fseeko: Fix C++ test error on mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 12:08:25 +0000 (14:08 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 13:04:15 +0000 (15:04 +0200)
ChangeLog
lib/fseeko.c
lib/stdio.in.h
m4/fseeko.m4
m4/stdio_h.m4
modules/stdio

index 88fffb8..e4f9426 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
+       fseeko: Fix C++ test error on mingw.
+       * lib/stdio.in.h (fseeko): Use modern idiom.
+       * lib/fseeko.c (fseeko): Renamed from rpl_fseeko.
+       * m4/fseeko.m4 (gl_FUNC_FSEEKO): Distinguish the case that the function
+       is missing and that it needs to be replaced.
+       (gl_REPLACE_FSEEKO): Don't set REPLACE_FSEEKO here.
+       * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize HAVE_FSEEKO.
+       * modules/stdio (Makefile.am): Substitute HAVE_FSEEKO.
+
+2010-04-03  Bruno Haible  <bruno@clisp.org>
+
        mkstemp: Fix C++ test error on mingw.
        * lib/stdlib.in.h (mkstemp): Use modern idiom.
        * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Distinguish the case that the
index 7c0fd0e..1fd1266 100644 (file)
 
 #include "stdio-impl.h"
 
+int
+fseeko (FILE *fp, off_t offset, int whence)
 #undef fseeko
 #if !HAVE_FSEEKO
 # undef fseek
 # define fseeko fseek
 #endif
-
-int
-rpl_fseeko (FILE *fp, off_t offset, int whence)
 {
 #if LSEEK_PIPE_BROKEN
   /* mingw gives bogus answers rather than failure on non-seekable files.  */
index 7647d48..25e8bdd 100644 (file)
@@ -322,30 +322,39 @@ _GL_CXXALIASWARN (fseek);
 #  undef fseek
 # endif
 # if @REPLACE_FSEEKO@
-/* Provide fseek, fseeko functions that are aware of a preceding
-   fflush(), and which detect pipes.  */
+/* Provide an fseeko function that is aware of a preceding fflush(), and which
+   detects pipes.  */
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef fseeko
 #   define fseeko rpl_fseeko
 #  endif
 _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
                                _GL_ARG_NONNULL ((1)));
-#  if !@GNULIB_FSEEK@
-    /* In order to avoid that fseek gets defined as a macro here, the
-       developer can request the 'fseek' module.  */
-#   undef fseek
-#   define fseek rpl_fseek
+_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
+# else
+#  if ! @HAVE_FSEEKO@
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseeko);
+# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
+   /* Provide an fseek function that is consistent with fseeko.  */
+   /* In order to avoid that fseek gets defined as a macro here, the
+      developer can request the 'fseek' module.  */
+#  undef fseek
+#  define fseek rpl_fseek
 static inline int _GL_ARG_NONNULL ((1))
 rpl_fseek (FILE *fp, long offset, int whence)
 {
+#  if @REPLACE_FSEEKO@
+  return rpl_fseeko (fp, offset, whence);
+#  else
   return fseeko (fp, offset, whence);
-}
 #  endif
-_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
-# else
-_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+}
 # endif
-_GL_CXXALIASWARN (fseeko);
 #elif defined GNULIB_POSIXCHECK
 # define _GL_FSEEK_WARN /* Category 1, above.  */
 # undef fseek
index 5f7f977..eff09b1 100644 (file)
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 7
+# fseeko.m4 serial 8
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,8 +19,14 @@ AC_DEFUN([gl_FUNC_FSEEKO],
 ]], [fseeko (stdin, 0, 0);])],
         [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
     ])
-  if test $gl_cv_func_fseeko = no \
-      || test $gl_cv_var_stdin_large_offset = no; then
+  if test $gl_cv_func_fseeko = no; then
+    HAVE_FSEEKO=0
+  else
+    if test $gl_cv_var_stdin_large_offset = no; then
+      REPLACE_FSEEKO=1
+    fi
+  fi
+  if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
     gl_REPLACE_FSEEKO
   fi
 ])
@@ -28,8 +34,6 @@ AC_DEFUN([gl_FUNC_FSEEKO],
 AC_DEFUN([gl_REPLACE_FSEEKO],
 [
   AC_LIBOBJ([fseeko])
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  REPLACE_FSEEKO=1
   dnl If we are also using the fseek module, then fseek needs replacing, too.
   m4_ifdef([gl_REPLACE_FSEEK], [gl_REPLACE_FSEEK])
 ])
index af56b1f..5b36f8b 100644 (file)
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 27
+# stdio_h.m4 serial 28
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -99,6 +99,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   HAVE_DECL_SNPRINTF=1;          AC_SUBST([HAVE_DECL_SNPRINTF])
   HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
   HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
+  HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
   HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
   HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
   HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
index 59a29bd..50eae50 100644 (file)
@@ -76,6 +76,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
              -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
              -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+             -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
              -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
              -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
              -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \