mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
b4f09d76d3
commit
6cb161a66c
1 changed files with 9 additions and 6 deletions
15
ruby.c
15
ruby.c
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue