summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-16 13:25:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-16 13:25:11 +0000
commitb7d6b2299bc2a2b8f205818396cd555b0e9e967a (patch)
treeb050ebf2a681ea0ece1b5313517bb817b8d9ed15 /ruby.c
parent316f58076d29dcff053256992d9ec19fed7e698f (diff)
ruby.c: script __dir__ encoding
* ruby.c (process_options): fallback to the encoding of the script name since rb_realpath_internal() cannot convert the encoding when it is ASCII-8BIT. * test/ruby/test_rubyoptions.rb (test___dir__encoding): explicitly pass environment variables for locale as they are overriden by invoke_ruby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ruby.c b/ruby.c
index f0af34a9a8..452d0a0e3c 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1744,6 +1744,9 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
path = str_conv_enc(path, uenc, lenc);
}
#endif
+ if (!ENCODING_GET(path)) { /* ASCII-8BIT */
+ rb_enc_copy(path, opt->script_name);
+ }
}
base_block = toplevel_context(toplevel_binding);
iseq = rb_iseq_new_main(ast->root, opt->script_name, path, vm_block_iseq(base_block));