7 intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base)
10 struct intparse ip = {0};
12 if (p) *p = (wchar_t *)s;
14 if (base && base-2U > 34) {
19 for (; iswspace(*s); s++);
22 for (; __intparse(&ip, (char[]){(*s&-(*s<128U))}, 1); s++);
24 if (p && ip.err != EINVAL)
25 *p = (wchar_t *)s1 + ip.cnt;
29 if (ip.err == EINVAL) return 0;
30 return ip.neg ? INTMAX_MIN : INTMAX_MAX;
33 if (ip.val > INTMAX_MAX) {
34 if (!ip.neg || -ip.val != INTMAX_MIN)
36 return ip.neg ? INTMAX_MIN : INTMAX_MAX;
38 return ip.neg ? -ip.val : ip.val;