[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.2

version 1.51, 2015/02/05 12:59:57 version 1.51.2.2, 2015/07/31 18:34:30
Line 1402 
Line 1402 
                     *t != '\0' && strchr("acdis", *t) != NULL) {                      *t != '\0' && strchr("acdis", *t) != NULL) {
                         if (pipefp != NULL)                          if (pipefp != NULL)
                                 fputs(buf, pipefp);                                  fputs(buf, pipefp);
                         if (*t != 'd' && *t != 's') {                          if (*t == 's') {
                                   for (;;) {
                                           bool continued = false;
                                           t = buf + strlen(buf) - 1;
                                           while (--t >= buf && *t == '\\')
                                                   continued = !continued;
                                           if (!continued ||
                                               pgets(buf, sizeof buf, pfp) == NULL)
                                                   break;
                                           if (pipefp != NULL)
                                                   fputs(buf, pipefp);
                                   }
                           } else if (*t != 'd') {
                                 while (pgets(buf, sizeof buf, pfp) != NULL) {                                  while (pgets(buf, sizeof buf, pfp) != NULL) {
                                         p_input_line++;                                          p_input_line++;
                                         if (pipefp != NULL)                                          if (pipefp != NULL)
Line 1457 
Line 1469 
         }          }
         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 1481 
 }  }
   
 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 1498 
         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 1529 
 {  {
         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.2