[前][次][番号順一覧][スレッド一覧]

ruby-changes:47888

From: nobu <ko1@a...>
Date: Sun, 24 Sep 2017 14:22:30 +0900 (JST)
Subject: [ruby-changes:47888] nobu:r60007 (trunk): load.c: fix rb_load_protect condition

nobu	2017-09-24 14:22:23 +0900 (Sun, 24 Sep 2017)

  New Revision: 60007

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60007

  Log:
    load.c: fix rb_load_protect condition
    
    * load.c (rb_load_protect): fix the condition to load the found
      file.  fixup of r59155.

  Added directories:
    trunk/ext/-test-/load/protect/
  Added files:
    trunk/ext/-test-/load/protect/extconf.rb
    trunk/ext/-test-/load/protect/protect.c
    trunk/test/-ext-/load/script.rb
    trunk/test/-ext-/load/test_protect.rb
  Modified files:
    trunk/load.c
Index: test/-ext-/load/script.rb
===================================================================
--- test/-ext-/load/script.rb	(nonexistent)
+++ test/-ext-/load/script.rb	(revision 60007)
@@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/load/script.rb#L1
+# frozen_string_literal: true
+raise "foo"

Property changes on: test/-ext-/load/script.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: test/-ext-/load/test_protect.rb
===================================================================
--- test/-ext-/load/test_protect.rb	(nonexistent)
+++ test/-ext-/load/test_protect.rb	(revision 60007)
@@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/load/test_protect.rb#L1
+# frozen_string_literal: true
+require 'test/unit'
+require '-test-/load/protect'
+
+class Test_Load_Protect < Test::Unit::TestCase
+  def test_load_protect
+    assert_raise(LoadError) {
+      Bug.load_protect(__dir__+"/nonexistent.rb")
+    }
+    assert_raise_with_message(RuntimeError, "foo") {
+      Bug.load_protect(__dir__+"/script.rb")
+    }
+  end
+end

Property changes on: test/-ext-/load/test_protect.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ext/-test-/load/protect/extconf.rb
===================================================================
--- ext/-test-/load/protect/extconf.rb	(nonexistent)
+++ ext/-test-/load/protect/extconf.rb	(revision 60007)
@@ -0,0 +1 @@
+create_makefile('-test-/load/protect')

Property changes on: ext/-test-/load/protect/extconf.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ext/-test-/load/protect/protect.c
===================================================================
--- ext/-test-/load/protect/protect.c	(nonexistent)
+++ ext/-test-/load/protect/protect.c	(revision 60007)
@@ -0,0 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/load/protect/protect.c#L1
+#include <ruby.h>
+
+static VALUE
+load_protect(int argc, VALUE *argv, VALUE self)
+{
+    int state;
+    VALUE path, wrap;
+    rb_scan_args(argc, argv, "11", &path, &wrap);
+    rb_load_protect(path, RTEST(wrap), &state);
+    if (state) rb_jump_tag(state);
+    return Qnil;
+}
+
+void
+Init_protect(void)
+{
+    VALUE mod = rb_define_module("Bug");
+    rb_define_singleton_method(mod, "load_protect", load_protect, -1);
+}

Property changes on: ext/-test-/load/protect/protect.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: load.c
===================================================================
--- load.c	(revision 60006)
+++ load.c	(revision 60007)
@@ -677,7 +677,7 @@ rb_load_protect(VALUE fname, int wrap, i https://github.com/ruby/ruby/blob/trunk/load.c#L677
     }
     POP_TAG();
 
-    if (state != TAG_NONE) state = rb_load_internal0(GET_THREAD(), path, wrap);
+    if (state == TAG_NONE) state = rb_load_internal0(GET_THREAD(), path, wrap);
     if (state != TAG_NONE) *pstate = state;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]