summaryrefslogtreecommitdiff
path: root/build-aux/lint-h
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 22:32:10 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 23:05:00 -0700
commit1c0769fdc316a5e2982d8909e713050af223c928 (patch)
treedc4291c162b2299ac9082dc325342b94cad5c75e /build-aux/lint-h
parent536877a84b6ba93c6c228bee27b2c82691c3d733 (diff)
GNUmakefile: Pull lint/c, lint/all, and lint/unknown out into separate shell scripts
Diffstat (limited to 'build-aux/lint-h')
-rwxr-xr-xbuild-aux/lint-h19
1 files changed, 19 insertions, 0 deletions
diff --git a/build-aux/lint-h b/build-aux/lint-h
new file mode 100755
index 0000000..965d7d8
--- /dev/null
+++ b/build-aux/lint-h
@@ -0,0 +1,19 @@
+#!/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
+
+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
+ echo "$filename does not have ${guard} guard"; r=1
+ fi
+done
+exit $r