From ef0706a5bf4dd888363f017c2408899009c24c4a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Dec 2007 04:40:13 +0000 Subject: * encoding.c (rb_enc_register): set encoding constant. * encoding.c (rb_enc_find_index): replace non-alphanumeric chars with underscores, so that initialize function can be called. * ruby.c (proc_options, process_options): finds encoding after load_path is initialized. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 66b7aab83a..19b243578f 100644 --- a/ruby.c +++ b/ruby.c @@ -81,6 +81,7 @@ struct cmdline_options { int yydebug; char *script; VALUE e_script; + const char *enc_name; int enc_index; }; @@ -739,7 +740,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_enc_name(enc); } s++; } @@ -810,9 +811,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) rb_raise(rb_eRuntimeError, "missing argument for --encoding"); } encoding: - if ((opt->enc_index = rb_enc_find_index(s)) < 0) { - rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s); - } + opt->enc_name = s; } else if (strncmp("encoding=", s, 9) == 0) { if (!*(s += 9)) goto noencoding; @@ -981,6 +980,11 @@ process_options(VALUE arg) ruby_init_gems(opt); parser = rb_parser_new(); if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue); + if ((s = opt->enc_name) != 0) { + 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); -- cgit v1.2.3