mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-10 15:48:13 +01:00
Support ?IF in copied files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
8803cd8d3b
commit
88b1180817
@ -1586,12 +1586,27 @@ sub copy( $ ) {
|
|||||||
assert( $script_enabled );
|
assert( $script_enabled );
|
||||||
|
|
||||||
if ( $script ) {
|
if ( $script ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
|
my $omitting = 0;
|
||||||
|
my $save_ifstack = $ifstack;
|
||||||
|
my $lineno = 0;
|
||||||
|
|
||||||
|
$ifstack = @ifstack;
|
||||||
|
|
||||||
open IF , $file or fatal_error "Unable to open $file: $!";
|
open IF , $file or fatal_error "Unable to open $file: $!";
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
chomp;
|
chomp;
|
||||||
|
|
||||||
|
$lineno++;
|
||||||
|
|
||||||
|
if ( /^\s*\?/ ) {
|
||||||
|
$omitting = process_conditional( $omitting, $_, $lineno );
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
next if $omitting;
|
||||||
|
|
||||||
if ( /^\s*$/ ) {
|
if ( /^\s*$/ ) {
|
||||||
print $script "\n" unless $lastlineblank;
|
print $script "\n" unless $lastlineblank;
|
||||||
$lastlineblank = 1;
|
$lastlineblank = 1;
|
||||||
@ -1607,6 +1622,14 @@ sub copy( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $ifstack < @ifstack ) {
|
||||||
|
$currentlinenumber = 'EOF';
|
||||||
|
$currentfilename = $file;
|
||||||
|
fatal_error "Missing ?ENDIF to match the ?IF at line $ifstack[-1]->[3]";
|
||||||
|
} else {
|
||||||
|
$ifstack = $save_ifstack;
|
||||||
|
}
|
||||||
|
|
||||||
close IF;
|
close IF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1621,6 +1644,7 @@ sub copy1( $ ) {
|
|||||||
|
|
||||||
if ( $script || $debug ) {
|
if ( $script || $debug ) {
|
||||||
my ( $do_indent, $here_documents ) = ( 1, '');
|
my ( $do_indent, $here_documents ) = ( 1, '');
|
||||||
|
my $save_ifstack = $ifstack;
|
||||||
|
|
||||||
open_file( $_[0] );
|
open_file( $_[0] );
|
||||||
|
|
||||||
@ -1630,6 +1654,11 @@ sub copy1( $ ) {
|
|||||||
|
|
||||||
chomp;
|
chomp;
|
||||||
|
|
||||||
|
if ( /^\s*\?/ ) {
|
||||||
|
$omitting = process_conditional( $omitting, $_, $currentlinenumber );
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
if ( /^${here_documents}\s*$/ ) {
|
if ( /^${here_documents}\s*$/ ) {
|
||||||
if ( $script ) {
|
if ( $script ) {
|
||||||
print $script $here_documents if $here_documents;
|
print $script $here_documents if $here_documents;
|
||||||
@ -1712,6 +1741,13 @@ sub copy1( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $ifstack < @ifstack ) {
|
||||||
|
$currentlinenumber = 'EOF';
|
||||||
|
fatal_error "Missing ?ENDIF to match the ?IF at line $ifstack[-1]->[3]";
|
||||||
|
} else {
|
||||||
|
$ifstack = $save_ifstack;
|
||||||
|
}
|
||||||
|
|
||||||
close_file;
|
close_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1732,10 +1768,14 @@ sub copy2( $$ ) {
|
|||||||
|
|
||||||
if ( $script || $trace ) {
|
if ( $script || $trace ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
|
my $omitting = 0;
|
||||||
|
my $save_ifstack = $ifstack;
|
||||||
|
my $lineno = 0;
|
||||||
|
|
||||||
open IF , $file or fatal_error "Unable to open $file: $!";
|
open IF , $file or fatal_error "Unable to open $file: $!";
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
|
$lineno++;
|
||||||
$empty = 0, last unless /^#/;
|
$empty = 0, last unless /^#/;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1749,7 +1789,16 @@ EOF
|
|||||||
emit( $_ ) unless /^\s*$/;
|
emit( $_ ) unless /^\s*$/;
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
|
$lineno++;
|
||||||
chomp;
|
chomp;
|
||||||
|
|
||||||
|
if ( /^\s*\?/ ) {
|
||||||
|
$omitting = process_conditional( $omitting, $_, $lineno );
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
next if $omitting;
|
||||||
|
|
||||||
if ( /^\s*$/ ) {
|
if ( /^\s*$/ ) {
|
||||||
unless ( $lastlineblank ) {
|
unless ( $lastlineblank ) {
|
||||||
print $script "\n" if $script;
|
print $script "\n" if $script;
|
||||||
@ -1777,8 +1826,6 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close IF;
|
|
||||||
|
|
||||||
unless ( $lastlineblank ) {
|
unless ( $lastlineblank ) {
|
||||||
print $script "\n" if $script;
|
print $script "\n" if $script;
|
||||||
print "GS----->\n" if $trace;
|
print "GS----->\n" if $trace;
|
||||||
@ -1788,6 +1835,17 @@ EOF
|
|||||||
"# End of imports from $file",
|
"# End of imports from $file",
|
||||||
'################################################################################' );
|
'################################################################################' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $ifstack < @ifstack ) {
|
||||||
|
$currentfilename = $file;
|
||||||
|
$currentlinenumber = 'EOF';
|
||||||
|
fatal_error "Missing ?ENDIF to match the ?IF at line $ifstack[-1]->[3]";
|
||||||
|
} else {
|
||||||
|
$ifstack = $save_ifstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
close IF;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2168,6 +2226,11 @@ sub read_a_line(;$$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( @ifstack ) {
|
||||||
|
$currentlinenumber = 'EOF';
|
||||||
|
fatal_error "Missing ?ENDIF to match the ?IF at line $ifstack[-1]->[3]";
|
||||||
|
}
|
||||||
|
|
||||||
close_file;
|
close_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user