Create an immortal C locale

This adds a function fish_c_locale() which returns an immortal locale_t
corresponding to the C locale, and switches builtin_printf to use wcstod_l.
This commit is contained in:
ridiculousfish
2018-07-28 17:56:42 -07:00
parent 09541e9524
commit 42c648ab35
3 changed files with 10 additions and 9 deletions

View File

@@ -517,6 +517,11 @@ int fish_wcswidth(const wchar_t *str) { return fish_wcswidth(str, wcslen(str));
/// See fallback.h for the normal definitions.
int fish_wcswidth(const wcstring &str) { return fish_wcswidth(str.c_str(), str.size()); }
locale_t fish_c_locale() {
static locale_t loc = newlocale(LC_ALL_MASK, "C", NULL);
return loc;
}
/// Like fish_wcstol(), but fails on a value outside the range of an int.
///
/// This is needed because BSD and GNU implementations differ in several ways that make it really