=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/pch.c,v retrieving revision 1.41 retrieving revision 1.41.6.1 diff -c -r1.41 -r1.41.6.1 *** src/usr.bin/patch/pch.c 2013/11/26 13:19:07 1.41 --- src/usr.bin/patch/pch.c 2015/07/27 16:08:18 1.41.6.1 *************** *** 1,4 **** ! /* $OpenBSD: pch.c,v 1.41 2013/11/26 13:19:07 deraadt Exp $ */ /* * patch - a program to apply diffs to original files --- 1,4 ---- ! /* $OpenBSD: pch.c,v 1.41.6.1 2015/07/27 16:08:18 guenther Exp $ */ /* * patch - a program to apply diffs to original files *************** *** 1448,1465 **** } if (path == NULL && !assume_exists) { /* ! * No files found, look for something we can checkout from ! * RCS/SCCS 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; --- 1448,1456 ---- } 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; *************** *** 1469,1475 **** } 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; --- 1460,1466 ---- } static char * ! compare_names(const struct file_name *names, bool assume_exists) { size_t min_components, min_baselen, min_len, tmp; char *best = NULL; *************** *** 1486,1494 **** 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; --- 1477,1483 ---- 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; *************** *** 1519,1535 **** { 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 ? savestr(best) : NULL; } --- 1508,1519 ---- { 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 ? savestr(best) : NULL; }