ruby-changes:21942
From: naruse <ko1@a...>
Date: Fri, 9 Dec 2011 15:01:57 +0900 (JST)
Subject: [ruby-changes:21942] naruse:r33991 (trunk): * file.c (file_path_convert): don't convert it when the path string is
naruse 2011-12-09 15:01:41 +0900 (Fri, 09 Dec 2011) New Revision: 33991 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33991 Log: * file.c (file_path_convert): don't convert it when the path string is ascii only. [ruby-core:41556] [Bug #5733] tests are contributed by nobu. Modified files: trunk/ChangeLog trunk/file.c trunk/test/ruby/test_econv.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 33990) +++ ChangeLog (revision 33991) @@ -1,3 +1,9 @@ +Fri Dec 9 14:28:40 2011 NARUSE, Yui <naruse@r...> + + * file.c (file_path_convert): don't convert it when the path string is + ascii only. [ruby-core:41556] [Bug #5733] + tests are contributed by nobu. + Fri Dec 9 08:00:15 2011 Luis Lavena <luislavena@g...> * include/ruby/win32.h: undef stat to silence mingw-w64 stat Index: test/ruby/test_econv.rb =================================================================== --- test/ruby/test_econv.rb (revision 33990) +++ test/ruby/test_econv.rb (revision 33991) @@ -1,4 +1,5 @@ require 'test/unit' +require 'envutil' class TestEncodingConverter < Test::Unit::TestCase def check_ec(edst, esrc, eres, dst, src, ec, off, len, opts=nil) @@ -908,4 +909,23 @@ ec2 = Encoding::Converter.new("", "", newline: :universal) assert_equal(ec1, ec2) end + + def test_default_external + cmd = <<EOS + Encoding.default_external = ext = ARGV[0] + Encoding.default_internal = int ='utf-8' + begin + Encoding::Converter.new(ext, int) + ensure + Marshal.dump($!, STDOUT) + STDOUT.flush + end +EOS + Encoding.list.grep(->(enc) {/^ISO-8859-\d(?:[0-5])?\z/i =~ enc.name}) do |enc| + error = IO.popen([EnvUtil.rubybin, "-e", cmd, enc.name]) do |child| + Marshal.load(child) + end + assert_nil(error) + end + end end Index: file.c =================================================================== --- file.c (revision 33990) +++ file.c (revision 33991) @@ -136,8 +136,10 @@ if (rb_default_internal_encoding() != NULL && rb_usascii_encoding() != fname_encoding && rb_ascii8bit_encoding() != fname_encoding - && (fs_encoding = rb_filesystem_encoding()) != fname_encoding) { + && (fs_encoding = rb_filesystem_encoding()) != fname_encoding + && !rb_enc_str_asciionly_p(name)) { /* Don't call rb_filesystem_encoding() before US-ASCII and ASCII-8BIT */ + /* fs_encoding should be ascii compatible */ name = rb_str_conv_enc(name, fname_encoding, fs_encoding); } #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/