[libc++] Add __iswctype to the locale base API since it's required by <locale> (#122168) GitOrigin-RevId: 81ae6686ab026c820f2f23d3c18cdd65ecb2ae7c
diff --git a/include/__locale_dir/locale_base_api.h b/include/__locale_dir/locale_base_api.h index 9957429..cda6033 100644 --- a/include/__locale_dir/locale_base_api.h +++ b/include/__locale_dir/locale_base_api.h
@@ -56,6 +56,7 @@ // int __strcoll(const char*, const char*, __locale_t); // size_t __strxfrm(char*, const char*, size_t, __locale_t); // +// int __iswctype(wint_t, wctype_t, __locale_t); // int __iswspace(wint_t, __locale_t); // int __iswprint(wint_t, __locale_t); // int __iswcntrl(wint_t, __locale_t); @@ -192,6 +193,9 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { return wcsxfrm_l(__dest, __src, __n, __loc); } +inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __ch, wctype_t __type, __locale_t __loc) { + return iswctype_l(__ch, __type, __loc); +} inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __ch, __locale_t __loc) { return iswspace_l(__ch, __loc); } inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __ch, __locale_t __loc) { return iswprint_l(__ch, __loc); } inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __ch, __locale_t __loc) { return iswcntrl_l(__ch, __loc); }
diff --git a/include/__locale_dir/support/bsd_like.h b/include/__locale_dir/support/bsd_like.h index da31aea..b3933c7 100644 --- a/include/__locale_dir/support/bsd_like.h +++ b/include/__locale_dir/support/bsd_like.h
@@ -94,6 +94,10 @@ } #if _LIBCPP_HAS_WIDE_CHARACTERS +inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { + return ::iswctype_l(__c, __type, __loc); +} + inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); } inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }
diff --git a/include/__locale_dir/support/windows.h b/include/__locale_dir/support/windows.h index 03d05a4..eca0e17 100644 --- a/include/__locale_dir/support/windows.h +++ b/include/__locale_dir/support/windows.h
@@ -206,6 +206,9 @@ } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { + return ::_iswctype_l(__c, __type, __loc); +} inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::_iswspace_l(__c, __loc); } inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::_iswprint_l(__c, __loc); } inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::_iswcntrl_l(__c, __loc); }
diff --git a/src/locale.cpp b/src/locale.cpp index a1e1040..599c61c 100644 --- a/src/locale.cpp +++ b/src/locale.cpp
@@ -1109,11 +1109,11 @@ ctype_byname<wchar_t>::~ctype_byname() { __locale::__freelocale(__l_); } bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const { + wint_t ch = static_cast<wint_t>(c); # ifdef _LIBCPP_WCTYPE_IS_MASK - return static_cast<bool>(iswctype_l(c, m, __l_)); + return static_cast<bool>(__locale::__iswctype(ch, m, __l_)); # else bool result = false; - wint_t ch = static_cast<wint_t>(c); if ((m & space) == space) result |= (__locale::__iswspace(ch, __l_) != 0); if ((m & print) == print) @@ -1179,7 +1179,7 @@ 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_)) + if (__locale::__iswctype(static_cast<wint_t>(*low), m, __l_)) break; # else wint_t ch = static_cast<wint_t>(*low); @@ -1210,11 +1210,11 @@ 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) { + wint_t ch = static_cast<wint_t>(*low); # ifdef _LIBCPP_WCTYPE_IS_MASK - if (!iswctype_l(*low, m, __l_)) + if (!__locale::__iswctype(ch, m, __l_)) break; # else - wint_t ch = static_cast<wint_t>(*low); if ((m & space) == space && __locale::__iswspace(ch, __l_)) continue; if ((m & print) == print && __locale::__iswprint(ch, __l_))