mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c8bc11d3d
commit
37504dc560
5 changed files with 45 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Apr 8 03:39:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@dotrb.org>
|
Mon Apr 7 22:41:21 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* numeric.c: cancelled recent changes (except to remove rdiv).
|
* numeric.c: cancelled recent changes (except to remove rdiv).
|
||||||
|
|
25
bootstraptest/test_autoload.rb
Normal file
25
bootstraptest/test_autoload.rb
Normal file
|
@ -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
|
||||||
|
}
|
6
load.c
6
load.c
|
@ -191,7 +191,13 @@ int
|
||||||
rb_provided(const char *feature)
|
rb_provided(const char *feature)
|
||||||
{
|
{
|
||||||
const char *ext = strrchr(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 (ext && !strchr(ext, '/')) {
|
||||||
if (IS_RBEXT(ext)) {
|
if (IS_RBEXT(ext)) {
|
||||||
if (rb_feature_p(feature, ext, Qtrue, Qfalse, 0)) return Qtrue;
|
if (rb_feature_p(feature, ext, Qtrue, Qfalse, 0)) return Qtrue;
|
||||||
|
|
|
@ -1374,7 +1374,7 @@ rb_autoload_load(VALUE klass, ID id)
|
||||||
VALUE file;
|
VALUE file;
|
||||||
NODE *load = autoload_delete(klass, id);
|
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 Qfalse;
|
||||||
}
|
}
|
||||||
return rb_require_safe(file, load->nd_nth);
|
return rb_require_safe(file, load->nd_nth);
|
||||||
|
@ -1393,7 +1393,7 @@ autoload_file(VALUE mod, ID id)
|
||||||
}
|
}
|
||||||
file = ((NODE *)load)->nd_lit;
|
file = ((NODE *)load)->nd_lit;
|
||||||
Check_Type(file, T_STRING);
|
Check_Type(file, T_STRING);
|
||||||
if (!RSTRING_PTR(file)) {
|
if (!RSTRING_PTR(file) || !*RSTRING_PTR(file)) {
|
||||||
rb_raise(rb_eArgError, "empty file name");
|
rb_raise(rb_eArgError, "empty file name");
|
||||||
}
|
}
|
||||||
if (!rb_provided(RSTRING_PTR(file))) {
|
if (!rb_provided(RSTRING_PTR(file))) {
|
||||||
|
@ -1433,7 +1433,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse)
|
||||||
|
|
||||||
tmp = klass;
|
tmp = klass;
|
||||||
retry:
|
retry:
|
||||||
while (tmp && !NIL_P(tmp)) {
|
while (RTEST(tmp)) {
|
||||||
while (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp),id,&value)) {
|
while (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp),id,&value)) {
|
||||||
if (value == Qundef) {
|
if (value == Qundef) {
|
||||||
if (!RTEST(rb_autoload_load(tmp, id))) break;
|
if (!RTEST(rb_autoload_load(tmp, id))) break;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#define RUBY_VERSION "1.9.0"
|
#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_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20080407
|
#define RUBY_RELEASE_CODE 20080408
|
||||||
#define RUBY_PATCHLEVEL 0
|
#define RUBY_PATCHLEVEL 0
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define RUBY_VERSION_TEENY 0
|
#define RUBY_VERSION_TEENY 0
|
||||||
#define RUBY_RELEASE_YEAR 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 4
|
#define RUBY_RELEASE_MONTH 4
|
||||||
#define RUBY_RELEASE_DAY 7
|
#define RUBY_RELEASE_DAY 8
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Add table
Reference in a new issue