Don't assume that wctype produces a nice mask on all platforms. On
glibc, for instance, it's a const char *. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134787 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e59f724f79
commit
6f0342cf2e
@ -289,4 +289,8 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_STABLE_APPLE_ABI
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _LIBCPP_WCTYPE_IS_MASK
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CONFIG
|
||||
|
@ -1114,7 +1114,21 @@ ctype_byname<wchar_t>::~ctype_byname()
|
||||
bool
|
||||
ctype_byname<wchar_t>::do_is(mask m, char_type c) const
|
||||
{
|
||||
#ifdef _LIBCPP_WCTYPE_IS_MASK
|
||||
return static_cast<bool>(iswctype_l(c, m, __l));
|
||||
#else
|
||||
if (m & space && !iswspace_l(c, __l)) return false;
|
||||
if (m & print && !iswprint_l(c, __l)) return false;
|
||||
if (m & cntrl && !iswcntrl_l(c, __l)) return false;
|
||||
if (m & upper && !iswupper_l(c, __l)) return false;
|
||||
if (m & lower && !iswlower_l(c, __l)) return false;
|
||||
if (m & alpha && !iswalpha_l(c, __l)) return false;
|
||||
if (m & digit && !iswdigit_l(c, __l)) return false;
|
||||
if (m & punct && !iswpunct_l(c, __l)) return false;
|
||||
if (m & xdigit && !iswxdigit_l(c, __l)) return false;
|
||||
if (m & blank && !iswblank_l(c, __l)) return false;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
@ -1154,8 +1168,24 @@ const wchar_t*
|
||||
ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
|
||||
{
|
||||
for (; low != high; ++low)
|
||||
{
|
||||
#ifdef _LIBCPP_WCTYPE_IS_MASK
|
||||
if (iswctype_l(*low, m, __l))
|
||||
break;
|
||||
#else
|
||||
if (m & space && !iswspace_l(*low, __l)) continue;
|
||||
if (m & print && !iswprint_l(*low, __l)) continue;
|
||||
if (m & cntrl && !iswcntrl_l(*low, __l)) continue;
|
||||
if (m & upper && !iswupper_l(*low, __l)) continue;
|
||||
if (m & lower && !iswlower_l(*low, __l)) continue;
|
||||
if (m & alpha && !iswalpha_l(*low, __l)) continue;
|
||||
if (m & digit && !iswdigit_l(*low, __l)) continue;
|
||||
if (m & punct && !iswpunct_l(*low, __l)) continue;
|
||||
if (m & xdigit && !iswxdigit_l(*low, __l)) continue;
|
||||
if (m & blank && !iswblank_l(*low, __l)) continue;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return low;
|
||||
}
|
||||
|
||||
@ -1163,8 +1193,24 @@ const wchar_t*
|
||||
ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
|
||||
{
|
||||
for (; low != high; ++low)
|
||||
{
|
||||
#ifdef _LIBCPP_WCTYPE_IS_MASK
|
||||
if (!iswctype_l(*low, m, __l))
|
||||
break;
|
||||
#else
|
||||
if (m & space && iswspace_l(*low, __l)) continue;
|
||||
if (m & print && iswprint_l(*low, __l)) continue;
|
||||
if (m & cntrl && iswcntrl_l(*low, __l)) continue;
|
||||
if (m & upper && iswupper_l(*low, __l)) continue;
|
||||
if (m & lower && iswlower_l(*low, __l)) continue;
|
||||
if (m & alpha && iswalpha_l(*low, __l)) continue;
|
||||
if (m & digit && iswdigit_l(*low, __l)) continue;
|
||||
if (m & punct && iswpunct_l(*low, __l)) continue;
|
||||
if (m & xdigit && iswxdigit_l(*low, __l)) continue;
|
||||
if (m & blank && iswblank_l(*low, __l)) continue;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return low;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user