summaryrefslogtreecommitdiff
path: root/glob/fnmatch.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1996-06-22 21:14:22 +0000
committerRoland McGrath <roland@redhat.com>1996-06-22 21:14:22 +0000
commit63f3cf925bcaa8ea3bcfa63800bc52d581c40bcc (patch)
treea3933ec37b3fc590c7f276f9fd7205f80cbe7191 /glob/fnmatch.c
parent8541e3345df12b3c4941c8b7261b966e073cc461 (diff)
downloadgunmake-63f3cf925bcaa8ea3bcfa63800bc52d581c40bcc.tar.gz
Updated from libc
Diffstat (limited to 'glob/fnmatch.c')
-rw-r--r--glob/fnmatch.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/glob/fnmatch.c b/glob/fnmatch.c
index 08c1c94..de45941 100644
--- a/glob/fnmatch.c
+++ b/glob/fnmatch.c
@@ -92,10 +92,24 @@ fnmatch (pattern, string, flags)
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
- for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
- if (((flags & FNM_FILE_NAME) && *n == '/') ||
- (c == '?' && *n == '\0'))
- return FNM_NOMATCH;
+ for (c = *p++; c == '?' || c == '*'; c = *p++)
+ {
+ if ((flags & FNM_FILE_NAME) && *n == '/')
+ /* A slash does not match a wildcard under FNM_FILE_NAME. */
+ return FNM_NOMATCH;
+ else if (c == '?')
+ {
+ /* A ? needs to match one character. */
+ if (*n == '\0')
+ /* There isn't another character; no match. */
+ return FNM_NOMATCH;
+ else
+ /* One character of the string is consumed in matching
+ this ? wildcard, so *??? won't match if there are
+ less than three characters. */
+ ++n;
+ }
+ }
if (c == '\0')
return 0;