]> granicus.if.org Git - python/commitdiff
Use lseek instead of ftell; compensate by adding BUFSIZE
authorGuido van Rossum <guido@python.org>
Thu, 21 Aug 1997 02:31:25 +0000 (02:31 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 21 Aug 1997 02:31:25 +0000 (02:31 +0000)
Objects/fileobject.c

index d47b1dbe96c54a14b7487edc61967780b2cbd8a7..a0d05c485bc6db9ee208af574cd7dfab7d41b9ad 100644 (file)
@@ -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) {