mruby-string (chars2bytes): reduce the scope of local variables

This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-01-09 11:00:44 +09:00
parent f1d01a6107
commit f3ebef1172
+3 -3
View File
@@ -330,12 +330,12 @@ chars2bytes(mrb_value s, mrb_int off, mrb_int idx)
return idx;
}
else {
mrb_int i, b, n;
mrb_int b = 0;
const char *p = RSTRING_PTR(s) + off;
const char *e = RSTRING_END(s);
for (b=i=0; p<e && i<idx; i++) {
n = mrb_utf8len(p, e);
for (mrb_int i=0; p<e && i<idx; i++) {
mrb_int n = mrb_utf8len(p, e);
b += n;
p += n;
}