summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/src/stdlib/SDL_string.c
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/SDL2/src/stdlib/SDL_string.c')
-rw-r--r--3rdparty/SDL2/src/stdlib/SDL_string.c16
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 {
td>as if millions of this pointers suddenly cried out in terror, and were sudden... Vas Crabb2018-06-081-3/+3 * More cleanup/streamlining of machine configuration and macros: Vas Crabb2018-05-151-2/+2 * Removed DRIVER_INIT-related macros, made driver init entry in GAME/COMP/CONS ... MooglyGuy2018-05-131-2/+2 * dsp16: fix condition mask in disassembler (nw) Vas Crabb2018-05-091-1/+1 * Streamline machine configuration macros - everyone's a device edition. Vas Crabb2018-05-061-4/+4 * Address maps macros removal, pass 1 [O. Galibert] Olivier Galibert2018-03-141-21/+23 * API change: Memory maps are now methods of the owner class [O. Galibert] Olivier Galibert2018-02-121-2/+4 * xtal.h is dead, long live to xtal.cpp [O. Galibert] Olivier Galibert2018-01-231-2/+2 * API Change: Machine configs are now a method of the owner class, and the prot... Olivier Galibert2018-01-171-1/+2 * (nw) minor tidyup of some of my drivers Robbbert2017-11-091-4/+4 * Move static data out of devices into the device types. This is a significant... Vas Crabb2017-05-141-6/+6 * Self-registering devices prep: Vas Crabb2017-02-271-0/+2 * (nw) Finished converting m_p_chargen to required region, and associated clean... Robbbert2017-02-141-5/+0 * Converting m_p_chargen into a required_region, part 1 Robbbert2017-02-091-13/+12 * Cleanup of my drivers (nw) Robbbert2017-01-071-3/+1 * Improvements to rgb_t (nw) AJR2016-10-221-1/+1 * cleanup of TRUE/FALSE in mame section (nw) Miodrag Milanovic2016-10-221-1/+1 * NOTICE (TYPE NAME CONSOLIDATION) Miodrag Milanovic2016-10-221-8/+8 * Don't rely on macro expansion to supply parentheses around condition for if s... Vas Crabb2016-08-161-1/+1 * Add support to adjust the screen color Dirk Best2016-03-121-2/+2 * BEEP device clock() added, instead of default frequency of 3250 hap2016-01-211-2/+1 * reverting: Miodrag Milanovic2016-01-201-1/+1 * tags are now strings (nw) Miodrag Milanovic2016-01-161-1/+1 * overrides in drivers (nw) Miodrag Milanovic2015-12-061-3/+3