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

* string.c (str_new_empty): should copy also the encoding as an

empty substring.  [ruby-dev:45441][Bug #6206]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-27 04:13:54 +00:00
parent 9052a8cd94
commit ab9c982cc0
3 changed files with 26 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 27 13:13:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_new_empty): should copy also the encoding as an
empty substring. [ruby-dev:45441][Bug #6206]
Mon Mar 26 23:43:04 2012 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (parse227, parse228, parse229): don't use $~.

View file

@ -726,6 +726,7 @@ static VALUE
str_new_empty(VALUE str)
{
VALUE v = rb_str_new5(str, 0, 0);
rb_enc_copy(v, str);
OBJ_INFECT(v, str);
return v;
}

View file

@ -1174,6 +1174,12 @@ class TestString < Test::Unit::TestCase
assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug")
bug6206 = '[ruby-dev:45441]'
Encoding.list.each do |enc|
next unless enc.ascii_compatible?
s = S("a:".force_encoding(enc))
assert_equal([enc]*2, s.split(":", 2).map(&:encoding), bug6206)
end
end
def test_squeeze
@ -1824,6 +1830,13 @@ class TestString < Test::Unit::TestCase
assert_raise(TypeError) { "hello".partition(1) }
def (hyphen = Object.new).to_str; "-"; end
assert_equal(%w(foo - bar), "foo-bar".partition(hyphen), '[ruby-core:23540]')
bug6206 = '[ruby-dev:45441]'
Encoding.list.each do |enc|
next unless enc.ascii_compatible?
s = S("a:".force_encoding(enc))
assert_equal([enc]*3, s.partition("|").map(&:encoding), bug6206)
end
end
def test_rpartition
@ -1832,6 +1845,13 @@ class TestString < Test::Unit::TestCase
assert_raise(TypeError) { "hello".rpartition(1) }
def (hyphen = Object.new).to_str; "-"; end
assert_equal(%w(foo - bar), "foo-bar".rpartition(hyphen), '[ruby-core:23540]')
bug6206 = '[ruby-dev:45441]'
Encoding.list.each do |enc|
next unless enc.ascii_compatible?
s = S("a:".force_encoding(enc))
assert_equal([enc]*3, s.rpartition("|").map(&:encoding), bug6206)
end
end
def test_setter