[Rd] fix for broken largefile seek() on 32-bit linux (PR#9883)

jbrzusto at fastmail.fm jbrzusto at fastmail.fm
Mon Aug 27 16:33:48 CEST 2007


Full_Name: John Brzustowski
Version: R-devel-trunk, R-2.4.0
OS: linux
Submission from: (NULL) (206.248.132.197)


DESCRIPTION

seek() on files larger than 2 gigabytes fails for large values of "where" on
i386 linux 2.6.13 (and presumably other 32-bit unix-like platforms).

e.g.:

> f<-file("3gigabytefile.dat", "rb")
> seek(f, 3e9, "start", "r")
[1] 0  ## correct
> seek(f, NA, "start", "r")
[1] 0  ## should be 3e+09

DIAGNOSIS

Typo: the compile-time tests for large file support use "HAVE_SEEKO" instead of
"HAVE_FSEEKO", and so fail.  

The same typo appears in one of the extra/zlib files, so I'm fixing
it in the patch below, but I haven't tested whether that actually
produces a bug.

PATCH
Index: src/extra/zlib/gzio.c
===================================================================
--- src/extra/zlib/gzio.c	(revision 42664)
+++ src/extra/zlib/gzio.c	(working copy)
@@ -25,7 +25,7 @@
 #include "zutil.h"
 
 /* R ADDITION */
-#if defined(HAVE_OFF_T) && defined(HAVE_SEEKO)
+#if defined(HAVE_OFF_T) && defined(HAVE_FSEEKO)
 #define f_seek fseeko
 #define f_tell ftello
 #else
Index: src/include/Rconnections.h
===================================================================
--- src/include/Rconnections.h	(revision 42664)
+++ src/include/Rconnections.h	(working copy)
@@ -63,7 +63,7 @@
 
 typedef struct fileconn {
     FILE *fp;
-#if defined(HAVE_OFF_T) && defined(HAVE_SEEKO)
+#if defined(HAVE_OFF_T) && defined(HAVE_FSEEKO)
     off_t rpos, wpos;
 #else
 #ifdef Win32
Index: src/main/connections.c
===================================================================
--- src/main/connections.c	(revision 42664)
+++ src/main/connections.c	(working copy)
@@ -446,7 +446,7 @@
 
 /* ------------------- file connections --------------------- */
 
-#if defined(HAVE_OFF_T) && defined(HAVE_SEEKO)
+#if defined(HAVE_OFF_T) && defined(HAVE_FSEEKO)
 #define f_seek fseeko
 #define f_tell ftello
 #else
@@ -570,7 +570,7 @@
 {
     Rfileconn this = con->private;
     FILE *fp = this->fp;
-#if defined(HAVE_OFF_T) && defined(HAVE_SEEKO)
+#if defined(HAVE_OFF_T) && defined(HAVE_FSEEKO)
     off_t pos;
 #else
 #ifdef Win32



More information about the R-devel mailing list