#
# 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){
print "An error while open2\n";
exit -1;
}
-
-
+
if($pid=fork()){
#do parrent staf
close(FROM_ASTYLE);
else{
# child staf
close(TO_ASTYLE);
-
+
if(!open(OUT,">$out")){
print "Can't open output file: $out\n";
exit -1;
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;
$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;
}
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