From: Francesco Chemolli Date: Tue, 28 Aug 2012 12:45:52 +0000 (+0200) Subject: Enable source-formatting tools to collapse multiple whitelines in the source to one. X-Git-Tag: sourceformat-review-1~64^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74201a78f22561051571b7b965733d428afedd86;p=thirdparty%2Fsquid.git Enable source-formatting tools to collapse multiple whitelines in the source to one. --- diff --git a/scripts/formater.pl b/scripts/formater.pl index f52cbbd31f..03f3b4a1d6 100755 --- a/scripts/formater.pl +++ b/scripts/formater.pl @@ -176,11 +176,24 @@ sub input_filter{ return 1; } +my $last_line_was_empty=0; +#param: a reference to input line +#retval 1: print line +#retval 0: don't print line sub output_filter{ my($line)=@_; + # collapse multiple empty lines onto the first one if($$line =~ /^\s*$/){ - return 1; + if ($last_line_was_empty==1) { + $$line=""; + return 0; + } else { + $last_line_was_empty=1; + return 1; + } + } else { + $last_line_was_empty=0; } if($$line =~ s/\s*\/\/__ASTYLECOMMENT__//) {