forked from extern/shorewall_code
Conditionally trace writes by copy2().
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
51d4bf19b5
commit
7e97e9519d
@ -1240,11 +1240,13 @@ sub copy1( $ ) {
|
|||||||
#
|
#
|
||||||
# This one drops header comments and replaces them with a three-line banner
|
# This one drops header comments and replaces them with a three-line banner
|
||||||
#
|
#
|
||||||
sub copy2( $ ) {
|
sub copy2( $$ ) {
|
||||||
|
my ( $file, $trace ) = @_;
|
||||||
|
|
||||||
assert( $script_enabled );
|
assert( $script_enabled );
|
||||||
my $empty = 1;
|
my $empty = 1;
|
||||||
|
|
||||||
if ( $script ) {
|
if ( $script || $trace ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
|
|
||||||
open IF , $file or fatal_error "Unable to open $file: $!";
|
open IF , $file or fatal_error "Unable to open $file: $!";
|
||||||
@ -1254,18 +1256,22 @@ sub copy2( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unless ( $empty ) {
|
unless ( $empty ) {
|
||||||
print $script <<EOF;
|
emit <<EOF;
|
||||||
################################################################################
|
################################################################################
|
||||||
# Functions imported from $file
|
# Functions imported from $file
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
print $script $_ unless /^\s*$/;
|
chomp;
|
||||||
|
emit( $_ ) unless /^\s*$/;
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
chomp;
|
chomp;
|
||||||
if ( /^\s*$/ ) {
|
if ( /^\s*$/ ) {
|
||||||
print $script "\n" unless $lastlineblank;
|
unless ( $lastlineblank ) {
|
||||||
|
print $script "\n" if $script;
|
||||||
|
print "GS----->\n" if $trace;
|
||||||
|
}
|
||||||
|
|
||||||
$lastlineblank = 1;
|
$lastlineblank = 1;
|
||||||
} else {
|
} else {
|
||||||
if ( $indent ) {
|
if ( $indent ) {
|
||||||
@ -1273,22 +1279,30 @@ EOF
|
|||||||
s/ /\t/ if $indent2;
|
s/ /\t/ if $indent2;
|
||||||
}
|
}
|
||||||
|
|
||||||
print $script $_;
|
if ( $script ) {
|
||||||
print $script "\n";
|
print $script $_;
|
||||||
|
print $script "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $trace ) {
|
||||||
|
s/\n/GS-----> \n/g;
|
||||||
|
print "GS-----> $_\n";
|
||||||
|
}
|
||||||
|
|
||||||
$lastlineblank = 0;
|
$lastlineblank = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close IF;
|
close IF;
|
||||||
|
|
||||||
print $script "\n" unless $lastlineblank;
|
unless ( $lastlineblank ) {
|
||||||
|
print $script "\n" if $script;
|
||||||
|
print "GS----->\n" if $trace;
|
||||||
|
}
|
||||||
|
|
||||||
print $script <<EOF;
|
emit( '################################################################################',
|
||||||
################################################################################
|
"# End of imports from $file",
|
||||||
# End of imports from $file
|
'################################################################################' );
|
||||||
################################################################################
|
|
||||||
EOF
|
|
||||||
$lastlineblank = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user