Skip to content

fix(libc): print the FreeBSD printf extensions and stray percent signs on Windows - #5087

Closed
ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libc-windows-printf-freebsd-extensions
Closed

ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libc-windows-printf-freebsd-extensions

Conversation

@ErenYeager1836

@ErenYeager1836 ErenYeager1836 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

The Windows printf formatting implementation threw on the FreeBSD q length modifier (%qd, %qu, etc.), %D, %O and %U conversions, unknown conversion characters, and formats ending with a trailing %.

  • Handles the q length modifier by mapping to 64-bit integer formatting (ll).
  • Maps %D, %O and %U conversions to long formats per FreeBSD 11.4 vfprintf.c.
  • Prints unknown conversion characters as characters rather than throwing.
  • Stops cleanly at a trailing % character.
  • Adds test coverage in core/libs/tests/Formatting.cpp.
  • Records technical debt in docs/dev/debt/libc.md.

Carried from @husseinkadhim with attribution preserved.

Tested

Windows and Linux: core/libs/tests/Formatting.cpp test suite passes for FreeBSD printf conversion extensions.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: none
  • AI-assisted: yes

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Review note (static): behavior matches FreeBSD 11.4 vfprintf.c as far as I checked: %D, %O, %U act as %ld, %lo, %lu, a conversion character that is not known prints as %c with that character (including width), and a format that ends in % ends the output. One question: for %hD/%hhD the code switches to l, which agrees with FreeBSD where the long flag takes precedence over the short flag; a test line for %hhD would pin that. The tests sit in the Windows-only part of Formatting.cpp; the description does not say whether they were run on Windows. The branch also edits docs/dev/debt/libc.md at the end of the file, where #5070 and #4981 add entries too, so expect a rebase of the debt file when one of them lands.

AI-assisted (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@ErenYeager1836
ErenYeager1836 force-pushed the carry/libc-windows-printf-freebsd-extensions branch from e580118 to 112f000 Compare October 13, 2026 14:03
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
…s on Windows

The Windows printf family threw on the q length modifier, the D, O and U conversions, an unknown conversion character and a format ending in a percent sign, where FreeBSD's vfprintf formats the first three and prints the unknown character itself or stops at the end of the format.
@ErenYeager1836
ErenYeager1836 force-pushed the carry/libc-windows-printf-freebsd-extensions branch from 112f000 to 8f18b7a Compare October 13, 2026 15:58
@github-actions

github-actions Bot commented Oct 13, 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
#3987 core/libs/prx/libc/include/WindowsFormatting.hpp L309, L314-316, L393
#4164 docs/dev/debt/libc.md L68

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@ErenYeager1836

Copy link
Copy Markdown
Contributor Author

Closing in favor of earlier open PR #3987 by @MarcZX100.

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