summaryrefslogtreecommitdiffstats
path: root/include/ctype.h
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 /include/ctype.h
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 'include/ctype.h')
-rw-r--r--include/ctype.h42
1 files changed, 21 insertions, 21 deletions
diff --git a/include/ctype.h b/include/ctype.h
index 0825ff6..dfc89cc 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -86,19 +86,19 @@ int isspecial(int);
#endif
__END_DECLS
-#define isalnum(c) __istype((c), _CTYPE_A|_CTYPE_D)
-#define isalpha(c) __istype((c), _CTYPE_A)
-#define iscntrl(c) __istype((c), _CTYPE_C)
+#define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D)
+#define isalpha(c) __sbistype((c), _CTYPE_A)
+#define iscntrl(c) __sbistype((c), _CTYPE_C)
#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */
-#define isgraph(c) __istype((c), _CTYPE_G)
-#define islower(c) __istype((c), _CTYPE_L)
-#define isprint(c) __istype((c), _CTYPE_R)
-#define ispunct(c) __istype((c), _CTYPE_P)
-#define isspace(c) __istype((c), _CTYPE_S)
-#define isupper(c) __istype((c), _CTYPE_U)
+#define isgraph(c) __sbistype((c), _CTYPE_G)
+#define islower(c) __sbistype((c), _CTYPE_L)
+#define isprint(c) __sbistype((c), _CTYPE_R)
+#define ispunct(c) __sbistype((c), _CTYPE_P)
+#define isspace(c) __sbistype((c), _CTYPE_S)
+#define isupper(c) __sbistype((c), _CTYPE_U)
#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */
-#define tolower(c) __tolower(c)
-#define toupper(c) __toupper(c)
+#define tolower(c) __sbtolower(c)
+#define toupper(c) __sbtoupper(c)
#if __XSI_VISIBLE
/*
@@ -112,24 +112,24 @@ __END_DECLS
*
* XXX isascii() and toascii() should similarly be undocumented.
*/
-#define _tolower(c) __tolower(c)
-#define _toupper(c) __toupper(c)
+#define _tolower(c) __sbtolower(c)
+#define _toupper(c) __sbtoupper(c)
#define isascii(c) (((c) & ~0x7F) == 0)
#define toascii(c) ((c) & 0x7F)
#endif
#if __ISO_C_VISIBLE >= 1999
-#define isblank(c) __istype((c), _CTYPE_B)
+#define isblank(c) __sbistype((c), _CTYPE_B)
#endif
#if __BSD_VISIBLE
-#define digittoint(c) __maskrune((c), 0xFF)
-#define ishexnumber(c) __istype((c), _CTYPE_X)
-#define isideogram(c) __istype((c), _CTYPE_I)
-#define isnumber(c) __istype((c), _CTYPE_D)
-#define isphonogram(c) __istype((c), _CTYPE_Q)
-#define isrune(c) __istype((c), 0xFFFFFF00L)
-#define isspecial(c) __istype((c), _CTYPE_T)
+#define digittoint(c) __sbmaskrune((c), 0xFF)
+#define ishexnumber(c) __sbistype((c), _CTYPE_X)
+#define isideogram(c) __sbistype((c), _CTYPE_I)
+#define isnumber(c) __sbistype((c), _CTYPE_D)
+#define isphonogram(c) __sbistype((c), _CTYPE_Q)
+#define isrune(c) __sbistype((c), 0xFFFFFF00L)
+#define isspecial(c) __sbistype((c), _CTYPE_T)
#endif
#endif /* !_CTYPE_H_ */
OpenPOWER on IntegriCloud