summary refs log tree commit diff
path: root/stdio/bug3.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /stdio/bug3.c
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.xz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
initial import
Diffstat (limited to 'stdio/bug3.c')
-rw-r--r--stdio/bug3.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/stdio/bug3.c b/stdio/bug3.c
new file mode 100644
index 0000000000..0f3c7f1087
--- /dev/null
+++ b/stdio/bug3.c
@@ -0,0 +1,52 @@
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+DEFUN_VOID(main)
+{
+  FILE *f;
+  int i;
+
+  f = fopen("bugtest", "w+");
+  for (i=0; i<9000; i++)
+    putc ('x', f);
+  fseek (f, 8180L, 0);
+  fwrite ("Where does this text go?", 1, 24, f);
+  fflush (f);
+
+  rewind (f);
+  for (i=0; i<9000; i++)
+    {
+      int j;
+
+      if ((j = getc(f)) != 'x')
+	{
+	  if (i != 8180)
+	    {
+	      printf ("Test FAILED!");
+	      return 1;
+	    }
+	  else
+	    {
+	      char buf[25];
+
+	      buf[0] = j;
+	      fread (buf + 1, 1, 23, f);
+	      buf[24] = '\0';
+	      if (strcmp (buf, "Where does this text go?") != 0)
+		{
+		  printf ("%s\nTest FAILED!\n", buf);
+		  return 1;
+		}
+	      i += 23;
+	    }
+	}
+    }
+
+  fclose(f);
+
+  puts ("Test succeeded.");
+
+  return 0;
+}