Mercurial > hg > octave-kai > gnulib-hg
changeset 12202:a0f033ee41af
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 <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Tue, 27 Oct 2009 10:42:50 -0600 |
parents | 96048aa0ade9 |
children | e298b64a31cf |
files | ChangeLog lib/stdio.in.h m4/fseek.m4 m4/fseeko.m4 |
diffstat | 4 files changed, 43 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,21 @@ +2009-10-27 Eric Blake <ebb9@byu.net> + + 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 <bruno@clisp.org> * lib/isnan.c (rpl_isnan[fdl]): Repeat the specification declaration. Reported by Jim Meyering. 2009-10-27 Jim Meyering <jim@meyering.net> - Bruno Haible <bruno@clisp.org> + Bruno Haible <bruno@clisp.org> Avoid warning despite dropping the return value of fwrite. * lib/unicodeio.c: Include ignore-value.h.
--- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -227,7 +227,14 @@ 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 @@ # 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
--- 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_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 +])
--- 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_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko], [ - AC_TRY_LINK([#include <stdio.h>], [fseeko (stdin, 0, 0);], + AC_TRY_LINK([[#include <stdio.h>]], [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_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]) ])