1 #include "stdio_impl.h"
5 static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim)
7 /* FIXME: use a helper function or macro to setup the FILE */
10 f.buf = f.rpos = (void *)s;
11 if ((size_t)s > (size_t)-1/2)
14 f.rend = (unsigned char *)s+(size_t)-1/2;
17 unsigned long long y = __intscan(&f, base, 1, lim);
19 size_t cnt = shcnt(&f);
25 unsigned long long strtoull(const char *s, char **p, int base)
27 return strtox(s, p, base, ULLONG_MAX);
30 long long strtoll(const char *s, char **p, int base)
32 return strtox(s, p, base, LLONG_MIN);
35 unsigned long strtoul(const char *s, char **p, int base)
37 return strtox(s, p, base, ULONG_MAX);
40 long strtol(const char *s, char **p, int base)
42 return strtox(s, p, base, 0UL+LONG_MIN);
45 intmax_t strtoimax(const char *s, char **p, int base)
47 return strtoll(s, p, base);
50 uintmax_t strtoumax(const char *s, char **p, int base)
52 return strtoull(s, p, base);