From 08e698d4df6f7147708e025ca25f48cb6b1c333d Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 27 Jun 2014 08:58:05 +0000 Subject: merge revision(s) 46243,46244: [Backport #9882] [Backport #9883] * string.c (rb_str_substr): need to reset code range for shared string too, not only copied string. [ruby-core:62842] [Bug #9882] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ string.c | 2 +- test/ruby/test_string.rb | 5 +++++ version.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc7c3e32fa..fe0e6795ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jun 27 17:57:16 2014 Nobuyoshi Nakada + + * string.c (rb_str_substr): need to reset code range for shared + string too, not only copied string. + [ruby-core:62842] [Bug #9882] + Fri Jun 27 17:54:09 2014 Rei Odaira * signal.c (ruby_signal): should return either `old.sa_sigaction` diff --git a/string.c b/string.c index 357de5aacc..a45d7ad471 100644 --- a/string.c +++ b/string.c @@ -1786,10 +1786,10 @@ rb_str_substr(VALUE str, long beg, long len) } else { str2 = rb_str_new5(str, p, len); - rb_enc_cr_str_copy_for_substr(str2, str); OBJ_INFECT(str2, str); RB_GC_GUARD(str); } + rb_enc_cr_str_copy_for_substr(str2, str); return str2; } diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 1caca75247..ed888a1e42 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1190,6 +1190,11 @@ class TestString < Test::Unit::TestCase assert_equal(S("Bar"), S("FooBar").slice(S("Bar"))) assert_nil(S("FooBar").slice(S("xyzzy"))) assert_nil(S("FooBar").slice(S("plugh"))) + + bug9882 = '[ruby-core:62842] [Bug #9882]' + substr = S("\u{30c6 30b9 30c8 2019}#{bug9882}").slice(4..-1) + assert_equal(S(bug9882).hash, substr.hash, bug9882) + assert_predicate(substr, :ascii_only?, bug9882) end def test_slice! diff --git a/version.h b/version.h index e2968f25c2..853f88a7c1 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-06-27" -#define RUBY_PATCHLEVEL 508 +#define RUBY_PATCHLEVEL 509 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 -- cgit v1.2.3