bug-gnulib
[Top][All Lists]
Advanced

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

Re: [bug-gnulib] Handling of invalid multibyte character sequences in fn


From: Paul Eggert
Subject: Re: [bug-gnulib] Handling of invalid multibyte character sequences in fnmatch()
Date: Fri, 10 Jun 2005 12:53:40 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

James Youngman <address@hidden> writes:

> I was testing on a Glibc system, and so wasn't picking up the gnulib
> version of fnmatch().  Silly me.

Won't other people have the same problem?

Can you modify m4/fnmatch.m4 to detect the problem, and if so then use
the gnulib version instead of the glibc version?

But in any event, the .c fix should go in, so I installed this into gnulib:

2005-06-10  Paul Eggert  <address@hidden>

        * fnmatch.c (fnmatch): If there is an encoding error in a
        multibyte string or pattern, fall back on unibyte matching.
        Problem reported by James Youngman.

Index: lib/fnmatch.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fnmatch.c,v
retrieving revision 1.30
diff -p -u -b -w -r1.30 fnmatch.c
--- lib/fnmatch.c       14 May 2005 06:03:58 -0000      1.30
+++ lib/fnmatch.c       10 Jun 2005 19:51:24 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004
+/* Copyright (C) 
1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005
        Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -319,18 +319,12 @@ fnmatch (const char *pattern, const char
         wide characters.  */
       memset (&ps, '\0', sizeof (ps));
       patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
-      if (__builtin_expect (patsize == 0, 0))
-       /* Something wrong.
-          XXX Do we have to set `errno' to something which mbsrtows hasn't
-          already done?  */
-       return -1;
+      if (__builtin_expect (patsize != 0, 1))
+       {
       assert (mbsinit (&ps));
       strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
-      if (__builtin_expect (strsize == 0, 0))
-       /* Something wrong.
-          XXX Do we have to set `errno' to something which mbsrtows hasn't
-          already done?  */
-       return -1;
+         if (__builtin_expect (strsize != 0, 1))
+           {
       assert (mbsinit (&ps));
       totsize = patsize + strsize;
       if (__builtin_expect (! (patsize <= totsize
@@ -367,6 +361,9 @@ fnmatch (const char *pattern, const char
        free (wpattern);
       return res;
     }
+       }
+    }
+
 # endif /* HANDLE_MULTIBYTE */
 
   return internal_fnmatch (pattern, string, string + strlen (string),




reply via email to

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