summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-26 18:57:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-26 18:57:23 +0000
commit9320b5c65ff0f51d8fdc74d70476db70e40231e7 (patch)
treec036b64beb1936a7dceb109dfabe9ea275f8bb07 /file.c
parent655685612ef08de21c098a5dc44076b90344edb8 (diff)
* file.c (rmext): preceding dots are not a part of extension.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/file.c b/file.c
index 62155faf53..e16f4a83bc 100644
--- a/file.c
+++ b/file.c
@@ -2955,16 +2955,19 @@ rb_file_s_absolute_path(int argc, VALUE *argv)
static int
rmext(const char *p, int l1, const char *e)
{
- int l2;
+ int l0, 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;
e = p + l1;
do {
- if (e <= p) return 0;
+ if (e <= p + l0) return 0;
} while (*--e != c);
return e - p;
}