[BACK]Return to dir.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/dir.c between version 1.53 and 1.54

version 1.53, 2007/09/17 09:28:36 version 1.54, 2007/09/17 12:04:29
Line 356 
Line 356 
         LstNode ln;     /* a list element */          LstNode ln;     /* a list element */
         char *file;     /* the current filename to check */          char *file;     /* the current filename to check */
         char *temp;     /* index into file */          char *temp;     /* index into file */
         const char *cp; /* index of first slash, if any */          const char *basename;
         bool hasSlash;          bool hasSlash;
         struct stat stb;/* Buffer for stat, if necessary */          struct stat stb;/* Buffer for stat, if necessary */
         struct file_stamp *entry;          struct file_stamp *entry;
Line 366 
Line 366 
   
         /* Find the final component of the name and note whether name has a          /* Find the final component of the name and note whether name has a
          * slash in it */           * slash in it */
         cp = Str_rchri(name, ename, '/');          basename = Str_rchri(name, ename, '/');
         if (cp) {          if (basename) {
                 hasSlash = true;                  hasSlash = true;
                 cp++;                  basename++;
         } else {          } else {
                 hasSlash = false;                  hasSlash = false;
                 cp = name;                  basename = name;
         }          }
   
         hv = ohash_interval(cp, &ename);          hv = ohash_interval(basename, &ename);
   
         if (DEBUG(DIR))          if (DEBUG(DIR))
                 printf("Searching for %s...", name);                  printf("Searching for %s...", name);
Line 383 
Line 383 
          * the file in the current directory before anywhere else           * the file in the current directory before anywhere else
          * and we always return exactly what the caller specified. */           * and we always return exactly what the caller specified. */
         if (checkCurdirFirst &&          if (checkCurdirFirst &&
             (!hasSlash || (cp - name == 2 && *name == '.')) &&              (!hasSlash || (basename - name == 2 && *name == '.')) &&
             find_file_hashi(dot, cp, ename, hv) != NULL) {              find_file_hashi(dot, basename, ename, hv) != NULL) {
                 if (DEBUG(DIR))                  if (DEBUG(DIR))
                         printf("in '.'\n");                          printf("in '.'\n");
                 return Str_dupi(name, ename);                  return Str_dupi(name, ename);
Line 399 
Line 399 
                 p = (struct PathEntry *)Lst_Datum(ln);                  p = (struct PathEntry *)Lst_Datum(ln);
                 if (DEBUG(DIR))                  if (DEBUG(DIR))
                         printf("%s...", p->name);                          printf("%s...", p->name);
                 if (find_file_hashi(p, cp, ename, hv) != NULL) {                  if (find_file_hashi(p, basename, ename, hv) != NULL) {
                         if (DEBUG(DIR))                          if (DEBUG(DIR))
                                 printf("here...");                                  printf("here...");
                         if (hasSlash) {                          if (hasSlash) {
Line 412 
Line 412 
                                  * part of one of the components of p along                                   * part of one of the components of p along
                                  * with all the rest of them (*p1 != '/').  */                                   * with all the rest of them (*p1 != '/').  */
                                 p1 = p->name + strlen(p->name) - 1;                                  p1 = p->name + strlen(p->name) - 1;
                                 p2 = cp - 2;                                  p2 = basename - 2;
                                 while (p2 >= name && p1 >= p->name &&                                  while (p2 >= name && p1 >= p->name &&
                                     *p1 == *p2) {                                      *p1 == *p2) {
                                         p1--;                                          p1--;
Line 425 
Line 425 
                                         continue;                                          continue;
                                 }                                  }
                         }                          }
                         file = Str_concati(p->name, strchr(p->name, '\0'), cp,                          file = Str_concati(p->name, strchr(p->name, '\0'),
                             ename, '/');                              basename, ename, '/');
                         if (DEBUG(DIR))                          if (DEBUG(DIR))
                                 printf("returning %s\n", file);                                  printf("returning %s\n", file);
                         return file;                          return file;
Line 438 
Line 438 
                         for (p1 = p->name, p2 = name; *p1 && *p1 == *p2;                          for (p1 = p->name, p2 = name; *p1 && *p1 == *p2;
                             p1++, p2++)                              p1++, p2++)
                                 continue;                                  continue;
                         if (*p1 == '\0' && p2 == cp - 1) {                          if (*p1 == '\0' && p2 == basename - 1) {
                                 if (DEBUG(DIR))                                  if (DEBUG(DIR))
                                         printf("has to be here but isn't -- returning NULL\n");                                          printf("has to be here but isn't -- returning NULL\n");
                                 return NULL;                                  return NULL;

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54