mirror of https://github.com/mgba-emu/mgba.git
Util: Use proper locale for reading and writing float values
This commit is contained in:
parent
9c3e16925b
commit
4b14b71861
1
CHANGES
1
CHANGES
|
@ -51,6 +51,7 @@ Misc:
|
||||||
- GBA: Refactor gba-sensors and gba-gpio into gba-hardware
|
- GBA: Refactor gba-sensors and gba-gpio into gba-hardware
|
||||||
- GBA: Refactor gba directory, dropping gba- prefix and making supervisor directory
|
- GBA: Refactor gba directory, dropping gba- prefix and making supervisor directory
|
||||||
- Debugger: Add support for soft breakpoints
|
- Debugger: Add support for soft breakpoints
|
||||||
|
- Util: Use proper locale for reading and writing float values
|
||||||
|
|
||||||
0.1.1: (2015-01-24)
|
0.1.1: (2015-01-24)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -85,7 +85,9 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char* end;
|
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) {
|
if (*end) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <locale.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <xlocale.h>
|
||||||
|
|
||||||
#define UNUSED(V) (void)(V)
|
#define UNUSED(V) (void)(V)
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,10 @@ void ConfigurationSetUIntValue(struct Configuration* configuration, const char*
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationSetFloatValue(struct Configuration* configuration, const char* section, const char* key, float value) {
|
void ConfigurationSetFloatValue(struct Configuration* configuration, const char* section, const char* key, float value) {
|
||||||
char charValue[FLT_DIG + 7];
|
char charValue[16];
|
||||||
sprintf(charValue, "%.*g", FLT_DIG, value);
|
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);
|
ConfigurationSetValue(configuration, section, key, charValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue