cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] Changes to ccvs/lib/fnmatch.c


From: Derek Robert Price
Subject: [Cvs-cvs] Changes to ccvs/lib/fnmatch.c
Date: Fri, 12 Aug 2005 16:58:11 -0400

Index: ccvs/lib/fnmatch.c
diff -u ccvs/lib/fnmatch.c:1.10 ccvs/lib/fnmatch.c:1.11
--- ccvs/lib/fnmatch.c:1.10     Mon May 23 17:44:30 2005
+++ ccvs/lib/fnmatch.c  Fri Aug 12 20:58:10 2005
@@ -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,54 +319,51 @@
         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;
-      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;
-      assert (mbsinit (&ps));
-      totsize = patsize + strsize;
-      if (__builtin_expect (! (patsize <= totsize
-                              && totsize <= SIZE_MAX / sizeof (wchar_t)),
-                           0))
+      if (__builtin_expect (patsize != 0, 1))
        {
-         errno = ENOMEM;
-         return -1;
-       }
-
-      /* Allocate room for the wide characters.  */
-      if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
-       wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
-      else
-       {
-         wpattern = malloc (totsize * sizeof (wchar_t));
-         if (__builtin_expect (! wpattern, 0))
+         assert (mbsinit (&ps));
+         strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
+         if (__builtin_expect (strsize != 0, 1))
            {
-             errno = ENOMEM;
-             return -1;
+             assert (mbsinit (&ps));
+             totsize = patsize + strsize;
+             if (__builtin_expect (! (patsize <= totsize
+                                      && totsize <= SIZE_MAX / sizeof 
(wchar_t)),
+                                   0))
+               {
+                 errno = ENOMEM;
+                 return -1;
+               }
+
+             /* Allocate room for the wide characters.  */
+             if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
+               wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
+             else
+               {
+                 wpattern = malloc (totsize * sizeof (wchar_t));
+                 if (__builtin_expect (! wpattern, 0))
+                   {
+                     errno = ENOMEM;
+                     return -1;
+                   }
+               }
+             wstring = wpattern + patsize;
+
+             /* Convert the strings into wide characters.  */
+             mbsrtowcs (wpattern, &pattern, patsize, &ps);
+             assert (mbsinit (&ps));
+             mbsrtowcs (wstring, &string, strsize, &ps);
+
+             res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
+                                      flags & FNM_PERIOD, flags);
+
+             if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
+               free (wpattern);
+             return res;
            }
        }
-      wstring = wpattern + patsize;
-
-      /* Convert the strings into wide characters.  */
-      mbsrtowcs (wpattern, &pattern, patsize, &ps);
-      assert (mbsinit (&ps));
-      mbsrtowcs (wstring, &string, strsize, &ps);
-
-      res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
-                              flags & FNM_PERIOD, flags);
-
-      if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
-       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]