diff options
| author | Guido van Rossum <guido@python.org> | 1998-03-03 22:36:10 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 1998-03-03 22:36:10 +0000 |
| commit | dcb5e7f3892da0a8f7bb8ac518a2053c04ed1e43 (patch) | |
| tree | 17088fb1da125b09bed7a5a0fc477eb4f0ab2b8d /Objects/fileobject.c | |
| parent | d65911b3f3a2f8d72d170cc3537aa832d42591b6 (diff) | |
| download | cpython-git-dcb5e7f3892da0a8f7bb8ac518a2053c04ed1e43.tar.gz | |
Of course, I shouldn't have used lseek() to find out the file's
position in new_buffersize(); the correct function to use is ftell().
Thanks to Ben Jackson.
Diffstat (limited to 'Objects/fileobject.c')
| -rw-r--r-- | Objects/fileobject.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 5502f156ff..f8c58ba454 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -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) { |
