feat(libc): scan 16-bit wide conversions in the sscanf family on Linux #5606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5606"
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 Gashrod1 on 2026-10-14T00:56:11Z.
What
On Linux,
sscanf,vsscanf,sscanf_sandvsscanf_sthrew for the 16-bit wide conversions%ls,%lc,%l[,%Sand%C(#3984), because glibc would store a 32-bitwchar_tper character into the guest's 16-bit buffer. Windows already handed them to its host, whosewchar_tis 16 bits.When the format has such a conversion, these functions now go through the per-directive scanner the
_sforms already use (ScanGuest). Each wide directive is scanned as its narrow form into a temporary buffer, then each byte is widened to onechar16_t, as the C locale of FreeBSD 11'snone.cconverts a byte to the wide character of the same value.%lsand%l[are terminated,%lcis not, and in the_sforms the capacity counts 16-bit characters (a string that does not fit stores an empty string, as for%s). Formats without a wide conversion still go to the host unchanged.A wide conversion combined with a positional argument or the
'flag still throws, asScanGuesthandles neither.fscanfkeeps throwing for wide conversions: it reads from a host stream and needs separate handling. On Windows,sscanf,vsscanfandfscanfstill throw for%Sand%C, which their format translation does not accept; that is unchanged here. The technical debt entry is updated accordingly.guest_formattingreplaces the Linux rejection checks with checks on both platforms for%ls,%lcwith a width,%l[throughvsscanf, a byte above 0x7f, the_scapacity (fit, overflow,%lc), empty input and the remaining rejections, plus%Sand%Con Linux. It aborts onmainand passes with the change.Tested
Linux (Arch, GCC), Release,
BUILD_TESTING=ON, based onmaince5c83953:guest_formattingaborts onmainand passes with the change (3 runs); full build and fullctestpass. Windows (WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 5060), Release,BUILD_TESTING=ON: full build and fullctestpass (1111 tests, the same 8 skipped as onmain;guest_formattingwas rerun after restricting the%S/%Ccases to Linux and passes, 3 runs). No title or homebrew run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T01:09:21Z.
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.
main)core/libs/tests/Formatting.cppL247-255core/libs/prx/libc/src/Formatting.cppL396core/libs/prx/libc/src/Formatting.cppL374, L393, L396docs/dev/debt/libc.mdL56core/libs/prx/libc/src/Formatting.cppL98-99, L374, L393, L396docs/dev/debt/libc.mdL56Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:24:43Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed