aboutsummaryrefslogtreecommitdiff
path: root/posix/fnmatch.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-28 09:23:09 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-28 09:23:09 +0000
commit66f93c2d97c7a6299361805091513981b6277893 (patch)
tree763f44901596aa0f7a6afb6a4df2be02f0c69661 /posix/fnmatch.c
parent980e58323af243dd0a87f6a6eeec6f97308b46e5 (diff)
downloadglibc-66f93c2d97c7a6299361805091513981b6277893.zip
glibc-66f93c2d97c7a6299361805091513981b6277893.tar.gz
glibc-66f93c2d97c7a6299361805091513981b6277893.tar.bz2
Update.
1999-04-28 Ulrich Drepper <drepper@cygnus.com> * posix/fnmatch.c (internal_fnmatch): Finish incomplete no_leading_period change. * posix/testfnm.c: More test cases.
Diffstat (limited to 'posix/fnmatch.c')
-rw-r--r--posix/fnmatch.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
index b147f47..eb3f1cc 100644
--- a/posix/fnmatch.c
+++ b/posix/fnmatch.c
@@ -157,7 +157,9 @@ internal_fnmatch (const char *pattern, const char *string,
return FNM_NOMATCH;
else if (*n == '/' && (flags & FNM_FILE_NAME))
return FNM_NOMATCH;
- else if (*n == '.' && no_leading_period)
+ else if (*n == '.' && no_leading_period
+ && (n == string
+ || (n[-1] == '/' && (flags & FNM_FILE_NAME))))
return FNM_NOMATCH;
break;
@@ -175,7 +177,9 @@ internal_fnmatch (const char *pattern, const char *string,
break;
case '*':
- if (*n == '.' && no_leading_period)
+ if (*n == '.' && no_leading_period
+ && (n == string
+ || (n[-1] == '/' && (flags & FNM_FILE_NAME))))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++)
@@ -212,11 +216,17 @@ internal_fnmatch (const char *pattern, const char *string,
if (c == '[')
{
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+
for (--p; n < endp; ++n)
if (internal_fnmatch (p, n,
- (n == string) && no_leading_period,
- ((flags & FNM_FILE_NAME)
- ? flags : (flags & ~FNM_PERIOD)))
+ (no_leading_period
+ && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME)))),
+ flags2)
== 0)
return 0;
}
@@ -231,18 +241,21 @@ internal_fnmatch (const char *pattern, const char *string,
}
else
{
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+
if (c == '\\' && !(flags & FNM_NOESCAPE))
c = *p;
c = FOLD (c);
for (--p; n < endp; ++n)
if (FOLD ((unsigned char) *n) == c
&& (internal_fnmatch (p, n,
- ((n == string)
- && no_leading_period),
- ((flags & FNM_FILE_NAME)
- ? flags
- : (flags & ~FNM_PERIOD)))
- == 0))
+ (no_leading_period
+ && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME)))),
+ flags2) == 0))
return 0;
}
}
@@ -263,7 +276,10 @@ internal_fnmatch (const char *pattern, const char *string,
if (*n == '\0')
return FNM_NOMATCH;
- if (*n == '.' && no_leading_period)
+ if (*n == '.' && no_leading_period && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME))))
return FNM_NOMATCH;
if (*n == '/' && (flags & FNM_FILE_NAME))
@@ -297,7 +313,7 @@ internal_fnmatch (const char *pattern, const char *string,
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
wctype_t wt;
# endif
- char *startp = p;
+ const char *startp = p;
for (;;)
{