From: Amos Jeffries Date: Thu, 3 Sep 2009 12:05:05 +0000 (-0600) Subject: SourceFormat: report broken file and continue after errors. X-Git-Tag: SQUID_3_1_0_14~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3021caca7bb215cafb957b70bdb1e43195528d19;p=thirdparty%2Fsquid.git SourceFormat: report broken file and continue after errors. --- diff --git a/scripts/formater.pl b/scripts/formater.pl index af929fc0ad..2f6216edfd 100755 --- a/scripts/formater.pl +++ b/scripts/formater.pl @@ -25,13 +25,12 @@ use IPC::Open2; # # NP: The Squid code requires astyle version 1.22 or later # -$ASTYLE_BIN="/usr/bin/astyle"; - +$ASTYLE_BIN="/usr/local/bin/astyle"; +#$ASTYLE_BIN="/usr/bin/astyle"; #$ASTYLE_BIN="/usr/local/src/astyle-1.22/bin/astyle"; -$ASTYLE_ARGS ="--mode=c -s4 -O -l"; +$ASTYLE_ARGS ="--mode=c -s4 -O -l"; #$ASTYLE_ARGS="--mode=c -s4 -O --break-blocks -l"; -#$ASTYLE_BIN="/usr/local/src/astyle-1.22/bin/astyle"; if(! -e $ASTYLE_BIN){ @@ -82,8 +81,7 @@ while($out){ print "An error while open2\n"; exit -1; } - - + if($pid=fork()){ #do parrent staf close(FROM_ASTYLE); @@ -110,7 +108,7 @@ while($out){ else{ # child staf close(TO_ASTYLE); - + if(!open(OUT,">$out")){ print "Can't open output file: $out\n"; exit -1; @@ -141,7 +139,7 @@ sub input_filter{ if($$line =~/\s+int\s+.*/s || $$line=~ /\s+unsigned\s+.*/s || $$line =~/^int\s+.*/s || $$line=~ /^unsigned\s+.*/s - ){ + ){ if( $$line =~ /(\(|,|\)|\#|typedef)/s ){ #excluding int/unsigned appeared inside function prototypes,typedefs etc.... return 1; @@ -158,12 +156,12 @@ sub input_filter{ $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; $$line= "unsigned ".$name."__FORASTYLE__".$val.";".$extra; - } + } return 1; } diff --git a/scripts/srcformat.sh b/scripts/srcformat.sh index ffe5efe9c6..659c8a4c5d 100755 --- a/scripts/srcformat.sh +++ b/scripts/srcformat.sh @@ -30,12 +30,12 @@ for FILENAME in `ls -1`; do md52=`cat $FILENAME.astylebak| tr -d "\n \t\r" | $MD5`; if test "$md51" != "$md52" ; then - echo "File $PWD/$FILENAME not converted well"; + echo "ERROR: File $PWD/$FILENAME not formating well"; mv $FILENAME $FILENAME.astylebad mv $FILENAME.astylebak $FILENAME - exit 1; + else + rm $FILENAME.astylebak fi - rm $FILENAME.astylebak continue; fi esac