From 5abb9c9cbcf1c199155bce1f10324ce0e45f1e90 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 27 Oct 2009 10:42:50 -0600 Subject: [PATCH] fseek: avoid compilation failure when fflush is replaced ./gnulib-tool --import fseek fwritable failed on Debian, due to broken fflush() pulling in rpl_fseeko that mistakenly overwrote fseek() as function-like macro. * m4/fseek.m4 (gl_REPLACE_FSEEK): New macro. * m4/fseeko.m4 (gl_REPLACE_FSEEKO): Also replace fseek, if fseek module is in use. * lib/stdio.in.h (GNULIB_FSEEKO): Only poison fseek if fseek module is not in use; since REPLACE_FSEEK worked otherwise. (GNULIB_FTELLO): Likewise for ftell. Reported by Ian Beckwith and others. Signed-off-by: Eric Blake --- ChangeLog | 13 ++++++++++++- lib/stdio.in.h | 18 ++++++++++++++++-- m4/fseek.m4 | 16 ++++++++++------ m4/fseeko.m4 | 8 +++++--- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1143f61a..793ae5062 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,21 @@ +2009-10-27 Eric Blake + + fseek: avoid compilation failure when fflush is replaced + * m4/fseek.m4 (gl_REPLACE_FSEEK): New macro. + * m4/fseeko.m4 (gl_REPLACE_FSEEKO): Also replace fseek, if fseek + module is in use. + * lib/stdio.in.h (GNULIB_FSEEKO): Only poison fseek if fseek + module is not in use; since REPLACE_FSEEK worked otherwise. + (GNULIB_FTELLO): Likewise for ftell. + Reported by Ian Beckwith and others. + 2009-10-27 Bruno Haible * lib/isnan.c (rpl_isnan[fdl]): Repeat the specification declaration. Reported by Jim Meyering. 2009-10-27 Jim Meyering - Bruno Haible + Bruno Haible Avoid warning despite dropping the return value of fwrite. * lib/unicodeio.c: Include ignore-value.h. diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 7a0bc12d3..d0ffa5986 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -227,7 +227,14 @@ extern int rpl_fseek (FILE *fp, long offset, int whence); fflush(), and which detect pipes. */ # define fseeko rpl_fseeko extern int fseeko (FILE *fp, off_t offset, int whence); -# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) +# if !@GNULIB_FSEEK@ +# undef fseek +# define fseek(f,o,w) \ + (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use fseeko function for handling of large files"), \ + fseeko (f, o, w)) +# endif # endif #elif defined GNULIB_POSIXCHECK # undef fseeko @@ -263,7 +270,14 @@ extern long rpl_ftell (FILE *fp); # if @REPLACE_FTELLO@ # define ftello rpl_ftello extern off_t ftello (FILE *fp); -# define ftell(fp) ftello (fp) +# if !@GNULIB_FTELL@ +# undef ftell +# define ftell(f) \ + (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use ftello function for handling of large files"), \ + ftello (f)) +# endif # endif #elif defined GNULIB_POSIXCHECK # undef ftello diff --git a/m4/fseek.m4 b/m4/fseek.m4 index 80e450108..c33297dc5 100644 --- a/m4/fseek.m4 +++ b/m4/fseek.m4 @@ -1,5 +1,5 @@ -# fseek.m4 serial 1 -dnl Copyright (C) 2007 Free Software Foundation, Inc. +# fseek.m4 serial 2 +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, dnl with or without modifications, as long as this notice is preserved. @@ -9,8 +9,12 @@ AC_DEFUN([gl_FUNC_FSEEK], AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_FSEEKO]) dnl When fseeko needs fixes, fseek needs them too. - if test $REPLACE_FSEEKO != 0; then - AC_LIBOBJ([fseek]) - REPLACE_FSEEK=1 - fi + dnl gl_FUNC_FSEEKO takes care of calling gl_REPLACE_FSEEK +]) + +AC_DEFUN([gl_REPLACE_FSEEK], +[ + AC_LIBOBJ([fseek]) + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + REPLACE_FSEEK=1 ]) diff --git a/m4/fseeko.m4 b/m4/fseeko.m4 index 3d7736568..c9fbfb7fc 100644 --- a/m4/fseeko.m4 +++ b/m4/fseeko.m4 @@ -1,5 +1,5 @@ -# fseeko.m4 serial 4 -dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. +# fseeko.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, dnl with or without modifications, as long as this notice is preserved. @@ -15,7 +15,7 @@ AC_DEFUN([gl_FUNC_FSEEKO], AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko], [ - AC_TRY_LINK([#include ], [fseeko (stdin, 0, 0);], + AC_TRY_LINK([[#include ]], [fseeko (stdin, 0, 0);], [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no]) ]) if test $gl_cv_func_fseeko = no; then @@ -31,4 +31,6 @@ 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]) ]) -- 2.11.0