diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2007-02-09 18:44:37 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2007-02-09 18:44:37 (GMT) |
commit | 0e95a190bc124f38d5e680a0f7b1f41dd4c1fa15 (patch) | |
tree | d76e21d616b239fa53b5b32f18b32851a6d6c055 /Source/cmCommandArgumentParserHelper.cxx | |
parent | 0e1ae13f7c91774b6fca3835b422634a6f0f36b9 (diff) | |
download | CMake-0e95a190bc124f38d5e680a0f7b1f41dd4c1fa15.zip CMake-0e95a190bc124f38d5e680a0f7b1f41dd4c1fa15.tar.gz CMake-0e95a190bc124f38d5e680a0f7b1f41dd4c1fa15.tar.bz2 |
ENH: add atonly support to cmCommandArgumentParserHelper.cxx and remove old non-yacc parser code from cmMakefile.cxx
Diffstat (limited to 'Source/cmCommandArgumentParserHelper.cxx')
-rw-r--r-- | Source/cmCommandArgumentParserHelper.cxx | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index d446e15..cae9256 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -27,7 +27,7 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() { this->FileLine = -1; this->FileName = 0; - + this->RemoveEmpty = true; this->EmptyVariable[0] = 0; strcpy(this->DCURLYVariable, "${"); strcpy(this->RCURLYVariable, "}"); @@ -38,6 +38,7 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() this->NoEscapeMode = false; this->ReplaceAtSyntax = false; + this->AtOnly = false; } @@ -70,6 +71,18 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, if ( !key ) { return this->ExpandVariable(var); + } + if(this->AtOnly) + { + std::string ref = "$"; + ref += key; + ref += "{"; + if(var) + { + ref += var; + } + ref += "}"; + return this->AddString(ref.c_str()); } if ( strcmp(key, "ENV") == 0 ) { @@ -92,8 +105,21 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, return 0; } -char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) +char* cmCommandArgumentParserHelper::ExpandVariable(const char* var, + bool doingAt) { + // if we are in AtOnly mode, and we are not expanding an @ variable + // then put back the ${var} unexpanded + if(!doingAt && this->AtOnly) + { + std::string ref = "${"; + if(var) + { + ref += var; + } + ref += "}"; + return this->AddString(ref.c_str()); + } if(!var) { return 0; @@ -109,6 +135,10 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) return this->AddString(ostr.str().c_str()); } const char* value = this->Makefile->GetDefinition(var); + if(!value && !this->RemoveEmpty) + { + return 0; + } if (this->EscapeQuotes && value) { return this->AddString(cmSystemTools::EscapeQuotes(value).c_str()); @@ -120,15 +150,28 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) { if(this->ReplaceAtSyntax) { - return this->ExpandVariable(var); - } - else - { - std::string ref = "@"; - ref += var; - ref += "@"; - return this->AddString(ref.c_str()); + // try to expand the variable + char* ret = this->ExpandVariable(var, true); + // if the return was 0 and we want to replace empty strings + // then return an empty string + if(!ret && this->RemoveEmpty) + { + return this->AddString(ret); + } + // if the ret was not 0, then return it + if(ret) + { + return ret; + } } + // at this point we want to put it back because of one of these cases: + // - this->ReplaceAtSyntax is false + // - this->ReplaceAtSyntax is true, but this->RemoveEmpty is false, + // and the variable was not defined + std::string ref = "@"; + ref += var; + ref += "@"; + return this->AddString(ref.c_str()); } char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2) |