grep: Reverse some if-else logic

This way, people don't have to do double negatives in their head.
This commit is contained in:
Michael Forney 2016-05-13 23:34:50 -07:00 committed by sin
parent c7ea20a9cb
commit 8636c956d9
1 changed files with 7 additions and 7 deletions

14
grep.c
View File

@ -114,23 +114,23 @@ grep(FILE *fp, const char *str)
if (len && buf[len - 1] == '\n') if (len && buf[len - 1] == '\n')
buf[len - 1] = '\0'; buf[len - 1] = '\0';
SLIST_FOREACH(pnode, &phead, entry) { SLIST_FOREACH(pnode, &phead, entry) {
if (!Fflag) { if (Fflag) {
if (regexec(&pnode->preg, buf, 0, NULL, 0) ^ vflag) if (xflag) {
continue; if (!(iflag ? strcasecmp : strcmp)(buf, pnode->pattern))
} else {
if (!xflag) {
if ((iflag ? strcasestr : strstr)(buf, pnode->pattern))
match = Match; match = Match;
else else
match = NoMatch; match = NoMatch;
} else { } else {
if (!(iflag ? strcasecmp : strcmp)(buf, pnode->pattern)) if ((iflag ? strcasestr : strstr)(buf, pnode->pattern))
match = Match; match = Match;
else else
match = NoMatch; match = NoMatch;
} }
if (match ^ vflag) if (match ^ vflag)
continue; continue;
} else {
if (regexec(&pnode->preg, buf, 0, NULL, 0) ^ vflag)
continue;
} }
switch (mode) { switch (mode) {
case 'c': case 'c':