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

index e4f9426..52cac6d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
+       ftello: Fix C++ test error on mingw.
+       * lib/stdio.in.h (ftello): Use modern idiom.
+       * lib/ftello.c (ftello): Renamed from rpl_ftello.
+       * m4/ftello.m4 (gl_FUNC_FTELLO): Distinguish the case that the function
+       is missing and that it needs to be replaced.
+       (gl_REPLACE_FTELLO): Don't set REPLACE_FTELLO here.
+       * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize HAVE_FTELLO.
+       * modules/stdio (Makefile.am): Substitute HAVE_FTELLO.
+
+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.
index 70cd359..a15e26b 100644 (file)
@@ -1,5 +1,5 @@
 /* An ftello() function that works around platform bugs.
-   Copyright (C) 2007, 20092010 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 /* Get lseek.  */
 #include <unistd.h>
 
+off_t
+ftello (FILE *fp)
 #undef ftello
 #if !HAVE_FTELLO
 # undef ftell
 # define ftello ftell
 #endif
-
-off_t
-rpl_ftello (FILE *fp)
 {
 #if LSEEK_PIPE_BROKEN
   /* mingw gives bogus answers rather than failure on non-seekable files.  */
index 25e8bdd..58eb4f0 100644 (file)
@@ -406,22 +406,30 @@ _GL_CXXALIASWARN (ftell);
 #   define ftello rpl_ftello
 #  endif
 _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
-#  if !@GNULIB_FTELL@
-    /* In order to avoid that ftell gets defined as a macro here, the
-       developer can request the 'ftell' module.  */
-#   undef ftell
-#   define ftell rpl_ftell
+_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
+# else
+#  if ! @HAVE_FTELLO@
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftello);
+# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
+   /* Provide an ftell function that is consistent with ftello.  */
+   /* In order to avoid that ftell gets defined as a macro here, the
+      developer can request the 'ftell' module.  */
+#  undef ftell
+#  define ftell rpl_ftell
 static inline long _GL_ARG_NONNULL ((1))
 rpl_ftell (FILE *f)
 {
+#  if @REPLACE_FTELLO@
+  return rpl_ftello (f);
+#  else
   return ftello (f);
-}
 #  endif
-_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
-# else
-_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+}
 # endif
-_GL_CXXALIASWARN (ftello);
 #elif defined GNULIB_POSIXCHECK
 # define _GL_FTELL_WARN /* Category 1, above.  */
 # undef ftell
index 2dff6ee..fba549a 100644 (file)
@@ -1,4 +1,4 @@
-# ftello.m4 serial 5
+# ftello.m4 serial 6
 dnl Copyright (C) 2007, 2008, 2009, 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,
@@ -18,8 +18,14 @@ AC_DEFUN([gl_FUNC_FTELLO],
       AC_TRY_LINK([#include <stdio.h>], [ftello (stdin);],
         [gl_cv_func_ftello=yes], [gl_cv_func_ftello=no])
     ])
-  if test $gl_cv_func_ftello = no \
-      || test $gl_cv_var_stdin_large_offset = no; then
+  if test $gl_cv_func_ftello = no; then
+    HAVE_FTELLO=0
+  else
+    if test $gl_cv_var_stdin_large_offset = no; then
+      REPLACE_FTELLO=1
+    fi
+  fi
+  if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
     gl_REPLACE_FTELLO
   fi
 ])
@@ -27,6 +33,4 @@ AC_DEFUN([gl_FUNC_FTELLO],
 AC_DEFUN([gl_REPLACE_FTELLO],
 [
   AC_LIBOBJ([ftello])
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  REPLACE_FTELLO=1
 ])
index 5b36f8b..7b7e944 100644 (file)
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 28
+# stdio_h.m4 serial 29
 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,
@@ -100,6 +100,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
   HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
   HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
+  HAVE_FTELLO=1;                 AC_SUBST([HAVE_FTELLO])
   HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
   HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
   HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
index 50eae50..faa07cc 100644 (file)
@@ -77,6 +77,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -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_FTELLO''@|$(HAVE_FTELLO)|g' \
              -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
              -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
              -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \