Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strto[iu]_() and strtou_noneg(). #890

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Jan 6, 2024

This is in preparation of a rework of get[u]long().

@alejandro-colomar alejandro-colomar changed the title Add strto[iu](3bsd), strtou_noneg(), and move source files. Add strto[iu]_(), strtou_noneg(), and move source files. Jan 8, 2024
@alejandro-colomar alejandro-colomar marked this pull request as ready for review January 22, 2024 23:50
@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Jan 23, 2024

Link: https://lists.sr.ht/~hallyn/shadow/%3CZZoQDms6Sv6e5SPE%40debian%3E
Link: https://lists.freedesktop.org/archives/libbsd/2024-January/000384.html
Link: https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57828
Link: http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/stdlib/_strtoi.h?only_with_tag=MAIN
Link: http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/stdlib/_strtoi.h.diff?r1=1.2&r2=1.3&only_with_tag=MAIN

NetBSD has modified their APIs strtoi(3) and strtou(3) after my bug report, so our implementation will be fully compatible with theirs. libbsd will also adopt that behavior soon. However, for now, let's use our own definitions.

@alejandro-colomar alejandro-colomar changed the title Add strto[iu]_(), strtou_noneg(), and move source files. Add strto[iu]_() and strtou_noneg(). Jan 23, 2024
@alejandro-colomar alejandro-colomar mentioned this pull request Jan 23, 2024
@alejandro-colomar
Copy link
Collaborator Author

v2 changes:

  • Rebase to master
$ git range-diff master..gh/strtou_ shadow/master..strtou_ 
1:  619e0441 = 1:  7d7f7717 lib/atoi/strtoi.[ch]: strtoi_(), strtou_(): Add functions
2:  08dc5030 = 2:  7366080a tests/unit/test_atoi_strtoi.c: Test strtoi_()
3:  387d37a7 = 3:  99a7bc89 tests/unit/Makefile.am: tfix
4:  6a854e5b = 4:  324bce7b lib/atoi/strtou_noneg.[ch]: Add strtou_noneg()
5:  027f51e4 = 5:  b08d6260 tests/unit/test_atoi_strtoi.c: Test strtou_noneg()

These functions are identical to strtoi(3bsd) and strtou(3bsd), except
for one important thing: if both ERANGE and ENOTSUP conditions happen,
the BSD functions report ENOTSUP, which is bogus; our strtoi_() and
strtou_() report ERANGE.

Link: <https://lists.sr.ht/~hallyn/shadow/%3CZZoQDms6Sv6e5SPE%40debian%3E>
Link: <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57828>
Cc: Thorsten Glaser <tg@mirbsd.de>
Cc: christos <christos@netbsd.org>
Cc: roy <roy@netbsd.org>
Cc: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Fix typo.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
It's like strtou_(), but rejects negative input, instead of silently
converting it to unsigned.

Link: <https://softwareengineering.stackexchange.com/a/449060/332848>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar
Copy link
Collaborator Author

v2b changes:

  • Rebase to master
$ git range-diff master..gh/strtou_ shadow/master..strtou_ 
1:  7d7f7717 = 1:  1aebf7b4 lib/atoi/strtoi.[ch]: strtoi_(), strtou_(): Add functions
2:  7366080a = 2:  74096f8e tests/unit/test_atoi_strtoi.c: Test strtoi_()
3:  99a7bc89 = 3:  0c309e1b tests/unit/Makefile.am: tfix
4:  324bce7b = 4:  03f17ef8 lib/atoi/strtou_noneg.[ch]: Add strtou_noneg()
5:  b08d6260 = 5:  570aa4ca tests/unit/test_atoi_strtoi.c: Test strtou_noneg()

@hallyn hallyn merged commit f98e43e into shadow-maint:master Feb 1, 2024
9 checks passed
@alejandro-colomar alejandro-colomar deleted the strtou_ branch February 6, 2024 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants