Repository navigation
feat(libc): scan 16-bit wide conversions on Linux - #7386
peeldealer wants to merge 8 commits into
Conversation
|
Thanks. Linux is green, but on Windows |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Thanks, I took the first option. I couldn't run the Windows tests here. What I checked:
Could you re-run the Windows build? |
|
I ran the repository's Build workflow on my fork for this head, Result: 1472 of 1472 tests passed in the Windows job, including Run: https://github.com/peeldealer/AnyPS5/actions/runs/39113627972 The same run's relinker, register-context and write-watch jobs passed too, on Linux, macOS and ASan. |
06e6d3e to
1e4be7b
Compare
fscanf, sscanf, vsscanf, sscanf_s and vsscanf_s on Linux threw for %ls, %lc, %l[, %S and %C because glibc stores a 32-bit wchar_t. Formats with these conversions now go through the guest scanner, which reads from a buffer or a FILE stream and stores each byte as one 16-bit unit, as the guest's C-locale mbrtowc does.
The Windows sscanf, vsscanf and fscanf shim accepted %ls and %lc but threw for %S and %C, which the new wide-conversion tests use. They are now passed to the host as %ls and %lc, whose wchar_t is 16 bits, so both platforms accept the same conversions.
1e4be7b to
2b64ed4
Compare
|
Heads-up before this is merged: GitHub shows no conflict, but the merge with current #8292 (merged today as 4b527ad) added int APS5_VABI vfscanf_nid_postfix(FileStream* stream, const char* format, VaList* args) {
...
#else
RejectGuestWideScan(format);The earlier CI runs on this PR predate #8292, so they could not show it. Rebasing onto current |
|
Thanks for the Windows fix: mapping bare Since then |
|
Hi @peeldealer, @adriadam10, Thanks for the work on the 16-bit wide scan conversions. We're closing this as superseded: main has since reworked the libc formatting and scanning paths this touches, and the PR now conflicts with main in If any of |
What
On Linux,
fscanf,sscanf,vsscanf,sscanf_sandvsscanf_sthrew throughNotImplemented_nid_no_patchfor the 16-bit wide conversions%ls,%lc,%l[,%Sand%C, because glibc'swchar_tis 32 bits. A format with any of these conversions now goes through the guest scanner, the way the printf family already sends wide formats to the guest formatter. The scanner stores each input byte as one 16-bit unit of the same value, as the guest's C-localembrtowcconverts it. A format without these conversions still goes to glibc unchanged.ScanGuestnow reads from a buffer (BufferInput) or aFILE*(StreamInput), sofscanftakes the same path assscanf.%ncounts characters across both kinds of input.%lsskips leading white space and reads non-white-space bytes up to the width.%lcreads the width (default 1) without skipping or terminating.%l[reads the scanset.sscanf_sandvsscanf_sapply their size argument to wide fields in 16-bit elements, with the same overflow handling as the narrow fields. This path is shared, so it also applies on Windows.%2$C,%'ls) throwsstd::runtime_error, as before.fscanfandvsscanfexports no longer reachNotImplemented_nid_no_patch, which moves the libraries count from 3432 to 3434.docs/dev/debt/libc.md. Bytes above 0x7F and locales other than C are not measured on the console.Tested
Ubuntu 24.04 (WSL2), GCC 13.3.0, Release, no title or homebrew.
guest_formattingandfile_streamscover:sscanf,vsscanf,sscanf_sandvsscanf_swith%ls,%lc,%l[,%Sand%C, plus width, suppression,%n, a byte above 0x7F, EOF and matching failure;fscanfon a file stream, including%nand the stream position afterwards.mainand pass with this change.guest_scan_count,guest_wide_formatting,guest_wide_conversionguest_standard_streams,guest_standard_streams_closed_stdoutfile_streams,guest_formatting,guest_stringsguest_allocator_failures,guest_sysmodule,guest_sysmodule_maps_scanguest_kernel_stack_protect,guest_memory,guest_mmap_fixed_anonymous,guest_append_writessscanf,vsscanfandfscanfand through the guest scanner for the_sforms. The byte-above-0x7F check is Linux-only.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)