[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #19079] sscanf %s eats 1 char too much
From: |
Frédéric Nadeau |
Subject: |
[avr-libc-dev] [bug #19079] sscanf %s eats 1 char too much |
Date: |
Fri, 26 Oct 2007 00:06:26 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8 |
Follow-up Comment #2, bug #19079 (project avr-libc):
I included a patch file.
Here are comment on the patch:
do {
i = getc(stream);
} while (isspace(i));
if (i == EOF)
goto leave;
this was remove. Reason:
Man file state: Matches a sequence of non-white-space characters...
Obviosly that part of code as the exact purpose of removing any leading
space(or white-space characters). As a second remark, we dont yet decrement
width(hit, bug is sscanf eats 1 char too much)
.
Next modif:
- while (width-- > 0)
+ do
Using a post decrement tation will end up in the following senarion. if
Width == 6, we will loop 6 time, this way we will read 6 char from the stream.
Didn't we just read 1 earlyer?
next modification: Bring
if ((i = getc(stream)) == EOF)
break;
just after the do
Since we are going to do some test condition on var i, we better have
something in it. I guess it was done later on due to the fact that it was red
in the part I removed earlyer.
final modif:
while (--width > 0);
To close the do-while, this will ensure a width reading.
I have not done much testing on it, just things that came to my mind.
Comment are welcome
Fred
(file #14213)
_______________________________________________________
Additional Item Attachment:
File name: 19079_patch.txt Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?19079>
_______________________________________________
Message posté via/par Savannah
http://savannah.nongnu.org/