]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #5103]
authorUlrich Drepper <drepper@redhat.com>
Sun, 7 Oct 2007 18:54:52 +0000 (18:54 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 7 Oct 2007 18:54:52 +0000 (18:54 +0000)
* posix/glob.c (glob): Recognize patterns starting \/.
* posix/tst-gnuglob.c (find_file): Handle absolute path names.
(main): Add test for pattern starting \/.

ChangeLog
posix/glob.c
posix/tst-gnuglob.c

index 60cdd2e1f0d9a64f09270e126958cd45aa381741..2813e59a472d9639645b72856662dee44685b24d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-10-07  Ulrich Drepper  <drepper@redhat.com>
 
+       [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 \/.
+
        * misc/error.h: Use __const instead of const.
        * misc/bits/error.h: Likewise.
 
index 6d8a8913408b17ba56c3be015682d1705f030f1d..6ae09ef480df73e977af8ab43ee1f54cf16083ee 100644 (file)
@@ -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;
index 72f3fa4a3e2e64b25439c6fc0c4d4c82b6840742..95bfbae64133a8ee9b1afe91a7cb8ab7ed134163 100644 (file)
@@ -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;