summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/gb18030.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2007-10-13 16:28:22 +0000
committerache <ache@FreeBSD.org>2007-10-13 16:28:22 +0000
commita5038f060de9f1cc50cf532f78541dfd901f10b8 (patch)
tree364de71872fe91708dda5fd7ffeb957967a6f749 /lib/libc/locale/gb18030.c
parent5b067f00c53dea274158508c1867eedfa02afea8 (diff)
downloadFreeBSD-src-a5038f060de9f1cc50cf532f78541dfd901f10b8.zip
FreeBSD-src-a5038f060de9f1cc50cf532f78541dfd901f10b8.tar.gz
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@
Diffstat (limited to 'lib/libc/locale/gb18030.c')
-rw-r--r--lib/libc/locale/gb18030.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libc/locale/gb18030.c b/lib/libc/locale/gb18030.c
index 3e43179..1457d3e 100644
--- a/lib/libc/locale/gb18030.c
+++ b/lib/libc/locale/gb18030.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
#include <wchar.h>
#include "mblocal.h"
+extern int __mb_sb_limit;
+
static size_t _GB18030_mbrtowc(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
static int _GB18030_mbsinit(const mbstate_t *);
@@ -59,6 +61,7 @@ _GB18030_init(_RuneLocale *rl)
__mbsinit = _GB18030_mbsinit;
_CurrentRuneLocale = rl;
__mb_cur_max = 4;
+ __mb_sb_limit = 128;
return (0);
}
OpenPOWER on IntegriCloud