@@ -54,40 +54,57 @@ enum {
5454 WC_TYPE_MAX
5555};
5656
57- int iswalnum (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_POSIX_ALNUM, isalnum); }
57+ static u_hasBinaryProperty_t __find_u_hasBinaryProperty () {
58+ static auto u_hasBinaryProperty =
59+ reinterpret_cast <u_hasBinaryProperty_t>(__find_icu_symbol (" u_hasBinaryProperty" ));
60+ return u_hasBinaryProperty;
61+ }
62+
63+ #define DO_ISW (icu_constant, narrow_fn ) \
64+ u_hasBinaryProperty_t u_hasBinaryProperty; \
65+ if (__predict_true(wc < 0x80 ) || \
66+ !(u_hasBinaryProperty = __find_u_hasBinaryProperty())) { \
67+ return narrow_fn (wc); \
68+ } \
69+ return u_hasBinaryProperty(wc, icu_constant); \
70+
71+ int iswalnum (wint_t wc) { DO_ISW (UCHAR_POSIX_ALNUM, isalnum); }
5872__strong_alias (iswalnum_l, iswalnum);
59- int iswalpha (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_ALPHABETIC, isalpha); }
73+ int iswalpha (wint_t wc) { DO_ISW ( UCHAR_ALPHABETIC, isalpha); }
6074__strong_alias (iswalpha_l, iswalpha);
61- int iswblank (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_POSIX_BLANK, isblank); }
75+ int iswblank (wint_t wc) { DO_ISW ( UCHAR_POSIX_BLANK, isblank); }
6276__strong_alias (iswblank_l, iswblank);
63- int iswgraph (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_POSIX_GRAPH, isgraph); }
77+ int iswgraph (wint_t wc) { DO_ISW ( UCHAR_POSIX_GRAPH, isgraph); }
6478__strong_alias (iswgraph_l, iswgraph);
65- int iswlower (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_LOWERCASE, islower); }
79+ int iswlower (wint_t wc) { DO_ISW ( UCHAR_LOWERCASE, islower); }
6680__strong_alias (iswlower_l, iswlower);
67- int iswprint (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_POSIX_PRINT, isprint); }
81+ int iswprint (wint_t wc) { DO_ISW ( UCHAR_POSIX_PRINT, isprint); }
6882__strong_alias (iswprint_l, iswprint);
69- int iswspace (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_WHITE_SPACE, isspace); }
83+ int iswspace (wint_t wc) { DO_ISW ( UCHAR_WHITE_SPACE, isspace); }
7084__strong_alias (iswspace_l, iswspace);
71- int iswupper (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_UPPERCASE, isupper); }
85+ int iswupper (wint_t wc) { DO_ISW ( UCHAR_UPPERCASE, isupper); }
7286__strong_alias (iswupper_l, iswupper);
73- int iswxdigit (wint_t wc) { return __icu_hasBinaryProperty (wc, UCHAR_POSIX_XDIGIT, isxdigit); }
87+ int iswxdigit (wint_t wc) { DO_ISW ( UCHAR_POSIX_XDIGIT, isxdigit); }
7488__strong_alias (iswxdigit_l, iswxdigit);
7589
7690int iswcntrl (wint_t wc) {
91+ if (wc < 0x80 ) return iscntrl (wc);
7792 typedef int8_t (*FnT)(UChar32);
7893 static auto u_charType = reinterpret_cast <FnT>(__find_icu_symbol (" u_charType" ));
7994 return u_charType ? (u_charType (wc) == U_CONTROL_CHAR) : iscntrl (wc);
8095}
8196__strong_alias (iswcntrl_l, iswcntrl);
8297
8398int iswdigit (wint_t wc) {
99+ if (wc < 0x80 ) return isdigit (wc);
84100 typedef UBool (*FnT)(UChar32);
85101 static auto u_isdigit = reinterpret_cast <FnT>(__find_icu_symbol (" u_isdigit" ));
86102 return u_isdigit ? u_isdigit (wc) : isdigit (wc);
87103}
88104__strong_alias (iswdigit_l, iswdigit);
89105
90106int iswpunct (wint_t wc) {
107+ if (wc < 0x80 ) return ispunct (wc);
91108 typedef UBool (*FnT)(UChar32);
92109 static auto u_ispunct = reinterpret_cast <FnT>(__find_icu_symbol (" u_ispunct" ));
93110 return u_ispunct ? u_ispunct (wc) : ispunct (wc);
0 commit comments