summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/wcstoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/locale/wcstoll.c')
-rw-r--r--lib/libc/locale/wcstoll.c21
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());
+}
OpenPOWER on IntegriCloud