]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/bug4.c
update from main archive 970121
[thirdparty/glibc.git] / stdio-common / bug4.c
CommitLineData
28f540f4
RM
1#ifdef _LIBC
2#include <ansidecl.h>
3#endif
4#include <stdio.h>
5#include <unistd.h>
6#include <string.h>
7
8int stdio_block_read = 1, stdio_block_write = 1;
9
10int
11DEFUN(main, (argc, argv),
12 int argc AND char **argv)
13{
14 FILE *f;
15 int i;
16 char buffer[31];
ec4b0518 17 const char filename[] = "/tmp/bugtest";
28f540f4 18
1ef32c3d 19 while ((i = getopt (argc, argv, "rw")) != -1)
28f540f4
RM
20 switch (i)
21 {
22 case 'r':
23 stdio_block_read = 0;
24 break;
25 case 'w':
26 stdio_block_write = 0;
27 break;
28 }
29
ec4b0518 30 f = fopen(filename, "w+");
28f540f4
RM
31 for (i=0; i<9000; i++) {
32 putc('x', f);
33 }
34 fseek(f, 8180L, 0);
35 fwrite("Where does this text come from?", 1, 31, f);
36 fseek(f, 8180L, 0);
37 fread(buffer, 1, 31, f);
38 fwrite(buffer, 1, 31, stdout);
39 fclose(f);
ec4b0518 40 remove(filename);
28f540f4
RM
41
42 if (!memcmp (buffer, "Where does this text come from?", 31))
43 {
44 puts ("\nTest succeeded.");
45 return 0;
46 }
47 else
48 {
49 puts ("\nTest FAILED!");
50 return 1;
51 }
52}