mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-18 12:20:42 +01:00
Clean up of conditional inclusion.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
164d2f5d1b
commit
5f3ba4eb40
@ -1469,6 +1469,7 @@ sub do_open_file( $ ) {
|
|||||||
my $fname = $_[0];
|
my $fname = $_[0];
|
||||||
open $currentfile, '<', $fname or fatal_error "Unable to open $fname: $!";
|
open $currentfile, '<', $fname or fatal_error "Unable to open $fname: $!";
|
||||||
$currentlinenumber = 0;
|
$currentlinenumber = 0;
|
||||||
|
$ifstack = @ifstack;
|
||||||
$currentfilename = $fname;
|
$currentfilename = $fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1564,6 +1565,20 @@ sub process_conditional($$$) {
|
|||||||
$omitting;
|
$omitting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub end_conditional( $$ ) {
|
||||||
|
my ( $save_ifstack, $file ) = @_;
|
||||||
|
|
||||||
|
unless( $ifstack == @ifstack ) {
|
||||||
|
my $lastref = $ifstack[-1];
|
||||||
|
$currentlinenumber = 'EOF';
|
||||||
|
$currentfilename = $file;
|
||||||
|
fatal_error qq(Missing "?ENDIF" to match ?IF at line number $lastref->[2])
|
||||||
|
}
|
||||||
|
|
||||||
|
$ifstack = $save_ifstack;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions for copying a file into the script
|
# Functions for copying a file into the script
|
||||||
#
|
#
|
||||||
@ -1603,14 +1618,7 @@ sub copy( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unless( $ifstack == @ifstack ) {
|
end_conditional( $save_ifstack , $file );
|
||||||
my $lastref = $ifstack[-1];
|
|
||||||
$currentlinenumber = 'EOF';
|
|
||||||
$currentfilename = $file;
|
|
||||||
fatal_error qq(Missing "?ENDIF" to match ?IF at line number $lastref->[2])
|
|
||||||
}
|
|
||||||
|
|
||||||
$ifstack = $save_ifstack;
|
|
||||||
|
|
||||||
close IF;
|
close IF;
|
||||||
}
|
}
|
||||||
@ -1628,8 +1636,6 @@ sub copy1( $ ) {
|
|||||||
my ( $do_indent, $here_documents ) = ( 1, '');
|
my ( $do_indent, $here_documents ) = ( 1, '');
|
||||||
my $save_ifstack = $ifstack;
|
my $save_ifstack = $ifstack;
|
||||||
|
|
||||||
$ifstack = @ifstack;
|
|
||||||
|
|
||||||
open_file( $_[0] );
|
open_file( $_[0] );
|
||||||
|
|
||||||
while ( $currentfile ) {
|
while ( $currentfile ) {
|
||||||
@ -1727,14 +1733,7 @@ sub copy1( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unless( $ifstack == @ifstack ) {
|
end_conditional( $save_ifstack, $currentfilename );
|
||||||
my $lastref = $ifstack[-1];
|
|
||||||
$currentlinenumber = 'EOF';
|
|
||||||
$currentfilename = $_[0];
|
|
||||||
fatal_error qq(Missing "?ENDIF" to match ?IF at line number $lastref->[2])
|
|
||||||
}
|
|
||||||
|
|
||||||
$ifstack = $save_ifstack;
|
|
||||||
|
|
||||||
close_file;
|
close_file;
|
||||||
}
|
}
|
||||||
@ -1813,14 +1812,7 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unless( $ifstack == @ifstack ) {
|
end_conditional( $save_ifstack, $file );
|
||||||
my $lastref = $ifstack[-1];
|
|
||||||
$currentlinenumber = 'EOF';
|
|
||||||
$currentfilename = $file;
|
|
||||||
fatal_error qq(Missing "?ENDIF" to match ?IF at line number $lastref->[2])
|
|
||||||
}
|
|
||||||
|
|
||||||
$ifstack = $save_ifstack;
|
|
||||||
|
|
||||||
close IF;
|
close IF;
|
||||||
|
|
||||||
@ -1843,7 +1835,6 @@ EOF
|
|||||||
sub push_open( $ ) {
|
sub push_open( $ ) {
|
||||||
|
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||||
$ifstack = @ifstack;
|
|
||||||
my @a = @includestack;
|
my @a = @includestack;
|
||||||
push @openstack, \@a;
|
push @openstack, \@a;
|
||||||
@includestack = ();
|
@includestack = ();
|
||||||
@ -1928,12 +1919,13 @@ sub embedded_shell( $ ) {
|
|||||||
|
|
||||||
$command .= q(');
|
$command .= q(');
|
||||||
|
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack = @ifstack ];
|
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
||||||
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
||||||
$currentline = '';
|
$currentline = '';
|
||||||
$currentlinenumber = 0;
|
$currentlinenumber = 0;
|
||||||
|
$ifstack = @ifstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub embedded_perl( $ ) {
|
sub embedded_perl( $ ) {
|
||||||
@ -1984,7 +1976,7 @@ sub embedded_perl( $ ) {
|
|||||||
|
|
||||||
$perlscript = undef;
|
$perlscript = undef;
|
||||||
|
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack = @ifstack ];
|
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack ];
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
|
|
||||||
open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname";
|
open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname";
|
||||||
@ -1996,6 +1988,7 @@ sub embedded_perl( $ ) {
|
|||||||
$currentfilename = "PERL\@$currentfilename:$linenumber";
|
$currentfilename = "PERL\@$currentfilename:$linenumber";
|
||||||
$currentline = '';
|
$currentline = '';
|
||||||
$currentlinenumber = 0;
|
$currentlinenumber = 0;
|
||||||
|
$ifstack = @ifstack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2198,7 +2191,7 @@ sub read_a_line(;$$$) {
|
|||||||
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||||
|
|
||||||
if ( -s _ ) {
|
if ( -s _ ) {
|
||||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack = @ifstack ];
|
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||||
$currentfile = undef;
|
$currentfile = undef;
|
||||||
do_open_file $filename;
|
do_open_file $filename;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user