summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-28 20:52:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-28 20:52:16 +0000
commitb67ecc80df8502e10ddce0ceaeb7b5dfb5f8fba4 (patch)
treed19f5fc40dcc8c01ae2e10a3f4de9f2d567b5f92 /file.c
parent793af6993f90c80250c6d4be6829ca5b88b9d885 (diff)
* file.c (rb_file_s_basename): pass baselen to rmext.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/file.c b/file.c
index 9c94e7f555..8ce1f8dfe3 100644
--- a/file.c
+++ b/file.c
@@ -3398,15 +3398,12 @@ rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass)
}
static size_t
-rmext(const char *p, long l1, const char *e)
+rmext(const char *p, long l0, long l1, const char *e)
{
- long l0, l2;
+ long l2;
if (!e) return 0;
- for (l0 = 0; l0 < l1; ++l0) {
- if (p[l0] != '.') break;
- }
l2 = strlen(e);
if (l2 == 2 && e[1] == '*') {
unsigned char c = *e;
@@ -3527,7 +3524,7 @@ rb_file_s_basename(int argc, VALUE *argv)
p = ruby_find_basename(name, &f, &n);
if (n >= 0) {
- if (NIL_P(fext) || !(f = rmext(p, n, StringValueCStr(fext)))) {
+ if (NIL_P(fext) || !(f = rmext(p, f, n, StringValueCStr(fext)))) {
f = n;
}
if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname);