Skip to content

Commit 81ae668

Browse files
authored
[libc++] Add __iswctype to the locale base API since it's required by <locale> (llvm#122168)
1 parent a0d7749 commit 81ae668

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

libcxx/include/__locale_dir/locale_base_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
// int __strcoll(const char*, const char*, __locale_t);
5757
// size_t __strxfrm(char*, const char*, size_t, __locale_t);
5858
//
59+
// int __iswctype(wint_t, wctype_t, __locale_t);
5960
// int __iswspace(wint_t, __locale_t);
6061
// int __iswprint(wint_t, __locale_t);
6162
// int __iswcntrl(wint_t, __locale_t);
@@ -192,6 +193,9 @@ inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* _
192193
inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
193194
return wcsxfrm_l(__dest, __src, __n, __loc);
194195
}
196+
inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __ch, wctype_t __type, __locale_t __loc) {
197+
return iswctype_l(__ch, __type, __loc);
198+
}
195199
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __ch, __locale_t __loc) { return iswspace_l(__ch, __loc); }
196200
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __ch, __locale_t __loc) { return iswprint_l(__ch, __loc); }
197201
inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __ch, __locale_t __loc) { return iswcntrl_l(__ch, __loc); }

libcxx/include/__locale_dir/support/bsd_like.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
9494
}
9595

9696
#if _LIBCPP_HAS_WIDE_CHARACTERS
97+
inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
98+
return ::iswctype_l(__c, __type, __loc);
99+
}
100+
97101
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); }
98102

99103
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }

libcxx/include/__locale_dir/support/windows.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
206206
}
207207

208208
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
209+
inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
210+
return ::_iswctype_l(__c, __type, __loc);
211+
}
209212
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::_iswspace_l(__c, __loc); }
210213
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::_iswprint_l(__c, __loc); }
211214
inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::_iswcntrl_l(__c, __loc); }

libcxx/src/locale.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,11 +1109,11 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
11091109
ctype_byname<wchar_t>::~ctype_byname() { __locale::__freelocale(__l_); }
11101110

11111111
bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const {
1112+
wint_t ch = static_cast<wint_t>(c);
11121113
# ifdef _LIBCPP_WCTYPE_IS_MASK
1113-
return static_cast<bool>(iswctype_l(c, m, __l_));
1114+
return static_cast<bool>(__locale::__iswctype(ch, m, __l_));
11141115
# else
11151116
bool result = false;
1116-
wint_t ch = static_cast<wint_t>(c);
11171117
if ((m & space) == space)
11181118
result |= (__locale::__iswspace(ch, __l_) != 0);
11191119
if ((m & print) == print)
@@ -1179,7 +1179,7 @@ const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_typ
11791179
const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
11801180
for (; low != high; ++low) {
11811181
# ifdef _LIBCPP_WCTYPE_IS_MASK
1182-
if (iswctype_l(*low, m, __l_))
1182+
if (__locale::__iswctype(static_cast<wint_t>(*low), m, __l_))
11831183
break;
11841184
# else
11851185
wint_t ch = static_cast<wint_t>(*low);
@@ -1210,11 +1210,11 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, c
12101210

12111211
const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
12121212
for (; low != high; ++low) {
1213+
wint_t ch = static_cast<wint_t>(*low);
12131214
# ifdef _LIBCPP_WCTYPE_IS_MASK
1214-
if (!iswctype_l(*low, m, __l_))
1215+
if (!__locale::__iswctype(ch, m, __l_))
12151216
break;
12161217
# else
1217-
wint_t ch = static_cast<wint_t>(*low);
12181218
if ((m & space) == space && __locale::__iswspace(ch, __l_))
12191219
continue;
12201220
if ((m & print) == print && __locale::__iswprint(ch, __l_))

0 commit comments

Comments
 (0)