From: Vincent Pit Date: Sun, 15 Aug 2010 16:28:54 +0000 (+0200) Subject: Don't undef the $rule in LT::Functor::Rule::insert X-Git-Tag: rt87282~37 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=bc1f84f569da48d9d070384eb1bcccac289931e5;p=perl%2Fmodules%2FLaTeX-TikZ.git Don't undef the $rule in LT::Functor::Rule::insert Otherwise, we're unable to test if the subsequent rules are to be removed. --- diff --git a/lib/LaTeX/TikZ/Functor/Rule.pm b/lib/LaTeX/TikZ/Functor/Rule.pm index 0f86be1..df5b553 100644 --- a/lib/LaTeX/TikZ/Functor/Rule.pm +++ b/lib/LaTeX/TikZ/Functor/Rule.pm @@ -144,16 +144,16 @@ sub insert { my $is_role = $rule->is_role; if ($replace) { - my @remove; + my (@remove, $replaced); for my $i (0 .. $#$list) { my $old_target = $list->[$i]->target; if ($rule->handles($old_target)) { - if (defined $rule) { - splice @$list, $i, 1, $rule; - $rule = undef; - } else { + if ($replaced) { push @remove, $i; + } else { + splice @$list, $i, 1, $rule; + $replaced = 1; } } } @@ -163,7 +163,7 @@ sub insert { splice @$list, $_ - $shift, 1; ++$shift; } - return 1 unless defined $rule; + return 1 if $replaced; } else { # Replace only an existent rule