summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-24 08:54:26 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-24 08:54:26 +0000
commitcea49f7ca653df88fa0432e673179dde86b6c4ff (patch)
treec7b49f0ff7e18aa02bd93bfaf7517c1f3f4ec0f4
parentfe8e1058231a9ce40725ae6780ed2505ef79e882 (diff)
merge revision(s) 17103:
* ext/stringio/stringio.c (strio_init): rewind when reopened. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@26171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/stringio/stringio.c2
-rw-r--r--test/stringio/test_stringio.rb13
-rw-r--r--version.h2
4 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b400b555e..f80a2468f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Dec 24 17:50:35 2009 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * ext/stringio/stringio.c (strio_init): rewind when reopened.
+
Thu Dec 24 17:06:13 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (run_final): runs finalizers with the object terminated.
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 71b7b69f71..cd68185dc4 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 fce067b24b..656d9945c3 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-12-24"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20091224
-#define RUBY_PATCHLEVEL 245
+#define RUBY_PATCHLEVEL 246
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8