wcstoimax.c.patch   [plain text]


--- wcstoimax.c.orig	2003-05-20 15:21:45.000000000 -0700
+++ wcstoimax.c	2005-02-23 16:06:32.000000000 -0800
@@ -40,6 +40,8 @@
 #endif
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstoimax.c,v 1.2 2003/01/01 18:48:43 schweikh Exp $");
 
+#include "xlocale_private.h"
+
 #include <errno.h>
 #include <inttypes.h>
 #include <stdlib.h>
@@ -50,8 +52,8 @@
  * Convert a wide character string to an intmax_t integer.
  */
 intmax_t
-wcstoimax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
-    int base)
+wcstoimax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+    int base, locale_t loc)
 {
 	const wchar_t *s;
 	uintmax_t acc;
@@ -59,13 +61,14 @@
 	uintmax_t cutoff;
 	int neg, any, cutlim;
 
+	NORMALIZE_LOCALE(loc);
 	/*
 	 * See strtoimax for comments as to the logic used.
 	 */
 	s = nptr;
 	do {
 		c = *s++;
-	} while (iswspace(c));
+	} while (iswspace_l(c, loc));
 	if (c == L'-') {
 		neg = 1;
 		c = *s++;
@@ -92,8 +95,8 @@
 	cutoff /= base;
 	for ( ; ; c = *s++) {
 #ifdef notyet
-		if (iswdigit(c))
-			c = digittoint(c);
+		if (iswdigit_l(c, loc))
+			c = digittoint_l(c, loc);
 		else
 #endif
 		if (c >= L'0' && c <= L'9')
@@ -126,3 +129,10 @@
 		*endptr = (wchar_t *)(any ? s - 1 : nptr);
 	return (acc);
 }
+
+intmax_t
+wcstoimax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+    int base)
+{
+	return wcstoimax_l(nptr, endptr, base, __current_locale());
+}