Source-Changes-HG archive

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

[src/trunk]: src Add strtol_l and friends. Switch _citrus_bcs_strtol to use p...



details:   https://anonhg.NetBSD.org/src/rev/c13e6c879d2e
branches:  trunk
changeset: 786136:c13e6c879d2e
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Apr 16 21:44:06 2013 +0000

description:
Add strtol_l and friends. Switch _citrus_bcs_strtol to use plain
strtol_l unless in tools mode. Add note to retire the BCS code on the
next libc major bump.

diffstat:

 common/lib/libc/stdlib/_strtol.h     |  36 ++++++++++++++++++++++++++++++++++--
 common/lib/libc/stdlib/_strtoul.h    |  36 ++++++++++++++++++++++++++++++++++--
 common/lib/libc/stdlib/strtoll.c     |   5 +++--
 common/lib/libc/stdlib/strtoull.c    |   5 +++--
 common/lib/libc/stdlib/strtoumax.c   |   5 +++--
 include/inttypes.h                   |   6 +++++-
 include/stdlib.h                     |  24 +++++++++++++++++++++++-
 lib/libc/citrus/citrus_bcs_strtol.c  |  31 +++++++++++--------------------
 lib/libc/citrus/citrus_bcs_strtoul.c |  30 +++++++++++-------------------
 lib/libc/include/namespace.h         |   6 +++++-
 lib/libc/shlib_version               |   3 ++-
 lib/libc/stdlib/strtoimax.c          |   3 ++-
 12 files changed, 136 insertions(+), 54 deletions(-)

diffs (truncated from 414 to 300 lines):

diff -r e5d420d83ea9 -r c13e6c879d2e common/lib/libc/stdlib/_strtol.h
--- a/common/lib/libc/stdlib/_strtol.h  Tue Apr 16 21:13:38 2013 +0000
+++ b/common/lib/libc/stdlib/_strtol.h  Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.4 2013/04/16 19:34:57 joerg Exp $ */
+/* $NetBSD: _strtol.h,v 1.5 2013/04/16 21:44:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -41,9 +41,19 @@
  *      __INT_MIN : lower limit of the return type
  *      __INT_MAX : upper limit of the return type
  */
-
+#if defined(_KERNEL) || defined(_STANDALONE) || defined(HAVE_NBTOOL_CONFIG_H)
 __INT
 _FUNCNAME(const char *nptr, char **endptr, int base)
+#else
+#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 char *nptr, char **endptr,
+                                  int base, locale_t loc)
+#endif
 {
        const char *s;
        __INT acc, cutoff;
@@ -72,9 +82,15 @@
         * assume decimal; if base is already 16, allow 0x.
         */
        s = nptr;
+#if defined(_KERNEL) || defined(_STANDALONE) || defined(HAVE_NBTOOL_CONFIG_H)
        do {
                c = *s++;
        } while (isspace(c));
+#else
+       do {
+               c = *s++;
+       } while (isspace_l(c, loc));
+#endif
        if (c == '-') {
                neg = 1;
                c = *s++;
@@ -169,3 +185,19 @@
                *endptr = __UNCONST(any ? s - 1 : nptr);
        return(acc);
 }
+
+#if !defined(_KERNEL) && !defined(_STANDALONE) && !defined(HAVE_NBTOOL_CONFIG_H)
+__INT
+_FUNCNAME(const char *nptr, char **endptr, int base)
+{
+       return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, *_current_locale());
+}
+
+__INT
+INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc)
+{
+       if (loc == NULL)
+               loc = _C_locale;
+       return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
+}
+#endif
diff -r e5d420d83ea9 -r c13e6c879d2e common/lib/libc/stdlib/_strtoul.h
--- a/common/lib/libc/stdlib/_strtoul.h Tue Apr 16 21:13:38 2013 +0000
+++ b/common/lib/libc/stdlib/_strtoul.h Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.4 2013/04/16 19:34:58 joerg Exp $ */
+/* $NetBSD: _strtoul.h,v 1.5 2013/04/16 21:44:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -40,9 +40,19 @@
  *      __UINT     : return type
  *      __UINT_MAX : upper limit of the return type
  */
-
+#if defined(_KERNEL) || defined(_STANDALONE) || defined(HAVE_NBTOOL_CONFIG_H)
 __UINT
 _FUNCNAME(const char *nptr, char **endptr, int base)
+#else
+#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 char *nptr, char **endptr,
+                                  int base, locale_t loc)
+#endif
 {
        const char *s;
        __UINT acc, cutoff;
@@ -68,9 +78,15 @@
         * assume decimal; if base is already 16, allow 0x.
         */
        s = nptr;
+#if defined(_KERNEL) || defined(_STANDALONE) || defined(HAVE_NBTOOL_CONFIG_H)
        do {
                c = *s++;
        } while (isspace(c));
+#else
+       do {
+               c = *s++;
+       } while (isspace_l(c, loc));
+#endif
        if (c == '-') {
                neg = 1;
                c = *s++;
@@ -128,3 +144,19 @@
                *endptr = __UNCONST(any ? s - 1 : nptr);
        return(acc);
 }
+
+#if !defined(_KERNEL) && !defined(_STANDALONE) && !defined(HAVE_NBTOOL_CONFIG_H)
+__UINT
+_FUNCNAME(const char *nptr, char **endptr, int base)
+{
+       return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, *_current_locale());
+}
+
+__UINT
+INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc)
+{
+       if (loc == NULL)
+               loc = _C_locale;
+       return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc);
+}
+#endif
diff -r e5d420d83ea9 -r c13e6c879d2e common/lib/libc/stdlib/strtoll.c
--- a/common/lib/libc/stdlib/strtoll.c  Tue Apr 16 21:13:38 2013 +0000
+++ b/common/lib/libc/stdlib/strtoll.c  Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoll.c,v 1.6 2008/08/22 03:00:02 matt Exp $ */
+/* $NetBSD: strtoll.c,v 1.7 2013/04/16 21:44:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
@@ -32,7 +32,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoll.c,v 1.6 2008/08/22 03:00:02 matt Exp $");
+__RCSID("$NetBSD: strtoll.c,v 1.7 2013/04/16 21:44:06 joerg Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -63,4 +63,5 @@
 
 #ifdef _LIBC
 __weak_alias(strtoll, _strtoll)
+__weak_alias(strtoll_l, _strtoll_l)
 #endif
diff -r e5d420d83ea9 -r c13e6c879d2e common/lib/libc/stdlib/strtoull.c
--- a/common/lib/libc/stdlib/strtoull.c Tue Apr 16 21:13:38 2013 +0000
+++ b/common/lib/libc/stdlib/strtoull.c Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoull.c,v 1.5 2008/09/10 18:08:58 joerg Exp $ */
+/* $NetBSD: strtoull.c,v 1.6 2013/04/16 21:44:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
@@ -32,7 +32,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoull.c,v 1.5 2008/09/10 18:08:58 joerg Exp $");
+__RCSID("$NetBSD: strtoull.c,v 1.6 2013/04/16 21:44:06 joerg Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -62,4 +62,5 @@
 
 #ifdef _LIBC
 __weak_alias(strtoull, _strtoull)
+__weak_alias(strtoull_l, _strtoull_l)
 #endif
diff -r e5d420d83ea9 -r c13e6c879d2e common/lib/libc/stdlib/strtoumax.c
--- a/common/lib/libc/stdlib/strtoumax.c        Tue Apr 16 21:13:38 2013 +0000
+++ b/common/lib/libc/stdlib/strtoumax.c        Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoumax.c,v 1.5 2008/09/10 18:08:58 joerg Exp $ */
+/* $NetBSD: strtoumax.c,v 1.6 2013/04/16 21:44:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
@@ -32,7 +32,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoumax.c,v 1.5 2008/09/10 18:08:58 joerg Exp $");
+__RCSID("$NetBSD: strtoumax.c,v 1.6 2013/04/16 21:44:06 joerg Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -63,4 +63,5 @@
 
 #ifdef _LIBC
 __weak_alias(strtoumax, _strtoumax)
+__weak_alias(strtoumax_l, _strtoumax_l)
 #endif
diff -r e5d420d83ea9 -r c13e6c879d2e include/inttypes.h
--- a/include/inttypes.h        Tue Apr 16 21:13:38 2013 +0000
+++ b/include/inttypes.h        Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inttypes.h,v 1.8 2013/04/16 16:52:13 joerg Exp $       */
+/*     $NetBSD: inttypes.h,v 1.9 2013/04/16 21:44:06 joerg Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -65,6 +65,10 @@
 typedef struct _locale         *locale_t;
 #  define __LOCALE_T_DECLARED
 #  endif
+intmax_t       strtoimax_l(const char * __restrict,
+                   char ** __restrict, int, locale_t);
+uintmax_t      strtoumax_l(const char * __restrict,
+                   char ** __restrict, int, locale_t);
 intmax_t       wcstoimax_l(const wchar_t * __restrict,
                    wchar_t ** __restrict, int, locale_t);
 uintmax_t      wcstoumax_l(const wchar_t * __restrict,
diff -r e5d420d83ea9 -r c13e6c879d2e include/stdlib.h
--- a/include/stdlib.h  Tue Apr 16 21:13:38 2013 +0000
+++ b/include/stdlib.h  Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdlib.h,v 1.100 2012/06/21 21:13:29 christos Exp $    */
+/*     $NetBSD: stdlib.h,v 1.101 2013/04/16 21:44:06 joerg Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -328,6 +328,28 @@
 #if defined(_NETBSD_SOURCE)
 qdiv_t  qdiv(quad_t, quad_t);
 #endif
+
+#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
+#  ifndef __LOCALE_T_DECLARED
+typedef struct _locale         *locale_t;
+#  define __LOCALE_T_DECLARED
+#  endif
+long    strtol_l(const char * __restrict, char ** __restrict, int, locale_t);
+unsigned long
+        strtoul_l(const char * __restrict, char ** __restrict, int, locale_t);
+/* LONGLONG */
+long long int
+       strtoll_l(const char * __restrict, char ** __restrict, int, locale_t);
+/* LONGLONG */
+unsigned long long int
+       strtoull_l(const char * __restrict, char ** __restrict, int, locale_t);
+
+#  if defined(_NETBSD_SOURCE)
+quad_t  strtoq_l(const char * __restrict, char ** __restrict, int, locale_t);
+u_quad_t strtouq_l(const char * __restrict, char ** __restrict, int, locale_t);
+#  endif
+#endif /* _POSIX_C_SOURCE >= 200809 || _NETBSD_SOURCE */
+
 __END_DECLS
 
 #endif /* !_STDLIB_H_ */
diff -r e5d420d83ea9 -r c13e6c879d2e lib/libc/citrus/citrus_bcs_strtol.c
--- a/lib/libc/citrus/citrus_bcs_strtol.c       Tue Apr 16 21:13:38 2013 +0000
+++ b/lib/libc/citrus/citrus_bcs_strtol.c       Tue Apr 16 21:44:06 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $ */
+/* $NetBSD: citrus_bcs_strtol.c,v 1.3 2013/04/16 21:44:07 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $");
+__RCSID("$NetBSD: citrus_bcs_strtol.c,v 1.3 2013/04/16 21:44:07 joerg Exp $");
 
 #include <assert.h>
 #include <errno.h>
@@ -39,21 +39,12 @@
 #include "citrus_namespace.h"
 #include "citrus_bcs.h"
 
-#define        _FUNCNAME       _bcs_strtol
-#define        __INT           long int
-#define        __INT_MIN       LONG_MIN
-#define        __INT_MAX       LONG_MAX
-
-#undef isspace
-#define isspace(c)     _bcs_isspace(c)
-
-#undef isdigit
-#define isdigit(c)     _bcs_isdigit(c)
-
-#undef isalpha
-#define isalpha(c)     _bcs_isalpha(c)
-
-#undef isupper
-#define isupper(c)     _bcs_isupper(c)



Home | Main Index | Thread Index | Old Index