libc: swscanf is absent (PS5CEMU-HAR); fix branch ready #4464

Closed
opened 2026-10-12 12:28:38 +00:00 by screamm · 1 comment
screamm commented 2026-10-12 12:28:38 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T12:28:38Z.


libc (libSceLibcInternal) lacks swscanf (NID HNnWdT43ues). PS5CEMU-HAR (PPSA99360) imports it at registry index 292, right after pthread_setaffinity_np (276), so once #3787 and the setaffinity branch are in, the predicted stop is FAIL: unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx; not yet observed in a run.

Fix branch ready: screamm:feat/libc-swscanf (569cb122, one commit on main ffa19840). I cannot open it as a PR under the intake rule while #4081 is open; anyone eligible is welcome to carry it, keeping the commit as is.

  • swscanf(s, format, ...) with the 16-bit guest wchar_t shares one scanner with the existing swscanf_s (ScanningWide.cpp, from #3083): a flag decides whether a buffer-size argument is read after %s, %c and %[; without it the whole field is written, as FreeBSD 11.4 swscanf.c passing straight to vswscanf does. swscanf_s behaviour is unchanged and its cases still pass; error messages now carry the calling function's name. The null checks return EOF; everything that threw for swscanf_s (scanset ranges, %Ld, %n with * or a width, unknown conversions, narrow %s/%c/%[ input without a single-byte form) throws for swscanf too. The swscanf_s TechnicalDebt bullet is widened to cover both (no console confirmation; the engine follows C11 where FreeBSD's scanner differs on literal mismatches and prefix-only fields).
  • guest_wide_conversion gains 40 swscanf cases mirroring the swscanf_s ones without size arguments: integers (%i hex prefix, *, widths, %ld, %hd, a bad %x prefix), floats (%lf, %Lf, infinity, incomplete exponent), strings (%ls not cut off, %3ls, %s, %2lc, %c keeping spaces, %l[, %l[^, narrow %[^=]), %ln, %n after a suppressed conversion, %%, a partial match returning 1, EOF on empty and whitespace-only input, null buffer/format and the throws.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_wide_conversion 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 606/606; with main's ScanningWide.cpp the extended test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5813726467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4464). Originally posted by [screamm](https://github.com/screamm) on 2026-10-12T12:28:38Z. --- libc (libSceLibcInternal) lacks `swscanf` (NID `HNnWdT43ues`). PS5CEMU-HAR (PPSA99360) imports it at registry index 292, right after `pthread_setaffinity_np` (276), so once #3787 and the setaffinity branch are in, the predicted stop is `FAIL: unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx`; not yet observed in a run. **Fix branch ready:** [`screamm:feat/libc-swscanf`](https://github.com/screamm/AnyPS5/tree/feat/libc-swscanf) (`569cb122`, one commit on `main` `ffa19840`). I cannot open it as a PR under the intake rule while #4081 is open; anyone eligible is welcome to carry it, keeping the commit as is. - `swscanf(s, format, ...)` with the 16-bit guest `wchar_t` shares one scanner with the existing `swscanf_s` (`ScanningWide.cpp`, from #3083): a flag decides whether a buffer-size argument is read after `%s`, `%c` and `%[`; without it the whole field is written, as FreeBSD 11.4 `swscanf.c` passing straight to `vswscanf` does. `swscanf_s` behaviour is unchanged and its cases still pass; error messages now carry the calling function's name. The null checks return `EOF`; everything that threw for `swscanf_s` (scanset ranges, `%Ld`, `%n` with `*` or a width, unknown conversions, narrow `%s`/`%c`/`%[` input without a single-byte form) throws for `swscanf` too. The `swscanf_s` TechnicalDebt bullet is widened to cover both (no console confirmation; the engine follows C11 where FreeBSD's scanner differs on literal mismatches and prefix-only fields). - `guest_wide_conversion` gains 40 `swscanf` cases mirroring the `swscanf_s` ones without size arguments: integers (`%i` hex prefix, `*`, widths, `%ld`, `%hd`, a bad `%x` prefix), floats (`%lf`, `%Lf`, infinity, incomplete exponent), strings (`%ls` not cut off, `%3ls`, `%s`, `%2lc`, `%c` keeping spaces, `%l[`, `%l[^`, narrow `%[^=]`), `%ln`, `%n` after a suppressed conversion, `%%`, a partial match returning 1, `EOF` on empty and whitespace-only input, null buffer/format and the throws. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_wide_conversion` 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` 606/606; with `main`'s `ScanningWide.cpp` the extended test fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
arcwiser commented 2026-10-12 12:41:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-10-12T12:41:17Z.


Carried in #4467 with commit authorship preserved. I rebased it onto current main and independently validated it on Windows 11 build 26200 with the supported WinLibs GCC 15.2.0 r7 toolchain: the focused guest_wide_conversion test passes 3/3, conventions and diff checks pass, all 705 built test executables remain registered, and the project overlap checker reports no open overlap. Thank you for preparing and testing the implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124461266 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4464#issuecomment-6124461266). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-10-12T12:41:17Z. --- Carried in #4467 with commit authorship preserved. I rebased it onto current main and independently validated it on Windows 11 build 26200 with the supported WinLibs GCC 15.2.0 r7 toolchain: the focused guest_wide_conversion test passes 3/3, conventions and diff checks pass, all 705 built test executables remain registered, and the project overlap checker reports no open overlap. Thank you for preparing and testing the implementation.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#4464
No description provided.