summaryrefslogtreecommitdiff
path: root/src/stdlib/wcstoul.c
blob: e39faafe10b35f5cefa695faae381bb9b3079392 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <wchar.h>
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <limits.h>

unsigned long wcstoul(const wchar_t *s, wchar_t **p, int base)
{
	uintmax_t x = wcstoumax(s, p, base);
	if (x > ULONG_MAX) {
		errno = ERANGE;
		return ULONG_MAX;
	}
	return x;
}