tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
strsuftoi(3), strsuftou(3) proposal in libc
I'm proposing adoption of a new functions in libc:
- strsuftoi(3),
- strsuftou(3),
- their _l counterparts.
Their are built over strtoi(3) and strtou(3), which are part of the
Standard C Library in NetBSD-7.0. The only difference between *i and *u
functions is operating over signed or unsigned values.
These functions take exactly the same arguments as strtoi(3) and
strtou(3), just they return different status values and they can handle
multiplication of products in nptr.
intmax_t
strsuftoi(const char * restrict nptr, char ** restrict endptr, int base,
intmax_t lo, intmax_t hi, int *rstatus);
The strsuftoi() function converts the string in nptr to an intmax_t
value. Two or more numbers may be separated by an ``x'' or ``*'' to
indicate a product.
Each number may have one of the following optional suffixes:
b Block; multiply by 512
k Kibi; multiply by 1024 (1 KiB)
m Mebi; multiply by 1048576 (1 MiB)
g Gibi; multiply by 1073741824 (1 GiB)
t Tebi; multiply by 1099511627776 (1 TiB)
p Pebi; multiply by 1125899906842624 (1 PiB)
e Exbi; multiply by 1152921504606846976 (1 EiB)
w Word; multiply by the number of bytes in an integer
-- strsuftoi(3)
There is one homegrown function with the same name (strsuftoi()) in
ftp(1), used to parse commands.
Commands which take a byte count as an argument (e.g., hash, rate, and
xferbuf) support an optional suffix on the argument which changes the
interpretation of the argument. Supported suffixes are:
b Causes no modification. (Optional)
k Kilo; multiply the argument by 1024
m Mega; multiply the argument by 1048576
g Giga; multiply the argument by 1073741824
-- ftp(1)
There is already strsuftoll(3) (it even calls exit internally) and
strsuftollx(3). New functions are aimed to replace them and address the
issues mentioned in the strsuftoi(3) manpage:
The strsuftoi() function first appeared in NetBSD 8. The strsuftoll(3)
function was introduced in NetBSD 2 for the same purpose, but the
interface makes it impossible to use safely and differentiate illegal
returns. The strsuftoi() functions is intentionally based on strtoi(3)
to extend its features and fix the following problems of strsuftoll(3):
o Stop ignoring locale.
o Fail gracefully in case of invalid input data.
o Return intmax_t instead of long long.
o Stop being prone to buffer overflows when used incorrectly.
o Stop returning English strings.
o Stop calling exit(3) in case of invalid string.
-- strsuftoi(3)
strsuftoll(3) and strsuftollx(3) are used in:
- dd(1),
- makefs(8),
- fssconfig(8),
- vndcompress(1),
- progress(1),
- midirecord(1),
- audioplay(1), audiorecord(1),
- tunefs(8),
- ftp(1).
There are homegrown functions for the strsuftoi(3) functionality (called
strsuftoi64()) to handle suffixes:
Options with numeric arguments may contain an optional (case-insensitive)
suffix:
b Bytes; causes no modification. (Default)
k Kilo; multiply the argument by 1024.
m Mega; multiply the argument by 1048576.
g Giga; multiply the argument by 1073741824.
t Tera; multiply the argument by 1099511627776.
-- newfs(8)
Our tool login.conf(5) has homegrown functionality for the same purpose:
size A number which expresses a size in bytes. It may have a
trailing b to multiply the value by 512, a k to multiply the
value by 1 K (1024), and a m to multiply the value by 1 M
(1048576).
-- login.conf(5)
There is undocumented support for g (giga) and t (tera) in the source code.
The code checking for overflows in multiplication is quite complicated,
I'm attaching just the comments to follow the algorithm:
/*
* Get rid of the simple cases
*/
/*
* sizeof() returns number of bytes needed for storage.
* This may be different from the actual number of useful bits.
*/
/*
* First check the magnitude of each number. If the sum of the
* magnatude is way to high, reject the number. (If this test
* is not done then the first multiply below may overflow.)
*/
/*
* Decompose the multiplication to be:
* h1 = n1 & ~1
* h2 = n2 &~1
* l1 = n1 & 1
* l2 = n2 & 1
* (h1 + l1) * (h2 + l2)
* (h1 * h2) + (h1 * l2) + (l1 * h2) + (l1 * l2)
*
* Since h1 && h2 do not have the low bit set, we can then say:
*
* (h1>>1 * h2>>1 * 4) + ...
*
* So if (h1>>1 * h2>>1) > (1<<(bpw - 2)) then the result will
* overflow.
*
* Finally, if MAX - ((h1 * l2) + (l1 * h2) + (l1 * l2))<(h1*h2)
* then adding in residual amout will cause an overflow.
*/
-- src/lib/libutil/login_cap.c
I'm attaching a patch for review adding strsuftoi(3) and strsuftou(3).
This patch requires immediate switch in ftp(1) (or rename local
homegrown strsuftoi() to something else..).
Things not to be discussed:
1. Whether string like '123x 123' is legal or not. Traditionally we
strip whitespace from the beginning of strtol(3) like functions. '123
x123' isn't fully converted string, while '123x 123' is. I was thinking
about making only initial whitespace to the whole input (like '
123x123') legal.
2. Streamline 'b' meaning, change from nothing/dummy argument to block
size (512 bytes).
3. Accept uppercase and lowercase multiplication types (for
compatibility with existing software and orders)?
I don't see need for these functions in kernel or libstand, if you think
it might be usable, please let me know and I will move it to src/common.
estrsuftoi(3) and estrsuftou(3) will come with a next patch. Later I
will propose a patch to switch our tools, one after another.
At the end, I would like to obsolete strsuftoll(3) and strsuftollx(3)
entirely.
Originally, I had overflow library ideas, to be used by reallocarr(3)
and strsuftoi(3) functions, however this isn't implementable without GCC
or C11 compatible compiler. I'm adding a wild assumption in my
implementation towards positive and negative values representation - I
stripped the case of abs(type_min_value) = abs(type_max_value). It may
be enforced by POSIX anyway.
Index: distrib/sets/lists/comp/mi
===================================================================
RCS file: /public/netbsd-rsync/src/distrib/sets/lists/comp/mi,v
retrieving revision 1.1999
diff -u -r1.1999 mi
--- distrib/sets/lists/comp/mi 26 Oct 2015 07:07:36 -0000 1.1999
+++ distrib/sets/lists/comp/mi 28 Oct 2015 23:15:47 -0000
@@ -8832,8 +8832,10 @@
./usr/share/man/cat3/strspct.0 comp-c-catman .cat
./usr/share/man/cat3/strspn.0 comp-c-catman .cat
./usr/share/man/cat3/strstr.0 comp-c-catman .cat
+./usr/share/man/cat3/strsuftoi.0 comp-c-catman .cat
./usr/share/man/cat3/strsuftoll.0 comp-c-catman .cat
./usr/share/man/cat3/strsuftollx.0 comp-c-catman .cat
+./usr/share/man/cat3/strsuftou.0 comp-c-catman .cat
./usr/share/man/cat3/strsvis.0 comp-c-catman .cat
./usr/share/man/cat3/strsvisx.0 comp-c-catman .cat
./usr/share/man/cat3/strtod.0 comp-c-catman .cat
@@ -15716,8 +15718,10 @@
./usr/share/man/html3/strspct.html comp-c-htmlman html
./usr/share/man/html3/strspn.html comp-c-htmlman html
./usr/share/man/html3/strstr.html comp-c-htmlman html
+./usr/share/man/html3/strsuftoi.html comp-c-htmlman html
./usr/share/man/html3/strsuftoll.html comp-c-htmlman html
./usr/share/man/html3/strsuftollx.html comp-c-htmlman html
+./usr/share/man/html3/strsuftou.html comp-c-htmlman html
./usr/share/man/html3/strsvis.html comp-c-htmlman html
./usr/share/man/html3/strsvisx.html comp-c-htmlman html
./usr/share/man/html3/strtod.html comp-c-htmlman html
@@ -22633,8 +22637,10 @@
./usr/share/man/man3/strspct.3 comp-c-man .man
./usr/share/man/man3/strspn.3 comp-c-man .man
./usr/share/man/man3/strstr.3 comp-c-man .man
+./usr/share/man/man3/strsuftoi.3 comp-c-man .man
./usr/share/man/man3/strsuftoll.3 comp-c-man .man
./usr/share/man/man3/strsuftollx.3 comp-c-man .man
+./usr/share/man/man3/strsuftou.3 comp-c-man .man
./usr/share/man/man3/strsvis.3 comp-c-man .man
./usr/share/man/man3/strsvisx.3 comp-c-man .man
./usr/share/man/man3/strtod.3 comp-c-man .man
Index: include/inttypes.h
===================================================================
RCS file: /public/netbsd-rsync/src/include/inttypes.h,v
retrieving revision 1.11
diff -u -r1.11 inttypes.h
--- include/inttypes.h 16 Jan 2015 18:35:59 -0000 1.11
+++ include/inttypes.h 28 Oct 2015 23:13:50 -0000
@@ -88,6 +88,18 @@
intmax_t, intmax_t, int *, locale_t);
uintmax_t strtou_l(const char * __restrict, char ** __restrict, int,
uintmax_t, uintmax_t, int *, locale_t);
+
+/* strsuftoi(3) family of functions */
+intmax_t strsuftoi(const char * __restrict, char ** __restrict, int,
+ intmax_t, intmax_t, int *);
+uintmax_t strsuftou(const char * __restrict, char ** __restrict, int,
+ uintmax_t, uintmax_t, int *);
+
+/* i18n variations */
+intmax_t strsuftoi_l(const char * __restrict, char ** __restrict, int,
+ intmax_t, intmax_t, int *, locale_t);
+uintmax_t strsuftou_l(const char * __restrict, char ** __restrict, int,
+ uintmax_t, uintmax_t, int *, locale_t);
#endif /* defined(_NETBSD_SOURCE) */
__END_DECLS
Index: lib/libc/include/namespace.h
===================================================================
RCS file: /public/netbsd-rsync/src/lib/libc/include/namespace.h,v
retrieving revision 1.179
diff -u -r1.179 namespace.h
--- lib/libc/include/namespace.h 10 Sep 2015 14:05:06 -0000 1.179
+++ lib/libc/include/namespace.h 28 Oct 2015 23:57:24 -0000
@@ -647,8 +647,12 @@
#define strptime_l _strptime_l
#define strsep _strsep
#define strsignal _strsignal
+#define strsuftoi _strsuftoi
+#define strsuftoi_l _strsuftoi_l
#define strsuftoll _strsuftoll
#define strsuftollx _strsuftollx
+#define strsuftou _strsuftou
+#define strsuftou_l _strsuftou_l
#define strtok_r _strtok_r
#define strnunvisx _strnunvisx
#define strvisx _strvisx
Index: lib/libc/stdlib/Makefile.inc
===================================================================
RCS file: /public/netbsd-rsync/src/lib/libc/stdlib/Makefile.inc,v
retrieving revision 1.90
diff -u -r1.90 Makefile.inc
--- lib/libc/stdlib/Makefile.inc 1 May 2015 14:17:56 -0000 1.90
+++ lib/libc/stdlib/Makefile.inc 28 Oct 2015 23:12:11 -0000
@@ -13,6 +13,7 @@
nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \
quick_exit.c radixsort.c rand.c rand_r.c random.c remque.c \
reallocarr.c reallocarray.c seed48.c setenv.c srand48.c strsuftoll.c \
+ strsuftoi.c strsuftou.c \
strtoi.c strtou.c strtonum.c \
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
@@ -54,6 +55,7 @@
qabs.3 qdiv.3 quick_exit.3 qsort.3 \
radixsort.3 rand48.3 rand.3 random.3 reallocarr.3 reallocarray.3 \
strfmon.3 strsuftoll.3 strtod.3 strtoi.3 strtol.3 strtou.3 strtoul.3 \
+ strsuftoi.3 strsuftou.3 \
strtonum.3 system.3 \
tsearch.3 \
unlockpt.3
Index: lib/libc/stdlib/_strsuftoi.h
===================================================================
RCS file: lib/libc/stdlib/_strsuftoi.h
diff -N lib/libc/stdlib/_strsuftoi.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/libc/stdlib/_strsuftoi.h 28 Oct 2015 20:24:39 -0000
@@ -0,0 +1,264 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * Original version ID:
+ * NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/_strtoul.h,v 1.7 2013/05/17 12:55:56 joerg Exp
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/_strtoi.h,v 1.2 2015/01/18 17:55:22 christos Exp
+ */
+
+/*
+ * function template for strsuftoi and strsuftou
+ *
+ * parameters:
+ * _FUNCNAME : function name
+ * __TYPE : return and range limits type
+ * __TYPE_MAX : maximal possible value of __TYPE
+ * __TYPE_MIN : minimal possible value of __TYPE
+ * __WRAPPED : wrapped function, strtoimax or strtoumax
+ */
+
+#define __WRAPPED_L_(x) x ## _l
+#define __WRAPPED_L__(x) __WRAPPED_L_(x)
+#define __WRAPPED_L __WRAPPED_L__(__WRAPPED)
+
+
+/* According to the C standard
+ * INTMAX_MIN Minimum value of intmax_t -(2**63-1), or lower
+ * INTMAX_MAX Maximum value of intmax_t 2**63-1, or higher */
+
+#define STRSUFTO_SIZE_BLOCK 512
+#define STRSUFTO_SIZE_KIB ((__TYPE)1024) /* 2**10 */
+#define STRSUFTO_SIZE_MIB ((__TYPE)1024 * STRSUFTO_SIZE_KIB) /* 2**20 */
+#define STRSUFTO_SIZE_GIB ((__TYPE)1024 * STRSUFTO_SIZE_MIB) /* 2**30 */
+#define STRSUFTO_SIZE_TIB ((__TYPE)1024 * STRSUFTO_SIZE_GIB) /* 2**40 */
+#define STRSUFTO_SIZE_PIB ((__TYPE)1024 * STRSUFTO_SIZE_TIB) /* 2**50 */
+#define STRSUFTO_SIZE_EIB ((__TYPE)1024 * STRSUFTO_SIZE_PIB) /* 2**60 */
+#define STRSUFTO_SIZE_WORD sizeof(int)
+#define STRSUFTO_RECURSION_LIMIT 16
+
+/* Helper function for overflow check */
+static __inline int overflow_mul(__TYPE * r, __TYPE b)
+{
+ __TYPE a = *r;
+
+#if (__TYPE_MIN < 0) /* signed type path */
+ if (a < 0 && b < 0) {
+ if (a == __TYPE_MIN || b == __TYPE_MIN)
+ return 1;
+
+ *r *= -1;
+ return overflow_mul(r, -b);
+ }
+
+ if ((a > 0 && b > 0) && (a > __TYPE_MAX / b))
+ return 1;
+
+ if ((a < 0 && b > 0) && (a < __TYPE_MIN / b))
+ return 1;
+
+ if ((a > 0 && b < 0) && (b < __TYPE_MIN / a))
+ return 1;
+
+ *r = a * b;
+ return 0;
+#else /* unsigned type path */
+ if (b != 0 && a > __TYPE_MAX / b)
+ return 1;
+
+ *r = a * b;
+ return 0;
+#endif
+}
+
+#if defined(HAVE_NBTOOL_CONFIG_H)
+__TYPE
+_FUNCNAME(const char * __restrict nptr, char ** __restrict endptr, int base,
+ __TYPE lo, __TYPE hi, int * rstatus)
+#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 __TYPE
+INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char * __restrict nptr,
+ char ** __restrict endptr, int base,
+ __TYPE lo, __TYPE hi, int * rstatus, locale_t loc)
+#endif
+{
+ __TYPE im = 1;
+ __TYPE rv;
+ int e;
+ char *ep;
+ int rep;
+ int depth = 0;
+
+ _DIAGASSERT(hi >= lo);
+
+ _DIAGASSERT(nptr != NULL);
+ /* endptr may be NULL */
+
+ if (endptr == NULL)
+ endptr = &ep;
+
+ if (rstatus == NULL)
+ rstatus = &rep;
+
+ do {
+#if defined(HAVE_NBTOOL_CONFIG_H)
+ rv = __WRAPPED(nptr, endptr, base, __TYPE_MIN, __TYPE_MAX, &e);
+#else
+ rv = __WRAPPED_L(nptr, endptr, base, __TYPE_MIN, __TYPE_MAX,
+ &e, loc);
+#endif
+ if(overflow_mul(&im, rv))
+ e = ERANGE;
+
+ *rstatus = e;
+ if (e == 0 || e != ENOTSUP)
+ break;
+
+ /* Handle optional multiplication suffix */
+ if (**endptr == 'b') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_BLOCK)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'k') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_KIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'm') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_MIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'g') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_GIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 't') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_TIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'p') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_PIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'e') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_EIB)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ } else if (**endptr == 'w') {
+ if (overflow_mul(&im, STRSUFTO_SIZE_WORD)) {
+ *rstatus = ERANGE;
+ break;
+ }
+ ++(*endptr);
+ }
+
+ /* Are we done with the string? */
+ if (**endptr == '\0') {
+ *rstatus = 0;
+ break;
+ }
+
+ /* Chech whether we are at the product separator */
+ if (**endptr != 'x' && **endptr != '*')
+ break;
+
+ /* Check if there is anything after the separator */
+ if (*((*endptr) + 1) == '\0')
+ break;
+
+ /* Check the limit of allowed products */
+ if (++depth > STRSUFTO_RECURSION_LIMIT) {
+ *rstatus = E2BIG;
+ break;
+ }
+
+ /* Move the cursor awaiting the next product */
+ ++(*endptr);
+ nptr = *endptr;
+ } while (1);
+
+ if (*rstatus == ECANCELED && depth > 0)
+ *rstatus = ENOTSUP;
+
+ if (im < lo) {
+ if (*rstatus == 0)
+ *rstatus = ERANGE;
+ return lo;
+ }
+
+ if (im > hi) {
+ if (*rstatus == 0)
+ *rstatus = ERANGE;
+ return hi;
+ }
+
+ return im;
+}
+
+#if !defined(HAVE_NBTOOL_CONFIG_H)
+__TYPE
+_FUNCNAME(const char * __restrict nptr, char ** __restrict endptr, int base,
+ __TYPE lo, __TYPE hi, int * rstatus)
+{
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, lo, hi,
+ rstatus, _current_locale());
+}
+
+__TYPE
+INT_FUNCNAME(, _FUNCNAME, _l)(const char * __restrict nptr,
+ char ** __restrict endptr, int base,
+ __TYPE lo, __TYPE hi, int * rstatus, locale_t loc)
+{
+ return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, lo, hi,
+ rstatus, loc);
+}
+#endif
Index: lib/libc/stdlib/strsuftoi.3
===================================================================
RCS file: lib/libc/stdlib/strsuftoi.3
diff -N lib/libc/stdlib/strsuftoi.3
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/libc/stdlib/strsuftoi.3 28 Oct 2015 23:09:42 -0000
@@ -0,0 +1,304 @@
+.\" $NetBSD$
+.\"
+.\" 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
+.\"
+.\" Created by Kamil Rytarowski, based on ID:
+.\" NetBSD: strtoi.3,v 1.3 2015/07/11 15:50:56 wiz Exp
+.\"
+.Dd August 1, 2015
+.Dt STRSUFTOI 3
+.Os
+.Sh NAME
+.Nm strsuftoi
+.Nd convert string value to an intmax_t integer,
+with suffix and multiplication parsing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In inttypes.h
+.Ft intmax_t
+.Fo strsuftoi
+.Fa "const char * restrict nptr"
+.Fa "char ** restrict endptr"
+.Fa "int base"
+.Fa "intmax_t lo"
+.Fa "intmax_t hi"
+.Fa "int *rstatus"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn strsuftoi
+function converts the string in
+.Fa nptr
+to an
+.Ft intmax_t
+value.
+Two or more numbers may be separated by an
+.Dq x
+or
+.Dq *
+to indicate a product.
+.Pp
+Each number may have one of the following optional suffixes:
+.Pp
+.Bl -tag -width 3n -offset indent -compact
+.It Em b
+Block; multiply by 512
+.It Em k
+Kibi; multiply by 1024 (1 KiB)
+.It Em m
+Mebi; multiply by 1048576 (1 MiB)
+.It Em g
+Gibi; multiply by 1073741824 (1 GiB)
+.It Em t
+Tebi; multiply by 1099511627776 (1 TiB)
+.It Em p
+Pebi; multiply by 1125899906842624 (1 PiB)
+.It Em e
+Exbi; multiply by 1152921504606846976 (1 EiB)
+.It Em w
+Word; multiply by the number of bytes in an integer
+.El
+.Pp
+The
+.Fn strsuftoi
+function uses internally
+.Xr strtoi 3
+and ensures that the final 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
+Each product 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 product is converted to an
+.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
+The product separator cannot begin with an arbitrary amount of white space
+(as determined by
+.Xr isspace 3 ) .
+Another restriction to the product seprator is that,
+it cannot be placed before the first product or after the last one,
+because as the result it will be unparsed.
+The maximum number of handled products is arbitrarily set to 16.
+.Pp
+If a letter represents a valid number and an optional multiplication suffix
+in the given base, then it's interpreted as the number.
+The same rule applies to the
+.Dq x
+multiplication symbol.
+In the case of the
+.Ql 0x
+ambiguity (the base 16 prefix or the multiplication symbol),
+the characters are interpreted as the hexadecimal base.
+For this use-case there is provided the
+.Dq *
+symbol and the optional suffix should be replaced with the appropriate number
+of bytes.
+.Pp
+If
+.Fa endptr
+is non-nil,
+.Fn strsuftoi
+stores the address of the first invalid character in
+.Fa *endptr .
+If there were no digits at all, however,
+.Fn strsuftoi
+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
+The
+.Fn strsuftoi
+function
+always returns the closest value in the range specified by
+the
+.Fa lo
+and
+.Fa hi
+arguments.
+.Pp
+The
+.Va errno
+value is guaranteed to be left unchanged.
+.Pp
+Errors are stored as the conversion status in the
+.Fa rstatus
+argument.
+.Sh EXAMPLES
+The following example will always return a number in
+.Dv [1..99]
+range no matter what the input is, and warn if the conversion failed.
+.Bd -literal -offset indent
+int e;
+intmax_t lval = strsuftoi(buf, NULL, 0, 1, 99, &e);
+if (e)
+ warnc(e, "conversion of `%s' to a number failed, using %jd",
+ buf, lval);
+.Ed
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er ECANCELED
+The string did not contain any characters that were converted.
+.It Bq Er EINVAL
+The
+.Ar base
+is not between 2 and 36 and does not contain the special value 0.
+.It Bq Er ENOTSUP
+The string contained non-numeric characters that did not get converted.
+In this case,
+.Fa endptr
+points to the first unconverted character.
+.It Bq Er ERANGE
+The given string was out of range; the value converted has been clamped;
+or the range given was invalid, i.e.
+.Fa lo
+\*[Gt]
+.Fa hi .
+.It Bq Er E2BIG
+Too many products (>16).
+.El
+.Sh SEE ALSO
+.Xr atof 3 ,
+.Xr atoi 3 ,
+.Xr atol 3 ,
+.Xr atoll 3 ,
+.Xr strsuftou 3 ,
+.Xr strtod 3 ,
+.Xr strtoi 3 ,
+.Xr strtoimax 3 ,
+.Xr strtol 3 ,
+.Xr strtoll 3 ,
+.Xr strtou 3 ,
+.Xr strtoul 3 ,
+.Xr strtoull 3 ,
+.Xr strtoumax 3
+.Sh STANDARDS
+The
+.Fn strsuftoi
+function is a
+.Nx
+extension.
+.Sh HISTORY
+The
+.Fn strsuftoi
+function first appeared in
+.Nx 8 .
+The
+.Xr strsuftoll 3
+function was introduced in
+.Nx 2
+for the same purpose, but the interface makes it impossible to use safely
+and differentiate illegal returns.
+The
+.Fn strsuftoi
+functions is intentionally based on
+.Xr strtoi 3
+to extend its features and fix the following problems of
+.Xr strsuftoll 3 :
+.Bl -bullet
+.It
+Stop ignoring locale.
+.It
+Fail gracefully in case of invalid input data.
+.It
+Return
+.Vt intmax_t
+instead of
+.Vt long long .
+.It
+Stop being prone to buffer overflows when used incorrectly.
+.It
+Stop returning English strings.
+.It
+Stop calling
+.Xr exit 1
+in case of invalid string.
+.El
+.Sh BUGS
+Ignores the current locale.
Index: lib/libc/stdlib/strsuftoi.c
===================================================================
RCS file: lib/libc/stdlib/strsuftoi.c
diff -N lib/libc/stdlib/strsuftoi.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/libc/stdlib/strsuftoi.c 28 Oct 2015 20:24:47 -0000
@@ -0,0 +1,63 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2005 The DragonFly Project. All rights reserved.
+ * Copyright (c) 2003 Citrus Project,
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/strtoi.c,v 1.2 2015/05/01 14:17:56 christos Exp
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+
+#include <stddef.h>
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#define _FUNCNAME strsuftoi
+#define __TYPE intmax_t
+#define __TYPE_MAX INTMAX_MAX
+#define __TYPE_MIN INTMAX_MIN
+#define __WRAPPED strtoi
+
+#include "_strsuftoi.h"
+
+#ifdef _LIBC
+__weak_alias(strsuftoi, _strsuftoi)
+__weak_alias(strsuftoi_l, _strsuftoi_l)
+#endif
Index: lib/libc/stdlib/strsuftou.3
===================================================================
RCS file: lib/libc/stdlib/strsuftou.3
diff -N lib/libc/stdlib/strsuftou.3
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/libc/stdlib/strsuftou.3 28 Oct 2015 23:09:48 -0000
@@ -0,0 +1,305 @@
+.\" $NetBSD: strtou.3,v 1.3 2015/07/11 15:51:33 wiz 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: @(#)strtoul.3 8.1 (Berkeley) 6/4/93
+.\"
+.\" Created by Kamil Rytarowski, based on ID:
+.\" NetBSD: strtoul.3,v 1.29 2015/03/10 13:00:58 christos Exp
+.\"
+.\" Created by Kamil Rytarowski, based on ID:
+.\" NetBSD: strtou.3,v 1.3 2015/07/11 15:51:33 wiz Exp
+.\"
+.Dd August 1, 2015
+.Dt STRSUFTOU 3
+.Os
+.Sh NAME
+.Nm strsuftou
+.Nd convert a string to an uintmax_t integer,
+with suffix and multiplication parsing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In inttypes.h
+.Ft uintmax_t
+.Fo strsuftou
+.Fa "const char * restrict nptr"
+.Fa "char ** restrict endptr"
+.Fa "int base"
+.Fa "uintmax_t lo"
+.Fa "uintmax_t hi"
+.Fa "int *rstatus"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn strsuftou
+function converts the string in
+.Fa nptr
+to an
+.Ft uintmax_t
+value.
+Two or more numbers may be separated by an
+.Dq x
+or
+.Dq *
+to indicate a product.
+.Pp
+Each number may have one of the following optional suffixes:
+.Pp
+.Bl -tag -width 3n -offset indent -compact
+.It Em b
+Block; multiply by 512
+.It Em k
+Kibi; multiply by 1024 (1 KiB)
+.It Em m
+Mebi; multiply by 1048576 (1 MiB)
+.It Em g
+Gibi; multiply by 1073741824 (1 GiB)
+.It Em t
+Tebi; multiply by 1099511627776 (1 TiB)
+.It Em p
+Pebi; multiply by 1125899906842624 (1 PiB)
+.It Em e
+Exbi; multiply by 1152921504606846976 (1 EiB)
+.It Em w
+Word; multiply by the number of bytes in an integer
+.El
+.Pp
+The
+.Fn strsuftou
+function uses internally
+.Xr strtou 3
+and ensures that the final 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
+Each product 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 product is converted to an
+.Em uintmax_t
+value in the obvious manner,
+stopping at the end of the string
+or at the first character that does not produce 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
+The product separator cannot begin with an arbitrary amount of white space
+(as determined by
+.Xr isspace 3 ) .
+Another restriction to the product seprator is that,
+it cannot be placed before the first product or after the last one,
+because as the result it will be unparsed.
+The maximum number of handled products is arbitrarily set to 16.
+.Pp
+If a letter represents a valid number and an optional multiplication suffix
+in the given base, then it's interpreted as the number.
+The same rule applies to the
+.Dq x
+multiplication symbol.
+In the case of the
+.Ql 0x
+ambiguity (the base 16 prefix or the multiplication symbol),
+the characters are interpreted as the hexadecimal base.
+For this use-case there is provided the
+.Dq *
+symbol and the optional suffix should be replaced with the appropriate number
+of bytes.
+.Pp
+If
+.Fa endptr
+is non-nil,
+.Fn strsuftou
+stores the address of the first invalid character in
+.Fa *endptr .
+If there were no digits at all, however,
+.Fn strsuftou
+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
+The
+.Fn strsuftou
+function
+always returns the closest value in the range specified by
+the
+.Fa lo
+and
+.Fa hi
+arguments.
+.Pp
+The
+.Va errno
+value is guaranteed to be left unchanged.
+.Pp
+Errors are stored as the conversion status in the
+.Fa rstatus
+argument.
+.Sh EXAMPLES
+The following example will always return a number in
+.Dv [1..99]
+range no matter what the input is, and warn if the conversion failed.
+.Bd -literal -offset indent
+int e;
+uintmax_t lval = strsuftou(buf, NULL, 0, 1, 99, &e);
+if (e)
+ warnc(e, "conversion of `%s' to a number failed, using %ju",
+ buf, lval);
+.Ed
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er ECANCELED
+The string did not contain any characters that were converted.
+.It Bq Er EINVAL
+The
+.Ar base
+is not between 2 and 36 and does not contain the special value 0.
+.It Bq Er ENOTSUP
+The string contained non-numeric characters that did not get converted.
+In this case,
+.Fa endptr
+points to the first unconverted character.
+.It Bq Er ERANGE
+The given string was out of range; the value converted has been clamped; or
+the range given was invalid, i.e.
+.Fa lo
+\*[Gt]
+.Fa hi .
+.It Bq Er E2BIG
+Too many products (>16).
+.El
+.Sh SEE ALSO
+.Xr atof 3 ,
+.Xr atoi 3 ,
+.Xr atol 3 ,
+.Xr atoll 3 ,
+.Xr strsuftoi 3 ,
+.Xr strtod 3 ,
+.Xr strtoi 3 ,
+.Xr strtoimax 3 ,
+.Xr strtol 3 ,
+.Xr strtoll 3 ,
+.Xr strtou 3 ,
+.Xr strtoul 3 ,
+.Xr strtoull 3 ,
+.Xr strtoumax 3
+.Sh STANDARDS
+The
+.Fn strsuftou
+function is a
+.Nx
+extension.
+.Sh HISTORY
+The
+.Fn strtou
+function first appeared in
+.Nx 7 .
+The
+.Xr strsuftoll 3
+function was introduced in
+.Nx 2
+for the same purpose, but the interface makes it impossible to use safely
+and differentiate illegal returns.
+The
+.Fn strsuftou
+function is intentionally based on
+.Xr strtou 3
+to extend its features and fix the following problems of
+.Xr strsuftoll 3 :
+.Bl -bullet
+.It
+Stop ignoring locale.
+.It
+Fail gracefully in case of invalid input data.
+.It
+Return
+.Vt uintmax_t
+instead of
+.Vt long long .
+.It
+Stop being prone to buffer overflows when used incorrectly.
+.It
+Stop returning English strings.
+.It
+Stop calling
+.Xr exit 1
+in case of invalid string.
+.El
+.Sh BUGS
+Ignores the current locale.
Index: lib/libc/stdlib/strsuftou.c
===================================================================
RCS file: lib/libc/stdlib/strsuftou.c
diff -N lib/libc/stdlib/strsuftou.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/libc/stdlib/strsuftou.c 28 Oct 2015 20:24:50 -0000
@@ -0,0 +1,63 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2005 The DragonFly Project. All rights reserved.
+ * Copyright (c) 2003 Citrus Project,
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp
+ *
+ * Created by Kamil Rytarowski, based on ID:
+ * NetBSD: src/common/lib/libc/stdlib/strtou.c,v 1.2 2015/05/01 14:17:56 christos Exp
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+
+#include <stddef.h>
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#define _FUNCNAME strsuftou
+#define __TYPE uintmax_t
+#define __TYPE_MAX UINTMAX_MAX
+#define __TYPE_MIN 0
+#define __WRAPPED strtou
+
+#include "_strsuftoi.h"
+
+#ifdef _LIBC
+__weak_alias(strsuftou, _strsuftou)
+__weak_alias(strsuftou_l, _strsuftou_l)
+#endif
Home |
Main Index |
Thread Index |
Old Index