[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: |
anonymous |
Subject: |
[avr-libc-dev] [bug #19079] sscanf %s eats 1 char too much |
Date: |
Sun, 18 Feb 2007 15:13:53 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 |
URL:
<http://savannah.nongnu.org/bugs/?19079>
Summary: sscanf %s eats 1 char too much
Project: AVR C Runtime Library
Submitted by: None
Submitted on: Sunday 02/18/2007 at 15:13 UTC
Category: Library
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Privacy: Private
Percent Complete: 0%
Assigned to: None
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Hello, I think we have a bug here.
example code:
char wsp_N[10];
char wsp_E[11];
int fixva = 0;
int nr_sat = 0;
int x = "$GP,194000.00,5001.4934,N,01954.5390,E,0,02,2.9";
int nrconv = sscanf(x, "$GP,%*u.%*u,%9s,N,%10s,E,%i,%i,%*s",
wsp_N, wsp_E, &fixva, &nr_sat);
nrconv will be equal 1, wsp_N equals 5001.4934, wsp_E wont be event touched!
It is because sscanf eats 1 char too much. This occurs only in situation
where pattern %9s will terminate on max string length (9 here), no on
whitespace. Then will eat ',' character above, before N from. If we remove
',' from pattern, the second %s will match, and nrconv will be equal 2. And
so on.
There is a fix, which works for me:
address@hidden:~/work/avrlibc/avr-libc-1.4.5/libc/stdio$ diff vfscanf.c
vfscanf.c.org
290,291d289
<
< ungetc(i,stream); /* we eat too much
*/
address@hidden:~/work/avrlibc/avr-libc-1.4.5/libc/stdio$
Regards,
Jerzy
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?19079>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] [bug #19079] sscanf %s eats 1 char too much,
anonymous <=