Mercurial > hg > toybox
changeset 1001:8b49ff103af9
grep: -om counts matching lines, not matching parts of lines.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 12 Aug 2013 03:16:29 -0500 |
parents | 99dad9fb5613 |
children | 4226645d3388 |
files | toys/pending/grep.c |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/pending/grep.c Mon Aug 12 03:08:56 2013 -0500 +++ b/toys/pending/grep.c Mon Aug 12 03:16:29 2013 -0500 @@ -67,6 +67,7 @@ regmatch_t matches[3]; size_t unused; long len; + int mmatch = 0; lcount++; if (0 > (len = getline(&line, &unused, file))) break; @@ -121,7 +122,7 @@ matches[which].rm_so = 0; } else if (rc) break; - mcount++; + mmatch++; if (toys.optflags & FLAG_q) { toys.exitval = 0; xexit(); @@ -152,6 +153,7 @@ free(line); + if (mmatch) mcount++; if ((toys.optflags & FLAG_m) && mcount >= TT.m) break; }