diff --git a/CHANGES b/CHANGES index 8d03c4631..9f225d177 100644 --- a/CHANGES +++ b/CHANGES @@ -51,6 +51,7 @@ Misc: - GBA: Refactor gba-sensors and gba-gpio into gba-hardware - GBA: Refactor gba directory, dropping gba- prefix and making supervisor directory - Debugger: Add support for soft breakpoints + - Util: Use proper locale for reading and writing float values 0.1.1: (2015-01-24) Bugfixes: diff --git a/src/gba/supervisor/config.c b/src/gba/supervisor/config.c index 3b385e371..55770f954 100644 --- a/src/gba/supervisor/config.c +++ b/src/gba/supervisor/config.c @@ -85,7 +85,9 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f return false; } char* end; - float value = strtof(charValue, &end); + locale_t l = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); + float value = strtof_l(charValue, &end, l); + freelocale(l); if (*end) { return false; } diff --git a/src/util/common.h b/src/util/common.h index 42f62c05f..29d031180 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #define UNUSED(V) (void)(V) diff --git a/src/util/configuration.c b/src/util/configuration.c index cc94789f9..63f8cef75 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -78,8 +78,10 @@ void ConfigurationSetUIntValue(struct Configuration* configuration, const char* } void ConfigurationSetFloatValue(struct Configuration* configuration, const char* section, const char* key, float value) { - char charValue[FLT_DIG + 7]; - sprintf(charValue, "%.*g", FLT_DIG, value); + char charValue[16]; + locale_t l = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); + snprintf_l(charValue, sizeof(charValue), l, "%.*g", FLT_DIG, value); + freelocale(l); ConfigurationSetValue(configuration, section, key, charValue); }