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
This commit is contained in:
parent
bd4a419d3e
commit
d9b9423ba8
18
ruby.c
18
ruby.c
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user