diff options
Diffstat (limited to 'src/core/misc.c')
| -rw-r--r-- | src/core/misc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 8f56e1fb4..11342481a 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -35,8 +35,17 @@ int inet_aton ( const char *cp, struct in_addr *inp ) { unsigned long strtoul ( const char *p, char **endp, int base ) { unsigned long ret = 0; + int negative = 0; unsigned int charval; + while ( isspace ( *p ) ) + p++; + + if ( *p == '-' ) { + negative = 1; + p++; + } + base = strtoul_base ( &p, base ); while ( 1 ) { @@ -47,6 +56,9 @@ unsigned long strtoul ( const char *p, char **endp, int base ) { p++; } + if ( negative ) + ret = -ret; + if ( endp ) *endp = ( char * ) p; |
