blob: 26ac13d55402e903ded133dbf3b7e8c4951d8226 (
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
|
#!/usr/bin/env bash
# build-aux/lint-h - Lint checks for C header files
#
# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
RED=$(tput setaf 1)
RESET=$(tput sgr0)
err() {
printf "${RED}%s${RESET}: %s\n" "$1" "$2" >&2
r=1
}
r=0
for filename in "$@"; do
dscname=$(./build-aux/get-dscname "$filename")
guard=${dscname//'/'/'_'}
guard=${guard//'.'/'_'}
guard="_${guard^^}_"
if ! { grep -Fxq "#ifndef ${guard}" "$filename" &&
grep -Fxq "#define ${guard}" "$filename" &&
grep -Fxq "#endif /* ${guard} */" "$filename"; }; then
err "$filename" "does not have ${guard} guard"
fi
done
exit $r
|