fix broken regerror (typo) and missing message
[musl] / src / stdlib / strtoul.c
1 #include <stdlib.h>
2 #include <inttypes.h>
3 #include <errno.h>
4 #include <limits.h>
5
6 unsigned long strtoul(const char *s, char **p, int base)
7 {
8         intmax_t x;
9         if (sizeof(intmax_t) == sizeof(long))
10                 return strtoumax(s, p, base);
11         x = strtoimax(s, p, base);
12         if (-x > ULONG_MAX || x > ULONG_MAX) {
13                 errno = ERANGE;
14                 return ULONG_MAX;
15         }
16         return x;
17 }