From 11f521b98e276262e140f1a40469c910267a7021 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 28 Aug 2003 08:35:43 +0000 Subject: * variable.c (rb_const_get_0): should check constants defined in included modules, if klass is Object. [ruby-talk:79302] * numeric.c (check_uint): check should be done using UINT_MAX, not INT_MAX. this fix is submitted by in [ruby-core:01486] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ numeric.c | 4 ++-- variable.c | 33 +++++++++++++-------------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c5710d89d..c95e6987b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Aug 28 17:30:24 2003 Yukihiro Matsumoto + + * variable.c (rb_const_get_0): should check constants defined in + included modules, if klass is Object. [ruby-talk:79302] + + * numeric.c (check_uint): check should be done using UINT_MAX, not + INT_MAX. this fix is submitted by in + [ruby-core:01486] + Thu Aug 28 05:02:52 2003 Yukihiro Matsumoto * parse.y (singleton): typo fixed (ruby-bugs-ja PR#562) diff --git a/numeric.c b/numeric.c index 71e4539d07..7d373e4083 100644 --- a/numeric.c +++ b/numeric.c @@ -1024,8 +1024,8 @@ static void check_uint(num) unsigned long num; { - if (num > INT_MAX) { - rb_raise(rb_eRangeError, "integer %lu too big to convert to `int'", num); + if (num > UINT_MAX) { + rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num); } } diff --git a/variable.c b/variable.c index d8e115a204..d182a703cc 100644 --- a/variable.c +++ b/variable.c @@ -1264,28 +1264,12 @@ rb_autoload_p(mod, id) return autoload_file(mod, id); } -VALUE -rb_const_get_at(klass, id) - VALUE klass; - ID id; -{ - VALUE value; - - while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) { - if (value == Qundef) { - rb_autoload_load(klass, id); - continue; - } - return value; - } - return const_missing(klass, id); -} - static VALUE -rb_const_get_0(klass, id, exclude) +rb_const_get_0(klass, id, exclude, recurse) VALUE klass; ID id; int exclude; + int recurse; { VALUE value, tmp; int mod_retry = 0; @@ -1304,6 +1288,7 @@ rb_const_get_0(klass, id, exclude) } return value; } + if (!recurse && klass != rb_cObject) break; tmp = RCLASS(tmp)->super; } if (!mod_retry && BUILTIN_TYPE(klass) == T_MODULE) { @@ -1320,7 +1305,7 @@ rb_const_get_from(klass, id) VALUE klass; ID id; { - return rb_const_get_0(klass, id, Qtrue); + return rb_const_get_0(klass, id, Qtrue, Qtrue); } VALUE @@ -1328,7 +1313,15 @@ rb_const_get(klass, id) VALUE klass; ID id; { - return rb_const_get_0(klass, id, Qfalse); + return rb_const_get_0(klass, id, Qfalse, Qtrue); +} + +VALUE +rb_const_get_at(klass, id) + VALUE klass; + ID id; +{ + return rb_const_get_0(klass, id, Qfalse, Qfalse); } VALUE -- cgit v1.2.3