Home | History | Annotate | Download | only in stdlib
History log of /src/common/lib/libc/stdlib/_strtoi.h
RevisionDateAuthorComments
 1.5  24-Jul-2024  kre PR lib/58461 PR lib/58453 portability fixes

Revert previous (1.4) and make the changes properly.

If base is invalid, what gets left in *endptr by strtoimax()
is unspecified (it is not guaranteed to be either nptr or unaltered)
and so cannot (in that case) be used in any way at all.

Since it is hard to determine from some implementations of
strtoimax() whether this happened or not, simply duplicate
the validity test for base here, so we know that error (EINVAL
because base is invalid) cannot occur from strtoimax(). In that
case, if we get an EINVAL from strtoimax we can simply ignore it,
as all it can mean is the (optional in POSIX) case where no
conversion occurred (where strtoi() sets the status to ECANCELED).

Since NetBSD never did that, this all changes nothing here, but
makes strtoi() portable to other environments using a different
version of strtoimax().

NFCI.

No pullups required, nothing has really changed, there never was
a NetBSD bug to fix.
 1.4  21-Jul-2024  christos POSIX allows systems that report EINVAL when no digits are found. On
such systems the only way to differentiate EINVAL and ECANCELED is to
initialized the end pointer to NULL before the call. On EINVAL cases,
strto*max(3) will leave the pointer unmodified, so we'll read back the
original NULL. On ECANCELED cases, strto*max(3) will set it to nptr.
This also prevents UB read of endptr on an unsupported base argument.
(Alejandro Colomar)
 1.3  20-Jan-2024  christos branches: 1.3.2;
PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
 1.2  18-Jan-2015  christos branches: 1.2.2; 1.2.18; 1.2.20; 1.2.32;
match variable names with man page (Kamil Rytarowski)
 1.1  16-Jan-2015  christos add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
 1.2.32.1  23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #792):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)

generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.2.20.1  23-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1870):

common/lib/libc/stdlib/_strtoi.h: revision 1.3
lib/libc/stdlib/strtou.3: revision 1.8
lib/libc/stdlib/strtonum.c: revision 1.7
lib/libc/stdlib/Makefile.inc: revision 1.97
lib/libc/stdlib/strtoi.3: revision 1.8
lib/libc/stdlib/strtoi.3: revision 1.9
lib/libc/stdlib/strtou.3: file removal
tests/lib/libc/stdlib/t_strtoi.c: revision 1.3

PR/57828: Alejandro Colomar: Prioritize test for ERANGE before testing for
fully consuming the string. Adjust strtonum(3) to behave as before. Document
the order of the tests and sync the man pages (I should really autogenerate
one of the two man pages...)
generate strtou.3 from strtoi.3, grammar police

Add range tests with trailing characters.
 1.2.18.2  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.2.18.1  21-Apr-2020  martin Sync with HEAD
 1.2.2.2  22-Apr-2015  snj Pull up following revision(s) (requested by roy in ticket #648):
common/lib/libc/stdlib/_strtoi.h: revisions 1.1, 1.2
common/lib/libc/stdlib/strtoi.c: revision 1.1
common/lib/libc/stdlib/strtou.c: revision 1.1
distrib/sets/lists/base/ad.aarch64: patch
distrib/sets/lists/base/ad.arm: patch
distrib/sets/lists/base/ad.mips: patch
distrib/sets/lists/base/ad.powerpc: patch
distrib/sets/lists/base/md.amd64: patch
distrib/sets/lists/base/md.sparc64: patch
distrib/sets/lists/base/shl.mi: patch
distrib/sets/lists/comp/mi: revision 1.1939
distrib/sets/lists/debug/ad.aarch64: patch
distrib/sets/lists/debug/ad.arm: patch
distrib/sets/lists/debug/ad.mips: patch
distrib/sets/lists/debug/ad.powerpc: patch
distrib/sets/lists/debug/md.amd64: patch
distrib/sets/lists/debug/md.sparc64: patch
distrib/sets/lists/debug/shl.mi: patch
include/inttypes.h: revision 1.11
lib/libc/shlib_version: patch
lib/libc/stdlib/Makefile.inc: revision 1.84
lib/libc/stdlib/strtol.3: revisions 1.27-1.31
lib/libc/stdlib/strtoul.3: revisions 1.26-1.29
sys/lib/libkern/Makefile.libkern: revision 1.37
sys/lib/libkern/libkern.h: revision 1.117
tools/compat/Makefile: revision 1.73
tools/compat/compat_defs.h: revision 1.101
tools/compat/configure.ac: revision 1.83
tools/compat/configure: revision 1.82
tools/compat/nbtool_config.h.in: revision 1.36
add strto{i,u} from Kamil Rytarowski as discussed in tech-userlevel.
--
strtoi and strtou additions
--
strtoi and strtou for the kernel
--
strtoi and strtou additions
--
strtoi and strtou man pages
--
strto{i,u}
--
regen
--
Remove trailing whitespace.
--
match variable names with man page (Kamil Rytarowski)
--
cleanups from (Kamil Rytarowski)
--
add strtoi strtou (Kamil Rytarowski)
--
PR/49640: Kamil Rytarowski: Improve error printing
--
Use existing month for Dd.
 1.2.2.1  18-Jan-2015  snj file _strtoi.h was added on branch netbsd-7 on 2015-04-22 07:18:57 +0000
 1.3.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed