summaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 04:40:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-21 04:40:13 +0000
commit75ee92129f2e5845e0c3c852155bc451970a4db7 (patch)
tree9c4741363c3f7162bd7fb73d5aeff1f32e37a349 /ruby.c
parent9bc459b96fb5c4e518b131c32b798c27eb894de1 (diff)
downloadruby-75ee92129f2e5845e0c3c852155bc451970a4db7.tar.gz
ruby-75ee92129f2e5845e0c3c852155bc451970a4db7.tar.xz
ruby-75ee92129f2e5845e0c3c852155bc451970a4db7.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@14399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ruby.c b/ruby.c
index 66b7aab83..19b243578 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);