[Cmake-commits] [cmake-commits] hoffman committed SystemTools.hxx.in 1.77 1.78 SystemTools.cxx 1.241 1.242

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Jun 5 12:01:32 EDT 2009


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

Modified Files:
	SystemTools.hxx.in SystemTools.cxx 
Log Message:
ENH: move PutEnv to SystemTools 


Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.241
retrieving revision 1.242
diff -C 2 -d -r1.241 -r1.242
*** SystemTools.cxx	13 May 2009 14:30:33 -0000	1.241
--- SystemTools.cxx	5 Jun 2009 16:01:30 -0000	1.242
***************
*** 403,406 ****
--- 403,433 ----
  }
  
+ class kwsysDeletingCharVector : public kwsys_stl::vector<char*>
+ {
+ public:
+   ~kwsysDeletingCharVector()
+     {
+       for(kwsys_stl::vector<char*>::iterator i = this->begin();
+           i != this->end(); ++i)
+         {
+         delete []*i;
+         }
+     }
+ };
+ 
+         
+ bool SystemTools::PutEnv(const char* value)
+ { 
+   static kwsysDeletingCharVector localEnvironment;
+   char* envVar = new char[strlen(value)+1];
+   strcpy(envVar, value);
+   int ret = putenv(envVar);
+   // save the pointer in the static vector so that it can
+   // be deleted on exit
+   localEnvironment.push_back(envVar);
+   return ret == 0;
+ }
+ 
+ 
  const char* SystemTools::GetExecutableExtension()
  {

Index: SystemTools.hxx.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.hxx.in,v
retrieving revision 1.77
retrieving revision 1.78
diff -C 2 -d -r1.77 -r1.78
*** SystemTools.hxx.in	21 Apr 2009 15:36:59 -0000	1.77
--- SystemTools.hxx.in	5 Jun 2009 16:01:29 -0000	1.78
***************
*** 755,758 ****
--- 755,762 ----
    static bool GetEnv(const char* key, kwsys_stl::string& result);
  
+   /** Put a string into the environment
+       of the form var=value */
+   static bool PutEnv(const char* value);
+ 
    /**
     * Get current working directory CWD



More information about the Cmake-commits mailing list