------------------------------------------------------------ revno: 12300 revision-id: kinkie@squid-cache.org-20120828124552-meazdgc59jeak9qh parent: squidadm@squid-cache.org-20120825001313-r29kssp32bjna4i1 committer: Francesco Chemolli branch nick: trunk timestamp: Tue 2012-08-28 14:45:52 +0200 message: Enable source-formatting tools to collapse multiple whitelines in the source to one. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kinkie@squid-cache.org-20120828124552-meazdgc59jeak9qh # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 3fa2013c84433a0043c47fabda3b9a61cb2f867b # timestamp: 2012-08-28 12:52:23 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squidadm@squid-cache.org-20120825001313-\ # r29kssp32bjna4i1 # # Begin patch === modified file 'scripts/formater.pl' --- scripts/formater.pl 2010-09-30 03:54:00 +0000 +++ scripts/formater.pl 2012-08-28 12:45:52 +0000 @@ -176,11 +176,24 @@ 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__//) {