iconv: add euro symbol to GBK as single byte 0x80
[musl.git] / src / stdlib / strtod.c
blob39b9daada8a5d93df5f625c2f3adc19bdbcb894f
1 #include <stdlib.h>
2 #include "shgetc.h"
3 #include "floatscan.h"
4 #include "stdio_impl.h"
6 static long double strtox(const char *s, char **p, int prec)
8 FILE f;
9 sh_fromstring(&f, s);
10 shlim(&f, 0);
11 long double y = __floatscan(&f, prec, 1);
12 off_t cnt = shcnt(&f);
13 if (p) *p = cnt ? (char *)s + cnt : (char *)s;
14 return y;
17 float strtof(const char *restrict s, char **restrict p)
19 return strtox(s, p, 0);
22 double strtod(const char *restrict s, char **restrict p)
24 return strtox(s, p, 1);
27 long double strtold(const char *restrict s, char **restrict p)
29 return strtox(s, p, 2);