ruby-changes:4429
From: ko1@a...
Date: Tue, 8 Apr 2008 03:39:48 +0900 (JST)
Subject: [ruby-changes:4429] nobu - Ruby:r15920 (trunk): * load.c (rb_provided): check expanded path for relative path
nobu 2008-04-08 03:39:28 +0900 (Tue, 08 Apr 2008) New Revision: 15920 Added files: trunk/bootstraptest/test_autoload.rb Modified files: trunk/ChangeLog trunk/load.c trunk/variable.c trunk/version.h Log: * load.c (rb_provided): check expanded path for relative path features, loading or loaded features are already expanded in 1.9. * variable.c (rb_autoload_load): no needs to check if provided before rb_require_safe. [ruby-dev:34266] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/load.c?r1=15920&r2=15919&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=15920&r2=15919&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/variable.c?r1=15920&r2=15919&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15920&r2=15919&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_autoload.rb?revision=15920&view=markup http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_autoload.rb?r1=15920&r2=15919&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15919) +++ ChangeLog (revision 15920) @@ -1,3 +1,11 @@ +Tue Apr 8 03:39:26 2008 Nobuyoshi Nakada <nobu@r...> + + * load.c (rb_provided): check expanded path for relative path + features, loading or loaded features are already expanded in 1.9. + + * variable.c (rb_autoload_load): no needs to check if provided before + rb_require_safe. [ruby-dev:34266] + Mon Apr 7 22:41:21 2008 Tadayoshi Funaba <tadf@d...> * numeric.c: cancelled recent changes (except to remove rdiv). Index: variable.c =================================================================== --- variable.c (revision 15919) +++ variable.c (revision 15920) @@ -1374,7 +1374,7 @@ VALUE file; NODE *load = autoload_delete(klass, id); - if (!load || !(file = load->nd_lit) || rb_provided(RSTRING_PTR(file))) { + if (!load || !(file = load->nd_lit)) { return Qfalse; } return rb_require_safe(file, load->nd_nth); @@ -1393,7 +1393,7 @@ } file = ((NODE *)load)->nd_lit; Check_Type(file, T_STRING); - if (!RSTRING_PTR(file)) { + if (!RSTRING_PTR(file) || !*RSTRING_PTR(file)) { rb_raise(rb_eArgError, "empty file name"); } if (!rb_provided(RSTRING_PTR(file))) { @@ -1433,7 +1433,7 @@ tmp = klass; retry: - while (tmp && !NIL_P(tmp)) { + while (RTEST(tmp)) { while (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp),id,&value)) { if (value == Qundef) { if (!RTEST(rb_autoload_load(tmp, id))) break; Index: bootstraptest/test_autoload.rb =================================================================== --- bootstraptest/test_autoload.rb (revision 0) +++ bootstraptest/test_autoload.rb (revision 15920) @@ -0,0 +1,25 @@ +assert_equal 'ok', %q{ + open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"} + autoload :ZZZ, "./zzz.rb" + print ZZZ.ok +} + +assert_equal 'ok', %q{ + open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"} + autoload :ZZZ, "./zzz.rb" + require "./zzz.rb" + print ZZZ.ok +} + +assert_equal 'ok', %q{ + open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"} + autoload :ZZZ, "./zzz.rb" + print proc{$SAFE=4; ZZZ.ok}.call +} + +assert_equal 'ok', %q{ + open("zzz.rb", "w") {|f| f.puts "class ZZZ; def self.ok;:ok;end;end"} + autoload :ZZZ, "./zzz.rb" + require "./zzz.rb" + print proc{$SAFE=4; ZZZ.ok}.call +} Property changes on: bootstraptest/test_autoload.rb ___________________________________________________________________ Name: svn:eol-style + LF Name: svn:keywords + Author Id Revision Index: load.c =================================================================== --- load.c (revision 15919) +++ load.c (revision 15920) @@ -191,7 +191,13 @@ rb_provided(const char *feature) { const char *ext = strrchr(feature, '.'); + volatile VALUE fullpath = 0; + if (*feature == '.' && + (feature[1] == '/' || strncmp(feature+1, "./", 2) == 0)) { + fullpath = rb_file_expand_path(rb_str_new2(feature), Qnil); + feature = RSTRING_PTR(fullpath); + } if (ext && !strchr(ext, '/')) { if (IS_RBEXT(ext)) { if (rb_feature_p(feature, ext, Qtrue, Qfalse, 0)) return Qtrue; Index: version.h =================================================================== --- version.h (revision 15919) +++ version.h (revision 15920) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-04-07" +#define RUBY_RELEASE_DATE "2008-04-08" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080407 +#define RUBY_RELEASE_CODE 20080408 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 8 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/