mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 11:43:37 +08:00
Revert "Fix unsafe locale usage in wcstod_l
fallback"
This reverts commit 3444e1db18
.
The reverted commit broke tests on the Mac.
This commit is contained in:
parent
a6fa237db2
commit
c15a702f18
|
@ -394,13 +394,13 @@ int flock(int fd, int op) {
|
|||
// For platforms without wcstod_l C extension, wrap wcstod after changing the
|
||||
// thread-specific locale.
|
||||
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 locale = newlocale(LC_NUMERIC, "C", nullptr);
|
||||
locale_t prev_locale = uselocale(locale);
|
||||
char *saved_locale = strdup(setlocale(LC_NUMERIC, NULL));
|
||||
// Yes, this is hardcoded to use the "C" locale.
|
||||
// That's the only thing we need, and uselocale(loc) broke in my testing.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
double ret = wcstod(enptr, endptr);
|
||||
// Restore the old locale before freeing the locale we created and are still using
|
||||
uselocale(prev_locale);
|
||||
freelocale(locale);
|
||||
setlocale(LC_NUMERIC, saved_locale);
|
||||
free(saved_locale);
|
||||
return ret;
|
||||
}
|
||||
#endif // defined(wcstod_l)
|
||||
|
|
Loading…
Reference in New Issue
Block a user