.
[glibc/history.git] / stdio-common / bug12.c
blob48610c0e78e81b5b8b69aaac887ff3c50d6d192c
1 #include <stdio.h>
2 #include <string.h>
4 char x[4096], z[4096], b[21], m[4096 * 4];
6 int
7 main (void)
9 FILE *f = tmpfile ();
10 int i, failed = 0;
12 memset (x, 'x', 4096);
13 memset (z, 'z', 4096);
14 b[20] = 0;
16 for (i = 0; i <= 5; i++)
18 fwrite (x, 4096, 1, f);
19 fwrite (z, 4096, 1, f);
21 rewind (f);
23 fread (m, 4096 * 4 - 10, 1, f);
24 fread (b, 20, 1, f);
25 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");
26 if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))
27 failed = 1;
29 fseek (f, -40, SEEK_CUR);
30 fread (b, 20, 1, f);
31 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzzzzzzzzzzz");
32 if (strcmp (b, "zzzzzzzzzzzzzzzzzzzz"))
33 failed = 1;
35 fread (b, 20, 1, f);
36 printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");
37 if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))
38 failed = 1;
40 fread (b, 20, 1, f);
41 printf ("got %s (should be %s)\n", b, "xxxxxxxxxxxxxxxxxxxx");
42 if (strcmp (b, "xxxxxxxxxxxxxxxxxxxx"))
43 failed = 1;
45 return failed;