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 | 4310b5d9ce709225c594ba1e04b2cfe13b105d25 (patch) | |
| tree | 2f3668175da80ef4684c1fcf68f62a171cd3de4f /io.c | |
| parent | e16ca20e84705cdd59a3f4a74c2e062e2eb384d9 (diff) | |
| download | ruby-4310b5d9ce709225c594ba1e04b2cfe13b105d25.tar.gz ruby-4310b5d9ce709225c594ba1e04b2cfe13b105d25.tar.xz ruby-4310b5d9ce709225c594ba1e04b2cfe13b105d25.zip | |
* 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: http://svn.ruby-lang.org/repos/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) { |
