[cmake-commits] alex committed cmIfCommand.h 1.42 1.43
cmIfCommand.cxx 1.79 1.80 cmStringCommand.cxx 1.24 1.25
cmStringCommand.h 1.22 1.23
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Aug 29 11:58:40 EDT 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv27562
Modified Files:
cmIfCommand.h cmIfCommand.cxx cmStringCommand.cxx
cmStringCommand.h
Log Message:
ENH: also store the group matches from IF( MATCHES) in CMAKE_MATCH_(0..9)
Alex
Index: cmStringCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmStringCommand.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cmStringCommand.cxx 21 Aug 2007 15:30:09 -0000 1.24
+++ cmStringCommand.cxx 29 Aug 2007 15:58:38 -0000 1.25
@@ -248,7 +248,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
//----------------------------------------------------------------------------
-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());
}
}
Index: cmStringCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmStringCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmStringCommand.h 21 Aug 2007 16:34:06 -0000 1.22
+++ cmStringCommand.h 29 Aug 2007 15:58:38 -0000 1.23
@@ -19,6 +19,7 @@
#include "cmCommand.h"
+class cmMakefile;
namespace cmsys
{
class RegularExpression;
@@ -122,6 +123,8 @@
}
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 @@
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
{
Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- cmIfCommand.cxx 6 Jun 2007 12:49:18 -0000 1.79
+++ cmIfCommand.cxx 29 Aug 2007 15:58:38 -0000 1.80
@@ -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 @@
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 @@
{
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 @@
if (regEntry.find(def))
{
*arg = "1";
+ cmStringCommand::StoreMatches(makefile, regEntry);
}
else
{
Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- cmIfCommand.h 6 Jun 2007 12:49:18 -0000 1.42
+++ cmIfCommand.h 29 Aug 2007 15:58:38 -0000 1.43
@@ -174,7 +174,7 @@
// 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.
More information about the Cmake-commits
mailing list