diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-05 13:33:59 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-05 13:33:59 +0000 |
commit | 0f0c5653a3faedf2c39d0ca7ae6d93619898524f (patch) | |
tree | e29dc32b54211e94692192b9ed7296d464a99290 /load.c | |
parent | 2ebd4baec095be6de78a490992c887b041be2c8f (diff) |
merges r20531 from trunk into ruby_1_9_1.
* 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/branches/ruby_1_9_1@20551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'load.c')
-rw-r--r-- | load.c | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -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 @@ -198,6 +192,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'; } |