Skip to content

Commit ebdae45

Browse files
libretroadminLibretroAdmin
authored andcommitted
intl: drop def-file pass markers and duplicate guards from emitted headers
The first hardened Crowdin sync exposed two emitter defects. The template expansion dropped only guards alternated with the strings pass, so the config-pass wrapper around divergent-key rows - a form added later - leaked '#ifndef SETTINGS_DEF_CONFIG_PASS' into every translated header; harmless only because no msg_hash consumer defines that macro. And a def row's own platform guard repeated an enclosing template guard verbatim, nesting '#ifdef HAVE_MICROPHONE' inside itself. Expansion now treats every SETTINGS_DEF marker as the always-true def-file internal it is, and guard emission drops a plain condition that is already open; else-branches are never deduplicated. All 47 headers re-emitted through the fixed emitter: idempotent, no pass markers, no duplicated guards, guard-balanced, and the full-language lookup output is byte-identical against the sync-landed tree - the cleanup is purely structural. The sync itself audits clean against its parent: six translation values changed and six added, nothing removed, no artifacts.
1 parent 65692e0 commit ebdae45

41 files changed

Lines changed: 58 additions & 5521 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

intl/json2h.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def def_to_rows(def_text):
6565
# A guard alternated with the strings pass is always true
6666
# for string consumers; this expansion mirrors the us.h
6767
# consumer, which defines the pass, so drop the pair.
68-
if 'SETTINGS_DEF_STRINGS_PASS' in ls:
68+
if 'SETTINGS_DEF' in ls:
69+
# Pass markers - strings-pass alternations, the
70+
# config-pass wrapper on divergent-key rows, the
71+
# enum-pass alias shells - are def-file internals,
72+
# always true for string consumers; drop the pair.
6973
skip_endif.append(True)
7074
i = line_end + 1
7175
continue
@@ -380,7 +384,21 @@ def parse_rows_with_guards(text):
380384
'#pragma warning(disable:4045)\n'
381385
'#endif\n')
382386

387+
def dedup_guards(g):
388+
# A def row's own platform guard can repeat an enclosing template
389+
# guard; nested identical plain guards are meaningless, so emit
390+
# each open condition once. Else-branches are never deduplicated.
391+
out, open_conds = [], set()
392+
for cond, in_else in g:
393+
if not in_else and cond in open_conds:
394+
continue
395+
out.append((cond, in_else))
396+
open_conds.add(cond)
397+
return tuple(out)
398+
383399
def emit_guard_transition(out, prev, cur):
400+
prev = dedup_guards(prev)
401+
cur = dedup_guards(cur)
384402
if prev == cur:
385403
return
386404
for _ in prev:

0 commit comments

Comments
 (0)