diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 16:40:05 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 16:40:05 +0000 |
commit | 86ade651044cc606584e11a5b2e8d02f315d3fa9 (patch) | |
tree | 2f3668175da80ef4684c1fcf68f62a171cd3de4f /io.c | |
parent | 2e51b7f9dacc5420c1f269dde24cb0677cce5571 (diff) | |
download | ruby-86ade651044cc606584e11a5b2e8d02f315d3fa9.tar.gz |
* io.c (rb_io_rewind): should reset fptr->readconv if it's
available.
* io.c (more_char): clear readconv at EOF.
* test/ruby/test_file.rb: should not read after EOF. use rewind
instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1057,6 +1057,8 @@ rb_io_set_pos(VALUE io, VALUE offset) return OFFT2NUM(pos); } +static void clear_readconv(rb_io_t *fptr); + /* * call-seq: * ios.rewind => 0 @@ -1082,6 +1084,9 @@ rb_io_rewind(VALUE io) ARGF.gets_lineno -= fptr->lineno; } fptr->lineno = 0; + if (fptr->readconv) { + clear_readconv(fptr); + } return INT2FIX(0); } @@ -1499,8 +1504,10 @@ more_char(rb_io_t *fptr) if (cbuf_len0 != fptr->cbuf_len) return 0; - if (res == econv_finished) + if (res == econv_finished) { + clear_readconv(fptr); return -1; + } if (res == econv_source_buffer_empty) { if (fptr->rbuf_len == 0) { |