diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-31 14:57:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-31 14:57:46 +0000 |
commit | 6cb161a66c014db83c62ebf8a0d6beff60f44382 (patch) | |
tree | 7ed4a9f21700e32464402e87f4d5d1da04a6eda4 | |
parent | b4f09d76d3795650ed1f9109bcc9919e919c312b (diff) |
* ruby.c (proc_options, process_options): delays finding encoding
until load_path is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ruby.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -81,6 +81,7 @@ struct cmdline_options { int yydebug; char *script; VALUE e_script; + VALUE enc_name; int enc_index; }; @@ -723,7 +724,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) break; } if (enc) { - opt->enc_index = rb_enc_find_index(rb_enc_name(enc)); + opt->enc_name = rb_str_new2(rb_enc_name(enc)); } s++; } @@ -789,16 +790,12 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) else if (strcmp("disable-gems", s) == 0) opt->disable_gems = 1; else if (strcmp("encoding", s) == 0) { - int idx; if (!--argc || !(s = *++argv)) { noencoding: rb_raise(rb_eRuntimeError, "missing argument for --encoding"); } encoding: - if ((idx = rb_enc_find_index(s)) < 0) { - rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s); - } - opt->enc_index = idx; + opt->enc_name = rb_str_new2(s); } else if (strncmp("encoding=", s, 9) == 0) { if (!*(s += 9)) goto noencoding; @@ -967,6 +964,12 @@ process_options(VALUE arg) ruby_init_gems(opt); parser = rb_parser_new(); if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue); + if (opt->enc_name != 0) { + s = RSTRING_PTR(opt->enc_name); + if ((opt->enc_index = rb_enc_find_index(s)) < 0) { + rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s); + } + } if (opt->e_script) { if (opt->enc_index >= 0) rb_enc_associate_index(opt->e_script, opt->enc_index); |