summaryrefslogtreecommitdiffstats
path: root/src/core/misc.c
diff options
context:
space:
mode:
authorMichael Brown2006-11-15 05:16:26 +0100
committerMichael Brown2006-11-15 05:16:26 +0100
commitea97fe42dd98685d4d4c5e25db5237f765b5f426 (patch)
treeaa881b78b157d0506bf7856be7977ec85f8f5edf /src/core/misc.c
parentMay as well add octal support to strtoul() (diff)
downloadipxe-ea97fe42dd98685d4d4c5e25db5237f765b5f426.tar.gz
ipxe-ea97fe42dd98685d4d4c5e25db5237f765b5f426.tar.xz
ipxe-ea97fe42dd98685d4d4c5e25db5237f765b5f426.zip
Note to self: do not write code late at night
Diffstat (limited to 'src/core/misc.c')
-rw-r--r--src/core/misc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 2a926313..c80eacdd 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -167,11 +167,14 @@ unsigned long strtoul ( const char *p, char **endp, int base ) {
}
while ( 1 ) {
- charval = ( *p - '0' );
- if ( charval > ( 'A' - '0' - 10 ) )
- charval -= ( 'A' - '0' - 10 );
- if ( charval > ( 'a' - 'A' ) )
- charval -= ( 'a' - 'A' );
+ charval = *p;
+ if ( charval >= 'a' ) {
+ charval = ( charval - 'a' + 10 );
+ } else if ( charval >= 'A' ) {
+ charval = ( charval - 'A' + 10 );
+ } else {
+ charval = ( charval - '0' );
+ }
if ( charval >= ( unsigned int ) base )
break;
ret = ( ( ret * base ) + charval );