Subject: Re: [PATCH 00/14] numparse module: systematically tighten up integer parsing

From: Michael Haggerty <[email-masked]>
Date: Wed, 25 Mar 2015 22:14:18 +0100

On 03/24/2015 05:49 PM, René Scharfe wrote:
> Am 24.03.2015 um 17:06 schrieb Michael Haggerty:
>> Parsing numbers is not rocket science, but there are a lot of pitfalls,
>> especially around overflow. It's even harder to write such code via
>> macros and the result is less readable.
>>
>> This patch series is mostly about finding a reasonable API and whipping
>> the callers into shape. That seems ambitious enough for me. I'd rather
>> stick with boring wrappers for now and lean on strtol()/strtoul() to do
>> the dirty work. It will be easy for a motivated person to change the
>> implementation later.
> 
> The OpenBSD developers invented strtonum for that.  Are you aware of it?
>  Would it fit?  This discussion may be useful:
> 
>     http://www.tedunangst.com/flak/post/the-design-of-strtonum

I wasn't aware of strtonum; thanks for the reference. It has an
untraditional interface. Their willingness to sacrifice half of the
unsigned range and requirement that the user specify minval and maxval
have the nice effect of permitting one function to be used for all
integer types.

I think git will need more flexibility, for example to support other
radixes and to allow trailing characters. So personally I don't think we
should use (or imitate) strtonum().

Michael

-- 
Michael Haggerty
[email-masked]