summaryrefslogtreecommitdiff
path: root/usr.bin/patch/patch.c
diff options
context:
space:
mode:
authorkristerw <kristerw@NetBSD.org>2003-01-19 00:50:28 +0000
committerkristerw <kristerw@NetBSD.org>2003-01-19 00:50:28 +0000
commit6d0ebdd74a9082b8f3b9122849fa23d7d0eabc2b (patch)
tree205d9b806f5563994d7cba83948e16bf41a310c0 /usr.bin/patch/patch.c
parent3799cab605017c67b7f8c17b6bdc5faef2f862e8 (diff)
Do not try to write a rejects file for those cases where the user has
told us to skip a patch due to missing file to patch. Solves PR 19827 from Toru TAKAMIZU.
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r--usr.bin/patch/patch.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index d35da589e0c..bc039f37b6a 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: patch.c,v 1.12 2002/03/16 22:36:42 kristerw Exp $ */
+/* $NetBSD: patch.c,v 1.13 2003/01/19 00:50:28 kristerw Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -25,7 +25,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: patch.c,v 1.12 2002/03/16 22:36:42 kristerw Exp $");
+__RCSID("$NetBSD: patch.c,v 1.13 2003/01/19 00:50:28 kristerw Exp $");
#endif /* not lint */
#include "INTERN.h"
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
reinitialize_almost_everything()
) { /* for each patch in patch file */
- if (outname == NULL)
+ if (!skip_rest_of_patch && outname == NULL)
outname = xstrdup(filearg[0]);
/* for ed script just up and do it and exit */
@@ -314,20 +314,23 @@ main(int argc, char *argv[])
rejfp = NULL;
if (failed) {
failtotal += failed;
- if (!*rejname) {
- Strcpy(rejname, outname);
- Strcat(rejname, REJEXT);
- }
- if (skip_rest_of_patch) {
- say("%d out of %d hunks ignored--saving rejects to %s\n",
- failed, hunk, rejname);
- }
- else {
- say("%d out of %d hunks failed--saving rejects to %s\n",
- failed, hunk, rejname);
- }
- if (move_file(TMPREJNAME, rejname) < 0)
- trejkeep = TRUE;
+ if (outname != NULL) {
+ if (!*rejname) {
+ Strcpy(rejname, outname);
+ Strcat(rejname, REJEXT);
+ }
+ if (skip_rest_of_patch)
+ say("%d out of %d hunks ignored"
+ "--saving rejects to %s\n",
+ failed, hunk, rejname);
+ else
+ say("%d out of %d hunks failed"
+ "--saving rejects to %s\n",
+ failed, hunk, rejname);
+ if (move_file(TMPREJNAME, rejname) < 0)
+ trejkeep = TRUE;
+ } else
+ say("%d out of %d hunks ignored\n", failed, hunk);
}
set_signals(1);
}