Bug #3175: extname and basename fail in "foo//bar.rb" style paths.
http://redmine.ruby-lang.org/issues/show/3175

Author: rico gloeckner
Status: Open, Priority: Normal
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

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


----------------------------------------
http://redmine.ruby-lang.org