mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 10:01:14 -03:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user