diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-07-22 23:50:49 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-07-22 23:50:49 +0000 |
commit | 69050873152acb2d2bd2b77c82078259ed59e2e2 (patch) | |
tree | a6e2e740fbe95aa4dbbab6337ae7aabb4b4da431 /posix/fnmatch.c | |
parent | e3efc21596f0929cb16837fab505f2f63b619808 (diff) | |
download | glibc-69050873152acb2d2bd2b77c82078259ed59e2e2.tar glibc-69050873152acb2d2bd2b77c82078259ed59e2e2.tar.gz glibc-69050873152acb2d2bd2b77c82078259ed59e2e2.tar.bz2 glibc-69050873152acb2d2bd2b77c82078259ed59e2e2.zip |
Update.
1998-07-22 23:47 Ulrich Drepper <drepper@cygnus.com>
* posix/fnmatch.c: Fix completely broken range matching.
Diffstat (limited to 'posix/fnmatch.c')
-rw-r--r-- | posix/fnmatch.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c index 4f5c667b02..e4677cb3df 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -35,7 +35,7 @@ # include <strings.h> #endif -#ifdef STDC_HEADERS +#if defined STDC_HEADERS || defined _LIBC # include <stdlib.h> #endif @@ -216,6 +216,7 @@ fnmatch (pattern, string, flags) /* Nonzero if the sense of the character class is inverted. */ static int posixly_correct; register int not; + char cold; if (posixly_correct == 0) posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; @@ -245,6 +246,9 @@ fnmatch (pattern, string, flags) if (c == fn) goto matched; } + else if ((flags & FNM_FILE_NAME) && c == '/') + /* [/] can never match. */ + return FNM_NOMATCH; else if (c == '[' && *p == ':') { /* Leave room for the null. */ @@ -301,8 +305,23 @@ fnmatch (pattern, string, flags) else if (FOLD (c) == fn) goto matched; + cold = c; c = *p++; + if (c == '-' && *p != ']') + { + /* It is a range. */ + char cend = *p++; + if (!(flags & FNM_NOESCAPE) && cend == '\\') + cend = *p++; + if (cend == '\0') + return FNM_NOMATCH; + + if (cold <= fn && fn <= FOLD (cend)) + goto matched; + + c = *p++; + } if (c == ']') break; } |