]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/wcstof.c.patch
Libc-391.tar.gz
[apple/libc.git] / locale / FreeBSD / wcstof.c.patch
1 --- wcstof.c.orig Thu Nov 25 11:38:20 2004
2 +++ wcstof.c Fri Feb 18 14:48:11 2005
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstof.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <stdlib.h>
10 #include <wchar.h>
11 #include <wctype.h>
12 @@ -35,7 +37,8 @@
13 * See wcstod() for comments as to the logic used.
14 */
15 float
16 -wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
17 +wcstof_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
18 + locale_t loc)
19 {
20 static const mbstate_t initial;
21 mbstate_t mbs;
22 @@ -44,12 +47,13 @@
23 const wchar_t *wcp;
24 size_t len;
25
26 - while (iswspace(*nptr))
27 + NORMALIZE_LOCALE(loc);
28 + while (iswspace_l(*nptr, loc))
29 nptr++;
30
31 wcp = nptr;
32 mbs = initial;
33 - if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
34 + if ((len = wcsrtombs_l(NULL, &wcp, 0, &mbs, loc)) == (size_t)-1) {
35 if (endptr != NULL)
36 *endptr = (wchar_t *)nptr;
37 return (0.0);
38 @@ -57,9 +61,9 @@
39 if ((buf = malloc(len + 1)) == NULL)
40 return (0.0);
41 mbs = initial;
42 - wcsrtombs(buf, &wcp, len + 1, &mbs);
43 + wcsrtombs_l(buf, &wcp, len + 1, &mbs, loc);
44
45 - val = strtof(buf, &end);
46 + val = strtof_l(buf, &end, loc);
47
48 if (endptr != NULL)
49 *endptr = (wchar_t *)nptr + (end - buf);
50 @@ -67,4 +71,10 @@
51 free(buf);
52
53 return (val);
54 +}
55 +
56 +float
57 +wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
58 +{
59 + return wcstof_l(nptr, endptr, __current_locale());
60 }