forked from extern/shorewall_code
Replace the complex rule deletion loops with C-stype for loops.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
9dc8267888
commit
7a831107c7
@ -601,29 +601,13 @@ sub purge_jump ( $$ ) {
|
||||
my ( $fromref, $toref ) = @_;
|
||||
my $to = $toref->{name};
|
||||
my $last = 0;
|
||||
#
|
||||
# splice() of an array being iterated over causes elements to be skipped so
|
||||
# we need to restart the scan after each deletion.
|
||||
#
|
||||
my $progress = 1;
|
||||
my $rule;
|
||||
|
||||
while ( $progress ) {
|
||||
my $rule = 0;
|
||||
|
||||
$progress = 0;
|
||||
|
||||
for ( @{$fromref->{rules}} ) {
|
||||
$rule++, next if $last-- > 0;
|
||||
|
||||
if ( / -[gj] ${to}\b/ ) {
|
||||
for ( $rule = 0; $rule < $#{$fromref->{rules}}; $rule++ ) {
|
||||
if ( $fromref->{rules}[$rule] =~ / -[gj] ${to}\b/ ) {
|
||||
trace( $fromref, 'D', $rule + 1, $_ ) if $debug;
|
||||
splice( @{$fromref->{rules}}, $rule, 1 );
|
||||
$progress = 1;
|
||||
$last = $rule;
|
||||
last;
|
||||
}
|
||||
|
||||
$rule++;
|
||||
$rule--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1433,33 +1417,15 @@ sub delete_references( $ ) {
|
||||
my $chainref = shift;
|
||||
my $table = $chainref->{table};
|
||||
my $count = 0;
|
||||
my $last = 0;
|
||||
my $rule;
|
||||
|
||||
for my $fromref ( map $chain_table{$table}{$_} , keys %{$chainref->{references}} ) {
|
||||
#
|
||||
# splice() of an array being iterated over causes elements to be skipped so
|
||||
# we need to restart the scan after each deletion.
|
||||
#
|
||||
my $progress = 1;
|
||||
|
||||
while ( $progress ) {
|
||||
my $rule = 0;
|
||||
|
||||
$progress = 0;
|
||||
|
||||
for ( @{$fromref->{rules}} ) {
|
||||
$rule++, next if $last-- > 0;
|
||||
|
||||
if ( / -[jg] $chainref->{name}$/ ) {
|
||||
for ( $rule = 0; $rule <= $#{$fromref->{rules}}; $rule++ ) {
|
||||
if ( $fromref->{rules}[$rule] =~ / -[jg] $chainref->{name}$/ ) {
|
||||
trace( $fromref, 'D', $rule + 1, $_ ) if $debug;
|
||||
splice( @{$fromref->{rules}}, $rule, 1 );
|
||||
$count++;
|
||||
$progress = 1;
|
||||
$last = $rule;
|
||||
last;
|
||||
}
|
||||
|
||||
$rule++;
|
||||
$rule--;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user