From 506c6f52b950c131b305456cf72fe8f84a2a8f5f Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 22 Apr 2014 18:44:48 +0000 Subject: Revert r45670 "stringio.c: use rb_str_append" It breaks test-all. http://u64b.rubyci.org/~chkbuild/ruby-trunk/log/20140422T143301Z.diff.html.gz rb_str_conv_enc() return original string for example when from ASCII-8BIT to UTF-8 with non ASCII strings git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ------ ext/stringio/stringio.c | 4 ++-- test/stringio/test_stringio.rb | 11 ----------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index de0a97fa7b..696b56639e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,12 +13,6 @@ Tue Apr 22 23:56:24 2014 NAKAMURA Usaku * configure.in (fstatfs): check it. -Tue Apr 22 23:14:28 2014 Nobuyoshi Nakada - - * ext/stringio/stringio.c (strio_write): use rb_str_append to - reuse coderange bits and keep taintedness. - [ruby-dev:48118] [Bug #9769] - Tue Apr 22 22:15:51 2014 NAKAMURA Usaku * file.c (rb_io_statfs): need to define even if the system doesn't have diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index dbd5a287c4..e964e79e12 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1170,6 +1170,7 @@ strio_write(VALUE self, VALUE str) long len, olen; rb_encoding *enc, *enc2; + RB_GC_GUARD(str); if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); enc = rb_enc_get(ptr->string); @@ -1185,7 +1186,7 @@ strio_write(VALUE self, VALUE str) ptr->pos = olen; } if (ptr->pos == olen) { - rb_str_append(ptr->string, str); + rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc); } else { strio_extend(ptr, ptr->pos, len); @@ -1193,7 +1194,6 @@ strio_write(VALUE self, VALUE str) OBJ_INFECT(ptr->string, str); } OBJ_INFECT(ptr->string, self); - RB_GC_GUARD(str); ptr->pos += len; return LONG2NUM(len); } diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index f4883455f6..c7db91aae1 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -119,17 +119,6 @@ class TestStringIO < Test::Unit::TestCase f.close unless f.closed? end - def test_write_infection - bug9769 = '[ruby-dev:48118] [Bug #9769]' - s = "".untaint - f = StringIO.new(s, "w") - f.print("bar".taint) - f.close - assert_predicate(s, :tainted?, bug9769) - ensure - f.close unless f.closed? - end - def test_mode_error f = StringIO.new("", "r") assert_raise(IOError) { f.write("foo") } -- cgit v1.2.3