Scan auf nicht-CP437-Zeichen in Ink-Buildscript
This commit is contained in:
@@ -54,12 +54,37 @@ if [ ! -d "$ink_dir" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Prüft eine .ink-Datei auf Zeichen außerhalb von CP437 und gibt sie aus.
|
||||||
|
# Exit-Code 1 wenn Treffer gefunden, sonst 0.
|
||||||
|
check_cp437() {
|
||||||
|
python3 - "$1" <<'PYEOF'
|
||||||
|
import sys
|
||||||
|
path = sys.argv[1]
|
||||||
|
cp437 = set(bytes(range(256)).decode('cp437', errors='replace'))
|
||||||
|
hits = []
|
||||||
|
with open(path, encoding='utf-8') as f:
|
||||||
|
for lineno, line in enumerate(f, 1):
|
||||||
|
for ch in line:
|
||||||
|
if ord(ch) > 127 and ch not in cp437:
|
||||||
|
hits.append(f' Z.{lineno}: U+{ord(ch):04X} {repr(ch)}')
|
||||||
|
for h in hits:
|
||||||
|
print(h)
|
||||||
|
sys.exit(1 if hits else 0)
|
||||||
|
PYEOF
|
||||||
|
}
|
||||||
|
|
||||||
built=0 skipped=0 failed=0
|
built=0 skipped=0 failed=0
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for src in "$ink_dir"/*.ink; do
|
for src in "$ink_dir"/*.ink; do
|
||||||
out="${src%.ink}.ink.json"
|
out="${src%.ink}.ink.json"
|
||||||
name="$(basename "$src")"
|
name="$(basename "$src")"
|
||||||
|
|
||||||
|
# CP437-Warnung: läuft immer, unabhängig vom Build-Status.
|
||||||
|
if ! cp437_warn="$(check_cp437 "$src")"; then
|
||||||
|
printf ' WARNUNG %s -- Nicht-CP437-Zeichen:\n' "$name"
|
||||||
|
printf '%s\n' "$cp437_warn"
|
||||||
|
fi
|
||||||
|
|
||||||
# Inkrementell: überspringen, wenn Ausgabe existiert und neuer ist.
|
# Inkrementell: überspringen, wenn Ausgabe existiert und neuer ist.
|
||||||
if [ "$force" -eq 0 ] && [ -f "$out" ] && [ "$out" -nt "$src" ]; then
|
if [ "$force" -eq 0 ] && [ -f "$out" ] && [ "$out" -nt "$src" ]; then
|
||||||
printf ' aktuell %s\n' "$name"
|
printf ' aktuell %s\n' "$name"
|
||||||
|
|||||||
Reference in New Issue
Block a user