diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-19 13:35:11 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-19 13:35:11 +0000 |
commit | 39ba53860bd86b50c031f847a8aa9b844466d371 (patch) | |
tree | 8d597f5c4c13cf922a8aaaadd7261fb4b8b4197b | |
parent | f8063e378c2d198f20c2a47e1ecba97c6940409a (diff) |
merges r23093 from trunk into ruby_1_9_1.
--
* lib/pathname.rb (Pathname#relative_path_from): compares path
components according to system default case-sensitiveness.
[ruby-core:22829]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/pathname.rb | 11 |
2 files changed, 15 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Sun Mar 29 08:59:26 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/pathname.rb (Pathname#relative_path_from): compares path + components according to system default case-sensitiveness. + [ruby-core:22829] + Sat Mar 28 11:10:32 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * common.mk (ruby.imp): all symbols in static library need to be diff --git a/lib/pathname.rb b/lib/pathname.rb index ed98c7b367..fbb42a66a1 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -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 + proc {|a, b| a.casecmp(b).zero?} + else + proc {|a, b| a == b} + end + # :startdoc: # @@ -731,12 +738,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 |