summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--array.c1
-rw-r--r--test/ruby/test_array.rb2
3 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dc69c4b33..41a2db78f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* gc.c (slot_sweep, rb_gc_finalize_deferred)
diff --git a/array.c b/array.c
index 82013df69d..8816d15590 100644
--- a/array.c
+++ b/array.c
@@ -1659,6 +1659,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
case T_STRING:
str_join:
rb_str_buf_append(result, val);
+ *first = FALSE;
break;
case T_ARRAY:
obj = val;
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 64524768e1..8d25e85d62 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -926,6 +926,8 @@ class TestArray < Test::Unit::TestCase
assert_equal(Encoding::US_ASCII, [1, [u]].join.encoding)
assert_equal(Encoding::UTF_8, [u, [e]].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
$, = nil
end