[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: strtonum(3) from OpenBSD?
On Wed, Jun 24, 2009 at 04:47:25PM -0700, James Chacon wrote:
> On Jun 24, 2009, at 4:07 PM, Manuel Bouyer wrote:
>> On Wed, Jun 24, 2009 at 11:14:43PM +0200, Marc Balmer wrote:
>>> Am 24.06.2009 um 21:42 schrieb Manuel Bouyer:
>>>> On Wed, Jun 24, 2009 at 09:00:53PM +0200, Marc Balmer wrote:
>>>>>> I'd have phrased it differently, but I agree with Thor -- this
>>>>>> is a
>>>>>> API. Nor have I seen sufficient evidence that it's widely used in
>>>>>> software we might want to import.
>>>>> I am eager to learn why it is bad.
>>>> I think Thor explained it quite well. And yes, I did look at the man
>>> he did not. he completely failed to back his strong words...
As I pointed out, the API for this function, *as specified by the manual
page*, distinguishes error return cases by way of *specific strings
given in the manual page* (which is why it is not localizable) which
it does not distinguish by different errno values.
In other words, strcmp against the strings given in the manual page is
the only way to tell two distinct error cases apart; if you rely on
errno, you can't do anything different, as multiple errors are needlessly
mapped to the same errno value.
> Look at it this way...If the error is in errno, what value does the
> string have? Zero basically since any modern program can't use it.
And that's precisely what's wrong with the API for this function as
specified by the manual page (and AFAICT as present in all current
open-source implementations): the errno values don't actually distinguish
all the possible different error cases the error strings do.
Of course, I must be making this up (or my argument must be worth
handwaving away) because it must necessarily be the case that when I
talk about the API specified by the documentation for the function, I
am not reading the manual page, I am just making it up from the whole
However, those who do care to refer to the manual page will, I think,
quickly be able to see the same thing I say I did: the "error strings"
distinguish error cases which the documented errno values don't.
Main Index |
Thread Index |