1 --- wcstof.c.orig 2008-10-09 11:50:52.000000000 -0700
2 +++ wcstof.c 2008-10-29 00:51:43.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 +extern size_t __wcs_end_offset(const char * __restrict buf, const char * __restrict end, locale_t loc);
21 -wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
22 +wcstof_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
25 static const mbstate_t initial;
33 + char mb[MB_CUR_MAX + 1];
34 + const wchar_t *nptr0 = nptr;
35 + const wchar_t *first;
37 - while (iswspace(*nptr))
38 + NORMALIZE_LOCALE(loc);
39 + ctype = __numeric_ctype(loc);
41 + while (iswspace_l(*nptr, ctype))
46 - if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
48 - *endptr = (wchar_t *)nptr;
51 - if ((buf = malloc(len + 1)) == NULL)
52 + if ((b = _simple_salloc()) == NULL)
57 - wcsrtombs(buf, &wcp, len + 1, &mbs);
58 + while (*nptr && (len = wcrtomb_l(mb, *nptr, &mbs, ctype)) != (size_t)-1) {
60 + if (_simple_sappend(b, mb) < 0) { /* no memory */
67 - val = strtof(buf, &end);
68 + buf = _simple_string(b);
69 + val = strtof_l(buf, &end, loc);
72 - *endptr = (wchar_t *)nptr + (end - buf);
73 + *endptr = (end == buf) ? (wchar_t *)nptr0 : ((wchar_t *)first + __wcs_end_offset(buf, end, loc));
82 +wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
84 + return wcstof_l(nptr, endptr, __current_locale());