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 * posix/fnmatch.c (fnmatch): If conversion to wide character fails fall back to single byte matching. --- posix/fnmatch.c 2003-03-19 13:24:08.000000000 +0100 +++ posix/fnmatch.c 2003-06-25 09:27:17.000000000 +0200 @@ -326,6 +326,7 @@ # 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; @@ -335,10 +336,8 @@ memset (&ps, '\0', sizeof (ps)); n = mbsrtowcs (NULL, &pattern, 0, &ps); if (__builtin_expect (n == (size_t) -1, 0)) - /* 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); @@ -346,16 +345,17 @@ assert (mbsinit (&ps)); n = mbsrtowcs (NULL, &string, 0, &ps); if (__builtin_expect (n == (size_t) -1, 0)) - /* 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. */