From 03a4c6c322d9d28dee265be090f48a6ee968e25f Mon Sep 17 00:00:00 2001 From: teastep Date: Tue, 27 Mar 2007 16:51:33 +0000 Subject: [PATCH] Improve emitj() git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5717 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- New/Shorewall/Common.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/New/Shorewall/Common.pm b/New/Shorewall/Common.pm index 886b7bdcc..5361c656f 100644 --- a/New/Shorewall/Common.pm +++ b/New/Shorewall/Common.pm @@ -174,7 +174,7 @@ sub emit ( $ ) { print $object "$line\n"; $lastlineblank = ( substr( $line, -1, 1 ) eq "\n" ); } else { - print $object "\n" unless $lastlineblank; + print $object "\n" unless $lastlineblank; $lastlineblank = 1; } } @@ -185,7 +185,22 @@ sub emit ( $ ) { # sub emitj { if ( $object ) { - for ( @_ ) { emit $_ }; + # + # 'compile' as opposed to 'check' + # + for ( @_ ) { + unless ( /^\s*$/ ) { + my $line = $_; + $line =~ s/^\n// if $lastlineblank; + $line =~ s/^/$indent/gm if $indent; + 1 while $line =~ s/^ /\t/; + print $object "$line\n"; + $lastlineblank = ( substr( $line, -1, 1 ) eq "\n" ); + } else { + print $object "\n" unless $lastlineblank; + $lastlineblank = 1; + } + } } }