]> git.saurik.com Git - apple/libc.git/blame - locale/FreeBSD/wcstold.c.patch
Libc-391.tar.gz
[apple/libc.git] / locale / FreeBSD / wcstold.c.patch
CommitLineData
3d9156a7
A
1--- wcstold.c.orig Thu Nov 25 11:38:20 2004
2+++ wcstold.c Fri Feb 18 14:52:24 2005
3@@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstold.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@@ -35,7 +37,8 @@
13 * See wcstod() for comments as to the logic used.
14 */
15 long double
16-wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
17+wcstold_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 = strtold(buf, &end);
46+ val = strtold_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+long double
57+wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
58+{
59+ return wcstold_l(nptr, endptr, __current_locale());
60 }