Project

General

Profile

Bug #11209 ยป 0001-Fix-String-when-subclassed.patch

yoongkang (Yoong Kang Lim), 06/04/2015 01:25 AM

View differences:

string.c
enc = rb_enc_check(str1, str2);
RSTRING_GETMEM(str1, ptr1, len1);
RSTRING_GETMEM(str2, ptr2, len2);
str3 = rb_str_new(0, len1+len2);
str3 = rb_str_new_with_class(str1, 0, len1+len2);
ptr3 = RSTRING_PTR(str3);
memcpy(ptr3, ptr1, len1);
memcpy(ptr3+len1, ptr2, len2);
test/ruby/test_string.rb
assert_equal((15..54).to_a.to_a.join, s3)
end
def test_str_plus_subclassed
foo = S2.new("foo")
bar = S2.new("bar")
baz = foo + bar
assert_equal(TestString::S2, baz.class)
end
def test_rb_str_new4
s = "a" * 100
s2 = s[10,90]
    (1-1/1)