diff options
author | NAKAMURA Usaku <usa@ruby-lang.org> | 2019-12-22 02:36:55 +0900 |
---|---|---|
committer | NAKAMURA Usaku <usa@ruby-lang.org> | 2019-12-22 02:42:09 +0900 |
commit | 61aff0cd189e67fa6f2565639ad0128fa33b88fc (patch) | |
tree | c1aaf72ca72f4f0e0f98655aef940299b1091ddc /file.c | |
parent | 29ea228efc5af08a0e91fafe155617f20e22976b (diff) |
Should return "." for File.extname("file.") also on Windows
But not changes another cases, such as "file.rb."
[Bug #15267]
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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" |