Fixed SDL printf output for 0x%.8x
This commit is contained in:
parent
32188834b5
commit
a7954b42d0
1 changed files with 19 additions and 7 deletions
|
@ -1308,7 +1308,24 @@ typedef struct
|
||||||
static size_t
|
static size_t
|
||||||
SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
|
SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
|
||||||
{
|
{
|
||||||
return SDL_strlcpy(text, string, maxlen);
|
size_t length = 0;
|
||||||
|
|
||||||
|
if (info && info->width && (size_t)info->width > SDL_strlen(string)) {
|
||||||
|
char fill = info->pad_zeroes ? '0' : ' ';
|
||||||
|
size_t width = info->width - SDL_strlen(string);
|
||||||
|
while (width-- > 0 && maxlen > 0) {
|
||||||
|
*text++ = fill;
|
||||||
|
++length;
|
||||||
|
--maxlen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
length += SDL_strlcpy(text, string, maxlen);
|
||||||
|
|
||||||
|
if (info && info->do_lowercase) {
|
||||||
|
SDL_strlwr(text);
|
||||||
|
}
|
||||||
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -1572,6 +1589,7 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||||
}
|
}
|
||||||
/* Fall through to unsigned handling */
|
/* Fall through to unsigned handling */
|
||||||
case 'u':
|
case 'u':
|
||||||
|
info.pad_zeroes = SDL_TRUE;
|
||||||
switch (inttype) {
|
switch (inttype) {
|
||||||
case DO_INT:
|
case DO_INT:
|
||||||
len = SDL_PrintUnsignedLong(text, left, &info,
|
len = SDL_PrintUnsignedLong(text, left, &info,
|
||||||
|
@ -1587,12 +1605,6 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||||
va_arg(ap, Uint64));
|
va_arg(ap, Uint64));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (info.do_lowercase) {
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < len && i < left; ++i) {
|
|
||||||
text[i] = SDL_tolower((unsigned char)text[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
done = SDL_TRUE;
|
done = SDL_TRUE;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue