Skip to content

Commit

Permalink
SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Sep 26, 2018
1 parent d40657b commit d0e9a36
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/stdlib/SDL_string.c
Expand Up @@ -1593,11 +1593,18 @@ SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt,
if (*fmt >= '0' && *fmt <= '9') {
info.width = SDL_strtol(fmt, (char **)&fmt, 0);
}
else if (*fmt == '*') {
++fmt;
info.width = va_arg(ap, int);
}

if (*fmt == '.') {
++fmt;
if (*fmt >= '0' && *fmt <= '9') {
info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
} else if (*fmt == '*') {
++fmt;
info.precision = va_arg(ap, int);
} else {
info.precision = 0;
}
Expand Down

0 comments on commit d0e9a36

Please sign in to comment.