diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-01-26 03:46:22 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-01-26 03:46:22 +0000 |
commit | 479248949b9cc41fc0b133b3510232d8a1b57767 (patch) | |
tree | d16f781c00facd9096371a768ba4093caad84b7e /posix/fnmatch_loop.c | |
parent | 1827fc4c9819187f1084fecd92f3071e3482defa (diff) | |
download | glibc-479248949b9cc41fc0b133b3510232d8a1b57767.tar.gz glibc-479248949b9cc41fc0b133b3510232d8a1b57767.tar.xz glibc-479248949b9cc41fc0b133b3510232d8a1b57767.zip |
Update.
2000-01-25 Ulrich Drepper <drepper@cygnus.com> * posix/fnmatch_loop.c: Fix problem with FNM_LEADING_DIR. * posix/testfnm.c: Add a few more tests. Rearrange test output.
Diffstat (limited to 'posix/fnmatch_loop.c')
-rw-r--r-- | posix/fnmatch_loop.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index 2928037cab..5f6c05710e 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -90,9 +90,31 @@ FCT (pattern, string, no_leading_period, flags) if (c == L('\0')) /* The wildcard(s) is/are the last element of the pattern. If the name is a file name and contains another slash - this does mean it cannot match. */ - return ((flags & FNM_FILE_NAME) && STRCHR (n, L('/')) != NULL - ? FNM_NOMATCH : 0); + this does mean it cannot match. If the FNM_LEADING_DIR + flag is set and exactly one slash is following, we have + a match. */ + { + int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; + + if (flags & FNM_FILE_NAME) + { + const CHAR *slashp = STRCHR (n, L('/')); + + if (flags & FNM_LEADING_DIR) + { + if (slashp != NULL + && STRCHR (slashp + 1, L('/')) == NULL) + result = 0; + } + else + { + if (slashp == NULL) + result = 0; + } + } + + return result; + } else { const CHAR *endp; |