- errno = 0;
- *val = strtoul(str, &end, base);
- if (errno != 0 || *end != 0)
- return false;
+ return INTCONV_OCTAL;
+ }
+
+ return INTCONV_DECIMAL;
+}
+
+bool test_strtoumax(cdecl_uintmax *out, const char *s, cdecl_uintmax limit)
+{
+ static const char idx[] = "0123456789abcdef0123456789ABCDEF";
+ unsigned base = intconv_base(&s);
+ cdecl_uintmax v;
+ char *c, d;
+
+ for (v = 0; (d = *s++);) {
+ if (!(c = strchr(idx, d)) || (d = (c-idx) & 0xf) >= base)
+ return 0;
+
+ if (!intconv_shift(&v, base, d) || v > limit)
+ return 0;
+ }