File: bug-19079.c

package info (click to toggle)
avr-libc 1%3A1.6.2.cvs20080610-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,848 kB
  • ctags: 55,619
  • sloc: ansic: 92,267; asm: 6,692; sh: 4,131; makefile: 2,481; python: 976; pascal: 426; perl: 116
file content (25 lines) | stat: -rw-r--r-- 675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* bug #19079: sscanf %s eats 1 char too much
   $Id: bug-19079.c,v 1.1.2.2 2008/02/23 09:03:53 dmix Exp $	*/

#include <stdio.h>
#include <string.h>

int main ()
{
    char wsp_N[10];
    char wsp_E[11];
    int fixva = 0;
    int nr_sat = 0;
    char s[] = "$GP,194000.00,5001.4934,N,01954.5390,E,0,02,2.9";
    int nrconv;
    
    nrconv = sscanf (s, "$GP,%*u.%*u,%9s,N,%10s,E,%i,%i,%*s",
		     wsp_N, wsp_E, &fixva, &nr_sat);
    if (nrconv != 4) return __LINE__;
    if (strcmp (wsp_N, "5001.4934")) return __LINE__;
    if (strcmp (wsp_E, "01954.5390")) return __LINE__;
    if (fixva != 0) return __LINE__;
    if (nr_sat != 2) return __LINE__;
    
    return 0;
}