summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 14:16:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 14:16:03 +0000
commit14ab3bd2ac7a3dda443342354847b99d1967e73a (patch)
tree49f26de01c06f516045143618a66b12d17dcad10 /ruby.c
parent70e01d72d875c5d68d3752622ac26e7e8cf150e3 (diff)
* ruby.c (proc_options): encoding option in shbang and RUBYOPT did not
work, do not store alloca()ed string in a parent scope struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/ruby.c b/ruby.c
index fce8479bd1..94aba59008 100644
--- a/ruby.c
+++ b/ruby.c
@@ -81,7 +81,6 @@ struct cmdline_options {
int yydebug;
char *script;
VALUE e_script;
- const char *enc_name;
int enc_index;
};
@@ -550,6 +549,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
{
int argc0 = argc;
const char *s;
+ const char *enc_name = 0;
if (argc == 0)
return 0;
@@ -740,7 +740,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
break;
}
if (enc) {
- opt->enc_name = rb_enc_name(enc);
+ opt->enc_index = rb_enc_find_index(rb_enc_name(enc));
}
s++;
}
@@ -806,12 +806,16 @@ 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:
- opt->enc_name = s;
+ if ((idx = rb_enc_find_index(s)) < 0) {
+ rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s);
+ }
+ opt->enc_index = idx;
}
else if (strncmp("encoding=", s, 9) == 0) {
if (!*(s += 9)) goto noencoding;
@@ -980,11 +984,6 @@ 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);