view lint/lint-rules.sh @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

#!/bin/sh
# lint-rules.sh - generate make rules for lint dir
# usage: lint-rules.sh > rules.mk

if [ $# != 0 ]; then
    echo "$0: usage: $0" 1>&2
    exit 1
fi

SOURCESETS='tool main example'


# generate the lists of sources

for S in $SOURCESETS; do
    if [ ! -f $S.srcs ]; then
	echo "$0: $S.srcs missing - rerun make rules?"
	exit 1
    fi

    echo $S | tr a-z A-Z | awk '{ printf "%sSRCS=\\\n", $1 }'
    sed < $S.srcs 's/^/    /;s/$/ \\/;$s/ \\$//'
    echo
done

for S in $SOURCESETS; do 
    awk < $S.srcs '
    {
	file=$1;
	base=file;
	sub(".*/", "", base);
	base = set "-" base;
	ok = sprintf("$(TOP)/lint/ok/%s.ok", base)

	printf "%s.lint: $(TOP)/%s $(CHECK)\n", base, file;
	printf "\t@echo \"        [CHECK]   %s\"\n", base;
	printf "\t@$(CHECK) --%s \"$(TOP)\" %s > %s.lint\n", set, file, base;
	printf "\n";

	printf "%s.diff: %s.lint %s\n", base, base, ok;
	printf "\t@diff %s %s.lint | tee %s.diff\n", ok, base, base;
	printf "\n";

	printf "all: %s.diff\n", base;
	printf "\n";
    }
    ' "set=$S"
done