summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-08-21 02:31:25 (GMT)
committerGuido van Rossum <guido@python.org>1997-08-21 02:31:25 (GMT)
commit36f8e2d1dbaa9a1c4c4f4ecde78b4889225ca451 (patch)
tree02ec565fc17a1aae047aa3c3aea88fe12deb633a /Objects
parentc6ef204830320ddca65c14b3c8fd5c50ba11d4ef (diff)
downloadcpython-36f8e2d1dbaa9a1c4c4f4ecde78b4889225ca451.zip
cpython-36f8e2d1dbaa9a1c4c4f4ecde78b4889225ca451.tar.gz
cpython-36f8e2d1dbaa9a1c4c4f4ecde78b4889225ca451.tar.bz2
Use lseek instead of ftell; compensate by adding BUFSIZE
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index d47b1db..a0d05c4 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -406,13 +406,17 @@ new_buffersize(f, currentsize)
size_t currentsize;
{
#ifdef HAVE_FSTAT
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
long pos, end;
struct stat st;
if (fstat(fileno(f->f_fp), &st) == 0) {
end = st.st_size;
- pos = ftell(f->f_fp);
+ pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR);
if (end > pos && pos >= 0)
- return end - pos + 1;
+ return end - pos + BUFSIZ;
+ /* Add BUFSIZ to allow for stdio buffered data */
}
#endif
if (currentsize > SMALLCHUNK) {