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

ruby-changes:11787

From: nobu <ko1@a...>
Date: Sat, 16 May 2009 13:49:45 +0900 (JST)
Subject: [ruby-changes:11787] Ruby:r23440 (trunk): * variable.c (rb_autoload_load): gets rid of false warning.

nobu	2009-05-16 13:49:26 +0900 (Sat, 16 May 2009)

  New Revision: 23440

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

  Log:
    * variable.c (rb_autoload_load): gets rid of false warning.
      [ruby-core:23466]

  Modified files:
    trunk/ChangeLog
    trunk/variable.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23439)
+++ ChangeLog	(revision 23440)
@@ -1,3 +1,8 @@
+Sat May 16 13:49:24 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* variable.c (rb_autoload_load): gets rid of false warning.
+	  [ruby-core:23466]
+
 Sat May 16 10:59:54 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* sample/drb/dhasenc.rb: add magic comment for encoding.
Index: variable.c
===================================================================
--- variable.c	(revision 23439)
+++ variable.c	(revision 23440)
@@ -1401,7 +1401,7 @@
 }
 
 static NODE *
-autoload_node(VALUE mod, ID id, int noload)
+autoload_node(VALUE mod, ID id, const char **loadingpath)
 {
     VALUE file;
     struct st_table *tbl;
@@ -1426,14 +1426,15 @@
     if (!rb_ensure(autoload_provided, (VALUE)&loading, reset_safe, (VALUE)safe)) {
 	return load;
     }
-    if (!noload && loading) {
+    if (loadingpath && loading) {
+	*loadingpath = loading;
 	return load;
     }
     return 0;
 }
 
-static NODE *
-autoload_node_ptr(VALUE mod, ID id)
+static int
+autoload_node_id(VALUE mod, ID id)
 {
     struct st_table *tbl = RCLASS_IV_TBL(mod);
     st_data_t val;
@@ -1441,16 +1442,21 @@
     if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) {
 	return 0;
     }
-    return autoload_node(mod, id, 0);
+    return 1;
 }
 
 VALUE
-rb_autoload_load(VALUE klass, ID id)
+rb_autoload_load(VALUE mod, ID id)
 {
     VALUE file;
-    NODE *load = autoload_node_ptr(klass, id);
+    NODE *load;
+    const char *loading = 0, *src;
 
+    if (!autoload_node_id(mod, id)) return Qfalse;
+    load = autoload_node(mod, id, &loading);
     if (!load) return Qfalse;
+    src = rb_sourcefile();
+    if (src && loading && strcmp(src, loading) == 0) return Qfalse;
     file = load->nd_lit;
     return rb_require_safe(file, (int)load->nd_nth);
 }
@@ -1459,8 +1465,11 @@
 rb_autoload_p(VALUE mod, ID id)
 {
     VALUE file;
-    NODE *load = autoload_node_ptr(mod, id);
+    NODE *load;
+    const char *loading = 0;
 
+    if (!autoload_node_id(mod, id)) return Qnil;
+    load = autoload_node(mod, id, &loading);
     if (!load) return Qnil;
     return load && (file = load->nd_lit) ? file : Qnil;
 }
@@ -1666,7 +1675,7 @@
   retry:
     while (tmp) {
 	if (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp), id, &value)) {
-	    if (value == Qundef && !autoload_node(klass, id, 1))
+	    if (value == Qundef && !autoload_node(klass, id, 0))
 		return Qfalse;
 	    return Qtrue;
 	}

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

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