1 --- wcstof.c.orig 2007-03-16 01:15:20.000000000 -0700
2 +++ wcstof.c 2007-03-16 03:04:01.000000000 -0700
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstof.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
7 +#include "xlocale_private.h"
15 * See wcstod() for comments as to the logic used.
18 -wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
19 +wcstof_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
22 static const mbstate_t initial;
30 + char mb[MB_CUR_MAX + 1];
31 + const wchar_t *nptr0 = nptr;
32 + const wchar_t *first;
34 - while (iswspace(*nptr))
35 + NORMALIZE_LOCALE(loc);
36 + ctype = __numeric_ctype(loc);
38 + while (iswspace_l(*nptr, ctype))
43 - if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
45 - *endptr = (wchar_t *)nptr;
48 - if ((buf = malloc(len + 1)) == NULL)
49 + if ((b = _simple_salloc()) == NULL)
54 - wcsrtombs(buf, &wcp, len + 1, &mbs);
55 + while (*nptr && (len = wcrtomb_l(mb, *nptr, &mbs, ctype)) != (size_t)-1) {
57 + if (_simple_sappend(b, mb) < 0) { /* no memory */
64 - val = strtof(buf, &end);
65 + buf = _simple_string(b);
66 + val = strtof_l(buf, &end, loc);
69 - *endptr = (wchar_t *)nptr + (end - buf);
70 + *endptr = (end == buf) ? (wchar_t *)nptr0 : ((wchar_t *)first + (end - buf));
79 +wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
81 + return wcstof_l(nptr, endptr, __current_locale());