mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (search_required): expand home relative path first.
[ruby-core:29610] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dcb13f8e17
commit
3dea38333c
3 changed files with 37 additions and 1 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Apr 19 19:13:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (search_required): expand home relative path first.
|
||||||
|
[ruby-core:29610]
|
||||||
|
|
||||||
Mon Apr 19 12:46:15 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Apr 19 12:46:15 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/timeout.rb (Timeout#timeout): propagate errors to the
|
* lib/timeout.rb (Timeout#timeout): propagate errors to the
|
||||||
|
|
|
||||||
6
eval.c
6
eval.c
|
|
@ -7411,9 +7411,13 @@ search_required(fname, featurep, path)
|
||||||
const char *ext, *ftptr;
|
const char *ext, *ftptr;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
if (*(ftptr = RSTRING_PTR(fname)) == '~') {
|
||||||
|
fname = rb_file_expand_path(fname, Qnil);
|
||||||
|
ftptr = RSTRING_PTR(fname);
|
||||||
|
}
|
||||||
*featurep = fname;
|
*featurep = fname;
|
||||||
*path = 0;
|
*path = 0;
|
||||||
ext = strrchr(ftptr = RSTRING_PTR(fname), '.');
|
ext = strrchr(ftptr, '.');
|
||||||
if (ext && !strchr(ext, '/')) {
|
if (ext && !strchr(ext, '/')) {
|
||||||
if (strcmp(".rb", ext) == 0) {
|
if (strcmp(".rb", ext) == 0) {
|
||||||
if (rb_feature_p(ftptr, ext, Qtrue)) {
|
if (rb_feature_p(ftptr, ext, Qtrue)) {
|
||||||
|
|
|
||||||
27
test/ruby/test_require.rb
Normal file
27
test/ruby/test_require.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
require 'test/unit'
|
||||||
|
|
||||||
|
require 'tempfile'
|
||||||
|
require File.expand_path('../envutil', __FILE__)
|
||||||
|
require 'tmpdir'
|
||||||
|
|
||||||
|
class TestRequire < Test::Unit::TestCase
|
||||||
|
def test_home_path
|
||||||
|
home = ENV["HOME"]
|
||||||
|
bug3171 = '[ruby-core:29610]'
|
||||||
|
Dir.mktmpdir do |tmp|
|
||||||
|
ENV["HOME"] = tmp
|
||||||
|
name = "loadtest#{$$}-1"
|
||||||
|
path = File.join(tmp, name) << ".rb"
|
||||||
|
open(path, "w") {}
|
||||||
|
require "~/#{name}"
|
||||||
|
assert_equal(path, $"[-1], bug3171)
|
||||||
|
name.succ!
|
||||||
|
path = File.join(tmp, name << ".rb")
|
||||||
|
open(path, "w") {}
|
||||||
|
require "~/#{name}"
|
||||||
|
assert_equal(path, $"[-1], bug3171)
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
ENV["HOME"] = home
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue