diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-25 12:25:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-25 12:25:29 +0000 |
commit | f3925d5ae05aad612ef9a52d6e3f49df2e480bf9 (patch) | |
tree | 258259feb6d37a823b41d7402fac8a9d6bfa9d5d /file.c | |
parent | c451d96fe62f1a9549c271aed572682b1b6dbe46 (diff) |
* file.c (rb_path_end): skip root directory. fixed: [ruby-core:08913]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -2427,9 +2427,8 @@ rb_path_last_separator(path) return last; } -#define chompdirsep rb_path_end char * -rb_path_end(path) +chompdirsep(path) const char *path; { while (*path) { @@ -2445,6 +2444,14 @@ rb_path_end(path) return (char *)path; } +char * +rb_path_end(path) + const char *path; +{ + if (isdirsep(*path)) path++; + return chompdirsep(path); +} + #define BUFCHECK(cond) do {\ long bdiff = p - buf;\ while (cond) {\ @@ -2821,7 +2828,7 @@ static VALUE rb_file_s_dirname(klass, fname) VALUE klass, fname; { - char *name, *root, *p; + const char *name, *root, *p; VALUE dirname; name = StringValueCStr(fname); @@ -2841,8 +2848,9 @@ rb_file_s_dirname(klass, 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 |