📄 wctype.c
字号:
<< WCuplow_TI_SHIFT; i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN + i + sc]) << 1; wc += WCuplow_diff[i]; } return wc;}#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */#endif /* SMALL_UPLOW */#ifdef L_towupper_lweak_alias(__towupper_l, towupper_l)#endif /* L_towupper_l */#endif /* __LOCALE_C_ONLY */#endif/**********************************************************************/#ifdef L_wctypestatic const unsigned char typestring[] = __CTYPE_TYPESTRING;/* extern const unsigned char typestring[]; */wctype_t wctype(const char *property){ const unsigned char *p; int i; p = typestring; i = 1; do { if (!strcmp(property, ++p)) { return i; } ++i; p += p[-1]; } while (*p); /* TODO - Add locale-specific classifications. */ return 0;}#endif/**********************************************************************/#ifdef L_wctype_l#ifdef __UCLIBC_MJN3_ONLY__#warning REMINDER: Currently wctype_l simply calls wctype.#endif /* __UCLIBC_MJN3_ONLY__ */wctype_t __wctype_l (const char *property, __locale_t locale){ return wctype(property);}weak_alias(__wctype_l, wctype_l)#endif/**********************************************************************/#if defined(L_iswctype) || defined(L_iswctype_l)#define __C_iswdigit(c) \ ((sizeof(c) == sizeof(char)) \ ? (((unsigned char)((c) - '0')) < 10) \ : (((__uwchar_t)((c) - '0')) < 10))#define __C_iswxdigit(c) \ (__C_iswdigit(c) \ || ((sizeof(c) == sizeof(char)) \ ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \ : (((__uwchar_t)((((c)) | 0x20) - 'a')) < 6)))#ifdef __UCLIBC_MJN3_ONLY__#ifdef L_iswctype#warning CONSIDER: Change to bit shift? would need to sync with wctype.h#endif#endif /* __UCLIBC_MJN3_ONLY__ */#ifdef __UCLIBC_HAS_CTYPE_TABLES__#if !defined(__UCLIBC_HAS_XLOCALE__) || defined(L_iswctype_l)static const unsigned short int desc2flag[] = { [_CTYPE_unclassified] = 0, [_CTYPE_isalnum] = (unsigned short int) _ISwalnum, [_CTYPE_isalpha] = (unsigned short int) _ISwalpha, [_CTYPE_isblank] = (unsigned short int) _ISwblank, [_CTYPE_iscntrl] = (unsigned short int) _ISwcntrl, [_CTYPE_isdigit] = (unsigned short int) _ISwdigit, [_CTYPE_isgraph] = (unsigned short int) _ISwgraph, [_CTYPE_islower] = (unsigned short int) _ISwlower, [_CTYPE_isprint] = (unsigned short int) _ISwprint, [_CTYPE_ispunct] = (unsigned short int) _ISwpunct, [_CTYPE_isspace] = (unsigned short int) _ISwspace, [_CTYPE_isupper] = (unsigned short int) _ISwupper, [_CTYPE_isxdigit] = (unsigned short int) _ISwxdigit,};#endif /* defined(L_iswctype_L) || defined(__LOCALE_C_ONLY) */#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */#ifdef __LOCALE_C_ONLY#ifdef __UCLIBC_HAS_CTYPE_TABLES__int __iswctype(wint_t wc, wctype_t desc){ /* Note... wctype_t is unsigned. */ if ((((__uwchar_t) wc) <= 0x7f) && (desc < (sizeof(desc2flag)/sizeof(desc2flag[0]))) ) { return __isctype(wc, desc2flag[desc]); } return 0;}#else /* __UCLIBC_HAS_CTYPE_TABLES__ */int __iswctype(wint_t wc, wctype_t desc){ /* This is lame, but it is here just to get it working for now. */ if (wc == ((unsigned int)(wc))) { switch(desc) { case _CTYPE_isupper: return __C_isupper((unsigned int)(wc)); case _CTYPE_islower: return __C_islower((unsigned int)(wc)); case _CTYPE_isalpha: return __C_isalpha((unsigned int)(wc)); case _CTYPE_isdigit: return __C_isdigit((unsigned int)(wc)); case _CTYPE_isxdigit: return __C_isxdigit((unsigned int)(wc)); case _CTYPE_isspace: return __C_isspace((unsigned int)(wc)); case _CTYPE_isprint: return __C_isprint((unsigned int)(wc)); case _CTYPE_isgraph: return __C_isgraph((unsigned int)(wc)); case _CTYPE_isblank: return __C_isblank((unsigned int)(wc)); case _CTYPE_iscntrl: return __C_iscntrl((unsigned int)(wc)); case _CTYPE_ispunct: return __C_ispunct((unsigned int)(wc)); case _CTYPE_isalnum: return __C_isalnum((unsigned int)(wc)); default: break; } } return 0;}#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */#else /* __LOCALE_C_ONLY */#ifdef __UCLIBC_MJN3_ONLY__#ifdef L_iswctype#warning CONSIDER: Handle combining class?#endif#endif /* __UCLIBC_MJN3_ONLY__ */#ifdef L_iswctype#define ISWCTYPE(w,d) __iswctype(w,d)#else /* L_iswctype */#define ISWCTYPE(w,d) __iswctype_l(w,d, __locale_t locale)#undef __UCLIBC_CURLOCALE_DATA#undef __UCLIBC_CURLOCALE#define __UCLIBC_CURLOCALE_DATA (*locale)#define __UCLIBC_CURLOCALE (locale)#endif /* L_iswctype */#if defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__)int __iswctype(wint_t wc, wctype_t desc){ return __iswctype_l(wc, desc, __UCLIBC_CURLOCALE);}#else /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */int ISWCTYPE(wint_t wc, wctype_t desc){ unsigned int sc, n, i0, i1; unsigned char d = __CTYPE_unclassified; if ((ENCODING != __ctype_encoding_7_bit) || (((__uwchar_t) wc) <= 0x7f)){ if (desc < _CTYPE_iswxdigit) { if (((__uwchar_t) wc) <= WC_TABLE_DOMAIN_MAX) { /* From here on, we know wc > 0. */ sc = wc & WCctype_TI_MASK; wc >>= WCctype_TI_SHIFT; n = wc & WCctype_II_MASK; wc >>= WCctype_II_SHIFT; i0 = WCctype[wc]; i0 <<= WCctype_II_SHIFT; i1 = WCctype[WCctype_II_LEN + i0 + n]; i1 <<= (WCctype_TI_SHIFT-1); d = WCctype[WCctype_II_LEN + WCctype_TI_LEN + i1 + (sc >> 1)]; d = (sc & 1) ? (d >> 4) : (d & 0xf); } else if ( ((((__uwchar_t)(wc - 0xe0020UL)) <= 0x5f) || (wc == 0xe0001UL)) || ( (((__uwchar_t)(wc - 0xf0000UL)) < 0x20000UL) && ((wc & 0xffffU) <= 0xfffdU)) ) { d = __CTYPE_punct; }#if 0 return ( ((unsigned char)(d - ctype_range[2*desc])) <= ctype_range[2*desc + 1] ) && ((desc != _CTYPE_iswblank) || (d & 1));#else return (__UCLIBC_CURLOCALE_DATA).code2flag[d] & desc2flag[desc];#endif }#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: xdigit really needs to be handled better. Remember only for ascii!#endif /* __UCLIBC_MJN3_ONLY__ */ /* TODO - Add locale-specific classifications. */ return (desc == _CTYPE_iswxdigit) ? __C_iswxdigit(wc) : 0; } return 0;}#endif /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */#ifdef L_iswctype_lweak_alias(__iswctype_l, iswctype_l)#endif /* L_iswctype_l */#endif /* __LOCALE_C_ONLY */#ifdef L_iswctypeweak_alias(__iswctype, iswctype)#endif /* L_iswctype */#endif/**********************************************************************/#if defined(L_towctrans) || defined(L_towctrans_l)#ifdef __LOCALE_C_ONLY/* Minimal support for C/POSIX locale. */#ifndef _tolower#warning _tolower is undefined!#define _tolower(c) tolower(c)#endif#ifndef _toupper#warning _toupper is undefined!#define _toupper(c) toupper(c)#endifwint_t towctrans(wint_t wc, wctrans_t desc){ if (((unsigned int)(desc - _CTYPE_tolower)) <= (_CTYPE_toupper - _CTYPE_tolower) ) { /* Transliteration is either tolower or toupper. */ if (((__uwchar_t) wc) <= 0x7f) { return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc); } } else { __set_errno(EINVAL); /* Invalid transliteration. */ } return wc;}#else /* __LOCALE_C_ONLY */#ifdef L_towctrans#define TOWCTRANS(w,d) towctrans(w,d)#else /* L_towctrans */#define TOWCTRANS(w,d) __towctrans_l(w,d, __locale_t locale)#undef __UCLIBC_CURLOCALE_DATA#undef __UCLIBC_CURLOCALE#define __UCLIBC_CURLOCALE_DATA (*locale)#define __UCLIBC_CURLOCALE (locale)#endif /* L_towctrans */#ifdef __UCLIBC_HAS_XLOCALE__#define TOWLOWER(w,l) __towlower_l(w,l)#define TOWUPPER(w,l) __towupper_l(w,l)#else /* __UCLIBC_HAS_XLOCALE__ */#define TOWLOWER(w,l) towlower(w)#define TOWUPPER(w,l) towupper(w)#endif /* __UCLIBC_HAS_XLOCALE__ */#if defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__)wint_t towctrans(wint_t wc, wctrans_t desc){ return __towctrans_l(wc, desc, __UCLIBC_CURLOCALE);}#else /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */#ifdef SMALL_UPLOWwint_t TOWCTRANS(wint_t wc, wctrans_t desc){ unsigned int sc, n, i; __uwchar_t u = wc; /* TODO - clean up */ if (ENCODING == __ctype_encoding_7_bit) { if ((((__uwchar_t) wc) > 0x7f) || (((unsigned int)(desc - _CTYPE_tolower)) > (_CTYPE_toupper - _CTYPE_tolower)) ){ /* We're in the C/POSIX locale, so ignore non-ASCII values * as well an any mappings other than toupper or tolower. */ return wc; } } if (((unsigned int)(desc - _CTYPE_tolower)) <= (_CTYPE_totitle - _CTYPE_tolower) ) { if (u <= WC_TABLE_DOMAIN_MAX) { sc = u & ((1 << WCuplow_TI_SHIFT) - 1); u >>= WCuplow_TI_SHIFT; n = u & ((1 << WCuplow_II_SHIFT) - 1); u >>= WCuplow_II_SHIFT; i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT; i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n]) << WCuplow_TI_SHIFT; i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN + i + sc]) << 1; if (desc == _CTYPE_tolower) { ++i; } wc += WCuplow_diff[i]; if (desc == _CTYPE_totitle) {#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: Verify totitle special cases!#endif /* __UCLIBC_MJN3_ONLY__ */ /* WARNING! These special cases work for glibc 2.2.4. Changes * may be needed if the glibc locale tables are updated. */ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4)) || (wc == 0x1f1) ) { ++wc; } } } } else { /* TODO - Deal with other transliterations. */ __set_errno(EINVAL); } return wc;}#else /* SMALL_UPLOW */wint_t TOWCTRANS(wint_t wc, wctrans_t desc){ if (ENCODING == __ctype_encoding_7_bit) { if ((((__uwchar_t) wc) > 0x7f) || (((unsigned int)(desc - _CTYPE_tolower)) > (_CTYPE_toupper - _CTYPE_tolower)) ){ /* We're in the C/POSIX locale, so ignore non-ASCII values * as well an any mappings other than toupper or tolower. */ return wc; } } if (desc == _CTYPE_tolower) { return TOWLOWER(wc, __UCLIBC_CURLOCALE); } else if (((unsigned int)(desc - _CTYPE_toupper)) <= (_CTYPE_totitle - _CTYPE_toupper) ) { wc = TOWUPPER(wc, __UCLIBC_CURLOCALE); if (desc == _CTYPE_totitle) {#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: Verify totitle special cases!#endif /* __UCLIBC_MJN3_ONLY__ */ /* WARNING! These special cases work for glibc 2.2.4. Changes * may be needed if the glibc locale tables are updated. */ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4)) || (wc == 0x1f1) ) { ++wc; } } } else { /* TODO - Deal with other transliterations. */ __set_errno(EINVAL); } return wc;}#endif /* SMALL_UPLOW */#endif /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */#ifdef L_towctrans_lweak_alias(__towctrans_l, towctrans_l)#endif /* L_towctrans_l */#endif /* __LOCALE_C_ONLY */#endif/**********************************************************************/#ifdef L_wctransstatic const char transstring[] = __CTYPE_TRANSTRING;wctrans_t wctrans(const char *property){ const unsigned char *p; int i; p = transstring; i = 1; do { if (!strcmp(property, ++p)) { return i; } ++i; p += p[-1]; } while (*p); /* TODO - Add locale-specific translations. */ return 0;}#endif/**********************************************************************/#ifdef L_wctrans_l#ifdef __UCLIBC_MJN3_ONLY__#warning REMINDER: Currently wctrans_l simply calls wctrans.#endif /* __UCLIBC_MJN3_ONLY__ */wctrans_t __wctrans_l(const char *property, __locale_t locale){ return wctrans(property);}weak_alias(__wctrans_l, wctrans_l)#endif/**********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -