diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-07 18:16:03 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-09-07 18:16:03 +0000 |
commit | 489d46253d126ce011dfd7bd1e98d466890987e4 (patch) | |
tree | d28ffee1731e95051ef385c5cbc3186812689952 /usr.bin | |
parent | dc610acf459d7a6a8287417ced436fd5dfc4d546 (diff) |
try again at -u#. ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/diff/diff.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 2ace748a852..49244bb99fe 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.39 2003/09/06 05:25:22 tedu Exp $ */ +/* $OpenBSD: diff.c,v 1.40 2003/09/07 18:16:02 tedu Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff.c,v 1.39 2003/09/06 05:25:22 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: diff.c,v 1.40 2003/09/07 18:16:02 tedu Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -46,7 +46,7 @@ char *start, *ifdefname, *diffargs, *label; struct stat stb1, stb2; struct excludes *excludes_list; -#define OPTIONS "abC:c::dD:efhiL:lnNPqrS:sTtU:u::wX:x:" +#define OPTIONS "0123456789abC:cdD:efhiL:lnNPqrS:sTtU:uwX:x:" static struct option longopts[] = { { "text", no_argument, 0, 'a' }, { "ignore-space-change", no_argument, 0, 'b' }, @@ -84,13 +84,23 @@ main(int argc, char **argv) { char *ep, **oargv; long l; - int ch, gotstdin; + int ch, lastch, gotstdin; oargv = argv; gotstdin = 0; + lastch = 0; while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (!(lastch == 'c' || lastch == 'u' || + (lastch >= '0' && lastch <= '9'))) + usage(); + if (lastch == 'c' || lastch == 'u') + context = 0; + context = context * 10 + ch - '0'; + break; case 'a': aflag = 1; break; @@ -185,6 +195,7 @@ main(int argc, char **argv) usage(); break; } + lastch = ch; } argc -= optind; argv += optind; |