Browse Source

Note to self: do not write code late at night

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

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

@@ -167,11 +167,14 @@ unsigned long strtoul ( const char *p, char **endp, int base ) {
167 167
 	}
168 168
 
169 169
 	while ( 1 ) {
170
-		charval = ( *p - '0' );
171
-		if ( charval > ( 'A' - '0' - 10 ) )
172
-			charval -= ( 'A' - '0' - 10 );
173
-		if ( charval > ( 'a' - 'A' ) )
174
-			charval -= ( 'a' - 'A' );
170
+		charval = *p;
171
+		if ( charval >= 'a' ) {
172
+			charval = ( charval - 'a' + 10 );
173
+		} else if ( charval >= 'A' ) {
174
+			charval = ( charval - 'A' + 10 );
175
+		} else {
176
+			charval = ( charval - '0' );
177
+		}
175 178
 		if ( charval >= ( unsigned int ) base )
176 179
 			break;
177 180
 		ret = ( ( ret * base ) + charval );

Loading…
Cancel
Save