ruby-changes:9603
From: ko1 <ko1@a...>
Date: Mon, 29 Dec 2008 03:45:42 +0900 (JST)
Subject: [ruby-changes:9603] Ruby:r21143 (trunk): * ruby.c (process_options): set th->base_block only while
ko1 2008-12-29 03:45:24 +0900 (Mon, 29 Dec 2008) New Revision: 21143 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21143 Log: * ruby.c (process_options): set th->base_block only while it is needed. * ruby.c (require_libraries): clear th->base_block before require libraries. Modified files: trunk/ChangeLog trunk/ruby.c Index: ChangeLog =================================================================== --- ChangeLog (revision 21142) +++ ChangeLog (revision 21143) @@ -1,3 +1,11 @@ +Mon Dec 29 03:43:25 2008 Koichi Sasada <ko1@a...> + + * ruby.c (process_options): set th->base_block only while + it is needed. + + * ruby.c (require_libraries): clear th->base_block before + require libraries. + Sun Dec 28 21:33:52 2008 NARUSE, Yui <naruse@r...> * test/ext/dl/test_base.rb : add BSD's case. Index: ruby.c =================================================================== --- ruby.c (revision 21142) +++ ruby.c (revision 21143) @@ -456,6 +456,9 @@ { VALUE list = opt->req_list; ID require; + rb_thread_t *th = GET_THREAD(); + rb_block_t *prev_base_block = th->base_block; + th->base_block = 0; Init_ext(); /* should be called here for some reason :-( */ CONST_ID(require, "require"); @@ -464,6 +467,7 @@ rb_funcall2(rb_vm_top_self(), require, 1, &feature); } opt->req_list = 0; + th->base_block = prev_base_block; } static void @@ -1336,10 +1340,16 @@ GetBindingPtr(toplevel_binding, bind); GetEnvPtr(bind->env, env); - - th->parse_in_eval++; } +#define PREPARE_PARSE_MAIN(expr) do { \ + th->parse_in_eval++; \ + th->base_block = &env->block; \ + expr; \ + th->parse_in_eval--; \ + th->base_block = 0; \ +} while (0) + if (opt->e_script) { rb_encoding *eenc; if (opt->src.enc.index >= 0) { @@ -1351,16 +1361,18 @@ rb_enc_associate(opt->e_script, eenc); require_libraries(opt); - th->base_block = &env->block; - tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); + PREPARE_PARSE_MAIN({ + tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); + }); } else { if (opt->script[0] == '-' && !opt->script[1]) { forbid_setid("program input from stdin"); } - th->base_block = &env->block; - tree = load_file(parser, opt->script, 1, opt); + PREPARE_PARSE_MAIN({ + tree = load_file(parser, opt->script, 1, opt); + }); } if (opt->dump & DUMP_BIT(yydebug)) return Qtrue; @@ -1389,19 +1401,23 @@ } if (opt->do_print) { - tree = rb_parser_append_print(parser, tree); + PREPARE_PARSE_MAIN({ + tree = rb_parser_append_print(parser, tree); + }); } if (opt->do_loop) { - tree = rb_parser_while_loop(parser, tree, opt->do_line, opt->do_split); + PREPARE_PARSE_MAIN({ + 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); rb_define_global_function("chomp", rb_f_chomp, -1); } - iseq = rb_iseq_new_main(tree, opt->script_name); - th->parse_in_eval--; - th->base_block = 0; + PREPARE_PARSE_MAIN({ + iseq = rb_iseq_new_main(tree, opt->script_name); + }); if (opt->dump & DUMP_BIT(insns)) { rb_io_write(rb_stdout, ruby_iseq_disasm(iseq)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/