diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-24 23:33:43 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-26 15:23:03 +0900 |
commit | 47c5f0cc3285fd4d6e95cad0f72c8491a101c275 (patch) | |
tree | ddec9b40f2faf1eea1727ded6918e9be77d2db70 | |
parent | d9e4b1c9bb179466743d941dc45de5993a027599 (diff) | |
download | ruby-47c5f0cc3285fd4d6e95cad0f72c8491a101c275.tar.gz |
string.c: preserve coderange in #setbyte
Do not clear the coderange when 1) the string is heap-allocated, 2) the
current coderange is 7bit, 3) the new byte is an ASCII character.
-rw-r--r-- | string.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -5279,13 +5279,13 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value) enc = STR_ENC_GET(str); head = RSTRING_PTR(str); ptr = &head[pos]; - if (!STR_EMBEDDABLE_P(len, rb_enc_mbminlen(enc))) { + if (!STR_EMBED_P(str)) { cr = ENC_CODERANGE(str); switch (cr) { case ENC_CODERANGE_7BIT: left = ptr; *ptr = byte; - if (ISASCII(byte)) break; + if (ISASCII(byte)) goto end; nlen = rb_enc_precise_mbclen(left, head+len, enc); if (!MBCLEN_CHARFOUND_P(nlen)) ENC_CODERANGE_SET(str, ENC_CODERANGE_BROKEN); |