summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-21 09:34:15 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-21 09:34:15 -0400
commit7e965cba479cd560600bbb68bd1be0c619da9541 (patch)
treeaad48d657db624255f6ad67dd88f23d8129f5685 /grep.c
parenta2d6323436f4d80fbd3f7d80b7d839ba247076a2 (diff)
implement -x for -F
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c7
1 files changed, 5 insertions, 2 deletions
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;
}