mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08: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:
parent
355cb88e38
commit
ffab420e43
|
@ -72,6 +72,7 @@ CHECK_CXX_SYMBOL_EXISTS(wcsdup wchar.h HAVE_WCSDUP)
|
|||
CHECK_CXX_SYMBOL_EXISTS(wcslcpy wchar.h HAVE_WCSLCPY)
|
||||
CHECK_CXX_SYMBOL_EXISTS(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
|
||||
CHECK_CXX_SYMBOL_EXISTS(wcsndup wchar.h HAVE_WCSNDUP)
|
||||
CHECK_CXX_SYMBOL_EXISTS(wcstod_l wchar.h HAVE_WCSTOD_L)
|
||||
|
||||
CHECK_CXX_SYMBOL_EXISTS(_sys_errs stdlib.h HAVE__SYS__ERRS)
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ AC_STRUCT_DIRENT_D_TYPE
|
|||
#
|
||||
|
||||
AC_CHECK_FUNCS( wcsndup )
|
||||
AC_CHECK_FUNCS( wcstod_l )
|
||||
AC_CHECK_FUNCS( futimes )
|
||||
AC_CHECK_FUNCS( wcslcpy lrand48_r killpg )
|
||||
AC_CHECK_FUNCS( backtrace_symbols getifaddrs )
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -198,3 +198,7 @@ int flock(int fd, int op);
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef wcstod_l
|
||||
double wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user