diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1995-11-03 12:25:14 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1995-11-03 12:25:14 +0000 |
| commit | 15b31aa05a681edaed2d190c0f921fb644c152fb (patch) | |
| tree | caea21754830d1d5342e4470073b139bd18ca4b7 /include | |
| parent | 1babea36caf5e630c730e7b8a29bc89994d41af1 (diff) | |
Notes
Diffstat (limited to 'include')
| -rw-r--r-- | include/_ctype.h | 31 | ||||
| -rw-r--r-- | include/ctype.h | 31 |
2 files changed, 26 insertions, 36 deletions
diff --git a/include/_ctype.h b/include/_ctype.h index 157134eea8793..963a4d4416b13 100644 --- a/include/_ctype.h +++ b/include/_ctype.h @@ -111,9 +111,9 @@ __END_DECLS #define ishexnumber(c) __istype((c), _X) #define isideogram(c) __istype((c), _I) #define isnumber(c) __istype((c), _D) -#define isphonogram(c) __istype((c), _T) +#define isphonogram(c) __istype((c), _Q) #define isrune(c) __istype((c), 0xFFFFFF00L) -#define isspecial(c) __istype((c), _Q) +#define isspecial(c) __istype((c), _T) #endif /* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */ @@ -141,37 +141,32 @@ __END_DECLS static __inline int __istype(_BSD_RUNE_T_ _c, unsigned long _f) { - if (_c < 0) - _c = (unsigned char) _c; - return((((_c & _CRMASK) ? ___runetype(_c) : - _CurrentRuneLocale->runetype[_c]) & _f) ? 1 : 0); + return (_c < 0 || _c & _CRMASK) ? !!(___runetype(_c) & _f) : + (_c >= _CACHED_RUNES) ? 0 : + !!(_CurrentRuneLocale->runetype[_c] & _f); } static __inline int __isctype(_BSD_RUNE_T_ _c, unsigned long _f) { - if (_c < 0) - _c = (unsigned char) _c; - return((((_c & _CRMASK) ? 0 : - _DefaultRuneLocale.runetype[_c]) & _f) ? 1 : 0); + return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : + !!(_DefaultRuneLocale.runetype[_c] & _f); } static __inline _BSD_RUNE_T_ __toupper(_BSD_RUNE_T_ _c) { - if (_c < 0) - _c = (unsigned char) _c; - return((_c & _CRMASK) ? - ___toupper(_c) : _CurrentRuneLocale->mapupper[_c]); + return (_c < 0 || _c & _CRMASK) ? ___toupper(_c) : + (_c >= _CACHED_RUNES) ? _c : + _CurrentRuneLocale->mapupper[_c]; } static __inline _BSD_RUNE_T_ __tolower(_BSD_RUNE_T_ _c) { - if (_c < 0) - _c = (unsigned char) _c; - return((_c & _CRMASK) ? - ___tolower(_c) : _CurrentRuneLocale->maplower[_c]); + return (_c < 0 || _c & _CRMASK) ? ___tolower(_c) : + (_c >= _CACHED_RUNES) ? _c : + _CurrentRuneLocale->maplower[_c]; } #else /* not using inlines */ diff --git a/include/ctype.h b/include/ctype.h index 157134eea8793..963a4d4416b13 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -111,9 +111,9 @@ __END_DECLS #define ishexnumber(c) __istype((c), _X) #define isideogram(c) __istype((c), _I) #define isnumber(c) __istype((c), _D) -#define isphonogram(c) __istype((c), _T) +#define isphonogram(c) __istype((c), _Q) #define isrune(c) __istype((c), 0xFFFFFF00L) -#define isspecial(c) __istype((c), _Q) +#define isspecial(c) __istype((c), _T) #endif /* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */ @@ -141,37 +141,32 @@ __END_DECLS static __inline int __istype(_BSD_RUNE_T_ _c, unsigned long _f) { - if (_c < 0) - _c = (unsigned char) _c; - return((((_c & _CRMASK) ? ___runetype(_c) : - _CurrentRuneLocale->runetype[_c]) & _f) ? 1 : 0); + return (_c < 0 || _c & _CRMASK) ? !!(___runetype(_c) & _f) : + (_c >= _CACHED_RUNES) ? 0 : + !!(_CurrentRuneLocale->runetype[_c] & _f); } static __inline int __isctype(_BSD_RUNE_T_ _c, unsigned long _f) { - if (_c < 0) - _c = (unsigned char) _c; - return((((_c & _CRMASK) ? 0 : - _DefaultRuneLocale.runetype[_c]) & _f) ? 1 : 0); + return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : + !!(_DefaultRuneLocale.runetype[_c] & _f); } static __inline _BSD_RUNE_T_ __toupper(_BSD_RUNE_T_ _c) { - if (_c < 0) - _c = (unsigned char) _c; - return((_c & _CRMASK) ? - ___toupper(_c) : _CurrentRuneLocale->mapupper[_c]); + return (_c < 0 || _c & _CRMASK) ? ___toupper(_c) : + (_c >= _CACHED_RUNES) ? _c : + _CurrentRuneLocale->mapupper[_c]; } static __inline _BSD_RUNE_T_ __tolower(_BSD_RUNE_T_ _c) { - if (_c < 0) - _c = (unsigned char) _c; - return((_c & _CRMASK) ? - ___tolower(_c) : _CurrentRuneLocale->maplower[_c]); + return (_c < 0 || _c & _CRMASK) ? ___tolower(_c) : + (_c >= _CACHED_RUNES) ? _c : + _CurrentRuneLocale->maplower[_c]; } #else /* not using inlines */ |
