Browse Source

May as well add octal support to strtoul()

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
5753f2c58b
1 changed files with 8 additions and 5 deletions
  1. 8
    5
      src/core/misc.c

+ 8
- 5
src/core/misc.c View File

@@ -155,11 +155,14 @@ unsigned long strtoul ( const char *p, char **endp, int base ) {
155 155
 	unsigned int charval;
156 156
 
157 157
 	if ( base == 0 ) {
158
-		if ( ( p[0] == '0' ) && ( ( p[1] | 0x20 ) == 'x' ) ) {
159
-			base = 16;
160
-			p += 2;
161
-		} else {
162
-			base = 10;
158
+		base = 10;
159
+		if ( *p == '0' ) {
160
+			p++;
161
+			base = 8;
162
+			if ( ( *p | 0x20 ) == 'x' ) {
163
+				p++;
164
+				base = 16;
165
+			}
163 166
 		}
164 167
 	}
165 168
 

Loading…
Cancel
Save