From 50405f57ba23429a8a9077db29c6284ed19c7269 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 8 Apr 2012 07:54:03 -0700 Subject: [PATCH] Don't suppress whitespace in embedded Perl and Shell Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 94907511b..ba514d723 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -1939,7 +1939,7 @@ sub first_entry( $ ) { } } -sub read_a_line(;$$$); +sub read_a_line(;$$$$); sub embedded_shell( $ ) { my $multiline = shift; @@ -1956,7 +1956,7 @@ sub embedded_shell( $ ) { my $last = 0; - while ( read_a_line( 0, 0, 0 ) ) { + while ( read_a_line( 0, 0, 0, 0 ) ) { last if $last = $currentline =~ s/^\s*END(\s+SHELL)?\s*;?//; $command .= $currentline; } @@ -1990,7 +1990,7 @@ sub embedded_perl( $ ) { my $last = 0; - while ( read_a_line( 0, 0, 0 ) ) { + while ( read_a_line( 0, 0, 0, 0 ) ) { last if $last = $currentline =~ s/^\s*END(\s+PERL)?\s*;?//; $command .= $currentline; } @@ -2145,10 +2145,11 @@ sub expand_variables( \$ ) { # - Handle ?IF, ?ELSE, ?ENDIF # -sub read_a_line(;$$$) { - my $embedded_enabled = defined $_[0] ? shift : 1; - my $expand_variables = defined $_[0] ? shift : 1; - my $strip_comments = defined $_[0] ? shift : 1; +sub read_a_line(;$$$$) { + my $embedded_enabled = defined $_[0] ? shift : 1; + my $expand_variables = defined $_[0] ? shift : 1; + my $strip_comments = defined $_[0] ? shift : 1; + my $suppress_whitespace = defined $_[0] ? shift : 1; while ( $currentfile ) { @@ -2163,7 +2164,7 @@ sub read_a_line(;$$$) { # # Suppress leading whitespace in certain continuation lines # - s/^\s*// if $currentline =~ /[,:]$/; + s/^\s*// if $currentline =~ /[,:]$/ && $suppress_whitespace; # # If this isn't a continued line, remove trailing comments. Note that # the result may now end in '\'. @@ -2180,7 +2181,7 @@ sub read_a_line(;$$$) { # # Ignore ( concatenated ) Blank Lines # - $currentline = '', $currentlinenumber = 0, next if $currentline =~ /^\s*$/; + $currentline = '', $currentlinenumber = 0, next if $currentline =~ /^\s*$/ && $suppress_whitespace; # # Line not blank -- Handle any first-entry message/capabilities check #