From d4c77690d3bd451b134156b1e117ab60826036f8 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 6 Sep 2012 20:11:02 +0000 Subject: [PATCH] build: start working on a script to test source code problems. --- build/check-source | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 build/check-source diff --git a/build/check-source b/build/check-source new file mode 100755 index 00000000..be896c87 --- /dev/null +++ b/build/check-source @@ -0,0 +1,39 @@ +#!/bin/sh + +set -e + +# Find out where the top directory is and go there +top_srcdir="$(cd "$(dirname $0)"; cd ..; pwd)" +cd "$top_srcdir" + +# Find out what kind of Vcs directory this is +if [ -f "$top_srcdir/.git/index" ]; then + echo "I: detected Git repository" + repo=git +elif [ -f "$top_srcdir/.svn/format" ]; then + echo "I: detected SVN repository" + repo=svn +else + echo "I: not in a Vcs directory, nothing to do" + exit 0 +fi + +if [ "$repo" = git ]; then + git ls-files +else + : +fi | while read file; do + case "$file" in + src/bullet/*|contrib/*|people/*|*/generated/*) + : # These files aren't ours, don't fix + ;; + *.c|*.cpp|*.h) + ntabs="$(grep -c -P '\t' "$file" || true)" + nspaces="$(grep -c ' $' "$file" || true)" + total="$(($ntabs + $nspaces))" + if [ "$total" != 0 ]; then + echo "E: $total lines with tabs in $file" + fi + ;; + esac +done