mirror of https://github.com/mgba-emu/mgba.git
Util: Fix Win32 build
This commit is contained in:
parent
4b14b71861
commit
f2c29bc8d6
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
#define UNUSED(V) (void)(V)
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue