]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceFormat: Convert md5checker script into a recursive formatter+validator
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 9 Oct 2008 13:00:28 +0000 (02:00 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 9 Oct 2008 13:00:28 +0000 (02:00 +1300)
This converts the md5 validation script from a single layer to a
recursive script.

Given a directory path calls the formater.pl script for all .h .c .cc and
.cci files within. Validating each file conversion as it goes and aborts
at the first error found.

This is intended for maintenance of the central Squid-3 repository code.

NP: As with the original checker its a bash script.
    Probably non-portable right now without adaptions.

scripts/md5checker.sh [deleted file]
scripts/srcformat.sh [new file with mode: 0755]

diff --git a/scripts/md5checker.sh b/scripts/md5checker.sh
deleted file mode 100755 (executable)
index bcd7dd0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# A checker
-
-
-for FILENAME in $*; do
-
-    if test -e $FILENAME -a -e "$FILENAME.astylebak"; then
-       md51=`cat  $FILENAME| tr -d "\n \t\r" | md5sum|sed 's/  -//'`;
-       md52=`cat  $FILENAME.astylebak| tr -d "\n \t\r" | md5sum|sed 's/  -//'`;
-       
-       if test $md51 != $md52; then
-           echo "File $FILENAME not converted well";
-       fi
-    else
-       echo "can not check file: $FILENAME";
-    fi
-
-done
-
-
-
-
-
diff --git a/scripts/srcformat.sh b/scripts/srcformat.sh
new file mode 100755 (executable)
index 0000000..a04b625
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# A checker to recursively reformat all source files: .h .c .cc .cci
+# using a custom astyle formatter and to use MD5 to validate that
+# the formatter has not altered the code syntax.
+#
+# If code alteration takes place the process is halted for manual intervention.
+#
+
+ROOT="$1"
+PWD=`pwd`
+
+for FILENAME in `ls -1`; do
+
+    if    test "${FILENAME: -2:2}" = ".h" \
+       || test "${FILENAME: -2:2}" = ".c" \
+       || test "${FILENAME: -3:3}" = ".cc" \
+       || test "${FILENAME: -4:4}" = ".cci" \
+    ; then
+       ${ROOT}/scripts/formater.pl ${FILENAME}
+
+       if test -e $FILENAME -a -e "$FILENAME.astylebak"; then
+               md51=`cat  $FILENAME| tr -d "\n \t\r" | md5sum|sed 's/  -//'`;
+               md52=`cat  $FILENAME.astylebak| tr -d "\n \t\r" | md5sum|sed 's/  -//'`;
+
+               if test $md51 != $md52; then
+                       echo "File $PWD/$FILENAME not converted well";
+                       exit 1;
+               fi
+               rm $FILENAME.astylebak
+               continue;
+        fi
+    fi
+
+    if test -d $FILENAME ; then
+       cd $FILENAME
+       $ROOT/scripts/md5checker.sh "$ROOT"  || exit 1
+       cd ..
+    fi
+
+done