summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-17 14:42:38 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-17 18:51:51 +0900
commite169ad93f44e1944ecf7bb65133fd34e8b868ea8 (patch)
tree82c3badab1865e5036dd054dcb15b7fdc3f7c61e /file.c
parent2a261909cc6d0767d584c0555a1c6594aacf567a (diff)
Fixed File.extname at a name ending with a dot
File.extname now returns a dot string at a name ending with a dot. [Bug #15267]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2565
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/file.c b/file.c
index e333c868a9c..d10aeaa3e09 100644
--- a/file.c
+++ b/file.c
@@ -4792,7 +4792,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.") #=> ""
+ * File.extname("foo.") #=> "."
* File.extname("test") #=> ""
* File.extname(".profile") #=> ""
* File.extname(".profile.sh") #=> ".sh"
@@ -4810,7 +4810,7 @@ rb_file_s_extname(VALUE klass, VALUE fname)
name = StringValueCStr(fname);
len = RSTRING_LEN(fname);
e = ruby_enc_find_extname(name, &len, rb_enc_get(fname));
- if (len <= 1)
+ if (len < 1)
return rb_str_new(0, 0);
extname = rb_str_subseq(fname, e - name, len); /* keep the dot, too! */
OBJ_INFECT(extname, fname);