summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-18 08:27:52 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-18 08:27:52 +0000
commit147dcb2236416f0d40497caf2cc5eba754bbbefb (patch)
tree8117fbcddd482f273eecb1a45fde7a5865fbb13e /file.c
parent8f8d046b1fa27cc84a5de7b0367c3326b02050b2 (diff)
* file.c (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 patterns. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/file.c b/file.c
index 8db72a0..36c5ed8 100644
--- a/file.c
+++ b/file.c
@@ -2689,7 +2689,7 @@ rb_file_s_dirname(klass, fname)
root = skiproot(name);
#ifdef DOSISH_UNC
if (root > name + 1 && isdirsep(*name))
- root = skipprefix(name = root - 2);
+ name = root - 2;
#else
if (root > name + 1)
name = root - 1;
@@ -2700,9 +2700,16 @@ rb_file_s_dirname(klass, fname)
}
if (p == name)
return rb_str_new2(".");
+#ifdef DOSISH_DRIVE_LETTER
+ if (has_drive_letter(name) && isdirsep(*(name + 2))) {
+ dirname = rb_str_new(name, 3);
+ rb_str_cat(dirname, skiproot(name + 2), p - skiproot(name + 2));
+ }
+ else
+#endif
dirname = rb_str_new(name, p - name);
#ifdef DOSISH_DRIVE_LETTER
- if (root == name + 2 && name[1] == ':')
+ if (has_drive_letter(name) && root == name + 2 && p - name == 2)
rb_str_cat(dirname, ".", 1);
#endif
OBJ_INFECT(dirname, fname);