bug #3739: handle %lu, %li and %ld in SDL_SetError.

This commit is contained in:
Ozkan Sezer 2017-10-29 14:15:00 +03:00
parent 5abd7d16d7
commit 926d803f83
2 changed files with 27 additions and 0 deletions

View File

@ -76,6 +76,16 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
case 0: /* Malformed format string.. */ case 0: /* Malformed format string.. */
--fmt; --fmt;
break; break;
case 'l':
switch (*fmt++) {
case 0: /* Malformed format string.. */
--fmt;
break;
case 'i': case 'd': case 'u':
error->args[error->argc++].value_l = va_arg(ap, long);
break;
}
break;
case 'c': case 'c':
case 'i': case 'i':
case 'd': case 'd':
@ -219,6 +229,22 @@ SDL_GetErrorMsg(char *errstr, int maxlen)
&& spot < (tmp + SDL_arraysize(tmp) - 2)) { && spot < (tmp + SDL_arraysize(tmp) - 2)) {
*spot++ = *fmt++; *spot++ = *fmt++;
} }
if (*fmt == 'l') {
*spot++ = *fmt++;
*spot++ = *fmt++;
*spot++ = '\0';
switch (spot[-2]) {
case 'i': case 'd': case 'u':
len = SDL_snprintf(msg, maxlen, tmp,
error->args[argi++].value_l);
if (len > 0) {
msg += len;
maxlen -= len;
}
break;
}
continue;
}
*spot++ = *fmt++; *spot++ = *fmt++;
*spot++ = '\0'; *spot++ = '\0';
switch (spot[-2]) { switch (spot[-2]) {

View File

@ -51,6 +51,7 @@ typedef struct SDL_error
unsigned char value_c; unsigned char value_c;
#endif #endif
int value_i; int value_i;
long value_l;
double value_f; double value_f;
char buf[ERR_MAX_STRLEN]; char buf[ERR_MAX_STRLEN];
} args[ERR_MAX_ARGS]; } args[ERR_MAX_ARGS];