Author: hhinnant Date: Wed Jul 13 10:48:16 2011 New Revision: 135044 URL: http://llvm.org/viewvc/llvm-project?rev=135044&view=rev Log: Reverted to 134947. Once I got into it, I discovered there were too many problems to fix in 135035.
Modified: libcxx/trunk/include/__config libcxx/trunk/include/locale libcxx/trunk/src/locale.cpp Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=135044&r1=135043&r2=135044&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Wed Jul 13 10:48:16 2011 @@ -286,10 +286,6 @@ #endif #ifdef __APPLE__ -#define _LIBCPP_LOCALE__L_EXTENSIONS 1 -#endif - -#ifdef __APPLE__ #define _LIBCPP_STABLE_APPLE_ABI #endif Modified: libcxx/trunk/include/locale URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=135044&r1=135043&r2=135044&view=diff ============================================================================== --- libcxx/trunk/include/locale (original) +++ libcxx/trunk/include/locale Wed Jul 13 10:48:16 2011 @@ -197,14 +197,11 @@ 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 @@ return isdigit_l(__c, 0); } -#else // _LIBCPP_STABLE_APPLE_ABI - -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>())) -inline _LIBCPP_INLINE_VISIBILITY -__mb_cur_max_l(locale_t __l) -{ - return MB_CUR_MAX_L(__l); -} -#else // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline -decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) -{ - __locale_raii __current(uselocale(__l), uselocale); - return MB_CUR_MAX; -} -#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); +#else // __APPLE__ +inline +#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +_LIBCPP_INLINE_VISIBILITY #endif -} - -_LIBCPP_ALWAYS_INLINE inline -int __wctob_l(wint_t __c, locale_t __l) +int +__nolocale_sprintf(char* __restrict __str, + const char* __restrict __format, ...) { -#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); + 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 -} - -_LIBCPP_ALWAYS_INLINE inline -size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) +int +__nolocale_snprintf(char* __restrict __str, size_t __size, + const char* __restrict __format, ...) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS - return wcrtomb_l(__s, __wc, __ps, __l); -#else - __locale_raii __current(uselocale(__l), uselocale); - return wcrtomb(__s, __wc, __ps); + 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 -} - -_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) +int +__nolocale_asprintf(char** __ret, + const char* __restrict __format, ...) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS - return mbtowc(__pwc, __pmb, __max, __l); -#else - __locale_raii __current(uselocale(__l), uselocale); - return mbtowc(__pwc, __pmb, __max); + 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 -} - -_LIBCPP_ALWAYS_INLINE inline -size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) +int +__nolocale_sscanf(const char* __restrict __str, + const char* __restrict __format, ...) { -#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 + va_list __ap; + va_start(__ap, __format); + int __result = vsscanf(__str, __format, __ap); + va_end(__ap); + return __result; } - -_LIBCPP_ALWAYS_INLINE inline -lconv *__localeconv_l(locale_t __l) +inline _LIBCPP_INLINE_VISIBILITY +int +__nolocale_isxdigit(int __c) { -#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; + return isxdigit(__c); } -_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; +inline _LIBCPP_INLINE_VISIBILITY +int +__nolocale_isdigit(int __c) +{ + return isdigit(__c); } - -#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 @@ 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 @@ 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 @@ 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 @@ 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 @@ *__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 @@ + ((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 @@ + ((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 @@ + ((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 @@ + ((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 @@ 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 @@ 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 @@ 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 @@ // 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); Modified: libcxx/trunk/src/locale.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=135044&r1=135043&r2=135044&view=diff ============================================================================== --- libcxx/trunk/src/locale.cpp (original) +++ libcxx/trunk/src/locale.cpp Wed Jul 13 10:48:16 2011 @@ -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 @@ 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 @@ { 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 @@ { // 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 @@ { // 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 @@ { // 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ __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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ { 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; _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits