diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-21 13:21:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-21 13:21:47 +0000 |
commit | c49ad1c40dde6da0404bb31e8e07740336d96cdd (patch) | |
tree | 88ae5725e4ceece2c9da898d90e8b877f74be8d4 | |
parent | 6fb4053d9e34ea1f06f888b74b9f9ff7b12ac064 (diff) |
* file.c (rb_path_skip_prefix, rb_file_s_basename): UNC without path
should not be splitted. fixed: [ruby-dev:27776] [ruby-dev:27786]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | file.c | 29 |
2 files changed, 31 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Nov 21 22:19:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_path_skip_prefix, rb_file_s_basename): UNC without path + should not be splitted. fixed: [ruby-dev:27776] [ruby-dev:27786] + Mon Nov 21 16:03:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> * win32/setup.mk: findstr doesn't exist on win9x. @@ -2266,7 +2266,11 @@ rb_path_next(s) return (char *)s; } +#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) #define skipprefix rb_path_skip_prefix +#else +#define skipprefix(path) (path) +#endif char * rb_path_skip_prefix(path) const char *path; @@ -2274,7 +2278,7 @@ rb_path_skip_prefix(path) #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) #ifdef DOSISH_UNC if (isdirsep(path[0]) && isdirsep(path[1])) { - if (*(path = nextdirsep(path + 2))) + if (*(path = nextdirsep(path + 2)) && path[1] && !isdirsep(path[1])) path = nextdirsep(path + 1); return (char *)path; } @@ -2630,6 +2634,9 @@ rb_file_s_basename(argc, argv) { VALUE fname, fext, basename; char *name, *p; +#ifdef DOSISH + char *root; +#endif int f; if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) { @@ -2638,15 +2645,31 @@ rb_file_s_basename(argc, argv) StringValue(fname); if (RSTRING(fname)->len == 0 || !*(name = RSTRING(fname)->ptr)) return fname; - if (!*(name = skiproot(name))) { + name = skipprefix(name); +#ifdef DOSISH + root = name; +#endif + while (isdirsep(*name)) + name++; + if (!*name) { p = name - 1; f = 1; +#ifdef DOSISH + if (name != root) { + /* has slashes */ + } #ifdef DOSISH_DRIVE_LETTER - if (*p == ':') { + else if (*p == ':') { p++; f = 0; } #endif +#ifdef DOSISH_UNC + else { + p = "/"; + } +#endif +#endif } else if (!(p = strrdirsep(name))) { if (NIL_P(fext) || !(f = rmext(name, StringValueCStr(fext)))) { |