bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] Backport glibc change fixing Bugzilla bug #12378.


From: James Youngman
Subject: [PATCH 1/2] Backport glibc change fixing Bugzilla bug #12378.
Date: Thu, 12 May 2011 01:06:53 +0100

From: James Youngman <address@hidden>

* lib/fnmatch_loop.c (FCT): When matching '[' keep track of
beginning and fall back to matching as normal character if the
string ends before the matching ']' is found.  This is what POSIX
requires.

Signed-off-by: James Youngman <address@hidden>
---
 ChangeLog          |    8 ++++++++
 lib/fnmatch_loop.c |   11 +++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e8e37db..245cbbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-11  Ulrich Drepper  <address@hidden>
+
+       Backport glibc change fixing Bugzilla bug #12378.
+       * lib/fnmatch_loop.c (FCT): When matching '[' keep track of
+       beginning and fall back to matching as normal character if the
+       string ends before the matching ']' is found.  This is what POSIX
+       requires.
+
 2011-05-11  Eric Blake  <address@hidden>
 
        fclose: preserve fflush errors
diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c
index ed760dd..0516ac6 100644
--- a/lib/fnmatch_loop.c
+++ b/lib/fnmatch_loop.c
@@ -200,6 +200,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR 
*string_end,
         case L_('['):
           {
             /* Nonzero if the sense of the character class is inverted.  */
+           CHAR *p_init = p;
+           CHAR *n_init = n;
             register bool not;
             CHAR cold;
             UCHAR fn;
@@ -410,8 +412,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR 
*string_end,
                   }
 #endif
                 else if (c == L_('\0'))
-                  /* [ (unterminated) loses.  */
-                  return FNM_NOMATCH;
+                 {
+                   /* [ unterminated, treat as normal character.  */
+                   p = p_init;
+                   n = n_init;
+                   c = L_('[');
+                   goto normal_match;
+                 }
                 else
                   {
                     bool is_range = false;
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]