Skip to content

Commit d9954c0

Browse files
libretroadminLibretroAdmin
authored andcommitted
tools/settings_migrate_group: the migrating table is not entangled with itself
Level-variant rows now pass through the front end, so the entanglement guard must scan every table except the one being migrated, and level-variant rows themselves are exempt - the guard exists to protect a plain row from a variant twin elsewhere, not to refuse the variant grammar it was waiting for.
1 parent 9c779f2 commit d9954c0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tools/settings_migrate_group.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def guard_of(text, pat):
175175
'SDESC_{BOOL,UINT,INT,FLOAT}_ROW; variant rows (_EX/_AT/_LV/...) are '
176176
'outside the def grammar - migrate this table manually or extend the '
177177
'grammar deliberately' % (len(all_invocations), len(rows)))
178-
assert rows and len(rows) == len(re.findall(r'SDESC_\w+_ROW(?:_P|_DS|_EX)?\(', tm.group(1))), (len(rows), tm.group(1)[:200])
178+
assert rows and len(rows) == len(re.findall(r'SDESC_\w+_ROW(?:_P|_DS|_EX|_LV)?\(', tm.group(1))), (len(rows), tm.group(1)[:200])
179179

180180
us = open('intl/msg_hash_us.h').read()
181181
ref_tokens = set()
@@ -210,7 +210,7 @@ def guard_of(text, pat):
210210
_tail = [r for r in rows if r[2] in ref_tokens]
211211
_ref_literals = {}
212212
for _k3, _f3, _t3, _a3 in _tail:
213-
_rm3 = re.search(r'[ \t]*SDESC_\w+_ROW(?:_P|_DS|_EX)?\(\s*%s,\s*%s,(?:[^()]|\((?:[^()]|\([^()]*\))*\))*\),?' % (_f3, _t3), body)
213+
_rm3 = re.search(r'[ \t]*SDESC_\w+_ROW(?:_P|_DS|_EX|_LV)?\(\s*%s,\s*%s,(?:[^()]|\((?:[^()]|\([^()]*\))*\))*\),?' % (_f3, _t3), body)
214214
assert _rm3, _t3
215215
_rl3 = _rm3.group(0).strip()
216216
for _g3 in reversed(guards.get(_f3 or _t3, ())):
@@ -244,10 +244,14 @@ def guard_of(text, pat):
244244
# migration zeroed the fullscreen override's default. Such tables
245245
# wait for the variant grammar.
246246
_ms_all = open('menu/menu_setting.c').read()
247+
# the migrating table's own body is not an entanglement with itself
248+
_ms_scan = _ms_all[:tm.start()] + _ms_all[tm.end():]
247249
for _k, _f, _T, _a in rows:
248-
_vm = re.search(r'SDESC_\w+_ROW_(?:LV|AT|AT_EX)\(%s,' % _f, _ms_all)
250+
if _k.endswith('_LV') or not _f:
251+
continue
252+
_vm = re.search(r'SDESC_\w+_ROW_(?:LV|AT|AT_EX)\(\s*%s,' % _f, _ms_scan)
249253
assert not _vm, ("field %s is entangled with a variant row" % _f,
250-
_ms_all[_vm.start():_vm.start()+60] if _vm else '')
254+
_ms_scan[_vm.start():_vm.start()+60] if _vm else '')
251255
print("extraction ok: %d settings (%d without sublabel)" % (len(rows), sum(1 for _,_,T,_ in rows if T not in ussub)))
252256

253257
cfg = open('configuration.c').read()

0 commit comments

Comments
 (0)