summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--file.c18
2 files changed, 16 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fd3c7e2d9e..8732f3a438 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jul 7 13:22:20 2010 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * file.c (ruby_find_basename): set correct baselen.
+
Wed Jul 7 13:02:59 2010 Akinori MUSHA <knu@iDaemons.org>
* vm_method.c (rb_method_boundp): respond_to?(:protected_method,
diff --git a/file.c b/file.c
index 63a6ebe61f..94c2468179 100644
--- a/file.c
+++ b/file.c
@@ -3430,9 +3430,9 @@ rmext(const char *p, long l1, const char *e)
}
const char *
-ruby_find_basename(const char *name, long *len, long *ext)
+ruby_find_basename(const char *name, long *baselen, long *alllen)
{
- const char *p;
+ const char *p, *q, *e;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
const char *root;
#endif
@@ -3476,12 +3476,18 @@ ruby_find_basename(const char *name, long *len, long *ext)
#else
n = chompdirsep(p) - p;
#endif
+ for (q = p; q - p < n && *q == '.'; q++);
+ for (e = 0; q - p < n; q = CharNext(q)) {
+ if (*q == '.') e = q;
+ }
+ if (e) f = e - p;
+ else f = n;
}
- if (len)
- *len = f;
- if (ext)
- *ext = n;
+ if (baselen)
+ *baselen = f;
+ if (alllen)
+ *alllen = n;
return p;
}