May as well add octal support to strtoul()
authorMichael Brown <mcb30@etherboot.org>
Wed, 15 Nov 2006 02:57:24 +0000 (02:57 +0000)
committerMichael Brown <mcb30@etherboot.org>
Wed, 15 Nov 2006 02:57:24 +0000 (02:57 +0000)
src/core/misc.c

index 968e232..2a92631 100644 (file)
@@ -155,11 +155,14 @@ unsigned long strtoul ( const char *p, char **endp, int base ) {
        unsigned int charval;
 
        if ( base == 0 ) {
-               if ( ( p[0] == '0' ) && ( ( p[1] | 0x20 ) == 'x' ) ) {
-                       base = 16;
-                       p += 2;
-               } else {
-                       base = 10;
+               base = 10;
+               if ( *p == '0' ) {
+                       p++;
+                       base = 8;
+                       if ( ( *p | 0x20 ) == 'x' ) {
+                               p++;
+                               base = 16;
+                       }
                }
        }