mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* variable.c (rb_autoload_load): gets rid of false warning.
[ruby-core:23466] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b10617c3d1
commit
8c7172605b
2 changed files with 23 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat May 16 13:49:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* variable.c (rb_autoload_load): gets rid of false warning.
|
||||
[ruby-core:23466]
|
||||
|
||||
Sat May 16 10:59:54 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* sample/drb/dhasenc.rb: add magic comment for encoding.
|
||||
|
|
27
variable.c
27
variable.c
|
@ -1401,7 +1401,7 @@ reset_safe(VALUE safe)
|
|||
}
|
||||
|
||||
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 @@ autoload_node(VALUE mod, ID id, int noload)
|
|||
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 @@ autoload_node_ptr(VALUE mod, ID id)
|
|||
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 @@ VALUE
|
|||
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 @@ rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue