6 intmax_t strtoimax(const char *s1, char **p, int base)
8 const unsigned char *s = (void *)s1;
9 struct intparse ip = {0};
11 if (p) *p = (char *)s1;
13 if (base && base-2U > 34) {
18 for (; isspace(*s); s++);
21 __intparse(&ip, s, SIZE_MAX);
23 if (p && ip.err != EINVAL)
24 *p = (char *)s + ip.cnt;
28 if (ip.err == EINVAL) return 0;
29 return ip.neg ? INTMAX_MIN : INTMAX_MAX;
32 if (ip.val > INTMAX_MAX) {
33 if (!ip.neg || -ip.val != INTMAX_MIN)
35 return ip.neg ? INTMAX_MIN : INTMAX_MAX;
37 return ip.neg ? -ip.val : ip.val;