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

* file.c (rb_file_s_dirname): should use skipprefix for UNC path.

pointed out by nobu ([ruby-dev:27744]). fixed: [ruby-core:5076]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2005-11-18 09:09:25 +00:00
parent ed9a1f3e8f
commit a8abed1256
3 changed files with 22 additions and 9 deletions

View file

@ -1,3 +1,8 @@
Fri Nov 18 18:07:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* 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 <nagai@ai.kyutech.ac.jp> Fri Nov 18 17:35:09 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: add restriction to access the entried * 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 <nagai@ai.kyutech.ac.jp>
Fri Nov 18 16:47:33 2005 NAKAMURA Usaku <usa@ruby-lang.org> Fri Nov 18 16:47:33 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* 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] letter. fixed: [ruby-dev:27738]
* test/ruby/test_path.rb (test_dirname): added tests for above * test/ruby/test_path.rb (test_dirname): added tests for above

4
file.c
View file

@ -2626,8 +2626,8 @@ rb_file_s_dirname(VALUE klass, VALUE fname)
name = StringValueCStr(fname); name = StringValueCStr(fname);
root = skiproot(name); root = skiproot(name);
#ifdef DOSISH_UNC #ifdef DOSISH_UNC
if (root > name + 2 && isdirsep(*name)) if (root > name + 1 && isdirsep(*name))
name = root - 2; root = skipprefix(name = root - 2);
#else #else
if (root > name + 1) if (root > name + 1)
name = root - 1; name = root - 1;

View file

@ -95,23 +95,31 @@ class TestPath < Test::Unit::TestCase
if /(bcc|ms|cyg)win|mingw|djgpp|human|emx/ =~ RUBY_PLATFORM if /(bcc|ms|cyg)win|mingw|djgpp|human|emx/ =~ RUBY_PLATFORM
# DOSISH_UNC # DOSISH_UNC
assert_equal('//', File.dirname('//')) assert_equal('//', File.dirname('//'))
assert_equal('//', File.dirname('//a')) assert_equal('//a', File.dirname('//a'))
assert_equal('//', File.dirname('//a/')) assert_equal('//a/', File.dirname('//a/'))
assert_equal('//a', File.dirname('//a/b')) 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('///'))
assert_equal('//', File.dirname('///a')) assert_equal('//a', File.dirname('///a'))
assert_equal('//', File.dirname('///a/')) assert_equal('//a/', File.dirname('///a/'))
assert_equal('//a', File.dirname('///a/b')) 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 else
# others # others
assert_equal('/', File.dirname('//')) assert_equal('/', File.dirname('//'))
assert_equal('/', File.dirname('//a')) assert_equal('/', File.dirname('//a'))
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', File.dirname('//a/b/'))
assert_equal('/a/b', File.dirname('//a/b/c'))
assert_equal('/', File.dirname('///')) assert_equal('/', File.dirname('///'))
assert_equal('/', File.dirname('///a')) assert_equal('/', File.dirname('///a'))
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', File.dirname('///a/b/'))
assert_equal('/a/b', File.dirname('///a/b/c'))
end end
end end
end end