Project

General

Profile

Feature #13300 ยป 0001-Strip-chroot-path-from-LOADED_FEATURES-when-calling-.patch

jeremyevans0 (Jeremy Evans), 03/10/2017 11:49 PM

View differences:

dir.c
static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
VALUE features = rb_gv_get("$LOADED_FEATURES");
VALUE chroot_to;
path = check_dirname(path);
chroot_to = rb_file_s_expand_path(1, &path);
if (chroot(RSTRING_PTR(path)) == -1)
rb_sys_fail_path(path);
if (rb_type(features) == RUBY_T_ARRAY &&
rb_type(chroot_to) == RUBY_T_STRING) {
long i, features_len, chroot_len, feature_min_len;
VALUE feature;
char * chroot_str = RSTRING_PTR(chroot_to);
features_len = RARRAY_LEN(features);
chroot_len = RSTRING_LEN(chroot_to);
feature_min_len = chroot_len + 1;
for (i=0; i < features_len; i++) {
feature = RARRAY_AREF(features, i);
if ((rb_type(feature) == RUBY_T_STRING) &&
RSTRING_LEN(feature) > feature_min_len &&
strncmp(chroot_str, RSTRING_PTR(feature), chroot_len) == 0) {
feature = rb_str_substr(feature, chroot_len,
RSTRING_LEN(feature));
RARRAY_ASET(features, i, feature);
features_index_add(feature, INT2FIX(i));
}
}
}
return INT2FIX(0);
}
#else
load.c
or ends in '/'. This maintains the invariant that `rb_feature_p()`
relies on for its fast lookup.
*/
static void
void
features_index_add(VALUE feature, VALUE offset)
{
VALUE short_feature;
    (1-1/1)