From: tedu Date: Sat, 10 Jan 2015 13:48:02 +0000 (+0000) Subject: 1. They're flags, not counters. Set to one instead of incrementing. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a1b2c99e0e3c7666148c8e48b145f58097d5f57b;p=openbsd 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 --- 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;