diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 04:20:40 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-17 04:20:40 +0000 |
commit | 897b2177c19cf2f0dc956b9b868191f5f4d29112 (patch) | |
tree | 29839ba1e56f4fbffb73c919138f133be3a8b01b /ext | |
parent | 6d886eb2557fe846957da483ab08f7c964e95679 (diff) |
merge revision(s) 47716: [Backport #10285]
* ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO
should be writable any encoding strings, without conversion.
[ruby-core:65240] [Bug #10285]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@47988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 2e7c367276..4dc279cd12 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1171,12 +1171,13 @@ strio_write(VALUE self, VALUE str) struct StringIO *ptr = writable(self); long len, olen; rb_encoding *enc, *enc2; + rb_encoding *const ascii8bit = rb_ascii8bit_encoding(); if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); enc = rb_enc_get(ptr->string); enc2 = rb_enc_get(str); - if (enc != enc2 && enc != rb_ascii8bit_encoding()) { + if (enc != enc2 && enc != ascii8bit) { str = rb_str_conv_enc(str, enc2, enc); } len = RSTRING_LEN(str); @@ -1187,7 +1188,7 @@ strio_write(VALUE self, VALUE str) ptr->pos = olen; } if (ptr->pos == olen) { - if (enc2 == rb_ascii8bit_encoding()) { + if (enc == ascii8bit || enc2 == ascii8bit) { rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc); OBJ_INFECT(ptr->string, str); } |