summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--file.c29
2 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 7799b7579b..818c814389 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/file.c b/file.c
index e2136f2d64..c114818246 100644
--- a/file.c
+++ b/file.c
@@ -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)))) {