Eliminate a couple of local variables

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7035 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-08-03 14:26:19 +00:00
parent d480e79c9c
commit ddbbb6c0b6

View File

@ -220,8 +220,6 @@ use constant { NULL_STATE => 0 , # Generating neither shell commands nor iptab
CMD_STATE => 2 }; # Generating shell commands. CMD_STATE => 2 }; # Generating shell commands.
our $state; our $state;
our $emitted_comment;
our $emitted_test;
# #
# Initialize globals -- we take this novel approach to globals initialization to allow # Initialize globals -- we take this novel approach to globals initialization to allow
@ -309,14 +307,6 @@ sub initialize() {
%interfaceaddrs = (); %interfaceaddrs = ();
%interfacenets = (); %interfacenets = ();
%interfacebcasts = (); %interfacebcasts = ();
#
# When true, we've emitted a comment about global variable initialization
#
$emitted_comment = 0;
#
# When true, we've emitted a test of $COMMAND != restore
#
$emitted_test = 0;
} }
INIT { INIT {
@ -1848,22 +1838,18 @@ sub insertnatjump( $$$$ ) {
} }
} }
sub emit_comment() { sub emit_comment( $ ) {
unless ( $emitted_comment ) {
emit ( '#', emit ( '#',
'# Establish the values of shell variables used in the following function calls', '# Establish the values of shell variables used in the following function calls',
'#' ); '#' );
$emitted_comment = 1; ${$_[0]} = 1;
}
} }
sub emit_test() { sub emit_test( $ ) {
unless ( $emitted_test ) {
emit ( 'if [ "$COMMAND" != restore ]; then' , emit ( 'if [ "$COMMAND" != restore ]; then' ,
'' ); '' );
push_indent; push_indent;
$emitted_test = 1; ${$_[0]} = 1;
}
} }
# #
@ -1871,26 +1857,28 @@ sub emit_test() {
# #
sub set_global_variables() { sub set_global_variables() {
my ( $emitted_comment, $emitted_test ) = (0, 0);
for ( values %interfaceaddr ) { for ( values %interfaceaddr ) {
emit_comment unless $emitted_comment; emit_comment( \$emitted_comment ) unless $emitted_comment;
emit $_; emit $_;
} }
for ( values %interfaceaddrs ) { for ( values %interfaceaddrs ) {
emit_comment unless $emitted_comment; emit_comment( \$emitted_comment ) unless $emitted_comment;
emit_test unless $emitted_test; emit_test( \$emitted_test ) unless $emitted_test;
emit $_; emit $_;
} }
for ( values %interfacenets ) { for ( values %interfacenets ) {
emit_comment unless $emitted_comment; emit_comment( \$emitted_comment ) unless $emitted_comment;
emit_test unless $emitted_test; emit_test( \$emitted_test ) unless $emitted_test;
emit $_; emit $_;
} }
unless ( $capabilities{ADDRTYPE} ) { unless ( $capabilities{ADDRTYPE} ) {
emit_comment unless $emitted_comment; emit_comment( \$emitted_comment ) unless $emitted_comment;
emit_test unless $emitted_test; emit_test( \$emitted_test ) unless $emitted_test;
emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"'; emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"';
for ( values %interfacebcasts ) { for ( values %interfacebcasts ) {