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.
This commit is contained in:
parent
9c44086af0
commit
a67fde0356
|
@ -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 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
* 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 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
*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
|
||||
|
|
|
@ -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 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
* 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 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
*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
|
||||
|
|
|
@ -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 @@ __RCSID("$NetBSD: strtoll.c,v 1.6 2008/08/22 03:00:02 matt Exp $");
|
|||
|
||||
#ifdef _LIBC
|
||||
__weak_alias(strtoll, _strtoll)
|
||||
__weak_alias(strtoll_l, _strtoll_l)
|
||||
#endif
|
||||
|
|
|
@ -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 @@ __RCSID("$NetBSD: strtoull.c,v 1.5 2008/09/10 18:08:58 joerg Exp $");
|
|||
|
||||
#ifdef _LIBC
|
||||
__weak_alias(strtoull, _strtoull)
|
||||
__weak_alias(strtoull_l, _strtoull_l)
|
||||
#endif
|
||||
|
|
|
@ -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 @@ __RCSID("$NetBSD: strtoumax.c,v 1.5 2008/09/10 18:08:58 joerg Exp $");
|
|||
|
||||
#ifdef _LIBC
|
||||
__weak_alias(strtoumax, _strtoumax)
|
||||
__weak_alias(strtoumax_l, _strtoumax_l)
|
||||
#endif
|
||||
|
|
|
@ -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 @@ imaxdiv_t imaxdiv(intmax_t, intmax_t);
|
|||
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,
|
||||
|
|
|
@ -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 @@ size_t shquotev(int, char * const *, char *, size_t);
|
|||
#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_ */
|
||||
|
|
|
@ -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 @@ __RCSID("$NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $")
|
|||
#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)
|
||||
|
||||
#include "_strtol.h"
|
||||
long int
|
||||
_bcs_strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
|
||||
{
|
||||
#if defined(HAVE_NBTOOL_CONFIG_H)
|
||||
return strtol(nptr, endptr, base);
|
||||
#else
|
||||
return strtol_l(nptr, endptr, base, 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $ */
|
||||
/* $NetBSD: citrus_bcs_strtoul.c,v 1.4 2013/04/16 21:44:07 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $");
|
||||
__RCSID("$NetBSD: citrus_bcs_strtoul.c,v 1.4 2013/04/16 21:44:07 joerg Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -45,20 +45,12 @@ __RCSID("$NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $"
|
|||
#include "citrus_namespace.h"
|
||||
#include "citrus_bcs.h"
|
||||
|
||||
#define _FUNCNAME _bcs_strtoul
|
||||
#define __UINT unsigned long int
|
||||
#define __UINT_MAX ULONG_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)
|
||||
|
||||
#include "_strtoul.h"
|
||||
unsigned long int
|
||||
_bcs_strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
|
||||
{
|
||||
#if defined(HAVE_NBTOOL_CONFIG_H)
|
||||
return strtoul(nptr, endptr, base);
|
||||
#else
|
||||
return strtoul_l(nptr, endptr, base, 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: namespace.h,v 1.157 2013/04/16 11:39:13 joerg Exp $ */
|
||||
/* $NetBSD: namespace.h,v 1.158 2013/04/16 21:44:07 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
|
||||
|
@ -61,10 +61,14 @@
|
|||
#define strlcpy _strlcpy
|
||||
#define strtof _strtof
|
||||
#define strtoimax _strtoimax
|
||||
#define strtoimax_l _strtoimax_l
|
||||
#define strtold _strtold
|
||||
#define strtoll _strtoll
|
||||
#define strtoll_l _strtoll_l
|
||||
#define strtoull _strtoull
|
||||
#define strtoull_l _strtoull_l
|
||||
#define strtoumax _strtoumax
|
||||
#define strtoumax_l _strtoumax_l
|
||||
#define sys_errlist _sys_errlist
|
||||
#define sys_nerr _sys_nerr
|
||||
#define sys_siglist _sys_siglist
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# $NetBSD: shlib_version,v 1.239 2013/04/13 10:21:20 joerg Exp $
|
||||
# $NetBSD: shlib_version,v 1.240 2013/04/16 21:44:07 joerg Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# things we wish to do on next major version bump:
|
||||
# - remove code under BUILD_LEGACY
|
||||
# - remove BCS code in citrus and replace it with use of the C locale
|
||||
# - libc/net/rcmd.c: make __ivaliduser() and __ivaliduser_sa() static
|
||||
# - libc/net: resolver update to BIND8/9?
|
||||
# - md2, md4, md5, rmd160 & sha1 functions should take the same arguments AFAP
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: strtoimax.c,v 1.7 2008/09/10 18:08:58 joerg Exp $");
|
||||
__RCSID("$NetBSD: strtoimax.c,v 1.8 2013/04/16 21:44:08 joerg Exp $");
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
@ -50,3 +50,4 @@ __RCSID("$NetBSD: strtoimax.c,v 1.7 2008/09/10 18:08:58 joerg Exp $");
|
|||
#include "_strtol.h"
|
||||
|
||||
__strong_alias(_strtoimax, strtoimax)
|
||||
__strong_alias(_strtoimax_l, strtoimax_l)
|
||||
|
|
Loading…
Reference in New Issue