From 16bbe780c7cc8e4b96210a2fa991150588e4ec1f Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Tue, 16 Mar 2010 07:23:02 -0700 Subject: [PATCH] Try to avoid printing import banners unnecessarily Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 50 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 09b18fff3..287ec6747 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -1205,6 +1205,7 @@ sub copy1( $ ) { # sub copy2( $ ) { assert( $script_enabled ); + my $empty = 1; if ( $script ) { my $file = $_[0]; @@ -1212,46 +1213,47 @@ sub copy2( $ ) { open IF , $file or fatal_error "Unable to open $file: $!"; while ( ) { - last unless /^#/; + $empty = 0, last unless /^#/; } - print $script < ) { - chomp; - if ( /^\s*$/ ) { - print $script "\n" unless $lastlineblank; - $lastlineblank = 1; - } else { - if ( $indent ) { - s/^(\s*)/$indent1$1$indent2/; - s/ /\t/ if $indent2; + while ( ) { + chomp; + if ( /^\s*$/ ) { + print $script "\n" unless $lastlineblank; + $lastlineblank = 1; + } else { + if ( $indent ) { + s/^(\s*)/$indent1$1$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 "\n" unless $lastlineblank; - - print $script <