From d222472299a9c2ce8fc094c162f1acd2f4199403 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 11 Jun 2008 17:50:03 +0000 Subject: * ext/stringio/stringio.c (strio_init): rewind when reopened. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/stringio/stringio.c | 2 ++ test/stringio/test_stringio.rb | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dac15ac9cf..5f1e69a3e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jun 12 02:49:40 2008 Yusuke Endoh + + * ext/stringio/stringio.c (strio_init): rewind when reopened. + Thu Jun 12 02:43:27 2008 Yusuke Endoh * array.c (rb_ary_zip): ANSI style. diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 2f32d5a30d..604ea87800 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -192,6 +192,8 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr) break; } ptr->string = string; + ptr->pos = 0; + ptr->lineno = 0; } static VALUE diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index d022c10fad..8f0dc8702c 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -252,11 +252,11 @@ class TestStringIO < Test::Unit::TestCase f = StringIO.new("foo\nbar\nbaz\n") assert_equal("foo\n", f.gets) f.reopen("qux\nquux\nquuux\n") - assert_equal("quux\n", f.gets) + assert_equal("qux\n", f.gets) f2 = StringIO.new("") f2.reopen(f) - assert_equal("quuux\n", f2.gets) + assert_equal("quux\n", f2.gets) ensure f.close unless f.closed? end -- cgit v1.2.3