ruby-changes:46651
From: nobu <ko1@a...>
Date: Wed, 17 May 2017 13:47:10 +0900 (JST)
Subject: [ruby-changes:46651] nobu:r58767 (trunk): ruby.c: encode script name
nobu 2017-05-17 13:47:05 +0900 (Wed, 17 May 2017) New Revision: 58767 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58767 Log: ruby.c: encode script name * ruby.c (process_options): encode script name to locale encoding instead of associate, if UTF-8 path. Modified files: trunk/ruby.c Index: ruby.c =================================================================== --- ruby.c (revision 58766) +++ ruby.c (revision 58767) @@ -423,6 +423,8 @@ str_conv_enc(VALUE str, rb_encoding *fro https://github.com/ruby/ruby/blob/trunk/ruby.c#L423 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, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1566 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, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1610 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/