summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorNAKAMURA Usaku <usa@ruby-lang.org>2019-12-23 11:54:25 +0900
committerNAKAMURA Usaku <usa@ruby-lang.org>2019-12-23 11:54:25 +0900
commit204dc3f39f12b4e2640555306bd1dd4530344277 (patch)
tree1532d86db7caeb9b6f5b74b3602918ceb04e11a4 /file.c
parent048f797bf019cdf303d70494fba63d4a4e606462 (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.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"