blob: 7c5516d0a17dd0c018f4cf2929174953d867b64a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh
if [ -n "$(grep -En '[a-z]+\(\) {' "$@")" ]; then
echo 'Functions with no argument without explicit "void" parameter:' >&2
grep -En '[a-z]+\(\) {' "$@"
exit 1
fi
awk '
/^[a-zA-Z0-9_]+.+{$/ && !/^static / {
match($0, /[a-zA-Z0-9_]+\(/)
fn_name = substr($0, RSTART, RLENGTH - 1)
if (fn_name != "main") {
header = substr(FILENAME, 0, length(FILENAME) - 1) "h"
if (system("grep -qF \"" fn_name "(\" " header)) {
print "non-static function is not declared in a header:"
printf "%s:%s:%s\n", FILENAME, FNR, $0
exit 1
}
}
}
' "$@"
|