=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/pch.c,v retrieving revision 1.51 retrieving revision 1.52 diff -c -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 **** ! /* $OpenBSD: pch.c,v 1.51 2015/02/05 12:59:57 millert Exp $ */ /* * patch - a program to apply diffs to original files --- 1,4 ---- ! /* $OpenBSD: pch.c,v 1.52 2015/07/26 14:32:19 millert Exp $ */ /* * patch - a program to apply diffs to original files *************** *** 1457,1474 **** } if (path == NULL && !assume_exists) { /* ! * No files found, look for something we can checkout from ! * RCS dirs. Same order as above. */ - 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; --- 1457,1465 ---- } if (path == NULL && !assume_exists) { /* ! * No files found, 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,1484 **** } static char * ! compare_names(const struct file_name *names, bool assume_exists, int phase) { size_t min_components, min_baselen, min_len, tmp; char *best = NULL; --- 1469,1475 ---- } static char * ! compare_names(const struct file_name *names, bool assume_exists) { size_t min_components, min_baselen, min_len, tmp; char *best = NULL; *************** *** 1495,1503 **** 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)) continue; if ((tmp = num_components(path)) > min_components) continue; --- 1486,1492 ---- min_components = min_baselen = min_len = SIZE_MAX; for (i = INDEX_FILE; i >= OLD_FILE; i--) { path = names[i].path; ! if (path == NULL || (!names[i].exists && !assume_exists)) continue; if ((tmp = num_components(path)) > min_components) continue; *************** *** 1528,1544 **** { 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; ! } return best ? xstrdup(best) : NULL; } --- 1517,1528 ---- { char *best; ! 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; }