diff options
author | Brad King <brad.king@kitware.com> | 2015-02-06 18:38:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-02-06 18:38:41 (GMT) |
commit | 8772420e2ff1da38903162ce8e9335edbe1c3dcd (patch) | |
tree | fce0ab4193a73e3bb807a36fc3511f2da3b1442a /Source | |
parent | cb01f1517051b577d571e8fd21d210ef303f56c9 (diff) | |
parent | 0f870234febd9dba0df78e903b412ea19d681062 (diff) | |
download | CMake-8772420e2ff1da38903162ce8e9335edbe1c3dcd.zip CMake-8772420e2ff1da38903162ce8e9335edbe1c3dcd.tar.gz CMake-8772420e2ff1da38903162ce8e9335edbe1c3dcd.tar.bz2 |
Merge branch 'no-global-setlocale' into release
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 2 | ||||
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 3 | ||||
-rw-r--r-- | Source/cmArchiveWrite.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocale.h | 31 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 3 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 2 | ||||
-rw-r--r-- | Source/ctest.cxx | 3 |
8 files changed, 39 insertions, 10 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 07839f3..8a83c3e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -277,6 +277,7 @@ set(SRCS cmLocalGenerator.cxx cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx + cmLocale.h ${MACH_SRCS} cmMakeDepend.cxx cmMakeDepend.h diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 00bfe5b..6106472 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -26,7 +26,6 @@ #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> #include <cmsys/Encoding.hxx> -#include <locale.h> //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -101,7 +100,6 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, // this is CPack. int main (int argc, char const* const* argv) { - setlocale(LC_CTYPE, ""); cmsys::Encoding::CommandLineArguments args = cmsys::Encoding::CommandLineArguments::Main(argc, argv); argc = args.argc(); diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 28f3d9b..3d92a2d 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -16,7 +16,6 @@ #include <signal.h> #include <sys/ioctl.h> -#include <locale.h> #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" @@ -95,8 +94,6 @@ void CMakeMessageHandler(const char* message, const char* title, bool&, int main(int argc, char const* const* argv) { - setlocale(LC_CTYPE, ""); - cmsys::Encoding::CommandLineArguments encoding_args = cmsys::Encoding::CommandLineArguments::Main(argc, argv); argc = encoding_args.argc(); diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index c24c68e..cf2fe82 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -12,6 +12,7 @@ #include "cmArchiveWrite.h" #include "cmSystemTools.h" +#include "cmLocale.h" #include <cmsys/ios/iostream> #include <cmsys/Directory.hxx> #include <cmsys/FStream.hxx> @@ -260,6 +261,9 @@ bool cmArchiveWrite::AddFile(const char* file, } const char* out = file + skip; + cmLocaleRAII localeRAII; + static_cast<void>(localeRAII); + // Meta-data. std::string dest = prefix? prefix : ""; dest += out; diff --git a/Source/cmLocale.h b/Source/cmLocale.h new file mode 100644 index 0000000..727f0f5 --- /dev/null +++ b/Source/cmLocale.h @@ -0,0 +1,31 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-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 cmLocale_h +#define cmLocale_h + +#include <locale.h> + +class cmLocaleRAII +{ + const char* OldLocale; +public: + cmLocaleRAII(): OldLocale(setlocale(LC_CTYPE, 0)) + { + setlocale(LC_CTYPE, ""); + } + ~cmLocaleRAII() + { + setlocale(LC_CTYPE, this->OldLocale); + } +}; + +#endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e9735ed..6a7467f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -26,6 +26,7 @@ #include <cmsys/Encoding.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmArchiveWrite.h" +# include "cmLocale.h" # include <cm_libarchive.h> # include <cmsys/Terminal.h> #endif @@ -1690,6 +1691,8 @@ long copy_data(struct archive *ar, struct archive *aw) bool extract_tar(const char* outFileName, bool verbose, bool extract) { + cmLocaleRAII localeRAII; + static_cast<void>(localeRAII); struct archive* a = archive_read_new(); struct archive *ext = archive_write_disk_new(); archive_read_support_compression_all(a); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 6d25b70..e0bd55b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -25,7 +25,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include <cmsys/Encoding.hxx> -#include <locale.h> #ifdef CMAKE_BUILD_WITH_CMAKE //---------------------------------------------------------------------------- @@ -173,7 +172,6 @@ static void cmakemainProgressCallback(const char *m, float prog, int main(int ac, char const* const* av) { - setlocale(LC_CTYPE, ""); cmsys::Encoding::CommandLineArguments args = cmsys::Encoding::CommandLineArguments::Main(ac, av); ac = args.argc(); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index b77c231..c0eb8ac 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -19,7 +19,6 @@ #include "CTest/cmCTestScriptHandler.h" #include "CTest/cmCTestLaunch.h" #include "cmsys/Encoding.hxx" -#include <locale.h> //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -117,8 +116,6 @@ static const char * cmDocumentationOptions[][2] = // this is a test driver program for cmCTest. int main (int argc, char const* const* argv) { - setlocale(LC_CTYPE, ""); - cmsys::Encoding::CommandLineArguments encoding_args = cmsys::Encoding::CommandLineArguments::Main(argc, argv); argc = encoding_args.argc(); |