summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 15:09:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 15:09:37 +0000
commitd8ecc168f1422ee6846dce6c75898a84ee18028c (patch)
treec493dc857cdd2b5e43b780f07f8c4ab7704f85bb /eval.c
parente87f0fc47744cbd7f9e7ebdd78cf3029b52a6714 (diff)
* eval.c (rb_provided): return true only for features loaded from
.rb files, and not search actual library type. [ruby-dev:30414] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/eval.c b/eval.c
index 23c5514610..c49e36f2b8 100644
--- a/eval.c
+++ b/eval.c
@@ -6937,6 +6937,9 @@ static const char *const loadable_ext[] = {
0
};
+static int rb_feature_p _((const char *, const char *, int));
+static int search_required _((VALUE, VALUE *, VALUE *));
+
static int
rb_feature_p(feature, ext, rb)
const char *feature, *ext;
@@ -6973,7 +6976,7 @@ rb_feature_p(feature, ext, rb)
}
if (loading_tbl) {
if (st_lookup(loading_tbl, (st_data_t)feature, 0)) {
- if (ext) return 'u';
+ if (!ext) return 'u';
return strcmp(ext, ".rb") ? 's' : 'r';
}
else {
@@ -6993,21 +6996,24 @@ rb_feature_p(feature, ext, rb)
return 0;
}
-static int search_required(VALUE, VALUE *, VALUE *);
-
int
rb_provided(feature)
const char *feature;
{
- VALUE fname, path;
+ const char *ext = strrchr(feature, '.');
- if (rb_feature_p(feature, 0, Qfalse))
- return Qtrue;
- if (search_required(rb_str_new2(feature), &fname, &path) != 0) {
- feature = RSTRING_PTR(fname);
- if (rb_feature_p(feature, strrchr(feature, '.'), Qfalse))
- return Qtrue;
+ if (ext && !strchr(ext, '/')) {
+ if (strcmp(".rb", ext) == 0) {
+ if (rb_feature_p(feature, ext, Qtrue)) return Qtrue;
+ return Qfalse;
+ }
+ else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
+ return Qfalse; /* may be overriden by .rb file */
+ }
}
+ if (rb_feature_p(feature, feature + strlen(feature), Qtrue))
+ return Qtrue;
+
return Qfalse;
}