bsdgrep: More trivial cleanup/style cleanup
We can avoid branching for these easily reduced patterns
This commit is contained in:
parent
f3cf3e5933
commit
e3a2abadc2
@ -110,11 +110,8 @@ file_matching(const char *fname)
|
||||
for (unsigned int i = 0; i < fpatterns; ++i) {
|
||||
if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
|
||||
fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
|
||||
if (fpattern[i].mode == EXCL_PAT) {
|
||||
ret = false;
|
||||
ret = (fpattern[i].mode != EXCL_PAT);
|
||||
break;
|
||||
} else
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
free(fname_buf);
|
||||
@ -129,13 +126,8 @@ dir_matching(const char *dname)
|
||||
ret = dinclude ? false : true;
|
||||
|
||||
for (unsigned int i = 0; i < dpatterns; ++i) {
|
||||
if (dname != NULL &&
|
||||
fnmatch(dpattern[i].pat, dname, 0) == 0) {
|
||||
if (dpattern[i].mode == EXCL_PAT)
|
||||
return (false);
|
||||
else
|
||||
ret = true;
|
||||
}
|
||||
if (dname != NULL && fnmatch(dpattern[i].pat, dname, 0) == 0)
|
||||
return (dpattern[i].mode != EXCL_PAT);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
@ -164,7 +156,6 @@ grep_tree(char **argv)
|
||||
break;
|
||||
default:
|
||||
fts_flags = FTS_LOGICAL;
|
||||
|
||||
}
|
||||
|
||||
fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
|
||||
|
Loading…
Reference in New Issue
Block a user