1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* load.c (rb_get_load_path): returns the load path without

touching.

* load.c (rb_feature_provided): new function to return the loading
  path in addition to rb_provided().

* load.c (search_required): sets path if loading.

* variable.c (autoload_provided): load paths are expanded to check
  if loading.

* variable.c (autoload_node): keeps autoload mark while loading.
  [ruby-core:20235]

* variable.c (rb_const_get_0): loops while autoload mark is set.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-12-04 18:29:20 +00:00
parent 0b10c32079
commit 8e864d1e86
5 changed files with 90 additions and 47 deletions

32
load.c
View file

@ -30,13 +30,7 @@ VALUE
rb_get_load_path(void)
{
VALUE load_path = GET_VM()->load_path;
VALUE ary = rb_ary_new2(RARRAY_LEN(load_path));
long i;
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
rb_ary_push(ary, rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil));
}
return ary;
return load_path;
}
static VALUE
@ -197,6 +191,12 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
int
rb_provided(const char *feature)
{
return rb_feature_provided(feature, 0);
}
int
rb_feature_provided(const char *feature, const char **loading)
{
const char *ext = strrchr(feature, '.');
volatile VALUE fullpath = 0;
@ -208,15 +208,15 @@ rb_provided(const char *feature)
}
if (ext && !strchr(ext, '/')) {
if (IS_RBEXT(ext)) {
if (rb_feature_p(feature, ext, Qtrue, Qfalse, 0)) return Qtrue;
if (rb_feature_p(feature, ext, Qtrue, Qfalse, loading)) return Qtrue;
return Qfalse;
}
else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
if (rb_feature_p(feature, ext, Qfalse, Qfalse, 0)) return Qtrue;
if (rb_feature_p(feature, ext, Qfalse, Qfalse, loading)) return Qtrue;
return Qfalse;
}
}
if (rb_feature_p(feature, feature + strlen(feature), Qtrue, Qfalse, 0))
if (rb_feature_p(feature, feature + strlen(feature), Qtrue, Qfalse, loading))
return Qtrue;
return Qfalse;
}
@ -430,9 +430,8 @@ search_required(VALUE fname, volatile VALUE *path)
return 'r';
}
if ((tmp = rb_find_file(fname)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, Qtrue, Qtrue, 0))
if (!rb_feature_p(ftptr, ext, Qtrue, Qtrue, &loading) || loading)
*path = tmp;
return 'r';
}
@ -447,9 +446,8 @@ search_required(VALUE fname, volatile VALUE *path)
#ifdef DLEXT2
OBJ_FREEZE(tmp);
if (rb_find_file_ext(&tmp, loadable_ext + 1)) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, &loading) || loading)
*path = tmp;
return 's';
}
@ -457,9 +455,8 @@ search_required(VALUE fname, volatile VALUE *path)
rb_str_cat2(tmp, DLEXT);
OBJ_FREEZE(tmp);
if ((tmp = rb_find_file(tmp)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, &loading) || loading)
*path = tmp;
return 's';
}
@ -471,9 +468,8 @@ search_required(VALUE fname, volatile VALUE *path)
return 's';
}
if ((tmp = rb_find_file(fname)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, &loading) || loading)
*path = tmp;
return 's';
}