Skip to content

Instantly share code, notes, and snippets.

@hannahwhy
Created January 19, 2011 05:17
Show Gist options
  • Select an option

  • Save hannahwhy/785728 to your computer and use it in GitHub Desktop.

Select an option

Save hannahwhy/785728 to your computer and use it in GitHub Desktop.
modification of rb_get_expanded_load_path to handle /a/b/../c
diff --git a/load.c b/load.c
index 185d6e0..5e6b9d0 100644
--- a/load.c
+++ b/load.c
@@ -48,14 +48,6 @@ rb_get_expanded_load_path(void)
VALUE ary;
long i;
- for (i = 0; i < RARRAY_LEN(load_path); ++i) {
- VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]);
- if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str)))
- goto relative_path_found;
- }
- return load_path;
-
- relative_path_found:
ary = rb_ary_new2(RARRAY_LEN(load_path));
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil);
VALUE
rb_get_expanded_load_path(void)
{
VALUE load_path = rb_get_load_path();
VALUE ary;
long i;
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]);
if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str)))
goto relative_path_found;
}
return load_path;
relative_path_found:
ary = rb_ary_new2(RARRAY_LEN(load_path));
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil);
rb_str_freeze(path);
rb_ary_push(ary, path);
}
rb_obj_freeze(ary);
return ary;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment