fallback: Use passed locale in wcstod_l

Strange idea, but it just might work.
This commit is contained in:
Fabian Homborg 2019-02-13 22:31:54 +01:00
parent 553bf47191
commit f037b0f30f

View File

@ -394,18 +394,9 @@ int flock(int fd, int op) {
// For platforms without wcstod_l C extension, wrap wcstod after changing the // For platforms without wcstod_l C extension, wrap wcstod after changing the
// thread-specific locale. // thread-specific locale.
double fish_compat::wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc) { double fish_compat::wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc) {
// Create and use a new, thread-specific locale locale_t prev_locale = uselocale(loc);
// NOTE: We use "C" whatever the passed locale,
// and we use the LC_ALL category.
//
// Empirically, this fails on OpenIndiana/Illumos/Solaris/SunOS if using LC_NUMERIC.
// Since we reset it afterwards, it shouldn't matter.
locale_t locale = newlocale(LC_ALL, "C", nullptr);
locale_t prev_locale = uselocale(locale);
double ret = wcstod(enptr, endptr); double ret = wcstod(enptr, endptr);
// Restore the old locale before freeing the locale we created and are still using
uselocale(prev_locale); uselocale(prev_locale);
freelocale(locale);
return ret; return ret;
} }
#endif // defined(wcstod_l) #endif // defined(wcstod_l)