rb_str_resize(string,shorter)// clear ENC_CODERANGE in some caserb_str_resize(string,longer)// does not clear ENC_CODERANGE anymore
// rb_str_resize in string.cif(slen>len&&ENC_CODERANGE(str)!=ENC_CODERANGE_7BIT){ENC_CODERANGE_CLEAR(str);}
I think this change is based on an assumption that appending null bytes will not change flag ascii_only?.
strio_extend() will make the string longer if needed, and update the flags correctly for appending null bytes. Before memmove(), we need to rb_str_modify() because updated flags are not updated for memmove().
[ruby/stringio] Fix ascii_only? flag in strio_write
(https://github.com/ruby/stringio/pull/77)
Followup of #79
rb_str_resize()was changed by https://github.com/ruby/ruby/commit/b0b9f7201acab05c2a3ad92c3043a1f01df3e17f .I think this change is based on an assumption that appending null bytes
will not change flag
ascii_only?.strio_extend()will make the string longer if needed, and update theflags correctly for appending null bytes.
Before
memmove(), we need torb_str_modify()because updated flags are notupdated for
memmove().https://github.com/ruby/stringio/commit/b31a538576