summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-02-06 18:23:07 (GMT)
committerBrad King <brad.king@kitware.com>2015-02-06 18:32:57 (GMT)
commitcd408d93fdf347ff63a8062f75f1f4ee3e898b17 (patch)
tree8fe5fcf05cd8092ccb1b80b0879c3928bec2af82 /Source/cmSystemTools.cxx
parent87be2e1427ba2b1b7697c9332487862917897dca (diff)
downloadCMake-cd408d93fdf347ff63a8062f75f1f4ee3e898b17.zip
CMake-cd408d93fdf347ff63a8062f75f1f4ee3e898b17.tar.gz
CMake-cd408d93fdf347ff63a8062f75f1f4ee3e898b17.tar.bz2
Add setlocale() calls around use of libarchive APIs (#14934, #15377)
The libarchive APIs use nl_langinfo(CODESET) for iconv so they need the locale to be set for LC_CTYPE. However, the rest of CMake does not define any behavior for non-ASCII character classification/conversion so we do not want to setlocale() globally. Add a RAII class to save, set, and restore the locale around calls to libarchive APIs. Inspired-by: Clinton Stimpson <clinton@elemtech.com>
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index fbb4416..89efdc7 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -28,6 +28,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
@@ -1691,6 +1692,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);