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];
|
||||
open $currentfile, '<', $fname or fatal_error "Unable to open $fname: $!";
|
||||
$currentlinenumber = 0;
|
||||
$ifstack = @ifstack;
|
||||
$currentfilename = $fname;
|
||||
}
|
||||
|
||||
@ -1564,6 +1565,20 @@ sub process_conditional($$$) {
|
||||
$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
|
||||
#
|
||||
@ -1603,14 +1618,7 @@ sub copy( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
end_conditional( $save_ifstack , $file );
|
||||
|
||||
close IF;
|
||||
}
|
||||
@ -1628,8 +1636,6 @@ sub copy1( $ ) {
|
||||
my ( $do_indent, $here_documents ) = ( 1, '');
|
||||
my $save_ifstack = $ifstack;
|
||||
|
||||
$ifstack = @ifstack;
|
||||
|
||||
open_file( $_[0] );
|
||||
|
||||
while ( $currentfile ) {
|
||||
@ -1727,14 +1733,7 @@ sub copy1( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
unless( $ifstack == @ifstack ) {
|
||||
my $lastref = $ifstack[-1];
|
||||
$currentlinenumber = 'EOF';
|
||||
$currentfilename = $_[0];
|
||||
fatal_error qq(Missing "?ENDIF" to match ?IF at line number $lastref->[2])
|
||||
}
|
||||
|
||||
$ifstack = $save_ifstack;
|
||||
end_conditional( $save_ifstack, $currentfilename );
|
||||
|
||||
close_file;
|
||||
}
|
||||
@ -1813,14 +1812,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
end_conditional( $save_ifstack, $file );
|
||||
|
||||
close IF;
|
||||
|
||||
@ -1843,7 +1835,6 @@ EOF
|
||||
sub push_open( $ ) {
|
||||
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||
$ifstack = @ifstack;
|
||||
my @a = @includestack;
|
||||
push @openstack, \@a;
|
||||
@includestack = ();
|
||||
@ -1928,12 +1919,13 @@ sub embedded_shell( $ ) {
|
||||
|
||||
$command .= q(');
|
||||
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack = @ifstack ];
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||
$currentfile = undef;
|
||||
open $currentfile , '-|', $command or fatal_error qq(Shell Command failed);
|
||||
$currentfilename = "SHELL\@$currentfilename:$currentlinenumber";
|
||||
$currentline = '';
|
||||
$currentlinenumber = 0;
|
||||
$ifstack = @ifstack;
|
||||
}
|
||||
|
||||
sub embedded_perl( $ ) {
|
||||
@ -1984,7 +1976,7 @@ sub embedded_perl( $ ) {
|
||||
|
||||
$perlscript = undef;
|
||||
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack = @ifstack ];
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber , $ifstack ];
|
||||
$currentfile = undef;
|
||||
|
||||
open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname";
|
||||
@ -1996,6 +1988,7 @@ sub embedded_perl( $ ) {
|
||||
$currentfilename = "PERL\@$currentfilename:$linenumber";
|
||||
$currentline = '';
|
||||
$currentlinenumber = 0;
|
||||
$ifstack = @ifstack;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2198,7 +2191,7 @@ sub read_a_line(;$$$) {
|
||||
fatal_error "Directory ($filename) not allowed in INCLUDE" if -d _;
|
||||
|
||||
if ( -s _ ) {
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack = @ifstack ];
|
||||
push @includestack, [ $currentfile, $currentfilename, $currentlinenumber, $ifstack ];
|
||||
$currentfile = undef;
|
||||
do_open_file $filename;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user