summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-11-26 18:53:06 (GMT)
committerBrad King <brad.king@kitware.com>2014-11-26 18:53:06 (GMT)
commit808c77e2319a4a81a86b2df3bf8fbba6bdbac7ac (patch)
tree97ba6bf36741c5fadc780b6b9242ebdfae8f4b64 /Source/cmStringCommand.cxx
parent82582c96bd86969ee5e1cc6f7bc4e5b12e1717e1 (diff)
parent7d674b5f0b28a610333644d417c2e8cb796cc9e4 (diff)
downloadCMake-808c77e2319a4a81a86b2df3bf8fbba6bdbac7ac.zip
CMake-808c77e2319a4a81a86b2df3bf8fbba6bdbac7ac.tar.gz
CMake-808c77e2319a4a81a86b2df3bf8fbba6bdbac7ac.tar.bz2
Merge branch 'revert-cached-regex-clear' into revert-cached-regex-clear-for-master
Resolve conflict in Source/cmMakefile.h by integrating both changes.
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx44
1 files changed, 38 insertions, 6 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 8341027..9827c62 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -310,7 +310,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
input += args[i];
}
- this->Makefile->ClearMatches();
+ this->ClearMatches(this->Makefile);
// 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->Makefile->StoreMatches(re);
+ this->StoreMatches(this->Makefile, 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->Makefile->ClearMatches();
+ this->ClearMatches(this->Makefile);
// 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->Makefile->StoreMatches(re);
+ this->StoreMatches(this->Makefile, 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->Makefile->ClearMatches();
+ this->ClearMatches(this->Makefile);
// 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->Makefile->StoreMatches(re);
+ this->StoreMatches(this->Makefile, re);
std::string::size_type l2 = re.start();
std::string::size_type r = re.end();
@@ -541,6 +541,38 @@ 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)
{