Skip to content

Commit 4bf7894

Browse files
committed
merge revision(s) 51116: [Backport ruby#11324]
* transcode.c (rb_econv_set_replacement): target encoding name can be empty now. [ruby-core:69841] [Bug ruby#11324] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 170f64d commit 4bf7894

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Mon Aug 17 17:54:33 2015 Nobuyoshi Nakada <[email protected]>
2+
3+
* transcode.c (rb_econv_set_replacement): target encoding name can
4+
be empty now. [ruby-core:69841] [Bug #11324]
5+
16
Mon Aug 17 17:52:11 2015 Nobuyoshi Nakada <[email protected]>
27

38
* hash.c (rb_any_hash): fix Float hash. rb_dbl_hash() returns a

test/ruby/test_transcode.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,4 +2109,13 @@ def test_loading_race
21092109
assert_equal([expected]*num, result, bug11277)
21102110
end;
21112111
end
2112+
2113+
def test_universal_newline
2114+
bug11324 = '[ruby-core:69841] [Bug #11324]'
2115+
usascii = Encoding::US_ASCII
2116+
s = "A\nB\r\nC".force_encoding(usascii)
2117+
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true), bug11324)
2118+
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true, undef: :replace), bug11324)
2119+
assert_equal("A\nB\nC", s.encode(usascii, universal_newline: true, undef: :replace, replace: ''), bug11324)
2120+
end
21122121
end

transcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,7 @@ rb_econv_set_replacement(rb_econv_t *ec,
22012201

22022202
encname2 = rb_econv_encoding_to_insert_output(ec);
22032203

2204-
if (encoding_equal(encname, encname2)) {
2204+
if (!*encname2 || encoding_equal(encname, encname2)) {
22052205
str2 = xmalloc(len);
22062206
MEMCPY(str2, str, unsigned char, len); /* xxx: str may be invalid */
22072207
len2 = len;

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.7"
22
#define RUBY_RELEASE_DATE "2015-08-17"
3-
#define RUBY_PATCHLEVEL 396
3+
#define RUBY_PATCHLEVEL 397
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)