aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-29 10:49:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-29 10:49:40 +0000
commit12cd6efccf18d28d4ebbff75bec8c5815bbb39fd (patch)
treec5a9c1452c6a320010769aa3e80ec7b89df41791 /array.c
parent9974ae67b492aab2c2d4d4d67869fc40599b2553 (diff)
downloadruby-12cd6efccf18d28d4ebbff75bec8c5815bbb39fd.tar.gz
array.c: join encoding
* array.c (ary_join_1): copy the encoding of the converted string of the first element by to_str too, as an initial encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/array.c b/array.c
index ecf1fed5c1..f8faf697bf 100644
--- a/array.c
+++ b/array.c
@@ -1994,7 +1994,10 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
if (RB_TYPE_P(val, T_STRING)) {
str_join:
rb_str_buf_append(result, val);
- *first = FALSE;
+ if (*first) {
+ rb_enc_copy(result, val);
+ *first = FALSE;
+ }
}
else if (RB_TYPE_P(val, T_ARRAY)) {
obj = val;
@@ -2025,10 +2028,6 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
goto ary_join;
}
val = rb_obj_as_string(val);
- if (*first) {
- rb_enc_copy(result, val);
- *first = FALSE;
- }
goto str_join;
}
}