From 7e965cba479cd560600bbb68bd1be0c619da9541 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 21 Apr 2022 09:34:15 -0400 Subject: implement -x for -F --- grep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index 85a6d8f..73d9220 100644 --- a/grep.c +++ b/grep.c @@ -50,8 +50,11 @@ static int grep_match(struct grep_list *head, const char *buf) { for (struct grep_list *c = head; c != NULL; c = c->next) { if (c->string) { - if (strstr(buf, c->string)) { - return 1; + if (grep_exact && strcmp(buf, c->string) == 0) { + return !grep_inverse; + } + if (!grep_exact && strstr(buf, c->string)) { + return !grep_inverse; } continue; } -- cgit v1.2.1