ruby-changes:10034
From: yugui <ko1@a...>
Date: Fri, 16 Jan 2009 01:34:15 +0900 (JST)
Subject: [ruby-changes:10034] Ruby:r21576 (ruby_1_9_1): merges r21571 from trunk into ruby_1_9_1.
yugui 2009-01-16 01:33:06 +0900 (Fri, 16 Jan 2009) New Revision: 21576 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21576 Log: merges r21571 from trunk into ruby_1_9_1. * ruby.c (process_options): decrement parse_in_eval to recognize parsing main or normal eval script. * compile.c (rb_parse_in_main): return 1 if parsing main script. (if parse_in_eval is negative value, it means main script) * parse.y (yycompile0): check rb_parse_in_main() to accumulate script text. Bug #848 [ruby-core:20450] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/compile.c branches/ruby_1_9_1/parse.y branches/ruby_1_9_1/ruby.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 21575) +++ ruby_1_9_1/ChangeLog (revision 21576) @@ -1,3 +1,14 @@ +Fri Jan 16 01:09:37 2009 Koichi Sasada <ko1@a...> + + * ruby.c (process_options): decrement parse_in_eval to recognize + parsing main or normal eval script. + + * compile.c (rb_parse_in_main): return 1 if parsing main script. + (if parse_in_eval is negative value, it means main script) + + * parse.y (yycompile0): check rb_parse_in_main() to accumulate + script text. Bug #848 [ruby-core:20450] + Fri Jan 16 00:57:34 2009 Koichi Sasada <ko1@a...> * lib/debug.rb: as wanabe-san pointed out, Index: ruby_1_9_1/compile.c =================================================================== --- ruby_1_9_1/compile.c (revision 21575) +++ ruby_1_9_1/compile.c (revision 21576) @@ -5350,3 +5350,9 @@ { return GET_THREAD()->parse_in_eval != 0; } + +int +rb_parse_in_main(void) +{ + return GET_THREAD()->parse_in_eval < 0; +} Index: ruby_1_9_1/parse.y =================================================================== --- ruby_1_9_1/parse.y (revision 21575) +++ ruby_1_9_1/parse.y (revision 21576) @@ -437,6 +437,7 @@ extern int rb_dvar_defined(ID); extern int rb_local_defined(ID); extern int rb_parse_in_eval(void); +extern int rb_prase_in_main(void); static VALUE reg_compile_gen(struct parser_params*, VALUE, int); #define reg_compile(str,options) reg_compile_gen(parser, str, options) @@ -4977,7 +4978,7 @@ NODE *tree; struct parser_params *parser = (struct parser_params *)arg; - if (!compile_for_eval && rb_safe_level() == 0) { + if ((!compile_for_eval || rb_parse_in_main()) && rb_safe_level() == 0) { ruby_debug_lines = debug_lines(ruby_sourcefile); if (ruby_debug_lines && ruby_sourceline > 0) { VALUE str = STR_NEW0(); Index: ruby_1_9_1/ruby.c =================================================================== --- ruby_1_9_1/ruby.c (revision 21575) +++ ruby_1_9_1/ruby.c (revision 21576) @@ -1319,10 +1319,10 @@ } #define PREPARE_PARSE_MAIN(expr) do { \ - th->parse_in_eval++; \ + th->parse_in_eval--; \ th->base_block = &env->block; \ expr; \ - th->parse_in_eval--; \ + th->parse_in_eval++; \ th->base_block = 0; \ } while (0) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/