mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-09 23:59:53 -05:00
Replace empty-string comparisons with checking against empty().
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
-3
@@ -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)";
|
||||
}
|
||||
|
||||
|
||||
@@ -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 += ".";
|
||||
|
||||
@@ -68,8 +68,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> 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(),
|
||||
|
||||
@@ -97,8 +97,8 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> 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(),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) &&
|
||||
|
||||
@@ -197,7 +197,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> 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());
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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\t<Global\n"
|
||||
<< "\t\t\tName=\"" << name << "\"\n"
|
||||
|
||||
@@ -510,7 +510,7 @@ void cmOutputRequiredFilesCommand::ListDependencies(
|
||||
// now recurse with info's dependencies
|
||||
for (cmDependInformation* d : info->DependencySet) {
|
||||
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")) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user