This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
When fnmatch detects an invalid multibyte character it should fall back to single byte matching, so that "*" has a chance to match such a string. Andreas. 2002-11-28 Andreas Schwab <schwab@suse.de> * posix/fnmatch.c (fnmatch): If conversion to wide character fails fall back to single byte matching. --- posix/fnmatch.c.~1.47.~ 2001-07-16 10:43:43.000000000 +0200 +++ posix/fnmatch.c 2002-11-25 15:21:12.000000000 +0100 @@ -325,6 +325,7 @@ fnmatch (pattern, string, flags) # if HANDLE_MULTIBYTE if (__builtin_expect (MB_CUR_MAX, 1) != 1) { + const char *orig_pattern = pattern; mbstate_t ps; size_t n; wchar_t *wpattern; @@ -334,10 +335,8 @@ fnmatch (pattern, string, flags) memset (&ps, '\0', sizeof (ps)); n = mbsrtowcs (NULL, &pattern, 0, &ps); if (__builtin_expect (n, 0) == (size_t) -1) - /* Something wrong. - XXX Do we have to set `errno' to something which mbsrtows hasn't - already done? */ - return -1; + /* Something wrong. Fall back to single byte matching. */ + goto try_singlebyte; wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); assert (mbsinit (&ps)); (void) mbsrtowcs (wpattern, &pattern, n + 1, &ps); @@ -345,16 +344,17 @@ fnmatch (pattern, string, flags) assert (mbsinit (&ps)); n = mbsrtowcs (NULL, &string, 0, &ps); if (__builtin_expect (n, 0) == (size_t) -1) - /* Something wrong. - XXX Do we have to set `errno' to something which mbsrtows hasn't - already done? */ - return -1; + /* Something wrong. Fall back to single byte matching. */ + goto try_singlebyte; wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); assert (mbsinit (&ps)); (void) mbsrtowcs (wstring, &string, n + 1, &ps); return internal_fnwmatch (wpattern, wstring, wstring + n, flags & FNM_PERIOD, flags); + + try_singlebyte: + pattern = orig_pattern; } # endif /* mbstate_t and mbsrtowcs or _LIBC. */ -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |