From 58b6ac5f67329330e34c09f6612ea90e1598a5ae Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 30 Oct 2008 12:09:24 +0000 Subject: merges r20045 from trunk into ruby_1_9_1. * 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/branches/ruby_1_9_1@20058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index 772d9e4d71..5fa6a1f17c 100644 --- a/io.c +++ b/io.c @@ -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) { -- cgit v1.2.3