Permalink
Browse files

Fix off-by-one in grapheme iterator.

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...
1 parent c3762be commit c01472d7c539a8eea55b8443dc99e494437b7fdc @jnthn jnthn committed Jul 21, 2016
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/strings/iter.h
View
@@ -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");

0 comments on commit c01472d

Please sign in to comment.