bug #3739: handle %lu, %li and %ld in SDL_SetError.
authorOzkan Sezer <sezero@users.sourceforge.net>
Sun, 29 Oct 2017 14:15:00 +0300
changeset 1187591138f56d762
parent 11874 b0e4f5085af4
child 11876 dfde5d3f9781
bug #3739: handle %lu, %li and %ld in SDL_SetError.
src/SDL_error.c
src/SDL_error_c.h
     1.1 --- a/src/SDL_error.c	Tue Feb 13 22:58:20 2018 -0800
     1.2 +++ b/src/SDL_error.c	Sun Oct 29 14:15:00 2017 +0300
     1.3 @@ -76,6 +76,16 @@
     1.4              case 0:            /* Malformed format string.. */
     1.5                  --fmt;
     1.6                  break;
     1.7 +            case 'l':
     1.8 +                switch (*fmt++) {
     1.9 +                case 0:        /* Malformed format string.. */
    1.10 +                    --fmt;
    1.11 +                    break;
    1.12 +                case 'i': case 'd': case 'u':
    1.13 +                    error->args[error->argc++].value_l = va_arg(ap, long);
    1.14 +                    break;
    1.15 +                }
    1.16 +                break;
    1.17              case 'c':
    1.18              case 'i':
    1.19              case 'd':
    1.20 @@ -219,6 +229,22 @@
    1.21                         && spot < (tmp + SDL_arraysize(tmp) - 2)) {
    1.22                      *spot++ = *fmt++;
    1.23                  }
    1.24 +                if (*fmt == 'l') {
    1.25 +                    *spot++ = *fmt++;
    1.26 +                    *spot++ = *fmt++;
    1.27 +                    *spot++ = '\0';
    1.28 +                    switch (spot[-2]) {
    1.29 +                    case 'i': case 'd': case 'u':
    1.30 +                      len = SDL_snprintf(msg, maxlen, tmp,
    1.31 +                                         error->args[argi++].value_l);
    1.32 +                      if (len > 0) {
    1.33 +                          msg += len;
    1.34 +                          maxlen -= len;
    1.35 +                      }
    1.36 +                      break;
    1.37 +                    }
    1.38 +                    continue;
    1.39 +                }
    1.40                  *spot++ = *fmt++;
    1.41                  *spot++ = '\0';
    1.42                  switch (spot[-2]) {
     2.1 --- a/src/SDL_error_c.h	Tue Feb 13 22:58:20 2018 -0800
     2.2 +++ b/src/SDL_error_c.h	Sun Oct 29 14:15:00 2017 +0300
     2.3 @@ -51,6 +51,7 @@
     2.4          unsigned char value_c;
     2.5  #endif
     2.6          int value_i;
     2.7 +        long value_l;
     2.8          double value_f;
     2.9          char buf[ERR_MAX_STRLEN];
    2.10      } args[ERR_MAX_ARGS];