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

* lib/pathname.rb (relative_path_from): backport r23093 and r25440

from ruby_1_9_2.  [ruby-core:32415]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@29333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-09-24 07:23:44 +00:00
parent f5cbe886b6
commit b39ec66ece
2 changed files with 14 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Fri Sep 24 16:22:40 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/pathname.rb (relative_path_from): backport r23093 and r25440
from ruby_1_9_2. [ruby-core:32415]
Fri Sep 24 03:00:26 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_add_threadswitch_hook): wrapper for unofficial APIs

View file

@ -194,6 +194,13 @@ class Pathname
# to_path is implemented so Pathname objects are usable with File.open, etc.
TO_PATH = :to_path
end
SAME_PATHS = if File::FNM_SYSCASE.nonzero?
proc {|a, b| a.casecmp(b).zero?}
else
proc {|a, b| a == b}
end
# :startdoc:
#
@ -719,12 +726,12 @@ class Pathname
base_prefix, basename = r
base_names.unshift basename if basename != '.'
end
if dest_prefix != base_prefix
unless SAME_PATHS[dest_prefix, base_prefix]
raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
end
while !dest_names.empty? &&
!base_names.empty? &&
dest_names.first == base_names.first
SAME_PATHS[dest_names.first, base_names.first]
dest_names.shift
base_names.shift
end