Module Name: src
Committed By: joerg
Date: Tue Apr 16 16:52:13 UTC 2013
Modified Files:
src/include: inttypes.h wchar.h
src/lib/libc/locale: _wcstol.h _wcstoul.h
Log Message:
Add support for wcstoimax_l and friends.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/include/inttypes.h
cvs rdiff -u -r1.31 -r1.32 src/include/wchar.h
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/_wcstol.h \
src/lib/libc/locale/_wcstoul.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/include/inttypes.h
diff -u src/include/inttypes.h:1.7 src/include/inttypes.h:1.8
--- src/include/inttypes.h:1.7 Sun Nov 15 22:21:03 2009
+++ src/include/inttypes.h Tue Apr 16 16:52:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: inttypes.h,v 1.7 2009/11/15 22:21:03 christos Exp $ */
+/* $NetBSD: inttypes.h,v 1.8 2013/04/16 16:52:13 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -59,6 +59,17 @@ typedef struct {
} imaxdiv_t;
imaxdiv_t imaxdiv(intmax_t, intmax_t);
+
+#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
+# ifndef __LOCALE_T_DECLARED
+typedef struct _locale *locale_t;
+# define __LOCALE_T_DECLARED
+# endif
+intmax_t wcstoimax_l(const wchar_t * __restrict,
+ wchar_t ** __restrict, int, locale_t);
+uintmax_t wcstoumax_l(const wchar_t * __restrict,
+ wchar_t ** __restrict, int, locale_t);
+#endif
__END_DECLS
#endif /* !_INTTYPES_H_ */
Index: src/include/wchar.h
diff -u src/include/wchar.h:1.31 src/include/wchar.h:1.32
--- src/include/wchar.h:1.31 Tue Apr 16 11:55:02 2013
+++ src/include/wchar.h Tue Apr 16 16:52:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wchar.h,v 1.31 2013/04/16 11:55:02 joerg Exp $ */
+/* $NetBSD: wchar.h,v 1.32 2013/04/16 16:52:13 joerg Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -211,6 +211,16 @@ __END_DECLS
typedef struct _locale *locale_t;
# define __LOCALE_T_DECLARED
# endif
+long int wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int,
+ locale_t);
+unsigned long int wcstoul_l(const wchar_t * __restrict,
+ wchar_t ** __restrict, int, locale_t);
+/* LONGLONG */
+long long int wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int,
+ locale_t);
+/* LONGLONG */
+unsigned long long int wcstoull_l(const wchar_t * __restrict,
+ wchar_t ** __restrict, int, locale_t);
int wcwidth_l(wchar_t, locale_t);
int wcswidth_l(const wchar_t *, size_t, locale_t);
#endif
Index: src/lib/libc/locale/_wcstol.h
diff -u src/lib/libc/locale/_wcstol.h:1.4 src/lib/libc/locale/_wcstol.h:1.5
--- src/lib/libc/locale/_wcstol.h:1.4 Mon Jun 25 22:32:44 2012
+++ src/lib/libc/locale/_wcstol.h Tue Apr 16 16:52:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: _wcstol.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
+/* $NetBSD: _wcstol.h,v 1.5 2013/04/16 16:52:13 joerg Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -44,8 +44,14 @@
* __INT_MAX : upper limit of the return type
*/
-__INT
-_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
+#include <locale.h>
+#include "setlocale_local.h"
+#define INT_FUNCNAME_(pre, name, post) pre ## name ## post
+#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post)
+
+static __INT
+INT_FUNCNAME(_int_, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
+ int base, locale_t loc)
{
const wchar_t *s;
__INT acc, cutoff;
@@ -74,7 +80,7 @@ _FUNCNAME(const wchar_t *nptr, wchar_t *
s = nptr;
do {
wc = (wchar_t) *s++;
- } while (iswspace(wc));
+ } while (iswspace_l(wc, loc));
if (wc == L'-') {
neg = 1;
wc = *s++;
@@ -139,3 +145,19 @@ _FUNCNAME(const wchar_t *nptr, wchar_t *
*endptr = __UNCONST(any ? s - 1 : nptr);
return (acc);
}
+
+__INT
+_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
+{
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base,
+ *_current_locale());
+}
+
+__INT
+INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
+ int base, locale_t loc)
+{
+ if (loc == NULL)
+ loc = _C_locale;
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
+}
Index: src/lib/libc/locale/_wcstoul.h
diff -u src/lib/libc/locale/_wcstoul.h:1.4 src/lib/libc/locale/_wcstoul.h:1.5
--- src/lib/libc/locale/_wcstoul.h:1.4 Mon Jun 25 22:32:44 2012
+++ src/lib/libc/locale/_wcstoul.h Tue Apr 16 16:52:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: _wcstoul.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
+/* $NetBSD: _wcstoul.h,v 1.5 2013/04/16 16:52:13 joerg Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -43,8 +43,14 @@
* __UINT_MAX : upper limit of the return type
*/
-__UINT
-_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
+#include <locale.h>
+#include "setlocale_local.h"
+#define INT_FUNCNAME_(pre, name, post) pre ## name ## post
+#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post)
+
+static __UINT
+INT_FUNCNAME(_int_, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
+ int base, locale_t loc)
{
const wchar_t *s;
__UINT acc, cutoff;
@@ -68,7 +74,7 @@ _FUNCNAME(const wchar_t *nptr, wchar_t *
s = nptr;
do {
wc = (wchar_t) *s++;
- } while (iswspace(wc));
+ } while (iswspace_l(wc, loc));
if (wc == L'-') {
neg = 1;
wc = *s++;
@@ -115,3 +121,19 @@ _FUNCNAME(const wchar_t *nptr, wchar_t *
*endptr = __UNCONST(any ? s - 1 : nptr);
return (acc);
}
+
+__UINT
+_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
+{
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base,
+ *_current_locale());
+}
+
+__UINT
+INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr,
+ int base, locale_t loc)
+{
+ if (loc == NULL)
+ loc = _C_locale;
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
+}