From 06a3a10acf1951429e3e2e8d18fd1a283fa5b132 Mon Sep 17 00:00:00 2001 From: rhe Date: Thu, 6 Jul 2017 07:21:17 +0000 Subject: 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 --- string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 22664febfd..2012a281d6 100644 --- a/string.c +++ b/string.c @@ -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); -- cgit v1.2.3