Util: Check for SETLOCALE too
Jeffrey Pfau jeffrey@endrift.com
Sun, 05 Jul 2015 13:05:09 -0700
2 files changed,
12 insertions(+),
2 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -228,6 +228,7 @@ endif()
check_function_exists(newlocale HAVE_NEWLOCALE) check_function_exists(freelocale HAVE_FREELOCALE) check_function_exists(uselocale HAVE_USELOCALE) +check_function_exists(setlocale HAVE_SETLOCALE) if(HAVE_STRDUP) add_definitions(-DHAVE_STRDUP)@@ -247,6 +248,9 @@ add_definitions(-DHAVE_SNPRINTF_L)
endif() endif() +if(HAVE_SETLOCALE) + add_definitions(-DHAVE_SETLOCALE) +endif() # Features set(DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/debugger.c ${CMAKE_SOURCE_DIR}/src/debugger/memory-debugger.c)
M
src/util/formatting.c
→
src/util/formatting.c
@@ -15,11 +15,14 @@ locale_t old = uselocale(locale);
int res = snprintf(str, size, "%*.g", FLT_DIG, f); uselocale(old); return res; -#else +#elif defined(HAVE_SETLOCALE) char* old = setlocale(LC_NUMERIC, locale); int res = snprintf(str, size, "%*.g", FLT_DIG, f); setlocale(LC_NUMERIC, old); return res; +#else + UNUSED(locale); + return snprintf(str, size, "%*.g", FLT_DIG, f); #endif }@@ -30,11 +33,14 @@ locale_t old = uselocale(locale);
float res = strtof(str, end); uselocale(old); return res; -#else +#elif defined(HAVE_SETLOCALE) char* old = setlocale(LC_NUMERIC, locale); float res = strtof(str, end); setlocale(LC_NUMERIC, old); return res; +#else + UNUSED(locale); + return strtof(str, end); #endif } #endif