diff options
author | Brad King <brad.king@kitware.com> | 2020-11-10 11:28:30 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-19 08:53:58 -0500 |
commit | 7302a23a1f292d0a5c0f09fda6fe8c75871cf31b (patch) | |
tree | 8a7e98a8a3f2139cedbda4c5d93acff47d080f86 /Source/cmake.cxx | |
parent | 98290782b65f6d3cdd68bc0acaaf7b3b5d19070c (diff) | |
download | cmake-7302a23a1f292d0a5c0f09fda6fe8c75871cf31b.tar.gz |
cmake: Simplify -W recognition of no- and error= prefixes
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
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<std::string>& 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<name> state->DiagLevels[name] = std::max(state->DiagLevels[name], DIAG_WARN); |