summaryrefslogtreecommitdiff
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
commitef0706a5bf4dd888363f017c2408899009c24c4a (patch)
tree9c4741363c3f7162bd7fb73d5aeff1f32e37a349 /ruby.c
parentad47716266cc8048b6ec1c8d73490cfe06a05657 (diff)
* 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
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 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);