Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some off-by-one and skip-empty issues
  • Loading branch information
lizmat committed Nov 7, 2015
1 parent f4266f2 commit 4b8937f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/Str.pm
Expand Up @@ -881,26 +881,26 @@ my class Str does Stringy { # declared in BOOTSTRAP
if $skip-empty {
nqp::splice($matches,$match-list,$i,
nqp::iseq_i(nqp::chars(nqp::atpos($matches,$i)),0))
while $i = $i - 1;
while nqp::isge_i($i = nqp::sub_i($i,1),0);
}
else {
nqp::splice($matches,$match-list,$i,0)
while $i = $i - 1;
while nqp::isge_i($i = nqp::sub_i($i,1),0);
}
}
}
elsif $skip-empty {
my int $i = nqp::elems($matches);
my $match-list := nqp::list;
while $i = $i - 1 {
while nqp::isge_i($i = nqp::sub_i($i,1),0) {
nqp::splice($matches,$match-list,$i,1)
if nqp::iseq_i(nqp::chars(nqp::atpos($matches,$i)),0);
}
}
}

# single chars need empty before/after
else {
# single chars need empty before/after, unless inhibited
elsif !$skip-empty {
nqp::unshift($matches,"");
nqp::push($matches,"");
}
Expand Down

0 comments on commit 4b8937f

Please sign in to comment.