From cdd225afe8e94e87933642ed54d24ebdbac85757 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 2 Jun 2011 18:03:49 +0200 Subject: fix the [...] bug also for relatively unusual uni-byte encodings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/dfa.c (setbit_case_fold): Also handle uni-byte locales like the one mentioned in the original report: see 2011-05-07 commit d98338eb. Re-reported by Santiago Ruano Rincón. Note that most uni-byte locales are not affected. * NEWS (Bug fixes): Mention it. --- src/dfa.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dfa.c b/src/dfa.c index b41cbb6b..83386aae 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -573,10 +573,14 @@ setbit_case_fold ( else { #if MBS_SUPPORT - int b2 = wctob ((unsigned char) b); - if (b2 == EOF || b2 == b) + /* Below, note how when b2 != b and we have a uni-byte locale + (MB_CUR_MAX == 1), we set b = b2. I.e., in a uni-byte locale, + we can safely call setbit with a non-EOF value returned by wctob. */ + int b2 = wctob (b); + if (b2 == EOF || b2 == b || (MB_CUR_MAX == 1 ? (b=b2), 1 : 0)) #endif - setbit (b, c); + if (b < NOTCHAR) + setbit (b, c); } } -- cgit v1.2.1