summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmIfCommand.cxx6
-rw-r--r--Source/cmIfCommand.h2
-rw-r--r--Source/cmStringCommand.cxx20
-rw-r--r--Source/cmStringCommand.h5
4 files changed, 19 insertions, 14 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index cdcf79d..12d156c 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -15,6 +15,8 @@
=========================================================================*/
#include "cmIfCommand.h"
+#include "cmStringCommand.h"
+
#include <stdlib.h> // required for atof
#include <list>
#include <cmsys/RegularExpression.hxx>
@@ -215,7 +217,7 @@ namespace
bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
- char **errorString, const cmMakefile *makefile)
+ char **errorString, cmMakefile *makefile)
{
// check for the different signatures
const char *def;
@@ -369,6 +371,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
const char* rex = (argP2)->c_str();
+ cmStringCommand::ClearMatches(makefile);
cmsys::RegularExpression regEntry;
if ( !regEntry.compile(rex) )
{
@@ -382,6 +385,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
if (regEntry.find(def))
{
*arg = "1";
+ cmStringCommand::StoreMatches(makefile, regEntry);
}
else
{
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index 6b855a2..7698595 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -174,7 +174,7 @@ public:
// arguments were valid, and if so, was the response true. If there is
// an error, the errorString will be set.
static bool IsTrue(const std::vector<std::string> &args,
- char** errorString, const cmMakefile *mf);
+ char** errorString, cmMakefile *mf);
// Get a definition from the makefile. If it doesn't exist,
// return the original string.
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 437b121..f746f82 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -248,7 +248,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches();
+ this->ClearMatches(this->Makefile);
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -263,7 +263,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
std::string output;
if(re.find(input.c_str()))
{
- this->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)
@@ -297,7 +297,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches();
+ this->ClearMatches(this->Makefile);
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -314,7 +314,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
const char* p = input.c_str();
while(re.find(p))
{
- this->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)
@@ -401,7 +401,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches();
+ this->ClearMatches(this->Makefile);
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -418,7 +418,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(re);
+ this->StoreMatches(this->Makefile, re);
std::string::size_type l2 = re.start();
std::string::size_type r = re.end();
@@ -479,24 +479,24 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
-void cmStringCommand::ClearMatches()
+void cmStringCommand::ClearMatches(cmMakefile* mf)
{
for (unsigned int i=0; i<10; i++)
{
char name[128];
sprintf(name, "CMAKE_MATCH_%d", i);
- this->Makefile->AddDefinition(name, "");
+ mf->AddDefinition(name, "");
}
}
//----------------------------------------------------------------------------
-void cmStringCommand::StoreMatches(cmsys::RegularExpression& re)
+void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re)
{
for (unsigned int i=0; i<10; i++)
{
char name[128];
sprintf(name, "CMAKE_MATCH_%d", i);
- this->Makefile->AddDefinition(name, re.match(i).c_str());
+ mf->AddDefinition(name, re.match(i).c_str());
}
}
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index e94f762..e323707 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -19,6 +19,7 @@
#include "cmCommand.h"
+class cmMakefile;
namespace cmsys
{
class RegularExpression;
@@ -122,6 +123,8 @@ public:
}
cmTypeMacro(cmStringCommand, cmCommand);
+ static void ClearMatches(cmMakefile* mf);
+ static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re);
protected:
bool HandleConfigureCommand(std::vector<std::string> const& args);
bool HandleAsciiCommand(std::vector<std::string> const& args);
@@ -137,8 +140,6 @@ protected:
bool HandleSubstringCommand(std::vector<std::string> const& args);
bool HandleStripCommand(std::vector<std::string> const& args);
bool HandleRandomCommand(std::vector<std::string> const& args);
- void ClearMatches();
- void StoreMatches(cmsys::RegularExpression& re);
class RegexReplacement
{