source: trunk/build/check-source @ 1886

Last change on this file since 1886 was 1886, checked in by sam, 8 years ago

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

  • Property svn:executable set to *
File size: 955 bytes
Line 
1#!/bin/sh
2
3set -e
4
5# Find out where the top directory is and go there
6top_srcdir="$(cd "$(dirname $0)"; cd ..; pwd)"
7cd "$top_srcdir"
8
9# Find out what kind of Vcs directory this is
10if [ -f "$top_srcdir/.git/index" ]; then
11    echo "I: detected Git repository"
12    repo=git
13elif [ -f "$top_srcdir/.svn/format" ]; then
14    echo "I: detected SVN repository"
15    repo=svn
16else
17    echo "I: not in a Vcs directory, nothing to do"
18    exit 0
19fi
20
21if [ "$repo" = git ]; then
22    git ls-files
23else
24    :
25fi | while read file; do
26    case "$file" in
27      src/bullet/*|contrib/*|people/*|*/generated/*)
28          : # These files aren't ours, don't fix
29          ;;
30      *.c|*.cpp|*.h)
31          ntabs="$(grep -c -P '\t' "$file" || true)"
32          nspaces="$(grep -c ' $' "$file" || true)"
33          total="$(($ntabs + $nspaces))"
34          if [ "$total" != 0 ]; then
35              echo "E: $total lines with tabs in $file"
36          fi
37          ;;
38    esac
39done
Note: See TracBrowser for help on using the repository browser.