feat(libSceLibcInternal): implement wide ctype do_scan_is #25111

Merged
pinewhite merged 3 commits from upstream-pr/25111 into main 2026-11-25 01:58:00 +00:00
pinewhite commented 2026-11-21 16:50:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pinewhite on 2026-11-21T16:50:56Z.


What

Implement std::ctype<wchar_t>::do_scan_is in libSceLibcInternal (NID pSQz254t3ug). The previous export threw on every call. The implementation returns the first wide character matching the supplied mask, or the end pointer. It follows the Dinkumware scan contract and shares the existing do_scan_not range walk and guest virtual do_is dispatch. The guest argument types come from the catalogued mangled name.

Tested

Ubuntu 24.04 ARM64, GCC 13.3. Ran the repository's GuestLibcInternalWideCtype.cpp test in a source-linked executable with the real libc guest-copy implementation. The same test linked to the baseline NID's stub stopped with sceLibcInternalUnknown_pSQz254t3ug_nid_no_patch not implemented. With the implementation it returned 0. The new cases cover an overridden do_is, first matching element, zero mask, and empty range. The existing wide ctype cases, including do_scan_not, also passed. nm confirmed the original NID aliases the new implementation. No full project build, PS5 firmware execution or game run was performed.

tools/progress.py --module libSceLibcInternal on the base and this branch shows 664/1124 → 665/1124 implemented exports. The inventory size is unchanged. tools/check_conventions.py, core/libs/tests/test_public_headers.py --audit-only, and git diff --check origin/main HEAD passed.

Targeted searches for the NID and unversioned export did not find a competing implementation. #16560 changes libc's separate std::__sce_v2 exports. The repository-wide branch overlap check timed out after enumerating 2,232 open pull requests.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5430195037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25111). Originally posted by [pinewhite](https://github.com/pinewhite) on 2026-11-21T16:50:56Z. --- ### What Implement `std::ctype<wchar_t>::do_scan_is` in `libSceLibcInternal` (NID `pSQz254t3ug`). The previous export threw on every call. The implementation returns the first wide character matching the supplied mask, or the end pointer. It follows the [Dinkumware scan contract](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L2536-L2544) and shares the existing `do_scan_not` range walk and guest virtual `do_is` dispatch. The guest argument types come from the catalogued mangled name. ### Tested Ubuntu 24.04 ARM64, GCC 13.3. Ran the repository's `GuestLibcInternalWideCtype.cpp` test in a source-linked executable with the real libc guest-copy implementation. The same test linked to the baseline NID's stub stopped with `sceLibcInternalUnknown_pSQz254t3ug_nid_no_patch not implemented`. With the implementation it returned 0. The new cases cover an overridden `do_is`, first matching element, zero mask, and empty range. The existing wide ctype cases, including `do_scan_not`, also passed. `nm` confirmed the original NID aliases the new implementation. No full project build, PS5 firmware execution or game run was performed. `tools/progress.py --module libSceLibcInternal` on the base and this branch shows 664/1124 → 665/1124 implemented exports. The inventory size is unchanged. `tools/check_conventions.py`, `core/libs/tests/test_public_headers.py --audit-only`, and `git diff --check origin/main HEAD` passed. Targeted searches for the NID and unversioned export did not find a competing implementation. #16560 changes `libc`'s separate `std::__sce_v2` exports. The repository-wide branch overlap check timed out after enumerating 2,232 open pull requests. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-21 17:19:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T17:19:35Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0c0682c645:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_wide_ctype_tests built cleanly.
  • CTest (guest_libc_internal_wide_ctype):
    1/1 Test #4472: guest_libc_internal_wide_ctype ...   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/InventoryExports2.cpp, core/libs/prx/libSceLibcInternal/WideCtype.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified sceLibcInternalWideCtypeDoScanIs_nid_no_patch signature against NID pSQz254t3ug (ZNKSt5ctypeIwE10do_scan_isEsPKwS2) in Api.hpp, WideCtype.cpp, and debt/libSceLibcInternal.md
    • Checked Scan() implementation for bounds safety, empty range handling, invalid range exceptions, and chunked GuestCopyIn pagination via VisitRange
    • Confirmed virtual do_is dispatch via LoadVtableFunction at DoIsSlot (slot 4) matching the Dinkumware facet vtable contract and early termination on match
    • Verified removal of stub from InventoryExports2.cpp and consistent technical debt documentation updates
    • Audited CheckScanIs in GuestLibcInternalWideCtype.cpp for full coverage including virtual callback matching, table lookup, unmatched return-to-end, and empty range safety

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6006916533 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25111#pullrequestreview-6006916533). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T17:19:35Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0c0682c645`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_wide_ctype_tests` built cleanly. - **CTest** (`guest_libc_internal_wide_ctype`): ``` 1/1 Test #4472: guest_libc_internal_wide_ctype ... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibcInternal/InventoryExports2.cpp`, `core/libs/prx/libSceLibcInternal/WideCtype.cpp`, `core/libs/prx/libSceLibcInternal/include/Api.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified sceLibcInternalWideCtypeDoScanIs_nid_no_patch signature against NID pSQz254t3ug (_ZNKSt5ctypeIwE10do_scan_isEsPKwS2_) in Api.hpp, WideCtype.cpp, and debt/libSceLibcInternal.md - Checked Scan() implementation for bounds safety, empty range handling, invalid range exceptions, and chunked GuestCopyIn pagination via VisitRange - Confirmed virtual do_is dispatch via LoadVtableFunction at DoIsSlot (slot 4) matching the Dinkumware facet vtable contract and early termination on match - Verified removal of stub from InventoryExports2.cpp and consistent technical debt documentation updates - Audited CheckScanIs in GuestLibcInternalWideCtype.cpp for full coverage including virtual callback matching, table lookup, unmatched return-to-end, and empty range safety Looks Good To Me
MarcZX10 commented 2026-11-22 23:47:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T23:47:07Z.

Review: APPROVED


Reviewed — looks good

The reviewed change implements the wide do_scan_is export and updates its tests and technical debt record; no blocking defect was found in the changed code inspected.

What I ran

Inspected the prepared diff and changed source files at head 0c0682c6450903e13a59252e494c5282e69ce030 using the review reader. No tests or build commands were run.

Results

Check Result Note
Diff and changed code passed Relevant implementation and tests inspected
Tests and build not run Author-reported results are not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The PR description and diff were read, along with all five changed files listed in the manifest: InventoryExports2.cpp, WideCtype.cpp, Api.hpp, GuestLibcInternalWideCtype.cpp, and libSceLibcInternal.md. No files were excluded in the manifest. The claimed test runs, convention checks, progress comparison, and diff check were not run independently; full project build, PS5 firmware execution, and game behavior remain unverified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015177853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25111#pullrequestreview-6015177853). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T23:47:07Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change implements the wide `do_scan_is` export and updates its tests and technical debt record; no blocking defect was found in the changed code inspected. ## What I ran Inspected the prepared diff and changed source files at head `0c0682c6450903e13a59252e494c5282e69ce030` using the review reader. No tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Relevant implementation and tests inspected | | Tests and build | not run | Author-reported results are not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The PR description and diff were read, along with all five changed files listed in the manifest: `InventoryExports2.cpp`, `WideCtype.cpp`, `Api.hpp`, `GuestLibcInternalWideCtype.cpp`, and `libSceLibcInternal.md`. No files were excluded in the manifest. The claimed test runs, convention checks, progress comparison, and diff check were not run independently; full project build, PS5 firmware execution, and game behavior remain unverified. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-23 07:33:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T07:33:24Z.

Review: APPROVED


Reviewed — looks good

The implementation follows the existing checked range traversal and virtual do_is dispatch, and the inspected tests cover first match, no match, and empty range.

What I ran

Reviewed head 60c88b83e5749fdf6d15d9aa6328115312c9ab57 and the prepared diff using the pinned repo_read.py reader. No tests or builds were run during this review.

Results

Check Result Note
Diff and changed code passed All five changed files read
Tests and build not run Author reports targeted tests; not independently verified
Console behavior not run Debt note records behavior as unverified on console

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported test run, build, export alias check, and convention checks were not independently run. No files were excluded according to the manifest; all five changed files marked included were read. No files.json was available through the reader, so excluded-by-rule details are not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6017899578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25111#pullrequestreview-6017899578). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T07:33:24Z. **Review:** APPROVED --- # Reviewed — looks good The implementation follows the existing checked range traversal and virtual `do_is` dispatch, and the inspected tests cover first match, no match, and empty range. ## What I ran Reviewed head `60c88b83e5749fdf6d15d9aa6328115312c9ab57` and the prepared diff using the pinned `repo_read.py` reader. No tests or builds were run during this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | All five changed files read | | Tests and build | not run | Author reports targeted tests; not independently verified | | Console behavior | not run | Debt note records behavior as unverified on console | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author-reported test run, build, export alias check, and convention checks were not independently run. No files were excluded according to the manifest; all five changed files marked `included` were read. No `files.json` was available through the reader, so excluded-by-rule details are not verified. ## To get this to a good state Nothing is required.
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!25111
No description provided.