Follow our own advice: fseek is not safe to use on large files.
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
(clear_ungetc_buffer): Avoid potential problems on large files.
* lib/freadseek.c (freadseek): Likewise.
* modules/freadseek (Depends-on): Add fseeko.
* modules/fseek (configure.ac): Set a witness.
* tests/test-fflush.c (main): Use fseeko.
* tests/test-fpurge.c (fseek): Disable link warning.
* tests/test-freadable.c (fseek): Likewise.
* tests/test-freading.c (fseek): Likewise.
* tests/test-fseeko.c (fseek): Likewise.
* tests/test-ftell.c (fseek): Likewise.
* tests/test-ftello.c (fseek): Likewise.
* tests/test-fwritable.c (fseek): Likewise.
* tests/test-fwriting.c (fseek): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
+2009-11-07 Eric Blake <ebb9@byu.net>
+
+ fflush, freadseek: use fseeko, not fseek
+ * lib/fflush.c (clear_ungetc_buffer_preserving_position)
+ (clear_ungetc_buffer): Avoid potential problems on large files.
+ * lib/freadseek.c (freadseek): Likewise.
+ * modules/freadseek (Depends-on): Add fseeko.
+ * modules/fseek (configure.ac): Set a witness.
+ * tests/test-fflush.c (main): Use fseeko.
+ * tests/test-fpurge.c (fseek): Disable link warning.
+ * tests/test-freadable.c (fseek): Likewise.
+ * tests/test-freading.c (fseek): Likewise.
+ * tests/test-fseeko.c (fseek): Likewise.
+ * tests/test-ftell.c (fseek): Likewise.
+ * tests/test-ftello.c (fseek): Likewise.
+ * tests/test-fwritable.c (fseek): Likewise.
+ * tests/test-fwriting.c (fseek): Likewise.
+
2009-11-06 Simon Josefsson <simon@josefsson.org>
* modules/memchr (Depends-on): Drop getpagesize dependency.
{
if (fp->_flags & _IO_IN_BACKUP)
/* _IO_free_backup_area is a bit complicated. Simply call fseek. */
- fseek (fp, 0, SEEK_CUR);
+ fseeko (fp, 0, SEEK_CUR);
}
#else
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
/* Nothing to do. */
# else /* other implementations */
- fseek (fp, 0, SEEK_CUR);
+ fseeko (fp, 0, SEEK_CUR);
# endif
}
if (fd >= 0 && lseek (fd, 0, SEEK_CUR) >= 0)
{
/* FP refers to a regular file. fseek is most efficient in this case. */
- return fseek (fp, offset, SEEK_CUR);
+ return fseeko (fp, offset, SEEK_CUR);
}
else
{
Depends-on:
freadahead
freadptr
+fseeko
lseek
configure.ac:
configure.ac:
gl_FUNC_FSEEK
+gl_MODULE_INDICATOR([fseek])
gl_STDIO_MODULE_INDICATOR([fseek])
Makefile.am:
}
#endif
/* POSIX requires fflush-fseek to set file offset of fd. */
- if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
+ if (fflush (f) != 0 || fseeko (f, 0, SEEK_CUR) != 0)
{
fputs ("Failed to flush-fseek sample file.\n", stderr);
fclose (f);
#include <stdlib.h>
#include <string.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
/* Test of freadable() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 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
#include <stdio.h>
#include <stdlib.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
#include <stdio.h>
#include <stdlib.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
#include <stdio.h>
#include <stdlib.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
#include "binary-io.h"
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
#include "binary-io.h"
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
/* Test of fwritable() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 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
#include <stdio.h>
#include <stdlib.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \
/* Test of fwriting() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 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
#include <stdio.h>
#include <stdlib.h>
+/* None of the files accessed by this test are large, so disable the
+ fseek link warning if we are not using the gnulib fseek module. */
+#if !GNULIB_FSEEK
+# undef fseek
+#endif
+
#define ASSERT(expr) \
do \
{ \