bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fseeko bug


From: Eric Blake
Subject: Re: fseeko bug
Date: Thu, 13 Dec 2007 18:27:31 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Larry Jones <lawrence.jones <at> siemens.com> writes:

> 
> CVS nightly testing has been failing on BSD/OS and I've finally tracked
> the problem down to a bug in fseeko -- it doesn't clear the EOF flag
> after doing its magic:

Just to make sure other platforms aren't affected, I'm installing this.


From: Eric Blake <address@hidden>
Date: Thu, 13 Dec 2007 11:25:42 -0700
Subject: [PATCH] Beef up fseek tests.

* tests/test-fseek.c (main): Also test eof handling.
* tests/test-fseeko.c (main): Likewise.
Reported by Larry Jones.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |    7 +++++++
 tests/test-fseek.c  |   18 +++++++++++++++++-
 tests/test-fseeko.c |   18 +++++++++++++++++-
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f430f7b..b91f640 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-13  Eric Blake  <address@hidden>
+
+       Beef up fseek tests.
+       * tests/test-fseek.c (main): Also test eof handling.
+       * tests/test-fseeko.c (main): Likewise.
+       Reported by Larry Jones.
+
 2007-12-13  Larry Jones  <address@hidden>  (tiny change)
 
        Fix fseeko on BSD-based platforms.
diff --git a/tests/test-fseek.c b/tests/test-fseek.c
index c2d783f..dde7ea0 100644
--- a/tests/test-fseek.c
+++ b/tests/test-fseek.c
@@ -25,5 +25,21 @@ main (int argc, char **argv)
 {
   /* Assume stdin is seekable iff argc > 1.  */
   int expected = argc > 1 ? 0 : -1;
-  return fseek (stdin, 0, SEEK_CUR) != expected;
+  if (fseek (stdin, 0, SEEK_CUR) != expected)
+    return 1;
+  if (argc > 1)
+    {
+      /* Test that fseek resets end-of-file marker.  */
+      if (fseek (stdin, 0, SEEK_END))
+        return 1;
+      if (fgetc (stdin) != EOF)
+        return 1;
+      if (!feof (stdin))
+        return 1;
+      if (fseek (stdin, 0, SEEK_END))
+        return 1;
+      if (feof (stdin))
+        return 1;
+    }
+  return 0;
 }
diff --git a/tests/test-fseeko.c b/tests/test-fseeko.c
index bcafeea..3be4f6e 100644
--- a/tests/test-fseeko.c
+++ b/tests/test-fseeko.c
@@ -31,5 +31,21 @@ main (int argc, char **argv)
   /* Exit with success only if fseek/fseeko agree.  */
   int r1 = fseeko (stdin, (off_t)0, SEEK_CUR);
   int r2 = fseek (stdin, (long)0, SEEK_CUR);
-  return ! (r1 == r2 && r1 == expected);
+  if (r1 != r2 || r1 != expected)
+    return 1;
+  if (argc > 1)
+    {
+      /* Test that fseek resets end-of-file marker.  */
+      if (fseeko (stdin, (off_t) 0, SEEK_END))
+        return 1;
+      if (fgetc (stdin) != EOF)
+        return 1;
+      if (!feof (stdin))
+        return 1;
+      if (fseeko (stdin, (off_t) 0, SEEK_END))
+        return 1;
+      if (feof (stdin))
+        return 1;
+    }
+  return 0;
 }
-- 
1.5.3.5







reply via email to

[Prev in Thread] Current Thread [Next in Thread]