diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-01-10 13:48:03 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-01-10 13:48:03 +0000 |
commit | cd0ff92a635cb2983ae67f969431e5b690748081 (patch) | |
tree | 47c894bc12166b03c5902b99fb3f6b8d0580a06e /usr.bin/grep | |
parent | 791897c6c33eb80bf8091f78e2e80f83c175cef5 (diff) |
1. They're flags, not counters. Set to one instead of incrementing.
2. The G flag is useless and never checked. Remove it.
ok millert
Diffstat (limited to 'usr.bin/grep')
-rw-r--r-- | usr.bin/grep/grep.c | 34 | ||||
-rw-r--r-- | usr.bin/grep/grep.h | 4 |
2 files changed, 15 insertions, 23 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 8d844564cd2..532d670ee69 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.48 2014/12/01 06:36:04 deraadt Exp $ */ +/* $OpenBSD: grep.c,v 1.49 2015/01/10 13:48:02 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -61,7 +61,6 @@ int Aflag; /* -A x: print x lines trailing each match */ int Bflag; /* -B x: print x lines leading each match */ int Eflag; /* -E: interpret pattern as extended regexp */ int Fflag; /* -F: interpret pattern as list of fixed strings */ -int Gflag; /* -G: interpret pattern as basic regexp */ int Hflag; /* -H: always print filename header */ int Lflag; /* -L: only show names of files with no matches */ int Rflag; /* -R: recursively search directory trees */ @@ -242,26 +241,20 @@ main(int argc, char *argv[]) SLIST_INIT(&patfilelh); switch (__progname[0]) { case 'e': - Eflag++; + Eflag = 1; break; case 'f': - Fflag++; - break; - case 'g': - Gflag++; + Fflag = 1; break; #ifndef NOZ case 'z': - Zflag++; + Zflag = 1; switch(__progname[1]) { case 'e': - Eflag++; + Eflag = 1; break; case 'f': - Fflag++; - break; - case 'g': - Gflag++; + Fflag = 1; break; } break; @@ -308,19 +301,18 @@ main(int argc, char *argv[]) } break; case 'E': - Fflag = Gflag = 0; - Eflag++; + Fflag = 0; + Eflag = 1; break; case 'F': - Eflag = Gflag = 0; - Fflag++; + Eflag = 0; + Fflag = 1; break; case 'G': Eflag = Fflag = 0; - Gflag++; break; case 'H': - Hflag++; + Hflag = 1; break; case 'I': binbehave = BIN_FILE_SKIP; @@ -331,7 +323,7 @@ main(int argc, char *argv[]) break; case 'R': case 'r': - Rflag++; + Rflag = 1; break; case 'U': binbehave = BIN_FILE_BIN; @@ -342,7 +334,7 @@ main(int argc, char *argv[]) break; #ifndef NOZ case 'Z': - Zflag++; + Zflag = 1; break; #endif case 'a': diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h index 954844bdc01..5f70738e747 100644 --- a/usr.bin/grep/grep.h +++ b/usr.bin/grep/grep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.h,v 1.20 2014/12/01 06:36:04 deraadt Exp $ */ +/* $OpenBSD: grep.h,v 1.21 2015/01/10 13:48:02 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -63,7 +63,7 @@ typedef struct { extern int cflags, eflags; /* Command line flags */ -extern int Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag, +extern int Aflag, Bflag, Eflag, Fflag, Hflag, Lflag, Rflag, Zflag, bflag, cflag, hflag, iflag, lflag, nflag, oflag, qflag, sflag, vflag, wflag, xflag; |