8 static inline int isspace(int c
)
10 return (c
<= ' '); /* Close enough */
13 static inline int digitval(int ch
)
15 if (ch
>= '0' && ch
<= '9') {
17 } else if (ch
>= 'A' && ch
<= 'Z') {
19 } else if (ch
>= 'a' && ch
<= 'z') {
26 unsigned long strtoul(const char *nptr
, char **endptr
, int base
)
32 while (isspace((unsigned char)*nptr
)) {
36 /* Single optional + or - */
39 if (c
== '-' || c
== '+') {
46 if (nptr
[0] == '0' && (nptr
[1] == 'x' || nptr
[1] == 'X')) {
49 } else if (nptr
[0] == '0') {
55 } else if (base
== 16) {
56 if (nptr
[0] == '0' && (nptr
[1] == 'x' || nptr
[1] == 'X')) {
61 while ((d
= digitval(*nptr
)) >= 0 && d
< base
) {
67 *endptr
= (char *)nptr
;
69 return minus
? -v
: v
;