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