Merge topic 'no-global-setlocale'
0f870234
Merge branch 'backport-no-global-setlocale' into no-global-setlocalecd408d93
Add setlocale() calls around use of libarchive APIs (#14934, #15377)87be2e14
Do not call setlocale() globally in CMake applications (#15377)
This commit is contained in:
commit
db9a2e8966
|
@ -277,6 +277,7 @@ set(SRCS
|
||||||
cmLocalGenerator.cxx
|
cmLocalGenerator.cxx
|
||||||
cmLocalGenerator.h
|
cmLocalGenerator.h
|
||||||
cmLocalUnixMakefileGenerator3.cxx
|
cmLocalUnixMakefileGenerator3.cxx
|
||||||
|
cmLocale.h
|
||||||
${MACH_SRCS}
|
${MACH_SRCS}
|
||||||
cmMakeDepend.cxx
|
cmMakeDepend.cxx
|
||||||
cmMakeDepend.h
|
cmMakeDepend.h
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <cmsys/CommandLineArguments.hxx>
|
#include <cmsys/CommandLineArguments.hxx>
|
||||||
#include <cmsys/SystemTools.hxx>
|
#include <cmsys/SystemTools.hxx>
|
||||||
#include <cmsys/Encoding.hxx>
|
#include <cmsys/Encoding.hxx>
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static const char * cmDocumentationName[][2] =
|
static const char * cmDocumentationName[][2] =
|
||||||
|
@ -101,7 +100,6 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
|
||||||
// this is CPack.
|
// this is CPack.
|
||||||
int main (int argc, char const* const* argv)
|
int main (int argc, char const* const* argv)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
cmsys::Encoding::CommandLineArguments args =
|
cmsys::Encoding::CommandLineArguments args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||||
argc = args.argc();
|
argc = args.argc();
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#include "cmCursesMainForm.h"
|
#include "cmCursesMainForm.h"
|
||||||
#include "cmCursesStandardIncludes.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)
|
int main(int argc, char const* const* argv)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
|
|
||||||
cmsys::Encoding::CommandLineArguments encoding_args =
|
cmsys::Encoding::CommandLineArguments encoding_args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||||
argc = encoding_args.argc();
|
argc = encoding_args.argc();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "cmArchiveWrite.h"
|
#include "cmArchiveWrite.h"
|
||||||
|
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
#include "cmLocale.h"
|
||||||
#include <cmsys/ios/iostream>
|
#include <cmsys/ios/iostream>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include <cmsys/FStream.hxx>
|
#include <cmsys/FStream.hxx>
|
||||||
|
@ -260,6 +261,9 @@ bool cmArchiveWrite::AddFile(const char* file,
|
||||||
}
|
}
|
||||||
const char* out = file + skip;
|
const char* out = file + skip;
|
||||||
|
|
||||||
|
cmLocaleRAII localeRAII;
|
||||||
|
static_cast<void>(localeRAII);
|
||||||
|
|
||||||
// Meta-data.
|
// Meta-data.
|
||||||
std::string dest = prefix? prefix : "";
|
std::string dest = prefix? prefix : "";
|
||||||
dest += out;
|
dest += out;
|
||||||
|
|
|
@ -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
|
|
@ -26,6 +26,7 @@
|
||||||
#include <cmsys/Encoding.hxx>
|
#include <cmsys/Encoding.hxx>
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
# include "cmArchiveWrite.h"
|
# include "cmArchiveWrite.h"
|
||||||
|
# include "cmLocale.h"
|
||||||
# include <cm_libarchive.h>
|
# include <cm_libarchive.h>
|
||||||
# include <cmsys/Terminal.h>
|
# include <cmsys/Terminal.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1690,6 +1691,8 @@ long copy_data(struct archive *ar, struct archive *aw)
|
||||||
bool extract_tar(const char* outFileName, bool verbose,
|
bool extract_tar(const char* outFileName, bool verbose,
|
||||||
bool extract)
|
bool extract)
|
||||||
{
|
{
|
||||||
|
cmLocaleRAII localeRAII;
|
||||||
|
static_cast<void>(localeRAII);
|
||||||
struct archive* a = archive_read_new();
|
struct archive* a = archive_read_new();
|
||||||
struct archive *ext = archive_write_disk_new();
|
struct archive *ext = archive_write_disk_new();
|
||||||
archive_read_support_compression_all(a);
|
archive_read_support_compression_all(a);
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include <cmsys/Encoding.hxx>
|
#include <cmsys/Encoding.hxx>
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#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)
|
int main(int ac, char const* const* av)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
cmsys::Encoding::CommandLineArguments args =
|
cmsys::Encoding::CommandLineArguments args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
||||||
ac = args.argc();
|
ac = args.argc();
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "CTest/cmCTestScriptHandler.h"
|
#include "CTest/cmCTestScriptHandler.h"
|
||||||
#include "CTest/cmCTestLaunch.h"
|
#include "CTest/cmCTestLaunch.h"
|
||||||
#include "cmsys/Encoding.hxx"
|
#include "cmsys/Encoding.hxx"
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static const char * cmDocumentationName[][2] =
|
static const char * cmDocumentationName[][2] =
|
||||||
|
@ -117,8 +116,6 @@ static const char * cmDocumentationOptions[][2] =
|
||||||
// this is a test driver program for cmCTest.
|
// this is a test driver program for cmCTest.
|
||||||
int main (int argc, char const* const* argv)
|
int main (int argc, char const* const* argv)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
|
|
||||||
cmsys::Encoding::CommandLineArguments encoding_args =
|
cmsys::Encoding::CommandLineArguments encoding_args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||||
argc = encoding_args.argc();
|
argc = encoding_args.argc();
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#include <cmSystemTools.h>
|
#include <cmSystemTools.h>
|
||||||
#include <cmsys/Encoding.hxx>
|
#include <cmsys/Encoding.hxx>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#define RETVAL @_retval@
|
#define RETVAL @_retval@
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int ac, char **av)
|
main(int ac, char **av)
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
cmsys::Encoding::CommandLineArguments args =
|
cmsys::Encoding::CommandLineArguments args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
||||||
int argc = args.argc();
|
int argc = args.argc();
|
||||||
|
|
Loading…
Reference in New Issue