summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-06-02 18:03:49 +0200
committerJim Meyering <meyering@redhat.com>2011-06-07 10:51:35 +0200
commitcdd225afe8e94e87933642ed54d24ebdbac85757 (patch)
treec6716ee50bf2b0a81c0b42e0ef50b82da99bcd75 /src
parenta5258004a87174122463f8160ea0eb6781fa2c95 (diff)
downloadgrep-cdd225afe8e94e87933642ed54d24ebdbac85757.tar.gz
fix the [...] bug also for relatively unusual uni-byte encodings
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/dfa.c10
1 files changed, 7 insertions, 3 deletions
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);
}
}