avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] [bugs #10420] sscanf(), If there is a decimal number


From: Theodore A. Roth
Subject: Re: [avr-libc-dev] [bugs #10420] sscanf(), If there is a decimal number followed by the character '_' in the buffer, you can't get the the number.
Date: Sat, 18 Sep 2004 15:20:43 -0700 (PDT)

On Sat, 18 Sep 2004, Joerg Wunsch wrote:

> As Theodore A. Roth wrote:
>
> >     378                     if (j > 9)
> >     379                         j -= 'a' - '0' - 10;
> >     380                     if (j < 0 || j >= base) {
>
> I think I see the logical flaw in this now, too.  I tried to minimize
> the code required for this check, but obviously opened a window for
> false positives by that.
>
> > I have attached a patch that seems to fix the problem for me. Tested on
> > a mega128, using both "<1/dr_2_600" and "<1/dr_2\\600" for buf and the
> > respective fmt strings.
>
> Patch looks OK to me except of some whitespace inconsistencies.  You've
> been using spaces here, and tabs there to indent the code.

Ok. I have emacs set up to never insert tabs into code. I will re-do the
patch with vim using tabs before I commit it (tomorrow or monday).

>
> > One other thing. line 379 is hideous. The distribution of the
> > subtraction via the '-=' operator makes this code very difficult to read
> > and understand what it is doing exactly. This is a case where parens
> > should be used:
> >
> >   j -= ('a' + '0' + 10);
> >
> > is so much more explicit and makes the code easier to understand.
>
> Yeah, blame me on this one. ;-)
>
>

---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]