1 #include <stdlib.h>
2 #include "shgetc.h"
3 #include "floatscan.h"
4 #include "stdio_impl.h"
5
6
strtox(const char * s,char ** p,int prec)7 static long double strtox(const char *s, char **p, int prec)
8 {
9 FILE f;
10 sh_fromstring(&f, s);
11 shlim(&f, 0);
12 long double y = __floatscan(&f, prec, 1);
13 off_t cnt = shcnt(&f);
14 if (p) *p = cnt ? (char *)s + cnt : (char *)s;
15 return y;
16 }
17 #if (!defined(MUSL_AARCH64_ARCH)) && (!defined(MUSL_ARM_ARCH))
strtof(const char * restrict s,char ** restrict p)18 float strtof(const char *restrict s, char **restrict p)
19 {
20 return strtox(s, p, 0);
21 }
22
strtod(const char * restrict s,char ** restrict p)23 double strtod(const char *restrict s, char **restrict p)
24 {
25 return strtox(s, p, 1);
26 }
27 #endif
28
strtold(const char * restrict s,char ** restrict p)29 long double strtold(const char *restrict s, char **restrict p)
30 {
31 return strtox(s, p, 2);
32 }
33