summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-13 05:02:55 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-13 05:02:55 +0000
commit3432474c906343d4a739a860c32371124def0349 (patch)
treeb5dedf27c3d8c867f8c31823fd57f4fa1d982541 /file.c
parent06675418948d45f5448c7b722f1e7c990f5c89bc (diff)
* file.c (rb_file_join): check encoding compatibility before joining
strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/file.c b/file.c
index 88a7065cf7..2aa896ae47 100644
--- a/file.c
+++ b/file.c
@@ -3940,6 +3940,7 @@ rb_file_join(VALUE ary, VALUE sep)
VALUE result, tmp;
const char *name, *tail;
int checked = TRUE;
+ rb_encoding *enc;
if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
@@ -3994,10 +3995,14 @@ rb_file_join(VALUE ary, VALUE sep)
rb_str_set_len(result, tail - name);
}
else if (!*tail) {
+ enc = rb_enc_check(result, sep);
rb_str_buf_append(result, sep);
+ rb_enc_associate(result, enc);
}
}
+ enc = rb_enc_check(result, tmp);
rb_str_buf_append(result, tmp);
+ rb_enc_associate(result, enc);
}
RBASIC(result)->klass = rb_cString;