Support the 1003.2-92 -i option to specify a patchfile;

fixes PR standards/11221.
This commit is contained in:
kleink 2000-10-16 07:05:04 +00:00
parent c64069308b
commit 961cdd38dd
2 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: patch.1,v 1.4 1996/09/19 06:27:12 thorpej Exp $ -*- nroff -*-
.\" $NetBSD: patch.1,v 1.5 2000/10/16 07:05:04 kleink Exp $ -*- nroff -*-
.rn '' }`
.de Sh
.br
@ -80,8 +80,13 @@ You may also specify where you want the output to go with a
switch; if that file already exists, it is backed up first.
.PP
If
no
.I patchfile
is omitted, or is a hyphen, the patch will be read from standard input.
argument is specified using the
.BR -i
option, and the
.I patchfile
argument is omitted, or is a hyphen, the patch will be read from standard input.
.PP
Upon startup, patch will attempt to determine the type of the diff listing,
unless over-ruled by a
@ -255,6 +260,9 @@ This option does not suppress commentary; use
.B \-s
for that.
.TP 5
.B \-i <patchfile> or \-\-patchfile <patchfile>
Read the patch to be applied from the specified file.
.TP 5
.B \-t or \-\-batch
similar to
.BR \-f ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: patch.c,v 1.7 1998/11/06 22:40:13 christos Exp $ */
/* $NetBSD: patch.c,v 1.8 2000/10/16 07:05:04 kleink Exp $ */
/* patch - a program to apply diffs to original files
*
@ -10,7 +10,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: patch.c,v 1.7 1998/11/06 22:40:13 christos Exp $");
__RCSID("$NetBSD: patch.c,v 1.8 2000/10/16 07:05:04 kleink Exp $");
#endif /* not lint */
#include "INTERN.h"
@ -424,6 +424,7 @@ decode_long_option(opt)
{ "ignore-whitespace", 'l' },
{ "normal", 'n' },
{ "output", 'o' },
{ "patchfile", 'i' },
{ "prefix", 'B' },
{ "quiet", 's' },
{ "reject-file", 'r' },
@ -466,6 +467,9 @@ get_some_switches()
if (*s != '-' || !s[1]) {
if (filec == MAXFILEC)
fatal1("too many file arguments\n");
if (filec == 1 && filearg[filec] != Nullch)
fatal1("-i option and patchfile argument are mutually\
exclusive\n");
filearg[filec++] = savestr(s);
}
else {
@ -518,6 +522,11 @@ get_some_switches()
s++;
maxfuzz = atoi(s);
break;
case 'i':
if (filearg[1] != Nullch)
free(filearg[1]);
filearg[1] = savestr(nextarg());
break;
case 'l':
canonicalize = TRUE;
break;