summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-03-12 18:23:12 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-04-29 20:00:05 (GMT)
commitf718b30a95e07d72a361d55b7ba495eda5d79680 (patch)
tree5f06d51f999483a1e111fa2969d7a0d125356b55 /Source/cmStringCommand.cxx
parentbb1c41a085c6eb9296bf701ea7633f715a06f6e1 (diff)
downloadCMake-f718b30a95e07d72a361d55b7ba495eda5d79680.zip
CMake-f718b30a95e07d72a361d55b7ba495eda5d79680.tar.gz
CMake-f718b30a95e07d72a361d55b7ba495eda5d79680.tar.bz2
ClearMatches: Only clear matches which were actually set
ClearMatches was clearing many variables which were never set in the first place. Instead, store how many matches were made last time and only clear those. It is moved to the cmMakefile class since it is a common utility used by multiple commands.
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx44
1 files changed, 6 insertions, 38 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index ea762eb..65912da 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -305,7 +305,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()))
@@ -320,7 +320,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)
@@ -354,7 +354,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()))
@@ -371,7 +371,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)
@@ -458,7 +458,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()))
@@ -475,7 +475,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();
@@ -536,38 +536,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
-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)
{