Mercurial > hg > octave-lojdl > gnulib-hg
changeset 8884:cccbcdfb7afa
New module 'fseek'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 28 May 2007 14:48:52 +0000 |
parents | 84c04df874fd |
children | 3995f1e5ccc7 |
files | ChangeLog lib/fseek.c lib/stdio_.h m4/fseek.m4 m4/stdio_h.m4 modules/fseek modules/stdio |
diffstat | 7 files changed, 103 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-05-28 Bruno Haible <bruno@clisp.org> + + * lib/fseek.c: New file. + * modules/fseek: New file. + * m4/fseek.m4: New file. + * doc/functions/fseek.texi: Update. + * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Set also GNULIB_FSEEK, + REPLACE_FSEEK. + * lib/stdio_.h (rpl_fseek): New declaration. + * modules/stdio (Makefile.am): Substitute also GNULIB_FSEEK, + REPLACE_FSEEK. + 2007-05-28 Bruno Haible <bruno@clisp.org> * lib/stdio_.h (fflush): More comments.
new file mode 100644 --- /dev/null +++ b/lib/fseek.c @@ -0,0 +1,31 @@ +/* An fseek() function that, together with fflush(), is POSIX compliant. + Copyright (C) 2007 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include <config.h> + +/* Specification. */ +#include <stdio.h> + +/* Get off_t. */ +#include <unistd.h> + +int +fseek (FILE *fp, long offset, int whence) +{ + /* Use the replacement fseeko function with all its workarounds. */ + return fseeko (fp, (off_t)offset, whence); +}
--- a/lib/stdio_.h +++ b/lib/stdio_.h @@ -232,7 +232,19 @@ fseeko (f, o, w)) #endif -#if defined GNULIB_POSIXCHECK +#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ +extern int rpl_fseek (FILE *fp, long offset, int whence); +# undef fseek +# if defined GNULIB_POSIXCHECK +# 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"), \ + rpl_fseek (f, o, w)) +# else +# define fseek rpl_fseek +# endif +#elif defined GNULIB_POSIXCHECK # ifndef fseek # define fseek(f,o,w) \ (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
new file mode 100644 --- /dev/null +++ b/m4/fseek.m4 @@ -0,0 +1,16 @@ +# fseek.m4 serial 1 +dnl Copyright (C) 2007 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. + +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 +])
--- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# stdio_h.m4 serial 5 +# stdio_h.m4 serial 6 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -30,6 +30,7 @@ GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) + GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) @@ -48,6 +49,7 @@ REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO]) + REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK]) HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
new file mode 100644 --- /dev/null +++ b/modules/fseek @@ -0,0 +1,26 @@ +Description: +fseek() function: Reposition a FILE stream. + +Files: +lib/fseek.c +m4/fseek.m4 + +Depends-on: +fseeko +stdio + +configure.ac: +gl_FUNC_FSEEK +gl_STDIO_MODULE_INDICATOR([fseek]) + +Makefile.am: + +Include: +<stdio.h> + +License: +LGPL + +Maintainer: +Bruno Haible +
--- a/modules/stdio +++ b/modules/stdio @@ -31,6 +31,7 @@ -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ + -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ @@ -47,6 +48,7 @@ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ + -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \