mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
2c8cec96cc
commit
06a3a10acf
1 changed files with 2 additions and 2 deletions
4
string.c
4
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue