summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-11 11:59:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-11 11:59:00 +0000
commit7dae5b90d4f428add1e71cd0c24ea75b9dbab031 (patch)
treefe5fed90346bc6ff366b6819d8d6a13729730b91
parent8eacd4fbfa67a81a1d3402be52ff8190dc92c579 (diff)
downloadruby-7dae5b90d4f428add1e71cd0c24ea75b9dbab031.tar.gz
ruby-7dae5b90d4f428add1e71cd0c24ea75b9dbab031.tar.xz
ruby-7dae5b90d4f428add1e71cd0c24ea75b9dbab031.zip
* io.c (remain_size): use buffered data instead of unreading to avoid
inconsistency of text mode. fixed: [ruby-dev:25446] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c10
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b14b04f99..90cc73873 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 11 20:58:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (remain_size): use buffered data instead of unreading to avoid
+ inconsistency of text mode. fixed: [ruby-dev:25446]
+
Tue Jan 11 09:37:53 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (Init_Numeric): turn off floating point exceptions
diff --git a/io.c b/io.c
index b2496b7b1..f3c7ed608 100644
--- a/io.c
+++ b/io.c
@@ -1120,7 +1120,7 @@ remain_size(fptr)
OpenFile *fptr;
{
struct stat st;
- off_t siz = BUFSIZ;
+ off_t siz = READ_DATA_PENDING_COUNT(fptr);
off_t pos;
if (fstat(fptr->fd, &st) == 0 && S_ISREG(st.st_mode)
@@ -1129,14 +1129,18 @@ remain_size(fptr)
#endif
)
{
- pos = io_tell(fptr);
+ io_fflush(fptr);
+ pos = lseek(fptr->fd, 0, SEEK_CUR);
if (st.st_size >= pos && pos >= 0) {
- siz = st.st_size - pos + 1;
+ siz += st.st_size - pos + 1;
if (siz > LONG_MAX) {
rb_raise(rb_eIOError, "file too big for single read");
}
}
}
+ else {
+ siz += BUFSIZ;
+ }
return (long)siz;
}