Kaydet (Commit) 36f8e2d1 authored tarafından Guido van Rossum's avatar Guido van Rossum

Use lseek instead of ftell; compensate by adding BUFSIZE

üst c6ef2048
...@@ -406,13 +406,17 @@ new_buffersize(f, currentsize) ...@@ -406,13 +406,17 @@ new_buffersize(f, currentsize)
size_t currentsize; size_t currentsize;
{ {
#ifdef HAVE_FSTAT #ifdef HAVE_FSTAT
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
long pos, end; long pos, end;
struct stat st; struct stat st;
if (fstat(fileno(f->f_fp), &st) == 0) { if (fstat(fileno(f->f_fp), &st) == 0) {
end = st.st_size; end = st.st_size;
pos = ftell(f->f_fp); pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR);
if (end > pos && pos >= 0) if (end > pos && pos >= 0)
return end - pos + 1; return end - pos + BUFSIZ;
/* Add BUFSIZ to allow for stdio buffered data */
} }
#endif #endif
if (currentsize > SMALLCHUNK) { if (currentsize > SMALLCHUNK) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment