summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-06-10 11:21:37 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-06-10 11:21:37 +0000
commit916d49f11456ff6dab90d7564c9d8184cb94df86 (patch)
tree530652422f53f9e78f6c068f517ff853f3149e6f /usr.bin
parenta7e831079363e3bb45f3172f6e59ba48e335682b (diff)
Support the long options that FSF's patch version has. $OpenBSD$ added
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/patch/EXTERN.h2
-rw-r--r--usr.bin/patch/INTERN.h2
-rw-r--r--usr.bin/patch/Makefile2
-rw-r--r--usr.bin/patch/backupfile.c4
-rw-r--r--usr.bin/patch/backupfile.h2
-rw-r--r--usr.bin/patch/common.h2
-rw-r--r--usr.bin/patch/config.h2
-rw-r--r--usr.bin/patch/inp.c4
-rw-r--r--usr.bin/patch/inp.h2
-rw-r--r--usr.bin/patch/malloc.c2
-rw-r--r--usr.bin/patch/patch.148
-rw-r--r--usr.bin/patch/patch.c84
-rw-r--r--usr.bin/patch/patchlevel.h2
-rw-r--r--usr.bin/patch/pch.c4
-rw-r--r--usr.bin/patch/pch.h2
-rw-r--r--usr.bin/patch/util.c4
-rw-r--r--usr.bin/patch/util.h2
-rw-r--r--usr.bin/patch/version.c4
-rw-r--r--usr.bin/patch/version.h2
19 files changed, 130 insertions, 46 deletions
diff --git a/usr.bin/patch/EXTERN.h b/usr.bin/patch/EXTERN.h
index 0238bf29056..c7eeb0f81b6 100644
--- a/usr.bin/patch/EXTERN.h
+++ b/usr.bin/patch/EXTERN.h
@@ -1,4 +1,4 @@
-/* $Id: EXTERN.h,v 1.1 1995/10/18 08:45:54 deraadt Exp $ */
+/* $OpenBSD: EXTERN.h,v 1.2 1996/06/10 11:21:23 niklas Exp $ */
#ifdef EXT
#undef EXT
diff --git a/usr.bin/patch/INTERN.h b/usr.bin/patch/INTERN.h
index da30be9879a..c13d9ed97f2 100644
--- a/usr.bin/patch/INTERN.h
+++ b/usr.bin/patch/INTERN.h
@@ -1,4 +1,4 @@
-/* $Id: INTERN.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $ */
+/* $OpenBSD: INTERN.h,v 1.2 1996/06/10 11:21:24 niklas Exp $ */
#ifdef EXT
#undef EXT
diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile
index 2c68ba3c675..2d47f3cb57e 100644
--- a/usr.bin/patch/Makefile
+++ b/usr.bin/patch/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.1 1995/10/18 08:45:55 deraadt Exp $
+# $OpenBSD: Makefile,v 1.2 1996/06/10 11:21:25 niklas Exp $
PROG= patch
SRCS= patch.c pch.c inp.c version.c util.c backupfile.c
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index 910a70807b9..1904a4e9b08 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: backupfile.c,v 1.2 1996/06/10 11:21:25 niklas Exp $ */
+
/* backupfile.c -- make Emacs style backup file names
Copyright (C) 1990 Free Software Foundation, Inc.
@@ -12,7 +14,7 @@
Some algorithms adapted from GNU Emacs. */
#ifndef lint
-static char rcsid[] = "$Id: backupfile.c,v 1.1 1995/10/18 08:45:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: backupfile.c,v 1.2 1996/06/10 11:21:25 niklas Exp $";
#endif /* not lint */
#include <stdio.h>
diff --git a/usr.bin/patch/backupfile.h b/usr.bin/patch/backupfile.h
index 5014fd1c02c..16881d2633b 100644
--- a/usr.bin/patch/backupfile.h
+++ b/usr.bin/patch/backupfile.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: backupfile.h,v 1.2 1996/06/10 11:21:26 niklas Exp $*/
/* backupfile.h -- declarations for making Emacs style backup file names
Copyright (C) 1990 Free Software Foundation, Inc.
@@ -8,7 +9,6 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- $Id: backupfile.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $
*/
/* When to make backup files. */
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index 4c0f9b0c90f..f3fcb5b144c 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,4 +1,4 @@
-/* $Id: common.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $ */
+/* $OpenBSD: common.h,v 1.2 1996/06/10 11:21:26 niklas Exp $ */
#define DEBUGGING
diff --git a/usr.bin/patch/config.h b/usr.bin/patch/config.h
index 1c7f493ef2c..ab735a85963 100644
--- a/usr.bin/patch/config.h
+++ b/usr.bin/patch/config.h
@@ -1,3 +1,4 @@
+/* * $OpenBSD: config.h,v 1.2 1996/06/10 11:21:27 niklas Exp $*/
/* config.h
* This file was produced by running the config.h.SH script, which
* gets its values from config.sh, which is generally produced by
@@ -7,7 +8,6 @@
* that running config.h.SH again will wipe out any changes you've made.
* For a more permanent change edit config.sh and rerun config.h.SH.
*
- * $Id: config.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $
*/
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index f061771e30a..e7661358124 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: inp.c,v 1.2 1996/06/10 11:21:28 niklas Exp $ */
+
#ifndef lint
-static char rcsid[] = "$Id: inp.c,v 1.1 1995/10/18 08:45:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.2 1996/06/10 11:21:28 niklas Exp $";
#endif /* not lint */
#include "EXTERN.h"
diff --git a/usr.bin/patch/inp.h b/usr.bin/patch/inp.h
index da25e6be9b0..1d0ed96ba88 100644
--- a/usr.bin/patch/inp.h
+++ b/usr.bin/patch/inp.h
@@ -1,4 +1,4 @@
-/* $Id: inp.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $ */
+/* $OpenBSD: inp.h,v 1.2 1996/06/10 11:21:29 niklas Exp $ */
EXT LINENUM input_lines INIT(0); /* how long is input file in lines */
EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */
diff --git a/usr.bin/patch/malloc.c b/usr.bin/patch/malloc.c
index d262e242d4f..60db44c77c8 100644
--- a/usr.bin/patch/malloc.c
+++ b/usr.bin/patch/malloc.c
@@ -1,6 +1,6 @@
+/* * $OpenBSD: malloc.c,v 1.2 1996/06/10 11:21:29 niklas Exp $*/
/*
* from: @(#)nmalloc.c 1 (Caltech) 2/21/82
- * $Id: malloc.c,v 1.1 1995/10/18 08:45:55 deraadt Exp $
*
* U of M Modified: 20 Jun 1983 ACT: strange hacks for Emacs
*
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1
index 123937f2336..8fb35d5bf4b 100644
--- a/usr.bin/patch/patch.1
+++ b/usr.bin/patch/patch.1
@@ -1,4 +1,4 @@
-.\" $Id: patch.1,v 1.1 1995/10/18 08:45:55 deraadt Exp $ -*- nroff -*-
+.\" $OpenBSD: patch.1,v 1.2 1996/06/10 11:21:30 niklas Exp $ -*- nroff -*-
.rn '' }`
.de Sh
.br
@@ -205,26 +205,26 @@ patch file, however.)
.I Patch
recognizes the following switches:
.TP 5
-.B \-b
+.B \-b or \-\-suffix
causes the next argument to be interpreted as the backup extension, to be
used in place of \*(L".orig\*(R" or \*(L"~\*(R".
.TP 5
-.B \-B
+.B \-B or \-\-prefix
causes the next argument to be interpreted as a prefix to the backup file
name. If this argument is specified any argument from -b will be ignored.
.TP 5
-.B \-c
+.B \-c or \-\-context
forces
.I patch
to interpret the patch file as a context diff.
.TP 5
-.B \-d
+.B \-d or \-\-directory
causes
.I patch
to interpret the next argument as a directory, and cd to it before doing
anything else.
.TP 5
-.B \-D
+.B \-D or \-\-ifdef
causes
.I patch
to use the "#ifdef...#endif" construct to mark changes.
@@ -233,17 +233,17 @@ Note that, unlike the C compiler, there must be a space between the
.B \-D
and the argument.
.TP 5
-.B \-e
+.B \-e or \-\-ed
forces
.I patch
to interpret the patch file as an ed script.
.TP 5
-.B \-E
+.B \-E or \-\-remove-empty-files
causes
.I patch
to remove output files that are empty after the patches have been applied.
.TP 5
-.B \-f
+.B \-f or \-\-force
forces
.I patch
to assume that the user knows exactly what he or she is doing, and to not
@@ -255,7 +255,7 @@ This option does not suppress commentary; use
.B \-s
for that.
.TP 5
-.B \-t
+.B \-t or \-\-batch
similar to
.BR \-f ,
in that it suppresses questions, but makes some different assumptions:
@@ -264,7 +264,7 @@ skip patches for which the file has the wrong version for the ``Prereq:'' line
in the patch; and assume that patches are reversed if they look like
they are.
.TP 5
-.B \-F<number>
+.B \-F<number> or \-\-fuzz <number>
sets the maximum fuzz factor.
This switch only applies to context diffs, and causes
.I patch
@@ -273,7 +273,7 @@ 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 \-l
+.B \-l or \-\-ignore-whitespace
causes the pattern matching to be done loosely, in case the tabs and
spaces have been munged in your input file.
Any sequence of whitespace in the pattern line will match any sequence
@@ -281,22 +281,22 @@ in the input file.
Normal characters must still match exactly.
Each line of the context must still match a line in the input file.
.TP 5
-.B \-n
+.B \-n or \-\-normal
forces
.I patch
to interpret the patch file as a normal diff.
.TP 5
-.B \-N
+.B \-N or \-\-forward
causes
.I patch
to ignore patches that it thinks are reversed or already applied.
See also
.B \-R .
.TP 5
-.B \-o
+.B \-o or \-\-output
causes the next argument to be interpreted as the output file name.
.TP 5
-.B \-p<number>
+.B \-p<number> or \-\-strip <number>
sets the pathname strip count,
which controls how pathnames found in the patch file are treated, in case
the you keep your files in a different directory than the person who sent
@@ -334,10 +334,10 @@ or the directory specified by the
.B \-d
switch.
.TP 5
-.B \-r
+.B \-r or \-\-reject-file
causes the next argument to be interpreted as the reject file name.
.TP 5
-.B \-R
+.B \-R or \-\-reverse
tells
.I patch
that this patch was created with the old and new files swapped.
@@ -366,12 +366,12 @@ Luckily, most patches add or change lines rather than delete them, so most
reversed normal diffs will begin with a delete, which will fail, triggering
the heuristic.)
.TP 5
-.B \-s
+.B \-s or \-\-quiet or \-\-silent
makes
.I patch
do its work silently, unless an error occurs.
.TP 5
-.B \-S
+.B \-S or \-\-skip
causes
.I patch
to ignore this patch from the patch file, but continue on looking
@@ -382,17 +382,17 @@ Thus
.sp
will ignore the first and second of three patches.
.TP 5
-.B \-u
+.B \-u or \-\-unified
forces
.I patch
to interpret the patch file as a unified context diff (a unidiff).
.TP 5
-.B \-v
+.B \-v or \-\-version
causes
.I patch
to print out its revision header and patch level.
.TP 5
-.B \-V
+.B \-V or \-\-version-control
causes the next argument to be interpreted as a method for creating
backup file names. The type of backups made can also be given in the
.B VERSION_CONTROL
@@ -423,7 +423,7 @@ This is the default.
Always make simple backups.
.RE
.TP 5
-.B \-x<number>
+.B \-x<number> or \-\-debug <number>
sets internal debugging flags, and is of interest only to
.I patch
patchers.
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 610512288aa..2c1a65ae97f 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: patch.c,v 1.2 1996/06/10 11:21:31 niklas Exp $ */
+
/* patch - a program to apply diffs to original files
*
* Copyright 1986, Larry Wall
@@ -7,7 +9,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: patch.c,v 1.1 1995/10/18 08:45:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.2 1996/06/10 11:21:31 niklas Exp $";
#endif /* not lint */
#include "INTERN.h"
@@ -367,6 +369,64 @@ nextarg()
return *++Argv;
}
+/* Module for handling of long options. */
+
+struct option {
+ char *long_opt;
+ char short_opt;
+};
+
+int
+optcmp(a, b)
+ struct option *a, *b;
+{
+ return strcmp (a->long_opt, b->long_opt);
+}
+
+/* Decode Long options beginning with "--" to their short equivalents. */
+
+char
+decode_long_option(opt)
+ char *opt;
+{
+ /* This table must be sorted on the first field. We also decode
+ unimplemented options as those will be handled later anyway. */
+ static struct option options[] = {
+ { "batch", 't' },
+ { "check", 'C' },
+ { "context", 'c' },
+ { "debug", 'x' },
+ { "directory", 'd' },
+ { "ed", 'e' },
+ { "force", 'f' },
+ { "forward", 'N' },
+ { "fuzz", 'F' },
+ { "ifdef", 'D' },
+ { "ignore-whitespace", 'l' },
+ { "normal", 'n' },
+ { "output", 'o' },
+ { "prefix", 'B' },
+ { "quiet", 's' },
+ { "reject-file", 'r' },
+ { "remove-empty-files", 'E' },
+ { "reverse", 'R' },
+ { "silent", 's' },
+ { "skip", 'S' },
+ { "strip", 'p' },
+ { "suffix", 'b' },
+ { "unified", 'u' },
+ { "version", 'v' },
+ { "version-control", 'V' },
+ };
+ struct option key, *found;
+
+ key.long_opt = opt;
+ found = (struct option *)bsearch(&key, options,
+ sizeof(options) / sizeof(options[0]),
+ sizeof(options[0]), optcmp);
+ return found ? found->short_opt : '\0';
+}
+
/* Process switches and filenames up to next '+' or end of list. */
void
@@ -390,7 +450,15 @@ get_some_switches()
filearg[filec++] = savestr(s);
}
else {
- switch (*++s) {
+ char opt;
+
+ if (*(s + 1) == '-') {
+ opt = decode_long_option(s + 2);
+ s += strlen(s) - 1;
+ }
+ else
+ opt = *++s;
+ switch (opt) {
case 'b':
simple_backup_suffix = savestr(nextarg());
break;
@@ -426,7 +494,9 @@ get_some_switches()
force = TRUE;
break;
case 'F':
- if (*++s == '=')
+ if (!*++s)
+ s = nextarg();
+ else if (*s == '=')
s++;
maxfuzz = atoi(s);
break;
@@ -443,7 +513,9 @@ get_some_switches()
outname = savestr(nextarg());
break;
case 'p':
- if (*++s == '=')
+ if (!*++s)
+ s = nextarg();
+ else if (*s == '=')
s++;
strippath = atoi(s);
break;
@@ -476,7 +548,9 @@ get_some_switches()
break;
#ifdef DEBUGGING
case 'x':
- debug = atoi(s+1);
+ if (!*++s)
+ s = nextarg();
+ debug = atoi(s);
break;
#endif
default:
diff --git a/usr.bin/patch/patchlevel.h b/usr.bin/patch/patchlevel.h
index 3f5970c175c..43c198dede5 100644
--- a/usr.bin/patch/patchlevel.h
+++ b/usr.bin/patch/patchlevel.h
@@ -1,3 +1,3 @@
-/* $Id: patchlevel.h,v 1.1 1995/10/18 08:45:55 deraadt Exp $ */
+/* $OpenBSD: patchlevel.h,v 1.2 1996/06/10 11:21:32 niklas Exp $ */
#define PATCHLEVEL "12u8"
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 98b93c6cfba..3d6caf2ef30 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: pch.c,v 1.2 1996/06/10 11:21:33 niklas Exp $ */
+
#ifndef lint
-static char rcsid[] = "$Id: pch.c,v 1.1 1995/10/18 08:45:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pch.c,v 1.2 1996/06/10 11:21:33 niklas Exp $";
#endif /* not lint */
#include "EXTERN.h"
diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h
index 520e9c92bcf..712c90a415c 100644
--- a/usr.bin/patch/pch.h
+++ b/usr.bin/patch/pch.h
@@ -1,4 +1,4 @@
-/* $Id: pch.h,v 1.1 1995/10/18 08:45:56 deraadt Exp $ */
+/* $OpenBSD: pch.h,v 1.2 1996/06/10 11:21:34 niklas Exp $ */
EXT FILE *pfp INIT(Nullfp); /* patch file pointer */
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 6ae9e0fd5c7..b67a0b8a5bd 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: util.c,v 1.2 1996/06/10 11:21:34 niklas Exp $ */
+
#ifndef lint
-static char rcsid[] = "$Id: util.c,v 1.1 1995/10/18 08:45:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.2 1996/06/10 11:21:34 niklas Exp $";
#endif /* not lint */
#include "EXTERN.h"
diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h
index 615e127365c..a396135b652 100644
--- a/usr.bin/patch/util.h
+++ b/usr.bin/patch/util.h
@@ -1,4 +1,4 @@
-/* $Id: util.h,v 1.1 1995/10/18 08:45:56 deraadt Exp $ */
+/* $OpenBSD: util.h,v 1.2 1996/06/10 11:21:35 niklas Exp $ */
/* and for those machine that can't handle a variable argument list */
diff --git a/usr.bin/patch/version.c b/usr.bin/patch/version.c
index 0687bc0f5a8..52da0ecf865 100644
--- a/usr.bin/patch/version.c
+++ b/usr.bin/patch/version.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: version.c,v 1.2 1996/06/10 11:21:35 niklas Exp $ */
+
#ifndef lint
-static char rcsid[] = "$Id: version.c,v 1.1 1995/10/18 08:45:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: version.c,v 1.2 1996/06/10 11:21:35 niklas Exp $";
#endif /* not lint */
#include "EXTERN.h"
diff --git a/usr.bin/patch/version.h b/usr.bin/patch/version.h
index 2dff743a295..17fa0d5bedf 100644
--- a/usr.bin/patch/version.h
+++ b/usr.bin/patch/version.h
@@ -1,3 +1,3 @@
-/* $Id: version.h,v 1.1 1995/10/18 08:45:56 deraadt Exp $ */
+/* $OpenBSD: version.h,v 1.2 1996/06/10 11:21:36 niklas Exp $ */
void version();