summaryrefslogtreecommitdiffstats
path: root/src/core/misc.c
diff options
context:
space:
mode:
authorMichael Brown2012-04-17 11:15:29 +0200
committerMichael Brown2012-04-17 11:42:08 +0200
commit1d33649516f2046e9fe692d42fffeeec96a2b858 (patch)
treef48462239a4cd88f506b8613cb0c05d885735fcf /src/core/misc.c
parent[multiboot] Include full image URI in command line (diff)
downloadipxe-1d33649516f2046e9fe692d42fffeeec96a2b858.tar.gz
ipxe-1d33649516f2046e9fe692d42fffeeec96a2b858.tar.xz
ipxe-1d33649516f2046e9fe692d42fffeeec96a2b858.zip
[libc] Allow strtoul() to interpret negative numbers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/misc.c')
-rw-r--r--src/core/misc.c12
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;