blob: 42d185c655761a78bea2543b37ba3514f8987756 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
RE='[a-z]+\(\) {'
if grep -Eq "$RE" "$@"; then
echo 'Functions with no argument without explicit "void" parameter:' >&2
grep -En "$RE" "$@"
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
}
}
}
' "$@"
|