summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-29 15:02:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-29 15:02:58 +0000
commit1ce81d6f8b00186dcae04005f502248f986fbe75 (patch)
tree37fbba1278ccfc02c9e0b4b9d26ab8e2d34f2a45 /ruby.c
parentb4c3c3171f4a8b9c39b68bf5e545d8853b84ff77 (diff)
ruby.c: transcode program names
* ruby.c (process_options, ruby_script): transcode script name and program name to locale encoding as well as argv. [ruby-dev:48752] [Bug #10555] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ruby.c b/ruby.c
index 92dac98..967c8a9 100644
--- a/ruby.c
+++ b/ruby.c
@@ -346,6 +346,16 @@ translit_char_bin(char *p, int from, int to)
# define UTF8_PATH 0
#endif
+#if UTF8_PATH
+static VALUE
+str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
+{
+ return rb_str_conv_enc_opts(str, from, to,
+ ECONV_UNDEF_REPLACE|ECONV_INVALID_REPLACE,
+ Qnil);
+}
+#endif
+
void ruby_init_loadpath_safe(int safe_level);
void
@@ -1404,6 +1414,10 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
rb_define_module("Gem");
}
ruby_init_prelude();
+#if UTF8_PATH
+ opt->script_name = str_conv_enc(opt->script_name, rb_utf8_encoding(), lenc);
+ opt->script = RSTRING_PTR(opt->script_name);
+#endif
ruby_set_argv(argc, argv);
process_sflag(&opt->sflag);
@@ -1819,9 +1833,7 @@ external_str_new_cstr(const char *p)
{
#if UTF8_PATH
VALUE str = rb_utf8_str_new_cstr(p);
- return rb_str_conv_enc_opts(str, NULL, rb_default_external_encoding(),
- ECONV_UNDEF_REPLACE|ECONV_INVALID_REPLACE,
- Qnil);
+ return str_conv_enc(str, NULL, rb_default_external_encoding());
#else
return rb_external_str_new_cstr(p);
#endif
@@ -1836,7 +1848,7 @@ void
ruby_script(const char *name)
{
if (name) {
- rb_orig_progname = rb_progname = rb_external_str_new(name, strlen(name));
+ rb_orig_progname = rb_progname = external_str_new_cstr(name);
rb_vm_set_progname(rb_progname);
}
}