diff options
author | Rob Landley <rob@landley.net> | 2023-03-03 15:21:06 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2023-03-03 15:21:06 -0600 |
commit | b367482e9c102f49001a7e2d1ddb048bdce8b06e (patch) | |
tree | f4c498463564b545fcee9408899925db8dc2d29a /toys/posix/grep.c | |
parent | 078e95bba4fa0ce2aaf3e17502bba05b8551a93d (diff) | |
download | toybox-b367482e9c102f49001a7e2d1ddb048bdce8b06e.tar.gz |
Change FLAG(x) macros to always return 0 or 1. Treewide audit of FLAG()
users to make sure nobody NEEDED FLAG(x) to return the masked bit value,
and to remove now-redundant !!, with a number of in-passing cleanups
while I was there.
I think I fixed an actual bug in patch.c (-R depended on the flag value
but commit 6f6b7614e463 changed it, so "+-"[FLAG(R)] was comparing
against the NUL terminator when measuring fuzz) but we didn't have a
test for "fuzz autodetection". And there was another bug in tar.c
where DIRTREE_BREADTH was assigned to a local variable... and then not
used. But the test passed? (Not sure the flag's needed at the top level,
added a comment to the test suite to remind me to revisit that.)
While I was there, capitalize TODO comments so they're easier to grep for.
Diffstat (limited to 'toys/posix/grep.c')
-rw-r--r-- | toys/posix/grep.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c index 5c6f5936..137c9c3c 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -429,8 +429,7 @@ static void parse_regex(void) struct reg *shoe; dlist_add_nomalloc(&TT.reg, (void *)(shoe = xmalloc(sizeof(struct reg)))); - xregcomp(&shoe->r, (*last)->arg, - (REG_EXTENDED*!!FLAG(E))|(REG_ICASE*!!FLAG(i))); + xregcomp(&shoe->r, (*last)->arg, REG_EXTENDED*FLAG(E)|REG_ICASE*FLAG(i)); al = *last; *last = (*last)->next; free(al); @@ -476,7 +475,7 @@ static int do_grep_r(struct dirtree *new) if (S_ISDIR(new->st.st_mode)) { for (al = TT.exclude_dir; al; al = al->next) if (!fnmatch(al->arg, new->name, 0)) return 0; - return DIRTREE_RECURSE|(FLAG(R)?DIRTREE_SYMFOLLOW:0); + return DIRTREE_RECURSE|DIRTREE_SYMFOLLOW*FLAG(R); } if (TT.S || TT.M) { for (al = TT.S; al; al = al->next) |