diff options
author | Ken Martin <ken.martin@kitware.com> | 2008-01-03 16:22:33 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2008-01-03 16:22:33 (GMT) |
commit | ac4c2f675a5607839a639d2297002c85351bfbe7 (patch) | |
tree | c859990e5578df97976d80ec535b8f81c250c1a9 /Source | |
parent | c61a3b6fe9580687458fc9687174a1acce4edf77 (diff) | |
download | CMake-ac4c2f675a5607839a639d2297002c85351bfbe7.zip CMake-ac4c2f675a5607839a639d2297002c85351bfbe7.tar.gz CMake-ac4c2f675a5607839a639d2297002c85351bfbe7.tar.bz2 |
ENH: change raise_scope signature to be safer for returned varuables
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmRaiseScopeCommand.cxx | 16 | ||||
-rw-r--r-- | Source/cmRaiseScopeCommand.h | 9 |
4 files changed, 24 insertions, 10 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 49fc0f1..c74cf4d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2846,9 +2846,12 @@ void cmMakefile::PopScope() this->DefinitionStack.pop_back(); } -void cmMakefile::RaiseScope(const char *var) +void cmMakefile::RaiseScope(const char *var, const char *varDef) { - const char *varDef = this->GetDefinition(var); + if (!var || !strlen(var)) + { + return; + } // multiple scopes in this directory? if (this->DefinitionStack.size() > 1) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 2d4e61f..3fa9951 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -740,7 +740,7 @@ public: // push and pop variable scopes void PushScope(); void PopScope(); - void RaiseScope(const char *var); + void RaiseScope(const char *var, const char *value); protected: // add link libraries and directories to the target diff --git a/Source/cmRaiseScopeCommand.cxx b/Source/cmRaiseScopeCommand.cxx index ffaff8e..adf87d8 100644 --- a/Source/cmRaiseScopeCommand.cxx +++ b/Source/cmRaiseScopeCommand.cxx @@ -20,10 +20,20 @@ bool cmRaiseScopeCommand ::InitialPass(std::vector<std::string> const& args) { - unsigned int i =0; - for(; i < args.size(); ++i) + if (args.size() < 1) { - this->Makefile->RaiseScope(args[i].c_str()); + this->SetError("called with incorrect number of arguments, " + "raise scope must have at least one argument"); + return false; + } + + if (args.size() == 1) + { + this->Makefile->RaiseScope(args[0].c_str(), 0); + } + else + { + this->Makefile->RaiseScope(args[0].c_str(), args[1].c_str()); } return true; } diff --git a/Source/cmRaiseScopeCommand.h b/Source/cmRaiseScopeCommand.h index 51d4f1f..0ff2e4e 100644 --- a/Source/cmRaiseScopeCommand.h +++ b/Source/cmRaiseScopeCommand.h @@ -61,12 +61,13 @@ public: virtual const char* GetFullDocumentation() { return - " raise_scope(VAR VAR2 VAR...)\n" - "Pushes the current state of a variable into the scope above the " + " raise_scope(VAR [VALUE])\n" + "Sets the value of a variable in the scope above the " "current scope. Each new directory or function creates a new scope. " - "This command will push the current state of a variable into the " + "This command will set the value of a variable into the " "parent directory or calling function (whichever is applicable to " - "the case at hand)"; + "the case at hand) If VALUE is not specified then the variable is " + "removed from the parent scope."; } /** |