Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add support for wcstoimax_l and friends.



details:   https://anonhg.NetBSD.org/src/rev/945b0ed3bd73
branches:  trunk
changeset: 786132:945b0ed3bd73
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Apr 16 16:52:13 2013 +0000

description:
Add support for wcstoimax_l and friends.

diffstat:

 include/inttypes.h         |  13 ++++++++++++-
 include/wchar.h            |  12 +++++++++++-
 lib/libc/locale/_wcstol.h  |  30 ++++++++++++++++++++++++++----
 lib/libc/locale/_wcstoul.h |  30 ++++++++++++++++++++++++++----
 4 files changed, 75 insertions(+), 10 deletions(-)

diffs (163 lines):

diff -r af466040689c -r 945b0ed3bd73 include/inttypes.h
--- a/include/inttypes.h        Tue Apr 16 15:50:57 2013 +0000
+++ b/include/inttypes.h        Tue Apr 16 16:52:13 2013 +0000
@@ -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 @@
 } 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_ */
diff -r af466040689c -r 945b0ed3bd73 include/wchar.h
--- a/include/wchar.h   Tue Apr 16 15:50:57 2013 +0000
+++ b/include/wchar.h   Tue Apr 16 16:52:13 2013 +0000
@@ -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 @@
 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
diff -r af466040689c -r 945b0ed3bd73 lib/libc/locale/_wcstol.h
--- a/lib/libc/locale/_wcstol.h Tue Apr 16 15:50:57 2013 +0000
+++ b/lib/libc/locale/_wcstol.h Tue Apr 16 16:52:13 2013 +0000
@@ -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 @@
        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 @@
                *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);
+}
diff -r af466040689c -r 945b0ed3bd73 lib/libc/locale/_wcstoul.h
--- a/lib/libc/locale/_wcstoul.h        Tue Apr 16 15:50:57 2013 +0000
+++ b/lib/libc/locale/_wcstoul.h        Tue Apr 16 16:52:13 2013 +0000
@@ -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 @@
        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 @@
                *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);
+}



Home | Main Index | Thread Index | Old Index