summaryrefslogtreecommitdiff
path: root/src/stdlib/strtod.c
blob: 98b992a1f77108e295405fae3b16495a8a6c8f8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdlib.h>
#include "floatscan.h"
#include "stdio_impl.h"

double strtod(const char *s, char **p)
{
	FILE f = {
		.buf = (void *)s, .rpos = (void *)s,
		.rend = (void *)-1, .lock = -1
	};
	off_t cnt;
	double y = __floatscan(&f, -1, 1, 1, &cnt);
	if (p) *p = (char *)s + cnt;
	return y;
}