summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-20 16:04:40 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-03-23 19:19:26 (GMT)
commitbfb69f9543bfa7f9f3c9488bf7e740f21896cec4 (patch)
tree866c20d05a20fae42cf06ef848796ba621d643f2 /Source
parent7df84ffe58572a4535b08bc7b76148a60d38fbb4 (diff)
downloadCMake-bfb69f9543bfa7f9f3c9488bf7e740f21896cec4.zip
CMake-bfb69f9543bfa7f9f3c9488bf7e740f21896cec4.tar.gz
CMake-bfb69f9543bfa7f9f3c9488bf7e740f21896cec4.tar.bz2
replace "substr(0, xx) ==" with cmHasPrefix()
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx10
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx3
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx7
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx2
-rw-r--r--Source/cmConditionEvaluator.cxx4
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.cxx4
-rw-r--r--Source/cmRST.cxx2
-rw-r--r--Source/cmSystemTools.cxx3
-rw-r--r--Source/cmcmd.cxx5
9 files changed, 16 insertions, 24 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 509ac65..2806c61 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -544,10 +544,7 @@ std::string cmCPackIFWGenerator::GetGroupPackageName(
if (group->ParentGroup) {
cmCPackIFWPackage* package = this->GetGroupPackage(group->ParentGroup);
bool dot = !this->ResolveDuplicateNames;
- if (dot && name.substr(0, package->Name.size()) == package->Name) {
- dot = false;
- }
- if (dot) {
+ if (dot && !cmHasPrefix(name, package->Name)) {
name = package->Name + "." + name;
}
}
@@ -576,10 +573,7 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
return package->Name;
}
bool dot = !this->ResolveDuplicateNames;
- if (dot && name.substr(0, package->Name.size()) == package->Name) {
- dot = false;
- }
- if (dot) {
+ if (dot && !cmHasPrefix(name, package->Name)) {
name = package->Name + "." + name;
}
}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 2ce989c..f29d8d9 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -350,8 +350,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
std::vector<std::string> options = GetOptions();
for (std::string const& name : options) {
- if (name.length() > prefix.length() &&
- name.substr(0, prefix.length()) == prefix) {
+ if (cmHasPrefix(name, prefix)) {
std::string id = name.substr(prefix.length());
std::string value = GetOption(name.c_str());
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 4a0ad33..daa10c9 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -680,8 +680,9 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
//
#ifdef _WIN32
# define fnc(s) cmSystemTools::LowerCase(s)
+# define fnc_prefix(s, t) fnc(s.substr(0, t.size())) == fnc(t)
#else
-# define fnc(s) s
+# define fnc_prefix(s, t) cmHasPrefix(s, t)
#endif
bool IsFileInDir(const std::string& infile, const std::string& indir)
@@ -689,8 +690,8 @@ bool IsFileInDir(const std::string& infile, const std::string& indir)
std::string file = cmSystemTools::CollapseFullPath(infile);
std::string dir = cmSystemTools::CollapseFullPath(indir);
- return file.size() > dir.size() &&
- fnc(file.substr(0, dir.size())) == fnc(dir) && file[dir.size()] == '/';
+ return file.size() > dir.size() && fnc_prefix(file, dir) &&
+ file[dir.size()] == '/';
}
int cmCTestCoverageHandler::HandlePHPCoverage(
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index b8329ea..1a5e7c5 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -155,7 +155,7 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
// if we have a routine name, check for end of routine
else {
// Totals in arg 0 marks the end of a routine
- if (separateLine[0].substr(0, 6) == "Totals") {
+ if (cmHasLiteralPrefix(separateLine[0], "Totals")) {
routine.clear(); // at the end of this routine
filepath.clear();
continue; // move to next line
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index fda687f..bf11022 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -494,12 +494,12 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end()) {
size_t argP1len = argP1->GetValue().size();
bool bdef = false;
- if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
+ if (argP1len > 4 && cmHasLiteralPrefix(argP1->GetValue(), "ENV{") &&
argP1->GetValue().operator[](argP1len - 1) == '}') {
std::string env = argP1->GetValue().substr(4, argP1len - 5);
bdef = cmSystemTools::HasEnv(env);
} else if (argP1len > 6 &&
- argP1->GetValue().substr(0, 6) == "CACHE{" &&
+ cmHasLiteralPrefix(argP1->GetValue(), "CACHE{") &&
argP1->GetValue().operator[](argP1len - 1) == '}') {
std::string cache = argP1->GetValue().substr(6, argP1len - 7);
bdef =
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index 561e830..a2b4d60 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -118,13 +118,13 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
} else {
bool relpath = false;
if (type == cmExportBuildAndroidMKGenerator::INSTALL) {
- relpath = lib.substr(0, 3) == "../";
+ relpath = cmHasLiteralPrefix(lib, "../");
}
// check for full path or if it already has a -l, or
// in the case of an install check for relative paths
// if it is full or a link library then use string directly
if (cmSystemTools::FileIsFullPath(lib) ||
- lib.substr(0, 2) == "-l" || relpath) {
+ cmHasLiteralPrefix(lib, "-l") || relpath) {
ldlibs += " " + lib;
// if it is not a path and does not have a -l then add -l
} else if (!lib.empty()) {
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 7f4abf9..68c15de 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -102,7 +102,7 @@ void cmRST::ProcessModule(std::istream& is)
this->ProcessLine("");
continue;
}
- if (line.substr(0, 2) == "# ") {
+ if (cmHasLiteralPrefix(line, "# ")) {
this->ProcessLine(line.substr(2));
continue;
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d8cd705..071f18e 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1055,8 +1055,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
if (type < 0 && !cmSystemTools::FileIsDirectory(fname)) {
continue;
}
- if (sfname.size() >= ppath.size() &&
- sfname.substr(0, ppath.size()) == ppath) {
+ if (cmHasPrefix(sfname, ppath)) {
files.push_back(fname);
res = true;
}
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 7eeb97f..8f619b1 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1054,8 +1054,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
homeOutDir = args[5];
startOutDir = args[6];
depInfo = args[7];
- if (args.size() >= 9 && args[8].length() >= 8 &&
- args[8].substr(0, 8) == "--color=") {
+ if (args.size() >= 9 && cmHasLiteralPrefix(args[8], "--color=")) {
// Enable or disable color based on the switch value.
color = (args[8].size() == 8 || cmIsOn(args[8].substr(8)));
}
@@ -1304,7 +1303,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
} else if (arg == "--debug") {
pipe.clear();
isDebug = true;
- } else if (arg.substr(0, pipePrefix.size()) == pipePrefix) {
+ } else if (cmHasPrefix(arg, pipePrefix)) {
isDebug = false;
pipe = arg.substr(pipePrefix.size());
if (pipe.empty()) {