1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (remain_size): use buffered data instead of unreading to avoid

inconsistency of text mode.  fixed: [ruby-dev:25446]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-01-11 11:59:00 +00:00
parent 0be6a1f5c8
commit 54198fca16
2 changed files with 12 additions and 3 deletions

View file

@ -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

10
io.c
View file

@ -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;
}