|
|
12745e |
diff -Nru glibc-2.17-c758a686/posix/fnmatch.c glibc-2.17-c758a686/posix/fnmatch.c
|
|
|
12745e |
--- glibc-2.17-c758a686/posix/fnmatch.c 2012-01-01 07:16:32.000000000 -0500
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/fnmatch.c 2012-05-23 14:14:29.099461189 -0400
|
|
|
29e444 |
@@ -333,6 +333,7 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
# if HANDLE_MULTIBYTE
|
|
|
29e444 |
if (__builtin_expect (MB_CUR_MAX, 1) != 1)
|
|
|
29e444 |
{
|
|
|
29e444 |
+ const char *orig_pattern = pattern;
|
|
|
29e444 |
mbstate_t ps;
|
|
|
29e444 |
size_t n;
|
|
|
29e444 |
const char *p;
|
|
|
29e444 |
@@ -356,10 +357,8 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
alloca_used);
|
|
|
29e444 |
n = mbsrtowcs (wpattern, &p, n + 1, &ps);
|
|
|
29e444 |
if (__builtin_expect (n == (size_t) -1, 0))
|
|
|
29e444 |
- /* Something wrong.
|
|
|
29e444 |
- XXX Do we have to set `errno' to something which mbsrtows hasn't
|
|
|
29e444 |
- already done? */
|
|
|
29e444 |
- return -1;
|
|
|
29e444 |
+ /* Something wrong: Fall back to single byte matching. */
|
|
|
29e444 |
+ goto try_singlebyte;
|
|
|
29e444 |
if (p)
|
|
|
29e444 |
{
|
|
|
29e444 |
memset (&ps, '\0', sizeof (ps));
|
|
|
29e444 |
@@ -371,10 +370,8 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
prepare_wpattern:
|
|
|
29e444 |
n = mbsrtowcs (NULL, &pattern, 0, &ps);
|
|
|
29e444 |
if (__builtin_expect (n == (size_t) -1, 0))
|
|
|
29e444 |
- /* Something wrong.
|
|
|
29e444 |
- XXX Do we have to set `errno' to something which mbsrtows hasn't
|
|
|
29e444 |
- already done? */
|
|
|
29e444 |
- return -1;
|
|
|
29e444 |
+ /*Something wrong: Fall back to single byte matching. */
|
|
|
29e444 |
+ goto try_singlebyte;
|
|
|
29e444 |
if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
|
|
|
29e444 |
{
|
|
|
29e444 |
__set_errno (ENOMEM);
|
|
|
29e444 |
@@ -401,14 +398,8 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
alloca_used);
|
|
|
29e444 |
n = mbsrtowcs (wstring, &p, n + 1, &ps);
|
|
|
29e444 |
if (__builtin_expect (n == (size_t) -1, 0))
|
|
|
29e444 |
- {
|
|
|
29e444 |
- /* Something wrong.
|
|
|
29e444 |
- XXX Do we have to set `errno' to something which
|
|
|
29e444 |
- mbsrtows hasn't already done? */
|
|
|
29e444 |
- free_return:
|
|
|
29e444 |
- free (wpattern_malloc);
|
|
|
29e444 |
- return -1;
|
|
|
29e444 |
- }
|
|
|
29e444 |
+ /* Something wrong: Fall back to single byte matching. */
|
|
|
29e444 |
+ goto free_and_try_singlebyte;
|
|
|
29e444 |
if (p)
|
|
|
29e444 |
{
|
|
|
29e444 |
memset (&ps, '\0', sizeof (ps));
|
|
|
29e444 |
@@ -420,10 +411,8 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
prepare_wstring:
|
|
|
29e444 |
n = mbsrtowcs (NULL, &string, 0, &ps);
|
|
|
29e444 |
if (__builtin_expect (n == (size_t) -1, 0))
|
|
|
29e444 |
- /* Something wrong.
|
|
|
29e444 |
- XXX Do we have to set `errno' to something which mbsrtows hasn't
|
|
|
29e444 |
- already done? */
|
|
|
29e444 |
- goto free_return;
|
|
|
29e444 |
+ /* Something wrong: Fall back to singlebyte matching. */
|
|
|
29e444 |
+ goto free_and_try_singlebyte;
|
|
|
29e444 |
if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
|
|
|
29e444 |
{
|
|
|
29e444 |
free (wpattern_malloc);
|
|
|
29e444 |
@@ -450,6 +439,10 @@ fnmatch (pattern, string, flags)
|
|
|
29e444 |
free (wpattern_malloc);
|
|
|
29e444 |
|
|
|
29e444 |
return res;
|
|
|
29e444 |
+ free_and_try_singlebyte:
|
|
|
29e444 |
+ free(wpattern_malloc);
|
|
|
29e444 |
+ try_singlebyte:
|
|
|
29e444 |
+ pattern = orig_pattern;
|
|
|
29e444 |
}
|
|
|
29e444 |
# endif /* mbstate_t and mbsrtowcs or _LIBC. */
|
|
|
29e444 |
|