sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 8636c956d954c589565fca21c820354bc19c4384
parent c7ea20a9cbaaa32ff8d1e3e67ae7f978b0b69e07
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 13 May 2016 23:34:50 -0700

grep: Reverse some if-else logic

This way, people don't have to do double negatives in their head.

Diffstat:
Mgrep.c | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

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