[Cmake-commits] [cmake-commits] king committed cmCTestUpdateHandler.cxx 1.48 1.49

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jan 6 14:58:34 EST 2009


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

Modified Files:
	cmCTestUpdateHandler.cxx 
Log Message:
BUG: Manage LC_MESSAGES with an object

This moves management of the LC_MESSAGES environment variable into an
automatic variable.  Previously if an error occurred the original
environment value was not restored.  This makes the fix to issue #5936
more robust.


Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.48
retrieving revision 1.49
diff -C 2 -d -r1.48 -r1.49
*** cmCTestUpdateHandler.cxx	6 Jan 2009 19:41:56 -0000	1.48
--- cmCTestUpdateHandler.cxx	6 Jan 2009 19:58:30 -0000	1.49
***************
*** 181,184 ****
--- 181,224 ----
  //----------------------------------------------------------------------
  
+ class cmCTestUpdateHandlerLocale
+ {
+ public:
+   cmCTestUpdateHandlerLocale();
+   ~cmCTestUpdateHandlerLocale();
+ private:
+   std::string saveLCMessages;
+ };
+ 
+ cmCTestUpdateHandlerLocale::cmCTestUpdateHandlerLocale()
+ {
+   const char* lcmess = cmSystemTools::GetEnv("LC_MESSAGES");
+   if(lcmess)
+     {
+     saveLCMessages = lcmess;
+     }
+   // if LC_MESSAGES is not set to C, then
+   // set it, so that svn/cvs info will be in english ascii
+   if(! (lcmess && strcmp(lcmess, "C") == 0))
+     {
+     cmSystemTools::PutEnv("LC_MESSAGES=C");
+     }
+ }
+ 
+ cmCTestUpdateHandlerLocale::~cmCTestUpdateHandlerLocale()
+ {
+   // restore the value of LC_MESSAGES after running the version control
+   // commands
+   if(saveLCMessages.size())
+     {
+     std::string put = "LC_MESSAGES=";
+     put += saveLCMessages;
+     cmSystemTools::PutEnv(put.c_str());
+     }
+   else
+     {
+     cmSystemTools::UnsetEnv("LC_MESSAGES");
+     }
+ }
+ 
  //----------------------------------------------------------------------
  cmCTestUpdateHandler::cmCTestUpdateHandler()
***************
*** 253,269 ****
    std::string errors;
  
!   // make sure
!   std::string saveLCMessages;
!   const char* lcmess = cmSystemTools::GetEnv("LC_MESSAGES");
!   if(lcmess)
!     {
!     saveLCMessages = lcmess;
!     }
!   // if LC_MESSAGES is not set to C, then
!   // set it, so that svn/cvs info will be in english ascii
!   if(! (lcmess && strcmp(lcmess, "C") == 0))
!     {
!     cmSystemTools::PutEnv("LC_MESSAGES=C");
!     }
    std::string checkoutErrorMessages;
    int retVal = 0;
--- 293,300 ----
    std::string errors;
  
!   // Make sure VCS tool messages are in English so we can parse them.
!   cmCTestUpdateHandlerLocale fixLocale;
!   static_cast<void>(fixLocale);
! 
    std::string checkoutErrorMessages;
    int retVal = 0;
***************
*** 1123,1138 ****
    os << "</UpdateReturnStatus>" << std::endl;
    os << "</Update>" << std::endl;
-   // restore the value of LC_MESSAGES after running the version control
-   // commands
-   if(saveLCMessages.size())
-     {
-     std::string put = "LC_MESSAGES=";
-     put += saveLCMessages;
-     cmSystemTools::PutEnv(put.c_str());
-     }
-   else
-     {
-     cmSystemTools::UnsetEnv("LC_MESSAGES");
-     }
    if (! res  )
      {
--- 1154,1157 ----



More information about the Cmake-commits mailing list