diff options
author | Brad King <brad.king@kitware.com> | 2014-05-07 19:59:47 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-05-07 19:59:47 (GMT) |
commit | 1cc1efc063c332ec6e05837a33695adc4fd798e7 (patch) | |
tree | 5d32cdc665f54ef5a25c5bc19e6d356a0feffb58 /Source/cmMakefile.cxx | |
parent | 45f338e3d9fa73150348abc54f136cfdb001e654 (diff) | |
parent | 3f51752264bc1243fa2e56da41131ac363d3bd85 (diff) | |
download | CMake-1cc1efc063c332ec6e05837a33695adc4fd798e7.zip CMake-1cc1efc063c332ec6e05837a33695adc4fd798e7.tar.gz CMake-1cc1efc063c332ec6e05837a33695adc4fd798e7.tar.bz2 |
Merge topic 'dev/regex-variables'
3f517522 StoreMatches: Minor cleanups
ef62fbad ClearMatches: Store match variable names statically
f718b30a ClearMatches: Only clear matches which were actually set
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 801627a..f6219ab 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -101,6 +101,8 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->Initialize(); this->PreOrder = false; this->GeneratingBuildSystem = false; + + this->NumLastMatches = 0; } cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) @@ -149,6 +151,8 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->CheckSystemVars = mf.CheckSystemVars; this->ListFileStack = mf.ListFileStack; this->OutputToSource = mf.OutputToSource; + + this->NumLastMatches = mf.NumLastMatches; } //---------------------------------------------------------------------------- @@ -4274,6 +4278,51 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const return this->QtUiFilesWithOptions; } +static std::string matchVariables[] = { + "CMAKE_MATCH_0", + "CMAKE_MATCH_1", + "CMAKE_MATCH_2", + "CMAKE_MATCH_3", + "CMAKE_MATCH_4", + "CMAKE_MATCH_5", + "CMAKE_MATCH_6", + "CMAKE_MATCH_7", + "CMAKE_MATCH_8", + "CMAKE_MATCH_9" +}; + +//---------------------------------------------------------------------------- +void cmMakefile::ClearMatches() +{ + for (unsigned int i=0; i<this->NumLastMatches; i++) + { + std::string const& var = matchVariables[i]; + std::string const& s = this->GetSafeDefinition(var); + if(!s.empty()) + { + this->AddDefinition(var, ""); + this->MarkVariableAsUsed(var); + } + } + this->NumLastMatches = 0; +} + +//---------------------------------------------------------------------------- +void cmMakefile::StoreMatches(cmsys::RegularExpression& re) +{ + for (unsigned int i=0; i<10; i++) + { + std::string const& m = re.match(i); + if(!m.empty()) + { + std::string const& var = matchVariables[i]; + this->AddDefinition(var, m.c_str()); + this->MarkVariableAsUsed(var); + this->NumLastMatches = i + 1; + } + } +} + //---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const |