[cmake-commits] martink committed cmMakefile.cxx 1.421 1.422 cmMakefile.h 1.216 1.217 cmRaiseScopeCommand.cxx 1.1 1.2 cmRaiseScopeCommand.h 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jan 3 11:21:41 EST 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv30051/Source

Modified Files:
	cmMakefile.cxx cmMakefile.h cmRaiseScopeCommand.cxx 
	cmRaiseScopeCommand.h 
Log Message:
ENH: change raise_scope signature to be safer for returned varuables


Index: cmRaiseScopeCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmRaiseScopeCommand.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmRaiseScopeCommand.h	3 Dec 2007 17:43:52 -0000	1.1
+++ cmRaiseScopeCommand.h	3 Jan 2008 16:21:39 -0000	1.2
@@ -61,12 +61,13 @@
   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.";
     }
 
   /**

Index: cmRaiseScopeCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmRaiseScopeCommand.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmRaiseScopeCommand.cxx	3 Dec 2007 17:43:52 -0000	1.1
+++ cmRaiseScopeCommand.cxx	3 Jan 2008 16:21:39 -0000	1.2
@@ -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;
 }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -d -r1.216 -r1.217
--- cmMakefile.h	3 Dec 2007 18:35:33 -0000	1.216
+++ cmMakefile.h	3 Jan 2008 16:21:39 -0000	1.217
@@ -740,7 +740,7 @@
   // 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

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.421
retrieving revision 1.422
diff -u -d -r1.421 -r1.422
--- cmMakefile.cxx	2 Jan 2008 22:49:16 -0000	1.421
+++ cmMakefile.cxx	3 Jan 2008 16:21:39 -0000	1.422
@@ -2846,9 +2846,12 @@
   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)



More information about the Cmake-commits mailing list