diff options
| author | Wolfram Schneider <wosch@FreeBSD.org> | 1996-09-27 19:44:46 +0000 |
|---|---|---|
| committer | Wolfram Schneider <wosch@FreeBSD.org> | 1996-09-27 19:44:46 +0000 |
| commit | d7c71d3534865ab9f17c87e5b779ea040467a523 (patch) | |
| tree | c7ceea5562d06dba74895dc5fb62b189fa29310d /gnu/usr.bin/grep | |
| parent | 8a9374d25bd69880caec7ef3c0a4072550b2aaa0 (diff) | |
Notes
Diffstat (limited to 'gnu/usr.bin/grep')
| -rw-r--r-- | gnu/usr.bin/grep/grep.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gnu/usr.bin/grep/grep.c b/gnu/usr.bin/grep/grep.c index ae301677da91..0353e26a33e1 100644 --- a/gnu/usr.bin/grep/grep.c +++ b/gnu/usr.bin/grep/grep.c @@ -343,6 +343,7 @@ static int out_line; /* Print line numbers. */ static int out_byte; /* Print byte offsets. */ static int out_before; /* Lines of leading context. */ static int out_after; /* Lines of trailing context. */ +static int count_matches; /* print a count of matching lines */ /* Internal variables to keep track of byte count, context, etc. */ static size_t totalcc; /* Total character count before bufbeg. */ @@ -589,6 +590,9 @@ grep(fd) nlines += grepbuf(beg, lim); if (pending) prpending(lim); + /* optimization */ + if (nlines && out_quiet && !count_matches) + return(nlines); } i = 0; beg = lim; @@ -659,7 +663,7 @@ main(argc, argv) { char *keys; size_t keycc, oldcc, keyalloc; - int keyfound, count_matches, no_filenames, list_files, suppress_errors; + int keyfound, no_filenames, list_files, suppress_errors; int opt, cc, desc, count, status; FILE *fp; extern char *optarg; |
