From 00812ef4617697f15632a068439193b044c1b5cd Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Sun, 18 Apr 2010 15:52:59 +0000 Subject: * (bug 4090) fix G_ClientNumbersFromString on an empty argument * faff about with const in strtol and strtod (see bug 4598) --- src/game/bg_lib.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/game/bg_lib.c') diff --git a/src/game/bg_lib.c b/src/game/bg_lib.c index 5f242934..382d8abd 100644 --- a/src/game/bg_lib.c +++ b/src/game/bg_lib.c @@ -1403,7 +1403,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; @@ -1418,7 +1418,7 @@ double strtod( const char *nptr, const char **endptr ) floatint_t nan; if( endptr ) - *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 @@ -1427,7 +1427,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 == ')' ) @@ -1453,9 +1453,9 @@ double strtod( const char *nptr, const char **endptr ) 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; } @@ -1528,12 +1528,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 ) @@ -1560,7 +1560,7 @@ double strtod( const char *nptr, const char **endptr ) } } if( endptr ) - *endptr = end; + *endptr = (char *)end; return res; } // decimal @@ -1592,12 +1592,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 ) @@ -1626,7 +1626,7 @@ double strtod( const char *nptr, const char **endptr ) } } if( endptr ) - *endptr = end; + *endptr = (char *)end; return res; } } @@ -1720,13 +1720,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 @@ -1753,7 +1753,7 @@ long strtol( const char *nptr, const char **endptr, int base ) // 0 is always a valid digit if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; if( *nptr == 'x' || *nptr == 'X' ) { @@ -1761,7 +1761,7 @@ long strtol( const char *nptr, const char **endptr, int base ) { // can't be hex, reject x (accept 0) if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; return 0; } @@ -1800,7 +1800,7 @@ long strtol( const char *nptr, const char **endptr, int base ) nptr++; if( endptr ) - *endptr = nptr; + *endptr = (char *)nptr; } if( pos ) { -- cgit