------------------------------------------------------------ revno: 13702 revision-id: squid3@treenet.co.nz-20141220180323-o1ho0xsnzv2r4byp parent: squid3@treenet.co.nz-20141220180017-ire9aq4cso6eq7j5 author: Source Maintenance committer: Amos Jeffries branch nick: 3.5 timestamp: Sat 2014-12-20 10:03:23 -0800 message: Maintenance: bump astyle to 2.04 and quieten report ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20141220180323-o1ho0xsnzv2r4byp # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 06510597d91b0acdb465f1e8ef6b4fa5efaadf09 # timestamp: 2014-12-20 18:09:05 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20141220180017-\ # ire9aq4cso6eq7j5 # # Begin patch === modified file 'scripts/formater.pl' --- scripts/formater.pl 2014-09-13 15:04:00 +0000 +++ scripts/formater.pl 2014-12-20 18:03:23 +0000 @@ -26,30 +26,34 @@ # See COPYING or http://www.gnu.org/licenses/gpl.html for details. # - +use strict; use IPC::Open2; # -# NP: The Squid code requires astyle version 1.22 (exactly for now) +# NP: The Squid code requires astyle version 2.04 (exactly for now) # -$ASTYLE_BIN="/usr/local/bin/astyle"; -#$ASTYLE_BIN="/usr/bin/astyle"; -#$ASTYLE_BIN="/usr/local/src/astyle-1.22/bin/astyle"; +my $ASTYLE_BIN="/usr/local/bin/astyle"; +if (! -x $ASTYLE_BIN) { + $ASTYLE_BIN="/usr/bin/astyle"; +} +if (! -x $ASTYLE_BIN) { + $ASTYLE_BIN="/usr/local/src/astyle-2.04/bin/astyle"; +} -$ASTYLE_ARGS ="--mode=c -s4 -O -l"; +my $ASTYLE_ARGS ="--mode=c -s4 --convert-tabs --keep-one-line-blocks --lineend=linux"; #$ASTYLE_ARGS="--mode=c -s4 -O --break-blocks -l"; -if(! -e $ASTYLE_BIN){ +if(! -e $ASTYLE_BIN || ! -x $ASTYLE_BIN){ print "\nFile $ASTYLE_BIN not found\n"; print "Please fix the ASTYLE_BIN variable in this script!\n\n"; exit -1; } $ASTYLE_BIN=$ASTYLE_BIN." ".$ASTYLE_ARGS; -$INDENT = ""; +my $INDENT = ""; -$out = shift @ARGV; +my $out = shift @ARGV; #read options, currently no options available while($out eq "" || $out =~ /^-\w+$/){ if($out eq "-h") { @@ -71,7 +75,7 @@ next; } - $in= "$out.astylebak"; + my $in= "$out.astylebak"; my($new_in) = $in; my($i) = 0; while(-e $new_in) { @@ -82,13 +86,14 @@ rename($out, $in); local (*FROM_ASTYLE, *TO_ASTYLE); - $pid_style=open2(\*FROM_ASTYLE, \*TO_ASTYLE, $ASTYLE_BIN); + my $pid_style=open2(\*FROM_ASTYLE, \*TO_ASTYLE, $ASTYLE_BIN); if(!$pid_style){ print "An error while open2\n"; exit -1; } + my $pid; if($pid=fork()){ #do parrent staf close(FROM_ASTYLE); @@ -139,7 +144,6 @@ $out = shift @ARGV; } - sub input_filter{ my($line)=@_; #if we have integer declaration, get it all before processing it.. @@ -159,15 +163,17 @@ if($$line =~ /(.*)\s*int\s+([^:]*):\s*(\w+)\s*\;(.*)/s){ # print ">>>>> ".$$line." ($1)\n"; - local($prx,$name,$val,$extra)=($1,$2,$3,$4); + my ($prx,$name,$val,$extra)=($1,$2,$3,$4); $prx =~ s/\s*$//g; $$line= $prx." int ".$name."__FORASTYLE__".$val.";".$extra; # print "----->".$$line."\n"; } elsif($$line =~ /\s*unsigned\s+([^:]*):\s*(\w+)\s*\;(.*)/s){ - local($name,$val,$extra)=($1,$2,$3); - $prx =~ s/\s*$//g; +# print ">>>>> ".$$line." ($1)\n"; + my ($name,$val,$extra)=($1,$2,$3); + my $prx =~ s/\s*$//g; $$line= "unsigned ".$name."__FORASTYLE__".$val.";".$extra; +# print "----->".$$line."\n"; } return 1; } === modified file 'scripts/source-maintenance.sh' --- scripts/source-maintenance.sh 2014-10-31 01:44:11 +0000 +++ scripts/source-maintenance.sh 2014-12-20 18:03:23 +0000 @@ -32,8 +32,9 @@ ROOT=`bzr root` ASVER=`astyle --version 2>&1 | grep -o -E "[0-9.]+"` -if test "${ASVER}" != "2.03" ; then - echo "Astyle version problem. You have ${ASVER} instead of 2.03"; +if test "${ASVER}" != "2.04" ; then + echo "Astyle version problem. You have ${ASVER} instead of 2.04" + ASVER="" else echo "Found astyle ${ASVER}. Formatting..." fi @@ -63,16 +64,17 @@ # # Code Style formatting maintenance # - if test "${ASVER}" = "1.23"; then + if test "${ASVER}"; then ${ROOT}/scripts/formater.pl ${FILENAME} if test -e $FILENAME -a -e "$FILENAME.astylebak"; then md51=`cat $FILENAME| tr -d "\n \t\r" | $MD5`; md52=`cat $FILENAME.astylebak| tr -d "\n \t\r" | $MD5`; - if test "$md51" != "$md52" ; then + if test "$md51" != "$md52"; then echo "ERROR: File $PWD/$FILENAME not formating well"; mv $FILENAME $FILENAME.astylebad mv $FILENAME.astylebak $FILENAME + bzr revert ${FILENAME} else rm -f $FILENAME.astylebak fi