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

* io.c (read_all): shift read buffer if exception occured.

pointed out in [ruby-dev:39702].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wanabe 2009-11-16 05:06:16 +00:00
parent ca7b32630c
commit 98cf9c43fa
2 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Nov 16 14:03:53 2009 wanabe <s.wanabe@gmail.com>
* io.c (read_all): shift read buffer if exception occured.
pointed out in [ruby-dev:39702].
Mon Nov 16 07:59:38 2009 wanabe <s.wanabe@gmail.com> Mon Nov 16 07:59:38 2009 wanabe <s.wanabe@gmail.com>
* io.c (read_all): don't call io_shift_cbuf until bufffering enough or * io.c (read_all): don't call io_shift_cbuf until bufffering enough or

9
io.c
View file

@ -1686,13 +1686,20 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
else rb_str_set_len(str, 0); else rb_str_set_len(str, 0);
make_readconv(fptr, 0); make_readconv(fptr, 0);
while (1) { while (1) {
int fin, state = 0;
if (fptr->cbuf_len > fptr->cbuf_capa / 2) { if (fptr->cbuf_len > fptr->cbuf_capa / 2) {
io_shift_cbuf(fptr, fptr->cbuf_len, &str); io_shift_cbuf(fptr, fptr->cbuf_len, &str);
} }
if (more_char(fptr) == -1) {
fin = rb_protect((VALUE (*)(VALUE))more_char, (VALUE)fptr, &state);
if (fin == -1 || state != 0) {
if (fptr->cbuf_len) { if (fptr->cbuf_len) {
io_shift_cbuf(fptr, fptr->cbuf_len, &str); io_shift_cbuf(fptr, fptr->cbuf_len, &str);
} }
if (state != 0) {
rb_jump_tag(state);
}
clear_readconv(fptr); clear_readconv(fptr);
return io_enc_str(str, fptr); return io_enc_str(str, fptr);
} }