9494// int __sscanf(const char*, __locale_t, const char*, ...);
9595// }
9696
97+ #if defined(__APPLE__)
98+ # include < __locale_dir/support/apple.h>
99+ #elif defined(__FreeBSD__)
100+ # include < __locale_dir/support/freebsd.h>
101+ #else
102+
97103// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
98104// (by providing global non-reserved names) and the new API. As we move individual platforms
99105// towards the new way of defining the locale base API, this should disappear since each platform
100106// will define those directly.
101- #if defined(_LIBCPP_MSVCRT_LIKE)
102- # include < __locale_dir/locale_base_api/win32.h>
103- #elif defined(_AIX) || defined(__MVS__)
104- # include < __locale_dir/locale_base_api/ibm.h>
105- #elif defined(__ANDROID__)
106- # include < __locale_dir/locale_base_api/android.h>
107- #elif defined(__OpenBSD__)
108- # include < __locale_dir/locale_base_api/openbsd.h>
109- #elif defined(__Fuchsia__)
110- # include < __locale_dir/locale_base_api/fuchsia.h>
111- #elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC
112- # include < __locale_dir/locale_base_api/musl.h>
113- #elif defined(__APPLE__)
114- # include < __locale_dir/locale_base_api/apple.h>
115- #elif defined(__FreeBSD__)
116- # include < __locale_dir/locale_base_api/freebsd.h>
117- #endif
107+ # if defined(_LIBCPP_MSVCRT_LIKE)
108+ # include < __locale_dir/locale_base_api/win32.h>
109+ # elif defined(_AIX) || defined(__MVS__)
110+ # include < __locale_dir/locale_base_api/ibm.h>
111+ # elif defined(__ANDROID__)
112+ # include < __locale_dir/locale_base_api/android.h>
113+ # elif defined(__OpenBSD__)
114+ # include < __locale_dir/locale_base_api/openbsd.h>
115+ # elif defined(__Fuchsia__)
116+ # include < __locale_dir/locale_base_api/fuchsia.h>
117+ # elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC
118+ # include < __locale_dir/locale_base_api/musl.h>
119+ # endif
118120
119- #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
120- # include < __locale_dir/locale_base_api/bsd_locale_defaults.h>
121- #else
122- # include < __locale_dir/locale_base_api/bsd_locale_fallbacks.h>
123- #endif
121+ # ifdef _LIBCPP_LOCALE__L_EXTENSIONS
122+ # include < __locale_dir/locale_base_api/bsd_locale_defaults.h>
123+ # else
124+ # include < __locale_dir/locale_base_api/bsd_locale_fallbacks.h>
125+ # endif
124126
125- #include < __cstddef/size_t.h>
126- #include < __utility/forward.h>
127- #include < ctype.h>
128- #include < string.h>
129- #include < time.h>
130- #if _LIBCPP_HAS_WIDE_CHARACTERS
131- # include < wctype.h>
132- #endif
127+ # include < __cstddef/size_t.h>
128+ # include < __utility/forward.h>
129+ # include < ctype.h>
130+ # include < string.h>
131+ # include < time.h>
132+ # if _LIBCPP_HAS_WIDE_CHARACTERS
133+ # include < wctype.h>
134+ # endif
133135_LIBCPP_BEGIN_NAMESPACE_STD
134136namespace __locale {
135137//
136138// Locale management
137139//
138140using __locale_t = locale_t ;
139141
140- #ifndef _LIBCPP_MSVCRT_LIKE
142+ # ifndef _LIBCPP_MSVCRT_LIKE
141143inline _LIBCPP_HIDE_FROM_ABI __locale_t __uselocale (__locale_t __loc) { return uselocale (__loc); }
142- #endif
144+ # endif
143145
144146inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale (int __category_mask, const char * __name, __locale_t __loc) {
145147 return newlocale (__category_mask, __name, __loc);
@@ -189,7 +191,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
189191inline _LIBCPP_HIDE_FROM_ABI int __toupper (int __ch, __locale_t __loc) { return toupper_l (__ch, __loc); }
190192inline _LIBCPP_HIDE_FROM_ABI int __tolower (int __ch, __locale_t __loc) { return tolower_l (__ch, __loc); }
191193
192- #if _LIBCPP_HAS_WIDE_CHARACTERS
194+ # if _LIBCPP_HAS_WIDE_CHARACTERS
193195inline _LIBCPP_HIDE_FROM_ABI int __wcscoll (const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) {
194196 return wcscoll_l (__s1, __s2, __loc);
195197}
@@ -208,7 +210,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret
208210inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit (wint_t __ch, __locale_t __loc) { return iswxdigit_l (__ch, __loc); }
209211inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper (wint_t __ch, __locale_t __loc) { return towupper_l (__ch, __loc); }
210212inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower (wint_t __ch, __locale_t __loc) { return towlower_l (__ch, __loc); }
211- #endif
213+ # endif
212214
213215inline _LIBCPP_HIDE_FROM_ABI size_t
214216__strftime (char * __s, size_t __max, const char * __format, const tm* __tm, __locale_t __loc) {
@@ -221,7 +223,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca
221223inline _LIBCPP_HIDE_FROM_ABI decltype (__libcpp_mb_cur_max_l(__locale_t ())) __mb_len_max(__locale_t __loc) {
222224 return __libcpp_mb_cur_max_l (__loc);
223225}
224- #if _LIBCPP_HAS_WIDE_CHARACTERS
226+ # if _LIBCPP_HAS_WIDE_CHARACTERS
225227inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc (int __ch, __locale_t __loc) { return __libcpp_btowc_l (__ch, __loc); }
226228inline _LIBCPP_HIDE_FROM_ABI int __wctob (wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l (__ch, __loc); }
227229inline _LIBCPP_HIDE_FROM_ABI size_t
@@ -249,16 +251,16 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
249251__mbsrtowcs (wchar_t * __dest, const char ** __src, size_t __len, mbstate_t * __ps, __locale_t __loc) {
250252 return __libcpp_mbsrtowcs_l (__dest, __src, __len, __ps, __loc);
251253}
252- #endif
254+ # endif
253255
254256_LIBCPP_DIAGNOSTIC_PUSH
255257_LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wgcc-compat" )
256258_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wformat-nonliteral" ) // GCC doesn't support [[gnu::format]] on variadic templates
257- #ifdef _LIBCPP_COMPILER_CLANG_BASED
258- # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT (...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
259- #else
260- # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT (...) /* nothing */
261- #endif
259+ # ifdef _LIBCPP_COMPILER_CLANG_BASED
260+ # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT (...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
261+ # else
262+ # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT (...) /* nothing */
263+ # endif
262264
263265template <class ... _Args>
264266_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT (__printf__, 4 , 5 ) int __snprintf(
@@ -276,9 +278,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __s
276278 return __libcpp_sscanf_l (__s, __loc, __format, std::forward<_Args>(__args)...);
277279}
278280_LIBCPP_DIAGNOSTIC_POP
279- #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
281+ # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
280282
281283} // namespace __locale
282284_LIBCPP_END_NAMESPACE_STD
283285
286+ #endif // Compatibility definition of locale base APIs
287+
284288#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
0 commit comments