blob: 711e19c39db810a338fb8cb3f853f8da13700561 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/bin/bash
. "${0%/*}"/../lib.sh
#
# check for misc common typos
#
find "${top_srcdir}" \
'(' -type d -a '(' -name CVS -o -name tests ')' -prune ')' \
-o '(' -type f -a -print0 ')' | xargs -0 \
grep -n -I \
-e '\<compatability\>' \
-e '\<compatable\>' \
-e '\<fordeground\>' \
-e '\<depency\>' \
-e '\<defalt\>' \
-e '\<remaing\>' \
-e '\<queuing\>' \
-e '\<detatch\>' \
-e '\<sempahore\>' \
-e '\<reprenstative\>' \
-e '\<overriden\>' \
-e '\<readed\>' \
-e '\<formated\>' \
-e '\<algorithic\>' \
-e '\<deamon\>' \
-e '\<derefernce\>' \
-e '\<lenght\>' \
| sed -e "s:^\.\./\.\./::g" > src.typos
testit src.typos
#
# don't allow obsolete functions
#
find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs
testit src.obsolete.funcs
#
# make sure people use our constants
#
find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \
| sed -e "s:^\.\./\.\./::g" > src.bad.constants
testit src.bad.constants
#
# don't allow obsolete headers
#
find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.headers
testit src.obsolete.headers
#
# make sure people use the x* helper funcs
#
xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' "${top_srcdir}"/xfuncs.h))
xfuncs=${xfuncs:0:${#xfuncs}-1}
find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \
| grep -v xfuncs.c \
| sed -e "s:^\.\./\.\./::g" > src.use.xfuncs
testit src.use.xfuncs
#
# check for style
#
find "${top_srcdir}" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E \
-e '\<(for|if|switch|while)\(' \
-e '\<(for|if|switch|while) \( ' \
-e ' ;' \
-e '[[:space:]]$' \
-e '\){' \
-e '(^|[^:])//' \
| sed -e "s:^\.\./\.\./::g" > src.style
testit src.style
#
# Auto clean up the space issues
#
for x in $(find ../.. '(' -name '*.c' -o -name '*.h' ')' ); do
case ${x} in
*/elf.h) continue ;; # Not our files
esac
./space "$x" > "$x~"
if ! diff -u "$x" "$x~" ; then
echo "New file: $x~"
else
rm -f "$x~"
fi
done > src.space
testit src.space
#
# Python checks
#
if pyflakes </dev/null 2>/dev/null; then
find "${top_srcdir}" -name '*.py' -exec pyflakes {} + > src.pyflakes
testit src.pyflakes
fi
exit ${ret}
|