stdlib: SDL_snprintf now adds decimal places for ("%f", 0.0).

This patch was from @Markvy (thanks!).

Fixes #4795.
This commit is contained in:
Ryan C. Gordon 2021-11-07 12:26:39 -05:00 committed by Sam Lantinga
parent 2008f2a8a6
commit 3acb172531
1 changed files with 28 additions and 41 deletions

View File

@ -1636,7 +1636,6 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
{
size_t length = 0;
if (arg) {
/* This isn't especially accurate, but hey, it's easy. :) */
unsigned long value;
@ -1671,18 +1670,6 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
mult *= 10;
}
}
} else {
if (length < maxlen) {
text[length] = '0';
}
++length;
if (info->force_type) {
if (length < maxlen) {
text[length] = '.';
}
++length;
}
}
if (info->width > 0 && (size_t)info->width > length) {
const char fill = info->pad_zeroes ? '0' : ' ';