From 09122971c5ece9d9f617f55133f3801861f71023 Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Sun, 18 Apr 2010 12:43:10 +0100 Subject: [PATCH] * Make the signature for strtol/strtod match the libc versions --- code/game/bg_lib.c | 32 ++++++++++++++++---------------- code/game/bg_lib.h | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git ioq3-r1782/code/game/bg_lib.c strto/code/game/bg_lib.c index e1e9e9e..5aa839f 100644 --- ioq3-r1782/code/game/bg_lib.c +++ strto/code/game/bg_lib.c @@ -904,7 +904,7 @@ The variable pointed to by endptr will hold the location of the first character in the nptr string that was not used in the conversion ============== */ -double strtod( const char *nptr, const char **endptr ) +double strtod( const char *nptr, char **endptr ) { double res; qboolean neg = qfalse; @@ -922,7 +922,7 @@ double strtod( const char *nptr, const char **endptr ) nan.ui = 0x7fffffff; return nan.f; } - *endptr = &nptr[3]; + *endptr = (char *)&nptr[3]; // nan can be followed by a bracketed number (in hex, octal, // or decimal) which is then put in the mantissa // this can be used to generate signalling or quiet NaNs, for @@ -930,7 +930,7 @@ double strtod( const char *nptr, const char **endptr ) // note that nan(0) is infinity! if( nptr[3] == '(' ) { - const char *end; + char *end; int mantissa = strtol( &nptr[4], &end, 0 ); if( *end == ')' ) { @@ -950,9 +950,9 @@ double strtod( const char *nptr, const char **endptr ) if( endptr == NULL ) return inf.f; if( Q_stricmpn( &nptr[3], "inity", 5 ) == 0 ) - *endptr = &nptr[8]; + *endptr = (char *)&nptr[8]; else - *endptr = &nptr[3]; + *endptr = (char *)&nptr[3]; return inf.f; } @@ -1018,12 +1018,12 @@ double strtod( const char *nptr, const char **endptr ) float res2; // apparently (confusingly) the exponent should be // decimal - exp = strtol( &nptr[1], &end, 10 ); + exp = strtol( &nptr[1], (char **)&end, 10 ); if( &nptr[1] == end ) { // no exponent if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; return res; } if( exp > 0 ) @@ -1050,7 +1050,7 @@ double strtod( const char *nptr, const char **endptr ) } } if( endptr ) - *endptr = end; + *endptr = (char *)end; return res; } // decimal @@ -1082,12 +1082,12 @@ double strtod( const char *nptr, const char **endptr ) { int exp; float res10; - exp = strtol( &nptr[1], &end, 10 ); + exp = strtol( &nptr[1], (char **)&end, 10 ); if( &nptr[1] == end ) { // no exponent if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; return res; } if( exp > 0 ) @@ -1116,7 +1116,7 @@ double strtod( const char *nptr, const char **endptr ) } } if( endptr ) - *endptr = end; + *endptr = (char *)end; return res; } } @@ -1226,13 +1226,13 @@ Will not overflow - returns LONG_MIN or LONG_MAX as appropriate *endptr is set to the location of the first character not used ============== */ -long strtol( const char *nptr, const char **endptr, int base ) +long strtol( const char *nptr, char **endptr, int base ) { long res; qboolean pos = qtrue; if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; // bases other than 0, 2, 8, 16 are very rarely used, but they're // not much extra effort to support if( base < 0 || base == 1 || base > 36 ) @@ -1254,14 +1254,14 @@ long strtol( const char *nptr, const char **endptr, int base ) nptr++; // 0 is always a valid digit if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; if( *nptr == 'x' || *nptr == 'X' ) { if( base != 0 && base != 16 ) { // can't be hex, reject x (accept 0) if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; return 0; } nptr++; @@ -1294,7 +1294,7 @@ long strtol( const char *nptr, const char **endptr, int base ) res = res * base - val; nptr++; if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; } if( pos ) { diff --git ioq3-r1782/code/game/bg_lib.h strto/code/game/bg_lib.h index 0090ddd..aee0248 100644 --- ioq3-r1782/code/game/bg_lib.h +++ strto/code/game/bg_lib.h @@ -95,10 +95,10 @@ int toupper( int c ); double atof( const char *string ); double _atof( const char **stringPtr ); -double strtod( const char *nptr, const char **endptr ); +double strtod( const char *nptr, char **endptr ); int atoi( const char *string ); int _atoi( const char **stringPtr ); -long strtol( const char *nptr, const char **endptr, int base ); +long strtol( const char *nptr, char **endptr, int base ); int Q_vsnprintf( char *buffer, size_t length, const char *fmt, va_list argptr ); int Q_snprintf( char *buffer, size_t length, const char *fmt, ... ) __attribute__ ((format (printf, 3, 4))); -- 1.7.0.5