1 #include <assert.h>
2 #include <errno.h>
3 #include <stdio.h>
4
5 #ifndef CHAR
6 # define CHAR char
7 # define L(str) str
8 # define FPUTS fputs
9 # define FSCANF fscanf
10 #endif
11
12
13 static int
do_test(void)14 do_test (void)
15 {
16 FILE *fp = tmpfile ();
17 if (fp == NULL)
18 {
19 puts ("cannot open file");
20 return 1;
21 }
22
23 FPUTS (L("7-11"), fp);
24 rewind (fp);
25
26 printf("setting errno to EINTR\n");
27 errno = EINTR;
28
29 printf("checking sscanf\n");
30
31 int i, j, n;
32
33 i = j = n = 0;
34 FSCANF (fp, L(" %i - %i %n"), &i, &j, &n);
35 printf ("found %i-%i (length=%i)\n", i, j, n);
36
37 int result = 0;
38 if (i != 7)
39 {
40 printf ("i is %d, expected 7\n", i);
41 result = 1;
42 }
43 if (j != 11)
44 {
45 printf ("j is %d, expected 11\n", j);
46 result = 1;
47 }
48 if (n != 4)
49 {
50 printf ("n is %d, expected 4\n", j);
51 result = 1;
52 }
53
54 return result;
55 }
56
57 #define TEST_FUNCTION do_test ()
58 #include "../test-skeleton.c"
59