diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-17 04:47:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-17 04:47:05 +0000 |
commit | d9b9423ba8f7cb178992e7087f71f3f163685eba (patch) | |
tree | bee0af9876bfb03ca0c2952d3aa69f3f61e04e0d /ruby.c | |
parent | bd4a419d3e41d275666f40044783ec4bf8705370 (diff) |
ruby.c: encode script name
* ruby.c (process_options): encode script name to locale encoding
instead of associate, if UTF-8 path.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -423,6 +423,8 @@ str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to) ECONV_UNDEF_REPLACE|ECONV_INVALID_REPLACE, Qnil); } +#else +# define str_conv_enc(str, from, to) (str) #endif void ruby_init_loadpath_safe(int safe_level); @@ -1564,9 +1566,15 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) ienc = enc; #endif } - rb_enc_associate(opt->script_name, lenc); + if (IF_UTF8_PATH((uenc = rb_utf8_encoding()) != lenc, 0)) { + opt->script_name = str_conv_enc(opt->script_name, uenc, lenc); + opt->script = RSTRING_PTR(opt->script_name); + } + else { + rb_enc_associate(opt->script_name, lenc); + } rb_obj_freeze(opt->script_name); - if (IF_UTF8_PATH((uenc = rb_utf8_encoding()) != lenc, 1)) { + if (IF_UTF8_PATH(uenc != lenc, 1)) { long i; VALUE load_path = GET_VM()->load_path; const ID id_initial_load_path_mark = INITIAL_LOAD_PATH_MARK; @@ -1602,12 +1610,6 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option); #undef SET_COMPILE_OPTION } -#if UTF8_PATH - if (uenc != lenc) { - opt->script_name = str_conv_enc(opt->script_name, uenc, lenc); - opt->script = RSTRING_PTR(opt->script_name); - } -#endif ruby_set_argv(argc, argv); process_sflag(&opt->sflag); |