changeset 13122:01741ff1a40e

ftello: Fix C++ test error on mingw.
author Bruno Haible <bruno@clisp.org>
date Sat, 03 Apr 2010 14:25:24 +0200
parents 472aa3de0fbb
children f42a08f19992
files ChangeLog lib/ftello.c lib/stdio.in.h m4/ftello.m4 m4/stdio_h.m4 modules/stdio
diffstat 6 files changed, 44 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
--- a/lib/ftello.c
+++ b/lib/ftello.c
@@ -1,5 +1,5 @@
 /* An ftello() function that works around platform bugs.
-   Copyright (C) 2007, 2009, 2010 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
@@ -22,14 +22,13 @@
 /* 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.  */
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -406,22 +406,30 @@
 #   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
--- a/m4/ftello.m4
+++ b/m4/ftello.m4
@@ -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_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_REPLACE_FTELLO],
 [
   AC_LIBOBJ([ftello])
-  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  REPLACE_FTELLO=1
 ])
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -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 @@
   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])
--- a/modules/stdio
+++ b/modules/stdio
@@ -77,6 +77,7 @@
 	      -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' \