summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-25 12:25:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-25 12:25:29 +0000
commitb96af08adda6e5e47088e7299567f8cb4cfb104b (patch)
tree2487b7319ae0948510981d002d7b9d1c1a75eeab /file.c
parentdb7f24b362bf9a0831f9a6f12ac0f1a21e476cf0 (diff)
* file.c (rb_path_end): skip root directory. fixed: [ruby-core:08913]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/file.c b/file.c
index a9864f5703..6018862d11 100644
--- a/file.c
+++ b/file.c
@@ -2367,9 +2367,8 @@ rb_path_last_separator(const char *path)
return last;
}
-#define chompdirsep rb_path_end
-char *
-rb_path_end(const char *path)
+static char *
+chompdirsep(const char *path)
{
while (*path) {
if (isdirsep(*path)) {
@@ -2384,6 +2383,13 @@ rb_path_end(const char *path)
return (char *)path;
}
+char *
+rb_path_end(const char *path)
+{
+ if (isdirsep(*path)) path++;
+ return chompdirsep(path);
+}
+
#define BUFCHECK(cond) do {\
long bdiff = p - buf;\
while (cond) {\
@@ -2752,7 +2758,7 @@ rb_file_s_basename(int argc, VALUE *argv)
static VALUE
rb_file_s_dirname(VALUE klass, VALUE fname)
{
- char *name, *root, *p;
+ const char *name, *root, *p;
VALUE dirname;
name = StringValueCStr(fname);
@@ -2772,8 +2778,9 @@ rb_file_s_dirname(VALUE klass, VALUE fname)
return rb_str_new2(".");
#ifdef DOSISH_DRIVE_LETTER
if (has_drive_letter(name) && isdirsep(*(name + 2))) {
+ const char *top = skiproot(name + 2);
dirname = rb_str_new(name, 3);
- rb_str_cat(dirname, skiproot(name + 2), p - skiproot(name + 2));
+ rb_str_cat(dirname, top, p - top);
}
else
#endif