mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
Force uselocale if glibc is in use
For some reason on a current glibc 2.33, the configure check fails. The man page says we'd have to define XOPEN_SOURCE>=700, but I don't want to do that since it changes a bunch of other things, and it didn't work in my tests. So we just force it, since we know it works (since glibc 2.3). This is a performance difference of ~20% for printf, so it's a reasonably big deal.
This commit is contained in:
@@ -751,11 +751,12 @@ maybe_t<int> builtin_printf(parser_t &parser, io_streams_t &streams, const wchar
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
#if defined(HAVE_USELOCALE)
|
||||
#if defined(HAVE_USELOCALE) || defined(__GLIBC__)
|
||||
// We use a locale-dependent LC_NUMERIC here,
|
||||
// unlike the rest of fish (which uses LC_NUMERIC=C).
|
||||
// Because we do output as well as wcstod (which would have wcstod_l),
|
||||
// we need to set the locale here.
|
||||
// (glibc has uselocale since 2.3, but our configure checks fail us)
|
||||
locale_t prev_locale = uselocale(fish_numeric_locale());
|
||||
#else
|
||||
// NetBSD does not have uselocale,
|
||||
@@ -776,7 +777,7 @@ maybe_t<int> builtin_printf(parser_t &parser, io_streams_t &streams, const wchar
|
||||
argv += args_used;
|
||||
} while (args_used > 0 && argc > 0 && !state.early_exit);
|
||||
|
||||
#if defined(HAVE_USELOCALE)
|
||||
#if defined(HAVE_USELOCALE) || defined(__GLIBC__)
|
||||
uselocale(prev_locale);
|
||||
#else
|
||||
setlocale(LC_NUMERIC, prev_locale);
|
||||
|
||||
Reference in New Issue
Block a user