summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoramafresh325 <arminamayeh@gmail.com>2026-10-05 18:54:09 +0200
committerGitHub <noreply@github.com>2026-10-05 16:54:09 +0000
commit94f950f8d7a44e700a420b231bf600cf5a26994c (patch)
tree4c3d42ed3df3341f239612e917a982b477e81850 /scripts
parent7cdf69b20bc7743e445eee77728afd8f755a583d (diff)
German (#7315)
Co-authored-by: serprex <159546+serprex@users.noreply.github.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-no-tabs.sh9
-rwxr-xr-xscripts/check-whitespace.sh26
2 files changed, 26 insertions, 9 deletions
diff --git a/scripts/check-no-tabs.sh b/scripts/check-no-tabs.sh
deleted file mode 100755
index 8eccad28b..000000000
--- a/scripts/check-no-tabs.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-# Fail if any C/C++ source in soh/ outside soh/include contains a tab.
-
-cd "$(dirname "$0")/.." || exit 2
-
-if git --no-pager grep -n "$(printf '\t')" -- 'soh/*.c' 'soh/*.cpp' 'soh/*.h' 'soh/*.hpp' ':!soh/include'; then
- echo "replace tabs with spaces"
- exit 1
-fi
diff --git a/scripts/check-whitespace.sh b/scripts/check-whitespace.sh
new file mode 100755
index 000000000..878325187
--- /dev/null
+++ b/scripts/check-whitespace.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Fail if any C/C++ source in soh/ outside soh/include contains tabs or
+# trailing whitespace. Pass --fix to strip trailing whitespace in place
+# (tabs still need fixing by hand).
+
+cd "$(dirname "$0")/.." || exit 2
+
+# git grep over the checked sources, extra args go before the file list
+grep_sources() {
+ git --no-pager grep "$@" -- 'soh/*.c' 'soh/*.cpp' 'soh/*.h' 'soh/*.hpp' ':!soh/include'
+}
+
+if [ "$1" = "--fix" ]; then
+ grep_sources -lE '[[:space:]]+$' | xargs -r sed -i -E 's/[[:space:]]+$//'
+fi
+
+status=0
+if grep_sources -n "$(printf '\t')"; then
+ echo "replace tabs with spaces"
+ status=1
+fi
+if grep_sources -nE '[[:space:]]+$'; then
+ echo "remove trailing whitespace (or run with --fix)"
+ status=1
+fi
+exit $status