all repos — mgba @ f2c29bc8d6d936547cbe1e8382ef8fd6f7ac77a1

mGBA Game Boy Advance Emulator

Util: Fix Win32 build
Jeffrey Pfau jeffrey@endrift.com
Tue, 10 Feb 2015 02:46:12 -0800
commit

f2c29bc8d6d936547cbe1e8382ef8fd6f7ac77a1

parent

4b14b71861b40026987d3b11024591bece1435eb

3 files changed, 15 insertions(+), 0 deletions(-)

jump to
M src/gba/supervisor/config.csrc/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.hsrc/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.csrc/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); }