1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
yugui 2010-12-20 13:22:53 +00:00
parent 0d0636d22c
commit d341834304
4 changed files with 25 additions and 3 deletions

View file

@ -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

View file

@ -4195,9 +4195,11 @@ rb_str_inspect(VALUE str)
(cc == '$' || cc == '@' || cc == '{')))) {
if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
str_buf_cat2(result, "\\");
if (asciicompat || enc == resenc) {
prev = p - n;
continue;
}
}
switch (c) {
case '\n': cc = 'n'; break;
case '\r': cc = 'r'; break;

View file

@ -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)
end
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

View file

@ -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