35 #include <sys/cdefs.h>
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/ctype.h>
41 #include <sys/limits.h>
59 int neg = 0, any, cutlim;
74 if ((base == 0 || base == 16) &&
75 c ==
'0' && (*s ==
'x' || *s ==
'X')) {
81 base = c ==
'0' ? 8 : 10;
100 cutoff = neg ? -(
unsigned long)LONG_MIN : LONG_MAX;
101 cutlim = cutoff % (
unsigned long)base;
102 cutoff /= (
unsigned long)base;
103 for (acc = 0, any = 0;; c = *s++) {
109 c -= isupper(c) ?
'A' - 10 :
'a' - 10;
114 if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
123 acc = neg ? LONG_MIN : LONG_MAX;
127 *endptr = __DECONST(
char *, any ? s - 1 : nptr);
long strtol(char *nptr, char **endptr, int base) const