From f9ac9e2dfc31aa0f641746c88a1cdc82d3bd016c Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 11 Jun 2008 18:30:10 +0000 Subject: [PATCH] * ext/stringio/stringio.c (strio_init): rewind when reopened. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/stringio/stringio.c | 2 ++ test/stringio/test_stringio.rb | 13 +++++++++++++ version.h | 6 +++--- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9951c3383..5500f4ab0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jun 12 03:20:59 2008 Yusuke Endoh + + * ext/stringio/stringio.c (strio_init): rewind when reopened. + Thu Jun 12 00:56:20 2008 Nobuyoshi Nakada * ext/tk: check proper conditions. [ruby-dev:35047] diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index f912c4193e..913fed7a5c 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -269,6 +269,8 @@ strio_init(argc, argv, 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 de15ab5508..4c67d19c60 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -40,4 +40,17 @@ class TestStringIO < Test::Unit::TestCase end assert_equal("hacker\nother ruby\n", stringio.string) end + + def test_reopen + f = StringIO.new("foo\nbar\nbaz\n") + assert_equal("foo\n", f.gets) + f.reopen("qux\nquux\nquuux\n") + assert_equal("qux\n", f.gets) + + f2 = StringIO.new("") + f2.reopen(f) + assert_equal("quux\n", f2.gets) + ensure + f.close unless f.closed? + end end diff --git a/version.h b/version.h index 4a24495fb3..39c4b2d55c 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-06-10" +#define RUBY_RELEASE_DATE "2008-06-12" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20080610 +#define RUBY_RELEASE_CODE 20080612 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 12 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];