From 8ae1ba34328c7f7f88af4789865fd99bda360f36 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 9 Apr 2023 12:12:13 +0200 Subject: [PATCH] wutil: remove unused locale handling code that has been ported already --- src/env_dispatch.cpp | 4 +++- src/wutil.cpp | 19 ------------------- src/wutil.h | 6 ------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index 48f4fdd16..3b3ab1248 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -11,6 +11,8 @@ #include #include +#include "ffi_init.rs.h" + #if HAVE_CURSES_H #include // IWYU pragma: keep #elif HAVE_NCURSES_H @@ -656,7 +658,7 @@ static void init_locale(const environment_t &vars) { setlocale(LC_NUMERIC, "C"); // See that we regenerate our special locale for numbers. - fish_invalidate_numeric_locale(); + rust_invalidate_numeric_locale(); fish_setlocale(); FLOGF(env_locale, L"init_locale() setlocale(): '%s'", locale); diff --git a/src/wutil.cpp b/src/wutil.cpp index 9013ad59a..8ffacfd0a 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -33,7 +33,6 @@ #include "common.h" #include "fallback.h" // IWYU pragma: keep #include "fds.h" -#include "ffi_init.rs.h" #include "flog.h" #include "wcstringutil.h" @@ -627,24 +626,6 @@ int fish_wcswidth(const wchar_t *str) { return fish_wcswidth(str, std::wcslen(st /// See fallback.h for the normal definitions. int fish_wcswidth(const wcstring &str) { return fish_wcswidth(str.c_str(), str.size()); } -static bool fish_numeric_locale_is_valid = false; - -void fish_invalidate_numeric_locale() { - fish_numeric_locale_is_valid = false; - rust_invalidate_numeric_locale(); -} - -locale_t fish_numeric_locale() { - // The current locale, except LC_NUMERIC isn't forced to C. - static locale_t loc = nullptr; - if (!fish_numeric_locale_is_valid) { - if (loc != nullptr) freelocale(loc); - auto cur = duplocale(LC_GLOBAL_LOCALE); - loc = newlocale(LC_NUMERIC_MASK, "", cur); - fish_numeric_locale_is_valid = true; - } - 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 diff --git a/src/wutil.h b/src/wutil.h index a615d71f3..fca980fa8 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -136,12 +136,6 @@ int fish_iswgraph(wint_t wc); int fish_wcswidth(const wchar_t *str); int fish_wcswidth(const wcstring &str); -// returns an immortal locale_t corresponding to the C locale. -locale_t fish_c_locale(); - -void fish_invalidate_numeric_locale(); -locale_t fish_numeric_locale(); - int fish_wcstoi(const wchar_t *str, const wchar_t **endptr = nullptr, int base = 10); long fish_wcstol(const wchar_t *str, const wchar_t **endptr = nullptr, int base = 10); long long fish_wcstoll(const wchar_t *str, const wchar_t **endptr = nullptr, int base = 10);