about summary refs log tree commit diff
path: root/posix/fnmatch_loop.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-21 07:30:28 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-21 07:30:28 +0000
commita4607c1f07fac984c22325e84caa525fa177edc9 (patch)
tree3dfafdd516700f16723722a01612a3c74c96b015 /posix/fnmatch_loop.c
parentd785c366924df522974f4ee88d77fd8aaed58803 (diff)
downloadglibc-a4607c1f07fac984c22325e84caa525fa177edc9.tar.gz
glibc-a4607c1f07fac984c22325e84caa525fa177edc9.tar.xz
glibc-a4607c1f07fac984c22325e84caa525fa177edc9.zip
Update.
	* posix/fnmatch_loop.c: Make FNM_LEADING_DIR behave as GNU tar
	expects it.  Patch by Colin Watson <riva.ucam.org>.
	* posix/tst-fnmatch.input: Add test cases for FNM_LEADING_DIR.
Diffstat (limited to 'posix/fnmatch_loop.c')
-rw-r--r--posix/fnmatch_loop.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index 6b20aa4304..4c619ed4bb 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -99,25 +99,18 @@ FCT (pattern, string, no_leading_period, flags)
 	  if (c == L('\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.  If the FNM_LEADING_DIR
-	       flag is set and exactly one slash is following, we have
-	       a match.  */
+	       this means it cannot match, unless the FNM_LEADING_DIR
+	       flag is set.  */
 	    {
 	      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;
-		    }
+		    result = 0;
 		  else
 		    {
-		      if (slashp == NULL)
+		      if (STRCHR (n, L('/')) == NULL)
 			result = 0;
 		    }
 		}