diff options
Diffstat (limited to 'lib/libc/stdlib/strtoull.c')
-rw-r--r-- | lib/libc/stdlib/strtoull.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c index e3db68c..15a0972 100644 --- a/lib/libc/stdlib/strtoull.c +++ b/lib/libc/stdlib/strtoull.c @@ -52,13 +52,13 @@ unsigned long long strtoull(nptr, endptr, base) const char *nptr; char **endptr; - register int base; + int base; { - register const char *s; - register unsigned long long acc; - register unsigned char c; - register unsigned long long cutoff; - register int neg, any, cutlim; + const char *s; + unsigned long long acc; + unsigned char c; + unsigned long long cutoff; + int neg, any, cutlim; /* * See strtoq for comments as to the logic used. @@ -84,17 +84,15 @@ strtoull(nptr, endptr, base) if (base == 0) base = c == '0' ? 8 : 10; acc = any = 0; - if (base < 2 || base > 36) + if (base < 2) goto noconv; cutoff = ULLONG_MAX / base; cutlim = ULLONG_MAX % base; for ( ; ; c = *s++) { - if (!isascii(c)) - break; - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) + if (isxdigit(c)) + c = digittoint(c); + else if (isascii(c) && isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; |