use explicit markers (comments) for the bsearch table checking, simplifies the scripts and makes them more robust too :)
This commit is contained in:
3
.github/checks/Makefile
vendored
3
.github/checks/Makefile
vendored
@@ -35,8 +35,9 @@ spaces: spaces.sh
|
||||
noexec: noexec.sh
|
||||
@./noexec.sh
|
||||
|
||||
sorted: sorted.sh sorted_codeopt.sh
|
||||
sorted: sorted.sh sorted_codeopt.sh sorted_opcodes.sh
|
||||
@./sorted.sh
|
||||
@./sorted_codeopt.sh
|
||||
@./sorted_opcodes.sh
|
||||
|
||||
endif
|
||||
|
||||
105
.github/checks/sorted.sh
vendored
105
.github/checks/sorted.sh
vendored
@@ -2,116 +2,39 @@
|
||||
OLDCWD=`pwd`
|
||||
SCRIPT_PATH=`dirname $0`
|
||||
|
||||
CHECK_DIR=../../src
|
||||
|
||||
SORT_OPT=-u
|
||||
|
||||
function checkarray_quoted_name
|
||||
{
|
||||
CHECK_FILE="$1"
|
||||
START="\\/\\* BEGIN SORTED.SH \\*\\/"
|
||||
END="\\/\\* END SORTED.SH \\*\\/"
|
||||
|
||||
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||
sed -e 's:.*\"\(.*\)\".*:\1:g' | \
|
||||
sed '/^\s*$/d' > .a.tmp
|
||||
awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \
|
||||
sed -e 's:\(.*\) ##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: "$2" table is empty"
|
||||
echo "error: "$1" table is empty"
|
||||
rm -rf .a.tmp
|
||||
exit -1
|
||||
fi
|
||||
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$2" definitions OK"
|
||||
echo ""$1" tables OK"
|
||||
else
|
||||
echo "error: "$2" definitions are not sorted."
|
||||
echo "error: "$1" tables are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
rm -rf .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
rm -rf .a.tmp .b.tmp
|
||||
}
|
||||
|
||||
function checkinstr_quoted_name
|
||||
{
|
||||
CHECK_FILE="$1"
|
||||
|
||||
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||
sed -e 's:^ *{$::g' | \
|
||||
sed -e 's:^ *}$::g' | \
|
||||
sed -e 's:.*\"\(.*\)\".*:\1:g' | \
|
||||
sed '/^\s*$/d' > .a.tmp
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: "$2" table is empty"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$2" definitions OK"
|
||||
else
|
||||
echo "error: "$2" definitions are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
rm -rf .a.tmp .b.tmp
|
||||
}
|
||||
|
||||
function checkopcodes_quoted_name
|
||||
{
|
||||
CHECK_FILE="$1"
|
||||
|
||||
awk '/'"$2"'/{flag=1;next}/};/{flag=0}flag' "$CHECK_FILE" | \
|
||||
grep "^ *\".*\"," | \
|
||||
sed '/^\s*$/d' > .a.tmp
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: "$2" table is empty"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$2" definitions OK"
|
||||
else
|
||||
echo "error: "$2" definitions are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
rm -rf .a.tmp .b.tmp
|
||||
}
|
||||
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502\.Ins\) \/ sizeof \(InsTab6502\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502X\.Ins\) \/ sizeof \(InsTab6502X\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab6502DTV\.Ins\) \/ sizeof \(InsTab6502DTV\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65C02\.Ins\) \/ sizeof \(InsTab65C02\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab4510\.Ins\) \/ sizeof \(InsTab4510\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTab65816\.Ins\) \/ sizeof \(InsTab65816\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabSweet16\.Ins\) \/ sizeof \(InsTabSweet16\.Ins\[0\]\),"
|
||||
checkinstr_quoted_name ../../src/ca65/instr.c "sizeof \(InsTabHuC6280\.Ins\) \/ sizeof \(InsTabHuC6280\.Ins\[0\]\),"
|
||||
|
||||
checkarray_quoted_name ../../src/ca65/scanner.c "} DotKeywords \[\] = {"
|
||||
|
||||
checkarray_quoted_name ../../src/cc65/codeinfo.c "static const FuncInfo FuncInfoTable\[\]"
|
||||
checkarray_quoted_name ../../src/cc65/codeinfo.c "static const ZPInfo ZPInfoTable\[\]"
|
||||
checkarray_quoted_name ../../src/cc65/codeoptutil.c "static const char\* const Tab\[\]"
|
||||
|
||||
checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncTable\[\]"
|
||||
checkarray_quoted_name ../../src/cc65/coptstop.c "static const OptFuncDesc FuncRegATable\[\]"
|
||||
|
||||
checkopcodes_quoted_name ../../src/cc65/opcodes.c "const OPCDesc OPCTable\[OP65_COUNT\] = {"
|
||||
checkarray_quoted_name ../../src/cc65/pragma.c "} Pragmas\[\] = {"
|
||||
checkarray_quoted_name ../../src/cc65/preproc.c "} PPDTypes\[\] = {"
|
||||
checkarray_quoted_name ../../src/cc65/scanner.c "} Keywords \[\] = {"
|
||||
checkarray_quoted_name ../../src/cc65/stdfunc.c "} StdFuncs\[\] = {"
|
||||
|
||||
checkarray_quoted_name ../../src/common/filetype.c "static const FileId TypeTable\[\]"
|
||||
checkarray_quoted_name ../../src/common/target.c "static const TargetEntry TargetMap\[\]"
|
||||
|
||||
checkarray_quoted_name ../../src/dbginfo/dbginfo.c "} KeywordTable\[\] = {"
|
||||
|
||||
checkarray_quoted_name ../../src/sp65/convert.c "static const ConverterMapEntry ConverterMap\[\]"
|
||||
checkarray_quoted_name ../../src/sp65/input.c "static const FileId FormatTable\[\]"
|
||||
checkarray_quoted_name ../../src/sp65/output.c "static const FileId FormatTable\[\]"
|
||||
checkarray_quoted_name ../../src/sp65/palconv.c "static const PaletteMapEntry PaletteMap\[\]"
|
||||
|
||||
for N in `grep -rl "BEGIN SORTED.SH" "$CHECK_DIR"`; do
|
||||
checkarray_quoted_name $N
|
||||
done
|
||||
|
||||
77
.github/checks/sorted_codeopt.sh
vendored
77
.github/checks/sorted_codeopt.sh
vendored
@@ -1,42 +1,61 @@
|
||||
#! /bin/bash
|
||||
OLDCWD=`pwd`
|
||||
SCRIPT_PATH=`dirname $0`
|
||||
CHECK_FILE=../../src/cc65/codeopt.c
|
||||
|
||||
CHECK_DIR=../../src
|
||||
|
||||
SORT_OPT=-u
|
||||
|
||||
grep "^static OptFunc " $CHECK_FILE | \
|
||||
sed -e 's:.*"\(.*\)",.*:\1:g' > .a.tmp
|
||||
function checkarray
|
||||
{
|
||||
CHECK_FILE="$1"
|
||||
START="\\/\\* BEGIN DECL SORTED_CODEOPT.SH \\*\\/"
|
||||
END="\\/\\* END DECL SORTED_CODEOPT.SH \\*\\/"
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: OptFunc table is empty"
|
||||
exit -1
|
||||
fi
|
||||
awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \
|
||||
sed -e 's:\(.*##\).*"\(.*\)",.*:\1\2:g' > .a.tmp
|
||||
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: "$1" table is empty"
|
||||
rm -rf .a.tmp
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo "static OptFunc definitions OK"
|
||||
else
|
||||
echo "error: static OptFunc definitions are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
|
||||
awk '/static OptFunc\* OptFuncs\[\] = {/{flag=1;next}/}/{flag=0}flag' $CHECK_FILE | \
|
||||
sed -e 's:.*&D\(.*\),:\1:g' > .a.tmp
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$1" decls OK"
|
||||
else
|
||||
echo "error: "$1" decls are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
rm -rf .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: OptFuncs table is empty"
|
||||
exit -1
|
||||
fi
|
||||
START="\\/\\* BEGIN SORTED_CODEOPT.SH \\*\\/"
|
||||
END="\\/\\* END SORTED_CODEOPT.SH \\*\\/"
|
||||
awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {print count,"##",$0}' "$CHECK_FILE" | \
|
||||
sed -e 's:\(.*##\).*&D\(.*\),.*:\1\2:g' > .a.tmp
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo "static OptFuncs* OptFuncs[] definitions OK"
|
||||
else
|
||||
echo "error: static OptFuncs* OptFuncs[] definitions are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
|
||||
echo "error: "$1" table is empty"
|
||||
rm -rf .a.tmp
|
||||
exit -1
|
||||
fi
|
||||
|
||||
rm -rf .a.tmp .b.tmp
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$1" tables OK"
|
||||
else
|
||||
echo "error: "$1" tables are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
rm -rf .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
|
||||
rm -rf .a.tmp .b.tmp
|
||||
}
|
||||
|
||||
|
||||
for N in `grep -rl "BEGIN DECL SORTED_CODEOPT.SH" "$CHECK_DIR"`; do
|
||||
checkarray $N
|
||||
done
|
||||
|
||||
42
.github/checks/sorted_opcodes.sh
vendored
Executable file
42
.github/checks/sorted_opcodes.sh
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
#! /bin/bash
|
||||
OLDCWD=`pwd`
|
||||
SCRIPT_PATH=`dirname $0`
|
||||
|
||||
CHECK_DIR=../../src
|
||||
|
||||
SORT_OPT=-u
|
||||
|
||||
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 {print 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
|
||||
|
||||
LC_COLLATE=C sort $SORT_OPT .a.tmp > .b.tmp
|
||||
|
||||
if cmp --silent -- .a.tmp .b.tmp; then
|
||||
echo ""$1" tables OK"
|
||||
else
|
||||
echo "error: "$1" tables are not sorted."
|
||||
diff -y .a.tmp .b.tmp
|
||||
rm -rf .a.tmp .b.tmp
|
||||
exit -1
|
||||
fi
|
||||
rm -rf .a.tmp .b.tmp
|
||||
}
|
||||
|
||||
for N in `grep -rl "BEGIN SORTED_OPCODES.SH" "$CHECK_DIR"`; do
|
||||
checkarray_quoted_name $N
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user