mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-19 17:28:35 +02:00
Try to avoid printing import banners unnecessarily
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
787cec4fe7
commit
16bbe780c7
@ -1205,6 +1205,7 @@ sub copy1( $ ) {
|
|||||||
#
|
#
|
||||||
sub copy2( $ ) {
|
sub copy2( $ ) {
|
||||||
assert( $script_enabled );
|
assert( $script_enabled );
|
||||||
|
my $empty = 1;
|
||||||
|
|
||||||
if ( $script ) {
|
if ( $script ) {
|
||||||
my $file = $_[0];
|
my $file = $_[0];
|
||||||
@ -1212,46 +1213,47 @@ sub copy2( $ ) {
|
|||||||
open IF , $file or fatal_error "Unable to open $file: $!";
|
open IF , $file or fatal_error "Unable to open $file: $!";
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
last unless /^#/;
|
$empty = 0, last unless /^#/;
|
||||||
}
|
}
|
||||||
|
|
||||||
print $script <<EOF;
|
unless ( $empty ) {
|
||||||
|
print $script <<EOF;
|
||||||
################################################################################
|
################################################################################
|
||||||
# Functions imported from $file
|
# Functions imported from $file
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
print $script $_ if defined && ! /^\s*$/;
|
print $script $_ unless /^\s*$/;
|
||||||
|
|
||||||
while ( <IF> ) {
|
while ( <IF> ) {
|
||||||
chomp;
|
chomp;
|
||||||
if ( /^\s*$/ ) {
|
if ( /^\s*$/ ) {
|
||||||
print $script "\n" unless $lastlineblank;
|
print $script "\n" unless $lastlineblank;
|
||||||
$lastlineblank = 1;
|
$lastlineblank = 1;
|
||||||
} else {
|
} else {
|
||||||
if ( $indent ) {
|
if ( $indent ) {
|
||||||
s/^(\s*)/$indent1$1$indent2/;
|
s/^(\s*)/$indent1$1$indent2/;
|
||||||
s/ /\t/ if $indent2;
|
s/ /\t/ if $indent2;
|
||||||
|
}
|
||||||
|
|
||||||
|
print $script $_;
|
||||||
|
print $script "\n";
|
||||||
|
$lastlineblank = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
print $script $_;
|
|
||||||
print $script "\n";
|
|
||||||
$lastlineblank = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
close IF;
|
||||||
|
|
||||||
|
print $script "\n" unless $lastlineblank;
|
||||||
|
|
||||||
close IF;
|
print $script <<EOF;
|
||||||
|
|
||||||
print $script "\n" unless $lastlineblank;
|
|
||||||
|
|
||||||
print $script <<EOF;
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# End of imports from $file
|
# End of imports from $file
|
||||||
################################################################################
|
################################################################################
|
||||||
EOF
|
EOF
|
||||||
$lastlineblank = 0;
|
$lastlineblank = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user