mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 04:27:46 +08:00
Remove wcsdup fallback
2a0e0d6721
removed the last use of it,
and in most cases we'd probably prefer to use a wcstring instead
This commit is contained in:
parent
4dfcd4cb4e
commit
5e0f5eff37
|
@ -133,18 +133,12 @@ SET(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}")
|
|||
check_cxx_symbol_exists(eventfd sys/eventfd.h HAVE_EVENTFD)
|
||||
check_cxx_symbol_exists(pipe2 unistd.h HAVE_PIPE2)
|
||||
check_cxx_symbol_exists(wcscasecmp wchar.h HAVE_WCSCASECMP)
|
||||
check_cxx_symbol_exists(wcsdup wchar.h HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
|
||||
|
||||
# These are for compatibility with Solaris 10, which places the following
|
||||
# in the std namespace.
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcscasecmp wchar.h HAVE_STD__WCSCASECMP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(std::wcsdup wchar.h HAVE_STD__WCSDUP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -61,9 +61,6 @@
|
|||
/* Define to 1 if you have the `std::wcscasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsdup' function. */
|
||||
#cmakedefine HAVE_STD__WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSNCASECMP 1
|
||||
|
||||
|
@ -94,9 +91,6 @@
|
|||
/* Define to 1 if you have the `wcscasecmp' function. */
|
||||
#cmakedefine HAVE_WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsdup' function. */
|
||||
#cmakedefine HAVE_WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_WCSNCASECMP 1
|
||||
|
||||
|
|
|
@ -58,21 +58,10 @@ int fish_mkstemp_cloexec(char *name_template) {
|
|||
return result_fd;
|
||||
}
|
||||
|
||||
/// Fallback implementations of wcsdup and wcscasecmp. On systems where these are not needed (e.g.
|
||||
/// Fallback implementations of wcsncasecmp and wcscasecmp. On systems where these are not needed (e.g.
|
||||
/// building on Linux) these should end up just being stripped, as they are static functions that
|
||||
/// are not referenced in this file.
|
||||
// cppcheck-suppress unusedFunction
|
||||
[[gnu::unused]] static wchar_t *wcsdup_fallback(const wchar_t *in) {
|
||||
size_t len = std::wcslen(in);
|
||||
auto out = static_cast<wchar_t *>(malloc(sizeof(wchar_t) * (len + 1)));
|
||||
if (out == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::memcpy(out, in, sizeof(wchar_t) * (len + 1));
|
||||
return out;
|
||||
}
|
||||
|
||||
[[gnu::unused]] static int wcscasecmp_fallback(const wchar_t *a, const wchar_t *b) {
|
||||
if (*a == 0) {
|
||||
return *b == 0 ? 0 : -1;
|
||||
|
@ -99,12 +88,6 @@ int fish_mkstemp_cloexec(char *name_template) {
|
|||
return wcsncasecmp_fallback(a + 1, b + 1, count - 1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_WCSDUP
|
||||
#ifndef HAVE_STD__WCSDUP
|
||||
wchar_t *wcsdup(const wchar_t *in) { return wcsdup_fallback(in); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WCSCASECMP
|
||||
#ifndef HAVE_STD__WCSCASECMP
|
||||
int wcscasecmp(const wchar_t *a, const wchar_t *b) { return wcscasecmp_fallback(a, b); }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
// The following include must be kept despite what IWYU says. That's because of the interaction
|
||||
// between the weak linking of `wcsdup` and `wcscasecmp` via `#define`s below and the declarations
|
||||
// between the weak linking of `wcscasecmp` via `#define`s below and the declarations
|
||||
// in <wchar.h>. At least on OS X if we don't do this we get compilation errors do to the macro
|
||||
// substitution if wchar.h is included after this header.
|
||||
#include <cwchar> // IWYU pragma: keep
|
||||
|
@ -75,14 +75,6 @@ char *tparm_solaris_kludge(char *str, long p1 = 0, long p2 = 0, long p3 = 0, lon
|
|||
|
||||
/// These functions are missing from Solaris 10, and only accessible from
|
||||
/// Solaris 11 in the std:: namespace.
|
||||
#ifndef HAVE_WCSDUP
|
||||
#ifdef HAVE_STD__WCSDUP
|
||||
using std::wcsdup;
|
||||
#else
|
||||
wchar_t *wcsdup(const wchar_t *in);
|
||||
#endif // HAVE_STD__WCSDUP
|
||||
#endif // HAVE_WCSDUP
|
||||
|
||||
#ifndef HAVE_WCSCASECMP
|
||||
#ifdef HAVE_STD__WCSCASECMP
|
||||
using std::wcscasecmp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user