mirror of https://github.com/encounter/SDL.git
stdlib: Try to coerce VS2019 to not replace some loops with memset() calls.
Fixes (?) Bugzilla #4759.
This commit is contained in:
parent
aef1ed4ac6
commit
987aa3113c
|
@ -1387,15 +1387,18 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str
|
||||||
|
|
||||||
sz = SDL_strlen(string);
|
sz = SDL_strlen(string);
|
||||||
if (info && info->width > 0 && (size_t)info->width > sz) {
|
if (info && info->width > 0 && (size_t)info->width > sz) {
|
||||||
char fill = info->pad_zeroes ? '0' : ' ';
|
const char fill = info->pad_zeroes ? '0' : ' ';
|
||||||
size_t width = info->width - sz;
|
size_t width = info->width - sz;
|
||||||
|
size_t filllen;
|
||||||
|
|
||||||
if (info->precision >= 0 && (size_t)info->precision < sz)
|
if (info->precision >= 0 && (size_t)info->precision < sz)
|
||||||
width += sz - (size_t)info->precision;
|
width += sz - (size_t)info->precision;
|
||||||
while (width-- > 0 && maxlen > 0) {
|
|
||||||
*text++ = fill;
|
filllen = SDL_min(width, maxlen);
|
||||||
++length;
|
SDL_memset(text, fill, filllen);
|
||||||
--maxlen;
|
text += filllen;
|
||||||
}
|
length += filllen;
|
||||||
|
maxlen -= filllen;
|
||||||
}
|
}
|
||||||
|
|
||||||
slen = SDL_strlcpy(text, string, maxlen);
|
slen = SDL_strlcpy(text, string, maxlen);
|
||||||
|
@ -1580,7 +1583,7 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
|
||||||
|
|
||||||
width = info->width - (int)(text - textstart);
|
width = info->width - (int)(text - textstart);
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
char fill = info->pad_zeroes ? '0' : ' ';
|
const char fill = info->pad_zeroes ? '0' : ' ';
|
||||||
char *end = text+left-1;
|
char *end = text+left-1;
|
||||||
len = (text - textstart);
|
len = (text - textstart);
|
||||||
for (len = (text - textstart); len--; ) {
|
for (len = (text - textstart); len--; ) {
|
||||||
|
@ -1596,10 +1599,10 @@ SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
|
||||||
text += len;
|
text += len;
|
||||||
left -= len;
|
left -= len;
|
||||||
}
|
}
|
||||||
while (len--) {
|
|
||||||
if (textstart+len < end) {
|
if (end != textstart) {
|
||||||
textstart[len] = fill;
|
const size_t filllen = SDL_min(len, ((size_t) (end - textstart)) - 1);
|
||||||
}
|
SDL_memset(textstart, fill, fillen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue