From 4bf929db91462d2c8a433ea72b91fc87cda847b1 Mon Sep 17 00:00:00 2001 From: usa Date: Sat, 21 Oct 2017 15:43:05 +0000 Subject: The encoding of __FILE__ and __dir__ should be same * ruby.c (process_options): convert the real path of the script to locale encoding if its encoding is not locale (maybe UTF-8) on Windows/OS X. this change makes the encoding of __dir__ to the same encoding of __FILE__ when the script name is passed from commandline. * test/ruby/test_options.rb (test___dir__encoding): test for this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index e11f236870..cee50a34e8 100644 --- a/ruby.c +++ b/ruby.c @@ -1737,6 +1737,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) VALUE path = Qnil; if (!opt->e_script && strcmp(opt->script, "-")) { path = rb_realpath_internal(Qnil, script_name, 1); +#if UTF8_PATH + if (uenc != lenc) { + path = str_conv_enc(path, uenc, lenc); + } +#endif } base_block = toplevel_context(toplevel_binding); iseq = rb_iseq_new_main(tree, opt->script_name, path, vm_block_iseq(base_block)); -- cgit v1.2.3