summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/grep/util.c')
-rw-r--r--usr.bin/grep/util.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index c65d8f2..3c0a5a6 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -55,14 +55,15 @@ static int procline(struct str *l, int);
bool
file_matching(const char *fname)
{
+ char *fname_base;
bool ret;
ret = finclude ? false : true;
+ fname_base = basename(fname);
for (unsigned int i = 0; i < fpatterns; ++i) {
- if (fnmatch(fpattern[i].pat,
- fname, 0) == 0 || fnmatch(fpattern[i].pat,
- basename(fname), 0) == 0) {
+ if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
+ fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
if (fpattern[i].mode == EXCL_PAT)
return (false);
else
@@ -277,7 +278,7 @@ procfile(const char *fn)
* matches. The matching lines are passed to printline() to display the
* appropriate output.
*/
-static inline int
+static int
procline(struct str *l, int nottext)
{
regmatch_t matches[MAX_LINE_MATCHES];
@@ -318,7 +319,8 @@ procline(struct str *l, int nottext)
(size_t)pmatch.rm_eo != l->len)
r = REG_NOMATCH;
/* Check for whole word match */
- if (r == 0 && wflag && pmatch.rm_so != 0) {
+ if (r == 0 && fg_pattern[i].word &&
+ pmatch.rm_so != 0) {
wint_t wbegin, wend;
wbegin = wend = L' ';
OpenPOWER on IntegriCloud