aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-24 07:41:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-24 07:41:48 +0000
commitaaa9aa9e4bd61b81e4013725f4ba9c1fab333a9c (patch)
tree2d616b73ea2ec6e7faa09592fa7d1aebc2410319 /ruby.c
parent4fb24ac15ad09c36e7c12d15cb205b75c2e05fb2 (diff)
downloadruby-aaa9aa9e4bd61b81e4013725f4ba9c1fab333a9c.tar.gz
parse.y: rb_parser_set_options
* parse.y (yycompile0): append top-level addenda before appending prelude nodes. * parse.y (rb_parser_set_options): set top-level addendum options before parsing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/ruby.c b/ruby.c
index cee50a34e8..5cc7e252e6 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1646,6 +1646,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
/* need to acquire env from toplevel_binding each time, since it
* may update after eval() */
+ base_block = toplevel_context(toplevel_binding);
+ rb_parser_set_context(parser, base_block, TRUE);
+ rb_parser_set_options(parser, opt->do_print, opt->do_loop, opt->do_line, opt->do_split);
+
if (opt->e_script) {
VALUE progname = rb_progname;
rb_encoding *eenc;
@@ -1669,15 +1673,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
require_libraries(&opt->req_list);
}
ruby_set_script_name(progname);
-
- base_block = toplevel_context(toplevel_binding);
- rb_parser_set_context(parser, base_block, TRUE);
tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
}
else {
VALUE f;
- base_block = toplevel_context(toplevel_binding);
- rb_parser_set_context(parser, base_block, TRUE);
f = open_load_file(script_name, &opt->xflag);
tree = load_file(parser, opt->script_name, f, 1, opt);
}
@@ -1715,11 +1714,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
if (!dump) return Qtrue;
}
- if (opt->do_print) {
- tree = rb_parser_append_print(parser, tree);
- }
if (opt->do_loop) {
- tree = rb_parser_while_loop(parser, tree, opt->do_line, opt->do_split);
rb_define_global_function("sub", rb_f_sub, -1);
rb_define_global_function("gsub", rb_f_gsub, -1);
rb_define_global_function("chop", rb_f_chop, 0);