diff options
| author | Jakob Kaivo <jkk@ung.org> | 2022-04-21 09:20:39 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2022-04-21 09:20:39 -0400 |
| commit | db7aadfa489566529abd3e9d330494b246be3797 (patch) | |
| tree | 25336a625690fbb39dd9f5f82a19db0dd34e407f | |
| parent | e9366a5f43a9c5b5b16216646b67cccdf9cecf54 (diff) | |
implement -v
| -rw-r--r-- | grep.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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': |
