From 7e97e9519d68d1f08934ce30e3aec378a5185f26 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 29 Mar 2010 11:56:26 -0700 Subject: [PATCH] Conditionally trace writes by copy2(). Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 44 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 6d8f76c50..6bf9b09b5 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -1240,11 +1240,13 @@ sub copy1( $ ) { # # This one drops header comments and replaces them with a three-line banner # -sub copy2( $ ) { +sub copy2( $$ ) { + my ( $file, $trace ) = @_; + assert( $script_enabled ); my $empty = 1; - if ( $script ) { + if ( $script || $trace ) { my $file = $_[0]; open IF , $file or fatal_error "Unable to open $file: $!"; @@ -1254,18 +1256,22 @@ sub copy2( $ ) { } unless ( $empty ) { - print $script < ) { chomp; if ( /^\s*$/ ) { - print $script "\n" unless $lastlineblank; + unless ( $lastlineblank ) { + print $script "\n" if $script; + print "GS----->\n" if $trace; + } + $lastlineblank = 1; } else { if ( $indent ) { @@ -1273,22 +1279,30 @@ EOF s/ /\t/ if $indent2; } - print $script $_; - print $script "\n"; + if ( $script ) { + print $script $_; + print $script "\n"; + } + + if ( $trace ) { + s/\n/GS-----> \n/g; + print "GS-----> $_\n"; + } + $lastlineblank = 0; } } close IF; - print $script "\n" unless $lastlineblank; + unless ( $lastlineblank ) { + print $script "\n" if $script; + print "GS----->\n" if $trace; + } - print $script <