backport https://hg.libsdl.org/SDL/rev/8a70b87401c3 (bug #4548) SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Thu, 15 Aug 2019 17:02:10 +0300
branchSDL-1.2
changeset 13010a355b476255e
parent 13009 12a87fcb4d97
child 13011 edf8cb7ce974
backport https://hg.libsdl.org/SDL/rev/8a70b87401c3 (bug #4548)
src/SDL_error.c
     1.1 --- a/src/SDL_error.c	Thu Aug 15 16:55:56 2019 +0300
     1.2 +++ b/src/SDL_error.c	Thu Aug 15 17:02:10 2019 +0300
     1.3 @@ -28,7 +28,7 @@
     1.4  
     1.5  /* Routine to get the thread-specific error variable */
     1.6  #if SDL_THREADS_DISABLED
     1.7 -/* The  SDL_arraysize(The ),default (non-thread-safe) global error variable */
     1.8 +/* The  default (non-thread-safe) global error variable */
     1.9  static SDL_error SDL_global_error;
    1.10  #define SDL_GetErrBuf()	(&SDL_global_error)
    1.11  #else
    1.12 @@ -59,21 +59,21 @@
    1.13  
    1.14  	va_start(ap, fmt);
    1.15  	error->argc = 0;
    1.16 -	while ( *fmt ) {
    1.17 -		if ( *fmt++ == '%' ) {
    1.18 -			while ( *fmt == '.' || (*fmt >= '0' && *fmt <= '9') ) {
    1.19 +	while (*fmt) {
    1.20 +		if (*fmt++ == '%') {
    1.21 +			while (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) {
    1.22  				++fmt;
    1.23  			}
    1.24  			switch (*fmt++) {
    1.25 -			    case 0:  /* Malformed format string.. */
    1.26 +			    case 0: /* Malformed format string.. */
    1.27  				--fmt;
    1.28  				break;
    1.29  			    case 'l':
    1.30  				switch (*fmt++) {
    1.31 -				case 0:  /* Malformed format string.. */
    1.32 +				case 0: /* Malformed format string.. */
    1.33  					--fmt;
    1.34  					break;
    1.35 -				case 'i': case 'd': case 'u':
    1.36 +				case 'i': case 'd': case 'u': case 'x': case 'X':
    1.37  					error->args[error->argc++].value_l =
    1.38  								va_arg(ap, long);
    1.39  					break;
    1.40 @@ -110,7 +110,7 @@
    1.41  			    default:
    1.42  				break;
    1.43  			}
    1.44 -			if ( error->argc >= ERR_MAX_ARGS ) {
    1.45 +			if (error->argc >= ERR_MAX_ARGS) {
    1.46  				break;
    1.47  			}
    1.48  		}
    1.49 @@ -135,7 +135,7 @@
    1.50  
    1.51  	/* Get the thread-safe error, and print it out */
    1.52  	error = SDL_GetErrBuf();
    1.53 -	if ( error->error ) {
    1.54 +	if (error->error) {
    1.55  		const char *fmt;
    1.56  		char *msg = errstr;
    1.57  		int len;
    1.58 @@ -143,11 +143,11 @@
    1.59  
    1.60  		fmt = SDL_LookupString(error->key);
    1.61  		argi = 0;
    1.62 -		while ( *fmt && (maxlen > 0) ) {
    1.63 -			if ( *fmt == '%' ) {
    1.64 +		while (*fmt && (maxlen > 0)) {
    1.65 +			if (*fmt == '%') {
    1.66  				char tmp[32], *spot = tmp;
    1.67  				*spot++ = *fmt++;
    1.68 -				while ( (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2) ) {
    1.69 +				while ((*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2)) {
    1.70  					*spot++ = *fmt++;
    1.71  				}
    1.72  				if (*fmt == 'l') {
    1.73 @@ -155,7 +155,7 @@
    1.74  					*spot++ = *fmt++;
    1.75  					*spot++ = '\0';
    1.76  					switch (spot[-2]) {
    1.77 -					case 'i': case 'd': case 'u':
    1.78 +					case 'i': case 'd': case 'u': case 'x': case 'X':
    1.79  						len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_l);
    1.80  						if (len > 0) {
    1.81  						    msg += len;
    1.82 @@ -174,9 +174,9 @@
    1.83  					break;
    1.84  				    case 'c':
    1.85  				    case 'i':
    1.86 -			            case 'd':
    1.87 -			            case 'u':
    1.88 -			            case 'o':
    1.89 +				    case 'd':
    1.90 +				    case 'u':
    1.91 +				    case 'o':
    1.92  				    case 'x':
    1.93  				    case 'X':
    1.94  					len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_i);