Skip to content

Commit

Permalink
mruby-string-utf8: str_subseq takes UTF-8 index, not byte index; ref #…
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 18, 2014
1 parent 280f9df commit b2422cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mrbgems/mruby-string-utf8/src/string.c
Expand Up @@ -636,7 +636,8 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)

while (ptr < eptr &&
(end = mrb_memsearch(sptr, slen, ptr, eptr - ptr)) >= 0) {
mrb_ary_push(mrb, result, str_subseq(mrb, str, ptr - temp, end));
// mrb_ary_push(mrb, result, str_subseq(mrb, str, ptr - temp, end));
mrb_ary_push(mrb, result, mrb_str_new(mrb, ptr, end));
mrb_gc_arena_restore(mrb, ai);
ptr += end + slen;
if (lim_p && lim <= ++i) break;
Expand All @@ -652,7 +653,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
tmp = mrb_str_new_lit(mrb, "");
}
else {
tmp = str_subseq(mrb, str, beg, RSTRING_LEN(str)-beg);
tmp = mrb_str_new(mrb, RSTRING_PTR(str)+beg, RSTRING_LEN(str)-beg);
}
mrb_ary_push(mrb, result, tmp);
}
Expand Down

0 comments on commit b2422cf

Please sign in to comment.