feat(libc): implement vfscanf, vscanf, scanf, the wide stream printf family and vswscanf #8292

Merged
hypermoist merged 1 commit from upstream-pr/8292 into main 2026-10-20 12:03:46 +00:00
hypermoist commented 2026-10-20 09:14:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T09:14:02Z.


What

Adds eight libSceLibcInternal exports that no library provided. Each name hashes to the NID the firmware module exports (checked against a decrypted libSceLibcInternal.sprx):

Export NID Implementation
vfscanf lckWSkHDBrY the fscanf path (host vfscanf on Linux, ScanFileWindows on Windows) on a va_list
vscanf, scanf j7Jk3yd3yC8, 7XEv6NnznWw vfscanf on __stdinp
vfwprintf, fwprintf M2bGWSqt764, ZRAcn3dPVmA FormatWide, written to the guest stream as fputws writes
vwprintf QuF2rZGE-v8 vfwprintf on __stdoutp
vswscanf, vswscanf_s KGotca3AjYw, 39HHkIWrWNo the swscanf/swscanf_s scanner on a va_list

In the firmware, vfscanf and vfwprintf are the stream entry points of Dinkumware's _Scanf and _WPrintf, and vscanf is vfscanf on stdin. The new code is appended at the ends of Formatting.cpp, FormattingWide.cpp and ScanningWide.cpp, so it stays off the lines #7386, #7525, #7807, #5303 and #8226 change. If #7386 lands first, vfscanf should take its Linux wide-conversion path the same way fscanf does.

Tested

Linux (CachyOS, GCC, Release): the new guest_stdio_variadic test covers:

  • vfscanf across successive calls on one stream, up to EOF
  • vscanf/scanf reading from a guest stdin
  • fwprintf/vfwprintf wide-character counts and the UTF-8 bytes in the stream
  • vswscanf and the sized %ls cases of vswscanf_s

guest_wide_formatting, guest_wide_conversion and guest_standard_streams* still pass. import_audit.read_exports on the built libc.prx lists all eight NIDs. pr_overlap shows no line conflicts; the test registration sits at an anchor that only the repo-wide #6044 also covers.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code), reviewed by the contributor

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4933620885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8292). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T09:14:02Z. --- ### What Adds eight `libSceLibcInternal` exports that no library provided. Each name hashes to the NID the firmware module exports (checked against a decrypted `libSceLibcInternal.sprx`): | Export | NID | Implementation | |---|---|---| | `vfscanf` | `lckWSkHDBrY` | the `fscanf` path (host `vfscanf` on Linux, `ScanFileWindows` on Windows) on a `va_list` | | `vscanf`, `scanf` | `j7Jk3yd3yC8`, `7XEv6NnznWw` | `vfscanf` on `__stdinp` | | `vfwprintf`, `fwprintf` | `M2bGWSqt764`, `ZRAcn3dPVmA` | `FormatWide`, written to the guest stream as `fputws` writes | | `vwprintf` | `QuF2rZGE-v8` | `vfwprintf` on `__stdoutp` | | `vswscanf`, `vswscanf_s` | `KGotca3AjYw`, `39HHkIWrWNo` | the `swscanf`/`swscanf_s` scanner on a `va_list` | In the firmware, `vfscanf` and `vfwprintf` are the stream entry points of Dinkumware's `_Scanf` and `_WPrintf`, and `vscanf` is `vfscanf` on stdin. The new code is appended at the ends of `Formatting.cpp`, `FormattingWide.cpp` and `ScanningWide.cpp`, so it stays off the lines #7386, #7525, #7807, #5303 and #8226 change. If #7386 lands first, `vfscanf` should take its Linux wide-conversion path the same way `fscanf` does. ### Tested Linux (CachyOS, GCC, Release): the new `guest_stdio_variadic` test covers: - `vfscanf` across successive calls on one stream, up to EOF - `vscanf`/`scanf` reading from a guest stdin - `fwprintf`/`vfwprintf` wide-character counts and the UTF-8 bytes in the stream - `vswscanf` and the sized `%ls` cases of `vswscanf_s` `guest_wide_formatting`, `guest_wide_conversion` and `guest_standard_streams*` still pass. `import_audit.read_exports` on the built `libc.prx` lists all eight NIDs. `pr_overlap` shows no line conflicts; the test registration sits at an anchor that only the repo-wide #6044 also covers. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code), reviewed by the contributor 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
github-actions[bot] commented 2026-10-20 09:14:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T09:14:53Z.


Progress report (77c18ce → 4b527ad)

📈 System libraries: 65.2% (+0.03%, +7 implemented, +1 declared functions)

✅ 7 implemented
Library Name
libc fwprintf_nid_postfix
libc scanf_nid_postfix
libc vfwprintf_nid_postfix
libc vscanf_nid_postfix
libc vswscanf_nid_postfix
libc vswscanf_s_nid_postfix
libc vwprintf_nid_postfix
🆕 1 declared as stubs
Library Name
libc vfscanf_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287616452 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8292#issuecomment-6287616452). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T09:14:53Z. --- <!-- progress-report --> ### Progress report (77c18ce → 4b527ad) 📈 **System libraries**: 65.2% (+0.03%, +7 implemented, +1 declared functions) <details> <summary>✅ 7 implemented</summary> | Library | Name | | - | - | | libc | `fwprintf_nid_postfix` | | libc | `scanf_nid_postfix` | | libc | `vfwprintf_nid_postfix` | | libc | `vscanf_nid_postfix` | | libc | `vswscanf_nid_postfix` | | libc | `vswscanf_s_nid_postfix` | | libc | `vwprintf_nid_postfix` | </details> <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libc | `vfscanf_nid_postfix` | </details>
github-actions[bot] commented 2026-10-20 09:18:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T09:18:14Z.


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.

Pull request Shared files not compared
PR 5021 core/libs/prx/libc/CMakeLists.txt
PR 6044 core/libs/prx/libc/CMakeLists.txt
PR 6819 core/libs/prx/libc/CMakeLists.txt
PR 6879 core/libs/prx/libc/src/ScanningWide.cpp
PR 7081 core/libs/prx/libc/CMakeLists.txt
PR 7201 core/libs/prx/libc/CMakeLists.txt
PR 7332 core/libs/prx/libc/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287677996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8292#issuecomment-6287677996). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T09:18:14Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6819](https://www.github.com/boykopovar/AnyPS5/pull/6819) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libc/src/ScanningWide.cpp` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `core/libs/prx/libc/CMakeLists.txt` |
Sign in to join this conversation.
No reviewers
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!8292
No description provided.