aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-09 06:01:41 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-09 06:01:41 +0000
commit8e411664ab7f565ec30718529202e8013e8a3076 (patch)
tree2d4c0d65fc4333def7687154753dd051cc0a29f1
parent11d85dc1ec5775855cfd4986bd54410389fd1fd1 (diff)
downloadruby-8e411664ab7f565ec30718529202e8013e8a3076.tar.gz
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--file.c4
-rw-r--r--test/ruby/test_econv.rb20
3 files changed, 29 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 825099718a..adb81d0d8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Dec 9 14:28:40 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@gmail.com>
* include/ruby/win32.h: undef stat to silence mingw-w64 stat
diff --git a/file.c b/file.c
index 9a9f5fcb90..fb62c51d7a 100644
--- a/file.c
+++ b/file.c
@@ -136,8 +136,10 @@ file_path_convert(VALUE name)
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
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 080d027c4a..f667d733a0 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -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 @@ class TestEncodingConverter < Test::Unit::TestCase
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