diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-22 09:48:22 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-22 09:48:22 +0000 |
commit | 7681b977546394a37f269711a8fb39b38188025b (patch) | |
tree | 089078f3da7045035bf16c851d824fbe5071d491 | |
parent | 08b3f60e5746f4b68dbed09a6305414a4c398d2f (diff) | |
download | ruby-7681b977546394a37f269711a8fb39b38188025b.tar.gz ruby-7681b977546394a37f269711a8fb39b38188025b.tar.xz ruby-7681b977546394a37f269711a8fb39b38188025b.zip |
merges r23440 from trunk into ruby_1_9_1.
--
* variable.c (rb_autoload_load): gets rid of false warning.
[ruby-core:23466]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | variable.c | 27 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 24 insertions, 10 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. diff --git a/variable.c b/variable.c index 5ce48ca87..5d4a4ad2c 100644 --- a/variable.c +++ b/variable.c @@ -1399,7 +1399,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; @@ -1424,14 +1424,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; @@ -1439,16 +1440,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, load->nd_nth); } @@ -1457,8 +1463,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; } @@ -1664,7 +1673,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; } @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-05-12" -#define RUBY_PATCHLEVEL 142 +#define RUBY_PATCHLEVEL 143 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |