Navigation Menu

Skip to content

Commit

Permalink
* load.c (rb_get_expanded_load_path): always expand load paths.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Feb 5, 2011
1 parent e9cc518 commit bf794af
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Sat Feb 5 10:09:31 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>

* load.c (rb_get_expanded_load_path): always expand load paths.

Sat Feb 5 09:38:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Feb 5 09:38:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>


* transcode.c (encoded_dup): extract. * transcode.c (encoded_dup): extract.
Expand Down
8 changes: 0 additions & 8 deletions load.c
Expand Up @@ -48,14 +48,6 @@ rb_get_expanded_load_path(void)
VALUE ary; VALUE ary;
long i; 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)); ary = rb_ary_new2(RARRAY_LEN(load_path));
for (i = 0; i < RARRAY_LEN(load_path); ++i) { for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil); VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil);
Expand Down
25 changes: 25 additions & 0 deletions test/ruby/test_autoload.rb
Expand Up @@ -9,4 +9,29 @@ def test_autoload_so
begin Continuation; rescue LoadError; end begin Continuation; rescue LoadError; end
INPUT INPUT
end end

def test_non_realpath_in_loadpath
require 'tmpdir'
tmpdir = Dir.mktmpdir('autoload')
tmpdirs = [tmpdir]
tmpdirs.unshift(tmpdir + '/foo')
Dir.mkdir(tmpdirs[0])
tmpfiles = [tmpdir + '/foo.rb', tmpdir + '/foo/bar.rb']
open(tmpfiles[0] , 'w') do |f|
f.puts <<-INPUT
$:.unshift(File.expand_path('..', __FILE__)+'/./foo')
module Foo
autoload :Bar, 'bar'
end
Foo::Bar
INPUT
end
open(tmpfiles[1], 'w') do |f|
f.puts 'class Foo::Bar; end'
end
assert_in_out_err([tmpfiles[0]], "", [], [])
ensure
File.unlink(*tmpfiles) rescue nil if tmpfiles
tmpdirs.each {|dir| Dir.rmdir(dir)}
end
end end

0 comments on commit bf794af

Please sign in to comment.