]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/bug3.c
NEWS: Add advisories.
[thirdparty/glibc.git] / stdio-common / bug3.c
CommitLineData
28f540f4
RM
1#include <stdio.h>
2#include <string.h>
3
a84dcb4b
FB
4#include <support/xstdio.h>
5
28f540f4 6int
1f07e617 7main (void)
28f540f4
RM
8{
9 FILE *f;
10 int i;
27f10a09 11 const char filename[] = OBJPFX "bug3.test";
28f540f4 12
ec4b0518 13 f = fopen(filename, "w+");
28f540f4
RM
14 for (i=0; i<9000; i++)
15 putc ('x', f);
16 fseek (f, 8180L, 0);
17 fwrite ("Where does this text go?", 1, 24, f);
18 fflush (f);
19
20 rewind (f);
21 for (i=0; i<9000; i++)
22 {
23 int j;
24
25 if ((j = getc(f)) != 'x')
26 {
27 if (i != 8180)
28 {
29 printf ("Test FAILED!");
30 return 1;
31 }
32 else
33 {
34 char buf[25];
35
36 buf[0] = j;
a84dcb4b 37 xfread (buf + 1, 1, 23, f);
28f540f4
RM
38 buf[24] = '\0';
39 if (strcmp (buf, "Where does this text go?") != 0)
40 {
41 printf ("%s\nTest FAILED!\n", buf);
42 return 1;
43 }
44 i += 23;
45 }
46 }
47 }
48
49 fclose(f);
ec4b0518 50 remove(filename);
28f540f4
RM
51
52 puts ("Test succeeded.");
53
54 return 0;
55}