fnmatch: add a test for glibc's Bugzilla bug #12378
authorJames Youngman <jay@gnu.org>
Thu, 12 May 2011 21:14:12 +0000 (22:14 +0100)
committerEric Blake <eblake@redhat.com>
Sat, 14 May 2011 03:07:29 +0000 (21:07 -0600)
* m4/fnmatch.m4: Use gnulib's fnmatch if the system fnmatch
doesn't allow the literal matching of a lone "[" (which is
required by POSIX).
* tests/test-fnmatch.c (main): Check that "[/b" matches itself.

ChangeLog
m4/fnmatch.m4
tests/test-fnmatch.c

index f5e33cb..9654f9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-12  James Youngman  <jay@gnu.org>
+
+       Add a test for glibc's Bugzilla bug #12378.
+       * m4/fnmatch.m4: Use gnulib's fnmatch if the system fnmatch
+       doesn't allow the literal matching of a lone "[" (which is
+       required by POSIX).
+       * tests/test-fnmatch.c (main): Check that "[/b" matches itself.
+
 2011-05-11  Ulrich Drepper  <drepper@gmail.com>
 
        Sync glibc change fixing Bugzilla bug #12378.
index c8ed9e7..4ddfbae 100644 (file)
@@ -65,6 +65,8 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
               return 1;
             if (!y ("a*", "abc", 0))
               return 1;
+            if (!y ("[/b", "[/b", 0)) /*"]]"*/ /* glibc Bugzilla bug 12378 */
+              return 1;
             if (!n ("d*/*1", "d/s/1", FNM_PATHNAME))
               return 2;
             if (!y ("a\\\\bc", "abc", 0))
index 66f9b1c..71664a8 100644 (file)
@@ -46,5 +46,11 @@ main ()
   ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", 0) == 0);
   ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH);
 
+  /* Verify that an unmatched [ is treated as a literal, as POSIX
+     requires.  This test ensures that glibc Bugzilla bug #12378 stays
+     fixed.
+   */
+  ASSERT (res = fnmatch ("[/b", "[/b", 0) == 0);
+
   return 0;
 }