~ubuntu-branches/ubuntu/raring/avr-libc/raring-proposed

« back to all changes in this revision

Viewing changes to tests/simulate/regression/bug-22593.c

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2008-08-10 09:59:16 UTC
  • mfrom: (1.1.7 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080810095916-wwyigh3vt0e9s7ud
Tags: 1:1.6.2.cvs20080610-2
Added build-depends on texlive-extra-utils (closes: #493454)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* bug #22593: vfscanf improperly scans string parameters with a width
 
2
   option by 1 character
 
3
   $Id: bug-22593.c,v 1.1.2.2 2008/03/18 13:30:06 dmix Exp $    */
 
4
 
 
5
/* Seems, this is duplication of bug #19079: sscanf %s eats 1 char too much
 
6
 */
 
7
 
 
8
#include <stdio.h>
 
9
#include <string.h>
 
10
 
 
11
#ifndef __AVR__
 
12
# define sscanf_P       sscanf
 
13
# define PSTR(s)        (s)
 
14
#else
 
15
# include <avr/pgmspace.h>
 
16
#endif
 
17
 
 
18
int main ()
 
19
{
 
20
    char s1[5], s2[5];
 
21
    int result;
 
22
    
 
23
    s1[0] = 0;
 
24
    s2[0] = 0;
 
25
 
 
26
    result = sscanf_P (",ABCD,EFGH,", PSTR (",%4s,%4s,"), s1, s2);
 
27
    if (result != 2)
 
28
        return __LINE__;
 
29
    if (strcmp (s1, "ABCD") || strcmp (s2, "EFGH"))
 
30
        return __LINE__;
 
31
 
 
32
    s1[0] = 0;
 
33
    s2[0] = 0;
 
34
    result = sscanf_P (",ABCD,EFGH,", PSTR (",%3s,%3s,"), s1, s2);
 
35
    if (result != 1)
 
36
        return __LINE__;
 
37
    if (strcmp (s1, "ABC"))
 
38
        return __LINE__;
 
39
 
 
40
    return 0;
 
41
}