From 5e0f5eff37e19b444be5f916297013b2044b899a Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 27 Aug 2022 11:36:15 +0200 Subject: [PATCH] Remove wcsdup fallback 2a0e0d67214aa45493e2f7b1782f672164fb8bc4 removed the last use of it, and in most cases we'd probably prefer to use a wcstring instead --- cmake/ConfigureChecks.cmake | 6 ------ config_cmake.h.in | 6 ------ src/fallback.cpp | 19 +------------------ src/fallback.h | 10 +--------- 4 files changed, 2 insertions(+), 39 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index f4b30c3d1..798f85368 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -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() diff --git a/config_cmake.h.in b/config_cmake.h.in index c690172ca..b9ea96f15 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -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 diff --git a/src/fallback.cpp b/src/fallback.cpp index 07d6e21c5..8578701ed 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -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(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); } diff --git a/src/fallback.h b/src/fallback.h index 377b52a8c..6cfdb2041 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -5,7 +5,7 @@ #include // 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 . 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 // 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;