summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2007-10-13 16:28:22 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2007-10-13 16:28:22 +0000
commit367ed4e13d697ceb415183d8a7acddf5f707667c (patch)
tree364de71872fe91708dda5fd7ffeb957967a6f749 /include
parentb46286393c7cc8cc0cd9330b1ea2280ec74ba579 (diff)
Notes
Diffstat (limited to 'include')
-rw-r--r--include/_ctype.h35
-rw-r--r--include/ctype.h42
-rw-r--r--include/wctype.h2
3 files changed, 56 insertions, 23 deletions
diff --git a/include/_ctype.h b/include/_ctype.h
index 1a42952a09dc..e27ab24f6c19 100644
--- a/include/_ctype.h
+++ b/include/_ctype.h
@@ -87,6 +87,8 @@ __END_DECLS
#define __inline
#endif
+extern int __mb_sb_limit;
+
/*
* Use inline functions if we are allowed to and the compiler supports them.
*/
@@ -103,15 +105,28 @@ __maskrune(__ct_rune_t _c, unsigned long _f)
}
static __inline int
+__sbmaskrune(__ct_rune_t _c, unsigned long _f)
+{
+ return (_c < 0 || _c >= __mb_sb_limit) ? 0 :
+ _CurrentRuneLocale->__runetype[_c] & _f;
+}
+
+static __inline int
__istype(__ct_rune_t _c, unsigned long _f)
{
return (!!__maskrune(_c, _f));
}
static __inline int
+__sbistype(__ct_rune_t _c, unsigned long _f)
+{
+ return (!!__sbmaskrune(_c, _f));
+}
+
+static __inline int
__isctype(__ct_rune_t _c, unsigned long _f)
{
- return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
+ return (_c < 0 || _c >= __mb_sb_limit) ? 0 :
!!(_DefaultRuneLocale.__runetype[_c] & _f);
}
@@ -123,12 +138,26 @@ __toupper(__ct_rune_t _c)
}
static __inline __ct_rune_t
+__sbtoupper(__ct_rune_t _c)
+{
+ return (_c < 0 || _c >= __mb_sb_limit) ? _c :
+ _CurrentRuneLocale->__mapupper[_c];
+}
+
+static __inline __ct_rune_t
__tolower(__ct_rune_t _c)
{
return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
_CurrentRuneLocale->__maplower[_c];
}
+static __inline __ct_rune_t
+__sbtolower(__ct_rune_t _c)
+{
+ return (_c < 0 || _c >= __mb_sb_limit) ? _c :
+ _CurrentRuneLocale->__maplower[_c];
+}
+
static __inline int
__wcwidth(__ct_rune_t _c)
{
@@ -146,10 +175,14 @@ __wcwidth(__ct_rune_t _c)
__BEGIN_DECLS
int __maskrune(__ct_rune_t, unsigned long);
+int __sbmaskrune(__ct_rune_t, unsigned long);
int __istype(__ct_rune_t, unsigned long);
+int __sbistype(__ct_rune_t, unsigned long);
int __isctype(__ct_rune_t, unsigned long);
__ct_rune_t __toupper(__ct_rune_t);
+__ct_rune_t __sbtoupper(__ct_rune_t);
__ct_rune_t __tolower(__ct_rune_t);
+__ct_rune_t __sbtolower(__ct_rune_t);
int __wcwidth(__ct_rune_t);
__END_DECLS
#endif /* using inlines */
diff --git a/include/ctype.h b/include/ctype.h
index 0825ff652c28..dfc89ccd5951 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_ */
diff --git a/include/wctype.h b/include/wctype.h
index 098045fa11a5..31f401ff76e6 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)