Files
cc65/.github/checks/sorted_opcodes.sh
Kugel Fuhr c7096ab6d7 Fix an error that was introduced by me in a4a24280f2:
Using a pipe causes a subshell to be generated so the "exit" statements will
just leave the subshell. As a consequence, the sortedxxx.sh scripts produced
output but no error exit code. Which in turn caused an error in #2778 to slip
through undetected.
2025-07-13 17:56:31 +02:00

42 lines
997 B
Bash
Executable File

#! /bin/bash
OLDCWD=`pwd`
SCRIPT_PATH=`dirname $0`
CHECK_DIR=../../src
SORT_OPT="-u -c"
# $1: filename
function checkarray_quoted_name
{
CHECK_FILE="$1"
START="\\/\\* BEGIN SORTED_OPCODES.SH \\*\\/"
END="\\/\\* END SORTED_OPCODES.SH \\*\\/"
awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {printf("%04d##%s\n", count, $0)}' "$CHECK_FILE" | \
sed 's:/\*.*::g' | \
grep '".*",' | \
sed -e 's:\(.*\)##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
echo "error: "$1" table is empty"
rm -rf .a.tmp
exit -1
fi
if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then
echo ""$1" tables OK"
else
echo "error: "$1" tables are not sorted."
rm -rf .a.tmp
exit -1
fi
rm -rf .a.tmp
}
FILES=$(find "$CHECK_DIR" -name \*.\[ch\] -print)
for N in $FILES; do
grep -q "BEGIN SORTED_OPCODES.SH" "$N" && checkarray_quoted_name "$N"
done
exit 0