Debian Codegraph @

caca/t/check-source

raw
1 #!/bin/sh
2
3 export MAKEFLAGS=""
4 top_srcdir="$(make -s echo-topdir)"
5
6 #
7 # Check that we have no tabs or trailing spaces in the source code
8 #
9 nfails=0
10 nfiles=0
11 nlines=0
12 for dir in $(make -s echo-dirs -C "${top_srcdir}"); do
13 if [ ! -d "${top_srcdir}/${dir}" ]; then continue; fi
14 for x in $(make -s echo-sources -C "${top_srcdir}/${dir}"); do
15 case "$x" in
16 *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|*.py|*.pl)
17 nfiles=$(($nfiles + 1));
18 nlines=$(($nlines + `grep -c . "${top_srcdir}/${dir}/$x"`)) ;;
19 *)
20 continue ;;
21 esac
22 if grep '[[:space:]]$' "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
23 echo "error: ${dir}/$x contains trailing spaces"
24 nfails=$(($nfails + 1))
25 fi
26 if grep ' ' "${top_srcdir}/${dir}/$x" >/dev/null 2>&1; then
27 echo "error: ${dir}/$x contains tabs"
28 nfails=$(($nfails + 1))
29 fi
30 done
31 done
32
33 echo "$nfiles files, $nlines lines, $nfails errors in source code"
34
35 if test "$nfails" != "0"; then
36 exit 1
37 fi
38
39 exit 0
40