diff --git a/ChangeLog b/ChangeLog index dc04f84ea0..619bdebee5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 18 18:07:05 2005 NAKAMURA Usaku + + * file.c (rb_file_s_dirname): should use skipprefix for UNC path. + pointed out by nobu ([ruby-dev:27744]). fixed: [ruby-core:5076] + Fri Nov 18 17:35:09 2005 Hidetoshi NAGAI * ext/tk/lib/multi-tk.rb: add restriction to access the entried @@ -16,7 +21,7 @@ Fri Nov 18 17:35:09 2005 Hidetoshi NAGAI Fri Nov 18 16:47:33 2005 NAKAMURA Usaku - * file.c (file_s_dirname): added checks for some patterns with drive + * file.c (rb_file_s_dirname): added checks for some patterns with drive letter. fixed: [ruby-dev:27738] * test/ruby/test_path.rb (test_dirname): added tests for above diff --git a/file.c b/file.c index 669929b606..e427cedade 100644 --- a/file.c +++ b/file.c @@ -2626,8 +2626,8 @@ rb_file_s_dirname(VALUE klass, VALUE fname) name = StringValueCStr(fname); root = skiproot(name); #ifdef DOSISH_UNC - if (root > name + 2 && isdirsep(*name)) - name = root - 2; + if (root > name + 1 && isdirsep(*name)) + root = skipprefix(name = root - 2); #else if (root > name + 1) name = root - 1; diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb index 4b9365508a..09ab4ac677 100644 --- a/test/ruby/test_path.rb +++ b/test/ruby/test_path.rb @@ -95,23 +95,31 @@ class TestPath < Test::Unit::TestCase if /(bcc|ms|cyg)win|mingw|djgpp|human|emx/ =~ RUBY_PLATFORM # DOSISH_UNC assert_equal('//', File.dirname('//')) - assert_equal('//', File.dirname('//a')) - assert_equal('//', File.dirname('//a/')) - assert_equal('//a', File.dirname('//a/b')) + assert_equal('//a', File.dirname('//a')) + assert_equal('//a/', File.dirname('//a/')) + assert_equal('//a/b', File.dirname('//a/b')) + assert_equal('//a/b', File.dirname('//a/b/')) + assert_equal('//a/b', File.dirname('//a/b/c')) assert_equal('//', File.dirname('///')) - assert_equal('//', File.dirname('///a')) - assert_equal('//', File.dirname('///a/')) - assert_equal('//a', File.dirname('///a/b')) + assert_equal('//a', File.dirname('///a')) + assert_equal('//a/', File.dirname('///a/')) + assert_equal('//a/b', File.dirname('///a/b')) + assert_equal('//a/b', File.dirname('///a/b/')) + assert_equal('//a/b', File.dirname('///a/b/c')) else # others assert_equal('/', File.dirname('//')) assert_equal('/', File.dirname('//a')) assert_equal('/', File.dirname('//a/')) assert_equal('/a', File.dirname('//a/b')) + assert_equal('/a', File.dirname('//a/b/')) + assert_equal('/a/b', File.dirname('//a/b/c')) assert_equal('/', File.dirname('///')) assert_equal('/', File.dirname('///a')) assert_equal('/', File.dirname('///a/')) assert_equal('/a', File.dirname('///a/b')) + assert_equal('/a', File.dirname('///a/b/')) + assert_equal('/a/b', File.dirname('///a/b/c')) end end end