diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:56:51 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 12:56:59 -0300 |
| commit | b7b08a7d29d84de187dd8a55e0c94de66b07a572 (patch) | |
| tree | 7e55661d3eca3cf3b16aada6e87eabee68802fb9 /tools | |
| download | asm-b7b08a7d29d84de187dd8a55e0c94de66b07a572.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/style.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/style.sh b/tools/style.sh new file mode 100755 index 0000000..08e40b1 --- /dev/null +++ b/tools/style.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Read-only style check: no tabs, no trailing whitespace, nothing past 80 +# columns, and every .S file must declare a non-executable stack. + +set -eu + +here=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +status=0 + +for file in "$here"/src/*.S "$here"/src/*.inc "$here"/include/*.h \ + "$here"/tests/*.c "$here"/examples/*.c; do + [ -e "$file" ] || continue + name=${file#"$here"/} + if grep -n ' ' "$file" >/dev/null 2>&1; then + echo "$name: contains a tab" >&2 + grep -n ' ' "$file" | head -5 >&2 + status=1 + fi + if grep -n '[ ]$' "$file" >/dev/null 2>&1; then + echo "$name: trailing whitespace" >&2 + grep -n '[ ]$' "$file" | head -5 >&2 + status=1 + fi + if awk 'length > 80 { print FILENAME ":" FNR ": line over 80 columns"; f=1 } + END { exit f ? 1 : 0 }' "$file" >&2; then + : + else + status=1 + fi +done + +for file in "$here"/src/*.S; do + name=${file#"$here"/} + if ! grep -q 'note.GNU-stack' "$file"; then + echo "$name: missing .note.GNU-stack" >&2 + status=1 + fi +done + +if [ "$status" -eq 0 ]; then + echo "style: ok" +fi +exit "$status" |