ruby-changes:30051
From: nobu <ko1@a...>
Date: Mon, 22 Jul 2013 09:48:48 +0900 (JST)
Subject: [ruby-changes:30051] nobu:r42103 (trunk): vm_eval.c: use file argument
nobu 2013-07-22 09:48:38 +0900 (Mon, 22 Jul 2013) New Revision: 42103 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42103 Log: vm_eval.c: use file argument * vm_eval.c (eval_string_with_cref): use the given file name unless eval even if scope is given. additional fix for [Bug #8436]. based on the patch by srawlins at [ruby-core:56099] [Bug #8662]. Modified files: trunk/ChangeLog trunk/test/ruby/test_method.rb trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42102) +++ ChangeLog (revision 42103) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 22 09:48:31 2013 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (eval_string_with_cref): use the given file name unless + eval even if scope is given. additional fix for [Bug #8436]. + based on the patch by srawlins at [ruby-core:56099] [Bug #8662]. + Mon Jul 22 09:24:19 2013 Kouji Takao <kouji@t...> * ext/readline/readline.c (Init_readline): added Index: vm_eval.c =================================================================== --- vm_eval.c (revision 42102) +++ vm_eval.c (revision 42103) @@ -1205,7 +1205,10 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1205 if (rb_obj_is_kind_of(scope, rb_cBinding)) { GetBindingPtr(scope, bind); envval = bind->env; - if (strcmp(file, "(eval)") == 0 && bind->path != Qnil) { + if (strcmp(file, "(eval)") != 0) { + absolute_path = rb_str_new_cstr(file); + } + else if (bind->path != Qnil) { file = RSTRING_PTR(bind->path); line = bind->first_lineno; absolute_path = rb_current_realfilepath(); Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 42102) +++ test/ruby/test_method.rb (revision 42103) @@ -547,6 +547,8 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L547 assert_equal(File.dirname(File.realpath(__FILE__)), __dir__) bug8436 = '[ruby-core:55123] [Bug #8436]' assert_equal(__dir__, eval("__dir__", binding), bug8436) + bug8662 = '[ruby-core:56099] [Bug #8662]' + assert_equal("arbitrary", eval("__dir__", binding, "arbitrary/file.rb"), bug8662) end def test_alias_owner -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/