From 962bcf1394762f297331f0a5a79c8fc3cc55ed10 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 28 Sep 2005 15:58:32 +0000 Subject: [PATCH] * eval.c (ev_const_get), variable.c (rb_const_get_0): retry only when autoload succeeded. * variable.c (rb_autoload_load): now return true if autoload succeeded. fixed: [ruby-dev:27331] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ eval.c | 2 +- intern.h | 2 +- variable.c | 8 ++++---- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46fcca46c7..40e135e5cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Sep 29 00:57:35 2005 Nobuyoshi Nakada + + * eval.c (ev_const_get), variable.c (rb_const_get_0): retry only when + autoload succeeded. + + * variable.c (rb_autoload_load): now return true if autoload + succeeded. fixed: [ruby-dev:27331] + Wed Sep 28 23:40:04 2005 Nobuyoshi Nakada * file.c (rb_stat_inspect): constified. diff --git a/eval.c b/eval.c index daaf635d2d..06a1fa1e5a 100644 --- a/eval.c +++ b/eval.c @@ -1795,7 +1795,7 @@ ev_const_get(NODE *cref, ID id, VALUE self) if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id); while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { if (result == Qundef) { - rb_autoload_load(klass, id); + if (!RTEST(rb_autoload_load(klass, id))) break; continue; } return result; diff --git a/intern.h b/intern.h index 15f0f6a1f9..a8cc771ca1 100644 --- a/intern.h +++ b/intern.h @@ -531,7 +531,7 @@ VALUE rb_path2class(const char*); void rb_name_class(VALUE, ID); VALUE rb_class_name(VALUE); void rb_autoload(VALUE, ID, const char*); -void rb_autoload_load(VALUE, ID); +VALUE rb_autoload_load(VALUE, ID); VALUE rb_autoload_p(VALUE, ID); void rb_gc_mark_global_tbl(void); VALUE rb_f_trace_var(int, VALUE*); diff --git a/variable.c b/variable.c index 24a339b09d..afa05e3ff8 100644 --- a/variable.c +++ b/variable.c @@ -1215,16 +1215,16 @@ autoload_delete(VALUE mod, ID id) return (NODE *)load; } -void +VALUE rb_autoload_load(VALUE klass, ID id) { VALUE file; NODE *load = autoload_delete(klass, id); if (!load || !(file = load->nd_lit) || rb_provided(RSTRING(file)->ptr)) { - const_missing(klass, id); + return Qfalse; } - rb_require_safe(file, load->nd_nth); + return rb_require_safe(file, load->nd_nth); } static VALUE @@ -1283,7 +1283,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse) while (tmp) { while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { if (value == Qundef) { - rb_autoload_load(tmp, id); + if (!RTEST(rb_autoload_load(tmp, id))) break; continue; } if (exclude && tmp == rb_cObject && klass != rb_cObject) {