diff options
author | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-07-10 19:16:23 +0000 |
---|---|---|
committer | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2003-07-10 19:16:23 +0000 |
commit | dc06cac74da4dd1ddc40bd80dbf3a6a6b9848024 (patch) | |
tree | 71b3c0f6d5b12d17192f6f026ca3315dadad8c9e | |
parent | 310f98473941e22565dcf00acdad84a0ffbd1bf4 (diff) |
restore grep -v semantics, print lines that don't match any (mismatch all)
patterns. ok tedu@, millert@
-rw-r--r-- | usr.bin/grep/grep.1 | 5 | ||||
-rw-r--r-- | usr.bin/grep/util.c | 11 |
2 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/grep/grep.1 b/usr.bin/grep/grep.1 index c038bbd2e61..8b813c9c127 100644 --- a/usr.bin/grep/grep.1 +++ b/usr.bin/grep/grep.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: grep.1,v 1.13 2003/06/24 04:43:53 tedu Exp $ +.\" $OpenBSD: grep.1,v 1.14 2003/07/10 19:16:22 dhartmei Exp $ .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -201,8 +201,7 @@ Nonexistent and unreadable files are ignored. .It Fl v Selected lines are those .Em not -matching the specified -patterns. +matching any of the specified patterns. .It Fl w The expression is searched for as a word (as if surrounded by `\e<' and `\e>', see diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 1e0591feb1a..b19b571fc17 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.14 2003/07/10 17:02:48 millert Exp $ */ +/* $OpenBSD: util.c,v 1.15 2003/07/10 19:16:22 dhartmei Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -169,14 +169,13 @@ static int procline(str_t *l, int nottext) { regmatch_t pmatch; - int c, i, r, t; + int c, i, r; if (matchall) { c = !vflag; goto print; } - t = vflag ? REG_NOMATCH : 0; for (c = i = 0; i < patterns; i++) { pmatch.rm_so = 0; pmatch.rm_eo = l->len; @@ -185,8 +184,6 @@ procline(str_t *l, int nottext) l->len, &pmatch); else r = regexec(&r_pattern[i], l->dat, 1, &pmatch, eflags); - if (r == REG_NOMATCH && t == 0) - continue; if (r == 0) { if (wflag) { if ((pmatch.rm_so != 0 && @@ -200,11 +197,13 @@ procline(str_t *l, int nottext) r = REG_NOMATCH; } } - if (r == t) { + if (r == 0) { c++; break; } } + if (vflag) + c = !c; print: if (c && binbehave == BIN_FILE_BIN && nottext) |