]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
scripts/formater.pl: use strict perl syntax checking
authorsquidadm@squid-cache.org <>
Sat, 20 Dec 2014 07:49:33 +0000 (07:49 +0000)
committersquidadm@squid-cache.org <>
Sat, 20 Dec 2014 07:49:33 +0000 (07:49 +0000)
scripts/formater.pl
scripts/source-maintenance.sh

index cbc6ea510d27590bd0ba1f205baac81d24d38bd6..7df24ed4631ef6561bfe5f54db18c8f9fffe538d 100755 (executable)
 # 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.03 (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.03/bin/astyle";
+}
 
-$ASTYLE_ARGS ="--mode=c -s4 -O -l";
+my $ASTYLE_ARGS ="--mode=c -s4 --convert-tabs --keep-one-line-blocks ";
 #$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 @@ while($out){
          next;
     }
 
-    $in= "$out.astylebak";
+    my $in= "$out.astylebak";
     my($new_in) = $in;
     my($i) = 0;
     while(-e $new_in) {
@@ -82,13 +86,14 @@ while($out){
     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 @@ while($out){
     $out = shift @ARGV;
 }
 
-
 sub input_filter{
     my($line)=@_;
      #if we have integer declaration, get it all before processing it..
@@ -159,14 +163,14 @@ sub input_filter{
 
        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;
+            my ($name,$val,$extra)=($1,$2,$3);
+            my $prx =~ s/\s*$//g;
            $$line= "unsigned ".$name."__FORASTYLE__".$val.";".$extra;
        }
        return 1;
index 5782d4b4559ff0ad70a6e29200dd3450aae4bdba..fd30e2dd82c141f3e8f67a9510ddd1471057ebff 100755 (executable)
@@ -70,10 +70,11 @@ for FILENAME in `bzr ls --versioned`; do
                        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