aboutsummaryrefslogtreecommitdiffstats
path: root/load.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-31 01:14:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-31 01:14:51 +0000
commit58508e8b558e1ae83d2f15617cb09f1cee8e222e (patch)
treedc30aa5c4d801c486503fd4a617f10307f4aa02f /load.c
parentc5e8627f658c88b2403e7b20637cf25e31feff88 (diff)
downloadruby-58508e8b558e1ae83d2f15617cb09f1cee8e222e.tar.gz
load.c: resolve_feature_path
* load.c (rb_resolve_feature_path): search the path for already loaded feature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'load.c')
-rw-r--r--load.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/load.c b/load.c
index d3ea6d7512..b8a1bc92a5 100644
--- a/load.c
+++ b/load.c
@@ -840,8 +840,10 @@ rb_f_require_relative(VALUE obj, VALUE fname)
return rb_require_safe(rb_file_absolute_path(fname, base), rb_safe_level());
}
+typedef int (*feature_func)(const char *feature, const char *ext, int rb, int expanded, const char **fn);
+
static int
-search_required(VALUE fname, volatile VALUE *path, int safe_level)
+search_required(VALUE fname, volatile VALUE *path, int safe_level, feature_func rb_feature_p)
{
VALUE tmp;
char *ext, *ftptr;
@@ -945,6 +947,12 @@ load_ext(VALUE path)
/* Method is documented in vm.c */
+static int
+no_feature_p(const char *feature, const char *ext, int rb, int expanded, const char **fn)
+{
+ return 0;
+}
+
VALUE
rb_resolve_feature_path(VALUE klass, VALUE fname)
{
@@ -954,7 +962,7 @@ rb_resolve_feature_path(VALUE klass, VALUE fname)
fname = rb_get_path_check(fname, 0);
path = rb_str_encode_ospath(fname);
- found = search_required(path, &path, 0);
+ found = search_required(path, &path, 0, no_feature_p);
switch (found) {
case 'r':
@@ -1003,7 +1011,7 @@ rb_require_internal(VALUE fname, int safe)
rb_set_safe_level_force(0);
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, RSTRING_PTR(fname));
- found = search_required(path, &path, safe);
+ found = search_required(path, &path, safe, rb_feature_p);
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, RSTRING_PTR(fname));
if (found) {