commit f41e6b7f2a1c2f016e29ea440f781a7d90680b4f Author: Petteri Räty Date: Mon May 30 23:33:08 2011 +0300 locale.cpp improved linux support Use type_traits to get the type of locale_t underlying struct and use posix versions of functions. What is left to compile fully on Linux is figuring out how to support _DefaultRuneLocale. diff --git a/src/locale.cpp b/src/locale.cpp index f32ce96..138dbc2 100644 --- a/src/locale.cpp +++ b/src/locale.cpp @@ -14,6 +14,7 @@ #include "algorithm" #include "algorithm" #include "typeinfo" +#include "type_traits" #include "clocale" #include "cstring" #include "cwctype" @@ -21,6 +22,97 @@ #include #include +namespace { + typedef std::remove_pointer::type locale_struct; + typedef std::unique_ptr locale_unique_ptr; + typedef std::unique_ptr 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) + mb_cur_max_l(locale_t loc) + { + return MB_CUR_MAX_L(loc); + } +#else + template + + auto using_locale(Function f, locale_t loc, Args&&... params) -> decltype(f(std::forward(params)...)) + { + locale_raii current(uselocale(loc), uselocale); + return f(std::forward(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 namespace { @@ -1082,49 +1174,33 @@ ctype_byname::do_tolower(char_type* low, const char_type* high) const wchar_t ctype_byname::do_widen(char c) const { -#ifdef __APPLE__ - return btowc_l(c, __l); -#else - return 0; -#endif + return with_locale::btowc_l(c, __l); } const char* ctype_byname::do_widen(const char* low, const char* high, char_type* dest) const { -#ifdef __APPLE__ for (; low != high; ++low, ++dest) - *dest = btowc_l(*low, __l); + *dest = with_locale::btowc_l(*low, __l); return low; -#else - return NULL; -#endif } char ctype_byname::do_narrow(char_type c, char dfault) const { -#ifdef __APPLE__ - int r = wctob_l(c, __l); + int r = with_locale::wctob_l(c, __l); return r != WEOF ? static_cast(r) : dfault; -#else - return 0; -#endif } const wchar_t* ctype_byname::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const { -#ifdef __APPLE__ for (; low != high; ++low, ++dest) { - int r = wctob_l(*low, __l); + int r = with_locale::wctob_l(*low, __l); *dest = r != WEOF ? static_cast(r) : dfault; } return low; -#else - return NULL; -#endif } // template <> class codecvt @@ -1220,7 +1296,6 @@ codecvt::do_out(state_type& st, const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const { -#ifdef __APPLE__ // look for first internal null in frm const intern_type* fend = frm; for (; fend != frm_end; ++fend) @@ -1232,13 +1307,13 @@ codecvt::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; @@ -1255,7 +1330,7 @@ codecvt::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? @@ -1270,9 +1345,6 @@ codecvt::do_out(state_type& st, } } return frm_nxt == frm_end ? ok : partial; -#else - return error; -#endif } codecvt::result @@ -1280,7 +1352,6 @@ codecvt::do_in(state_type& st, const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt, intern_type* to, intern_type* to_end, intern_type*& to_nxt) const { -#ifdef __APPLE__ // look for first internal null in frm const extern_type* fend = frm; for (; fend != frm_end; ++fend) @@ -1292,13 +1363,13 @@ codecvt::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: @@ -1326,7 +1397,7 @@ codecvt::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; @@ -1338,19 +1409,15 @@ codecvt::do_in(state_type& st, } } return frm_nxt == frm_end ? ok : partial; -#else - return error; -#endif } codecvt::result codecvt::do_unshift(state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const { -#ifdef __APPLE__ 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; @@ -1359,26 +1426,19 @@ codecvt::do_unshift(state_type& st, for (extern_type* p = tmp; n; --n) // write it *to_nxt++ = *p++; return ok; -#else - return error; -#endif } int codecvt::do_encoding() const _NOEXCEPT { -#ifdef __APPLE__ - if (mbtowc_l(0, 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; } return -1; -#else - return 0; -#endif } bool @@ -1391,11 +1451,10 @@ int codecvt::do_length(state_type& st, const extern_type* frm, const extern_type* frm_end, size_t mx) const { -#ifdef __APPLE__ 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: @@ -1412,19 +1471,12 @@ codecvt::do_length(state_type& st, } } return nbytes; -#else - return 0; -#endif } int codecvt::do_max_length() const _NOEXCEPT { -#ifdef __APPLE__ - return __l == 0 ? 1 : MB_CUR_MAX_L(__l); -#else - return 0; -#endif + return __l == 0 ? 1 : with_locale::mb_cur_max_l(__l); } // Valid UTF ranges @@ -3965,16 +4017,15 @@ numpunct_byname::~numpunct_byname() void numpunct_byname::__init(const char* nm) { -#ifdef __APPLE__ if (strcmp(nm, "C") != 0) { - unique_ptr<_xlocale, int(*)(locale_t)> 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::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) @@ -3982,7 +4033,6 @@ numpunct_byname::__init(const char* nm) __grouping_ = lc->grouping; // locallization for truename and falsename is not available } -#endif } // numpunct_byname @@ -4006,16 +4056,15 @@ numpunct_byname::~numpunct_byname() void numpunct_byname::__init(const char* nm) { -#ifdef __APPLE__ if (strcmp(nm, "C") != 0) { - unique_ptr<_xlocale, int(*)(locale_t)> 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::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) @@ -4023,7 +4072,6 @@ numpunct_byname::__init(const char* nm) __grouping_ = lc->grouping; // locallization for truename and falsename is not available } -#endif } // num_get helpers @@ -4588,7 +4636,6 @@ template <> wstring __time_get_storage::__analyze(char fmt, const ctype& ct) { -#ifdef __APPLE__ tm t; t.tm_sec = 59; t.tm_min = 55; @@ -4608,7 +4655,7 @@ __time_get_storage::__analyze(char fmt, const ctype& 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; @@ -4733,9 +4780,6 @@ __time_get_storage::__analyze(char fmt, const ctype& ct) ++wbb; } return result; -#else - return wstring(); -#endif } template <> @@ -4779,7 +4823,6 @@ template <> void __time_get_storage::init(const ctype& ct) { -#ifdef __APPLE__ tm t = {0}; char buf[100]; size_t be; @@ -4793,7 +4836,7 @@ __time_get_storage::init(const ctype& 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; @@ -4801,7 +4844,7 @@ __time_get_storage::init(const ctype& 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; @@ -4814,7 +4857,7 @@ __time_get_storage::init(const ctype& 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; @@ -4822,7 +4865,7 @@ __time_get_storage::init(const ctype& 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; @@ -4833,7 +4876,7 @@ __time_get_storage::init(const ctype& 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; @@ -4842,7 +4885,7 @@ __time_get_storage::init(const ctype& 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; @@ -4851,7 +4894,6 @@ __time_get_storage::init(const ctype& ct) __r_ = __analyze('r', ct); __x_ = __analyze('x', ct); __X_ = __analyze('X', ct); -#endif } template @@ -5113,17 +5155,15 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const { -#ifdef __APPLE__ char __nar[100]; char* __ne = __nar + 100; __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; -#endif } // moneypunct_byname @@ -5368,15 +5408,14 @@ template<> void moneypunct_byname::init(const char* nm) { -#ifdef __APPLE__ typedef moneypunct base; - unique_ptr<_xlocale, int(*)(locale_t)> 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 @@ -5401,22 +5440,20 @@ moneypunct_byname::init(const char* nm) __negative_sign_ = lc->negative_sign; __init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn); __init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn); -#endif } template<> void moneypunct_byname::init(const char* nm) { -#ifdef __APPLE__ typedef moneypunct base; - unique_ptr<_xlocale, int(*)(locale_t)> 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 @@ -5441,22 +5478,20 @@ moneypunct_byname::init(const char* nm) __negative_sign_ = lc->negative_sign; __init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn); __init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn); -#endif } template<> void moneypunct_byname::init(const char* nm) { -#ifdef __APPLE__ typedef moneypunct base; - unique_ptr<_xlocale, int(*)(locale_t)> 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(*lc->mon_decimal_point); else @@ -5469,7 +5504,7 @@ moneypunct_byname::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; @@ -5484,7 +5519,7 @@ moneypunct_byname::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; @@ -5496,7 +5531,7 @@ moneypunct_byname::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; @@ -5504,22 +5539,20 @@ moneypunct_byname::init(const char* nm) } __init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn); __init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn); -#endif } template<> void moneypunct_byname::init(const char* nm) { -#ifdef __APPLE__ typedef moneypunct base; - unique_ptr<_xlocale, int(*)(locale_t)> 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(*lc->mon_decimal_point); else @@ -5532,7 +5565,7 @@ moneypunct_byname::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; @@ -5547,7 +5580,7 @@ moneypunct_byname::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; @@ -5559,7 +5592,7 @@ moneypunct_byname::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; @@ -5567,7 +5600,6 @@ moneypunct_byname::init(const char* nm) } __init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn); __init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn); -#endif } void __do_nothing(void*) {}