summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-07 18:54:52 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-07 18:54:52 +0000
commitc8d48faef08fe72320394ebc5dc3d12059392b90 (patch)
tree37b30fef0de871969852467e4d7e2562853aabb3 /posix
parenta1a363d20cb4d698af8e7a8a0bb9c3313fe7d858 (diff)
downloadglibc-c8d48faef08fe72320394ebc5dc3d12059392b90.tar.gz
glibc-c8d48faef08fe72320394ebc5dc3d12059392b90.tar.xz
glibc-c8d48faef08fe72320394ebc5dc3d12059392b90.zip
[BZ #5103]
	* posix/glob.c (glob): Recognize patterns starting \/.
	* posix/tst-gnuglob.c (find_file): Handle absolute path names.
	(main): Add test for pattern starting \/.
Diffstat (limited to 'posix')
-rw-r--r--posix/glob.c5
-rw-r--r--posix/tst-gnuglob.c18
2 files changed, 20 insertions, 3 deletions
diff --git a/posix/glob.c b/posix/glob.c
index 6d8a891340..6ae09ef480 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -454,9 +454,10 @@ glob (pattern, flags, errfunc, pglob)
 	  dirlen = 0;
 	}
     }
-  else if (filename == pattern)
+  else if (filename == pattern
+	   || (filename == pattern + 1 && pattern[0] == '\\'))
     {
-      /* "/pattern".  */
+      /* "/pattern" or "\\/pattern".  */
       dirname = "/";
       dirlen = 1;
       ++filename;
diff --git a/posix/tst-gnuglob.c b/posix/tst-gnuglob.c
index 72f3fa4a3e..95bfbae641 100644
--- a/posix/tst-gnuglob.c
+++ b/posix/tst-gnuglob.c
@@ -1,6 +1,6 @@
 /* Test the GNU extensions in glob which allow the user to provide callbacks
    for the filesystem access functions.
-   Copyright (C) 2001-2002 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
 
@@ -103,6 +103,16 @@ find_file (const char *s)
   int level = 1;
   long int idx = 0;
 
+  while (s[0] == '/')
+    {
+      if (s[1] == '\0')
+	{
+	  s = ".";
+	  break;
+	}
+      ++s;
+    }
+
   if (strcmp (s, ".") == 0)
     return 0;
 
@@ -439,6 +449,12 @@ main (void)
 	"dir2lev1/dir1lev2/.dir",
 	"dir2lev1/dir1lev2/.foo");
 
+  test ("\\/*", GLOB_ALTDIRFUNC,
+	"/dir1lev1",
+	"/dir2lev1",
+	"/file1lev1",
+	"/file2lev1");
+
   globfree (&gl);
 
   return result;