--- wcstol.c.orig Tue May 20 15:21:45 2003 +++ wcstol.c Fri Feb 18 14:50:27 2005 @@ -34,6 +34,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/lib/libc/locale/wcstol.c,v 1.1 2002/09/08 13:27:26 tjr Exp $"); +#include "xlocale_private.h" + #include <ctype.h> #include <errno.h> #include <limits.h> @@ -44,7 +46,8 @@ * Convert a string to a long integer. */ long -wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) +wcstol_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, + int base, locale_t loc) { const wchar_t *s; unsigned long acc; @@ -52,13 +55,14 @@ unsigned long cutoff; int neg, any, cutlim; + NORMALIZE_LOCALE(loc); /* * See strtol for comments as to the logic used. */ s = nptr; do { c = *s++; - } while (iswspace(c)); + } while (iswspace_l(c, loc)); if (c == '-') { neg = 1; c = *s++; @@ -85,8 +89,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') @@ -118,4 +122,10 @@ if (endptr != NULL) *endptr = (wchar_t *)(any ? s - 1 : nptr); return (acc); +} + +long +wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) +{ + return wcstol_l(nptr, endptr, base, __current_locale()); }