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

Diff for /src/usr.bin/patch/pch.c between version 1.51 and 1.51.2.1

version 1.51, 2015/02/05 12:59:57 version 1.51.2.1, 2015/07/27 16:10:54
Line 1457 
Line 1457 
         }          }
         if (path == NULL && !assume_exists) {          if (path == NULL && !assume_exists) {
                 /*                  /*
                  * No files found, look for something we can checkout from                   * No files found, check to see if the diff could be
                  * RCS dirs.  Same order as above.                   * creating a new file.
                  */                   */
                 for (i = 0; i < MAX_FILE; i++) {  
                         if (names[i].path != NULL &&  
                             (path = checked_in(names[i].path)) != NULL)  
                                 break;  
                 }  
                 /*  
                  * Still no match?  Check to see if the diff could be creating  
                  * a new file.  
                  */  
                 if (path == NULL && ok_to_create_file &&                  if (path == NULL && ok_to_create_file &&
                     names[NEW_FILE].path != NULL)                      names[NEW_FILE].path != NULL)
                         path = names[NEW_FILE].path;                          path = names[NEW_FILE].path;
Line 1478 
Line 1469 
 }  }
   
 static char *  static char *
 compare_names(const struct file_name *names, bool assume_exists, int phase)  compare_names(const struct file_name *names, bool assume_exists)
 {  {
         size_t min_components, min_baselen, min_len, tmp;          size_t min_components, min_baselen, min_len, tmp;
         char *best = NULL;          char *best = NULL;
Line 1495 
Line 1486 
         min_components = min_baselen = min_len = SIZE_MAX;          min_components = min_baselen = min_len = SIZE_MAX;
         for (i = INDEX_FILE; i >= OLD_FILE; i--) {          for (i = INDEX_FILE; i >= OLD_FILE; i--) {
                 path = names[i].path;                  path = names[i].path;
                 if (path == NULL ||                  if (path == NULL || (!names[i].exists && !assume_exists))
                     (phase == 1 && !names[i].exists && !assume_exists) ||  
                     (phase == 2 && checked_in(path) == NULL))  
                         continue;                          continue;
                 if ((tmp = num_components(path)) > min_components)                  if ((tmp = num_components(path)) > min_components)
                         continue;                          continue;
Line 1528 
Line 1517 
 {  {
         char *best;          char *best;
   
         best = compare_names(names, assume_exists, 1);          best = compare_names(names, assume_exists);
         if (best == NULL) {  
                 best = compare_names(names, assume_exists, 2);          /* No match?  Check to see if the diff could be creating a new file. */
                 /*          if (best == NULL && ok_to_create_file)
                  * Still no match?  Check to see if the diff could be creating                  best = names[NEW_FILE].path;
                  * a new file.  
                  */  
                 if (best == NULL && ok_to_create_file &&  
                     names[NEW_FILE].path != NULL)  
                         best = names[NEW_FILE].path;  
         }  
         return best ? xstrdup(best) : NULL;          return best ? xstrdup(best) : NULL;
 }  }
   

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.51.2.1