From 24224de18168eec57bfa5cda4489b189b7591b75 Mon Sep 17 00:00:00 2001 From: yugui Date: Fri, 22 May 2009 09:48:05 +0000 Subject: merges r23431 from trunk into ruby_1_9_1. -- * variable.c (rb_autoload_load): checks if iv_tbl is valid. [ruby-dev:38456] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ bootstraptest/test_class.rb | 6 ++++++ variable.c | 23 +++++++++++++++-------- version.h | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index afb49566b..e4ad5578d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri May 15 15:15:12 2009 Nobuyoshi Nakada + + * variable.c (rb_autoload_load): checks if iv_tbl is valid. + [ruby-dev:38456] + Sat May 16 09:19:16 2009 Nobuyoshi Nakada * parse.y (magic_comment_encoding): use rb_compile_warning() to diff --git a/bootstraptest/test_class.rb b/bootstraptest/test_class.rb index ad2844106..a7f6d4df4 100644 --- a/bootstraptest/test_class.rb +++ b/bootstraptest/test_class.rb @@ -144,3 +144,9 @@ assert_equal '3', %q{ } $i } + +assert_match /::C\z/, %q{ + c = nil + Module.new{|m| c = class m::C; name; end} + c +}, '[ruby-dev:38456]' diff --git a/variable.c b/variable.c index 8b4acc8c7..5ce48ca87 100644 --- a/variable.c +++ b/variable.c @@ -1430,11 +1430,23 @@ autoload_node(VALUE mod, ID id, int noload) return 0; } +static NODE * +autoload_node_ptr(VALUE mod, ID id) +{ + struct st_table *tbl = RCLASS_IV_TBL(mod); + st_data_t val; + + if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) { + return 0; + } + return autoload_node(mod, id, 0); +} + VALUE rb_autoload_load(VALUE klass, ID id) { VALUE file; - NODE *load = autoload_node(klass, id, 0); + NODE *load = autoload_node_ptr(klass, id); if (!load) return Qfalse; file = load->nd_lit; @@ -1444,15 +1456,10 @@ rb_autoload_load(VALUE klass, ID id) VALUE rb_autoload_p(VALUE mod, ID id) { - struct st_table *tbl = RCLASS_IV_TBL(mod); - st_data_t val; - NODE *load; VALUE file; + NODE *load = autoload_node_ptr(mod, id); - if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) { - return Qnil; - } - load = autoload_node(mod, id, 0); + if (!load) return Qnil; return load && (file = load->nd_lit) ? file : Qnil; } diff --git a/version.h b/version.h index aba88b849..9f9a20b6c 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-05-12" -#define RUBY_PATCHLEVEL 140 +#define RUBY_PATCHLEVEL 141 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit