| OLD | NEW |
| 1 #include <stdlib.h> | 1 #include <stdlib.h> |
| 2 #include "shgetc.h" | 2 #include "shgetc.h" |
| 3 #include "floatscan.h" | 3 #include "floatscan.h" |
| 4 #include "stdio_impl.h" | 4 #include "stdio_impl.h" |
| 5 #include "libc.h" | 5 #include "libc.h" |
| 6 | 6 |
| 7 static long double strtox(const char *s, char **p, int prec) | 7 static long double strtox(const char* s, char** p, int prec) { |
| 8 { | 8 FILE f = {.buf = (void*)s, .rpos = (void*)s, .rend = (void*)-1, .lock = -1}; |
| 9 » FILE f = { | 9 shlim(&f, 0); |
| 10 » » .buf = (void *)s, .rpos = (void *)s, | 10 long double y = __floatscan(&f, prec, 1); |
| 11 » » .rend = (void *)-1, .lock = -1 | 11 off_t cnt = shcnt(&f); |
| 12 » }; | 12 if (p) |
| 13 » shlim(&f, 0); | 13 *p = cnt ? (char*)s + cnt : (char*)s; |
| 14 » long double y = __floatscan(&f, prec, 1); | 14 return y; |
| 15 » off_t cnt = shcnt(&f); | |
| 16 » if (p) *p = cnt ? (char *)s + cnt : (char *)s; | |
| 17 » return y; | |
| 18 } | 15 } |
| 19 | 16 |
| 20 float strtof(const char *restrict s, char **restrict p) | 17 float strtof(const char* restrict s, char** restrict p) { |
| 21 { | 18 return strtox(s, p, 0); |
| 22 » return strtox(s, p, 0); | |
| 23 } | 19 } |
| 24 | 20 |
| 25 double strtod(const char *restrict s, char **restrict p) | 21 double strtod(const char* restrict s, char** restrict p) { |
| 26 { | 22 return strtox(s, p, 1); |
| 27 » return strtox(s, p, 1); | |
| 28 } | 23 } |
| 29 | 24 |
| 30 long double strtold(const char *restrict s, char **restrict p) | 25 long double strtold(const char* restrict s, char** restrict p) { |
| 31 { | 26 return strtox(s, p, 2); |
| 32 » return strtox(s, p, 2); | |
| 33 } | 27 } |
| 34 | 28 |
| 35 weak_alias(strtof, strtof_l); | 29 weak_alias(strtof, strtof_l); |
| 36 weak_alias(strtod, strtod_l); | 30 weak_alias(strtod, strtod_l); |
| 37 weak_alias(strtold, strtold_l); | 31 weak_alias(strtold, strtold_l); |
| 38 weak_alias(strtof, __strtof_l); | 32 weak_alias(strtof, __strtof_l); |
| 39 weak_alias(strtod, __strtod_l); | 33 weak_alias(strtod, __strtod_l); |
| 40 weak_alias(strtold, __strtold_l); | 34 weak_alias(strtold, __strtold_l); |
| OLD | NEW |