More rational naming convention for open stacks

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5829 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-04-03 19:06:23 +00:00
parent e6f78b92c9
commit 3140475d5b

View File

@ -217,11 +217,17 @@ my %capdesc = ( NAT_ENABLED => 'NAT',
COMMENTS => 'Comments', COMMENTS => 'Comments',
ADDRTYPE => 'Address Type Match', ADDRTYPE => 'Address Type Match',
); );
#
# Directories to search for configuration files
#
my @config_path; my @config_path;
# #
# Stash away file references here when we encounter INCLUDE # Stash away file references here when we encounter INCLUDE
# #
my @includestack;
#
# Allow nested opens
#
my @openstack; my @openstack;
my $currentfile; my $currentfile;
@ -324,7 +330,7 @@ sub close_file() {
if ( $currentfile ) { if ( $currentfile ) {
close $currentfile; close $currentfile;
my $arrayref = pop @openstack; my $arrayref = pop @includestack;
if ( $arrayref ) { if ( $arrayref ) {
( $currentfile, $currentfilename, $currentlinenumber ) = @$arrayref; ( $currentfile, $currentfilename, $currentlinenumber ) = @$arrayref;
@ -334,26 +340,21 @@ sub close_file() {
} }
} }
#
# Allow nested opens
#
my @pushstack;
sub push_open( $ ) { sub push_open( $ ) {
push @openstack, [ $currentfile, $currentfilename, $currentlinenumber ]; push @includestack, [ $currentfile, $currentfilename, $currentlinenumber ];
my @a = @openstack; my @a = @includestack;
push @pushstack, \@a; push @openstack, \@a;
@openstack = (); @includestack = ();
$currentfile = undef; $currentfile = undef;
open_file( $_[0] ); open_file( $_[0] );
} }
sub pop_open() { sub pop_open() {
@openstack = @{pop @pushstack}; @includestack = @{pop @openstack};
my $arrayref = pop @openstack; my $arrayref = pop @includestack;
if ( $arrayref ) { if ( $arrayref ) {
( $currentfile, $currentfilename, $currentlinenumber ) = @$arrayref; ( $currentfile, $currentfilename, $currentlinenumber ) = @$arrayref;
@ -403,6 +404,7 @@ sub read_a_line {
$line =~ s/^\s+//; # Remove Leading white space $line =~ s/^\s+//; # Remove Leading white space
$line =~ s/\s+$//; # Remove Trailing white space $line =~ s/\s+$//; # Remove Trailing white space
# #
# Expand Shell Variables using $ENV # Expand Shell Variables using $ENV
# #
@ -415,14 +417,14 @@ sub read_a_line {
fatal_error "Missing file name after 'INCLUDE'" unless @line > 1; fatal_error "Missing file name after 'INCLUDE'" unless @line > 1;
fatal_error "Invalid INCLUDE command: $line" if @line > 2; fatal_error "Invalid INCLUDE command: $line" if @line > 2;
fatal_error "INCLUDEs nested too deeply: $line" if @openstack >= 4; fatal_error "INCLUDEs nested too deeply: $line" if @includestack >= 4;
my $filename = find_file $line[1]; my $filename = find_file $line[1];
fatal_error "INCLUDE file $filename not found" unless ( -f $filename ); fatal_error "INCLUDE file $filename not found" unless ( -f $filename );
if ( -s _ ) { if ( -s _ ) {
push @openstack, [ $currentfile, $currentfilename, $currentlinenumber ]; push @includestack, [ $currentfile, $currentfilename, $currentlinenumber ];
$currentfile = undef; $currentfile = undef;
do_open_file $filename; do_open_file $filename;
} }