From a5038f060de9f1cc50cf532f78541dfd901f10b8 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 13 Oct 2007 16:28:22 +0000 Subject: The problem is: currently our single byte ctype(3) functions are broken for wide characters locales in the argument range >= 0x80 - they may return false positives. Example 1: for UTF-8 locale we currently have: iswspace(0xA0)==1 and isspace(0xA0)==1 (because iswspace() and isspace() are the same code) but must have iswspace(0xA0)==1 and isspace(0xA0)==0 (because there is no such character and all others in the range 0x80..0xff for the UTF-8 locale, it keeps ASCII only in the single byte range because our internal wchar_t representation for UTF-8 is UCS-4). Example 2: for all wide character locales isalpha(arg) when arg > 0xFF may return false positives (must be 0). (because iswalpha() and isalpha() are the same code) This change address this issue separating single byte and wide ctype and also fix iswascii() (currently iswascii() is broken for arguments > 0xFF). This change is 100% binary compatible with old binaries. Reviewied by: i18n@ --- include/wctype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/wctype.h') diff --git a/include/wctype.h b/include/wctype.h index 098045f..31f401f 100644 --- a/include/wctype.h +++ b/include/wctype.h @@ -106,7 +106,7 @@ __END_DECLS #define towupper(wc) __toupper(wc) #if __BSD_VISIBLE -#define iswascii(wc) (((wc) & ~0x7F) == 0) +#define iswascii(wc) ((wc) < 0x80) #define iswhexnumber(wc) __istype((wc), _CTYPE_X) #define iswideogram(wc) __istype((wc), _CTYPE_I) #define iswnumber(wc) __istype((wc), _CTYPE_D) -- cgit v1.1