alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD

Paul Eggert eggert at cs.ucla.edu
Wed Mar 19 19:27:07 UTC 2025


On 2025-03-18 17:15, Bruno Haible wrote:
> If you don't want to do that, I can only repeat what I said in the previous
> mail: The proposal*does not achieve the goal* of avoiding the most common
> programmer mistakes. For a robust API, the success test should*only* involve
> testing the returned 'status', nothing else.

This was my initial reaction as well. Although strtol has real problems, 
the proposed interface is even more complicated and confusing and I 
suspect that in practice it'd be misused even more often than strtol is.

I suggest starting from scratch. In particular, use a functional style, 
with no side effects (no pointers-to-results). Just return the result 
you want, as a struct, and keep the struct simple. Two struct components 
should suffice: the scanned numeric value and a success/error indicator.



More information about the libbsd mailing list