mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 05:10:10 -05:00
replace "substr(0, xx) ==" with cmHasPrefix()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+2
-3
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user