mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 16:18:43 -05:00
cmMakefile: store the number of last matches in a CMake var
With PushScope and PopScope, keeping track of another bit of data for
each scope isn't easy. Instead, store it as another CMake variable so it
gets implicitly tracked along with everything else.
This works in a revert of commit
7d674b5f0b.
This commit is contained in:
@@ -310,7 +310,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
|
||||
input += args[i];
|
||||
}
|
||||
|
||||
this->ClearMatches(this->Makefile);
|
||||
this->Makefile->ClearMatches();
|
||||
// Compile the regular expression.
|
||||
cmsys::RegularExpression re;
|
||||
if(!re.compile(regex.c_str()))
|
||||
@@ -325,7 +325,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
|
||||
std::string output;
|
||||
if(re.find(input.c_str()))
|
||||
{
|
||||
this->StoreMatches(this->Makefile, re);
|
||||
this->Makefile->StoreMatches(re);
|
||||
std::string::size_type l = re.start();
|
||||
std::string::size_type r = re.end();
|
||||
if(r-l == 0)
|
||||
@@ -359,7 +359,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
|
||||
input += args[i];
|
||||
}
|
||||
|
||||
this->ClearMatches(this->Makefile);
|
||||
this->Makefile->ClearMatches();
|
||||
// Compile the regular expression.
|
||||
cmsys::RegularExpression re;
|
||||
if(!re.compile(regex.c_str()))
|
||||
@@ -376,7 +376,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
|
||||
const char* p = input.c_str();
|
||||
while(re.find(p))
|
||||
{
|
||||
this->StoreMatches(this->Makefile, re);
|
||||
this->Makefile->StoreMatches(re);
|
||||
std::string::size_type l = re.start();
|
||||
std::string::size_type r = re.end();
|
||||
if(r-l == 0)
|
||||
@@ -463,7 +463,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
|
||||
input += args[i];
|
||||
}
|
||||
|
||||
this->ClearMatches(this->Makefile);
|
||||
this->Makefile->ClearMatches();
|
||||
// Compile the regular expression.
|
||||
cmsys::RegularExpression re;
|
||||
if(!re.compile(regex.c_str()))
|
||||
@@ -480,7 +480,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
|
||||
std::string::size_type base = 0;
|
||||
while(re.find(input.c_str()+base))
|
||||
{
|
||||
this->StoreMatches(this->Makefile, re);
|
||||
this->Makefile->StoreMatches(re);
|
||||
std::string::size_type l2 = re.start();
|
||||
std::string::size_type r = re.end();
|
||||
|
||||
@@ -540,38 +540,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmStringCommand::ClearMatches(cmMakefile* mf)
|
||||
{
|
||||
for (unsigned int i=0; i<10; i++)
|
||||
{
|
||||
char name[128];
|
||||
sprintf(name, "CMAKE_MATCH_%d", i);
|
||||
const char* s = mf->GetDefinition(name);
|
||||
if(s && *s != 0)
|
||||
{
|
||||
mf->AddDefinition(name, "");
|
||||
mf->MarkVariableAsUsed(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re)
|
||||
{
|
||||
for (unsigned int i=0; i<10; i++)
|
||||
{
|
||||
std::string m = re.match(i);
|
||||
if(m.size() > 0)
|
||||
{
|
||||
char name[128];
|
||||
sprintf(name, "CMAKE_MATCH_%d", i);
|
||||
mf->AddDefinition(name, re.match(i).c_str());
|
||||
mf->MarkVariableAsUsed(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
|
||||
args)
|
||||
|
||||
Reference in New Issue
Block a user