summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/inp.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>1998-11-25 00:30:25 +0000
committerespie <espie@openbsd.org>1998-11-25 00:30:25 +0000
commit2b3f4f7546efb6746c68c51595bb06f1af5f370d (patch)
treeb9f75b9e1181527aa374e8df8fbb5ff28fdde114 /usr.bin/patch/inp.c
parentsync (diff)
downloadwireguard-openbsd-2b3f4f7546efb6746c68c51595bb06f1af5f370d.tar.xz
wireguard-openbsd-2b3f4f7546efb6746c68c51595bb06f1af5f370d.zip
add -C
Diffstat (limited to 'usr.bin/patch/inp.c')
-rw-r--r--usr.bin/patch/inp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index f5f43659dd3..bab3562943a 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: inp.c,v 1.6 1997/09/22 05:45:26 millert Exp $ */
+/* $OpenBSD: inp.c,v 1.7 1998/11/25 00:30:25 espie Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: inp.c,v 1.6 1997/09/22 05:45:26 millert Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.7 1998/11/25 00:30:25 espie Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -11,6 +11,8 @@ static char rcsid[] = "$OpenBSD: inp.c,v 1.6 1997/09/22 05:45:26 millert Exp $";
#include "INTERN.h"
#include "inp.h"
+extern bool check_only;
+
/* Input-file-with-indexable-lines abstract type */
static off_t i_size; /* size of the input file */
@@ -80,10 +82,18 @@ char *filename;
if (statfailed && ok_to_create_file) {
if (verbose)
say2("(Creating file %s...)\n",filename);
+ /* in check_patch case, we still display `Creating file' even
+ though we're not. The rule is that -C should be as similar
+ to normal patch behavior as possible
+ */
+ if (check_only)
+ return TRUE;
makedirs(filename, TRUE);
close(creat(filename, 0666));
statfailed = stat(filename, &filestat);
}
+ if (statfailed && check_only)
+ fatal2("%s not found, -C mode, can't probe further\n", filename);
/* For nonexistent or read-only files, look for RCS or SCCS versions. */
if (statfailed
/* No one can write to it. */