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:
Fabian Boehm
2022-08-27 11:36:15 +02:00
parent 4dfcd4cb4e
commit 5e0f5eff37
4 changed files with 2 additions and 39 deletions

View File

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