aboutsummaryrefslogtreecommitdiff
blob: b7b35674de0d0455804721146642d18603bece27 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash

. "${0%/*}"/../lib.sh

findfiles() {
	find "${top_srcdir}" \
		'(' -type d -a '(' -name CVS -o -name .git -o -name autotools ')' -prune ')' \
		-o '(' '(' -name '*.[ch]' -a ! -name 'config.h' ')' -print0 ')'
}

#
# check for misc common typos
#
find "${top_srcdir}" \
	'(' -type d -a '(' -name CVS -o -name .git -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
#
findfiles | 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
#
findfiles | 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
#
findfiles | 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}
findfiles | 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
#
findfiles | 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
#
while read -d'\0' x; 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 < <(findfiles)
testit src.space



#
# Make sure we don't keep re-importing stuff into elf.h that
# breaks non-GNU systems. #507470
#
grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > src.elf.h
testit src.elf.h



#
# Python checks
#
if pyflakes </dev/null 2>/dev/null; then
	find "${top_srcdir}" \
		'!' -ipath '*/tests/*' \
		-name '*.py' \
		-exec pyflakes {} + > src.pyflakes
	testit src.pyflakes
fi



exit ${ret}