Backport #6681

migw32 で utf-8 のスクリプトで「版」で終わるディレクトリの File.basename

Added by Tatsuo Akiyama almost 2 years ago. Updated over 1 year ago.

[ruby-dev:45887]
Status:Closed
Priority:Normal
Assignee:-

Description

=begin

migw32 で utf-8 のスクリプトで「版」で終わるディレクトリの File.basename の結果がおかしいです。

スクリプト test1.rb
# -- coding: utf-8 --
puts File.basename("1版/memo1.txt")

スクリプト test2.rb
# -- coding: Shift_JIS --
puts File.basename("1版/memo1.txt")

どちらも「memo1.txt」が表示されることを期待しましたが、test1.rb だと「1版/memo1.txt」が表示されます。

ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

ruby test1.rb
1版/memo1.txt

ruby test2.rb
memo1.txt

rubyinstaller.org 配布のバイナリを利用しています。

=end


Related issues

Duplicates ruby-trunk - Bug #5919: File singleton methods (expand_path, realpath, dirname, b... Closed 01/21/2012

Associated revisions

Revision 37330
Added by Usaku NAKAMURA over 1 year ago

merge revision(s) 32826,34732: [Backport #6681]

  • file.c (rbencpathnext, rbencpathskipprefix)
    (rb
    encpathlastseparator, rbencpathend)
    (rubyencfindbasename, rubyencfindextname): encoding-aware
    path handling functions.

  • file.c (rbhomedir, fileexpandpath, rbrealpathinternal)
    (rbfilesbasename, rbfiledirname, rbfilesextname)
    (rbfilejoin): should respect the encodings of arguments than
    file system encoding. [Bug #5919]

  • dir.c (checkdirname, rubyglob0): ditto.

  • ext/pathname/pathname.c (pathsubext): ditto.

  • util.c, include/ruby/util.h (rubyaddsuffix): remove the function.
    [Bug #5153]

  • io.c (argfnextargv): remove the call of above function.

  • ext/-test-/addsuffix, test/-ext-/testaddsuffix.rb: remove the test
    extension module because this is only for testsing ruby
    add_suffix().

  • LEGAL: remove the mention about a part of util.c, because now we
    removed the part.

  • io.c (argfnextargv): now the new filename is not guranteed to
    use, so should check the return value of rename(2).

  • test/ruby/testargf.rb (TestArgf#testinplacerenameimpossible):
    now we expect same result with other platforms on nosaferename
    platforms (=Windows).

Revision 37333
Added by Usaku NAKAMURA over 1 year ago

merge revision(s) 34374: [Backport #6681]

* file.c (rmext): no extension to strip if empty string.

History

#1 Updated by Yui NARUSE almost 2 years ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport93

#2 Updated by Yui NARUSE almost 2 years ago

p245 でバックポートしました

#3 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Open to Closed

#4 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Closed to Feedback

I can't merge r34372 because it introduces incompatibility

#5 Updated by Usaku NAKAMURA over 1 year ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37330.
Tatsuo, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 32826,34732: [Backport #6681]

  • file.c (rbencpathnext, rbencpathskipprefix)
    (rb
    encpathlastseparator, rbencpathend)
    (rubyencfindbasename, rubyencfindextname): encoding-aware
    path handling functions.

  • file.c (rbhomedir, fileexpandpath, rbrealpathinternal)
    (rbfilesbasename, rbfiledirname, rbfilesextname)
    (rbfilejoin): should respect the encodings of arguments than
    file system encoding. [Bug #5919]

  • dir.c (checkdirname, rubyglob0): ditto.

  • ext/pathname/pathname.c (pathsubext): ditto.

  • util.c, include/ruby/util.h (rubyaddsuffix): remove the function.
    [Bug #5153]

  • io.c (argfnextargv): remove the call of above function.

  • ext/-test-/addsuffix, test/-ext-/testaddsuffix.rb: remove the test
    extension module because this is only for testsing ruby
    add_suffix().

  • LEGAL: remove the mention about a part of util.c, because now we
    removed the part.

  • io.c (argfnextargv): now the new filename is not guranteed to
    use, so should check the return value of rename(2).

  • test/ruby/testargf.rb (TestArgf#testinplacerenameimpossible):
    now we expect same result with other platforms on nosaferename
    platforms (=Windows).

Also available in: Atom PDF