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:
parent
ed9a1f3e8f
commit
a8abed1256
3 changed files with 22 additions and 9 deletions
|
@ -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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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
|
||||
|
|
4
file.c
4
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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue