mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
transcode.c: empty encoding name
* transcode.c (rb_econv_set_replacement): target encoding name can be empty now. [ruby-core:69841] [Bug #11324] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b2a36083f8
commit
e0ec0c7dc4
3 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 3 12:25:19 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* transcode.c (rb_econv_set_replacement): target encoding name can
|
||||
be empty now. [ruby-core:69841] [Bug #11324]
|
||||
|
||||
Fri Jul 3 07:21:06 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* benchmark/bm_io_nonblock_noex.rb: new benchmark
|
||||
|
|
|
@ -2109,4 +2109,13 @@ class TestTranscode < Test::Unit::TestCase
|
|||
assert_equal([expected]*num, result, bug11277)
|
||||
end;
|
||||
end
|
||||
|
||||
def test_universal_newline
|
||||
bug11324 = '[ruby-core:69841] [Bug #11324]'
|
||||
usascii = Encoding::US_ASCII
|
||||
s = "A\nB\r\nC".force_encoding(usascii)
|
||||
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true), bug11324)
|
||||
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true, undef: :replace), bug11324)
|
||||
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true, undef: :replace, replace: ''), bug11324)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2199,7 +2199,7 @@ rb_econv_set_replacement(rb_econv_t *ec,
|
|||
|
||||
encname2 = rb_econv_encoding_to_insert_output(ec);
|
||||
|
||||
if (encoding_equal(encname, encname2)) {
|
||||
if (!*encname2 || encoding_equal(encname, encname2)) {
|
||||
str2 = xmalloc(len);
|
||||
MEMCPY(str2, str, unsigned char, len); /* xxx: str may be invalid */
|
||||
len2 = len;
|
||||
|
|
Loading…
Reference in a new issue