feat(libc): read 16-bit wide fields in fscanf on Linux #11724
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11724"
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 cocoa55 on 2026-10-27T05:48:45Z.
What
On Linux,
fscanf,vfscanf,scanfandvscanfthrewNotImplementedon the 16-bit wide conversions (%ls,%lc,%l[,%S,%C), and so did the_sstream forms.sscanfalready reads them with the guest scanner (ScanSource), which also has aStreamSource, but its wide branch only ran for contiguous strings (if constexpr (TSource::Contiguous)). The UTF-8 decoding is the existing sscanf behaviour; #12468 replaces it with the byte-by-byte rule measured on titles’ libc.prx.ScanSourceno longer walks aconst char*. Each source getsPeekWide, which decodes the next character without consuming it, and the branch callsSkipfor its bytes only once the field takes the character.StringSource::PeekWideis the oldReadWideScanCharactercall.StreamSource::PeekWidereads the UTF-8 sequence withfgetcand pushes it back withungetc, as thefwscanfstream reader inScanningWide.cppalready does. A rejected character therefore stays in the stream, and the accept/reject logic is the same code for strings and streams.fscanf/vfscanfuse the scanner when the format has a wide conversion (same check assscanf,ScansWideInProcess) and the hostvfscanfotherwise.ScanGuestStream(fscanf_sand friends) no longer rejects wide conversions and keeps the positional-argument check.RejectGuestWideScanis removed.ScanWideFieldgetsWideScanCharacterLength, whichDecodeUtf8now uses too.docs/dev/debt/libc.md: the scanf family and_sstream entries no longer listfscanfas throwing.Overlap: #9087 and #9340 change the same wide branch of
ScanSource(secure-size violations, and surrogate pairs / non-ASCII scansets). Neither reads wide fields from a stream, so they don't duplicate this PR. Agreed order (asked on both PRs): #9087, then #9340, then this PR, which I'll rebase after each one merges. StringSource::Remaining is kept because #12530 uses it. #11726 and #12468 build on this PR.Tested
Ubuntu 24.04, GCC 13.3, full build. New
CheckNarrowFormatWideFieldsincore/libs/tests/GuestWideStreamScan.cpp(Linux only, like thesscanfwide tests):fscanf%ls/%lcon UTF-8,vfscanf%Swith%ln, wide and narrow fields in one call, a scanset stopping beforeéand theéread by the next call,%3lcwith the next character left in the stream, matching failure and EOF,fscanf_s/vfscanf_ssizes,scanf/vscanfon the guest stdin. It fails onmainwithfscanf 16-bit wide conversion on Linux not implemented.guest_formatting,guest_scan_count,guest_wide_stream_scanandfile_streamspass. Fullctest: 2476 of 2491 pass, and the 15 failures (agc_*submit/metadata,guest_net_*,guest_tcp,guest_socket_*) fail the same way onmainin the same container (no GPU, sandboxed network). No title tested.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-27T06:00:50Z.
Review: CHANGES_REQUESTED
I reviewed the scanner changes and the reported build/test results.
git diff --checkand the current-base conventions check pass. The author reports a full Ubuntu build, the focused scanner tests, and a main-vs-change control for the wider CTest failures; hosted product build jobs are currently skipped.There is one repository-policy blocker before this can be approved. Both overlapping PRs #9087 and #9340 are still open, and I independently confirmed that merging this head with either branch produces a content conflict in
core/libs/prx/libc/src/Formatting.cpp(#9340also conflicts indocs/dev/debt/libc.md). CONTRIBUTING requires the authors to agree which overlapping PR goes first and declare that order withDepends on. The PR description identifies the overlaps and says the second merge will need a textual rebase, but its checklist still saysDepends on: none, and I found no coordination with those authors in the PR discussion.Please coordinate the merge order with the authors of #9087 and #9340, update the dependency line accordingly, and rebase when appropriate. This is a merge-order request; I did not find a separate correctness blocker in the reviewed code.
Pull request closed