Browse Source

build: start working on a script to test source code problems.

legacy
Sam Hocevar sam 12 years ago
parent
commit
d4c77690d3
1 changed files with 39 additions and 0 deletions
  1. +39
    -0
      build/check-source

+ 39
- 0
build/check-source View File

@@ -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

Loading…
Cancel
Save