* 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
This commit is contained in:
nobu 2005-04-23 02:45:38 +00:00
parent d8cd7516c5
commit 7b81c9d7a3
2 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Sat Apr 23 11:45:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_provided): should check also path name to be loaded.
fixed: [ruby-dev:26093]
Fri Apr 22 16:55:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> Fri Apr 22 16:55:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tk/tcltklib.c (ip_set_exc_message): fixed memory leak. * ext/tk/tcltklib.c (ip_set_exc_message): fixed memory leak.

26
eval.c
View File

@ -6779,23 +6779,33 @@ static const char *const loadable_ext[] = {
0 0
}; };
static int search_required _((VALUE, VALUE *));
int int
rb_provided(feature) rb_provided(feature)
const char *feature; const char *feature;
{ {
int i; int i;
char *buf; char *buf;
VALUE fname;
if (rb_feature_p(feature, 0, Qfalse)) if (rb_feature_p(feature, 0, Qfalse))
return Qtrue; return Qtrue;
if (!loading_tbl) return Qfalse; if (loading_tbl) {
if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue; if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue;
buf = ALLOCA_N(char, strlen(feature)+8); buf = ALLOCA_N(char, strlen(feature)+8);
strcpy(buf, feature); strcpy(buf, feature);
for (i=0; ; i++) { for (i=0; loadable_ext[i]; i++) {
if (!loadable_ext[i]) break; strcpy(buf+strlen(feature), loadable_ext[i]);
strcpy(buf+strlen(feature), loadable_ext[i]); if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue;
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; return Qfalse;
} }