Eliminate @comments

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-12-25 17:00:24 -08:00
parent 3f28af80d2
commit 84cc78c58e
3 changed files with 15 additions and 26 deletions

View File

@ -2330,7 +2330,7 @@ sub ensure_audit_blacklog_chain( $$$ ) {
sub ensure_audit_chain( $;$$ ) { sub ensure_audit_chain( $;$$ ) {
my ( $target, $action, $tgt ) = @_; my ( $target, $action, $tgt ) = @_;
push_comment( '' ); my $save_comment = push_comment;
my $ref = $filter_table->{$target}; my $ref = $filter_table->{$target};
@ -2353,7 +2353,7 @@ sub ensure_audit_chain( $;$$ ) {
} }
} }
pop_comment; pop_comment( $save_comment );
return $target; return $target;
} }

View File

@ -135,7 +135,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
process_comment process_comment
no_comment no_comment
macro_comment macro_comment
clear_comment
push_comment push_comment
pop_comment pop_comment
dump_mark_layout dump_mark_layout
@ -495,7 +494,6 @@ our $first_entry; # Message to output or function to call on first no
our $file_format; # Format of configuration file. our $file_format; # Format of configuration file.
our $max_format; # Max format value our $max_format; # Max format value
our $comment; # Current COMMENT our $comment; # Current COMMENT
our @comments;
our $comments_allowed; our $comments_allowed;
our $nocomment; our $nocomment;
our $warningcount; our $warningcount;
@ -623,7 +621,6 @@ sub initialize( $;$$) {
# Contents of last COMMENT line. # Contents of last COMMENT line.
# #
$comment = ''; $comment = '';
@comments = ();
$warningcount = 0; $warningcount = 0;
$warningcount1 = 0; $warningcount1 = 0;
$warningcount2 = 0; $warningcount2 = 0;
@ -1962,26 +1959,20 @@ sub no_comment() {
# #
sub clear_comment() { sub clear_comment() {
$comment = ''; $comment = '';
@comments = (); $nocomment = 0;
} }
# #
# Push and Pop comment stack # Push and Pop comment stack
# #
sub push_comment( $ ) { sub push_comment() {
push @comments, $comment; my $return = $comment;
$comment = shift; $comment = '';
$return;
} }
sub pop_comment() { sub pop_comment( $ ) {
$comment = pop @comments; $comment = $_[0];
}
#
# Set comment
#
sub set_comment( $ ) {
$comment = shift;
} }
# #
@ -2073,7 +2064,6 @@ sub pop_include() {
$currentfile = undef; $currentfile = undef;
$currentlinenumber = 'EOF'; $currentlinenumber = 'EOF';
clear_comment; clear_comment;
$nocomment = 0;
} }
} }

View File

@ -842,8 +842,7 @@ sub finish_chain_section ($$) {
my $chain = $chainref->{name}; my $chain = $chainref->{name};
my $related_level = $config{RELATED_LOG_LEVEL}; my $related_level = $config{RELATED_LOG_LEVEL};
my $related_target = $globals{RELATED_TARGET}; my $related_target = $globals{RELATED_TARGET};
my $save_comment = push_comment;
push_comment(''); #These rules should not have comments
if ( $state =~ /RELATED/ && ( $related_level || $related_target ne 'ACCEPT' ) ) { if ( $state =~ /RELATED/ && ( $related_level || $related_target ne 'ACCEPT' ) ) {
@ -890,7 +889,7 @@ sub finish_chain_section ($$) {
$chainref->{new} = @{$chainref->{rules}}; $chainref->{new} = @{$chainref->{rules}};
} }
pop_comment; pop_comment( $save_comment );
} }
# #
@ -1561,7 +1560,7 @@ sub process_action($) {
$active{$action}++; $active{$action}++;
push @actionstack, $wholeaction; push @actionstack, $wholeaction;
push_comment( '' ); my $save_comment = push_comment;
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
@ -1603,7 +1602,7 @@ sub process_action($) {
0 ); 0 );
} }
pop_comment; pop_comment( $save_comment );
$active{$action}--; $active{$action}--;
pop @actionstack; pop @actionstack;
@ -1769,7 +1768,7 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
push_open $inlinefile, 2, 1; push_open $inlinefile, 2, 1;
push_comment(''); my $save_comment = push_comment;
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $mtarget, my ( $mtarget,
@ -1855,7 +1854,7 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) {
progress_message " Rule \"$currentline\" $done"; progress_message " Rule \"$currentline\" $done";
} }
pop_comment; pop_comment( $save_comment );
pop_open; pop_open;