(fnmatch): Allow `/' in character class. Don't match `/' in filename
authordrepper <drepper>
Mon, 27 Jul 1998 17:45:38 +0000 (17:45 +0000)
committerdrepper <drepper>
Mon, 27 Jul 1998 17:45:38 +0000 (17:45 +0000)
by a character class if requested.

posix/fnmatch.c

index e4677cb..2d6f6af 100644 (file)
@@ -228,6 +228,10 @@ fnmatch (pattern, string, flags)
                (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
              return FNM_NOMATCH;
 
+           if (*n == '/' && (flags & FNM_FILE_NAME))
+             /* `/' cannot be matched.  */
+             return FNM_NOMATCH;
+
            not = (*p == '!' || (posixly_correct < 0 && *p == '^'));
            if (not)
              ++p;
@@ -246,9 +250,6 @@ 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.  */