mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-26 11:01:16 -03:00
Add fallback wcstod_l for musl
Just sets locale to "C" (because that's the only one we need), does wcstod and resets the locale. No idea why uselocale(loc) failed for me, but it did. Fixes #5407.
This commit is contained in:
@@ -388,3 +388,18 @@ int flock(int fd, int op) {
|
||||
}
|
||||
|
||||
#endif // HAVE_FLOCK
|
||||
|
||||
#ifndef HAVE_WCSTOD_L
|
||||
// musl doesn't feature wcstod_l,
|
||||
// so we just wrap wcstod.
|
||||
double wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc) {
|
||||
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);
|
||||
setlocale(LC_NUMERIC, saved_locale);
|
||||
free(saved_locale);
|
||||
return ret;
|
||||
}
|
||||
#endif // defined(wcstod_l)
|
||||
|
||||
Reference in New Issue
Block a user