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

ruby-changes:11780

From: nobu <ko1@a...>
Date: Fri, 15 May 2009 15:15:29 +0900 (JST)
Subject: [ruby-changes:11780] Ruby:r23431 (trunk): * variable.c (rb_autoload_load): checks if iv_tbl is valid.

nobu	2009-05-15 15:15:14 +0900 (Fri, 15 May 2009)

  New Revision: 23431

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23431

  Log:
    * variable.c (rb_autoload_load): checks if iv_tbl is valid.
      [ruby-dev:38456]

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_class.rb
    trunk/variable.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23430)
+++ ChangeLog	(revision 23431)
@@ -1,3 +1,8 @@
+Fri May 15 15:15:12 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* variable.c (rb_autoload_load): checks if iv_tbl is valid.
+	  [ruby-dev:38456]
+
 Fri May 15 11:17:48 2009  NAKAMURA Usaku  <usa@r...>
 
 	* win32/setup.mak (-version-): now version.h includes
Index: variable.c
===================================================================
--- variable.c	(revision 23430)
+++ variable.c	(revision 23431)
@@ -1432,11 +1432,23 @@
     return 0;
 }
 
+static NODE *
+autoload_node_ptr(VALUE mod, ID id)
+{
+    struct st_table *tbl = RCLASS_IV_TBL(mod);
+    st_data_t val;
+
+    if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) {
+	return 0;
+    }
+    return autoload_node(mod, id, 0);
+}
+
 VALUE
 rb_autoload_load(VALUE klass, ID id)
 {
     VALUE file;
-    NODE *load = autoload_node(klass, id, 0);
+    NODE *load = autoload_node_ptr(klass, id);
 
     if (!load) return Qfalse;
     file = load->nd_lit;
@@ -1446,15 +1458,10 @@
 VALUE
 rb_autoload_p(VALUE mod, ID id)
 {
-    struct st_table *tbl = RCLASS_IV_TBL(mod);
-    st_data_t val;
-    NODE *load;
     VALUE file;
+    NODE *load = autoload_node_ptr(mod, id);
 
-    if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) {
-	return Qnil;
-    }
-    load = autoload_node(mod, id, 0);
+    if (!load) return Qnil;
     return load && (file = load->nd_lit) ? file : Qnil;
 }
 
Index: bootstraptest/test_class.rb
===================================================================
--- bootstraptest/test_class.rb	(revision 23430)
+++ bootstraptest/test_class.rb	(revision 23431)
@@ -144,3 +144,9 @@
   }
   $i
 }
+
+assert_match /::C\z/, %q{
+  c = nil
+  Module.new{|m| c = class m::C; name; end}
+  c
+}, '[ruby-dev:38456]'

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

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