diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2021-05-11 15:20:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2021-05-11 15:20:04 (GMT) |
commit | 5e8fa0b7bcdd8f4f1af2a61335df9a1c952dbbdf (patch) | |
tree | 440ad6c931ede616674c1616cb328efc0ad80cf0 | |
parent | ee87e53d3732a6482841c01c16e89f2822137d0e (diff) | |
download | CMake-5e8fa0b7bcdd8f4f1af2a61335df9a1c952dbbdf.zip CMake-5e8fa0b7bcdd8f4f1af2a61335df9a1c952dbbdf.tar.gz CMake-5e8fa0b7bcdd8f4f1af2a61335df9a1c952dbbdf.tar.bz2 |
Source: Minor code improvements
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 5 | ||||
-rw-r--r-- | Source/cmCMakePathCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmCPluginAPI.cxx | 2 | ||||
-rw-r--r-- | Source/cmDepends.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalNMakeMakefileGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 6 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
9 files changed, 14 insertions, 17 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 103dc1e..03caa63 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -3,7 +3,6 @@ #include "cmCTestBuildHandler.h" #include <cstdlib> -#include <cstring> #include <set> #include <utility> @@ -657,14 +656,14 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) { // error-{hash}.xml return (cmHasLiteralPrefix(fname, "error-") && - strcmp(fname + strlen(fname) - 4, ".xml") == 0); + cmHasLiteralSuffix(fname, ".xml")); } bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname) { // warning-{hash}.xml return (cmHasLiteralPrefix(fname, "warning-") && - strcmp(fname + strlen(fname) - 4, ".xml") == 0); + cmHasLiteralSuffix(fname, ".xml")); } //###################################################################### diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx index 962fdcc..9a5fa7b 100644 --- a/Source/cmCMakePathCommand.cxx +++ b/Source/cmCMakePathCommand.cxx @@ -18,6 +18,7 @@ #include "cmCMakePath.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSubcommandTable.h" @@ -149,8 +150,8 @@ public: bool getInputPath(const std::string& arg, cmExecutionStatus& status, std::string& path) { - const auto* def = status.GetMakefile().GetDefinition(arg); - if (def == nullptr) { + cmProp def = status.GetMakefile().GetDefinition(arg); + if (!def) { status.SetError("undefined variable for input path."); return false; } diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 438a077..ace7382 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -734,7 +734,7 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir, } sf->SourceName = name; std::string fname = sf->SourceName; - if (ext && strlen(ext)) { + if (cmNonempty(ext)) { fname += "."; fname += ext; } diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 566c3bf..46c7e3e 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -229,11 +229,10 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, void cmDepends::SetIncludePathFromLanguage(const std::string& lang) { // Look for the new per "TARGET_" variant first: - cmProp includePath = nullptr; std::string includePathVar = cmStrCat("CMAKE_", lang, "_TARGET_INCLUDE_PATH"); cmMakefile* mf = this->LocalGenerator->GetMakefile(); - includePath = mf->GetDefinition(includePathVar); + cmProp includePath = mf->GetDefinition(includePathVar); if (includePath) { cmExpandList(*includePath, this->IncludePath); } else { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 55fba79..1357974 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2260,7 +2260,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, // Check whether the genex expansion of the property agrees in all // configurations. - if (trueCount && falseCount) { + if (trueCount > 0 && falseCount > 0) { std::ostringstream e; e << "The EXCLUDE_FROM_ALL property of target \"" << target->GetName() << "\" varies by configuration. This is not supported by the \"" diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 313f39b..f08b1da 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -43,9 +43,7 @@ bool cmGlobalNMakeMakefileGenerator::FindMakeProgram(cmMakefile* mf) return false; } if (cmProp nmakeCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) { - std::vector<std::string> command; - command.emplace_back(*nmakeCommand); - command.emplace_back("-?"); + std::vector<std::string> command{ *nmakeCommand, "-?" }; std::string out; std::string err; if (!cmSystemTools::RunSingleCommand(command, &out, &err, nullptr, nullptr, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index db7357a..fbbdfca 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2786,7 +2786,7 @@ void cmLocalGenerator::IncludeFileInUnitySources( cmGeneratedFileStream& unity_file, std::string const& sf_full_path, cmProp beforeInclude, cmProp afterInclude, cmProp uniqueIdName) const { - if (uniqueIdName && !uniqueIdName->empty()) { + if (cmNonempty(uniqueIdName)) { std::string pathToHash; auto PathEqOrSubDir = [](std::string const& a, std::string const& b) { return (cmSystemTools::ComparePath(a, b) || diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5a37bb9..29f9e36 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2479,7 +2479,7 @@ const std::string& cmMakefile::GetRequiredDefinition( const std::string& name) const { static std::string const empty; - const std::string* def = this->GetDefinition(name); + cmProp def = this->GetDefinition(name); if (!def) { cmSystemTools::Error("Error required internal CMake variable not " "set, cmake may not be built correctly.\n" @@ -2553,7 +2553,7 @@ cmProp cmMakefile::GetDefinition(const std::string& name) const const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const { static std::string const empty; - const std::string* def = this->GetDefinition(name); + cmProp def = this->GetDefinition(name); if (!def) { return empty; } @@ -3067,7 +3067,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew( if (filename && variable == lineVar) { varresult = std::to_string(line); } else { - const std::string* def = this->GetDefinition(variable); + cmProp def = this->GetDefinition(variable); if (def) { varresult = *def; } else if (!this->SuppressSideEffects) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ba0cf9c..12a3679 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -498,7 +498,7 @@ void cmVisualStudio10TargetGenerator::Generate() cmProp targetFramework = this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK"); if (targetFramework) { - if (std::strchr(targetFramework->c_str(), ';') != nullptr) { + if (targetFramework->find(';') != std::string::npos) { e1.Element("TargetFrameworks", *targetFramework); } else { e1.Element("TargetFramework", *targetFramework); |