Update to 2.1.x development version
[glibc/history.git] / stdio-common / bug3.c
blob3bb0158a21384022313c131afb1cac381e994d37
1 #include <ansidecl.h>
2 #include <stdio.h>
3 #include <string.h>
5 int
6 DEFUN_VOID(main)
8 FILE *f;
9 int i;
10 const char filename[] = "/tmp/bugtest";
12 f = fopen(filename, "w+");
13 for (i=0; i<9000; i++)
14 putc ('x', f);
15 fseek (f, 8180L, 0);
16 fwrite ("Where does this text go?", 1, 24, f);
17 fflush (f);
19 rewind (f);
20 for (i=0; i<9000; i++)
22 int j;
24 if ((j = getc(f)) != 'x')
26 if (i != 8180)
28 printf ("Test FAILED!");
29 return 1;
31 else
33 char buf[25];
35 buf[0] = j;
36 fread (buf + 1, 1, 23, f);
37 buf[24] = '\0';
38 if (strcmp (buf, "Where does this text go?") != 0)
40 printf ("%s\nTest FAILED!\n", buf);
41 return 1;
43 i += 23;
48 fclose(f);
49 remove(filename);
51 puts ("Test succeeded.");
53 return 0;