all repos — mgba @ d9778a98d484bd06875045ecb3ff953d1d466d78

mGBA Game Boy Advance Emulator

Util: Check for SETLOCALE too
Jeffrey Pfau jeffrey@endrift.com
Sun, 05 Jul 2015 13:05:09 -0700
commit

d9778a98d484bd06875045ecb3ff953d1d466d78

parent

32cb7bfcdca87d8dc95660ce53855356130a11d7

2 files changed, 12 insertions(+), 2 deletions(-)

jump to
M CMakeLists.txtCMakeLists.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.csrc/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