3 #include "stdio_impl.h"
6 /* This read function heavily cheats. It knows:
7 * (1) len will always be 1
8 * (2) non-ascii characters don't matter */
10 static size_t do_read(FILE *f, unsigned char *buf, size_t len)
13 const wchar_t *wcs = f->cookie;
15 if (!wcs[0]) wcs=L"@";
16 for (i=0; i<f->buf_size && wcs[i]; i++)
17 f->buf[i] = wcs[i] < 128 ? wcs[i] : '@';
20 f->cookie = (void *)(wcs+i);
29 static long double wcstox(const wchar_t *s, wchar_t **p, int prec)
31 wchar_t *t = (wchar_t *)s;
32 unsigned char buf[64];
37 f.buf_size = sizeof buf - 4;
40 while (iswspace(*t)) t++;
43 long double y = __floatscan(&f, prec, 1);
45 size_t cnt = shcnt(&f);
46 *p = cnt ? t + cnt : (wchar_t *)s;
51 float wcstof(const wchar_t *restrict s, wchar_t **restrict p)
53 return wcstox(s, p, 0);
56 double wcstod(const wchar_t *restrict s, wchar_t **restrict p)
58 return wcstox(s, p, 1);
61 long double wcstold(const wchar_t *restrict s, wchar_t **restrict p)
63 return wcstox(s, p, 2);