summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-23 02:45:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-23 02:45:38 +0000
commit7b81c9d7a3d1b1ce27c1853d8c0d6a622d57951d (patch)
tree872f8154cc894a86772761c5843c2f6596ddcbea /eval.c
parentd8cd7516c5d0ff56842ad4dbd676aca2b0e9f137 (diff)
* eval.c (rb_provided): should check also path name to be loaded.
fixed: [ruby-dev:26093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/eval.c b/eval.c
index 5807aa53b8..6f6e3d1197 100644
--- a/eval.c
+++ b/eval.c
@@ -6779,23 +6779,33 @@ static const char *const loadable_ext[] = {
0
};
+static int search_required _((VALUE, VALUE *));
+
int
rb_provided(feature)
const char *feature;
{
int i;
char *buf;
+ VALUE fname;
if (rb_feature_p(feature, 0, Qfalse))
return Qtrue;
- if (!loading_tbl) return Qfalse;
- if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue;
- buf = ALLOCA_N(char, strlen(feature)+8);
- strcpy(buf, feature);
- for (i=0; ; i++) {
- if (!loadable_ext[i]) break;
- strcpy(buf+strlen(feature), loadable_ext[i]);
- if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue;
+ if (loading_tbl) {
+ if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue;
+ buf = ALLOCA_N(char, strlen(feature)+8);
+ strcpy(buf, feature);
+ for (i=0; loadable_ext[i]; i++) {
+ strcpy(buf+strlen(feature), loadable_ext[i]);
+ if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue;
+ }
+ }
+ if (search_required(rb_str_new2(feature), &fname)) {
+ feature = RSTRING(fname)->ptr;
+ if (rb_feature_p(feature, 0, Qfalse))
+ return Qtrue;
+ if (loading_tbl && st_lookup(loading_tbl, (st_data_t)feature, 0))
+ return Qtrue;
}
return Qfalse;
}