From 7b81c9d7a3d1b1ce27c1853d8c0d6a622d57951d Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Apr 2005 02:45:38 +0000 Subject: * 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 --- eval.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'eval.c') 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; } -- cgit v1.2.3