diff options
author | theraven <theraven@FreeBSD.org> | 2011-11-20 14:45:42 +0000 |
---|---|---|
committer | theraven <theraven@FreeBSD.org> | 2011-11-20 14:45:42 +0000 |
commit | 0f6ef690b3118882121ed67561c7ce2660cfebe1 (patch) | |
tree | 909189922493cddbeeac84af2e316dc897661311 /lib/libc/locale/wcstoll.c | |
parent | 18b29f3fb8abee5d57ed8f4a44f806bec7e0eeff (diff) | |
download | FreeBSD-src-0f6ef690b3118882121ed67561c7ce2660cfebe1.zip FreeBSD-src-0f6ef690b3118882121ed67561c7ce2660cfebe1.tar.gz |
Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
load of _l suffixed versions of various standard library functions that use
the global locale, making them take an explicit locale parameter. Also
adds support for per-thread locales. This work was funded by the FreeBSD
Foundation.
Please test any code you have that uses the C standard locale functions!
Reviewed by: das (gdtoa changes)
Approved by: dim (mentor)
Diffstat (limited to 'lib/libc/locale/wcstoll.c')
-rw-r--r-- | lib/libc/locale/wcstoll.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/libc/locale/wcstoll.c b/lib/libc/locale/wcstoll.c index 19b285f..f246502 100644 --- a/lib/libc/locale/wcstoll.c +++ b/lib/libc/locale/wcstoll.c @@ -2,6 +2,11 @@ * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * + * Copyright (c) 2011 The FreeBSD Foundation + * All rights reserved. + * Portions of this software were developed by David Chisnall + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -41,18 +46,21 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <wchar.h> #include <wctype.h> +#include "xlocale_private.h" /* * Convert a wide character string to a long long integer. */ long long -wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) +wcstoll_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, + int base, locale_t locale) { const wchar_t *s; unsigned long long acc; wchar_t c; unsigned long long cutoff; int neg, any, cutlim; + FIX_LOCALE(locale); /* * See strtoll for comments as to the logic used. @@ -60,7 +68,7 @@ wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) s = nptr; do { c = *s++; - } while (iswspace(c)); + } while (iswspace_l(c, locale)); if (c == L'-') { neg = 1; c = *s++; @@ -87,8 +95,8 @@ wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) cutoff /= base; for ( ; ; c = *s++) { #ifdef notyet - if (iswdigit(c)) - c = digittoint(c); + if (iswdigit_l(c, locale)) + c = digittoint_l(c, locale); else #endif if (c >= L'0' && c <= L'9') @@ -121,3 +129,8 @@ noconv: *endptr = (wchar_t *)(any ? s - 1 : nptr); return (acc); } +long long +wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base) +{ + return wcstoll_l(nptr, endptr, base, __get_locale()); +} |