Skip to content

[libc++] Disable isw*_l functions on old MSVCRT (< 0x800) #144273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libcxx/include/__cxx03/__config
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ typedef __char32_t char32_t;
// clang-format on

# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
# define _LIBCPP_LOCALE__L_EXTENSIONS 1
# if !defined(__MSVCRT_VERSION__) || __MSVCRT_VERSION__ >= 0x800
# define _LIBCPP_LOCALE__L_EXTENSIONS 1
# endif
# endif

# ifdef __FreeBSD__
Expand Down
20 changes: 19 additions & 1 deletion libcxx/include/__locale_dir/support/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,23 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
}

# if _LIBCPP_HAS_WIDE_CHARACTERS
# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
_LIBCPP_EXPORTED_FROM_ABI int __iswctype(wint_t c, wctype_t __type, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswspace(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswprint(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswcntrl(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswupper(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswlower(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswalpha(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswblank(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswdigit(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswpunct(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __iswxdigit(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI wint_t __towupper(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI wint_t __towlower(wint_t c, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI int __wcscoll(const wchar_t* ws1, const wchar_t* ws2, __locale_t loc);
_LIBCPP_EXPORTED_FROM_ABI size_t __wcsxfrm(wchar_t* dest, const wchar_t* src, size_t n, __locale_t loc);
# else
inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
return ::_iswctype_l(__c, __type, __loc);
}
Expand All @@ -245,7 +262,8 @@ inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t*
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);
}
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
# endif // defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
# endif // _LIBCPP_HAS_WIDE_CHARACTERS

# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
_LIBCPP_EXPORTED_FROM_ABI size_t __strftime(char*, size_t, const char*, const struct tm*, __locale_t);
Expand Down
62 changes: 62 additions & 0 deletions libcxx/src/support/win32/locale_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,68 @@ size_t __strftime(char* ret, size_t n, const char* format, const struct tm* tm,
__locale_guard __current(loc);
return std::strftime(ret, n, format, tm);
}
# if _LIBCPP_HAS_WIDE_CHARACTERS
int __iswctype(wint_t c, wctype_t type, __locale_t loc) {
__locale_guard __current(loc);
return ::iswctype(c, type);
}
int __iswspace(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswspace(c);
}
int __iswprint(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswprint(c);
}
int __iswcntrl(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswcntrl(c);
}
int __iswupper(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswupper(c);
}
int __iswlower(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswlower(c);
}
int __iswalpha(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswalpha(c);
}
int __iswblank(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswblank(c);
}
int __iswdigit(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswdigit(c);
}
int __iswpunct(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswpunct(c);
}
int __iswxdigit(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::iswxdigit(c);
}
wint_t __towupper(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::towupper(c);
}
wint_t __towlower(wint_t c, __locale_t loc) {
__locale_guard __current(loc);
return ::towlower(c);
}
int __wcscoll(const wchar_t* ws1, const wchar_t* ws2, __locale_t loc) {
__locale_guard __current(loc);
return ::wcscoll(ws1, ws2);
}
size_t __wcsxfrm(wchar_t* dest, const wchar_t* src, size_t n, __locale_t loc) {
__locale_guard __current(loc);
return ::wcsxfrm(dest, src, n);
}
# endif
#endif

//
Expand Down
Loading