Skip to content

Commit

Permalink
Fix off-by-one in grapheme iterator.
Browse files Browse the repository at this point in the history
It failed to consider that we are already reading the next repetition
by the next time we read another character, and so ended up with a
repetition appearing to occur one time too many if we used move_to.
  • Loading branch information
jnthn committed Jul 21, 2016
1 parent c3762be commit c01472d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/strings/iter.h
Expand Up @@ -93,8 +93,10 @@ MVM_STATIC_INLINE void MVM_string_gi_move_to(MVMThreadContext *tc, MVMGraphemeIt
remaining_reps = gi->repetitions;
gi->repetitions -= remaining_reps;
remaining -= remaining_reps * rep_graphs;
if (gi->repetitions)
if (gi->repetitions) {
gi->pos = gi->start;
gi->repetitions--; /* Next read will be reading *this* repetition. */
}
}
else {
MVM_exception_throw_adhoc(tc, "Iteration past end of grapheme iterator");
Expand Down

0 comments on commit c01472d

Please sign in to comment.