backfort fix for bug #3739: handle %lu, %li and %ld in SDL_SetError. SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sat, 24 Mar 2018 22:41:17 +0300
branchSDL-1.2
changeset 119720b5ac2b90ab1
parent 11971 70dd6a38cd76
child 11973 94f71f4d90e9
backfort fix for 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	Sat Mar 24 22:39:46 2018 +0300
     1.2 +++ b/src/SDL_error.c	Sat Mar 24 22:41:17 2018 +0300
     1.3 @@ -68,6 +68,17 @@
     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 =
    1.14 +								va_arg(ap, long);
    1.15 +					break;
    1.16 +				}
    1.17 +				break;
    1.18  			    case 'c':
    1.19  			    case 'i':
    1.20  			    case 'd':
    1.21 @@ -139,6 +150,21 @@
    1.22  				while ( (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2) ) {
    1.23  					*spot++ = *fmt++;
    1.24  				}
    1.25 +				if (*fmt == 'l') {
    1.26 +					*spot++ = *fmt++;
    1.27 +					*spot++ = *fmt++;
    1.28 +					*spot++ = '\0';
    1.29 +					switch (spot[-2]) {
    1.30 +					case 'i': case 'd': case 'u':
    1.31 +						len = SDL_snprintf(msg, maxlen, tmp, 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	Sat Mar 24 22:39:46 2018 +0300
     2.2 +++ b/src/SDL_error_c.h	Sat Mar 24 22:41:17 2018 +0300
     2.3 @@ -50,6 +50,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];