Skip to content

fix: stop cleanName truncating titles that contain a dot - #26

Merged
lepht merged 1 commit into
mainfrom
claude/adopt-upstream-722-cleanname
Aug 12, 2026
Merged

fix: stop cleanName truncating titles that contain a dot#26
lepht merged 1 commit into
mainfrom
claude/adopt-upstream-722-cleanname

Conversation

@lepht

@lepht lepht commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Adopted from upstream LoveRetro/NextUI#722 by @ericreinsmidt.

The bug

cleanName() ran removeExtension() over names the game time db already stores without one, so the first dot in a title was read as a suffix boundary:

stored name displayed as
Gun.Smoke Gun
Dr.Mario Dr

removeExtension() has a guard (*(lastExt+1) != ' ') that spares 001. Sonic, which is why this only ever bit titles with a dot followed by a non-space.

The fix

Drop the removeExtension() call and its free(). Both callers in this tree — gametime.c:250 and gametimedb.c:462 — pass rom->name, which is stored extension-free, so no caller relied on the stripping. I also checked feat/favorites and feat/rom-search: neither adds a cleanName caller, so the in-flight stack is unaffected.

Testing

tests/test_utils.c already links utils.c, so this is covered directly. The tests were written before the fix and confirmed to fail on exactly the two truncation cases:

- cleanName
  FAIL  cleanName: keeps a dot that is part of the title
  FAIL  cleanName: keeps a dot with no space after it

The four other checks — numeric sorting prefixes, underscores, region parens, multi-dot titles like R.C. Pro-Am — passed before and after, so the change is bounded to the reported defect. make test is green.

Why now

Upstream is mid-transition from GPL-3.0 to PolyForm Noncommercial (LoveRetro/NextUI#765). Their LICENSE is still GPL-3.0 today, so this is adoptable now; code taken after the transition would not be. Original authorship is preserved in the commit trailer.

Adopted from upstream LoveRetro#722 by Eric Reinsmidt, taken while
upstream is still GPL-3.0 (see LoveRetro#765).

cleanName() ran removeExtension() over names the game time db already
stores without one, so the first dot in a title was read as a suffix
boundary. "Gun.Smoke" displayed as "Gun" and "Dr.Mario" as "Dr".

Both callers in this tree - gametime.c and gametimedb.c - pass rom->name,
which is stored extension-free, so dropping the removeExtension() call is
safe for every caller we have.

Covered in tests/test_utils.c: the two truncation cases fail without the
fix, alongside guards for the behaviour that has to survive it - numeric
sorting prefixes, underscores and region parens.

Co-Authored-By: Eric Reinsmidt <eric@reinsmidt.com>
@lepht
lepht force-pushed the claude/adopt-upstream-722-cleanname branch from c2c4d44 to 39c3ccd Compare August 12, 2026 04:14
@lepht
lepht merged commit 2e3193e into main Aug 12, 2026
62 checks passed
@lepht
lepht deleted the claude/adopt-upstream-722-cleanname branch August 12, 2026 04:22
lepht pushed a commit that referenced this pull request Aug 12, 2026
Brings in the three upstream adoptions (#26, #27, #28) now on main.

One conflict, in the scroll-text block of nextui.c. Both sides edited
adjacent lines for unrelated reasons:

  - this branch added SCREEN_CONTEXTMENU to the outer screen exclusion list
  - #27 added a total>0 guard to the inner condition

Resolved as the union of both, which is the only correct answer here.
Taking ours alone drops total>0 and reopens #6 two lines above the
top->entries->items[top->selected] read; taking theirs alone drops the
context menu exclusion and renders scroll text over it.

Git auto-merged the other five guard sites #27 added. Verified after the
merge: no assert(entry) remains, every read of entries->items[top->selected]
sits behind a count or total>0 check, nextui.c is syntax-clean against the
desktop platform headers, and make test passes.
lepht pushed a commit that referenced this pull request Aug 12, 2026
Carries the main merge (and with it #26, #27, #28) up the stack.

Same single conflict as one level down, in the same two lines of nextui.c:
this branch had added SCREEN_SEARCH to the outer screen exclusion list on
top of SCREEN_CONTEXTMENU, while #27 added a total>0 guard to the inner
condition. Resolved as the union again - all four screen exclusions kept,
total>0 kept.

Verified after the merge: no assert(entry) remains, every read of
entries->items[top->selected] is guarded, nextui.c is syntax-clean against
the desktop platform headers, and make test passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants