]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix problem with FNM_LEADING_DIR.
authorUlrich Drepper <drepper@redhat.com>
Wed, 26 Jan 2000 03:47:33 +0000 (03:47 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 26 Jan 2000 03:47:33 +0000 (03:47 +0000)
posix/fnmatch.c

index dc4021ef0de5bf60147b06b381a87d996fd132f0..82e2c2cd44c646a3931e36c405938774712343ad 100644 (file)
@@ -204,9 +204,31 @@ internal_fnmatch (const char *pattern, const char *string,
          if (c == '\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, '/') != 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;