1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2005-04-20 21:44:20 +00:00
parent 3ff0189a1f
commit 756a1c457e
2 changed files with 42 additions and 6 deletions

View file

@ -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> Thu Apr 21 01:53:09 2005 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb: add rdoc. * lib/net/http.rb: add rdoc.

43
ruby.c
View file

@ -178,8 +178,9 @@ rubylib_mangle(s, l)
#endif #endif
void void
ruby_incpush(path) ruby_push_include(path, filter)
const char *path; const char *path;
VALUE (*filter)_((VALUE));
{ {
const char sep = PATH_SEP_CHAR; const char sep = PATH_SEP_CHAR;
@ -199,21 +200,51 @@ ruby_incpush(path)
while (*p) { while (*p) {
while (*p == sep) p++; while (*p == sep) p++;
if (s = strchr(p, sep)) { 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; p = s + 1;
} }
else { else {
rb_ary_push(ary, rubylib_mangled_path2(p)); rb_ary_push(ary, (*filter)(rubylib_mangled_path2(p)));
break; break;
} }
} }
rb_ary_concat(rb_load_path, ary); rb_ary_concat(rb_load_path, ary);
} }
else { 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__ #if defined DOSISH || defined __CYGWIN__
#define LOAD_RELATIVE 1 #define LOAD_RELATIVE 1
#endif #endif
@ -626,9 +657,9 @@ proc_options(argc, argv)
case 'I': case 'I':
forbid_setid("-I"); forbid_setid("-I");
if (*++s) if (*++s)
ruby_incpush(s); ruby_incpush_expand(s);
else if (argv[1]) { else if (argv[1]) {
ruby_incpush(argv[1]); ruby_incpush_expand(argv[1]);
argc--,argv++; argc--,argv++;
} }
break; break;