mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* string.c (rb_str_inspect): increment by rb_enc_mbminlen(enc) for
broken byte sequence. [ruby-core:27748] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4b8e14c978
commit
83d9e9f42e
2 changed files with 10 additions and 4 deletions
11
string.c
11
string.c
|
@ -4099,9 +4099,14 @@ rb_str_inspect(VALUE str)
|
|||
n = rb_enc_precise_mbclen(p, pend, enc);
|
||||
if (!MBCLEN_CHARFOUND_P(n)) {
|
||||
if (p > prev) str_buf_cat(result, prev, p - prev);
|
||||
snprintf(buf, CHAR_ESC_LEN, "\\x%02X", *p & 0377);
|
||||
str_buf_cat(result, buf, strlen(buf));
|
||||
prev = ++p;
|
||||
n = rb_enc_mbminlen(enc);
|
||||
if (pend < p + n)
|
||||
n = pend - p;
|
||||
while (n--) {
|
||||
snprintf(buf, CHAR_ESC_LEN, "\\x%02X", *p & 0377);
|
||||
str_buf_cat(result, buf, strlen(buf));
|
||||
prev = ++p;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
n = MBCLEN_CHARFOUND_LEN(n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue