summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-17 16:10:51 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-19 03:05:53 +0900
commit99116da7f05633697177c09cf4de5080028d77f8 (patch)
treea70467efae729216f8af33d7a3eb47d980a64710 /sprintf.c
parentf34280ec6b684eeb21ef3336c7002e1a83dcfd2c (diff)
downloadruby-99116da7f05633697177c09cf4de5080028d77f8.tar.gz
Scan the code range of the last added portion
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sprintf.c b/sprintf.c
index 04cead7731..b16ab3f581 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -927,6 +927,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
flags = FNONE;
}
+ if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {
+ scanned += rb_str_coderange_scan_restartable(buf+scanned, buf+blen, enc, &coderange);
+ ENC_CODERANGE_SET(result, coderange);
+ }
sprint_exit:
rb_str_tmp_frozen_release(orig, fmt);
/* XXX - We cannot validate the number of arguments if (digit)$ style used.
@@ -937,8 +941,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
if (RTEST(ruby_verbose)) rb_warn("%s", mesg);
}
rb_str_resize(result, blen);
- // rb_str_format mutates the string without updating coderange
- ENC_CODERANGE_CLEAR(result);
return result;
}