summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-30 12:55:04 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-30 12:55:04 -0500
commite6f5177cb5e68765cd85c2293f88c9ffa119110a (patch)
tree15bacaf02ec6831d5763580d12d0b09c273a7276 /scripts
parentbacebb3df1fc96a2cbb5f196e4bff5a0977db425 (diff)
add script to verify sources have standard indicators and signal safety indicators
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/check.sh b/scripts/check.sh
new file mode 100755
index 00000000..307f3533
--- /dev/null
+++ b/scripts/check.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+check_standard() {
+ if ! (grep -q -F -e 'STDC(' -e 'POSIX(' -e 'XOPEN(' "$1"); then
+ printf '%s has no standard declaration\n' "$1"
+ fi
+}
+
+check_signal_safety() {
+ if ! (grep -q -F 'SIGNAL_SAFE(' "$1"); then
+ printf '%s has no signal safety information\n' "$1"
+ fi
+}
+
+check_file() {
+ check_standard $1
+ check_signal_safety $1
+}
+
+if [ $# -eq 0 ]; then
+ DIR=$(dirname $0)/../src
+ find "${DIR}" -name \*.c -exec sh $0 {} + | sed -e "s#^${DIR}#src#g"
+else
+ while [ $# -gt 0 ]; do
+ if [ -d $1 ]; then
+ find "$1" -name \*.c -exec sh $0 {} +
+ else
+ check_file $1
+ fi
+ shift
+ done
+fi