]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/wcstol.c.patch
Libc-763.13.tar.gz
[apple/libc.git] / locale / FreeBSD / wcstol.c.patch
1 --- wcstol.c.orig 2009-11-09 15:05:25.000000000 -0800
2 +++ wcstol.c 2009-11-09 15:05:26.000000000 -0800
3 @@ -30,6 +30,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstol.c,v 1.2 2007/01/09 00:28:01 imp Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <ctype.h>
10 #include <errno.h>
11 #include <limits.h>
12 @@ -40,7 +42,8 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
13 * Convert a string to a long integer.
14 */
15 long
16 -wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
17 +wcstol_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
18 + int base, locale_t loc)
19 {
20 const wchar_t *s;
21 unsigned long acc;
22 @@ -48,13 +51,14 @@ wcstol(const wchar_t * __restrict nptr,
23 unsigned long cutoff;
24 int neg, any, cutlim;
25
26 + NORMALIZE_LOCALE(loc);
27 /*
28 * See strtol for comments as to the logic used.
29 */
30 s = nptr;
31 do {
32 c = *s++;
33 - } while (iswspace(c));
34 + } while (iswspace_l(c, loc));
35 if (c == '-') {
36 neg = 1;
37 c = *s++;
38 @@ -81,8 +85,8 @@ wcstol(const wchar_t * __restrict nptr,
39 cutoff /= base;
40 for ( ; ; c = *s++) {
41 #ifdef notyet
42 - if (iswdigit(c))
43 - c = digittoint(c);
44 + if (iswdigit_l(c, loc))
45 + c = digittoint_l(c, loc);
46 else
47 #endif
48 if (c >= L'0' && c <= L'9')
49 @@ -115,3 +119,9 @@ noconv:
50 *endptr = (wchar_t *)(any ? s - 1 : nptr);
51 return (acc);
52 }
53 +
54 +long
55 +wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
56 +{
57 + return wcstol_l(nptr, endptr, base, __current_locale());
58 +}