Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src Pull up following revision(s) (requested by christos in t...
details: https://anonhg.NetBSD.org/src/rev/328754934b7d
branches: netbsd-7
changeset: 799341:328754934b7d
user: snj <snj%NetBSD.org@localhost>
date: Sat May 16 17:58:46 2015 +0000
description:
Pull up following revision(s) (requested by christos in ticket #781):
common/lib/libc/stdlib/strtoi.c: revision 1.2
common/lib/libc/stdlib/strtou.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.113
distrib/sets/lists/tests/mi: revision 1.617
lib/libc/include/namespace.h: revision 1.178
lib/libc/stdlib/Makefile.inc: revision 1.90 via patch
lib/libc/stdlib/strtoi.3: revisions 1.1, 1.2
lib/libc/stdlib/strtol.3: revision 1.32
lib/libc/stdlib/strtou.3: revisions 1.1, 1.2
lib/libc/stdlib/strtoul.3: revisions 1.30, 1.31
tests/lib/libc/stdlib/Makefile: revision 1.25
tests/lib/libc/stdlib/t_strtoi.c: revision 1.1
- new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
--
Sort ERRORS and SEE ALSO.
--
Sort ERRORS and SEE ALSO.
--
Sort SEE ALSO.
diffstat:
common/lib/libc/stdlib/strtoi.c | 13 +-
common/lib/libc/stdlib/strtou.c | 13 +-
distrib/sets/lists/debug/mi | 3 +-
distrib/sets/lists/tests/mi | 3 +-
lib/libc/include/namespace.h | 6 +-
lib/libc/stdlib/Makefile.inc | 6 +-
lib/libc/stdlib/strtoi.3 | 222 ++++++++++++++++++++++++++++
lib/libc/stdlib/strtol.3 | 99 +----------
lib/libc/stdlib/strtou.3 | 221 ++++++++++++++++++++++++++++
lib/libc/stdlib/strtoul.3 | 98 ++----------
tests/lib/libc/stdlib/Makefile | 3 +-
tests/lib/libc/stdlib/t_strtoi.c | 304 +++++++++++++++++++++++++++++++++++++++
12 files changed, 815 insertions(+), 176 deletions(-)
diffs (truncated from 1295 to 300 lines):
diff -r 690ec490391d -r 328754934b7d common/lib/libc/stdlib/strtoi.c
--- a/common/lib/libc/stdlib/strtoi.c Sat May 16 17:40:19 2015 +0000
+++ b/common/lib/libc/stdlib/strtoi.c Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoi.c,v 1.1.2.2 2015/04/22 07:18:57 snj Exp $ */
+/* $NetBSD: strtoi.c,v 1.1.2.3 2015/05/16 17:58:46 snj Exp $ */
/*-
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
@@ -35,7 +35,11 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoi.c,v 1.1.2.2 2015/04/22 07:18:57 snj Exp $");
+__RCSID("$NetBSD: strtoi.c,v 1.1.2.3 2015/05/16 17:58:46 snj Exp $");
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
#if defined(_KERNEL)
#include <sys/param.h>
@@ -57,6 +61,9 @@
#define __TYPE intmax_t
#define __WRAPPED strtoimax
-#if !HAVE_STRTOI
#include "_strtoi.h"
+
+#ifdef _LIBC
+__weak_alias(strtoi, _strtoi)
+__weak_alias(strtoi_l, _strtoi_l)
#endif
diff -r 690ec490391d -r 328754934b7d common/lib/libc/stdlib/strtou.c
--- a/common/lib/libc/stdlib/strtou.c Sat May 16 17:40:19 2015 +0000
+++ b/common/lib/libc/stdlib/strtou.c Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtou.c,v 1.1.2.2 2015/04/22 07:18:57 snj Exp $ */
+/* $NetBSD: strtou.c,v 1.1.2.3 2015/05/16 17:58:46 snj Exp $ */
/*-
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
@@ -35,7 +35,11 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strtou.c,v 1.1.2.2 2015/04/22 07:18:57 snj Exp $");
+__RCSID("$NetBSD: strtou.c,v 1.1.2.3 2015/05/16 17:58:46 snj Exp $");
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
#if defined(_KERNEL)
#include <sys/param.h>
@@ -57,6 +61,9 @@
#define __TYPE uintmax_t
#define __WRAPPED strtoumax
-#if !HAVE_STRTOU
#include "_strtoi.h"
+
+#ifdef _LIBC
+__weak_alias(strtou, _strtou)
+__weak_alias(strtou_l, _strtou_l)
#endif
diff -r 690ec490391d -r 328754934b7d distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Sat May 16 17:40:19 2015 +0000
+++ b/distrib/sets/lists/debug/mi Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.81.2.6 2015/04/30 06:07:32 riz Exp $
+# $NetBSD: mi,v 1.81.2.7 2015/05/16 17:58:46 snj Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib
@@ -1941,6 +1941,7 @@
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_posix_memalign.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_random.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_strtod.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_strtoi.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_strtol.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_strtox.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_system.debug tests-lib-debug debug,atf
diff -r 690ec490391d -r 328754934b7d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat May 16 17:40:19 2015 +0000
+++ b/distrib/sets/lists/tests/mi Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.584.2.1 2015/03/16 18:59:54 snj Exp $
+# $NetBSD: mi,v 1.584.2.2 2015/05/16 17:58:46 snj Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2599,6 +2599,7 @@
./usr/tests/lib/libc/stdlib/t_posix_memalign tests-lib-tests atf
./usr/tests/lib/libc/stdlib/t_random tests-lib-tests atf
./usr/tests/lib/libc/stdlib/t_strtod tests-lib-tests atf
+./usr/tests/lib/libc/stdlib/t_strtoi tests-lib-tests atf
./usr/tests/lib/libc/stdlib/t_strtol tests-lib-tests atf
./usr/tests/lib/libc/stdlib/t_strtox tests-obsolete obsolete
./usr/tests/lib/libc/stdlib/t_system tests-lib-tests atf
diff -r 690ec490391d -r 328754934b7d lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Sat May 16 17:40:19 2015 +0000
+++ b/lib/libc/include/namespace.h Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.174.2.1 2015/02/08 22:05:55 snj Exp $ */
+/* $NetBSD: namespace.h,v 1.174.2.2 2015/05/16 17:58:46 snj Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -65,12 +65,16 @@
#define strtod_l _strtod_l
#define strtof _strtof
#define strtof_l _strtof_l
+#define strtoi _strtoi
+#define strtoi_l _strtoi_l
#define strtoimax _strtoimax
#define strtoimax_l _strtoimax_l
#define strtold _strtold
#define strtold_l _strtold_l
#define strtoll _strtoll
#define strtoll_l _strtoll_l
+#define strtou _strtou
+#define strtou_l _strtou_l
#define strtoull _strtoull
#define strtoull_l _strtoull_l
#define strtoumax _strtoumax
diff -r 690ec490391d -r 328754934b7d lib/libc/stdlib/Makefile.inc
--- a/lib/libc/stdlib/Makefile.inc Sat May 16 17:40:19 2015 +0000
+++ b/lib/libc/stdlib/Makefile.inc Sat May 16 17:58:46 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.82.2.1 2015/04/22 07:18:58 snj Exp $
+# $NetBSD: Makefile.inc,v 1.82.2.2 2015/05/16 17:58:46 snj Exp $
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
# stdlib sources
@@ -51,7 +51,7 @@
posix_memalign.3 posix_openpt.3 ptsname.3 \
qabs.3 qdiv.3 quick_exit.3 qsort.3 \
radixsort.3 rand48.3 rand.3 random.3 \
- strfmon.3 strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 \
+ strfmon.3 strsuftoll.3 strtod.3 strtoi.3 strtol.3 strtou.3 strtoul.3 system.3 \
tsearch.3 \
unlockpt.3
@@ -85,9 +85,7 @@
MLINKS+=strtol.3 strtoimax.3
MLINKS+=strtol.3 strtoll.3
MLINKS+=strtol.3 strtoq.3
-MLINKS+=strtol.3 strtoi.3
MLINKS+=strtoul.3 strtoull.3
MLINKS+=strtoul.3 strtoumax.3
MLINKS+=strtoul.3 strtouq.3
-MLINKS+=strtoul.3 strtou.3
MLINKS+=tsearch.3 tfind.3 tsearch.3 twalk.3 tsearch.3 tdelete.3
diff -r 690ec490391d -r 328754934b7d lib/libc/stdlib/strtoi.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/strtoi.3 Sat May 16 17:58:46 2015 +0000
@@ -0,0 +1,222 @@
+.\" $NetBSD: strtoi.3,v 1.2.2.2 2015/05/16 17:58:46 snj Exp $
+.\"
+.\" Copyright (c) 1990, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Chris Torek and the American National Standards Committee X3,
+.\" on Information Processing Systems.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" from: @(#)strtol.3 8.1 (Berkeley) 6/4/93
+.\"
+.\" Created by Kamil Rytarowski, based on ID:
+.\" NetBSD: strtol.3,v 1.31 2015/03/11 09:57:35 wiz Exp
+.\"
+.Dd April 30, 2015
+.Dt STRTOI 3
+.Os
+.Sh NAME
+.Nm strtoi
+.Nd convert string value to an intmax_t integer
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In inttypes.h
+.Ft intmax_t
+.Fo strtoi
+.Fa "const char * restrict nptr"
+.Fa "char ** restrict endptr"
+.Fa "int base"
+.Fa "intmax_t lo"
+.Fa "intmax_t hi"
+.Fa "int *rstatus"
+.Sh DESCRIPTION
+The
+.Fn strtoi
+function
+converts the string in
+.Fa nptr
+to an
+.Ft intmax_t
+value.
+The
+.Fn strtoi
+function uses internally
+.Xr strtoimax 3
+and ensures that the result is always in the range [
+.Fa lo ..
+.Fa hi
+].
+In adddition it always places
+.Dv 0
+on success or a conversion status in the
+.Fa rstatus
+argument, avoiding the
+.Dv errno
+gymnastics the other functions require.
+The
+.Fa rstatus
+argument can be
+.Dv NULL
+if conversion status is to be ignored.
+.Pp
+The string may begin with an arbitrary amount of white space
+(as determined by
+.Xr isspace 3 )
+followed by a single optional
+.Ql +
+or
+.Ql -
+sign.
+If
+.Fa base
+is zero or 16,
+the string may then include a
+.Ql 0x
+prefix,
+and the number will be read in base 16; otherwise, a zero
+.Fa base
+is taken as 10 (decimal) unless the next character is
+.Ql 0 ,
+in which case it is taken as 8 (octal).
+.Pp
+The remainder of the string is converted to a
+.Em intmax_t
+value in the obvious manner,
+stopping at the first character which is not a valid digit
+in the given base.
+(In bases above 10, the letter
+.Ql A
+in either upper or lower case
+represents 10,
+.Ql B
+represents 11, and so forth, with
+.Ql Z
+representing 35.)
+.Pp
+If
+.Fa endptr
+is non-nil,
+.Fn strtoi
+stores the address of the first invalid character in
+.Fa *endptr .
+If there were no digits at all, however,
+.Fn strtoi
+stores the original value of
+.Fa nptr
+in
+.Fa *endptr .
+(Thus, if
+.Fa *nptr
+is not
+.Ql \e0
+but
+.Fa **endptr
+is
+.Ql \e0
+on return, the entire string was valid.)
+.Sh RETURN VALUES
Home |
Main Index |
Thread Index |
Old Index