Add -I or --index-first option to take Index: precedence over context diff,

as it was in hacked FreeBSD version
This commit is contained in:
Andrey A. Chernov 1998-01-21 15:10:14 +00:00
parent 249a716c6c
commit 8bf2e8c7e2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=32673
3 changed files with 32 additions and 5 deletions

View File

@ -1,8 +1,11 @@
.\" -*- nroff -*-
.rn '' }`
'\" $Header: /home/ncvs/src/gnu/usr.bin/patch/Attic/patch.1,v 1.5.2.1 1998/01/11 20:45:30 ache Exp $
'\" $Header: /home/ncvs/src/gnu/usr.bin/patch/patch.1,v 1.7 1998/01/21 14:37:21 ache Exp $
'\"
'\" $Log: patch.1,v $
'\" Revision 1.7 1998/01/21 14:37:21 ache
'\" Resurrect patch 2.1 without FreeBSD Index: hack
'\"
'\" Revision 1.5.2.1 1998/01/11 20:45:30 ache
'\" Back out rev1.5 change, Index: precedence restored to historycal behaviour
'\"
@ -335,6 +338,11 @@ Note that a larger fuzz factor increases the odds of a faulty patch.
The default fuzz factor is 2, and it may not be set to more than
the number of lines of context in the context diff, ordinarily 3.
.TP 5
.B "\-I, \-\-index-first"
forces
.I patch
to take ``Index:'' line precedence over context diff header.
.TP 5
.B "\-l, \-\-ignore\-whitespace"
causes the pattern matching to be done loosely, in case the tabs and
spaces have been munged in your input file.

View File

@ -1,5 +1,5 @@
char rcsid[] =
"$Header: /home/ncvs/src/gnu/usr.bin/patch/patch.c,v 1.9 1997/10/23 02:44:22 ache Exp $";
"$Header: /home/ncvs/src/gnu/usr.bin/patch/patch.c,v 1.11 1998/01/21 14:37:22 ache 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.11 1998/01/21 14:37:22 ache
* Resurrect patch 2.1 without FreeBSD Index: hack
*
* Revision 1.9 1997/10/23 02:44:22 ache
* Add (unsigned char) cast to ctype macros
*
@ -172,6 +175,9 @@ static int reverse_flag_specified = FALSE;
/* TRUE if -C was specified on command line. */
int check_patch = FALSE;
/* TRUE if -I was specified on command line. */
int index_first = FALSE;
/* Apply a set of diffs as appropriate. */
int
@ -485,7 +491,7 @@ reinitialize_almost_everything()
fatal1("you may not change to a different patch file\n");
}
static char *shortopts = "-b:B:cCd:D:eEfF:lnNo:p::r:RsStuvV:x:";
static char *shortopts = "-b:B:cCd:D:eEfF:IlnNo:p::r:RsStuvV:x:";
static struct option longopts[] =
{
{"suffix", 1, NULL, 'b'},
@ -498,6 +504,7 @@ static struct option longopts[] =
{"remove-empty-files", 0, NULL, 'E'},
{"force", 0, NULL, 'f'},
{"fuzz", 1, NULL, 'F'},
{"index-first", 0, NULL, 'I'},
{"ignore-whitespace", 0, NULL, 'l'},
{"normal", 0, NULL, 'n'},
{"forward", 0, NULL, 'N'},
@ -574,6 +581,9 @@ get_some_switches()
case 'F':
maxfuzz = atoi(optarg);
break;
case 'I':
index_first = TRUE;
break;
case 'l':
canonicalize = TRUE;
break;

View File

@ -1,6 +1,9 @@
/* $Header: /home/ncvs/src/gnu/usr.bin/patch/Attic/pch.c,v 1.8.2.2 1998/01/03 23:52:05 ache Exp $
/* $Header: /home/ncvs/src/gnu/usr.bin/patch/pch.c,v 1.13 1998/01/21 14:37:23 ache Exp $
*
* $Log: pch.c,v $
* Revision 1.13 1998/01/21 14:37:23 ache
* Resurrect patch 2.1 without FreeBSD Index: hack
*
* Revision 1.8.2.2 1998/01/03 23:52:05 ache
* MFC: ctype and Index over +++/--- precedence
*
@ -29,6 +32,9 @@
*
* Revision 1.8 1996/04/12 11:37:32 markm
* Attempt to break a $Log: pch.c,v $
* Attempt to break a Revision 1.13 1998/01/21 14:37:23 ache
* Attempt to break a Resurrect patch 2.1 without FreeBSD Index: hack
* Attempt to break a
* Attempt to break a Revision 1.8.2.2 1998/01/03 23:52:05 ache
* Attempt to break a MFC: ctype and Index over +++/--- precedence
* Attempt to break a
@ -322,6 +328,7 @@ intuit_diff_type()
char *newname = Nullch;
Reg11 int retval;
bool no_filearg = (filearg[0] == Nullch);
extern int index_first;
ok_to_create_file = FALSE;
Fseek(pfp, p_base, 0);
@ -431,7 +438,9 @@ intuit_diff_type()
oldname = fetchname(oldtmp, strippath, ok_to_create_file);
if (newtmp != Nullch)
newname = fetchname(newtmp, strippath, ok_to_create_file);
if (oldname && newname) {
if (index_first && indname)
filearg[0] = savestr(indname);
else if (oldname && newname) {
if (strlen(oldname) < strlen(newname))
filearg[0] = savestr(oldname);
else