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

Closed
ErenYeager1836 wants to merge 1 commit from upstream-pr/5087 into main
ErenYeager1836 commented 2026-10-13 11:15:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-13T11:15:00Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4842364743 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5087). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-13T11:15:00Z. --- ### 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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 11:45:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:45:01Z.


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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144801021 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5087#issuecomment-6144801021). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T11:45:01Z. --- 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[bot] commented 2026-10-13 16:02:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T16:02:16Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149732575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5087#issuecomment-6149732575). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T16:02:16Z. --- <!-- pr-overlap --> 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](https://github.com/boykopovar/AnyPS5/blob/18c438b1092b09cef54e4cfacab441c009a6b501/core/libs/prx/libc/include/WindowsFormatting.hpp#L309), [L314-316](https://github.com/boykopovar/AnyPS5/blob/18c438b1092b09cef54e4cfacab441c009a6b501/core/libs/prx/libc/include/WindowsFormatting.hpp#L314-L316), [L393](https://github.com/boykopovar/AnyPS5/blob/18c438b1092b09cef54e4cfacab441c009a6b501/core/libs/prx/libc/include/WindowsFormatting.hpp#L393) | | | | #4164 | `docs/dev/debt/libc.md` [L68](https://github.com/boykopovar/AnyPS5/blob/18c438b1092b09cef54e4cfacab441c009a6b501/docs/dev/debt/libc.md#L68) | | |
ErenYeager1836 commented 2026-10-13 18:43:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-13T18:43:22Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152651099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5087#issuecomment-6152651099). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-13T18:43:22Z. --- Closing in favor of earlier open PR #3987 by @MarcZX100.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5087
No description provided.