diff --git a/src/gba/supervisor/config.c b/src/gba/supervisor/config.c index 55770f954..c45c004c6 100644 --- a/src/gba/supervisor/config.c +++ b/src/gba/supervisor/config.c @@ -85,9 +85,15 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f 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; } diff --git a/src/util/common.h b/src/util/common.h index 29d031180..1dd43ef3f 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -20,7 +20,10 @@ #include #include #include + +#ifndef _WIN32 #include +#endif #define UNUSED(V) (void)(V) diff --git a/src/util/configuration.c b/src/util/configuration.c index 63f8cef75..86226b61c 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -79,9 +79,15 @@ void ConfigurationSetUIntValue(struct Configuration* configuration, const char* 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); }