From 17d84a64e910cab46c097013523967f4e7f19b58 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Tue, 28 Jul 2026 09:37:04 -0400 Subject: [PATCH] KWSys 2026-07-28 (b5fb218b) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit b5fb218b6b2b2da08939ff5dfc6dd4e83e87009d (master). Upstream Shortlog ----------------- Brad King (1): 9fd9ce30 SystemTools: Remove Strnucmp in favor of String_strncasecmp Tyler Yankee (1): 3a121a09 SystemTools: Widen string for registry deletion --- SystemTools.cxx | 19 ++----------------- SystemTools.hxx.in | 9 +-------- testSystemTools.cxx | 39 --------------------------------------- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index f18f67ebc4..ff1a3f5829 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -1252,7 +1252,8 @@ bool SystemTools::DeleteRegistryValue(std::string const& key, KeyWOW64 view) &hKey) != ERROR_SUCCESS) { return false; } else { - if (RegDeleteValue(hKey, (LPTSTR)valuename.c_str()) == ERROR_SUCCESS) { + if (RegDeleteValueW(hKey, Encoding::ToWide(valuename).c_str()) == + ERROR_SUCCESS) { RegCloseKey(hKey); return true; } @@ -2728,22 +2729,6 @@ int SystemTools::Strucmp(char const* l, char const* r) return lc - rc; } -int SystemTools::Strnucmp(char const* l, char const* r, size_t n) -{ - int lc; - int rc; - size_t count = 0; - do { - lc = kwsysString_tolower(*l++); - rc = kwsysString_tolower(*r++); - count++; - if (count >= n) { - return lc - rc; - } - } while (lc == rc && lc); - return lc - rc; -} - // return file's modified time long int SystemTools::ModifiedTime(std::string const& filename) { diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 330846f320..12b37406a2 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -198,17 +198,10 @@ public: char separator = '/', bool isPath = false); /** - * Perform a case-independent string comparison. - * Similar to POSIX's strcasecmp. + * Perform a case-independent string comparison */ static int Strucmp(char const* s1, char const* s2); - /** - * Perform a case-independent string comparison, but compares at most n - * characters. Similar to POSIX's strncasecmp. - */ - static int Strnucmp(char const* s1, char const* s2, size_t n); - /** * Split a string on its newlines into multiple lines * Return false only if the last line stored had no newline diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 6e0958202d..e48525de43 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -1317,43 +1317,6 @@ static bool CheckSplitString() return ret; } -static bool CheckStringComparisons() -{ - if (!(kwsys::SystemTools::Strucmp("", "") == 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("bob", "bob") == 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("bob", "BOB") == 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("bob1", "BoB2") < 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("bOb4", "Bob3") > 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("aaa", "aaaaaaaaa") < 0)) - return false; - if (!(kwsys::SystemTools::Strucmp("aaaaaaaaa", "aaa") > 1)) - return false; - - if (!(kwsys::SystemTools::Strnucmp("", "", 0) == 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("", "", 3000) == 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("bob", "Bobby", 3) == 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("Bob", "boBBy", 3) == 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("bob", "Bobby", 3000) < 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("bobbY", "BOB", 3000) > 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("bobb", "Bobby", 5) < 0)) - return false; - if (!(kwsys::SystemTools::Strnucmp("bobbY", "BOBb", 5) > 0)) - return false; - - return true; -} - int testSystemTools(int, char*[]) { bool res = true; @@ -1407,7 +1370,5 @@ int testSystemTools(int, char*[]) res &= CheckSplitString(); - res &= CheckStringComparisons(); - return res ? 0 : 1; }