From b7b08a7d29d84de187dd8a55e0c94de66b07a572 Mon Sep 17 00:00:00 2001 From: Murilo Ijanc Date: Sun, 26 Jul 2026 12:56:51 -0300 Subject: Initial import --- tools/style.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 tools/style.sh (limited to 'tools') 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" -- cgit v1.3