aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-20 21:44:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-20 21:44:20 +0000
commit756a1c457e8b5243c6fb09fa0aa8c71f5ca78646 (patch)
tree59d3be12b99674beca8332e94fa18a6559337d09
parent3ff0189a1f8a9639c0f8a67e4bb2c880d5c38f7b (diff)
downloadruby-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
-rw-r--r--ChangeLog5
-rw-r--r--ruby.c43
2 files changed, 42 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index c58597eb90..9761b718e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Apr 21 06:44:10 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ruby.c (ruby_incpush_expand, proc_options): expand relative path
+ given with -I option. [ruby-dev:26090]
+
Thu Apr 21 01:53:09 2005 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb: add rdoc.
diff --git a/ruby.c b/ruby.c
index 7f4ace7312..7507a53686 100644
--- a/ruby.c
+++ b/ruby.c
@@ -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;