Skip to content

fix(libc): preserve strftime literal conversions - #3653

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
QRMOE:fix-libc-strftime-literal-conversions
Oct 12, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
QRMOE:fix-libc-strftime-literal-conversions

Conversation

@QRMOE

@QRMOE QRMOE commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What

strftime("%Q") currently returns 0 on Windows instead of the literal Q produced by FreeBSD 11.4. A trailing %, incomplete modifiers and repeated E/O or padding modifiers have the same host-dependent problem.

Parse those literals before calling the host formatter, escaping literal percent signs so a following character cannot become a new conversion. Preserve ordinary conversions and the existing %k, %l, %s, %v and %+ expansion. Update TechnicalDebt to retain the remaining padding and timezone gaps.

The behavior follows _fmt in FreeBSD 11.4 strftime.c, including its repeated-modifier and end-of-format branches. %P is unknown in that version and becomes literal P.

Tested

  • Windows, MinGW GCC 15.2, Release: full default build and explicit libs target passed.
  • The added guest_time_conversion regression fails against unchanged main at %Q and passes with this fix. It covers 27 format cases, exact-fit and undersized buffers, empty formats and a zero-size buffer.
  • guest_time_conversion, guest_formatting, guest_wide_formatting, guest_errors, guest_locale and guest_freebsd_clocks passed five consecutive runs each (30 executions).
  • External comparison of the built library's two entry points with FreeBSD 11.4's original parser/helpers and C locale: 35,032 formats, 350,320 buffer/alias checks per run, zero mismatches with the reference compiled at -O0 and -O3. Portability shims replace locale lookup, types and host mktime; known padded conversions and standalone %z/%Z are excluded. No reference code or investigation files are added to the repository.
  • Reviewed actual library diffs from 209 open PR heads. feat(libc): implement wcsftime #3637 adds wcsftime in the same source file and delegates to the existing strftime; it does not implement this literal-conversion fix. A merge check combines the source automatically; the adjacent TechnicalDebt changes need resolution if both PRs merge. The closed timezone fix fix(libc): preserve guest time zones in Windows strftime #2665 is a separate gap.
  • Conventions checker and git diff --check passed. Linux runtime and console/game testing were not performed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

QRMOE added 3 commits October 11, 2026 16:51
Normalize FreeBSD 11.4 literal conversions before host formatting.

AI-assisted: yes
Exercise unknown, repeated and incomplete conversions, percent escaping and buffer boundaries.

AI-assisted: yes
Record literal handling while retaining unimplemented padding and timezone gaps.

AI-assisted: yes
@blawesom

Copy link
Copy Markdown
Contributor

Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4226 docs/dev/TechnicalDebt.md L635

@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
6 tasks done
@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@oneandonlydean
oneandonlydean merged commit 6913861 into boykopovar:main Oct 12, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants