SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
authorOzkan Sezer <sezeroz@gmail.com>
Wed, 26 Sep 2018 10:38:40 +0300
changeset 122264cbf7e663cb2
parent 12225 18445c9fc2f3
child 12227 3c5adcfe014e
SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
src/stdlib/SDL_string.c
     1.1 --- a/src/stdlib/SDL_string.c	Tue Sep 25 20:11:52 2018 -0700
     1.2 +++ b/src/stdlib/SDL_string.c	Wed Sep 26 10:38:40 2018 +0300
     1.3 @@ -1593,11 +1593,18 @@
     1.4              if (*fmt >= '0' && *fmt <= '9') {
     1.5                  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
     1.6              }
     1.7 +            else if (*fmt == '*') {
     1.8 +                ++fmt;
     1.9 +                info.width = va_arg(ap, int);
    1.10 +            }
    1.11  
    1.12              if (*fmt == '.') {
    1.13                  ++fmt;
    1.14                  if (*fmt >= '0' && *fmt <= '9') {
    1.15                      info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
    1.16 +                } else if (*fmt == '*') {
    1.17 +                    ++fmt;
    1.18 +                    info.precision = va_arg(ap, int);
    1.19                  } else {
    1.20                      info.precision = 0;
    1.21                  }