diff options
author | NAKAMURA Usaku <usa@ruby-lang.org> | 2019-12-23 11:54:25 +0900 |
---|---|---|
committer | NAKAMURA Usaku <usa@ruby-lang.org> | 2019-12-23 11:54:25 +0900 |
commit | 204dc3f39f12b4e2640555306bd1dd4530344277 (patch) | |
tree | 1532d86db7caeb9b6f5b74b3602918ceb04e11a4 /file.c | |
parent | 048f797bf019cdf303d70494fba63d4a4e606462 (diff) |
Revert "Should return "." for File.extname("file.") also on Windows"
We want to introduce consistency and better compatibility with unixen,
but the Windows APIs doues not have consistency fundamentally and
we can not found any logical way...
This reverts commit 61aff0cd189e67fa6f2565639ad0128fa33b88fc.
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 22 |
1 files changed, 5 insertions, 17 deletions
@@ -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" |