]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Of course, I shouldn't have used lseek() to find out the file's
authorGuido van Rossum <guido@python.org>
Tue, 3 Mar 1998 22:36:10 +0000 (22:36 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 3 Mar 1998 22:36:10 +0000 (22:36 +0000)
position in new_buffersize(); the correct function to use is ftell().
Thanks to Ben Jackson.

Objects/fileobject.c

index 5502f156ff68bd487ffd41329c1e156c8cab3d95..f8c58ba45430e0d3462584ce2c8a6831679bd83a 100644 (file)
@@ -406,17 +406,14 @@ 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 = lseek(fileno(f->f_fp), 0L, SEEK_CUR);
+               pos = ftell(f->f_fp);
                if (end > pos && pos >= 0)
-                       return end - pos + BUFSIZ;
-               /* Add BUFSIZ to allow for stdio buffered data */
+                       return end - pos + 1;
+               /* Add 1 so if the file were to grow we'd notice. */
        }
 #endif
        if (currentsize > SMALLCHUNK) {