]> git.saurik.com Git - apple/libc.git/blame - stdlib/FreeBSD/strtol.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdlib / FreeBSD / strtol.c.patch
CommitLineData
1f2f436a
A
1--- strtol.c.bsdnew 2009-11-13 14:11:51.000000000 -0800
2+++ strtol.c 2009-11-13 14:11:51.000000000 -0800
3@@ -33,6 +33,8 @@ static char sccsid[] = "@(#)strtol.c 8.1
3d9156a7 4 #include <sys/cdefs.h>
1f2f436a 5 __FBSDID("$FreeBSD: src/lib/libc/stdlib/strtol.c,v 1.20 2007/01/09 00:28:10 imp Exp $");
3d9156a7
A
6
7+#include "xlocale_private.h"
8+
9 #include <limits.h>
10 #include <ctype.h>
11 #include <errno.h>
1f2f436a 12@@ -46,7 +48,8 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/
3d9156a7
A
13 * alphabets and digits are each contiguous.
14 */
15 long
16-strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
17+strtol_l(const char * __restrict nptr, char ** __restrict endptr, int base,
18+ locale_t loc)
19 {
20 const char *s;
21 unsigned long acc;
1f2f436a 22@@ -54,6 +57,7 @@ strtol(const char * __restrict nptr, cha
3d9156a7
A
23 unsigned long cutoff;
24 int neg, any, cutlim;
25
26+ NORMALIZE_LOCALE(loc);
27 /*
28 * Skip white space and pick up leading +/- sign if any.
29 * If base is 0, allow 0x for hex and 0 for octal, else
1f2f436a 30@@ -62,7 +66,7 @@ strtol(const char * __restrict nptr, cha
3d9156a7
A
31 s = nptr;
32 do {
33 c = *s++;
34- } while (isspace((unsigned char)c));
35+ } while (isspace_l((unsigned char)c, loc));
36 if (c == '-') {
37 neg = 1;
38 c = *s++;
1f2f436a 39@@ -138,3 +142,9 @@ noconv:
3d9156a7
A
40 *endptr = (char *)(any ? s - 1 : nptr);
41 return (acc);
42 }
43+
44+long
45+strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
46+{
47+ return strtol_l(nptr, endptr, base, __current_locale());
48+}