From 65021cb444e137937b38b258e45f889750175eb8 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Sat, 16 Mar 2013 18:57:09 +0000 Subject: [PATCH] PDCLIB-3: Add lookup functions to _PDCLIB_locale.h which can be used to lookup the classification information pertaining to a wide character --- internals/_PDCLIB_locale.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internals/_PDCLIB_locale.h b/internals/_PDCLIB_locale.h index 8d28f2d..3e0f424 100644 --- a/internals/_PDCLIB_locale.h +++ b/internals/_PDCLIB_locale.h @@ -75,6 +75,25 @@ typedef struct _PDCLIB_wcinfo _PDCLIB_uint32_t upper; } _PDCLIB_wcinfo_t; +extern _PDCLIB_wcinfo_t _PDCLIB_wcinfo[]; +extern size_t _PDCLIB_wcinfo_size; + +static inline int _PDCLIB_wcinfo_cmp( const void * _key, const void * _obj ) +{ + _PDCLIB_uint32_t * key = (_PDCLIB_uint32_t *) _key; + _PDCLIB_wcinfo_t * obj = (_PDCLIB_wcinfo_t *) _obj; + return *key - obj->num; +} + +static inline _PDCLIB_wcinfo_t * _PDCLIB_wcgetinfo( _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 ); + + return info; +} + static inline _PDCLIB_wint_t _PDCLIB_unpackwint( _PDCLIB_wint_t wc ) { if( sizeof(_PDCLIB_wchar_t) == 2 && sizeof(_PDCLIB_wint_t) == 4 ) { -- 2.40.0