mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-23 11:59:52 +00:00
Reverted to 134947. Once I got into it, I discovered there were too many problems to fix in 135035.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c97da3a590
commit
8d75632ad0
@ -285,10 +285,6 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define __has_feature(__x) 0
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _LIBCPP_STABLE_APPLE_ABI
|
||||
#endif
|
||||
|
341
include/locale
341
include/locale
@ -197,14 +197,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
locale_t __cloc();
|
||||
#endif
|
||||
|
||||
typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
|
||||
typedef _VSTD::unique_ptr<__locale_struct, decltype(&freelocale)> __locale_unique_ptr;
|
||||
typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
|
||||
|
||||
// OSX has nice foo_l() functions that let you turn off use of the global
|
||||
// locale. Linux, not so much. The following functions avoid the locale when
|
||||
// that's possible and otherwise do the wrong thing. FIXME.
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
#if __APPLE__
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int
|
||||
@ -272,195 +269,77 @@ __nolocale_isdigit(int __c)
|
||||
return isdigit_l(__c, 0);
|
||||
}
|
||||
|
||||
#else // _LIBCPP_STABLE_APPLE_ABI
|
||||
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
|
||||
#else // __APPLE__
|
||||
inline
|
||||
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
int
|
||||
__nolocale_sprintf(char* __restrict __str,
|
||||
const char* __restrict __format, ...)
|
||||
{
|
||||
va_list __ap;
|
||||
va_start(__ap, __format);
|
||||
int __result = vsprintf(__str, __format, __ap);
|
||||
va_end(__ap);
|
||||
return __result;
|
||||
}
|
||||
inline
|
||||
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
int
|
||||
__nolocale_snprintf(char* __restrict __str, size_t __size,
|
||||
const char* __restrict __format, ...)
|
||||
{
|
||||
va_list __ap;
|
||||
va_start(__ap, __format);
|
||||
int __result = vsnprintf(__str, __size, __format, __ap);
|
||||
va_end(__ap);
|
||||
return __result;
|
||||
}
|
||||
inline
|
||||
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
int
|
||||
__nolocale_asprintf(char** __ret,
|
||||
const char* __restrict __format, ...)
|
||||
{
|
||||
va_list __ap;
|
||||
va_start(__ap, __format);
|
||||
int __result = vasprintf(__ret, __format, __ap);
|
||||
va_end(__ap);
|
||||
return __result;
|
||||
}
|
||||
inline
|
||||
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
int
|
||||
__nolocale_sscanf(const char* __restrict __str,
|
||||
const char* __restrict __format, ...)
|
||||
{
|
||||
va_list __ap;
|
||||
va_start(__ap, __format);
|
||||
int __result = vsscanf(__str, __format, __ap);
|
||||
va_end(__ap);
|
||||
return __result;
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__mb_cur_max_l(locale_t __l)
|
||||
int
|
||||
__nolocale_isxdigit(int __c)
|
||||
{
|
||||
return MB_CUR_MAX_L(__l);
|
||||
return isxdigit(__c);
|
||||
}
|
||||
#else // _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l)
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int
|
||||
__nolocale_isdigit(int __c)
|
||||
{
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return MB_CUR_MAX;
|
||||
return isdigit(__c);
|
||||
}
|
||||
#endif // _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
wint_t __btowc_l(int __c, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
return btowc_l(__c, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return btowc(__c);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __wctob_l(wint_t __c, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wctob_l(__c, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wctob(__c);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return wcrtomb_l(__s, __wc, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return wcrtomb(__s, __wc, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbsnrtowcs_l(__dest, __src, __nms__len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbrtowc_l(__pwc, __s, __n, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbrtowc(__pwc, __s, __n, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbtowc(__pwc, __pmb, __max, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbtowc(__pwc, __pmb, __max);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbrlen_l(__s, __n, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbrlen(__s, __n, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
lconv *__localeconv_l(locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return localeconv_l(__l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return localeconv();
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
return mbsrtowcs_l(__dest, __src, __len, __ps, __l);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
return mbsrtowcs(__dest, __src, __len, __ps);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __sprintf_l(char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsprintf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsprintf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsnprintf_l(__s, __n, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsnprintf(__s, __n, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vasprintf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vasprintf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE inline
|
||||
int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsscanf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsscanf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STABLE_APPLE_ABI
|
||||
#endif // __APPLE__
|
||||
|
||||
// __scan_keyword
|
||||
// Scans [__b, __e) until a match is found in the basic_strings range
|
||||
@ -874,11 +753,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
|
||||
int __save_errno = errno;
|
||||
errno = 0;
|
||||
char *__p2;
|
||||
#ifdef _LIBCXX_APPLE_STABLE_ABI
|
||||
long long __ll = strtoll_l(__a, &__p2, __base, 0);
|
||||
#else
|
||||
long long __ll = strtoll_l(__a, &__p2, __base, __cloc());
|
||||
#endif
|
||||
int __current_errno = errno;
|
||||
if (__current_errno == 0)
|
||||
errno = __save_errno;
|
||||
@ -918,11 +793,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
|
||||
int __save_errno = errno;
|
||||
errno = 0;
|
||||
char *__p2;
|
||||
#ifdef _LIBCXX_APPLE_STABLE_ABI
|
||||
unsigned long long __ll = strtoull_l(__a, &__p2, __base, 0);
|
||||
#else
|
||||
unsigned long long __ll = strtoull_l(__a, &__p2, __base, __cloc());
|
||||
#endif
|
||||
int __current_errno = errno;
|
||||
if (__current_errno == 0)
|
||||
errno = __save_errno;
|
||||
@ -950,11 +821,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
|
||||
if (__a != __a_end)
|
||||
{
|
||||
char *__p2;
|
||||
#ifdef _LIBCXX_APPLE_STABLE_ABI
|
||||
long double __ld = strtold_l(__a, &__p2, 0);
|
||||
#else
|
||||
long double __ld = strtold_l(__a, &__p2, __cloc());
|
||||
#endif
|
||||
if (__p2 != __a_end)
|
||||
{
|
||||
__err = ios_base::failbit;
|
||||
@ -1359,11 +1226,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
|
||||
break;
|
||||
// Stage 3
|
||||
__a[sizeof(__a)-1] = 0;
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
if (__nolocale_sscanf(__a, "%p", &__v) != 1)
|
||||
#else
|
||||
if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1)
|
||||
#endif
|
||||
__err = ios_base::failbit;
|
||||
// EOF checked
|
||||
if (__b == __e)
|
||||
@ -1468,21 +1331,13 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
|
||||
*__oe++ = __ct.widen(*__nf++);
|
||||
*__oe++ = __ct.widen(*__nf++);
|
||||
for (__ns = __nf; __ns < __ne; ++__ns)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
if (!__nolocale_isxdigit(*__ns))
|
||||
#else
|
||||
if (!isxdigit_l(*__ns, __cloc()))
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (__ns = __nf; __ns < __ne; ++__ns)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
if (!__nolocale_isdigit(*__ns))
|
||||
#else
|
||||
if (!isdigit_l(*__ns, __cloc()))
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (__grouping.empty())
|
||||
@ -1680,11 +1535,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
int __nc = __nolocale_sprintf(__nar, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1710,11 +1561,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<long long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
int __nc = __nolocale_sprintf(__nar, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1740,11 +1587,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<unsigned long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
int __nc = __nolocale_sprintf(__nar, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1770,11 +1613,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ ((numeric_limits<unsigned long long>::digits % 3) != 0)
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
int __nc = __nolocale_sprintf(__nar, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar while adding thousands separators
|
||||
@ -1801,36 +1640,18 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char* __nb = __nar;
|
||||
int __nc;
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_snprintf(__nb, __nbuf, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_snprintf(__nb, __nbuf, __fmt, __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
unique_ptr<char, void(*)(void*)> __nbh(0, free);
|
||||
if (__nc > static_cast<int>(__nbuf-1))
|
||||
{
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_asprintf(&__nb, __fmt, (int)__iob.precision(),
|
||||
__v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, __cloc(), __fmt,
|
||||
(int)__iob.precision());
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_asprintf(&__nb, __fmt, __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision());
|
||||
#endif
|
||||
if (__nb == 0)
|
||||
__throw_bad_alloc();
|
||||
__nbh.reset(__nb);
|
||||
@ -1871,36 +1692,18 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char* __nb = __nar;
|
||||
int __nc;
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_snprintf(__nb, __nbuf, __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
|
||||
(int)__iob.precision(), __v);
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_snprintf(__nb, __nbuf, __fmt, __v);
|
||||
#else
|
||||
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
unique_ptr<char, void(*)(void*)> __nbh(0, free);
|
||||
if (__nc > static_cast<int>(__nbuf-1))
|
||||
{
|
||||
if (__specify_precision)
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_asprintf(&__nb, __fmt, (int)__iob.precision(),
|
||||
__v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, __cloc(), __fmt,
|
||||
(int)__iob.precision());
|
||||
#endif
|
||||
else
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__nc = __nolocale_asprintf(&__nb, __fmt, __v);
|
||||
#else
|
||||
__nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision());
|
||||
#endif
|
||||
if (__nb == 0)
|
||||
__throw_bad_alloc();
|
||||
__nbh.reset(__nb);
|
||||
@ -1936,11 +1739,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
char __fmt[6] = "%p";
|
||||
const unsigned __nbuf = 20;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
int __nc = __nolocale_sprintf(__nar, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
// Stage 2 - Widen __nar
|
||||
@ -3624,11 +3423,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
|
||||
// secure memory for digit storage
|
||||
if (__n > __bs-1)
|
||||
{
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
__n = __nolocale_asprintf(&__bb, "%.0Lf", __units);
|
||||
#else
|
||||
__n = __asprintf_l(&__bb, __cloc(), "%.0Lf", __units);
|
||||
#endif
|
||||
if (__bb == 0)
|
||||
__throw_bad_alloc();
|
||||
__hn.reset(__bb);
|
||||
|
167
src/locale.cpp
167
src/locale.cpp
@ -22,16 +22,97 @@
|
||||
#include <langinfo.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _LIBCPP_STABLE_APPLE_ABI
|
||||
namespace {
|
||||
typedef std::remove_pointer<locale_t>::type locale_struct;
|
||||
typedef std::unique_ptr<locale_struct, decltype(&freelocale)> locale_unique_ptr;
|
||||
typedef std::unique_ptr<locale_struct, decltype(&uselocale)> locale_raii;
|
||||
}
|
||||
|
||||
namespace with_locale { namespace {
|
||||
#ifdef __APPLE__
|
||||
using ::btowc_l;
|
||||
using ::wctob_l;
|
||||
using ::wcsnrtombs_l;
|
||||
using ::wcrtomb_l;
|
||||
using ::mbsnrtowcs_l;
|
||||
using ::mbrtowc_l;
|
||||
using ::mbtowc_l;
|
||||
using ::mbrlen_l;
|
||||
using ::localeconv_l;
|
||||
using ::mbsrtowcs_l;
|
||||
|
||||
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
mb_cur_max_l(locale_t loc)
|
||||
{
|
||||
return MB_CUR_MAX_L(loc);
|
||||
}
|
||||
}
|
||||
#else
|
||||
template
|
||||
<typename Function, typename ...Args>
|
||||
auto using_locale(Function f, locale_t loc, Args&&... params) -> decltype(f(std::forward<Args>(params)...))
|
||||
{
|
||||
locale_raii current(uselocale(loc), uselocale);
|
||||
return f(std::forward<Args>(params)...);
|
||||
}
|
||||
|
||||
decltype(MB_CUR_MAX)
|
||||
mb_cur_max_l(locale_t loc)
|
||||
{
|
||||
locale_raii current(uselocale(loc), uselocale);
|
||||
return MB_CUR_MAX;
|
||||
}
|
||||
|
||||
wint_t btowc_l(int c, locale_t l) { return using_locale(&btowc, l, c); }
|
||||
int wctob_l(wint_t c, locale_t l) { return using_locale(&wctob, l, c); }
|
||||
size_t wcsnrtombs_l(char * dest,
|
||||
const wchar_t * * src,
|
||||
size_t nwc,
|
||||
size_t len,
|
||||
mbstate_t * ps,
|
||||
locale_t l)
|
||||
{
|
||||
return using_locale(&wcsnrtombs, l, dest, src, nwc, len, ps);
|
||||
}
|
||||
size_t wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t l)
|
||||
{
|
||||
return using_locale(&wcrtomb, l, s, wc, ps);
|
||||
}
|
||||
size_t mbsnrtowcs_l(wchar_t * dest,
|
||||
const char * * src,
|
||||
size_t nms,
|
||||
size_t len,
|
||||
mbstate_t * ps,
|
||||
locale_t l)
|
||||
{
|
||||
return using_locale(&mbsnrtowcs, l, dest, src, nms, len, ps);
|
||||
}
|
||||
size_t mbrtowc_l(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps, locale_t l)
|
||||
{
|
||||
return using_locale(&mbrtowc, l, pwc, s, n, ps);
|
||||
}
|
||||
int mbtowc_l(wchar_t * pwc, const char * pmb, size_t max, locale_t l)
|
||||
{
|
||||
return using_locale(&mbtowc, l, pwc, pmb, max);
|
||||
}
|
||||
size_t mbrlen_l(const char *s, size_t n, mbstate_t *ps, locale_t l)
|
||||
{
|
||||
return using_locale(&mbrlen, l, s, n, ps);
|
||||
}
|
||||
struct lconv *localeconv_l(locale_t l)
|
||||
{
|
||||
return using_locale(&localeconv, l);
|
||||
}
|
||||
size_t mbsrtowcs_l(wchar_t * dest,
|
||||
const char * * src,
|
||||
size_t len,
|
||||
mbstate_t * ps,
|
||||
locale_t l)
|
||||
{
|
||||
return using_locale(&mbsrtowcs, l, dest, src, len, ps);
|
||||
}
|
||||
#endif
|
||||
} }
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -1164,21 +1245,21 @@ ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
|
||||
wchar_t
|
||||
ctype_byname<wchar_t>::do_widen(char c) const
|
||||
{
|
||||
return __btowc_l(c, __l);
|
||||
return with_locale::btowc_l(c, __l);
|
||||
}
|
||||
|
||||
const char*
|
||||
ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
|
||||
{
|
||||
for (; low != high; ++low, ++dest)
|
||||
*dest = __btowc_l(*low, __l);
|
||||
*dest = with_locale::btowc_l(*low, __l);
|
||||
return low;
|
||||
}
|
||||
|
||||
char
|
||||
ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
|
||||
{
|
||||
int r = __wctob_l(c, __l);
|
||||
int r = with_locale::wctob_l(c, __l);
|
||||
return r != WEOF ? static_cast<char>(r) : dfault;
|
||||
}
|
||||
|
||||
@ -1187,7 +1268,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
|
||||
{
|
||||
for (; low != high; ++low, ++dest)
|
||||
{
|
||||
int r = __wctob_l(*low, __l);
|
||||
int r = with_locale::wctob_l(*low, __l);
|
||||
*dest = r != WEOF ? static_cast<char>(r) : dfault;
|
||||
}
|
||||
return low;
|
||||
@ -1297,13 +1378,13 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
|
||||
{
|
||||
// save state in case needed to reover to_nxt on error
|
||||
mbstate_t save_state = st;
|
||||
size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
size_t n = with_locale::wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
if (n == size_t(-1))
|
||||
{
|
||||
// need to recover to_nxt
|
||||
for (to_nxt = to; frm != frm_nxt; ++frm)
|
||||
{
|
||||
n = __wcrtomb_l(to_nxt, *frm, &save_state, __l);
|
||||
n = with_locale::wcrtomb_l(to_nxt, *frm, &save_state, __l);
|
||||
if (n == size_t(-1))
|
||||
break;
|
||||
to_nxt += n;
|
||||
@ -1320,7 +1401,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
|
||||
{
|
||||
// Try to write the terminating null
|
||||
extern_type tmp[MB_LEN_MAX];
|
||||
n = __wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
n = with_locale::wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
if (n == size_t(-1)) // on error
|
||||
return error;
|
||||
if (n > to_end-to_nxt) // is there room?
|
||||
@ -1353,13 +1434,13 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
|
||||
{
|
||||
// save state in case needed to reover to_nxt on error
|
||||
mbstate_t save_state = st;
|
||||
size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
size_t n = with_locale::mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
|
||||
if (n == size_t(-1))
|
||||
{
|
||||
// need to recover to_nxt
|
||||
for (to_nxt = to; frm != frm_nxt; ++to_nxt)
|
||||
{
|
||||
n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l);
|
||||
n = with_locale::mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l);
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
@ -1387,7 +1468,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
|
||||
if (fend != frm_end) // set up next null terminated sequence
|
||||
{
|
||||
// Try to write the terminating null
|
||||
n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
|
||||
n = with_locale::mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
|
||||
if (n != 0) // on error
|
||||
return error;
|
||||
++to_nxt;
|
||||
@ -1407,7 +1488,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
|
||||
{
|
||||
to_nxt = to;
|
||||
extern_type tmp[MB_LEN_MAX];
|
||||
size_t n = __wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
size_t n = with_locale::wcrtomb_l(tmp, intern_type(), &st, __l);
|
||||
if (n == size_t(-1) || n == 0) // on error
|
||||
return error;
|
||||
--n;
|
||||
@ -1421,10 +1502,10 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
|
||||
int
|
||||
codecvt<wchar_t, char, mbstate_t>::do_encoding() const _NOEXCEPT
|
||||
{
|
||||
if (__mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
|
||||
if (with_locale::mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
|
||||
{
|
||||
// stateless encoding
|
||||
if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings
|
||||
if (__l == 0 || with_locale::mb_cur_max_l(__l) == 1) // there are no known constant length encodings
|
||||
return 1; // which take more than 1 char to form a wchar_t
|
||||
return 0;
|
||||
}
|
||||
@ -1444,7 +1525,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
|
||||
int nbytes = 0;
|
||||
for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
|
||||
{
|
||||
size_t n = __mbrlen_l(frm, frm_end-frm, &st, __l);
|
||||
size_t n = with_locale::mbrlen_l(frm, frm_end-frm, &st, __l);
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
@ -1466,7 +1547,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
|
||||
int
|
||||
codecvt<wchar_t, char, mbstate_t>::do_max_length() const _NOEXCEPT
|
||||
{
|
||||
return __l == 0 ? 1 : __mb_cur_max_l(__l);
|
||||
return __l == 0 ? 1 : with_locale::mb_cur_max_l(__l);
|
||||
}
|
||||
|
||||
// Valid UTF ranges
|
||||
@ -4009,13 +4090,13 @@ numpunct_byname<char>::__init(const char* nm)
|
||||
{
|
||||
if (strcmp(nm, "C") != 0)
|
||||
{
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("numpunct_byname<char>::numpunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->decimal_point)
|
||||
__decimal_point_ = *lc->decimal_point;
|
||||
if (*lc->thousands_sep)
|
||||
@ -4048,13 +4129,13 @@ numpunct_byname<wchar_t>::__init(const char* nm)
|
||||
{
|
||||
if (strcmp(nm, "C") != 0)
|
||||
{
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("numpunct_byname<char>::numpunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->decimal_point)
|
||||
__decimal_point_ = *lc->decimal_point;
|
||||
if (*lc->thousands_sep)
|
||||
@ -4645,7 +4726,7 @@ __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
|
||||
wchar_t* wbb = wbuf;
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = buf;
|
||||
size_t i = __mbsrtowcs_l( wbb, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
size_t i = with_locale::mbsrtowcs_l( wbb, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (i == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbb + i;
|
||||
@ -4826,7 +4907,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%A", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
size_t j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -4834,7 +4915,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%a", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -4847,7 +4928,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%B", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
size_t j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -4855,7 +4936,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%b", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -4866,7 +4947,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%p", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
const char* bb = buf;
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
size_t j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -4875,7 +4956,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
|
||||
be = strftime_l(buf, 100, "%p", &t, __loc_);
|
||||
mb = mbstate_t();
|
||||
bb = buf;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5150,7 +5231,7 @@ __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
|
||||
__do_put(__nar, __ne, __tm, __fmt, __mod);
|
||||
mbstate_t mb = {0};
|
||||
const char* __nb = __nar;
|
||||
size_t j = __mbsrtowcs_l(__wb, &__nb, 100, &mb, __loc_);
|
||||
size_t j = with_locale::mbsrtowcs_l(__wb, &__nb, 100, &mb, __loc_);
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
__we = __wb + j;
|
||||
@ -5399,13 +5480,13 @@ void
|
||||
moneypunct_byname<char, false>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<char, false> base;
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = *lc->mon_decimal_point;
|
||||
else
|
||||
@ -5437,13 +5518,13 @@ void
|
||||
moneypunct_byname<char, true>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<char, true> base;
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = *lc->mon_decimal_point;
|
||||
else
|
||||
@ -5475,13 +5556,13 @@ void
|
||||
moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<wchar_t, false> base;
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
|
||||
else
|
||||
@ -5494,7 +5575,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->currency_symbol;
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
size_t j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
@ -5509,7 +5590,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5521,7 +5602,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5536,13 +5617,13 @@ void
|
||||
moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
typedef moneypunct<wchar_t, true> base;
|
||||
__locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
if (loc == 0)
|
||||
throw runtime_error("moneypunct_byname"
|
||||
" failed to construct for " + string(nm));
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
lconv* lc = __localeconv_l(loc.get());
|
||||
lconv* lc = with_locale::localeconv_l(loc.get());
|
||||
if (*lc->mon_decimal_point)
|
||||
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
|
||||
else
|
||||
@ -5555,7 +5636,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
wchar_t wbuf[100];
|
||||
mbstate_t mb = {0};
|
||||
const char* bb = lc->int_curr_symbol;
|
||||
size_t j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
size_t j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wchar_t* wbe = wbuf + j;
|
||||
@ -5570,7 +5651,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->positive_sign;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
@ -5582,7 +5663,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
|
||||
{
|
||||
mb = mbstate_t();
|
||||
bb = lc->negative_sign;
|
||||
j = __mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
j = with_locale::mbsrtowcs_l(wbuf, &bb, sizeof(wbuf)/sizeof(wbuf[0]), &mb, loc.get());
|
||||
if (j == -1)
|
||||
__throw_runtime_error("locale not supported");
|
||||
wbe = wbuf + j;
|
||||
|
Loading…
Reference in New Issue
Block a user