fix(libc): end swscanf at %S and %C as a matching failure #8306
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8306"
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 ZSWolt on 2026-10-20T09:39:35Z.
What
swscanf,swscanf_s(andvswscanf, which shares the scanner) threwunsupported conversionfor%Sand%C. They now end the scan as a matching failure. The call returns the number of fields assigned before the directive, and nothing is stored for it or for any later directive. The same applies with a length modifier (%lS,%hC, …) or with*.This follows what @oneandonlydean found in the console's
libc.prxshipped by PPSA21564 (review below): its wide scanner is Dinkumware's, and it treatsSandClike an unknown conversion letter. An earlier revision of this PR read them as%ls/%lcafter FreeBSD'svfwscanf.c, which the console does not do. That reading is dropped.The behavior was read from the module, not run on a console. Whether input that ends before
%S/%CgivesEOFinstead of the count is unverified and recorded indocs/dev/debt/libc.md.Tested
Windows 11 with WSL2, Ubuntu 26.04.1, GCC 15.2.0, Release,
BUILD_TESTING=ON.guest_wide_conversionchecks, for bothswscanf_sandswscanf:%S,%lS,%3S,%C,%lC,%hCand%*Sassign nothing and leave the destination untouched."%d%3S%d"→ 1), and later conversions are not performed.With main's
ScanningWide.cppthese checks abort withswscanf_s: unsupported conversion 83; with this change they pass.Full
ctest: 1719/1719 pass on current main with this change. Vulkan tests are skipped under WSL.tools/check_conventions.py: 0 errors. Its onedebt-lengthwarning is on theswscanfentry indocs/dev/debt/libc.md, which is already 2,165 characters on main. This change only rewrites its%S/%Cclause.tools/pr_overlap.pyfound no overlapping exports. Of the PRs it could not compare: #6879 changes unrelated lines inScanningWide.cpp, #6044 only renamesGuestWideConversion.cpp, and none of the PRs listed fordocs/dev/debt/libc.mdmentionswscanf. #8292 addsvswscanf/vswscanf_sthrough the sameWideScanner, so they get this behavior too, and the diffs don't touch the same lines.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 oneandonlydean on 2026-10-20T18:16:50Z.
Thanks. Before this goes in I checked the console's own
libc.prx(read from the module that a retail title, PPSA21564, ships). Its wide scanner is Dinkumware's, not FreeBSD's, and it doesn't read%Sor%Cas%ls/%lc:swscanf,vswscanfandswscanf_sshare one scanner. It treatsSandCthe same as an unknown conversion letter: the directive is an invalid conversion, and scanning stops there.s,c,[,n,d,pand the others are handled normally. Anlqualifier doesn't change this.swscanf(u"Āb cd", u"%S", buf)assigns nothing, rather than reading"Āb".Main throws for
%S/%C, which at least reports the gap loudly. Following FreeBSD here would make a title silently read data the console never would. Suggested shape: either keep the throw, or treat%S/%C(with or without a qualifier) as a matching failure that returns what was assigned before them, and test that.This comes from reading the module, not from running on a console.
Imported from boykopovar/AnyPS5. Originally posted by ZSWolt on 2026-10-20T19:00:13Z.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T18:36:40Z.
Overlap coordination for a follow-up to #9321: I have a narrow patch for the reported incomplete-exponent and literal-at-EOF cases. Its scanner code hunks are separate from this PR's
%S/%Cchange, but it currently edits the same libc debt bullet, whichpr_overlap.pyflags. Would you prefer that follow-up to depend on this PR and update the debt entry after yours merges, or do you have another sequencing preference?Imported from boykopovar/AnyPS5. Originally posted by ZSWolt on 2026-10-21T18:54:52Z.
@MarcZX10 Thanks for checking. Making your follow-up depend on this PR and updating the debt entry once it merges works for me. In that bullet I only rewrite the
%S/%Cclause, so rebasing your scanner change on top should leave the rest for you.