From 861da91bf1029c1442f154f6c369b1b6030b29f3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 13 Jul 2023 22:00:53 +0800 Subject: [PATCH] drop unused functions and configure checks Remove the following C++ functions/methods, which have no callers: fallback.cpp: - wcstod_l proc.cpp: - job_t::get_processes wutil.cpp: - fish_wcstoll - fish_wcstoull Also drop unused configure checks/defines: - HAVE_WCSTOD_L - HAVE_USELOCALE --- cmake/ConfigureChecks.cmake | 11 ------- config_cmake.h.in | 6 ---- src/fallback.cpp | 13 -------- src/fallback.h | 17 ---------- src/proc.cpp | 2 -- src/proc.h | 3 -- src/wutil.cpp | 64 ------------------------------------- src/wutil.h | 3 -- 8 files changed, 119 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 59f9b5a5a..db7ba5757 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -1,8 +1,6 @@ # The following defines affect the environment configuration tests are run in: # CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_LIBRARIES, # and CMAKE_REQUIRED_INCLUDES -# `wcstod_l` is a GNU-extension, sometimes hidden behind GNU-related defines. -# This is the case for at least Cygwin and Newlib. list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1) include(CheckCXXCompilerFlag) include(CMakePushCheckState) @@ -167,16 +165,7 @@ if(NOT HAVE_WCSNCASECMP) check_cxx_symbol_exists(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP) endif() -# `xlocale.h` is required to find `wcstod_l` in `wchar.h` under FreeBSD, -# but it's not present under Linux. check_include_files("xlocale.h" HAVE_XLOCALE_H) -if(HAVE_XLOCALE_H) - list(APPEND WCSTOD_L_INCLUDES "xlocale.h") -endif() -list(APPEND WCSTOD_L_INCLUDES "wchar.h") -check_cxx_symbol_exists(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L) - -check_cxx_symbol_exists(uselocale "locale.h;xlocale.h" HAVE_USELOCALE) cmake_push_check_state() check_struct_has_member("struct winsize" ws_row "termios.h;sys/ioctl.h" _HAVE_WINSIZE) diff --git a/config_cmake.h.in b/config_cmake.h.in index b9ea96f15..a53d8a11e 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -94,9 +94,6 @@ /* Define to 1 if you have the `wcsncasecmp' function. */ #cmakedefine HAVE_WCSNCASECMP 1 -/* Define to 1 if you have the `wcstod_l' function. */ -#cmakedefine HAVE_WCSTOD_L 1 - /* Define to 1 if the status that wait returns and WEXITSTATUS expects is signal and then ret instead of the other way around. */ #cmakedefine HAVE_WAITSTATUS_SIGNAL_RET 1 @@ -144,9 +141,6 @@ /* Define if xlocale.h is required for locale_t or wide character support */ #cmakedefine HAVE_XLOCALE_H 1 -/* Define if uselocale is available */ -#cmakedefine HAVE_USELOCALE 1 - /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 diff --git a/src/fallback.cpp b/src/fallback.cpp index e022f3cab..3d093d703 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -262,16 +262,3 @@ int flock(int fd, int op) { } #endif // HAVE_FLOCK - -#if !defined(HAVE_WCSTOD_L) && !defined(__NetBSD__) -#undef wcstod_l -#include -// For platforms without wcstod_l C extension, wrap wcstod after changing the -// thread-specific locale. -double fish_compat::wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc) { - locale_t prev_locale = uselocale(loc); - double ret = std::wcstod(enptr, endptr); - uselocale(prev_locale); - return ret; -} -#endif // defined(wcstod_l) diff --git a/src/fallback.h b/src/fallback.h index b56caafe1..f56ceda08 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -127,21 +127,4 @@ int flock(int fd, int op); #define LOCK_NB 4 // Don't block when locking. #endif -// NetBSD _has_ wcstod_l, but it's doing some weak linking hullabaloo that I don't get. -// Since it doesn't have uselocale (yes, the standard function isn't there, the non-standard -// extension is), we can't try to use the fallback. -#if !defined(HAVE_WCSTOD_L) && !defined(__NetBSD__) -// On some platforms if this is incorrectly detected and a system-defined -// defined version of `wcstod_l` exists, calling `wcstod` from our own -// `wcstod_l` can call back into `wcstod_l` causing infinite recursion. -// e.g. FreeBSD defines `wcstod(x, y)` as `wcstod_l(x, y, __get_locale())`. -// Solution: namespace our implementation to make sure there is no symbol -// duplication. -#undef wcstod_l -namespace fish_compat { -double wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc); -} -#define wcstod_l(x, y, z) fish_compat::wcstod_l(x, y, z) -#endif - #endif // FISH_FALLBACK_H diff --git a/src/proc.cpp b/src/proc.cpp index e4ce149fc..8b4422ecf 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -170,8 +170,6 @@ maybe_t job_t::get_statuses() const { return st; } -const process_list_t &job_t::get_processes() const { return processes; } - RustFFIProcList job_t::ffi_processes() const { return RustFFIProcList{const_cast(processes.data()), processes.size()}; } diff --git a/src/proc.h b/src/proc.h index dd9231eb1..f0ef9cc33 100644 --- a/src/proc.h +++ b/src/proc.h @@ -543,9 +543,6 @@ class job_t : noncopyable_t { /// \returns the statuses for this job. maybe_t get_statuses() const; - /// \returns the list of processes. - const process_list_t &get_processes() const; - /// autocxx junk. RustFFIProcList ffi_processes() const; diff --git a/src/wutil.cpp b/src/wutil.cpp index 766118ef0..b076305e0 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -665,70 +665,6 @@ long fish_wcstol(const wchar_t *str, const wchar_t **endptr, int base) { return result; } -/// An enhanced version of wcstoll(). -/// -/// This is needed because BSD and GNU implementations differ in several ways that make it really -/// annoying to use them in a portable fashion. -/// -/// The caller doesn't have to zero errno. Sets errno to -1 if the int ends with something other -/// than a digit. Leading whitespace is ignored (per the base wcstoll implementation). Trailing -/// whitespace is also ignored. -long long fish_wcstoll(const wchar_t *str, const wchar_t **endptr, int base) { - while (iswspace(*str)) ++str; // skip leading whitespace - if (!*str) { // this is because some implementations don't handle this sensibly - errno = EINVAL; - if (endptr) *endptr = str; - return 0; - } - - errno = 0; - wchar_t *_endptr; - long long result = std::wcstoll(str, &_endptr, base); - while (iswspace(*_endptr)) ++_endptr; // skip trailing whitespace - if (!errno && *_endptr) { - if (_endptr == str) { - errno = EINVAL; - } else { - errno = -1; - } - } - if (endptr) *endptr = _endptr; - return result; -} - -/// An enhanced version of wcstoull(). -/// -/// This is needed because BSD and GNU implementations differ in several ways that make it really -/// annoying to use them in a portable fashion. -/// -/// The caller doesn't have to zero errno. Sets errno to -1 if the int ends with something other -/// than a digit. Leading minus is considered invalid. Leading whitespace is ignored (per the base -/// wcstoull implementation). Trailing whitespace is also ignored. -unsigned long long fish_wcstoull(const wchar_t *str, const wchar_t **endptr, int base) { - while (iswspace(*str)) ++str; // skip leading whitespace - if (!*str || // this is because some implementations don't handle this sensibly - *str == '-') // disallow minus as the first character to avoid questionable wrap-around - { - errno = EINVAL; - if (endptr) *endptr = str; - return 0; - } - - errno = 0; - wchar_t *_endptr; - unsigned long long result = std::wcstoull(str, &_endptr, base); - while (iswspace(*_endptr)) ++_endptr; // skip trailing whitespace - if (!errno && *_endptr) { - if (_endptr == str) { - errno = EINVAL; - } else { - errno = -1; - } - } - if (endptr) *endptr = _endptr; - return result; -} - /// Like wcstod(), but wcstod() is enormously expensive on some platforms so this tries to have a /// fast path. double fish_wcstod(const wchar_t *str, wchar_t **endptr, size_t len) { diff --git a/src/wutil.h b/src/wutil.h index e27333b4d..e190bf0b6 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -144,9 +144,6 @@ int fish_wcswidth(const wcstring &str); 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); -unsigned long long fish_wcstoull(const wchar_t *str, const wchar_t **endptr = nullptr, - int base = 10); double fish_wcstod(const wchar_t *str, wchar_t **endptr, size_t len); double fish_wcstod(const wchar_t *str, wchar_t **endptr); double fish_wcstod(const wcstring &str, wchar_t **endptr);