summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/bg_lib.c32
-rw-r--r--src/game/bg_lib.h4
-rw-r--r--src/game/g_cmds.c9
3 files changed, 24 insertions, 21 deletions
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 )
{
diff --git a/src/game/bg_lib.h b/src/game/bg_lib.h
index 50c44558..13739a0c 100644
--- a/src/game/bg_lib.h
+++ b/src/game/bg_lib.h
@@ -104,10 +104,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 sscanf( const char *buffer, const char *fmt, ... );
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index d194c142..c9cb889c 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -154,17 +154,20 @@ int G_ClientNumbersFromString( char *s, int *plist, int max )
{
gclient_t *p;
int i, found = 0;
+ char *endptr;
char n2[ MAX_NAME_LENGTH ] = {""};
char s2[ MAX_NAME_LENGTH ] = {""};
if( max == 0 )
return 0;
+ if( !s[ 0 ] )
+ return 0;
+
// if a number is provided, it is a clientnum
- for( i = 0; s[ i ] && isdigit( s[ i ] ); i++ );
- if( !s[ i ] )
+ i = strtol( s, &endptr, 10 );
+ if( *endptr == '\0' )
{
- i = atoi( s );
if( i >= 0 && i < level.maxclients )
{
p = &level.clients[ i ];