Project

General

Profile

Backport #6681

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

Added by taki (Tatsuo Akiyama) about 7 years ago. Updated almost 7 years ago.

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

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

Is duplicate of Ruby master - Bug #5919: File singleton methods (expand_path, realpath, dirname, basename, extname) should respect encodingsClosed01/21/2012Actions

Associated revisions

Revision 0e6dcc7a
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

  • file.c (rb_enc_path_next, rb_enc_path_skip_prefix)
    (rb_enc_path_last_separator, rb_enc_path_end)
    (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware
    path handling functions.

  • file.c (rb_home_dir, file_expand_path, rb_realpath_internal)
    (rb_file_s_basename, rb_file_dirname, rb_file_s_extname)
    (rb_file_join): should respect the encodings of arguments than
    file system encoding. [ruby-dev:45145] [Bug #5919]

  • dir.c (check_dirname, ruby_glob0): ditto.

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

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

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

  • ext/-test-/add_suffix, test/-ext-/test_add_suffix.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 (argf_next_argv): now the new filename is not guranteed to
    use, so should check the return value of rename(2).

  • test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible):
    now we expect same result with other platforms on no_safe_rename
    platforms (=Windows).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37330
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

  • file.c (rb_enc_path_next, rb_enc_path_skip_prefix)
    (rb_enc_path_last_separator, rb_enc_path_end)
    (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware
    path handling functions.

  • file.c (rb_home_dir, file_expand_path, rb_realpath_internal)
    (rb_file_s_basename, rb_file_dirname, rb_file_s_extname)
    (rb_file_join): should respect the encodings of arguments than
    file system encoding. [ruby-dev:45145] [Bug #5919]

  • dir.c (check_dirname, ruby_glob0): ditto.

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

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

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

  • ext/-test-/add_suffix, test/-ext-/test_add_suffix.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 (argf_next_argv): now the new filename is not guranteed to
    use, so should check the return value of rename(2).

  • test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible):
    now we expect same result with other platforms on no_safe_rename
    platforms (=Windows).

Revision 48e95864
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37333
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

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

History

#1

Updated by naruse (Yui NARUSE) about 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193

Updated by naruse (Yui NARUSE) about 7 years ago

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

Updated by naruse (Yui NARUSE) about 7 years ago

  • Status changed from Open to Closed

Updated by naruse (Yui NARUSE) about 7 years ago

  • Status changed from Closed to Feedback

I can't merge r34372 because it introduces incompatibility

#5

Updated by usa (Usaku NAKAMURA) almost 7 years 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 (rb_enc_path_next, rb_enc_path_skip_prefix)
    (rb_enc_path_last_separator, rb_enc_path_end)
    (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware
    path handling functions.

  • file.c (rb_home_dir, file_expand_path, rb_realpath_internal)
    (rb_file_s_basename, rb_file_dirname, rb_file_s_extname)
    (rb_file_join): should respect the encodings of arguments than
    file system encoding. [ruby-dev:45145] [Bug #5919]

  • dir.c (check_dirname, ruby_glob0): ditto.

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

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

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

  • ext/-test-/add_suffix, test/-ext-/test_add_suffix.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 (argf_next_argv): now the new filename is not guranteed to
    use, so should check the return value of rename(2).

  • test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible):
    now we expect same result with other platforms on no_safe_rename
    platforms (=Windows).

Also available in: Atom PDF