summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/file.c b/file.c
index c46377b933..170455ab0a 100644
--- a/file.c
+++ b/file.c
@@ -4711,13 +4711,26 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
while (*p) {
if (*p == '.' || istrailinggarbage(*p)) {
#if USE_NTFS
- const char *last = p++, *dot = last;
+ const char *first = 0, *last, *dot;
+ if (*p == '.') first = p;
+ last = p++;
+ dot = last;
while (istrailinggarbage(*p)) {
- if (*p == '.') dot = p;
+ if (*p == '.') {
+ dot = p;
+ if (!first) {
+ first = p;
+ }
+ }
p++;
}
if (!*p || isADS(*p)) {
- p = last;
+ if (first == dot && e == 0) {
+ e = first;
+ }
+ else {
+ p = last;
+ }
break;
}
if (*last == '.' || dot > last) e = dot;
@@ -4766,8 +4779,7 @@ ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
* File.extname("test.rb") #=> ".rb"
* File.extname("a/b/d/test.rb") #=> ".rb"
* File.extname(".a/b/d/test.rb") #=> ".rb"
- * File.extname("foo.") #=> "" on Windows
- * File.extname("foo.") #=> "." on non-Windows
+ * File.extname("foo.") #=> "."
* File.extname("test") #=> ""
* File.extname(".profile") #=> ""
* File.extname(".profile.sh") #=> ".sh"