Index: src/locale.cpp =================================================================== --- src/locale.cpp +++ src/locale.cpp @@ -4281,6 +4281,10 @@ { } +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wmissing-braces" +#endif + void numpunct_byname::__init(const char* nm) { @@ -4288,16 +4292,40 @@ { __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); if (loc == nullptr) - __throw_runtime_error("numpunct_byname::numpunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error("numpunct_byname::numpunct_byname" + " failed to construct for " + string(nm)); lconv* lc = __libcpp_localeconv_l(loc.get()); - if (*lc->decimal_point) - __decimal_point_ = *lc->decimal_point; - if (*lc->thousands_sep) - __thousands_sep_ = *lc->thousands_sep; + if (*lc->decimal_point) { + size_t len = strlen(lc->decimal_point); + mbstate_t mbs = {0}; + wchar_t wc; + size_t nb = __libcpp_mbrtowc_l(&wc, lc->decimal_point, len, &mbs, + loc.get()); + if (nb == len) { + __decimal_point_ = wc; + } else { + __throw_runtime_error("numpunct_byname: decimal_point" + " is not a valid multibyte character: " + + string(lc->decimal_point)); + } + } + if (*lc->thousands_sep) { + size_t len = strlen(lc->thousands_sep); + mbstate_t mbs = {0}; + wchar_t wc; + size_t nb = __libcpp_mbrtowc_l(&wc, lc->thousands_sep, len, &mbs, + loc.get()); + if (nb == len) { + __thousands_sep_ = wc; + } else { + __throw_runtime_error("numpunct_byname: thousands_sep" + " is not a valid multibyte character: " + + string(lc->thousands_sep)); + } + } __grouping_ = lc->grouping; - // locallization for truename and falsename is not available + // localization for truename and falsename is not available } } @@ -4861,10 +4889,6 @@ return result; } -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wmissing-braces" -#endif - template <> wstring __time_get_storage::__analyze(char fmt, const ctype& ct)