summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/diff/diff.c
diff options
context:
space:
mode:
authorjtc <jtc@NetBSD.org>1993-11-12 02:25:52 +0000
committerjtc <jtc@NetBSD.org>1993-11-12 02:25:52 +0000
commitdbc9689292c21e5d6065de6864b1bb0c69c35b42 (patch)
tree26af35b0b580db7903ee2f0e439c2f0a279ffd80 /gnu/usr.bin/diff/diff.c
parentd8cd41a62ae45621d4ba897dc716c2f24ad9c9e8 (diff)
Upgraded to diffutils 2.6.
Diffstat (limited to 'gnu/usr.bin/diff/diff.c')
-rw-r--r--gnu/usr.bin/diff/diff.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/gnu/usr.bin/diff/diff.c b/gnu/usr.bin/diff/diff.c
index d5e7f8c09be..6541d99f6e9 100644
--- a/gnu/usr.bin/diff/diff.c
+++ b/gnu/usr.bin/diff/diff.c
@@ -18,7 +18,7 @@ along with GNU DIFF; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef lint
-static char *rcsid = "$Id: diff.c,v 1.5 1993/09/29 21:37:04 jtc Exp $";
+static char *rcsid = "$Id: diff.c,v 1.6 1993/11/12 02:25:55 jtc Exp $";
#endif
/* GNU DIFF was written by Mike Haertel, David Hayes,
@@ -46,7 +46,7 @@ static int specify_format PARAMS((char **, char *));
static void add_exclude PARAMS((char const *));
static void add_regexp PARAMS((struct regexp_list **, char const *));
static void specify_style PARAMS((enum output_style));
-static void usage PARAMS((void));
+static void usage PARAMS((char const *));
/* Nonzero for -r: if comparing two directories,
compare their common subdirectories recursively. */
@@ -216,6 +216,7 @@ static struct option const longopts[] =
{"unchanged-group-format", 1, 0, 138},
{"changed-group-format", 1, 0, 139},
{"horizon-lines", 1, 0, 140},
+ {"help", 0, 0, 141},
{0, 0, 0, 0}
};
@@ -454,8 +455,8 @@ main (argc, argv)
break;
case 'v':
- fprintf (stderr, "GNU diff version %s\n", version_string);
- break;
+ printf ("GNU diff version %s\n", version_string);
+ exit (0);
case 'w':
/* Ignore horizontal white space when comparing lines. */
@@ -531,14 +532,17 @@ main (argc, argv)
fatal ("horizon must be a nonnegative integer");
break;
+ case 141:
+ usage (0);
+
default:
- usage ();
+ usage ("");
}
prev = c;
}
if (optind != argc - 2)
- usage ();
+ usage (optind < argc - 2 ? "extra operand" : "missing operand");
{
@@ -626,33 +630,37 @@ add_regexp (reglist, pattern)
}
static void
-usage ()
+usage (reason)
+ char const *reason;
{
- fprintf (stderr, "Usage: %s [options] from-file to-file\n", program);
- fprintf (stderr, "Options:\n\
+ if (reason && *reason)
+ fprintf (stderr, "%s: %s\n", program, reason);
+ fflush (stderr);
+ printf ("Usage: %s [options] from-file to-file\n", program);
+ printf ("Options:\n\
[-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D name] [-F regexp]\n\
[-I regexp] [-L from-label [-L to-label]] [-S starting-file] [-U lines]\n\
[-W columns] [-x pattern] [-X pattern-file]\n");
- fprintf (stderr, "\
+ printf ("\
[--brief] [--changed-group-format=format] [--context[=lines]] [--ed]\n\
[--exclude=pattern] [--exclude-from=pattern-file] [--expand-tabs]\n\
- [--forward-ed] [--horizon-lines=lines] [--ifdef=name]\n\
+ [--forward-ed] [--help] [--horizon-lines=lines] [--ifdef=name]\n\
[--ignore-all-space] [--ignore-blank-lines] [--ignore-case]\n");
- fprintf (stderr, "\
+ printf ("\
[--ignore-matching-lines=regexp] [--ignore-space-change]\n\
[--initial-tab] [--label=from-label [--label=to-label]]\n\
[--left-column] [--minimal] [--new-file] [--new-group-format=format]\n\
[--new-line-format=format] [--old-group-format=format]\n");
- fprintf (stderr, "\
+ printf ("\
[--old-line-format=format] [--paginate] [--rcs] [--recursive]\n\
[--report-identical-files] [--sdiff-merge-assist] [--show-c-function]\n\
[--show-function-line=regexp] [--side-by-side] [--speed-large-files]\n\
[--starting-file=starting-file] [--suppress-common-lines] [--text]\n");
- fprintf (stderr, "\
+ printf ("\
[--unchanged-group-format=format] [--unchanged-line-format=format]\n\
[--unidirectional-new-file] [--unified[=lines]] [--version]\n\
[--width=columns]\n");
- exit (2);
+ exit (reason ? 2 : 0);
}
static int
@@ -751,6 +759,8 @@ compare_files (dir0, name0, dir1, name1, depth)
return 1;
}
+ bzero (inf, sizeof (inf));
+
/* Mark any nonexistent file with -1 in the desc field. */
/* Mark unopened files (e.g. directories) with -2. */
@@ -771,9 +781,6 @@ compare_files (dir0, name0, dir1, name1, depth)
for (i = 0; i <= 1; i++)
{
- bzero (&inf[i].stat, sizeof (struct stat));
- inf[i].dir_p = 0;
-
if (inf[i].desc != -1)
{
int stat_result;