Bug #19378 » windows-revert-79a4484a.patch
load.c | ||
---|---|---|
return vm->loaded_features;
|
||
}
|
||
static VALUE
|
||
get_loaded_features_realpaths(rb_vm_t *vm)
|
||
{
|
||
return vm->loaded_features_realpaths;
|
||
}
|
||
static VALUE
|
||
get_LOADED_FEATURES(ID _x, VALUE *_y)
|
||
{
|
||
... | ... | |
modified loaded_features. Rebuild the index. */
|
||
st_foreach(vm->loaded_features_index, loaded_features_index_clear_i, 0);
|
||
VALUE realpaths = vm->loaded_features_realpaths;
|
||
rb_hash_clear(realpaths);
|
||
features = vm->loaded_features;
|
||
for (i = 0; i < RARRAY_LEN(features); i++) {
|
||
VALUE entry, as_str;
|
||
... | ... | |
features_index_add(vm, as_str, INT2FIX(i));
|
||
}
|
||
reset_loaded_features_snapshot(vm);
|
||
features = rb_ary_dup(vm->loaded_features_snapshot);
|
||
long j = RARRAY_LEN(features);
|
||
for (i = 0; i < j; i++) {
|
||
VALUE as_str = rb_ary_entry(features, i);
|
||
VALUE realpath = rb_check_realpath(Qnil, as_str, NULL);
|
||
if (NIL_P(realpath)) realpath = as_str;
|
||
rb_hash_aset(realpaths, rb_fstring(realpath), Qtrue);
|
||
}
|
||
}
|
||
return vm->loaded_features_index;
|
||
}
|
||
... | ... | |
char *volatile ftptr = 0;
|
||
VALUE path;
|
||
volatile VALUE saved_path;
|
||
volatile VALUE realpath = 0;
|
||
VALUE realpaths = get_loaded_features_realpaths(th->vm);
|
||
volatile bool reset_ext_config = false;
|
||
struct rb_ext_config prev_ext_config;
|
||
... | ... | |
result = TAG_RETURN;
|
||
}
|
||
#endif
|
||
else if (RTEST(rb_hash_aref(realpaths,
|
||
realpath = rb_realpath_internal(Qnil, path, 1)))) {
|
||
result = 0;
|
||
}
|
||
else {
|
||
switch (found) {
|
||
case 'r':
|
||
... | ... | |
if (result == TAG_RETURN) {
|
||
rb_provide_feature(th2->vm, path);
|
||
VALUE real = realpath;
|
||
if (real) {
|
||
rb_hash_aset(realpaths, rb_fstring(real), Qtrue);
|
||
}
|
||
}
|
||
ec->errinfo = saved.errinfo;
|
||
... | ... | |
vm->loaded_features = rb_ary_new();
|
||
vm->loaded_features_snapshot = rb_ary_hidden_new(0);
|
||
vm->loaded_features_index = st_init_numtable();
|
||
vm->loaded_features_realpaths = rb_hash_new();
|
||
rb_obj_hide(vm->loaded_features_realpaths);
|
||
rb_define_global_function("load", rb_f_load, -1);
|
||
rb_define_global_function("require", rb_f_require, 1);
|
test/ruby/test_require.rb | ||
---|---|---|
}
|
||
end
|
||
def test_relative_symlink_realpath
|
||
Dir.mktmpdir {|tmp|
|
||
Dir.chdir(tmp) {
|
||
Dir.mkdir "a"
|
||
File.open("a/a.rb", "w") {|f| f.puts 'require_relative "b"' }
|
||
File.open("a/b.rb", "w") {|f| f.puts '$t += 1' }
|
||
Dir.mkdir "b"
|
||
File.binwrite("c.rb", <<~RUBY)
|
||
$t = 0
|
||
$:.unshift(File.expand_path('../b', __FILE__))
|
||
require "b"
|
||
require "a"
|
||
print $t
|
||
RUBY
|
||
begin
|
||
File.symlink("../a/a.rb", "b/a.rb")
|
||
File.symlink("../a/b.rb", "b/b.rb")
|
||
result = IO.popen([EnvUtil.rubybin, "c.rb"], &:read)
|
||
assert_equal("1", result, "bug17885 [ruby-core:104010]")
|
||
rescue NotImplementedError, Errno::EACCES
|
||
omit "File.symlink is not implemented"
|
||
end
|
||
}
|
||
}
|
||
end
|
||
def test_frozen_loaded_features
|
||
bug3756 = '[ruby-core:31913]'
|
||
assert_in_out_err(['-e', '$LOADED_FEATURES.freeze; require "ostruct"'], "",
|
vm.c | ||
---|---|---|
vm->expanded_load_path = rb_gc_location(vm->expanded_load_path);
|
||
vm->loaded_features = rb_gc_location(vm->loaded_features);
|
||
vm->loaded_features_snapshot = rb_gc_location(vm->loaded_features_snapshot);
|
||
vm->loaded_features_realpaths = rb_gc_location(vm->loaded_features_realpaths);
|
||
vm->top_self = rb_gc_location(vm->top_self);
|
||
vm->orig_progname = rb_gc_location(vm->orig_progname);
|
||
... | ... | |
rb_gc_mark_movable(vm->expanded_load_path);
|
||
rb_gc_mark_movable(vm->loaded_features);
|
||
rb_gc_mark_movable(vm->loaded_features_snapshot);
|
||
rb_gc_mark_movable(vm->loaded_features_realpaths);
|
||
rb_gc_mark_movable(vm->top_self);
|
||
rb_gc_mark_movable(vm->orig_progname);
|
||
RUBY_MARK_MOVABLE_UNLESS_NULL(vm->coverages);
|
vm_core.h | ||
---|---|---|
VALUE expanded_load_path;
|
||
VALUE loaded_features;
|
||
VALUE loaded_features_snapshot;
|
||
VALUE loaded_features_realpaths;
|
||
struct st_table *loaded_features_index;
|
||
struct st_table *loading_table;
|
||
#if EXTSTATIC
|
- « Previous
- 1
- 2
- Next »