diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-30 16:45:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-30 16:45:45 +0000 |
commit | 9c3623342734efd6744d1fa28a1e0b4b40a2336c (patch) | |
tree | 3a35799e389cf4e8081376a3b1fe011d5c86ce40 | |
parent | 009de441745dc02901cedf9c335c4fe63a57ec9f (diff) |
Add POSIX -i option; tedu@ OK
-rw-r--r-- | usr.bin/patch/patch.1 | 6 | ||||
-rw-r--r-- | usr.bin/patch/patch.c | 28 |
2 files changed, 24 insertions, 10 deletions
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 index 9f2cfc4d5dd..ccbe89c79a9 100644 --- a/usr.bin/patch/patch.1 +++ b/usr.bin/patch/patch.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: patch.1,v 1.14 2003/07/28 18:34:36 otto Exp $ +.\" $OpenBSD: patch.1,v 1.15 2003/07/30 16:45:44 millert Exp $ .\" Copyright 1986, Larry Wall .\" .\" Redistribution and use in source and binary forms, with or without @@ -274,6 +274,10 @@ to ignore up to that many lines in looking for places to install a hunk. 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. +.It Fl i , Fl Fl input +Causes the next argument to be interpreted as the input file name +(i.e. a patchfile). +This option may be specified multiple times. .It Fl l , Fl Fl ignore-whitespace Causes the pattern matching to be done loosely, in case the tabs and spaces have been munged in your input file. diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 7e847065947..b88036cb324 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.31 2003/07/29 20:10:17 millert Exp $ */ +/* $OpenBSD: patch.c,v 1.32 2003/07/30 16:45:44 millert Exp $ */ /* * patch - a program to apply diffs to original files @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: patch.c,v 1.31 2003/07/29 20:10:17 millert Exp $"; +static const char rcsid[] = "$OpenBSD: patch.c,v 1.32 2003/07/30 16:45:44 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -436,7 +436,7 @@ reinitialize_almost_everything(void) static void get_some_switches(void) { - const char *options = "b::B:cCd:D:eEfF:lnNo:p::r:RstuvV:x:z:"; + const char *options = "b::B:cCd:D:eEfF:i:lnNo:p::r:RstuvV:x:z:"; static struct option longopts[] = { {"backup", no_argument, 0, 'b'}, {"batch", no_argument, 0, 't'}, @@ -449,6 +449,7 @@ get_some_switches(void) {"forward", no_argument, 0, 'N'}, {"fuzz", required_argument, 0, 'F'}, {"ifdef", required_argument, 0, 'D'}, + {"input", required_argument, 0, 'i'}, {"ignore-whitespace", no_argument, 0, 'l'}, {"normal", no_argument, 0, 'n'}, {"output", required_argument, 0, 'o'}, @@ -526,6 +527,11 @@ get_some_switches(void) case 'F': maxfuzz = atoi(optarg); break; + case 'i': + if (++filec == MAXFILEC) + fatal("too many file arguments\n"); + filearg[filec] = savestr(optarg); + break; case 'l': canonicalize = TRUE; break; @@ -578,11 +584,15 @@ get_some_switches(void) Argc -= optind; Argv += optind; - while (Argc > 0) { - if (filec == MAXFILEC) - fatal("too many file arguments\n"); - filearg[filec++] = savestr(*Argv++); + if (Argc > 0) { + filearg[0] = savestr(*Argv++); Argc--; + while (Argc > 0) { + if (++filec == MAXFILEC) + fatal("too many file arguments\n"); + filearg[filec] = savestr(*Argv++); + Argc--; + } } } @@ -591,8 +601,8 @@ usage(void) { fprintf(stderr, "usage: patch [-bcCeEflnNRstuv] [-B backup-prefix] [-d directory] [-D symbol]\n" -" [-Fmax-fuzz] [-o out-file] [-p[strip-count]] [-r rej-name]\n" -" [-V {numbered,existing,simple}] [-z backup-ext]\n" +" [-Fmax-fuzz] [-i patchfile] [-o out-file] [-p[strip-count]]\n" +" [-r rej-name] [-V {numbered,existing,simple}] [-z backup-ext]\n" " [origfile [patchfile]]\n"); my_exit(EXIT_SUCCESS); } |