diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index 6e1baac3..74d96c88 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -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 diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index 6e057b03..beb90d48 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -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"])