aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_parse_uint32__.c
blob: f87f19e01a6c0cb2d1f69de2704a067da1e022d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


int
libfonts_parse_uint32__(uint32_t *outp, const char *value)
{
	uint32_t out = 0, digit;
	value += *value == '+';
	if (!*value)
		return 0;
	while (isdigit(*value)) {
		digit = (*value & 15);
		if (out > (UINT32_C(0xFFFFFFFF) - digit) / 10)
			return 0;
		out = out * 10 + digit;
	}
	if (*value)
		return 0;
	*outp = out;
	return 1;
}


#else


int
main(void)
{
	return 0; /* TODO add test */
}


#endif