(_IO_new_file_close_it): Call _IO_set[bgp] even for wide streams.
[glibc/history.git] / stdio-common / bug4.c
bloba0377862a5ed507ad2100e4089f8cc16ad62974d
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <string.h>
5 int stdio_block_read = 1, stdio_block_write = 1;
7 int
8 main (int argc, char *argv[])
10 FILE *f;
11 int i;
12 char buffer[31];
13 const char filename[] = "/tmp/bug4.test";
15 while ((i = getopt (argc, argv, "rw")) != -1)
16 switch (i)
18 case 'r':
19 stdio_block_read = 0;
20 break;
21 case 'w':
22 stdio_block_write = 0;
23 break;
26 f = fopen (filename, "w+");
27 for (i = 0; i < 9000; ++i)
28 putc('x', f);
30 fseek (f, 8180L, 0);
31 fwrite ("Where does this text come from?", 1, 31, f);
32 fseek (f, 8180L, 0);
33 fread (buffer, 1, 31, f);
34 fwrite (buffer, 1, 31, stdout);
35 fclose (f);
36 remove (filename);
38 if (!memcmp (buffer, "Where does this text come from?", 31))
40 puts ("\nTest succeeded.");
41 return 0;
43 else
45 puts ("\nTest FAILED!");
46 return 1;