Fix a bug that caused some false mismatches when both FNM_PATHNAME

and FNM_LEADING_DIR were specified and the pattern ended with "*".
Example: pattern="src/usr.sbin/w*", string="src/usr.sbin/watch/watch.8,v".
This should match, but did not.
This commit is contained in:
John Polstra 1997-04-29 03:24:57 +00:00
parent 1a0345d543
commit 298c8e3d6b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25269
2 changed files with 4 additions and 2 deletions

View File

@ -93,7 +93,8 @@ fnmatch(pattern, string, flags)
/* Optimize for pattern with * at end or before /. */
if (c == EOS)
if (flags & FNM_PATHNAME)
return (strchr(string, '/') == NULL ?
return ((flags & FNM_LEADING_DIR) ||
strchr(string, '/') == NULL ?
0 : FNM_NOMATCH);
else
return (0);

View File

@ -93,7 +93,8 @@ fnmatch(pattern, string, flags)
/* Optimize for pattern with * at end or before /. */
if (c == EOS)
if (flags & FNM_PATHNAME)
return (strchr(string, '/') == NULL ?
return ((flags & FNM_LEADING_DIR) ||
strchr(string, '/') == NULL ?
0 : FNM_NOMATCH);
else
return (0);