[Cmake-commits] [cmake-commits] king committed cmFunctionCommand.cxx 1.6 1.7 cmMakefile.h 1.239 1.240

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jan 14 15:14:09 EST 2009


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

Modified Files:
	cmFunctionCommand.cxx cmMakefile.h 
Log Message:
BUG: Pop a function scope even on error

This uses an automatic variable to push and pop variable scope inside a
function call.  Previously if the function failed its scope would not be
popped.  This approach guarantees a balanced push/pop.


Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.239
retrieving revision 1.240
diff -C 2 -d -r1.239 -r1.240
*** cmMakefile.h	5 Jan 2009 20:00:57 -0000	1.239
--- cmMakefile.h	14 Jan 2009 20:14:06 -0000	1.240
***************
*** 781,784 ****
--- 781,794 ----
    void RaiseScope(const char *var, const char *value);
  
+   /** Helper class to push and pop scopes automatically.  */
+   class ScopePushPop
+   {
+   public:
+     ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
+     ~ScopePushPop() { this->Makefile->PopScope(); }
+   private:
+     cmMakefile* Makefile;
+   };
+ 
    void IssueMessage(cmake::MessageType t,
                      std::string const& text) const;

Index: cmFunctionCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionCommand.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** cmFunctionCommand.cxx	7 Mar 2008 13:40:36 -0000	1.6
--- cmFunctionCommand.cxx	14 Jan 2009 20:14:06 -0000	1.7
***************
*** 105,109 ****
  
    // we push a scope on the makefile
!   this->Makefile->PushScope();
  
    // set the value of argc
--- 105,110 ----
  
    // we push a scope on the makefile
!   cmMakefile::ScopePushPop varScope(this->Makefile);
!   static_cast<void>(varScope);
  
    // set the value of argc
***************
*** 168,172 ****
      if (status.GetReturnInvoked())
        {
-       this->Makefile->PopScope();
        return true;
        }
--- 169,172 ----
***************
*** 174,178 ****
  
    // pop scope on the makefile
-   this->Makefile->PopScope();
    return true;
  }
--- 174,177 ----



More information about the Cmake-commits mailing list