Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix off-by-one error spotted by ShimmerFairy++
  • Loading branch information
lizmat committed Oct 30, 2015
1 parent 2856ed3 commit 131af2c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/Str.pm
Expand Up @@ -855,7 +855,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
}
method !last-part() is raw {
my str $string = nqp::substr($!string,$!pos);
$!pos = $!chars;
$!pos = $!chars + 1;
$!todo = 0;
nqp::p6box_s($string)
}
Expand All @@ -874,14 +874,14 @@ my class Str does Stringy { # declared in BOOTSTRAP
$!todo = $!todo - 1;
my int $found = nqp::index($!string,$!match,$!pos);
if $found < 0 {
$!pos < $!chars ?? self!last-part !! IterationEnd
$!pos <= $!chars ?? self!last-part !! IterationEnd
}
else {
$!do-match = $!all;
self!next-part($found);
}
}
elsif $!pos < $!chars {
elsif $!pos <= $!chars {
self!last-part
}
else {
Expand Down Expand Up @@ -911,7 +911,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
!! $target.push(self!next-part($found));
}
}
$target.push(self!last-part) if $!pos < $!chars;
$target.push(self!last-part) if $!pos <= $!chars;
IterationEnd
}
method sink-all() { IterationEnd }
Expand Down

0 comments on commit 131af2c

Please sign in to comment.