Introduce Strings::case_insensitive_ascii_compare()
MODIFY
include/vcpkg_Strings.h
include/vcpkg_Strings.h
@@ -54,6 +54,8 @@ namespace vcpkg::Strings
std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern);
+ int case_insensitive_ascii_compare(const CStringView left, const CStringView right);
+
std::string ascii_to_lowercase(const std::string& input);
template<class T, class Transformer, class CharType>

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -700,7 +700,8 @@ namespace vcpkg::PostBuildLint
std::vector<fs::path> misplaced_files = fs.get_files_non_recursive(dir);
Util::unstable_keep_if(misplaced_files, [&fs](const fs::path& path) {
const std::string filename = path.filename().generic_string();
- if (_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0)
+ if (Strings::case_insensitive_ascii_compare(filename.c_str(), "CONTROL") == 0 ||
+ Strings::case_insensitive_ascii_compare(filename.c_str(), "BUILD_INFO") == 0)
return false;
return !fs.is_directory(path);
});

MODIFY
src/commands_install.cpp
src/commands_install.cpp
@@ -69,7 +69,8 @@ namespace vcpkg::Commands::Install
const std::string filename = file.filename().generic_string();
if (fs::is_regular_file(status) &&
- (_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0))
+ (Strings::case_insensitive_ascii_compare(filename.c_str(), "CONTROL") == 0 ||
+ Strings::case_insensitive_ascii_compare(filename.c_str(), "BUILD_INFO") == 0))
{
// Do not copy the control file
continue;

MODIFY
src/vcpkg_Strings.cpp
src/vcpkg_Strings.cpp
@@ -68,6 +68,11 @@ namespace vcpkg::Strings
[](const char a, const char b) { return details::tolower_char(a) == b; });
}
+ int case_insensitive_ascii_compare(const CStringView left, const CStringView right)
+ {
+ return _stricmp(left, right);
+ }
+
std::string ascii_to_lowercase(const std::string& input)
{
std::string output(input);

MODIFY
src/vcpkg_System.cpp
src/vcpkg_System.cpp
@@ -25,11 +25,11 @@ namespace vcpkg::System
Optional<CPUArchitecture> to_cpu_architecture(CStringView arch)
{
- if (_stricmp(arch, "x86") == 0) return CPUArchitecture::X86;
- if (_stricmp(arch, "x64") == 0) return CPUArchitecture::X64;
- if (_stricmp(arch, "amd64") == 0) return CPUArchitecture::X64;
- if (_stricmp(arch, "arm") == 0) return CPUArchitecture::ARM;
- if (_stricmp(arch, "arm64") == 0) return CPUArchitecture::ARM64;
+ if (Strings::case_insensitive_ascii_compare(arch, "x86") == 0) return CPUArchitecture::X86;
+ if (Strings::case_insensitive_ascii_compare(arch, "x64") == 0) return CPUArchitecture::X64;
+ if (Strings::case_insensitive_ascii_compare(arch, "amd64") == 0) return CPUArchitecture::X64;
+ if (Strings::case_insensitive_ascii_compare(arch, "arm") == 0) return CPUArchitecture::ARM;
+ if (Strings::case_insensitive_ascii_compare(arch, "arm64") == 0) return CPUArchitecture::ARM64;
return nullopt;
}

Introduce Strings::case_insensitive_ascii_compare()