diff options
author | jmg <jmg@FreeBSD.org> | 1997-02-13 21:10:45 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 1997-02-13 21:10:45 +0000 |
commit | fddb79c0af0d4bf9176b52713c0df1c2bafe48e5 (patch) | |
tree | 3913a51d4c09be4a013b66307b63291d4e50768a /gnu/usr.bin | |
parent | 8f1bd632d4528e09dc9ca0ed45397ded3364d354 (diff) | |
download | FreeBSD-src-fddb79c0af0d4bf9176b52713c0df1c2bafe48e5.zip FreeBSD-src-fddb79c0af0d4bf9176b52713c0df1c2bafe48e5.tar.gz |
Fix a problem with patch in that is will always default, even when the
controlling terminal is closed. Now the function ask() will return 1 when th
input is known to come from a file or terminal, or it will return 0 when ther
was a read error.
Modified the question "Skip patch?" so that on an error from ask it will skip
the patch instead of looping.
Closes PR#777
2.2 candidate
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/patch/Makefile | 2 | ||||
-rw-r--r-- | gnu/usr.bin/patch/inp.c | 9 | ||||
-rw-r--r-- | gnu/usr.bin/patch/patch.c | 9 | ||||
-rw-r--r-- | gnu/usr.bin/patch/pch.c | 15 | ||||
-rw-r--r-- | gnu/usr.bin/patch/util.c | 11 | ||||
-rw-r--r-- | gnu/usr.bin/patch/util.h | 7 |
6 files changed, 37 insertions, 16 deletions
diff --git a/gnu/usr.bin/patch/Makefile b/gnu/usr.bin/patch/Makefile index 4d5fad2..d16f628 100644 --- a/gnu/usr.bin/patch/Makefile +++ b/gnu/usr.bin/patch/Makefile @@ -1,6 +1,6 @@ PROG= patch SRCS = backupfile.c getopt.c getopt1.c inp.c patch.c pch.c util.c \ version.c -CFLAGS += -DHAVE_CONFIG_H +CFLAGS += -DHAVE_CONFIG_H -Wall MAN= patch.1 .include <bsd.prog.mk> diff --git a/gnu/usr.bin/patch/inp.c b/gnu/usr.bin/patch/inp.c index e8e1531..7b78651 100644 --- a/gnu/usr.bin/patch/inp.c +++ b/gnu/usr.bin/patch/inp.c @@ -1,6 +1,9 @@ -/* $Header: /home/ncvs/src/gnu/usr.bin/patch/inp.c,v 1.2 1995/01/12 22:09:39 hsu Exp $ +/* $Header: /usr/cvs/src/gnu/usr.bin/patch/inp.c,v 1.3 1995/05/30 05:02:31 rgrimes Exp $ * * $Log: inp.c,v $ + * Revision 1.3 1995/05/30 05:02:31 rgrimes + * Remove trailing whitespace. + * * Revision 1.2 1995/01/12 22:09:39 hsu * Fix bug that created new files even when running in -C check mode. * Reviewed by: phk @@ -240,7 +243,7 @@ char *filename; "this file doesn't appear to be the %s version--aborting.\n", revision); } else { - ask2( + (void) ask2( "This file doesn't appear to be the %s version--patch anyway? [n] ", revision); if (*buf != 'y') @@ -289,7 +292,7 @@ char *filename; "this file doesn't appear to be the %s version--aborting.\n", revision); } else { - ask2( + (void) ask2( "This file doesn't appear to be the %s version--patch anyway? [n] ", revision); if (*buf != 'y') diff --git a/gnu/usr.bin/patch/patch.c b/gnu/usr.bin/patch/patch.c index b03d065..2329ec8 100644 --- a/gnu/usr.bin/patch/patch.c +++ b/gnu/usr.bin/patch/patch.c @@ -1,5 +1,5 @@ char rcsid[] = - "$Header: /home/ncvs/src/gnu/usr.bin/patch/patch.c,v 1.5 1995/01/12 22:09:40 hsu Exp $"; + "$Header: /usr/cvs/src/gnu/usr.bin/patch/patch.c,v 1.6 1995/05/30 05:02:34 rgrimes Exp $"; /* patch - a program to apply diffs to original files * @@ -9,6 +9,9 @@ char rcsid[] = * money off of it, or pretend that you wrote it. * * $Log: patch.c,v $ + * Revision 1.6 1995/05/30 05:02:34 rgrimes + * Remove trailing whitespace. + * * Revision 1.5 1995/01/12 22:09:40 hsu * Fix bug that created new files even when running in -C check mode. * Reviewed by: phk @@ -296,12 +299,12 @@ char **argv; reverse ? "Assuming" : "Ignoring"); } else { - ask3( + (void) ask3( "%seversed (or previously applied) patch detected! %s -R? [y] ", reverse ? "R" : "Unr", reverse ? "Assume" : "Ignore"); if (*buf == 'n') { - ask1("Apply anyway? [n] "); + (void) ask1("Apply anyway? [n] "); if (*buf == 'y') rev_okayed = TRUE; else diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c index eb0c54a..c976838 100644 --- a/gnu/usr.bin/patch/pch.c +++ b/gnu/usr.bin/patch/pch.c @@ -1,6 +1,10 @@ -/* $Header: /home/ncvs/src/gnu/usr.bin/patch/pch.c,v 1.7 1996/04/11 10:13:40 markm Exp $ +/* $Header: /usr/cvs/src/gnu/usr.bin/patch/pch.c,v 1.8 1996/04/12 11:37:32 markm Exp $ * * $Log: pch.c,v $ + * Revision 1.8 1996/04/12 11:37:32 markm + * Attempt to break a $Log$ snafu where a *** /--- (minus space) + * was fouling up a comment in the checked-out code. + * * Revision 1.7 1996/04/11 10:13:40 markm * Priorities were broken. If there was an Index: line and *** /--- lines * with valid names, the *** /---names were taken first. @@ -219,7 +223,7 @@ there_is_another_patch() skip_rest_of_patch = TRUE; return TRUE; } - ask1("File to patch: "); + (void) ask1("File to patch: "); if (*buf != '\n') { if (bestguess) free(bestguess); @@ -227,9 +231,10 @@ there_is_another_patch() filearg[0] = fetchname(buf, 0, FALSE); } if (filearg[0] == Nullch) { - ask1("No file found--skip this patch? [n] "); - if (*buf != 'y') { - continue; + if (ask1("No file found--skip this patch? [n] ")) { + if (*buf != 'y') { + continue; + } } if (verbose) say1("Skipping patch...\n"); diff --git a/gnu/usr.bin/patch/util.c b/gnu/usr.bin/patch/util.c index 56ce12e..6c00880 100644 --- a/gnu/usr.bin/patch/util.c +++ b/gnu/usr.bin/patch/util.c @@ -227,7 +227,7 @@ long arg1,arg2,arg3; /* Get a response from the user, somehow or other. */ -void +int ask(pat,arg1,arg2,arg3) char *pat; long arg1,arg2,arg3; @@ -260,7 +260,9 @@ long arg1,arg2,arg3; } else { /* no terminal at all--default it */ buf[0] = '\n'; - r = 1; + buf[1] = 0; + say1(buf); + return 0; /* signal possible error */ } if (r <= 0) buf[0] = 0; @@ -268,6 +270,11 @@ long arg1,arg2,arg3; buf[r] = '\0'; if (!tty2) say1(buf); + + if (r <= 0) + return 0; /* if there was an error, return it */ + else + return 1; } #endif /* lint */ diff --git a/gnu/usr.bin/patch/util.h b/gnu/usr.bin/patch/util.h index c56b4c3..4260928 100644 --- a/gnu/usr.bin/patch/util.h +++ b/gnu/usr.bin/patch/util.h @@ -1,6 +1,9 @@ -/* $Header: /home/ncvs/src/gnu/usr.bin/patch/util.h,v 1.1.1.1 1993/06/19 14:21:52 paul Exp $ +/* $Header: /usr/cvs/src/gnu/usr.bin/patch/util.h,v 1.2 1995/05/30 05:02:38 rgrimes Exp $ * * $Log: util.h,v $ + * Revision 1.2 1995/05/30 05:02:38 rgrimes + * Remove trailing whitespace. + * * Revision 1.1.1.1 1993/06/19 14:21:52 paul * b-maked patch-2.10 * @@ -83,7 +86,7 @@ void copy_file(); void say(); void fatal(); void pfatal(); -void ask(); +int ask(); char *savestr(); void set_signals(); void ignore_signals(); |