summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_string.rb5
-rw-r--r--version.h2
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 <nobu@ruby-lang.org>
+
+ * 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 <Rei.Odaira@gmail.com>
* 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