ruby-changes:46987
From: nobu <ko1@a...>
Date: Fri, 16 Jun 2017 23:44:07 +0900 (JST)
Subject: [ruby-changes:46987] nobu:r59102 (trunk): pathname.rb: UNC root pathname needs a separator
nobu 2017-06-16 23:44:01 +0900 (Fri, 16 Jun 2017) New Revision: 59102 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59102 Log: pathname.rb: UNC root pathname needs a separator * ext/pathname/lib/pathname.rb (Pathname#plus): UNC root pathname needs a separator. File.basename returns "/" on UNC root, as well as sole drive letter, even if it does not end with a separator. [ruby-core:80900] [Bug #13515] Modified files: trunk/ext/pathname/lib/pathname.rb trunk/test/pathname/test_pathname.rb Index: test/pathname/test_pathname.rb =================================================================== --- test/pathname/test_pathname.rb (revision 59101) +++ test/pathname/test_pathname.rb (revision 59102) @@ -14,8 +14,8 @@ class TestPathname < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L14 end def self.get_linenum - if /:(\d+):/ =~ caller[1] - $1.to_i + if loc = caller_locations(2, 1) + loc[0].lineno else nil end @@ -221,6 +221,8 @@ class TestPathname < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L221 defassert(:plus, 'a//b/d//e', 'a//b/c', '../d//e') + defassert(:plus, '//foo/var/bar', '//foo/var', 'bar') + def test_slash assert_kind_of(Pathname, Pathname("a") / Pathname("b")) end Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 59101) +++ ext/pathname/lib/pathname.rb (revision 59102) @@ -378,7 +378,7 @@ class Pathname https://github.com/ruby/ruby/blob/trunk/ext/pathname/lib/pathname.rb#L378 basename_list2.shift end r1 = chop_basename(prefix1) - if !r1 && /#{SEPARATOR_PAT}/o =~ File.basename(prefix1) + if !r1 && (r1 = /#{SEPARATOR_PAT}/o =~ File.basename(prefix1)) while !basename_list2.empty? && basename_list2.first == '..' index_list2.shift basename_list2.shift -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/