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
This commit is contained in:
David Adam 2023-07-13 22:00:53 +08:00
parent 44cf0e5043
commit 861da91bf1
8 changed files with 0 additions and 119 deletions

View file

@ -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)

View file

@ -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

View file

@ -262,16 +262,3 @@ int flock(int fd, int op) {
}
#endif // HAVE_FLOCK
#if !defined(HAVE_WCSTOD_L) && !defined(__NetBSD__)
#undef wcstod_l
#include <locale.h>
// 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)

View file

@ -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

View file

@ -170,8 +170,6 @@ maybe_t<statuses_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<process_ptr_t *>(processes.data()), processes.size()};
}

View file

@ -543,9 +543,6 @@ class job_t : noncopyable_t {
/// \returns the statuses for this job.
maybe_t<statuses_t> get_statuses() const;
/// \returns the list of processes.
const process_list_t &get_processes() const;
/// autocxx junk.
RustFFIProcList ffi_processes() const;

View file

@ -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) {

View file

@ -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);