Tweak last commit.
authorBruno Haible <bruno@clisp.org>
Sun, 16 Aug 2009 12:46:39 +0000 (14:46 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 16 Aug 2009 12:46:39 +0000 (14:46 +0200)
ChangeLog
m4/fpurge.m4
tests/test-fpurge.c

index bb286dc..2233ff1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-16  Bruno Haible  <bruno@clisp.org>
+
+       * m4/fpurge.m4 (gl_FUNC_FPURGE): Don't compile fpurge.c if only the
+       declaration of fpurge is missing.
+       * tests/test-fpurge.c (main): Check that the file has not more contents
+       than expected. Close the file before removing it.
+
 2009-08-15  Eric Blake  <ebb9@byu.net>
 
        fpurge: don't wrap working cygwin implementation
index 99b9a6e..8c4ddb6 100644 (file)
@@ -1,4 +1,4 @@
-# fpurge.m4 serial 4
+# fpurge.m4 serial 5
 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,12 +34,10 @@ AC_DEFUN([gl_FUNC_FPURGE],
       [gl_cv_func_fpurge_works='guessing no'])])
     if test "x$gl_cv_func_fpurge_works" != xyes; then
       REPLACE_FPURGE=1
+      AC_LIBOBJ([fpurge])
     fi
   fi
   if test "x$ac_cv_have_decl_fpurge" = xno; then
     HAVE_DECL_FPURGE=0
   fi
-  if test "$REPLACE_FPURGE$HAVE_DECL_FPURGE" != 01; then
-    AC_LIBOBJ([fpurge])
-  fi
 ])
index f634840..596dd75 100644 (file)
@@ -51,6 +51,8 @@ main ()
   if (fclose (fp))
     goto skip;
 
+  /* The file's contents is now "foobarsh".  */
+
   /* Open it in read-write mode.  */
   fp = fopen (TESTFILE, "r+");
   if (fp == NULL)
@@ -82,22 +84,30 @@ main ()
   ASSERT (getc (fp) == EOF);
   ASSERT (fclose (fp) == 0);
 
+  /* The file's contents is now "foogarsh".  */
+
   /* Ensure that purging a read does not corrupt subsequent writes.  */
   fp = fopen (TESTFILE, "r+");
-  ASSERT (fp);
-  ASSERT (fseek (fp, -1, SEEK_END) == 0);
+  if (fp == NULL)
+    goto skip;
+  if (fseek (fp, -1, SEEK_END))
+    goto skip;
   ASSERT (getc (fp) == 'h');
   ASSERT (getc (fp) == EOF);
   ASSERT (fpurge (fp) == 0);
   ASSERT (putc ('!', fp) == '!');
   ASSERT (fclose (fp) == 0);
   fp = fopen (TESTFILE, "r");
-  ASSERT (fp);
+  if (fp == NULL)
+    goto skip;
   {
-    char buf[9];
-    ASSERT (fread (buf, 1, 9, fp) == 9);
+    char buf[10];
+    ASSERT (fread (buf, 1, 10, fp) == 9);
     ASSERT (memcmp (buf, "foogarsh!", 9) == 0);
   }
+  ASSERT (fclose (fp) == 0);
+
+  /* The file's contents is now "foogarsh!".  */
 
   remove (TESTFILE);
   return 0;