diff --git a/ChangeLog b/ChangeLog index 9a1307087d..85b683765b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Nov 21 22:19:33 2005 Nobuyoshi Nakada + + * 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 * win32/setup.mk: findstr doesn't exist on win9x. diff --git a/file.c b/file.c index e427cedade..37c83f208a 100644 --- a/file.c +++ b/file.c @@ -2214,14 +2214,18 @@ rb_path_next(const char *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(const char *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; } @@ -2569,6 +2573,9 @@ rb_file_s_basename(int argc, VALUE *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) { @@ -2577,14 +2584,30 @@ rb_file_s_basename(int argc, VALUE *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))) {