Skip to content

Commit b8a8c32

Browse files
committed
fix(inf): correct deprecated CRC= separated-value lookup
The deprecated CRC form ("CRC= 1A2B" with a space after the equals) was never matched because the code checked for the literal key "CRC=" in the extra_info dict instead of "CRC". The dict key is always the part before the equals sign, so the condition was dead code.
1 parent f5cd750 commit b8a8c32

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/beebtools/inf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def parseInf(line: str) -> InfData:
491491
# A single "CRC=" token is handled above; the deprecated form
492492
# shows up as two tokens: "CRC=" and a hex field. We only
493493
# honour this when the "CRC=" key has no value attached.
494-
if "CRC=" in extra_info and extra_info.get("CRC") == "":
494+
if "CRC" in extra_info and extra_info.get("CRC") == "":
495495
extra_info["CRC"] = token
496496
idx += 1
497497
continue

tests/test_inf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ def testLockBeforeCrc(self) -> None:
103103
assert result.locked is True
104104
assert result.crc == 0xABCD
105105

106+
def testDeprecatedCrcSeparatedValue(self) -> None:
107+
"""Deprecated CRC= with a space before the value is accepted."""
108+
result = parseInf("$.BOOT FF1900 FF8023 000A00 CRC= 1A2B")
109+
110+
assert result.crc == 0x1A2B
111+
assert result.extra_info["CRC"] == "1A2B"
112+
106113

107114
# =======================================================================
108115
# parseInf - syntax 3 (name access) - ADFS Explorer directory form

0 commit comments

Comments
 (0)