3 #include "stdio_impl.h"
5 /* This read function heavily cheats. It knows:
6 * (1) len will always be 1
7 * (2) non-ascii characters don't matter */
9 static size_t do_read(FILE *f, unsigned char *buf, size_t len)
12 const wchar_t *wcs = f->cookie;
14 if (!wcs[0]) wcs=L"@";
15 for (i=0; i<f->buf_size && wcs[i]; i++)
16 f->buf[i] = wcs[i] < 128 ? wcs[i] : '@';
19 f->cookie = (void *)(wcs+i);
28 static long double wcstox(const wchar_t *s, wchar_t **p, int prec)
30 wchar_t *t = (wchar_t *)s;
31 unsigned char buf[64];
36 f.buf_size = sizeof buf - 4;
39 while (iswspace(*t)) t++;
42 long double y = __floatscan(&f, prec, 1);
44 size_t cnt = shcnt(&f);
45 *p = cnt ? t + cnt : (wchar_t *)s;
50 float wcstof(const wchar_t *s, wchar_t **p)
52 return wcstox(s, p, 0);
55 double wcstod(const wchar_t *s, wchar_t **p)
57 return wcstox(s, p, 1);
60 long double wcstold(const wchar_t *s, wchar_t **p)
62 return wcstox(s, p, 2);