1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2007-12-25 14:16:03 +00:00
parent 70e01d72d8
commit 14ab3bd2ac
2 changed files with 12 additions and 8 deletions

View file

@ -1,3 +1,8 @@
Tue Dec 25 23:16:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (proc_options): encoding option in shbang and RUBYOPT did not
work, do not store alloca()ed string in a parent scope struct.
Tue Dec 25 22:56:52 2007 NAKAMURA Usaku <usa@ruby-lang.org> Tue Dec 25 22:56:52 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (config.status): keep this file. * win32/Makefile.sub (config.status): keep this file.

15
ruby.c
View file

@ -81,7 +81,6 @@ struct cmdline_options {
int yydebug; int yydebug;
char *script; char *script;
VALUE e_script; VALUE e_script;
const char *enc_name;
int enc_index; int enc_index;
}; };
@ -550,6 +549,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
{ {
int argc0 = argc; int argc0 = argc;
const char *s; const char *s;
const char *enc_name = 0;
if (argc == 0) if (argc == 0)
return 0; return 0;
@ -740,7 +740,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
break; break;
} }
if (enc) { if (enc) {
opt->enc_name = rb_enc_name(enc); opt->enc_index = rb_enc_find_index(rb_enc_name(enc));
} }
s++; s++;
} }
@ -806,12 +806,16 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
else if (strcmp("disable-gems", s) == 0) else if (strcmp("disable-gems", s) == 0)
opt->disable_gems = 1; opt->disable_gems = 1;
else if (strcmp("encoding", s) == 0) { else if (strcmp("encoding", s) == 0) {
int idx;
if (!--argc || !(s = *++argv)) { if (!--argc || !(s = *++argv)) {
noencoding: noencoding:
rb_raise(rb_eRuntimeError, "missing argument for --encoding"); rb_raise(rb_eRuntimeError, "missing argument for --encoding");
} }
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) { else if (strncmp("encoding=", s, 9) == 0) {
if (!*(s += 9)) goto noencoding; if (!*(s += 9)) goto noencoding;
@ -980,11 +984,6 @@ process_options(VALUE arg)
ruby_init_gems(opt); ruby_init_gems(opt);
parser = rb_parser_new(); parser = rb_parser_new();
if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue); 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->e_script) {
if (opt->enc_index >= 0) if (opt->enc_index >= 0)
rb_enc_associate_index(opt->e_script, opt->enc_index); rb_enc_associate_index(opt->e_script, opt->enc_index);