Re: [bugs] [PATCH] Fix integer parsing

On Wed, 29 Nov 2017 at 09:13:08, Lars Henriksen wrote:
> On Tue, Nov 28, 2017 at 08:50:35PM +0100, Lukas Fleischer wrote:
> > On Tue, 28 Nov 2017 at 20:32:26, Lars Henriksen wrote:
> > >  static int config_parse_int(int *dest, const char *val)
> > >  {
> > > -       if ((*val == '+' || *val == '-' || isdigit(*val))
> > > -           && is_all_digit(val + 1))
> > 
> > If the value is a single digit, isdigit(*val) is true and is_all_digit()
> > is invoked with an empty string (which should also return true). So
> > everything is as it should be...?
> 
> config_parse_int(&dest, "+")?
> 

Ah, I see. I guess this should be something like

    if (*cp == '+' || *cp == '-')
        cp++;
    if (isdigit(*cp) && is_all_digit(cp + 1))
        [...]

then, right?

Links