diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-01-16 23:59:55 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-01-16 15:06:22 +0000 |
commit | 6283ae8d369bd2f8a022bb69bc5b742c58529dec (patch) | |
tree | f2ffec9c57672d3a678598fbd0f672ba72bf0bc5 /ext/stringio | |
parent | fef8ccff11a5f48eef9f11f61ff0baa165acfaff (diff) |
[ruby/stringio] Update the coderange after overwrite
Fix https://bugs.ruby-lang.org/issues/20185
https://github.com/ruby/stringio/commit/8230552a46
Diffstat (limited to 'ext/stringio')
-rw-r--r-- | ext/stringio/stringio.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 74e2b95c99..4eb1511787 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1464,8 +1464,14 @@ strio_write(VALUE self, VALUE str) } } else { + int cr0 = ENC_CODERANGE(ptr->string); + int cr = ENC_CODERANGE_UNKNOWN; + if (rb_enc_asciicompat(enc) && rb_enc_asciicompat(enc2)) { + cr = ENC_CODERANGE_AND(cr0, ENC_CODERANGE(str)); + } strio_extend(ptr, ptr->pos, len); memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len); + if (cr != cr0) ENC_CODERANGE_SET(ptr->string, cr); } RB_GC_GUARD(str); ptr->pos += len; |