From db7aadfa489566529abd3e9d330494b246be3797 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 21 Apr 2022 09:20:39 -0400 Subject: implement -v --- grep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grep.c b/grep.c index 10e1a16..344921f 100644 --- a/grep.c +++ b/grep.c @@ -42,9 +42,9 @@ struct grep_list { enum { NORMAL, COUNT, LIST, QUIET } grep_display = NORMAL; static int grep_filenames = 0; static int grep_linenumbers = 0; +static int grep_inverse = 0; #define SUPPRESS 1 << 2 -#define INVERT 1 << 3 #define WHOLELINE 1 << 4 #define FILENAMES 1 << 5 @@ -59,11 +59,11 @@ static int grep_match(struct grep_list *head, const char *buf) } if (regexec(&(c->re), buf, 0, NULL, 0) == 0) { - return 1; + return !grep_inverse; } } - return 0; + return grep_inverse; } static uintmax_t grep(struct grep_list *head, const char *path, int flags) @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) break; case 'v': - //flags |= INVERT; + grep_inverse = 1; break; case 'x': -- cgit v1.2.1