Make gbdiff.bash handle CRLF sym files gracefully

Additionally, reduce the amount of lines piped through `cut`,
improving performance
This commit is contained in:
ISSOtm
2020-12-26 02:47:04 +01:00
parent d8e8b796e7
commit f82edaa7ec

View File

@@ -50,12 +50,14 @@ diff <(xxd $1) <(xxd $2) | while read -r LINE; do
EXTRA=$(if [ -f "$SYMFILE" ]; then EXTRA=$(if [ -f "$SYMFILE" ]; then
# Read the sym file for such a symbol # Read the sym file for such a symbol
# Ignore comment lines, only pick matching bank # Ignore comment lines, only pick matching bank
cut -d ';' -f 1 "$SYMFILE" | # (The bank regex ignores comments already, make `cut` and `tr` process less lines)
grep -Ei $(printf "^%02x:" $BANK) | grep -Ei $(printf "^%02x:" $BANK) "$SYMFILE" |
cut -d ';' -f 1 |
tr -d "\r" |
while read -r SYMADDR SYM; do while read -r SYMADDR SYM; do
SYMADDR=$((0x${SYMADDR#*:})) SYMADDR=$((0x${SYMADDR#*:}))
if [ $SYMADDR -le $ADDR ]; then if [ $SYMADDR -le $ADDR ]; then
printf " (%s+%#x)\n" $SYM $(($ADDR - $SYMADDR)) printf " (%s+%#x)\n" "$SYM" $(($ADDR - $SYMADDR))
fi fi
# TODO: assumes sorted sym files # TODO: assumes sorted sym files
done | tail -n 1 done | tail -n 1