From 7302a23a1f292d0a5c0f09fda6fe8c75871cf31b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 10 Nov 2020 11:28:30 -0500 Subject: cmake: Simplify -W recognition of no- and error= prefixes --- Source/cmake.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Source/cmake.cxx') diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 97834074af..5524d4e5f4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -527,28 +527,26 @@ bool cmake::SetCacheArgs(const std::vector& args) return true; }; - auto WarningLambda = [](std::string const& entry, cmake* state) -> bool { - std::string name; + auto WarningLambda = [](cm::string_view entry, cmake* state) -> bool { bool foundNo = false; bool foundError = false; - unsigned int nameStartPosition = 0; - if (entry.find("no-", nameStartPosition) == nameStartPosition) { + if (cmHasLiteralPrefix(entry, "no-")) { foundNo = true; - nameStartPosition += 3; + entry.remove_prefix(3); } - if (entry.find("error=", nameStartPosition) == nameStartPosition) { + if (cmHasLiteralPrefix(entry, "error=")) { foundError = true; - nameStartPosition += 6; + entry.remove_prefix(6); } - name = entry.substr(nameStartPosition); - if (name.empty()) { + if (entry.empty()) { cmSystemTools::Error("No warning name provided."); return false; } + std::string const name = std::string(entry); if (!foundNo && !foundError) { // -W state->DiagLevels[name] = std::max(state->DiagLevels[name], DIAG_WARN); -- cgit v1.2.1