summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 04:22:30 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 04:22:30 +0000
commit09e1383bcf4cb28a9a55e7d25277194b0222d051 (patch)
tree4408927f9c6b5572d5966fecc008a255cc7d1d0b /file.c
parent42f4a548f0e8ad0fa22a4132b164c7ab76e3bf45 (diff)
* file.c (ruby_find_basename): set correct baselen.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c18
1 files changed, 12 insertions, 6 deletions
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;
}