diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-27 23:07:51 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-27 23:07:51 -0700 |
commit | 1e2b67047da4ad0f567ef5956f813b2d33b3cfa6 (patch) | |
tree | 5f186c02fd3649894f2a5c28c2db6efa3abf9df6 /build-aux/lint-h | |
parent | f7b7c04e2ebb24ccae89b77ce76f0b405eb213d1 (diff) | |
parent | 3199e6a45fd5e8bd9ec44616d5dcfb856ba6a888 (diff) |
Merge branch 'lukeshu/lint'
Diffstat (limited to 'build-aux/lint-h')
-rwxr-xr-x | build-aux/lint-h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/build-aux/lint-h b/build-aux/lint-h new file mode 100755 index 0000000..26ac13d --- /dev/null +++ b/build-aux/lint-h @@ -0,0 +1,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 |