Util: Fix Win32 build
Jeffrey Pfau jeffrey@endrift.com
Tue, 10 Feb 2015 02:46:12 -0800
3 files changed,
15 insertions(+),
0 deletions(-)
M
src/gba/supervisor/config.c
→
src/gba/supervisor/config.c
@@ -85,9 +85,15 @@ if (!charValue) {
return false; } char* end; +#ifndef _WIN32 locale_t l = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); float value = strtof_l(charValue, &end, l); freelocale(l); +#else + const char* oldlocale = setlocale(LC_NUMERIC, "C"); + float value = strtof(charValue, &end); + setlocale(LC_NUMERIC, oldlocale); +#endif if (*end) { return false; }
M
src/util/common.h
→
src/util/common.h
@@ -20,7 +20,10 @@ #include <stdio.h>
#include <stdlib.h> #include <string.h> #include <unistd.h> + +#ifndef _WIN32 #include <xlocale.h> +#endif #define UNUSED(V) (void)(V)
M
src/util/configuration.c
→
src/util/configuration.c
@@ -79,9 +79,15 @@ }
void ConfigurationSetFloatValue(struct Configuration* configuration, const char* section, const char* key, float value) { char charValue[16]; +#ifndef _WIN32 locale_t l = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); snprintf_l(charValue, sizeof(charValue), l, "%.*g", FLT_DIG, value); freelocale(l); +#else + const char* oldlocale = setlocale(LC_NUMERIC, "C"); + snprintf(charValue, sizeof(charValue), "%.*g", FLT_DIG, value); + setlocale(LC_NUMERIC, oldlocale); +#endif ConfigurationSetValue(configuration, section, key, charValue); }