X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=internals%2F_PDCLIB_locale.h;h=fd47c9ab0c4b537835d374536d20d15e9b0a70e1;hp=3b2deced51b3f519eb01ed49f1a325da69183955;hb=fa53a74861e1ac9513ae57b7bd7889b85ac0fbe9;hpb=6e6c4e6b52f2516e4bb6b9f37c1e2e18cb7448b5 diff --git a/internals/_PDCLIB_locale.h b/internals/_PDCLIB_locale.h index 3b2dece..fd47c9a 100644 --- a/internals/_PDCLIB_locale.h +++ b/internals/_PDCLIB_locale.h @@ -2,6 +2,7 @@ #define __PDCLIB_LOCALE_H __PDCLIB_LOCALE_H #include <_PDCLIB_int.h> #include +#include #include #include @@ -78,6 +79,19 @@ typedef struct _PDCLIB_wcinfo _PDCLIB_wint_t upper; } _PDCLIB_wcinfo_t; +struct _PDCLIB_locale { + _PDCLIB_charcodec_t _Codec; + struct lconv _Conv; + + /* ctype / wctype */ + _PDCLIB_wcinfo_t *_WCType; + _PDCLIB_size_t _WCTypeSize; + _PDCLIB_ctype_t *_CType; + + /* perror/strerror */ + char *_ErrnoStr[_PDCLIB_ERRNO_MAX]; +}; + extern _PDCLIB_wcinfo_t _PDCLIB_wcinfo[]; extern size_t _PDCLIB_wcinfo_size; @@ -88,32 +102,32 @@ static inline int _PDCLIB_wcinfo_cmp( const void * _key, const void * _obj ) return *key - obj->num; } -static inline _PDCLIB_wcinfo_t * _PDCLIB_wcgetinfo( _PDCLIB_uint32_t num ) +static inline _PDCLIB_wcinfo_t * _PDCLIB_wcgetinfo( locale_t l, _PDCLIB_uint32_t num ) { _PDCLIB_wcinfo_t *info = (_PDCLIB_wcinfo_t*) - bsearch( &num, _PDCLIB_wcinfo, _PDCLIB_wcinfo_size, - sizeof( _PDCLIB_wcinfo[0] ), _PDCLIB_wcinfo_cmp ); + bsearch( &num, l->_WCType, l->_WCTypeSize, + sizeof( l->_WCType[0] ), _PDCLIB_wcinfo_cmp ); return info; } -static inline _PDCLIB_wint_t _PDCLIB_unpackwint( _PDCLIB_wint_t wc ) +static inline wint_t _PDCLIB_unpackwint( wint_t wc ) { if( sizeof(_PDCLIB_wchar_t) == 2 && sizeof(_PDCLIB_wint_t) == 4 ) { /* On UTF-16 platforms, as an extension accept a "packed surrogate" * encoding. We accept the surrogate pairs either way */ - _PDCLIB_wint_t c = (wc & 0xF800F800); + wint_t c = (wc & 0xF800F800); if(c == (_PDCLIB_wint_t) 0xD800DC00) { // MSW: Lead, LSW: Trail - _PDCLIB_wint_t lead = wc >> 16 & 0x3FF; - _PDCLIB_wint_t trail = wc & 0x3FF; + wint_t lead = wc >> 16 & 0x3FF; + wint_t trail = wc & 0x3FF; wc = lead << 10 | trail; } else if(c == (_PDCLIB_wint_t) 0xDC00D800) { // MSW: Trail, LSW: Lead - _PDCLIB_wint_t trail = wc >> 16 & 0x3FF; - _PDCLIB_wint_t lead = wc & 0x3FF; + wint_t trail = wc >> 16 & 0x3FF; + wint_t lead = wc & 0x3FF; wc = lead << 10 | trail; } @@ -121,15 +135,22 @@ static inline _PDCLIB_wint_t _PDCLIB_unpackwint( _PDCLIB_wint_t wc ) return wc; } -struct _PDCLIB_locale { - _PDCLIB_charcodec_t _Codec; - struct lconv _Conv; - - /* ctype */ - _PDCLIB_ctype_t *_CType; - - /* perror/strerror */ - char *_ErrnoStr[_PDCLIB_ERRNO_MAX]; -}; +/* Internal xlocale-style WCType API */ +int _PDCLIB_iswalnum_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswalpha_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswblank_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswcntrl_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswdigit_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswgraph_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswlower_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswprint_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswpunct_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswspace_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswupper_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswxdigit_l( wint_t _Wc, locale_t l ); +int _PDCLIB_iswctype_l( wint_t _Wc, wctype_t _Desc, locale_t l ); +wint_t _PDCLIB_towlower_l( wint_t _Wc, locale_t l ); +wint_t _PDCLIB_towupper_l( wint_t _Wc, locale_t l ); +wint_t _PDCLIB_towctrans_l( wint_t _Wc, wctrans_t _Desc, locale_t l ); #endif