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
1119 1119
static VALUE
1120 1120
dir_s_chroot(VALUE dir, VALUE path)
1121 1121
{
1122
    VALUE features = rb_gv_get("$LOADED_FEATURES");
1123
    VALUE chroot_to;
1124

  
1122 1125
    path = check_dirname(path);
1126
    chroot_to = rb_file_s_expand_path(1, &path);
1123 1127
    if (chroot(RSTRING_PTR(path)) == -1)
1124 1128
	rb_sys_fail_path(path);
1125 1129

  
1130
    if (rb_type(features) == RUBY_T_ARRAY &&
1131
        rb_type(chroot_to) == RUBY_T_STRING) {
1132
	long i, features_len, chroot_len, feature_min_len;
1133
	VALUE feature;
1134
	char * chroot_str = RSTRING_PTR(chroot_to);
1135

  
1136
	features_len = RARRAY_LEN(features);
1137
	chroot_len = RSTRING_LEN(chroot_to);
1138
	feature_min_len = chroot_len + 1;
1139

  
1140
	for (i=0; i < features_len; i++) {
1141
	    feature = RARRAY_AREF(features, i);
1142
	    if ((rb_type(feature) == RUBY_T_STRING) &&
1143
		RSTRING_LEN(feature) > feature_min_len &&
1144
	        strncmp(chroot_str, RSTRING_PTR(feature), chroot_len) == 0) {
1145
		feature = rb_str_substr(feature, chroot_len,
1146
		                        RSTRING_LEN(feature));
1147
		RARRAY_ASET(features, i, feature);
1148
		features_index_add(feature, INT2FIX(i));
1149
	    }
1150
	}
1151
    }
1152

  
1126 1153
    return INT2FIX(0);
1127 1154
}
1128 1155
#else
load.c
220 220
   or ends in '/'.  This maintains the invariant that `rb_feature_p()`
221 221
   relies on for its fast lookup.
222 222
*/
223
static void
223
void
224 224
features_index_add(VALUE feature, VALUE offset)
225 225
{
226 226
    VALUE short_feature;
227
-