diff options
author | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-06 07:21:17 +0000 |
---|---|---|
committer | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-06 07:21:17 +0000 |
commit | 06a3a10acf1951429e3e2e8d18fd1a283fa5b132 (patch) | |
tree | 2c390023a421a009292f434c9c424b36889d6cad /string.c | |
parent | 2c8cec96cc1cc1c2cdb8487e3c4e31e189fd3784 (diff) | |
download | ruby-06a3a10acf1951429e3e2e8d18fd1a283fa5b132.tar.gz |
string.c: preserve coderange in String#setbyte
Fix a wrong jump so replacing a byte in an ASCII-only string with an
ASCII character won't clear the coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-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); |