Commit 75844dd6 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'cleanup-find-cstr'

69ca85cc

 Remove unnecessary c_str() in RegularExpression::find calls
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2271
parents 34334c09 69ca85cc
......@@ -369,7 +369,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
inFile += '/';
}
for (cmsys::RegularExpression& reg : ignoreFilesRegex) {
if (reg.find(inFile.c_str())) {
if (reg.find(inFile)) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Ignore file: " << inFile << std::endl);
skip = true;
......
......@@ -589,7 +589,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
for (cmCTestCompileErrorWarningRex& rit :
this->ErrorWarningFileLineRegex) {
cmsys::RegularExpression* re = &rit.RegularExpression;
if (re->find(cm->Text.c_str())) {
if (re->find(cm->Text)) {
cm->SourceFile = re->match(rit.FileIndex);
// At this point we need to make this->SourceFile relative to
// the source root of the project, so cvs links will work
......
......@@ -1075,7 +1075,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
if (line.empty()) {
// Ignore empty line; probably style 2
} else if (st1re1.find(line.c_str())) {
} else if (st1re1.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
......@@ -1088,7 +1088,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
actualSourceFile.clear();
sourceFile = st1re1.match(2);
} else if (st1re2.find(line.c_str())) {
} else if (st1re2.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
......@@ -1100,7 +1100,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
gcovFile = st1re2.match(1);
} else if (st2re1.find(line.c_str())) {
} else if (st2re1.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......@@ -1113,7 +1113,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
actualSourceFile.clear();
sourceFile = st2re1.match(1);
} else if (st2re2.find(line.c_str())) {
} else if (st2re2.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......@@ -1123,7 +1123,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cont->Error++;
break;
}
} else if (st2re3.find(line.c_str())) {
} else if (st2re3.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......@@ -1135,7 +1135,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
gcovFile = st2re3.match(2);
} else if (st2re4.find(line.c_str())) {
} else if (st2re4.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......@@ -1150,7 +1150,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
"Warning: " << st2re4.match(1)
<< " had unexpected EOF" << std::endl,
this->Quiet);
} else if (st2re5.find(line.c_str())) {
} else if (st2re5.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......@@ -1165,7 +1165,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
"Warning: Cannot open file: " << st2re5.match(1)
<< std::endl,
this->Quiet);
} else if (st2re6.find(line.c_str())) {
} else if (st2re6.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
......
......@@ -584,7 +584,7 @@ bool cmCTestLaunch::Match(std::string const& line,
std::vector<cmsys::RegularExpression>& regexps)
{
for (cmsys::RegularExpression& r : regexps) {
if (r.find(line.c_str())) {
if (r.find(line)) {
return true;
}
}
......
......@@ -49,7 +49,7 @@ void cmCTestRunTest::CheckOutput(std::string const& line)
// Check for TIMEOUT_AFTER_MATCH property.
if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
for (auto& reg : this->TestProperties->TimeoutRegularExpressions) {
if (reg.first.find(this->ProcessOutput.c_str())) {
if (reg.first.find(this->ProcessOutput)) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
this->GetIndex()
<< ": "
......@@ -148,7 +148,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
this->FailedDependencies.empty()) {
bool found = false;
for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
if (pass.first.find(this->ProcessOutput.c_str())) {
if (pass.first.find(this->ProcessOutput)) {
found = true;
reason = "Required regular expression found.";
break;
......@@ -168,7 +168,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
if (!this->TestProperties->ErrorRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
for (auto& pass : this->TestProperties->ErrorRegularExpressions) {
if (pass.first.find(this->ProcessOutput.c_str())) {
if (pass.first.find(this->ProcessOutput)) {
reason = "Error regular expression found in output.";
reason += " Regex=[";
reason += pass.second;
......@@ -616,10 +616,10 @@ void cmCTestRunTest::DartProcessing()
{
if (!this->ProcessOutput.empty() &&
this->ProcessOutput.find("<DartMeasurement") != std::string::npos) {
if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str())) {
if (this->TestHandler->DartStuff.find(this->ProcessOutput)) {
this->TestResult.DartString = this->TestHandler->DartStuff.match(1);
// keep searching and replacing until none are left
while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str())) {
while (this->TestHandler->DartStuff1.find(this->ProcessOutput)) {
// replace the exact match for the string
cmSystemTools::ReplaceString(
this->ProcessOutput, this->TestHandler->DartStuff1.match(1).c_str(),
......
......@@ -2310,7 +2310,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
this->Quiet);
if (this->UseExcludeRegExpFlag && this->UseExcludeRegExpFirst &&
this->ExcludeTestsRegularExpression.find(testname.c_str())) {
this->ExcludeTestsRegularExpression.find(testname)) {
return true;
}
if (this->MemCheck) {
......@@ -2365,10 +2365,10 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.SkipReturnCode = -1;
test.PreviousRuns = 0;
if (this->UseIncludeRegExpFlag &&
!this->IncludeTestsRegularExpression.find(testname.c_str())) {
!this->IncludeTestsRegularExpression.find(testname)) {
test.IsInBasedOnREOptions = false;
} else if (this->UseExcludeRegExpFlag && !this->UseExcludeRegExpFirst &&
this->ExcludeTestsRegularExpression.find(testname.c_str())) {
this->ExcludeTestsRegularExpression.find(testname)) {
test.IsInBasedOnREOptions = false;
}
this->TestList.push_back(test);
......
......@@ -40,8 +40,8 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
if (!buildname.empty()) {
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
cmsys::RegularExpression reg(RegExp.c_str());
if (reg.find(buildname.c_str())) {
cmsys::RegularExpression reg(RegExp);
if (reg.find(buildname)) {
buildname = reg.match(1) + "-" + reg.match(2);
}
}
......
......@@ -174,7 +174,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Complain if the file cannot be found and matches the complain
// regex.
if (fullName.empty() &&
this->IncludeRegexComplain.find(current.FileName.c_str())) {
this->IncludeRegexComplain.find(current.FileName)) {
cmSystemTools::Error("Cannot find file \"", current.FileName.c_str(),
"\".");
return false;
......@@ -359,7 +359,7 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
}
// Match include directives.
if (this->IncludeRegexLine.find(line.c_str())) {
if (this->IncludeRegexLine.find(line)) {
// Get the file being included.
UnscannedEntry entry;
entry.FileName = this->IncludeRegexLine.match(2);
......@@ -383,7 +383,7 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
// file their own directory by simply using "filename.h" (#12619)
// This kind of problem will be fixed when a more
// preprocessor-like implementation of this scanner is created.
if (this->IncludeRegexScan.find(entry.FileName.c_str())) {
if (this->IncludeRegexScan.find(entry.FileName)) {
newCacheEntry->UnscannedEntries.push_back(entry);
if (this->Encountered.find(entry.FileName) ==
this->Encountered.end()) {
......@@ -449,7 +449,7 @@ void cmDependsC::ParseTransform(std::string const& xform)
void cmDependsC::TransformLine(std::string& line)
{
// Check for a transform rule match. Return if none.
if (!this->IncludeRegexTransform.find(line.c_str())) {
if (!this->IncludeRegexTransform.find(line)) {
return;
}
TransformRulesType::const_iterator tri =
......
......@@ -237,7 +237,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
}
const char* packageExpr = "^[A-Za-z0-9_.-]+$";
cmsys::RegularExpression packageRegex(packageExpr);
if (!packageRegex.find(package.c_str())) {
if (!packageRegex.find(package)) {
std::ostringstream e;
e << "PACKAGE given invalid package name \"" << package << "\". "
<< "Package names must match \"" << packageExpr << "\".";
......
......@@ -98,7 +98,7 @@ void cmExtraEclipseCDT4Generator::Generate()
std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION");
cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*");
if (regex.find(eclipseVersion.c_str())) {
if (regex.find(eclipseVersion)) {
unsigned int majorVersion = 0;
unsigned int minorVersion = 0;
int res =
......@@ -555,7 +555,7 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
// Frameworks/ part has to be stripped
// /System/Library/Frameworks/GLUT.framework/Headers
cmsys::RegularExpression frameworkRx("(.+/Frameworks)/.+\\.framework/");
if (frameworkRx.find(dir.c_str())) {
if (frameworkRx.find(dir)) {
dir = frameworkRx.match(1);
}
......
......@@ -663,7 +663,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// The current line has been terminated. Check if the current
// string matches the requirements. The length may now be as
// low as zero since blank lines are allowed.
if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
if (s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
s.clear();
......@@ -679,7 +679,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// string matches the requirements. We require that the length
// be at least one no matter what the user specified.
if (s.length() >= minlen && !s.empty() &&
(!have_regex || regex.find(s.c_str()))) {
(!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
s.clear();
......@@ -696,7 +696,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
if (maxlen > 0 && s.size() == maxlen) {
// Terminate a string if the maximum length is reached.
if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
if (s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
s.clear();
......@@ -712,7 +712,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// input file or the input size limit. Check if the current string
// matches the requirements.
if ((!limit_count || strings.size() < limit_count) && !s.empty() &&
s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output < 0 || output_size < limit_output) {
strings.push_back(s);
......
......@@ -337,7 +337,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
this->Configs.push_back(args[i]);
} else if (!haveVersion && version.find(args[i].c_str())) {
} else if (!haveVersion && version.find(args[i])) {
haveVersion = true;
this->Version = args[i];
} else {
......
......@@ -1126,7 +1126,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
std::string targetName = parameters.front();
propertyName = parameters[1];
if (!cmGeneratorExpression::IsValidTargetName(targetName)) {
if (!propertyNameValidator.find(propertyName.c_str())) {
if (!propertyNameValidator.find(propertyName)) {
::reportError(context, content->GetOriginalExpression(),
"Target name and property name not supported.");
return std::string();
......
......@@ -1139,7 +1139,7 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
std::string cppFileName = xaml + ".cpp";
files.ExpectedXamlHeaders.insert(hFileName);
files.ExpectedXamlSources.insert(cppFileName);
} else if (header_regex.find(sf->GetFullPath().c_str())) {
} else if (header_regex.find(sf->GetFullPath())) {
kind = SourceKindHeader;
} else {
kind = SourceKindExtra;
......
......@@ -1971,7 +1971,7 @@ void cmLocalGenerator::AppendCompileOptions(
cmsys::RegularExpression r(regex);
for (std::string const& opt : options_vec) {
if (r.find(opt.c_str())) {
if (r.find(opt)) {
this->AppendFlagEscape(options, opt);
}
}
......
......@@ -356,8 +356,7 @@ protected:
if (!found) {
// Couldn't find any dependency information.
if (this->ComplainFileRegularExpression.find(
info->IncludeName.c_str())) {
if (this->ComplainFileRegularExpression.find(info->IncludeName)) {
cmSystemTools::Error("error cannot find dependencies for ", path);
} else {
// Destroy the name of the file so that it won't be output as a
......
......@@ -273,7 +273,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
// Scan through the input for all matches.
std::string output;
if (re.find(input.c_str())) {
if (re.find(input)) {
this->Makefile->StoreMatches(re);
std::string::size_type l = re.start();
std::string::size_type r = re.end();
......
......@@ -82,12 +82,12 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
// regular expression for gl GL or xmesa in a file (match(1) of above)
cmsys::RegularExpression glLine("(gl|GL|xmesa)");
while (cmSystemTools::GetLineFromStream(fin, inLine)) {
if (includeLine.find(inLine.c_str())) {
if (includeLine.find(inLine)) {
std::string includeFile = includeLine.match(1);
if (glDirLine.find(includeFile.c_str())) {
if (glDirLine.find(includeFile)) {
std::string gfile = glDirLine.match(3);
fout << "#include \"" << outdir << "/" << gfile << "\"\n";
} else if (glLine.find(includeFile.c_str())) {
} else if (glLine.find(includeFile)) {
fout << "#include \"" << outdir << "/" << includeLine.match(1)
<< "\"\n";
} else {
......
......@@ -407,7 +407,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
for (std::string const& ck : cacheKeys) {
cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(ck);
if (t != cmStateEnums::STATIC) {
if (regex.find(ck.c_str())) {
if (regex.find(ck)) {
entriesToDelete.push_back(ck);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment