*** empty log message ***
[glibc.git] / stdio-common / bug4.c
blob00abf3c502d477904a8770699d68e40d8f0f5f4a
1 #ifdef _LIBC
2 #include <ansidecl.h>
3 #endif
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <string.h>
8 int stdio_block_read = 1, stdio_block_write = 1;
10 int
11 DEFUN(main, (argc, argv),
12 int argc AND char **argv)
14 FILE *f;
15 int i;
16 char buffer[31];
18 while ((i = getopt (argc, argv, "rw")) != EOF)
19 switch (i)
21 case 'r':
22 stdio_block_read = 0;
23 break;
24 case 'w':
25 stdio_block_write = 0;
26 break;
29 f = fopen("/tmp/bugtest", "w+");
30 for (i=0; i<9000; i++) {
31 putc('x', f);
33 fseek(f, 8180L, 0);
34 fwrite("Where does this text come from?", 1, 31, f);
35 fseek(f, 8180L, 0);
36 fread(buffer, 1, 31, f);
37 fwrite(buffer, 1, 31, stdout);
38 fclose(f);
40 if (!memcmp (buffer, "Where does this text come from?", 31))
42 puts ("\nTest succeeded.");
43 return 0;
45 else
47 puts ("\nTest FAILED!");
48 return 1;