changeset 14739:fa334fc6c425

fnmatch: 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.
author James Youngman <jay@gnu.org>
date Thu, 12 May 2011 22:14:12 +0100
parents 51a0158159b6
children d88ac2dba568
files ChangeLog m4/fnmatch.m4 tests/test-fnmatch.c
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/m4/fnmatch.m4
+++ b/m4/fnmatch.m4
@@ -65,6 +65,8 @@
               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))
--- a/tests/test-fnmatch.c
+++ b/tests/test-fnmatch.c
@@ -46,5 +46,11 @@
   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;
 }