libc: treat negative dynamic printf precision as omitted #503
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!503
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/503/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Mininaut on GitHub · 2026-09-07 14:00 UTC · original
Mininaut:fix/guest-printf-negative-precision→main· +205 −1 · 3 files · 1 commits · closed without mergingSummary
Treat negative precision arguments supplied through
.*as omitted in guest printf. ClearFLAGS_PRECISIONfor negative values; preserve explicit zero and positive precision. No snprintf truncation changes.The printf contract states: “A negative precision is taken as if the precision were omitted.” Previously the parser clamped the value to zero while retaining the explicit-precision flag. This suppressed zero integers, emptied strings, disabled integer zero-padding and selected zero rather than default floating precision.
Regression coverage
Add
guest_printf_tests, registered as CTestguest_printfand included inkyty_tests. Tests callGetGuestSnprintfCtxFuncwith a realVaContext, comparing output, returned lengths, termination and untouched buffer tails against hostsnprintfin the C locale.440 comparisons cover negative precision (including
INT_MIN), explicit zero/positive precision, zero integers, empty strings/format, integer and f/F/e/E conversions, widths, sign/zero-padding, per-conversion state reset, GP register boundaries and interleaved GP/FP stack overflow. Argument consumption is checked separately.Validation
Same test source against the entire actual production
guestPrintf.cpp:6aa6e390ee2930d7eeba7351c38bd342b783d933: 440 cases, 151 failures, executable exit 1 / CTest exit 8.These were focused CMake/Ninja/CTest unit runs on Linux x86-64 using Zig 0.13 / Clang 18 and libc++. No formatter or argument-accessor copies were used. The verification driver supplies fail-fast link fixtures only for unused logging/fatal hooks and uses real fmt headers; the checked-in target links
common. Objects were compiled in Release mode; a link-only-O0option reused the bootstrapped Zig runtime.The normal project configure was attempted but blocked by Zig rejecting
-Wl,-vduring compiler ABI detection. Consequently the root-project target itself has not been built locally. With the normal project configured, run:No full emulator/game compatibility, Windows/macOS validation, truncation/zero-size-buffer behavior or comprehensive floating-point conformance is claimed.
Developed and verified with AI assistance.
Pull request closed