fix(libc): format FreeBSD-only printf conversions and reject the rest instead of aborting #4995

Closed
ErenYeager1836 wants to merge 1 commit from upstream-pr/4995 into main
ErenYeager1836 commented 2026-10-13 07:36:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-13T07:36:28Z.


Carries husseinkad:fix/libc-format-freebsd-conversions. Fixes #3975.

What

On the Windows formatting path, the printf family aborted on %qd, %D, %O, %U, unknown conversions and a trailing %, where FreeBSD formats them. %qd/%q* are formatted as long long, %D/%O/%U as their long forms, %jD and the other width/precision forms follow the known rules, an unknown conversion prints verbatim, and a trailing % prints nothing more. Conversions FreeBSD supports but Windows does not (%m, positional arguments, the ' flag, too-long widths) keep throwing, now verified in the test suite.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release, BUILD_TESTING=ON: guest_formatting passes (the new FreeBSD-conversion cases and the throwing set). python tools/check_conventions.py --base upstream/main and python tools/check_test_registration.py pass.

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:4839958406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4995). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-13T07:36:28Z. --- Carries `husseinkad:fix/libc-format-freebsd-conversions`. Fixes #3975. ### What On the Windows formatting path, the printf family aborted on `%qd`, `%D`, `%O`, `%U`, unknown conversions and a trailing `%`, where FreeBSD formats them. `%qd`/`%q*` are formatted as long long, `%D`/`%O`/`%U` as their long forms, `%jD` and the other width/precision forms follow the known rules, an unknown conversion prints verbatim, and a trailing `%` prints nothing more. Conversions FreeBSD supports but Windows does not (`%m`, positional arguments, the `'` flag, too-long widths) keep throwing, now verified in the test suite. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release, `BUILD_TESTING=ON`: `guest_formatting` passes (the new FreeBSD-conversion cases and the throwing set). `python tools/check_conventions.py --base upstream/main` and `python tools/check_test_registration.py` pass. ### 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
oneandonlydean commented 2026-10-14 04:30:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:30:46Z.


This carries the same husseinkad branch for #3975 as #3987, so only one of them can go in, and the open review on #3987 applies here too: which title prints %qd, %D/%O/%U, an unknown conversion or a trailing %? The console's libc.prx formats through Dinkumware's _Printf, not FreeBSD's vfprintf.c, so the expected output needs to come from that code. Until then the throw stays. Closing in favour of #3987; please reopen if that one is dropped.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160926118 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4995#issuecomment-6160926118). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T04:30:46Z. --- This carries the same husseinkad branch for #3975 as #3987, so only one of them can go in, and the open review on #3987 applies here too: which title prints `%qd`, `%D`/`%O`/`%U`, an unknown conversion or a trailing `%`? The console's `libc.prx` formats through Dinkumware's `_Printf`, not FreeBSD's `vfprintf.c`, so the expected output needs to come from that code. Until then the throw stays. Closing in favour of #3987; please reopen if that one is dropped.

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!4995
No description provided.