fix(libc): convert a wide printf %c like btowc, as titles' libc.prx does #9964
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9964"
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?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-23T00:30:53Z.
What
The wide printf family wrote a narrow
%c(nol, or withh/hh) as the argument's low byte taken as a code unit, so 0xE9 became U+00E9. Thelibc.prxthat titles ship converts it the way itsbtowcdoes in the UTF-8 C locale (#8855 measures the samebtowc):Aand 0x100 gives U+0000;%sdoes, keeping the output written before the conversion;errnobecomesEILSEQ(86) only for 0x80–0xBF and 0xF0–0xFF. The valid lead bytes 0xC0–0xEF andEOF(-1) leave it alone.libc.prxmainx%cyof 0x80EILSEQ, bufferxx, U+0080,y[%3c]of 0xE9errnounchanged, buffer[%lc|%cof U+20AC, 0xFFEILSEQ, buffer€|[%c]of -1errnounchangedThis builds on the
WideEncodingErrorand booleanAppendUtf16decoder merged in #9953. The single error class retains main's message and partial output; its discriminator distinguishes%cfailures that preserve errno.%lcand%Cretain main's behavior.Tested
Current head
c22807ee5f65c395d0cca0d544a35d2bd669541fmerges main4f64f81ef7b4bca975b4b9f3dfd15dfff56f716finto the existing PR, as requested. No rebase or force-push.Linux, Release, independent fresh source/dependency checkout and configuration; built
guest_wide_formatting_tests,guest_formatting_testsandguest_stdio_variadic_testswith their full libc dependency.guest_wide_formatting,guest_formatting,guest_stdio_variadicandpublic_headerspass 4/4, zero skips.Negative control on prior merge
2c8453337e(candidate formatting source and fixture, and main control source, unchanged in this refresh): the same frozen wide-formatting executable fails at%c of a continuation byte fails with EILSEQwith onlyFormattingWide.cppreplaced by current main's version. Restoring the candidate rebuilds libc byte-for-byte identically; the four checks pass again. Conventions, whitespace and clean-worktree checks pass.Linux logs, JUnit, resolved diff and hashes, SHA-256
a6ec6ec866ade26fd53db504dcdd0c4d9514463ebc5ad6c17a3d881b80d2cce9.Earlier reference measurements on Windows 11/WinLibs GCC15.2 at head
7868aaf64aagainst #9953 head8bffaa164a: 44%ccases match the bundledlibc.prx(24 differences on the old main), and a 349,085-format sweep has no differences on PPSA07923/PPSA05916/PPSA13934 (2,843 old-main%cdifferences). These remain historical measurements of the byte-conversion rule, not a new Windows run of this merge. Console execution and streamed/secure%cerror output remain unverified in debt.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:34:11Z.
Review: APPROVED
Reviewed the exact PR head 7868aaf64a3e5e995a283a5c9d8f2ef7be8abbeb against its declared dependency, #9953 at 8bffaa164af60bb9be39d93b58b5c821bd4e1a01. The implementation and tests cover the measured title behavior for narrow
%c, including low-byte conversion, partialswprintfoutput, and the observedEILSEQcases; I found no blocking issue in the diff.I also overlaid the exact PR versions of
FormattingWide.cppandGuestWideFormatting.cpp(plus the debt update) into the existing configured Linux build tree, rebuiltguest_wide_formatting_tests, and ranctest -R '^guest_wide_formatting$': 1/1 passed. This reused the existing build configuration and prerequisites rather than a fresh PR checkout.git diff --checkand the repository convention checker against #9953 passed. Hosted Linux and Windows product jobs are skipped; the author's Windows differential and repeated focused-suite results are recorded in the PR description.