tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: strtonum(3) from OpenBSD?



On Tue, Jun 30, 2009 at 09:37:02AM +0100, Roy Marples wrote:
>> Correct use of sscanf() for a single integer is something like:
>>
>>      count = sscanf(inbuf, "%i%n", &int_val, &byte_count);
>>      if (count != 2 || inbuf[byte_count] != 0)
>>              /* Conversion error */
>>
>> I'm not sure that it is possible to detect numeric overflow.
>
> Using the standard, it's not.
> GNU libc sets ERANGE if the conversion overflows, I see no reason why we  
> could not do similar.

Because then our code isn't portable?

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index