Page MenuHomeFreeBSD

libc/stdlib: Port strtonumx() from illumos #15365
ClosedPublic

Authored by rosenfeld_grumpf.hope-2000.org on Dec 17 2025, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 16, 6:16 AM
Unknown Object (File)
Fri, Jan 16, 5:04 AM
Unknown Object (File)
Thu, Jan 15, 9:34 PM
Unknown Object (File)
Thu, Jan 15, 8:50 PM
Unknown Object (File)
Tue, Jan 13, 12:43 AM
Unknown Object (File)
Sat, Jan 10, 3:30 PM
Unknown Object (File)
Sat, Jan 10, 3:13 PM
Unknown Object (File)
Sat, Jan 10, 8:09 AM
Subscribers

Details

Summary

Add strtonumx(), a companion to strtonum(3) that preserves its safety
and error-reporting semantics while allowing the caller to specify a
conversion base, similar to the strtol(3) family of functions.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This looks fine to me, but I prefer to have more eyes on it before is is engraved into the libc.

This revision is now accepted and ready to land.Dec 17 2025, 4:30 PM

Wow, thanks so much for sharing this with us!

lib/libc/stdlib/strtonum.3
194

We prefer to use version numbers here.

lib/libc/stdlib/strtonum.c
5

I'm not sure if it's necessary, but all our style guides use this.

lib/libc/stdlib/strtonum.3
194

illumos doesn't have versions or version numbers. If it helps I can try to find the exact date the commit went into illumos-gate.

lib/libc/stdlib/strtonum.c
5

It's the copyright of the original change, not mine. I'm not sure it would be well received by them if I changed it here?

lib/libc/stdlib/strtonum.c
5

I don't know either, so I asked them. Hopefully they will come comment. It's so small, but I wanna get this kinda stuff right during import.

lib/libc/stdlib/strtonum.c
5

It's not necessary and if it's not in upstream; let's omit it. It's kind of silly that "Copyright (c)" is so prevalent, it'd be like writing "and &" or "% percent"

lib/libc/stdlib/strtonum.3
18

You (or whoever pushes the commit) can set this to the current date when it goes in

@rosenfeld_grumpf.hope-2000.org, we need to update the commit message to align with https://docs.freebsd.org/en/articles/committers-guide/#commit-log-message. How about this?

libc/stdlib: Port strtonumx() from Illumos #15365

Add strtonumx(), a companion to strtonum(3) that preserves its safety
and error-reporting semantics while allowing the caller to specify a
conversion base, similar to the strtol(3) family of functions.

Reviewed by:    emaste, kib, ziaee
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54270

I guess Illumos #15365 refers to something on https://code.illumos.org, but it's not easy to find. Could you either clarify, or we can simply use libc/stdlib: Port strtonumx() from Illumos for the subject.

In D54270#1250436, @jrm wrote:

@rosenfeld_grumpf.hope-2000.org, we need to update the commit message to align with https://docs.freebsd.org/en/articles/committers-guide/#commit-log-message. How about this?

libc/stdlib: Port strtonumx() from Illumos #15365

Add strtonumx(), a companion to strtonum(3) that preserves its safety
and error-reporting semantics while allowing the caller to specify a
conversion base, similar to the strtol(3) family of functions.

Reviewed by:    emaste, kib, ziaee
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D54270

Looks good!

I guess Illumos #15365 refers to something on https://code.illumos.org, but it's not easy to find. Could you either clarify, or we can simply use libc/stdlib: Port strtonumx() from Illumos for the subject.

That is the illumos issue number in the illumos issue tracker: https://www.illumos.org/issues/15365

I've added the link to the commit message in an "Obtained from" line as documented in the committer's guide. Please let me know if that is the correct way to handle it. If not, I guess it's better to just leave it out entirely.

rosenfeld_grumpf.hope-2000.org retitled this revision from libc/stdlib: port illumos#15365: strtonumx() would be a useful companion to strtonum() to libc/stdlib: Port strtonumx() from illumos #15365.Thu, Jan 15, 1:39 PM
rosenfeld_grumpf.hope-2000.org edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Thu, Jan 15, 1:40 PM
This revision was not accepted when it landed; it landed in state Needs Review.Thu, Jan 15, 1:46 PM
This revision was automatically updated to reflect the committed changes.