]>
Commit | Line | Data |
---|---|---|
e5bafd55 UD |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | ||
a84dcb4b FB |
4 | #include <support/xstdio.h> |
5 | ||
e5bafd55 UD |
6 | char x[4096], z[4096], b[21], m[4096 * 4]; |
7 | ||
8 | int | |
9 | main (void) | |
10 | { | |
11 | FILE *f = tmpfile (); | |
12 | int i, failed = 0; | |
13 | ||
14 | memset (x, 'x', 4096); | |
15 | memset (z, 'z', 4096); | |
16 | b[20] = 0; | |
17 | ||
18 | for (i = 0; i <= 5; i++) | |
19 | { | |
20 | fwrite (x, 4096, 1, f); | |
21 | fwrite (z, 4096, 1, f); | |
22 | } | |
23 | rewind (f); | |
24 | ||
a84dcb4b FB |
25 | xfread (m, 4096 * 4 - 10, 1, f); |
26 | xfread (b, 20, 1, f); | |
e5bafd55 UD |
27 | printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx"); |
28 | if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx")) | |
29 | failed = 1; | |
30 | ||
31 | fseek (f, -40, SEEK_CUR); | |
a84dcb4b | 32 | xfread (b, 20, 1, f); |
e5bafd55 UD |
33 | printf ("got %s (should be %s)\n", b, "zzzzzzzzzzzzzzzzzzzz"); |
34 | if (strcmp (b, "zzzzzzzzzzzzzzzzzzzz")) | |
35 | failed = 1; | |
36 | ||
a84dcb4b | 37 | xfread (b, 20, 1, f); |
e5bafd55 UD |
38 | printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx"); |
39 | if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx")) | |
40 | failed = 1; | |
41 | ||
a84dcb4b | 42 | xfread (b, 20, 1, f); |
e5bafd55 UD |
43 | printf ("got %s (should be %s)\n", b, "xxxxxxxxxxxxxxxxxxxx"); |
44 | if (strcmp (b, "xxxxxxxxxxxxxxxxxxxx")) | |
45 | failed = 1; | |
46 | ||
47 | return failed; | |
48 | } |