From 5d48c2d3e9b999c645ec0a8aa8042fc246c5bc14 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Mon, 1 Jun 2015 18:52:14 +0000 Subject: [PATCH] #5851: Don't use _configthreadlocale if not provided by CRT (even if declaration is present) --- CMakeLists.txt | 1 + cmake/TrMacros.cmake | 2 +- configure.ac | 2 +- libtransmission/variant.c | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba3e5fca4..74c78844a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,6 +397,7 @@ foreach(H ${NEEDED_HEADERS}) endforeach() set(NEEDED_FUNCTIONS + _configthreadlocale canonicalize_file_name daemon fallocate64 diff --git a/cmake/TrMacros.cmake b/cmake/TrMacros.cmake index 51eb11c15..634dfcf17 100644 --- a/cmake/TrMacros.cmake +++ b/cmake/TrMacros.cmake @@ -65,7 +65,7 @@ endmacro() function(tr_make_id INPUT OVAR) string(TOUPPER "${INPUT}" ID) string(REGEX REPLACE "[^A-Z0-9]+" "_" ID "${ID}") - string(REGEX REPLACE "^_+|_+$" "" ID "${ID}") + # string(REGEX REPLACE "^_+|_+$" "" ID "${ID}") set(${OVAR} "${ID}" PARENT_SCOPE) endfunction() diff --git a/configure.ac b/configure.ac index 55022806c..9866000b7 100644 --- a/configure.ac +++ b/configure.ac @@ -107,7 +107,7 @@ AC_HEADER_STDC AC_HEADER_TIME AC_CHECK_HEADERS([stdbool.h xlocale.h]) -AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename canonicalize_file_name strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll mkdtemp uselocale]) +AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename canonicalize_file_name strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll mkdtemp uselocale _configthreadlocale]) AC_PROG_INSTALL AC_PROG_MAKE_SET ACX_PTHREAD diff --git a/libtransmission/variant.c b/libtransmission/variant.c index c172f263e..8837b3eff 100644 --- a/libtransmission/variant.c +++ b/libtransmission/variant.c @@ -53,11 +53,11 @@ struct locale_context locale_t new_locale; locale_t old_locale; #else -#ifdef _WIN32 - int old_thread_config; +#if defined (HAVE__CONFIGTHREADLOCALE) && defined (_ENABLE_PER_THREAD_LOCALE) + int old_thread_config; #endif - int category; - char old_locale[128]; + int category; + char old_locale[128]; #endif }; @@ -72,7 +72,7 @@ use_numeric_locale (struct locale_context * context, #else -#ifdef _WIN32 +#if defined (HAVE__CONFIGTHREADLOCALE) && defined (_ENABLE_PER_THREAD_LOCALE) context->old_thread_config = _configthreadlocale (_ENABLE_PER_THREAD_LOCALE); #endif @@ -95,7 +95,7 @@ restore_locale (struct locale_context * context) setlocale (context->category, context->old_locale); -#ifdef _WIN32 +#if defined (HAVE__CONFIGTHREADLOCALE) && defined (_ENABLE_PER_THREAD_LOCALE) _configthreadlocale (context->old_thread_config); #endif