=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/pch.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- src/usr.bin/patch/pch.c 2015/02/05 12:59:57 1.51 +++ src/usr.bin/patch/pch.c 2015/07/26 14:32:19 1.52 @@ -1,4 +1,4 @@ -/* $OpenBSD: pch.c,v 1.51 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: pch.c,v 1.52 2015/07/26 14:32:19 millert Exp $ */ /* * patch - a program to apply diffs to original files @@ -1457,18 +1457,9 @@ } if (path == NULL && !assume_exists) { /* - * No files found, look for something we can checkout from - * RCS dirs. Same order as above. + * No files found, check to see if the diff could be + * 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 && names[NEW_FILE].path != NULL) path = names[NEW_FILE].path; @@ -1478,7 +1469,7 @@ } 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; char *best = NULL; @@ -1495,9 +1486,7 @@ min_components = min_baselen = min_len = SIZE_MAX; for (i = INDEX_FILE; i >= OLD_FILE; i--) { path = names[i].path; - if (path == NULL || - (phase == 1 && !names[i].exists && !assume_exists) || - (phase == 2 && checked_in(path) == NULL)) + if (path == NULL || (!names[i].exists && !assume_exists)) continue; if ((tmp = num_components(path)) > min_components) continue; @@ -1528,17 +1517,12 @@ { char *best; - best = compare_names(names, assume_exists, 1); - if (best == NULL) { - best = compare_names(names, assume_exists, 2); - /* - * Still no match? Check to see if the diff could be creating - * a new file. - */ - if (best == NULL && ok_to_create_file && - names[NEW_FILE].path != NULL) - best = names[NEW_FILE].path; - } + best = compare_names(names, assume_exists); + + /* No match? Check to see if the diff could be creating a new file. */ + if (best == NULL && ok_to_create_file) + best = names[NEW_FILE].path; + return best ? xstrdup(best) : NULL; }