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
This commit is contained in:
parent
8f1bd632d4
commit
fddb79c0af
@ -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>
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
@ -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,10 +231,11 @@ there_is_another_patch()
|
||||
filearg[0] = fetchname(buf, 0, FALSE);
|
||||
}
|
||||
if (filearg[0] == Nullch) {
|
||||
ask1("No file found--skip this patch? [n] ");
|
||||
if (ask1("No file found--skip this patch? [n] ")) {
|
||||
if (*buf != 'y') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
say1("Skipping patch...\n");
|
||||
filearg[0] = fetchname(bestguess, 0, TRUE);
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user