#!/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"