diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 13:22:53 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 13:22:53 +0000 |
commit | d3418343048213457d0686b807404babc949e994 (patch) | |
tree | 593cc1dba359009738d4cf552a7b22ebc3aa52d8 | |
parent | 0d0636d22ce7bd4729d749ca36cf2cde5175d815 (diff) |
merges r29868 and r29872 from trunk into ruby_1_9_2.
--
* string.c (rb_str_inspect): append for each chars instead of bulk
copy if encoding conversion is needed. [ruby-core:33283]
--
* string.c (rb_str_inspect): fix for ascii-compatible external
encoding and different encoding string. [ruby-core:33283]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@30262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | string.c | 6 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 10 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 25 insertions, 3 deletions
@@ -1,3 +1,13 @@ +Mon Nov 22 21:30:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (rb_str_inspect): fix for ascii-compatible external + encoding and different encoding string. [ruby-core:33283] + +Mon Nov 22 18:33:30 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (rb_str_inspect): append for each chars instead of bulk + copy if encoding conversion is needed. [ruby-core:33283] + Mon Nov 22 11:58:11 2010 NARUSE, Yui <naruse@ruby-lang.org> * string.c (rb_str_concat): set ENC_CODERANGE_VALID when the @@ -4195,8 +4195,10 @@ rb_str_inspect(VALUE str) (cc == '$' || cc == '@' || cc == '{')))) { if (p - n > prev) str_buf_cat(result, prev, p - n - prev); str_buf_cat2(result, "\\"); - prev = p - n; - continue; + if (asciicompat || enc == resenc) { + prev = p - n; + continue; + } } switch (c) { case '\n': cc = 'n'; break; diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index cea74c35e8..5c2bce15cc 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1886,10 +1886,20 @@ class TestString < Test::Unit::TestCase end def test_ascii_incomat_inspect + bug4081 = '[ruby-core:33283]' [Encoding::UTF_16LE, Encoding::UTF_16BE, Encoding::UTF_32LE, Encoding::UTF_32BE].each do |e| assert_equal('"abc"', "abc".encode(e).inspect) assert_equal('"\\u3042\\u3044\\u3046"', "\u3042\u3044\u3046".encode(e).inspect) + assert_equal('"ab\\"c"', "ab\"c".encode(e).inspect, bug4081) end + begin + ext = Encoding.default_external + Encoding.default_external = "us-ascii" + i = "abc\"\\".force_encoding("utf-8").inspect + ensure + Encoding.default_external = ext + end + assert_equal('"abc\\"\\\\"', i, bug4081) end end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 102 +#define RUBY_PATCHLEVEL 103 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |