ref: f82edaa7ec6a2b9eed73f2a35819ae9e254cea54
parent: d8e8b796e7aa15956f1e648edbdc9ab6f7edb555
author: ISSOtm <eldredhabert0@gmail.com>
date: Fri Dec 25 21:47:04 EST 2020
Make gbdiff.bash handle CRLF sym files gracefully Additionally, reduce the amount of lines piped through `cut`, improving performance
--- a/contrib/gbdiff.bash
+++ b/contrib/gbdiff.bash
@@ -50,12 +50,14 @@
EXTRA=$(if [ -f "$SYMFILE" ]; then
# Read the sym file for such a symbol
# Ignore comment lines, only pick matching bank
- cut -d ';' -f 1 "$SYMFILE" |
- grep -Ei $(printf "^%02x:" $BANK) |
+ # (The bank regex ignores comments already, make `cut` and `tr` process less lines)
+ grep -Ei $(printf "^%02x:" $BANK) "$SYMFILE" |
+ cut -d ';' -f 1 |
+ tr -d "\r" |
while read -r SYMADDR SYM; do
SYMADDR=$((0x${SYMADDR#*:}))
if [ $SYMADDR -le $ADDR ]; then
- printf " (%s+%#x)\n" $SYM $(($ADDR - $SYMADDR))
+ printf " (%s+%#x)\n" "$SYM" $(($ADDR - $SYMADDR))
fi
# TODO: assumes sorted sym files
done | tail -n 1