* load.c (features_index_add): use rb_str_subseq() to specify C string

position properly to fix require non ascii path.
  [ruby-core:53733] [Bug #8165]

* test/ruby/test_require.rb (TestRequire#test_require_nonascii_path):
  a test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shirosaki 2013-04-05 15:30:52 +00:00
parent 21d47b7381
commit 07636ed42e
3 changed files with 33 additions and 3 deletions

View file

@ -59,6 +59,27 @@ class TestRequire < Test::Unit::TestCase
end
end
def test_require_nonascii_path
bug8165 = '[ruby-core:53733] [Bug #8165]'
Dir.mktmpdir {|tmp|
encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? 'filesystem' : 'UTF-8'
dir = "\u3042" * 5
begin
require_path = File.join(tmp, dir, 'foo.rb').encode(encoding)
rescue
skip "cannot convert path encoding to #{encoding}"
end
Dir.mkdir(File.dirname(require_path))
open(require_path, "wb") {}
assert_in_out_err([], <<-INPUT, %w(:ok), [], bug8165)
# coding: #{encoding}
$:.replace([IO::NULL] + $:.reject {|path| path !~ /\.ext/})
p :ok if require '#{require_path}'
p :ng if require '#{require_path}'
INPUT
}
end
def test_require_path_home_1
env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"]
pathname_too_long = /pathname too long \(ignored\).*\(LoadError\)/m