summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/file.c b/file.c
index bd96ffee35..3107895037 100644
--- a/file.c
+++ b/file.c
@@ -3847,7 +3847,10 @@ rb_file_join(VALUE ary, VALUE sep)
FilePathStringValue(tmp);
}
name = StringValueCStr(result);
- if (i > 0 && !NIL_P(sep)) {
+ if (i == 0) {
+ rb_enc_copy(result, tmp);
+ }
+ else if (!NIL_P(sep)) {
tail = chompdirsep(name);
if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) {
rb_str_set_len(result, tail - name);