diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-20 21:44:20 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-20 21:44:20 +0000 |
commit | 756a1c457e8b5243c6fb09fa0aa8c71f5ca78646 (patch) | |
tree | 59d3be12b99674beca8332e94fa18a6559337d09 /ruby.c | |
parent | 3ff0189a1f8a9639c0f8a67e4bb2c880d5c38f7b (diff) | |
download | bundler-756a1c457e8b5243c6fb09fa0aa8c71f5ca78646.tar.gz |
* ruby.c (ruby_incpush_expand, proc_options): expand relative path
given with -I option. [ruby-dev:26090]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 43 |
1 files changed, 37 insertions, 6 deletions
@@ -178,8 +178,9 @@ rubylib_mangle(s, l) #endif void -ruby_incpush(path) +ruby_push_include(path, filter) const char *path; + VALUE (*filter)_((VALUE)); { const char sep = PATH_SEP_CHAR; @@ -199,21 +200,51 @@ ruby_incpush(path) while (*p) { while (*p == sep) p++; if (s = strchr(p, sep)) { - rb_ary_push(ary, rubylib_mangled_path(p, (int)(s-p))); + rb_ary_push(ary, (*filter)(rubylib_mangled_path(p, (int)(s-p)))); p = s + 1; } else { - rb_ary_push(ary, rubylib_mangled_path2(p)); + rb_ary_push(ary, (*filter)(rubylib_mangled_path2(p))); break; } } rb_ary_concat(rb_load_path, ary); } else { - rb_ary_push(rb_load_path, rubylib_mangled_path2(path)); + rb_ary_push(rb_load_path, (*filter)(rubylib_mangled_path2(path))); } } +static VALUE +identical_path(path) + VALUE path; +{ + return path; +} + +void +ruby_incpush(const char *path) +{ + ruby_push_include(path, identical_path); +} + +static VALUE +expand_include_path(path) + VALUE path; +{ + char *p = RSTRING(path)->ptr; + if (!p) return path; + if (*p == '.' && p[1] == '/') return path; + return rb_file_expand_path(path, Qnil); +} + + +void +ruby_incpush_expand(const char *path) +{ + ruby_push_include(path, expand_include_path); +} + #if defined DOSISH || defined __CYGWIN__ #define LOAD_RELATIVE 1 #endif @@ -626,9 +657,9 @@ proc_options(argc, argv) case 'I': forbid_setid("-I"); if (*++s) - ruby_incpush(s); + ruby_incpush_expand(s); else if (argv[1]) { - ruby_incpush(argv[1]); + ruby_incpush_expand(argv[1]); argc--,argv++; } break; |