94
94
// int __sscanf(const char*, __locale_t, const char*, ...);
95
95
// }
96
96
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
+
97
103
// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
98
104
// (by providing global non-reserved names) and the new API. As we move individual platforms
99
105
// towards the new way of defining the locale base API, this should disappear since each platform
100
106
// 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
118
120
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
124
126
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
133
135
_LIBCPP_BEGIN_NAMESPACE_STD
134
136
namespace __locale {
135
137
//
136
138
// Locale management
137
139
//
138
140
using __locale_t = locale_t ;
139
141
140
- #ifndef _LIBCPP_MSVCRT_LIKE
142
+ # ifndef _LIBCPP_MSVCRT_LIKE
141
143
inline _LIBCPP_HIDE_FROM_ABI __locale_t __uselocale (__locale_t __loc) { return uselocale (__loc); }
142
- #endif
144
+ # endif
143
145
144
146
inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale (int __category_mask, const char * __name, __locale_t __loc) {
145
147
return newlocale (__category_mask, __name, __loc);
@@ -189,7 +191,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
189
191
inline _LIBCPP_HIDE_FROM_ABI int __toupper (int __ch, __locale_t __loc) { return toupper_l (__ch, __loc); }
190
192
inline _LIBCPP_HIDE_FROM_ABI int __tolower (int __ch, __locale_t __loc) { return tolower_l (__ch, __loc); }
191
193
192
- #if _LIBCPP_HAS_WIDE_CHARACTERS
194
+ # if _LIBCPP_HAS_WIDE_CHARACTERS
193
195
inline _LIBCPP_HIDE_FROM_ABI int __wcscoll (const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) {
194
196
return wcscoll_l (__s1, __s2, __loc);
195
197
}
@@ -208,7 +210,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret
208
210
inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit (wint_t __ch, __locale_t __loc) { return iswxdigit_l (__ch, __loc); }
209
211
inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper (wint_t __ch, __locale_t __loc) { return towupper_l (__ch, __loc); }
210
212
inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower (wint_t __ch, __locale_t __loc) { return towlower_l (__ch, __loc); }
211
- #endif
213
+ # endif
212
214
213
215
inline _LIBCPP_HIDE_FROM_ABI size_t
214
216
__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
221
223
inline _LIBCPP_HIDE_FROM_ABI decltype (__libcpp_mb_cur_max_l(__locale_t ())) __mb_len_max(__locale_t __loc) {
222
224
return __libcpp_mb_cur_max_l (__loc);
223
225
}
224
- #if _LIBCPP_HAS_WIDE_CHARACTERS
226
+ # if _LIBCPP_HAS_WIDE_CHARACTERS
225
227
inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc (int __ch, __locale_t __loc) { return __libcpp_btowc_l (__ch, __loc); }
226
228
inline _LIBCPP_HIDE_FROM_ABI int __wctob (wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l (__ch, __loc); }
227
229
inline _LIBCPP_HIDE_FROM_ABI size_t
@@ -249,16 +251,16 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
249
251
__mbsrtowcs (wchar_t * __dest, const char ** __src, size_t __len, mbstate_t * __ps, __locale_t __loc) {
250
252
return __libcpp_mbsrtowcs_l (__dest, __src, __len, __ps, __loc);
251
253
}
252
- #endif
254
+ # endif
253
255
254
256
_LIBCPP_DIAGNOSTIC_PUSH
255
257
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wgcc-compat" )
256
258
_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
262
264
263
265
template <class ... _Args>
264
266
_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
276
278
return __libcpp_sscanf_l (__s, __loc, __format, std::forward<_Args>(__args)...);
277
279
}
278
280
_LIBCPP_DIAGNOSTIC_POP
279
- #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
281
+ # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
280
282
281
283
} // namespace __locale
282
284
_LIBCPP_END_NAMESPACE_STD
283
285
286
+ #endif // Compatibility definition of locale base APIs
287
+
284
288
#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
0 commit comments