8000 * ruby.c (proc_options, process_options): now opt->e_script is an array · jruby/ruby@67eeff7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67eeff7

Browse files
committed
* ruby.c (proc_options, process_options): now opt->e_script is an array
of arrays. each arrays have two elements -- pos and string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/win32-unicode-test@17948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9376563 commit 67eeff7

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

ChangeLog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
Tue Jul 8 01:04:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
2+
3+
* ruby.c (proc_options, process_options): now opt->e_script is an array
4+
of arrays. each arrays have two elements -- pos and string.
5+
16
Tue Jul 8 00:37:50 2008 NAKAMURA Usaku <usa@ruby-lang.org>
27

38
* ruby.c (process_options): no need to call rb_w32_parse_cmdline() if
49
locale == default_external.
510

611
Tue Jul 8 00:33:46 2008 NAKAMURA Usaku <usa@ruby-lang.org>
712

8-
* ruby.c (process_options): re-set e_script.
13+
* ruby.c (proc_options, process_options): re-set e_script.
914

1015
Tue Jul 8 00:03:20 2008 NAKAMURA Usaku <usa@ruby-lang.org>
1116

ruby.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ struct cmdline_options {
9090
const char *script;
9191
VALUE script_name;
9292
VALUE e_script;
93-
VALUE e_script_pos;
9493
struct {
9594
struct {
9695
VALUE name;
@@ -717,14 +716,12 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
717716
rb_raise(rb_eRuntimeError, "no code specified for -e");
718717
}
719718
if (!opt->e_script) {
720-
opt->e_script = rb_str_new(0, 0);
719+
opt->e_script = rb_ary_new();
721720
if (opt->script == 0)
722721
opt->script = "-e";
723-
opt->e_script_pos = rb_ary_new();
724722
}
725-
rb_str_cat2(opt->e_script, s);
726-
rb_str_cat2(opt->e_script, "\n");
727-
rb_ary_push(opt->e_script_pos, INT2FIX(argc0 - argc));
723+
rb_ary_push(opt->e_script,
724+
rb_ary_new3(2, INT2FIX(argc0 - argc), rb_str_new2(s)));
728725
break;
729726

730727
case 'r':
@@ -1104,13 +1101,11 @@ process_options(VALUE arg)
11041101
#ifdef _WIN32
11051102
if (enc != lenc &&
11061103
(argc = rb_w32_parse_cmdline(&argv, rb_enc_name(enc))) != 0) {
1107-
if (opt->e_script && opt->e_script_pos) {
1108-
opt->e_script = rb_str_new(0, 0);
1109-
for (i = 0; i < RARRAY_LEN(opt->e_s 10000 cript_pos); ++i) {
1110-
int pos = FIX2INT(RARRAY_PTR(opt->e_script_pos)[i]);
1111-
rb_enc_str_buf_cat(opt->e_script, argv[pos], strlen(argv[pos]),
1112-
enc);
1113-
rb_str_cat2(opt->e_script, "\n");
1104+
if (opt->e_script) {
1105+
for (i = 0; i < RARRAY_LEN(opt->e_script); ++i) {
1106+
int pos = FIX2INT(RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[0]);
1107+
RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[1] =
1108+
rb_enc_str_new(argv[pos], strlen(argv[pos]), enc);
11141109
}
11151110
}
11161111
argc -= opnum;
@@ -1124,15 +1119,22 @@ process_options(VALUE arg)
11241119
rb_set_safe_level_force(safe);
11251120
if (opt->e_script) {
11261121
rb_encoding *eenc;
1122+
VALUE script = rb_str_new(0, 0);
11271123
if (opt->src.enc.index >= 0) {
11281124
eenc = rb_enc_from_index(opt->src.enc.index);
11291125
}
11301126
else {
11311127
eenc = lenc;
11321128
}
1133-
rb_enc_associate(opt->e_script, eenc);
1129+
for (i = 0; i < RARRAY_LEN(opt->e_script); ++i) {
1130+
VALUE str = RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[1];
1131+
if (rb_enc_get_index(str) == 0)
1132+
rb_enc_associate(str, eenc);
1133+
rb_str_buf_append(script, str);
1134+
rb_str_cat2(script, "\n");
1135+
}
11341136
require_libraries(opt);
1135-
tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
1137+
tree = rb_parser_compile_string(parser, opt->script, script, 1);
11361138
}
11371139
else {
11381140
if (opt->script[0] == '-' && !opt->script[1]) {

0 commit comments

Comments
 (0)
0