1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (ary_join_1): should not copy the encoding of non-string

element after string element.  [ruby-core:39776] [Bug #5379]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-09-29 18:18:03 +00:00
parent 8ce9cb8f31
commit 813f358569
3 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Thu Sep 29 13:17:51 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (ary_join_1): should not copy the encoding of non-string
element after string element. [ruby-core:39776] [Bug #5379]
Thu Sep 29 11:53:56 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Sep 29 11:53:56 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (slot_sweep, rb_gc_finalize_deferred) * gc.c (slot_sweep, rb_gc_finalize_deferred)

View file

@ -1659,6 +1659,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
case T_STRING: case T_STRING:
str_join: str_join:
rb_str_buf_append(result, val); rb_str_buf_append(result, val);
*first = FALSE;
break; break;
case T_ARRAY: case T_ARRAY:
obj = val; obj = val;

View file

@ -926,6 +926,8 @@ class TestArray < Test::Unit::TestCase
assert_equal(Encoding::US_ASCII, [1, [u]].join.encoding) assert_equal(Encoding::US_ASCII, [1, [u]].join.encoding)
assert_equal(Encoding::UTF_8, [u, [e]].join.encoding) assert_equal(Encoding::UTF_8, [u, [e]].join.encoding)
assert_equal(Encoding::UTF_8, [u, [1]].join.encoding) assert_equal(Encoding::UTF_8, [u, [1]].join.encoding)
bug5379 = '[ruby-core:39776]'
assert_equal(Encoding::UTF_8, [[], u, nil].join.encoding, bug5379)
ensure ensure
$, = nil $, = nil
end end