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.
This commit is contained in:
Ulrich Drepper 1999-04-28 09:23:09 +00:00
parent 980e58323a
commit 66f93c2d97
3 changed files with 39 additions and 13 deletions

View File

@ -1,3 +1,10 @@
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.
1999-04-27 Ulrich Drepper <drepper@cygnus.com> 1999-04-27 Ulrich Drepper <drepper@cygnus.com>
* include/dirent.h: Remove __getdirentries declaration, add __getdents * include/dirent.h: Remove __getdirentries declaration, add __getdents

View File

@ -157,7 +157,9 @@ internal_fnmatch (const char *pattern, const char *string,
return FNM_NOMATCH; return FNM_NOMATCH;
else if (*n == '/' && (flags & FNM_FILE_NAME)) else if (*n == '/' && (flags & FNM_FILE_NAME))
return FNM_NOMATCH; 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; return FNM_NOMATCH;
break; break;
@ -175,7 +177,9 @@ internal_fnmatch (const char *pattern, const char *string,
break; break;
case '*': case '*':
if (*n == '.' && no_leading_period) if (*n == '.' && no_leading_period
&& (n == string
|| (n[-1] == '/' && (flags & FNM_FILE_NAME))))
return FNM_NOMATCH; return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++) for (c = *p++; c == '?' || c == '*'; c = *p++)
@ -212,11 +216,17 @@ internal_fnmatch (const char *pattern, const char *string,
if (c == '[') if (c == '[')
{ {
int flags2 = ((flags & FNM_FILE_NAME)
? flags : (flags & ~FNM_PERIOD));
for (--p; n < endp; ++n) for (--p; n < endp; ++n)
if (internal_fnmatch (p, n, if (internal_fnmatch (p, n,
(n == string) && no_leading_period, (no_leading_period
((flags & FNM_FILE_NAME) && (n == string
? flags : (flags & ~FNM_PERIOD))) || (n[-1] == '/'
&& (flags
& FNM_FILE_NAME)))),
flags2)
== 0) == 0)
return 0; return 0;
} }
@ -231,18 +241,21 @@ internal_fnmatch (const char *pattern, const char *string,
} }
else else
{ {
int flags2 = ((flags & FNM_FILE_NAME)
? flags : (flags & ~FNM_PERIOD));
if (c == '\\' && !(flags & FNM_NOESCAPE)) if (c == '\\' && !(flags & FNM_NOESCAPE))
c = *p; c = *p;
c = FOLD (c); c = FOLD (c);
for (--p; n < endp; ++n) for (--p; n < endp; ++n)
if (FOLD ((unsigned char) *n) == c if (FOLD ((unsigned char) *n) == c
&& (internal_fnmatch (p, n, && (internal_fnmatch (p, n,
((n == string) (no_leading_period
&& no_leading_period), && (n == string
((flags & FNM_FILE_NAME) || (n[-1] == '/'
? flags && (flags
: (flags & ~FNM_PERIOD))) & FNM_FILE_NAME)))),
== 0)) flags2) == 0))
return 0; return 0;
} }
} }
@ -263,7 +276,10 @@ internal_fnmatch (const char *pattern, const char *string,
if (*n == '\0') if (*n == '\0')
return FNM_NOMATCH; return FNM_NOMATCH;
if (*n == '.' && no_leading_period) if (*n == '.' && no_leading_period && (n == string
|| (n[-1] == '/'
&& (flags
& FNM_FILE_NAME))))
return FNM_NOMATCH; return FNM_NOMATCH;
if (*n == '/' && (flags & FNM_FILE_NAME)) 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) # if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
wctype_t wt; wctype_t wt;
# endif # endif
char *startp = p; const char *startp = p;
for (;;) for (;;)
{ {

View File

@ -48,6 +48,9 @@ struct {
{ "a/b", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, 0 }, { "a/b", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, 0 },
{ "a/[", "*[![:digit:]]*/[[:d-d]", FNM_PATHNAME, 0 }, { "a/[", "*[![:digit:]]*/[[:d-d]", FNM_PATHNAME, 0 },
{ "a/[", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, FNM_NOMATCH }, { "a/[", "*[![:digit:]]*/[![:d-d]", FNM_PATHNAME, FNM_NOMATCH },
{ "a.b", "a?b", FNM_PATHNAME|FNM_PERIOD, 0 },
{ "a.b", "a*b", FNM_PATHNAME|FNM_PERIOD, 0 },
{ "a.b", "a[.]b", FNM_PATHNAME|FNM_PERIOD, 0 },
}; };
int int