diff options
author | 2016-11-16 16:26:13 +0100 | |
---|---|---|
committer | 2016-11-16 16:28:01 +0100 | |
commit | 47a05778bff9388fc6c479461dd3804c79d7b539 (patch) | |
tree | bb3d4dc8df676b8aa478339b3fd0cd305dc4ac4d /3rdparty/SDL2/src/stdlib/SDL_string.c | |
parent | e61b392edfbfe5b9d70908c087632da915a3abd8 (diff) |
Updated SDL2 to 2.0.5 (nw)
Diffstat (limited to '3rdparty/SDL2/src/stdlib/SDL_string.c')
-rw-r--r-- | 3rdparty/SDL2/src/stdlib/SDL_string.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/3rdparty/SDL2/src/stdlib/SDL_string.c b/3rdparty/SDL2/src/stdlib/SDL_string.c index 5debb228507..debbebaed87 100644 --- a/3rdparty/SDL2/src/stdlib/SDL_string.c +++ b/3rdparty/SDL2/src/stdlib/SDL_string.c @@ -1315,6 +1315,7 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string) { size_t length = 0; + size_t slen; if (info && info->width && (size_t)info->width > SDL_strlen(string)) { char fill = info->pad_zeroes ? '0' : ' '; @@ -1326,7 +1327,8 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str } } - length += SDL_strlcpy(text, string, maxlen); + slen = SDL_strlcpy(text, string, maxlen); + length += SDL_min(slen, maxlen); if (info) { if (info->force_case == SDL_CASE_LOWER) { @@ -1402,10 +1404,11 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) } value = (unsigned long) arg; len = SDL_PrintUnsignedLong(text, left, NULL, value); - text += len; if (len >= left) { + text += (left > 1) ? left - 1 : 0; left = SDL_min(left, 1); } else { + text += len; left -= len; } arg -= value; @@ -1422,10 +1425,11 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) while (info->precision-- > 0) { value = (unsigned long) (arg * mult); len = SDL_PrintUnsignedLong(text, left, NULL, value); - text += len; if (len >= left) { + text += (left > 1) ? left - 1 : 0; left = SDL_min(left, 1); } else { + text += len; left -= len; } arg -= (double) value / mult; @@ -1458,10 +1462,11 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg) } } len = (size_t)width; - text += len; if (len >= left) { + text += (left > 1) ? left - 1 : 0; left = SDL_min(left, 1); } else { + text += len; left -= len; } while (len--) { @@ -1637,10 +1642,11 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, } ++fmt; } - text += len; if (len >= left) { + text += (left > 1) ? left - 1 : 0; left = SDL_min(left, 1); } else { + text += len; left -= len; } } else { |