[Cmake-commits] CMake branch, next, updated. v3.2.1-1694-g607638a

Nils Gladitz nilsgladitz at gmail.com
Thu Apr 9 14:59:02 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  607638aacbc1f21c09df0d8a378217f45301984a (commit)
       via  90cc26d5f021f1e57b4025e62ba249448c5eb8ef (commit)
      from  b97afb70bf378e783817763d9e1d0c7ed064f250 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=607638aacbc1f21c09df0d8a378217f45301984a
commit 607638aacbc1f21c09df0d8a378217f45301984a
Merge: b97afb7 90cc26d
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Apr 9 14:59:00 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Apr 9 14:59:00 2015 -0400

    Merge topic 'c-locale-messages' into next
    
    90cc26d5 CTest: Fix locale used for VCS updates


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=90cc26d5f021f1e57b4025e62ba249448c5eb8ef
commit 90cc26d5f021f1e57b4025e62ba249448c5eb8ef
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Apr 9 20:56:43 2015 +0200
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Thu Apr 9 20:56:43 2015 +0200

    CTest: Fix locale used for VCS updates
    
    6a661f06030b85b4484733375bbb0aa23eca7446 fixed the
    locale used for message output but at the same time broke the locale
    used for filename encodings.
    
    This commit preserves LC_CTYPE in the presence of LC_ALL.

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 04f6a81..7af6da3 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -159,6 +159,8 @@ set(SRCS
   cmCacheManager.cxx
   cmCacheManager.h
   "${CMAKE_CURRENT_BINARY_DIR}/cmCommands.cxx"
+  cmCLocaleEnvironmentScope.h
+  cmCLocaleEnvironmentScope.cxx
   cmCommands.h
   cmCommandArgumentLexer.cxx
   cmCommandArgumentParser.cxx
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index b9da8a0..10927e7 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -21,6 +21,7 @@
 #include "cmGeneratedFileStream.h"
 #include "cmXMLParser.h"
 #include "cmXMLSafe.h"
+#include "cmCLocaleEnvironmentScope.h"
 
 #include "cmCTestVC.h"
 #include "cmCTestCVS.h"
@@ -66,46 +67,6 @@ static const char* cmCTestUpdateHandlerUpdateToString(int type)
   return cmCTestUpdateHandlerUpdateStrings[type];
 }
 
-class cmCTestUpdateHandlerLocale
-{
-public:
-  cmCTestUpdateHandlerLocale();
-  ~cmCTestUpdateHandlerLocale();
-private:
-  std::string saveLCAll;
-};
-
-cmCTestUpdateHandlerLocale::cmCTestUpdateHandlerLocale()
-{
-  const char* lcall = cmSystemTools::GetEnv("LC_ALL");
-  if(lcall)
-    {
-    saveLCAll = lcall;
-    }
-  // if LC_ALL is not set to C, then
-  // set it, so that svn/cvs info will be in english ascii
-  if(! (lcall && strcmp(lcall, "C") == 0))
-    {
-    cmSystemTools::PutEnv("LC_ALL=C");
-    }
-}
-
-cmCTestUpdateHandlerLocale::~cmCTestUpdateHandlerLocale()
-{
-  // restore the value of LC_ALL after running the version control
-  // commands
-  if(!saveLCAll.empty())
-    {
-    std::string put = "LC_ALL=";
-    put += saveLCAll;
-    cmSystemTools::PutEnv(put);
-    }
-  else
-    {
-    cmSystemTools::UnsetEnv("LC_ALL");
-    }
-}
-
 //----------------------------------------------------------------------
 cmCTestUpdateHandler::cmCTestUpdateHandler()
 {
@@ -194,7 +155,7 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
 int cmCTestUpdateHandler::ProcessHandler()
 {
   // Make sure VCS tool messages are in English so we can parse them.
-  cmCTestUpdateHandlerLocale fixLocale;
+  cmCLocaleEnvironmentScope fixLocale;
   static_cast<void>(fixLocale);
 
   // Get source dir
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
new file mode 100644
index 0000000..5792302
--- /dev/null
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -0,0 +1,67 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2015 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmCLocaleEnvironmentScope.h"
+
+#include "cmSystemTools.h"
+
+#include <sstream>
+
+cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
+{
+  this->SetEnv("LANGUAGE", "");
+  this->SetEnv("LC_MESSAGES", "C");
+
+  std::string lcAll = this->GetEnv("LC_ALL");
+
+  if(!lcAll.empty())
+    {
+    this->SetEnv("LC_ALL", "");
+    this->SetEnv("LC_CTYPE", lcAll);
+    }
+}
+
+std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
+{
+  const char* value = cmSystemTools::GetEnv(key);
+  return value ? value : std::string();
+}
+
+void cmCLocaleEnvironmentScope::SetEnv(
+  std::string const& key, std::string const& value)
+{
+  std::string oldValue = this->GetEnv(key);
+
+  this->EnvironmentBackup.insert(std::make_pair(key, oldValue));
+
+  if(value.empty())
+    {
+    cmSystemTools::UnsetEnv(key.c_str());
+    }
+  else
+    {
+    std::stringstream tmp;
+    tmp << key << "=" << value;
+    cmSystemTools::PutEnv(tmp.str());
+    }
+}
+
+cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
+{
+  for(backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
+    i != this->EnvironmentBackup.end(); ++i)
+    {
+    std::stringstream tmp;
+    tmp << i->first << "=" << i->second;
+    cmSystemTools::PutEnv(tmp.str());
+    }
+}
diff --git a/Source/cmCLocaleEnvironmentScope.h b/Source/cmCLocaleEnvironmentScope.h
new file mode 100644
index 0000000..223aaae
--- /dev/null
+++ b/Source/cmCLocaleEnvironmentScope.h
@@ -0,0 +1,33 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2015 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmCLocaleEnvironmentScope_h
+#define cmCLocaleEnvironmentScope_h
+
+#include <map>
+#include <string>
+
+class cmCLocaleEnvironmentScope
+{
+public:
+  cmCLocaleEnvironmentScope();
+  ~cmCLocaleEnvironmentScope();
+
+private:
+  std::string GetEnv(std::string const& key);
+  void SetEnv(std::string const& key, std::string const& value);
+
+  typedef std::map<std::string, std::string> backup_map_t;
+  backup_map_t EnvironmentBackup;
+};
+
+#endif

-----------------------------------------------------------------------

Summary of changes:
 Source/CMakeLists.txt                              |    2 +
 Source/CTest/cmCTestUpdateHandler.cxx              |   43 +------------
 Source/cmCLocaleEnvironmentScope.cxx               |   67 ++++++++++++++++++++
 Source/{cmLocale.h => cmCLocaleEnvironmentScope.h} |   30 +++++----
 4 files changed, 87 insertions(+), 55 deletions(-)
 create mode 100644 Source/cmCLocaleEnvironmentScope.cxx
 copy Source/{cmLocale.h => cmCLocaleEnvironmentScope.h} (52%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list