diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-06-06 22:33:28 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-06-06 22:33:28 +0000 |
commit | 05a068e60e343e65de9eb2da75e560577a395755 (patch) | |
tree | f7054f8bb9396385e063756036c4b2ff31106e6b | |
parent | e2dbbd9eea04896f2edb3314fc3f3cf65e5838a5 (diff) |
Notes
-rw-r--r-- | lib/libc/gen/fnmatch.c | 14 | ||||
-rw-r--r-- | sys/libkern/fnmatch.c | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index 28ec19639349f..542a5284318a3 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -121,8 +121,13 @@ fnmatch(pattern, string, flags) case '[': if (*string == EOS) return (FNM_NOMATCH); - if (*string == '/' && flags & FNM_PATHNAME) + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); + switch (rangematch(pattern, *string, flags, &newp)) { case RANGE_ERROR: goto norm; @@ -177,10 +182,8 @@ rangematch(pattern, test, flags, newp) * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) { - first = 0; + if ( (negate = (*pattern == '!' || *pattern == '^')) ) ++pattern; - } if (flags & FNM_CASEFOLD) test = tolower((unsigned char)test); @@ -197,6 +200,9 @@ rangematch(pattern, test, flags, newp) if (c == EOS) return (RANGE_ERROR); + if (c == '/' && (flags & FNM_PATHNAME)) + return (RANGE_NOMATCH); + if (flags & FNM_CASEFOLD) c = tolower((unsigned char)c); diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c index 28ec19639349f..542a5284318a3 100644 --- a/sys/libkern/fnmatch.c +++ b/sys/libkern/fnmatch.c @@ -121,8 +121,13 @@ fnmatch(pattern, string, flags) case '[': if (*string == EOS) return (FNM_NOMATCH); - if (*string == '/' && flags & FNM_PATHNAME) + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); + switch (rangematch(pattern, *string, flags, &newp)) { case RANGE_ERROR: goto norm; @@ -177,10 +182,8 @@ rangematch(pattern, test, flags, newp) * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) { - first = 0; + if ( (negate = (*pattern == '!' || *pattern == '^')) ) ++pattern; - } if (flags & FNM_CASEFOLD) test = tolower((unsigned char)test); @@ -197,6 +200,9 @@ rangematch(pattern, test, flags, newp) if (c == EOS) return (RANGE_ERROR); + if (c == '/' && (flags & FNM_PATHNAME)) + return (RANGE_NOMATCH); + if (flags & FNM_CASEFOLD) c = tolower((unsigned char)c); |