On Tue, 23 Jun 2009 19:28:37 +0200
Adam Hoka <adam.hoka%gmail.com@localhost> wrote:
And what about implementing something with similar functionality
sans the mentioned
api problems and put it into libutil?
Would OpenBSD and those few other programs also convert their code to
use a new interface though? Otherwise we don't solve much...
Two possible draft alternatives are attached to fuel even more
debate (yes, seems I had too much time on my hands tonight :) But
looking at how small these functions really are, maybe they're still
best embedded into the programs needing them? Which if already
embedding strtonum() might best be left as-is.
So strtoint() uses intmax_t but doesn't allow to know if the supplied
value was too large or too small if out of range, as it uses standard
errno values.
On the other hand, strtoi() also using intmax_t provides an interface
with a custom error system (in this case it's still better than
strtonum() where this information was only human-readable, and its
optional error string could be provided via a localized and thread-
safe
function similar to strerror_r(), over-engineering for a simple
problem
but allright for "correctness" :)