Added check to avoid tabs in source files
authorAntonin Descampe <antonin@gmail.com>
Thu, 1 Dec 2005 12:38:36 +0000 (12:38 +0000)
committerAntonin Descampe <antonin@gmail.com>
Thu, 1 Dec 2005 12:38:36 +0000 (12:38 +0000)
CVSROOT/checktabs.sh [new file with mode: 0755]
CVSROOT/commitinfo

diff --git a/CVSROOT/checktabs.sh b/CVSROOT/checktabs.sh
new file mode 100755 (executable)
index 0000000..19a522e
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/tcsh
+#
+# checkTabs checks source code for explicit TABS
+# checks only files with the following extensions: .c, .cxx, .txx,
+# exits with 0, if all commited files pass the test.
+# exits with 1, if any one of the tests fails
+#
+# checkTabs can be run as a cvs commitinfo command.
+# The following commitinfo line (without the #) will run the script
+# ALL $CVSROOT/CVSROOT/checkTabs
+#
+set failed=0
+#
+# skip the first arg, the directory
+foreach file ( $argv[2-] )
+#
+# select files with extentions .txx, .cxx, .h, .html, .htm
+set match=`echo $file | egrep \[\.\]txx\$\|\[\.\]cxx\$\|\[\.\]h\$\|\[\.\]c\$`
+if ( $match == "" ) continue;
+set count=`grep -n "   " /dev/null $file|wc -c`
+set results=`expr $count \| 0`
+if ( "$results" != "0" ) then
+        echo
+"=========================================================="
+        grep -n "      " /dev/null $file
+        echo ""
+        echo "$file has explicit TABSs."
+        echo "They must be converted to SPACES(2 per TAB) before you can commit."
+        echo
+"=========================================================="
+        set failed=1
+endif
+end
+exit $failed
\ No newline at end of file
index b19e7b7a63e8e90cdb49c43f02035646c4a76e0a..221cb065cad68337652e74de33fc5577c6270f4c 100644 (file)
@@ -13,3 +13,5 @@
 #
 # If the name "ALL" appears as a regular expression it is always used
 # in addition to the first matching regex or "DEFAULT".
+
+ALL $CVSROOT/CVSROOT/checktabs.sh
\ No newline at end of file