fix: never nudge a ref that cites code

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 13:23:41 +02:00
1 parent de0b494ee5
commit 8605f85657
2 files changed
+14 -2

No files matched your search

+5
View File
@@ -884,6 +884,11 @@ def nudge_to_declared(
"""
if not tokens:
return None
if end > start and any(line.strip() for line in pin_lines[start - 1:end]):
# A range over code cites that code (a loading function), not the
# value beside it. Moved onto the nearest name, ymir's 598-618 left
# load_rom_cartridge() and a real change read as a silent SHIFTED.
return None
lowered = [line.lower() for line in pin_lines]
hits = [
i + 1
+9 -2
View File
@@ -783,11 +783,18 @@ class TestNudgeToDeclared(unittest.TestCase):
)
def test_range_length_is_kept(self):
lines = [""] * 20 + ["ROM_START( stvbios )"] + ["pad"] * 20
self.assertEqual(
profile_sync.nudge_to_declared(self.LINES, 19, 22, ["stvbios"]),
(21, 24),
profile_sync.nudge_to_declared(lines, 17, 19, ["stvbios"]),
(21, 23),
)
def test_a_range_over_code_cites_that_code(self):
"""ymir's 598-618 cited load_rom_cartridge(); nudged onto the file
table beside it, a rewritten function read SHIFTED, not CHANGED."""
lines = ["void load_rom_cartridge() {"] + [" code();"] * 19 + ["}", "kKOF95Files"]
self.assertIsNone(profile_sync.nudge_to_declared(lines, 1, 21, ["kkof95files"]))
def test_nothing_when_already_on_target(self):
self.assertIsNone(
profile_sync.nudge_to_declared(self.LINES, 21, 21, ["stvbios"])