ruby-changes:29254
From: nobu <ko1@a...>
Date: Sat, 15 Jun 2013 08:37:46 +0900 (JST)
Subject: [ruby-changes:29254] nobu:r41306 (trunk): vm_eval.c: __dir__ in eval
nobu 2013-06-15 08:37:35 +0900 (Sat, 15 Jun 2013) New Revision: 41306 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41306 Log: vm_eval.c: __dir__ in eval * vm_eval.c (eval_string_with_cref): propagate absolute path from the binding if it is given explicitly. patch by Gat (Dawid Janczak) at [ruby-core:55123]. [Bug #8436] Modified files: trunk/ChangeLog trunk/test/ruby/test_method.rb trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41305) +++ ChangeLog (revision 41306) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jun 15 08:37:28 2013 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (eval_string_with_cref): propagate absolute path from the + binding if it is given explicitly. patch by Gat (Dawid Janczak) at + [ruby-core:55123]. [Bug #8436] + Sat Jun 15 02:40:18 2013 Tanaka Akira <akr@f...> * bignum.c (bdigs_small_lshift): Extracted from big_lshift. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 41305) +++ vm_eval.c (revision 41306) @@ -1164,6 +1164,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1164 int state; VALUE result = Qundef; VALUE envval; + VALUE absolute_path = Qnil; rb_thread_t *th = GET_THREAD(); rb_env_t *env = NULL; rb_block_t block, *base_block; @@ -1190,6 +1191,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1191 if (strcmp(file, "(eval)") == 0 && bind->path != Qnil) { file = RSTRING_PTR(bind->path); line = bind->first_lineno; + absolute_path = rb_current_realfilepath(); } } else { @@ -1217,7 +1219,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1219 /* make eval iseq */ th->parse_in_eval++; th->mild_compile_error++; - iseqval = rb_iseq_compile_on_base(src, rb_str_new2(file), INT2FIX(line), base_block); + iseqval = rb_iseq_compile_with_option(src, rb_str_new2(file), absolute_path, INT2FIX(line), base_block, Qnil); th->mild_compile_error--; th->parse_in_eval--; Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 41305) +++ test/ruby/test_method.rb (revision 41306) @@ -545,6 +545,8 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L545 def test___dir__ assert_instance_of String, __dir__ assert_equal(File.dirname(File.realpath(__FILE__)), __dir__) + bug8436 = '[ruby-core:55123] [Bug #8436]' + assert_equal(__dir__, eval("__dir__", binding), bug8436) end def test_alias_owner -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/