diff options
Diffstat (limited to 'libcxx/src/locale.cpp')
-rw-r--r-- | libcxx/src/locale.cpp | 92 |
1 files changed, 35 insertions, 57 deletions
diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index da2fd11678d..a4e0a53d638 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -107,6 +107,16 @@ countof(const T * const begin, const T * const end) return static_cast<size_t>(end - begin); } +_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg) +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw runtime_error(msg); +#else + (void)msg; + _VSTD::abort(); +#endif +} + } #if defined(_AIX) @@ -646,22 +656,18 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) : collate<char>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<char>::collate_byname" + __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + string(n)); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<char>::collate_byname(const string& name, size_t refs) : collate<char>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<char>::collate_byname" + __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<char>::~collate_byname() @@ -698,22 +704,18 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" + __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + string(n)); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" + __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<wchar_t>::~collate_byname() @@ -1172,22 +1174,18 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<char>::ctype_byname" + __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + string(name)); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<char>::ctype_byname(const string& name, size_t refs) : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<char>::ctype_byname" + __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<char>::~ctype_byname() @@ -1229,22 +1227,18 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<wchar_t>::ctype_byname" + __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + string(name)); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<wchar_t>::ctype_byname" + __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<wchar_t>::~ctype_byname() @@ -1504,11 +1498,9 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) : locale::facet(refs), __l(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" + __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } codecvt<wchar_t, char, mbstate_t>::~codecvt() @@ -4257,11 +4249,10 @@ numpunct_byname<char>::__init(const char* nm) if (strcmp(nm, "C") != 0) { __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("numpunct_byname<char>::numpunct_byname" + __throw_runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -4296,11 +4287,10 @@ numpunct_byname<wchar_t>::__init(const char* nm) if (strcmp(nm, "C") != 0) { __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("numpunct_byname<char>::numpunct_byname" + __throw_runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -4703,21 +4693,17 @@ __time_get_c_storage<wchar_t>::__r() const __time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_get_byname" + __throw_runtime_error("time_get_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_get_byname" + __throw_runtime_error("time_get_byname" " failed to construct for " + nm); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_get::~__time_get() @@ -5363,21 +5349,17 @@ __time_get_storage<wchar_t>::__do_date_order() const __time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_put_byname" + __throw_runtime_error("time_put_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_put_byname" + __throw_runtime_error("time_put_byname" " failed to construct for " + nm); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_put::~__time_put() @@ -5792,11 +5774,10 @@ moneypunct_byname<char, false>::init(const char* nm) { typedef moneypunct<char, false> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5836,11 +5817,10 @@ moneypunct_byname<char, true>::init(const char* nm) { typedef moneypunct<char, true> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5897,11 +5877,9 @@ 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); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -5964,11 +5942,10 @@ 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); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -6050,6 +6027,7 @@ void __throw_runtime_error(const char* msg) throw runtime_error(msg); #else (void)msg; + _VSTD::abort(); #endif } |