79long strtol(nptr, endptr, base)
const char* nptr;
92 if(base < 0 || base > 36)
98 *endptr = (
char*)(uintptr_t)nptr;
124 if((base == 0 || base == 16) && c ==
'0' && (*s ==
'x' || *s ==
'X'))
130 else if((base == 0 || base == 2) && c ==
'0' && (*s ==
'b' || *s ==
'B'))
139 base = c ==
'0' ? 8 : 10;
159 cutoff = neg ? -(
unsigned long)LONG_MIN : LONG_MAX;
160 cutlim = (int)(cutoff % (
unsigned long)base);
161 cutoff /= (
unsigned long)base;
163 for(acc = 0, any = 0;; c = *s++)
171 c -= isupper(c) ?
'A' - 10 :
'a' - 10;
183 if(any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
190 acc *= (
unsigned long)base;
191 acc += (
unsigned long)c;
197 acc = neg ? (
unsigned long)LONG_MIN : (unsigned long)LONG_MAX;
207 *endptr = (
char*)(uintptr_t)(any ? s - 1 : nptr);