all repos — mgba @ e528f673b8c478a77b0e100590961edfe957259d

mGBA Game Boy Advance Emulator

Util: Fix formatting of floats
Jeffrey Pfau jeffrey@endrift.com
Sat, 15 Aug 2015 14:48:01 -0700
commit

e528f673b8c478a77b0e100590961edfe957259d

parent

0eb76806beb6af13d8aacf535795fc0f84b65233

2 files changed, 5 insertions(+), 4 deletions(-)

jump to
M CHANGESCHANGES

@@ -72,6 +72,7 @@ - Qt: Fix passing command line options

- Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls - GBA Video: Fix timing on first scanline - GBA: Ensure cycles never go negative + - Util: Fix formatting of floats Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/util/formatting.csrc/util/formatting.c

@@ -9,20 +9,20 @@ #include <float.h>

int ftostr_l(char* restrict str, size_t size, float f, locale_t locale) { #ifdef HAVE_SNPRINTF_L - return snprintf_l(str, size, locale, "%*.g", FLT_DIG, f); + return snprintf_l(str, size, locale, "%.*g", FLT_DIG, f); #elif defined(HAVE_LOCALE) locale_t old = uselocale(locale); - int res = snprintf(str, size, "%*.g", FLT_DIG, f); + int res = snprintf(str, size, "%.*g", FLT_DIG, f); uselocale(old); return res; #elif defined(HAVE_SETLOCALE) char* old = setlocale(LC_NUMERIC, locale); - int res = snprintf(str, size, "%*.g", FLT_DIG, f); + int res = snprintf(str, size, "%.*g", FLT_DIG, f); setlocale(LC_NUMERIC, old); return res; #else UNUSED(locale); - return snprintf(str, size, "%*.g", FLT_DIG, f); + return snprintf(str, size, "%.*g", FLT_DIG, f); #endif }