1 #include "shgetc.h" 2 #include "floatscan.h" 3 #include <wchar.h> 4 #include <wctype.h> 5 6 static long double wcstox(const wchar_t * restrict s, 7 wchar_t ** restrict p, 8 int prec) 9 { 10 wchar_t *t = (wchar_t *)s; 11 struct fake_file_t f; 12 while (iswspace(*t)) t++; 13 shinit_wcstring(&f, t); 14 long double y = __floatscan(&f, prec, 1); 15 if (p) { 16 size_t cnt = shcnt(&f); 17 *p = cnt ? t + cnt : (wchar_t *)s; 18 } 19 return y; 20 } 21 22 float wcstof(const wchar_t *restrict s, wchar_t **restrict p) 23 { 24 return wcstox(s, p, 0); 25 } 26 27 double wcstod(const wchar_t *restrict s, wchar_t **restrict p) 28 { 29 return wcstox(s, p, 1); 30 } 31 32 long double wcstold(const wchar_t *restrict s, wchar_t **restrict p) 33 { 34 return wcstox(s, p, 2); 35 } 36