Project

General

Profile

Actions

Bug #3175

closed

extname and basename fail in "foo//bar.rb" style paths.

Added by many (rico gloeckner) about 14 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Backport:
[ruby-core:29627]

Description

=begin
as reported in #ruby@freenode:

12:37 < jetienne> irb(main):002:0> File.extname('/tmp//bla.rb')
12:37 < jetienne> => ""

This Bug is present in 1.8 and 1.9.

The problem seems to nail down in that rb_file_s_basename calls rb_path_last_separator, which seem to return "/bla.rb" instead of "bla.rb", since *path isnt saved into *tmp (actually the pointer, not the content) when PATH_SEPARATORS are skipped.

rb_file_s_extname itself returns with 0 immediately, when the first char of the returned string is "/"; this makes the behaviour look somewhat intentional, while in unix its (imho) clearly a bug.

Incase the specific behaviour isnt changed, i think API docs should include this as example, so people know that it is intentional.

Thanks,
-many
=end

Actions

Also available in: Atom PDF

Like0
Like0