From 37d9387be37b5ad51b518d5df467b64e88f73350 Mon Sep 17 00:00:00 2001 From: Pavel Solodovnikov Date: Sat, 16 Sep 2017 01:42:59 +0300 Subject: Replace empty-string comparisons with checking against `empty()`. --- Source/CPack/IFW/cmCPackIFWRepository.cxx | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 4 ++-- Source/CTest/cmCTestMultiProcessHandler.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 4 ++-- Source/CTest/cmCTestSVN.cxx | 2 +- Source/CTest/cmCTestSubmitHandler.cxx | 10 +++++----- Source/CTest/cmCTestTestHandler.cxx | 4 ++-- Source/CTest/cmParseCoberturaCoverage.cxx | 4 ++-- Source/CTest/cmParseDelphiCoverage.cxx | 3 ++- Source/CTest/cmParseJacocoCoverage.cxx | 2 +- Source/cmCTest.cxx | 6 +++--- Source/cmDependsJavaParserHelper.cxx | 2 +- Source/cmFindLibraryCommand.cxx | 4 ++-- Source/cmFindProgramCommand.cxx | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmLoadCommandCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio7Generator.cxx | 6 +++--- Source/cmOutputRequiredFilesCommand.cxx | 2 +- Source/cmPolicies.cxx | 2 +- Source/cmServer.cxx | 2 +- Source/cmSystemTools.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 4 ++-- 24 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 87e7089..a01fc4e 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -162,7 +162,7 @@ protected: void CharacterDataHandler(const char* data, int length) override { std::string content(data, data + length); - if (content == "" || content == " " || content == " " || + if (content.empty() || content == " " || content == " " || content == "\n") { return; } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 28fc113..1da42d4 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -260,11 +260,11 @@ std::string cmCTestBuildHandler::GetMakeCommand() "MakeCommand:" << makeCommand << "\n", this->Quiet); std::string configType = this->CTest->GetConfigType(); - if (configType == "") { + if (configType.empty()) { configType = this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType"); } - if (configType == "") { + if (configType.empty()) { configType = "Release"; } diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index c853373..6a7bdc0 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -491,7 +491,7 @@ void cmCTestMultiProcessHandler::ReadCostData() } // Next part of the file is the failed tests while (std::getline(fin, line)) { - if (line != "") { + if (!line.empty()) { this->LastTestsFailed.push_back(line); } } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 56a9cb8..abdb643 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -494,7 +494,7 @@ bool cmCTestRunTest::StartTest(size_t total) } } // log and return if we did not find the executable - if (this->ActualCommand == "") { + if (this->ActualCommand.empty()) { // if the command was not found create a TestResult object // that has that information this->TestProcess = new cmProcess; @@ -595,7 +595,7 @@ double cmCTestRunTest::ResolveTimeout() { double timeout = this->TestProperties->Timeout; - if (this->CTest->GetStopTime() == "") { + if (this->CTest->GetStopTime().empty()) { return timeout; } struct tm* lctime; diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 087eb38..ce96224 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -410,7 +410,7 @@ void cmCTestSVN::DoRevisionSVN(Revision const& revision, // Ignore changes in the old revision for external repositories if (revision.Rev == revision.SVNInfo->OldRevision && - revision.SVNInfo->LocalPath != "") { + !revision.SVNInfo->LocalPath.empty()) { return; } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 137cea9..e51e168 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -496,11 +496,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, ? "" : this->GetOption("RetryCount"); - int delay = retryDelay == "" + int delay = retryDelay.empty() ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay") .c_str()) : atoi(retryDelay.c_str()); - int count = retryCount == "" + int count = retryCount.empty() ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount") .c_str()) : atoi(retryCount.c_str()); @@ -1032,14 +1032,14 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, ? "" : this->GetOption("RetryCount"); unsigned long retryDelay = 0; - if (retryDelayString != "") { + if (!retryDelayString.empty()) { if (!cmSystemTools::StringToULong(retryDelayString.c_str(), &retryDelay)) { cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : " << retryDelayString << std::endl); } } unsigned long retryCount = 0; - if (retryCountString != "") { + if (!retryCountString.empty()) { if (!cmSystemTools::StringToULong(retryCountString.c_str(), &retryCount)) { cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : " << retryCountString << std::endl); @@ -1361,7 +1361,7 @@ int cmCTestSubmitHandler::ProcessHandler() std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); - if (dropMethod == "" || dropMethod == "ftp") { + if (dropMethod.empty() || dropMethod == "ftp") { ofs << "Using drop method: FTP" << std::endl; cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Using FTP submit method" << std::endl diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f3404a5..5896014 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1596,7 +1596,7 @@ std::string cmCTestTestHandler::FindExecutable( // wasn't specified if (fullPath.empty() && filepath.empty()) { std::string const path = cmSystemTools::FindProgram(filename.c_str()); - if (path != "") { + if (!path.empty()) { resultingConfig.clear(); return path; } @@ -1802,7 +1802,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() if (fileNameSubstring != pattern) { continue; } - if (logName == "") { + if (logName.empty()) { logName = fileName; } else { // if multiple matching logs were found we use the most recently diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 3e85339..61ce7d4 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -78,7 +78,7 @@ protected: } } - if (this->CurFileName == "") { + if (this->CurFileName.empty()) { // Check if this is a path that is relative to our source or // binary directories. for (std::string const& filePath : FilePaths) { @@ -91,7 +91,7 @@ protected: } cmsys::ifstream fin(this->CurFileName.c_str()); - if (this->CurFileName == "" || !fin) { + if (this->CurFileName.empty() || !fin) { this->CurFileName = this->Coverage.BinaryDir + "/" + atts[tagCount + 1]; fin.open(this->CurFileName.c_str()); diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index 4b781a6..6d82cb2 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -71,7 +71,8 @@ public: } } // Based up what was found, add a line to the coverageVector - if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) { + if (!beginSet.empty() && !line.empty() && !blockComFlag && + !lineComFlag) { coverageVector.push_back(0); } else { coverageVector.push_back(-1); diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 56d07e7..7acb5ca 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -36,7 +36,7 @@ protected: } else if (name == "sourcefile") { std::string fileName = atts[1]; - if (this->PackagePath == "") { + if (this->PackagePath.empty()) { if (!this->FindPackagePath(fileName)) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " << this->PackageName << "/" << fileName << std::endl); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index d60ce55..ba50986 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -147,7 +147,7 @@ std::string cmCTest::CurrentTime() std::string cmCTest::GetCostDataFile() { std::string fname = this->GetCTestConfiguration("CostDataFile"); - if (fname == "") { + if (fname.empty()) { fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt"; } return fname; @@ -1235,7 +1235,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value) { std::string safevalue(value); - if (safevalue != "") { + if (!safevalue.empty()) { // Disallow non-filename and non-space whitespace characters. // If they occur, replace them with "" // @@ -1254,7 +1254,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value) } } - if (safevalue == "") { + if (safevalue.empty()) { safevalue = "(empty)"; } diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 85dfc7d..f227cf2 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -310,7 +310,7 @@ void cmDependsJavaParserHelper::Error(const char* str) void cmDependsJavaParserHelper::UpdateCombine(const char* str1, const char* str2) { - if (this->CurrentCombine == "" && str1 != nullptr) { + if (this->CurrentCombine.empty() && str1 != nullptr) { this->CurrentCombine = str1; } this->CurrentCombine += "."; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 09a9648..b8b51ba 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -68,8 +68,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn, this->AddArchitecturePaths("x32"); } - std::string library = this->FindLibrary(); - if (library != "") { + std::string const library = this->FindLibrary(); + if (!library.empty()) { // Save the value in the cache this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(), this->VariableDocumentation.c_str(), diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index a5dc1c6..2059b3d 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -97,8 +97,8 @@ bool cmFindProgramCommand::InitialPass(std::vector const& argsIn, return true; } - std::string result = FindProgram(); - if (result != "") { + std::string const result = FindProgram(); + if (!result.empty()) { // Save the value in the cache this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 15ddeff..be40126 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -230,7 +230,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() // The all and preinstall rules might never have any dependencies // added to them. - if (this->EmptyRuleHackDepends != "") { + if (!this->EmptyRuleHackDepends.empty()) { depends.push_back(this->EmptyRuleHackDepends); } @@ -438,7 +438,7 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // Work-around for makes that drop rules that have no dependencies // or commands. - if (depends.empty() && this->EmptyRuleHackDepends != "") { + if (depends.empty() && !this->EmptyRuleHackDepends.empty()) { depends.push_back(this->EmptyRuleHackDepends); } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index ece2a77..0651536 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -150,7 +150,7 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() { std::string dir = this->GetUserMacrosDirectory(); - if (dir != "") { + if (!dir.empty()) { std::string src = cmSystemTools::GetCMakeRoot(); src += "/Templates/" CMAKE_VSMACROS_FILENAME; @@ -190,7 +190,7 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro( // - the CMake vsmacros file is registered // - there were .sln/.vcproj files changed during generation // - if (dir != "") { + if (!dir.empty()) { std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME; std::string nextSubkeyName; if (cmSystemTools::FileExists(macrosFile.c_str()) && diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 2850032..6bfac17 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -197,7 +197,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector const& args, // Try to find the program. std::string fullPath = cmSystemTools::FindFile(moduleName, path); - if (fullPath == "") { + if (fullPath.empty()) { std::ostringstream e; e << "Attempt to load command failed from file \"" << moduleName << "\""; this->SetError(e.str()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e1662ac..1a088ea 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1410,7 +1410,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // If the input name is the empty string, there is no real // dependency. Short-circuit the other checks: - if (name == "") { + if (name.empty()) { return false; } @@ -2096,7 +2096,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( } // Install this target if a destination is given. - if (l->Target->GetInstallPath() != "") { + if (!l->Target->GetInstallPath().empty()) { // Compute the full install destination. Note that converting // to unix slashes also removes any trailing slash. // We also skip over the leading slash given by the user. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index c978936..a1771ee 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1591,7 +1591,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( // If the group has a name, write the header. std::string name = sg->GetName(); - if (name != "") { + if (!name.empty()) { this->WriteVCProjBeginGroup(fout, name.c_str(), ""); } @@ -1709,7 +1709,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( } // If the group has a name, write the footer. - if (name != "") { + if (!name.empty()) { this->WriteVCProjEndGroup(fout); } @@ -2006,7 +2006,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter( i != props.end(); ++i) { if (i->find("VS_GLOBAL_") == 0) { std::string name = i->substr(10); - if (name != "") { + if (!name.empty()) { /* clang-format off */ fout << "\t\tDependencySet) { if (visited->find(d) == visited->end()) { - if (info->FullPath != "") { + if (!info->FullPath.empty()) { std::string tmp = d->FullPath; std::string::size_type pos = tmp.rfind('.'); if (pos != std::string::npos && (tmp.substr(pos) != ".h")) { diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a1f346a..e7d1b72 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -140,7 +140,7 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, *defaultSetting = cmPolicies::NEW; } else if (defaultValue == "OLD") { *defaultSetting = cmPolicies::OLD; - } else if (defaultValue == "") { + } else if (defaultValue.empty()) { *defaultSetting = cmPolicies::WARN; } else { std::ostringstream e; diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 30d0f51..e923c22 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -84,7 +84,7 @@ void cmServer::ProcessRequest(cmConnection* connection, const cmServerRequest request(this, connection, value[kTYPE_KEY].asString(), value[kCOOKIE_KEY].asString(), value); - if (request.Type == "") { + if (request.Type.empty()) { cmServerResponse response(request); response.SetError("No type given in request."); this->WriteResponse(connection, response, nullptr); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f2737d..58adc43 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1375,7 +1375,7 @@ std::string cmSystemTools::CollapseCombinedPath(std::string const& dir, if (fileComponents.empty()) { return dir; } - if (fileComponents[0] != "") { + if (!fileComponents[0].empty()) { // File is not a relative path. return file; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 99b9bce..8dce028 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -407,7 +407,7 @@ void cmVisualStudio10TargetGenerator::Generate() continue; std::string globalKey = keyIt->substr(strlen(prefix)); // Skip invalid or separately-handled properties. - if (globalKey == "" || globalKey == "PROJECT_TYPES" || + if (globalKey.empty() || globalKey == "PROJECT_TYPES" || globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") { continue; } @@ -614,7 +614,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() ++i) { if (i->first.find("VS_DOTNET_REFERENCE_") == 0) { std::string name = i->first.substr(20); - if (name != "") { + if (!name.empty()) { std::string path = i->second.GetValue(); if (!cmsys::SystemTools::FileIsFullPath(path)) { path = std::string(this->GeneratorTarget->Target->GetMakefile() -- cgit v0.12