summaryrefslogtreecommitdiffstats
path: root/src/core/strtoull.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/strtoull.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/strtoull.c')
-rw-r--r--src/core/strtoull.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/strtoull.c b/src/core/strtoull.c
index b1ceeb45..00986eef 100644
--- a/src/core/strtoull.c
+++ b/src/core/strtoull.c
@@ -29,8 +29,17 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
unsigned long long strtoull ( const char *p, char **endp, int base ) {
unsigned long 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 ) {
@@ -41,6 +50,9 @@ unsigned long long strtoull ( const char *p, char **endp, int base ) {
p++;
}
+ if ( negative )
+ ret = -ret;
+
if ( endp )
*endp = ( char * ) p;