diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1998-01-03 23:52:05 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1998-01-03 23:52:05 +0000 |
| commit | 1255258cfca3179677e0c855d2920842e130757c (patch) | |
| tree | 39e113cba54c3b6ca8a1392f0b5ead59ab675a68 /gnu | |
| parent | 1da671d87c15704941f5a197cb1ab5be86ff8023 (diff) | |
Notes
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/usr.bin/patch/pch.c | 144 |
1 files changed, 116 insertions, 28 deletions
diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c index cc5d2c85e261..52f6ef2f25b1 100644 --- a/gnu/usr.bin/patch/pch.c +++ b/gnu/usr.bin/patch/pch.c @@ -1,6 +1,95 @@ -/* $Header: /home/ncvs/src/gnu/usr.bin/patch/pch.c,v 1.8 1996/04/12 11:37:32 markm Exp $ +/* $Header: /home/ncvs/src/gnu/usr.bin/patch/pch.c,v 1.11 1998/01/03 23:42:56 ache Exp $ + * + * $Log: pch.c,v $ + * Revision 1.11 1998/01/03 23:42:56 ache + * Back out Index over +++/--- precedence. + * It maybe right, if patch was FreeBSD-own program, but it break compatibility + * with pre-existent patches in other systems. + * The example is big ncurses patch which don't apply on FreeBSD + * due to "fixed" precedence. + * + * Revision 1.10 1997/10/23 02:44:22 ache + * Add (unsigned char) cast to ctype macros + * + * Revision 1.9 1997/02/13 21:10:43 jmg + * 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 + * + * Revision 1.8 1996/04/12 11:37:32 markm + * Attempt to break a $Log: pch.c,v $ + * Attempt to break a Revision 1.11 1998/01/03 23:42:56 ache + * Attempt to break a Back out Index over +++/--- precedence. + * Attempt to break a It maybe right, if patch was FreeBSD-own program, but it break compatibility + * Attempt to break a with pre-existent patches in other systems. + * Attempt to break a The example is big ncurses patch which don't apply on FreeBSD + * Attempt to break a due to "fixed" precedence. + * Attempt to break a + * Attempt to break a Revision 1.10 1997/10/23 02:44:22 ache + * Attempt to break a Add (unsigned char) cast to ctype macros + * Attempt to break a + * Attempt to break a Revision 1.9 1997/02/13 21:10:43 jmg + * Attempt to break a Fix a problem with patch in that is will always default, even when the + * Attempt to break a controlling terminal is closed. Now the function ask() will return 1 when th + * Attempt to break a input is known to come from a file or terminal, or it will return 0 when ther + * Attempt to break a was a read error. + * Attempt to break a + * Attempt to break a Modified the question "Skip patch?" so that on an error from ask it will skip + * Attempt to break a the patch instead of looping. + * Attempt to break a + * Attempt to break a Closes PR#777 + * Attempt to break a + * Attempt to break a 2.2 candidate + * Attempt to break a 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. + * this broke eg: + * Index: foo/Makefile + * ========== + * RCS <blah> + * Retrieving <blah> + * diff <blah> + * *** Makefile <blah> + * --- Makefile <blah> + * + * By trying to patch the Makefile in the _curent_ directory, rather than + * the one in the foo/ directory. + * + * Revision 1.6 1995/09/14 04:33:35 gibbs + * Give "Index" specified filenames preference over other filenames specified + * in the diff. This makes it so that diffs containing files in different + * subdirectories that have the same name not patch the same file. For example + * a diff with patches to Makefile, des/Makefile, usr.bin/Makefile would attempt + * to patch Makefile three times. + * + * Revision 1.5 1995/05/30 05:02:35 rgrimes + * Remove trailing whitespace. + * + * Revision 1.4 1994/02/25 21:46:07 phk + * added the -C/-check again. + * + * Revision 1.3 1994/02/17 22:20:36 jkh + * Put this back - I was somehow under the erroneous impression that patch was in + * ports, until I saw the the commit messages, that is! :-) All changed backed out. + * + * Revision 1.2 1994/02/17 22:16:05 jkh + * From Poul-Henning Kamp - Implement a -C option to verify the integrity of + * a patch before actually applying it. + * + * Revision 1.1.1.1 1993/06/19 14:21:52 paul + * b-maked patch-2.10 * - * Log: pch.c,v * Revision 2.0.2.0 90/05/01 22:17:51 davison * patch12u: unidiff support added * @@ -259,8 +348,8 @@ intuit_diff_type() else indent++; } - for (t=s; isdigit(*t) || *t == ','; t++) ; - this_is_a_command = (isdigit(*s) && + for (t=s; isdigit((unsigned char)*t) || *t == ','; t++) ; + this_is_a_command = (isdigit((unsigned char)*s) && (*t == 'd' || *t == 'c' || *t == 'a') ); if (first_command_line < 0L && this_is_a_command) { first_command_line = this_line; @@ -276,9 +365,9 @@ intuit_diff_type() else if (strnEQ(s, "Index:", 6)) indtmp = savestr(s+6); else if (strnEQ(s, "Prereq:", 7)) { - for (t=s+7; isspace(*t); t++) ; + for (t=s+7; isspace((unsigned char)*t); t++) ; revision = savestr(t); - for (t=revision; *t && !isspace(*t); t++) ; + for (t=revision; *t && !isspace((unsigned char)*t); t++) ; *t = '\0'; if (!*revision) { free(revision); @@ -336,14 +425,13 @@ intuit_diff_type() oldname = fetchname(oldtmp, strippath, ok_to_create_file); if (newtmp != Nullch) newname = fetchname(newtmp, strippath, ok_to_create_file); - if (indname) - filearg[0] = savestr(indname); - else if (oldname && newname) { + if (oldname && newname) { if (strlen(oldname) < strlen(newname)) filearg[0] = savestr(oldname); else filearg[0] = savestr(newname); - } + } else if (indname) + filearg[0] = savestr(indname); else if (oldname) filearg[0] = savestr(oldname); else if (newname) @@ -524,15 +612,15 @@ another_hunk() p_end--; return FALSE; } - for (s=buf; *s && !isdigit(*s); s++) ; + for (s=buf; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed (); if (strnEQ(s,"0,0",3)) strcpy(s,s+2); p_first = (LINENUM) atol(s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; + for (; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed (); p_ptrn_lines = ((LINENUM)atol(s)) - p_first + 1; @@ -590,13 +678,13 @@ another_hunk() return FALSE; } p_Char[p_end] = '='; - for (s=buf; *s && !isdigit(*s); s++) ; + for (s=buf; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed (); p_newfirst = (LINENUM) atol(s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; + for (; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed (); p_repl_lines = ((LINENUM)atol(s)) - p_newfirst + 1; @@ -624,7 +712,7 @@ another_hunk() change_line: if (buf[1] == '\n' && canonicalize) strcpy(buf+1," \n"); - if (!isspace(buf[1]) && buf[1] != '>' && buf[1] != '<' && + if (!isspace((unsigned char)buf[1]) && buf[1] != '>' && buf[1] != '<' && repl_beginning && repl_could_be_missing) { repl_missing = TRUE; goto hunk_done; @@ -660,7 +748,7 @@ another_hunk() } break; case ' ': - if (!isspace(buf[1]) && + if (!isspace((unsigned char)buf[1]) && repl_beginning && repl_could_be_missing) { repl_missing = TRUE; goto hunk_done; @@ -784,20 +872,20 @@ another_hunk() if (!*s) malformed (); p_first = (LINENUM) atol(s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; if (*s == ',') { p_ptrn_lines = (LINENUM) atol(++s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; } else p_ptrn_lines = 1; if (*s == ' ') s++; if (*s != '+' || !*++s) malformed (); p_newfirst = (LINENUM) atol(s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; if (*s == ',') { p_repl_lines = (LINENUM) atol(++s); - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; } else p_repl_lines = 1; if (*s == ' ') s++; @@ -919,15 +1007,15 @@ another_hunk() p_context = 0; ret = pgets(buf, sizeof buf, pfp); p_input_line++; - if (ret == Nullch || !isdigit(*buf)) { + if (ret == Nullch || !isdigit((unsigned char)*buf)) { next_intuit_at(line_beginning,p_input_line); return FALSE; } p_first = (LINENUM)atol(buf); - for (s=buf; isdigit(*s); s++) ; + for (s=buf; isdigit((unsigned char)*s); s++) ; if (*s == ',') { p_ptrn_lines = (LINENUM)atol(++s) - p_first + 1; - while (isdigit(*s)) s++; + while (isdigit((unsigned char)*s)) s++; } else p_ptrn_lines = (*s != 'a'); @@ -935,7 +1023,7 @@ another_hunk() if (hunk_type == 'a') p_first++; /* do append rather than insert */ min = (LINENUM)atol(++s); - for (; isdigit(*s); s++) ; + for (; isdigit((unsigned char)*s); s++) ; if (*s == ',') max = (LINENUM)atol(++s); else @@ -1269,8 +1357,8 @@ do_ed_script() break; } p_input_line++; - for (t=buf; isdigit(*t) || *t == ','; t++) ; - this_line_is_command = (isdigit(*buf) && + for (t=buf; isdigit((unsigned char)*t) || *t == ','; t++) ; + this_line_is_command = (isdigit((unsigned char)*buf) && (*t == 'd' || *t == 'c' || *t == 'a') ); if (this_line_is_command) { if (!skip_rest_of_patch) |
