]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/wcstod.c.patch
Libc-391.2.3.tar.gz
[apple/libc.git] / locale / FreeBSD / wcstod.c.patch
1 --- wcstod.c.orig Thu Nov 25 11:38:20 2004
2 +++ wcstod.c Fri Feb 18 14:45:42 2005
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstod.c,v 1.4 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 @@ -41,7 +43,8 @@
13 * for at least the digits, radix character and letters.
14 */
15 double
16 -wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
17 +wcstod_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 @@ -50,7 +53,8 @@
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 /*
32 @@ -65,7 +69,7 @@
33 */
34 wcp = nptr;
35 mbs = initial;
36 - if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
37 + if ((len = wcsrtombs_l(NULL, &wcp, 0, &mbs, loc)) == (size_t)-1) {
38 if (endptr != NULL)
39 *endptr = (wchar_t *)nptr;
40 return (0.0);
41 @@ -73,10 +77,10 @@
42 if ((buf = malloc(len + 1)) == NULL)
43 return (0.0);
44 mbs = initial;
45 - wcsrtombs(buf, &wcp, len + 1, &mbs);
46 + wcsrtombs_l(buf, &wcp, len + 1, &mbs, loc);
47
48 /* Let strtod() do most of the work for us. */
49 - val = strtod(buf, &end);
50 + val = strtod_l(buf, &end, loc);
51
52 /*
53 * We only know where the number ended in the _multibyte_
54 @@ -91,4 +95,10 @@
55 free(buf);
56
57 return (val);
58 +}
59 +
60 +double
61 +wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
62 +{
63 + return wcstod_l(nptr, endptr, __current_locale());
64 }