aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2019-03-01 01:20:21 +0000
committerKyle Evans <kevans@FreeBSD.org>2019-03-01 01:20:21 +0000
commitef30b5a80910bd877f582248004200065eeb3ef5 (patch)
tree1b8c26650c4d2ea7dae4fe745ad995b5c8372bfb /usr.bin/patch
parente3431664dff30f3d9a7f324a2a1b88ca0c0d9886 (diff)
Notes
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/common.h1
-rw-r--r--usr.bin/patch/patch.c3
-rw-r--r--usr.bin/patch/pch.c3
3 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 1e69ee9b07fd..3253df27e684 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -64,6 +64,7 @@ extern size_t buf_size; /* size of general purpose buffer */
extern bool using_plan_a; /* try to keep everything in memory */
extern bool out_of_mem; /* ran out of memory in plan a */
+extern bool nonempty_patchf_seen; /* seen a non-zero-length patch file? */
#define MAXFILEC 2
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index b52919fe0467..8342dba688bc 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -53,6 +53,7 @@ size_t buf_size; /* size of the general purpose buffer */
bool using_plan_a = true; /* try to keep everything in memory */
bool out_of_mem = false; /* ran out of memory in plan a */
+bool nonempty_patchf_seen = false; /* seen nonempty patch file? */
#define MAXFILEC 2
@@ -419,7 +420,7 @@ main(int argc, char *argv[])
set_signals(1);
}
- if (!patch_seen)
+ if (!patch_seen && nonempty_patchf_seen)
error = 2;
my_exit(error);
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 0b583ea7eb31..50e1604b9b92 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -179,6 +179,9 @@ there_is_another_patch(void)
say("done\n");
return false;
}
+ if (p_filesize == 0)
+ return false;
+ nonempty_patchf_seen = true;
if (verbose)
say("Hmm...");
diff_type = intuit_diff_type();