feat(libSceIcu): implement u_uastrcpy and u_uastrncpy #22862

Merged
Callimann8 merged 1 commit from upstream-pr/22862 into main 2026-11-18 16:39:51 +00:00
Callimann8 commented 2026-11-18 13:00:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-18T13:00:31Z.


What

Implements u_uastrcpy and u_uastrncpy in libSceIcu. Both were stubs in LegacyExports.cpp; they now live in Invariant.cpp next to their narrowing counterparts u_austrcpy and u_austrncpy, and follow ICU 78.1's ustr_cnv.cpp the same way:

  • u_uastrcpy widens a NUL-terminated byte string to UTF-16, terminator included, and returns the destination.
  • u_uastrncpy widens at most n bytes, writes one NUL when the source ends before n (no zero padding), and writes nothing for a nonpositive count.
  • Bytes above 0x7f throw NotImplemented_nid_no_patch, because the console's default converter is unknown.
  • Null buffers (always for u_uastrcpy, with a positive count for u_uastrncpy) throw an invalid-argument exception, as the existing u_austr* helpers do.
  • The debt fragment extends the existing "Default-converter string copy helpers" entry to cover the two new exports.

Tested

Linux (Ubuntu 24.04, GCC 13.3, Release). guest_icu_version_tests gains UaStrcpy and UaStrncpy cases: empty string, every byte 0x01–0x7f, truncation, exact length, a single terminator without padding, an unterminated source bounded by the count, nonpositive counts and null pointers. All 63 libSceIcu tests (ctest -R guest_icu) pass on this branch. tools/check_conventions.py --base origin/main and tools/debt_fold.py --check pass. Not tested on a console.

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:5376430586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22862). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-18T13:00:31Z. --- ### What Implements `u_uastrcpy` and `u_uastrncpy` in libSceIcu. Both were stubs in `LegacyExports.cpp`; they now live in `Invariant.cpp` next to their narrowing counterparts `u_austrcpy` and `u_austrncpy`, and follow ICU 78.1's `ustr_cnv.cpp` the same way: - `u_uastrcpy` widens a NUL-terminated byte string to UTF-16, terminator included, and returns the destination. - `u_uastrncpy` widens at most `n` bytes, writes one NUL when the source ends before `n` (no zero padding), and writes nothing for a nonpositive count. - Bytes above `0x7f` throw `NotImplemented_nid_no_patch`, because the console's default converter is unknown. - Null buffers (always for `u_uastrcpy`, with a positive count for `u_uastrncpy`) throw an invalid-argument exception, as the existing `u_austr*` helpers do. - The debt fragment extends the existing "Default-converter string copy helpers" entry to cover the two new exports. ### Tested Linux (Ubuntu 24.04, GCC 13.3, Release). `guest_icu_version_tests` gains `UaStrcpy` and `UaStrncpy` cases: empty string, every byte `0x01`–`0x7f`, truncation, exact length, a single terminator without padding, an unterminated source bounded by the count, nonpositive counts and null pointers. All 63 libSceIcu tests (`ctest -R guest_icu`) pass on this branch. `tools/check_conventions.py --base origin/main` and `tools/debt_fold.py --check` pass. Not tested on a console. ### 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-18 13:03:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T13:03:11Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 324a6a29b7:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_version_tests built cleanly.
  • CTest (guest_icu_version):
    1/1 Test #3827: guest_icu_version ................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Invariant.cpp, core/libs/prx/libSceIcu/Invariant.hpp, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceIcu/Invariant.cpp: verified null pointer checks and APS5_INVALID_ARG_EX exceptions for u_uastrcpy and u_uastrncpy (matching u_austrcpy/u_austrncpy behavior).
    • core/libs/prx/libSceIcu/Invariant.cpp: verified bounds checking, non-positive count handling (early return of units), and NUL-termination behavior against upstream ICU 78.1 ustr_cnv.cpp specification.
    • core/libs/prx/libSceIcu/Invariant.cpp: verified strict check for non-ASCII input (> 0x7f) correctly routing to NotImplemented_nid_no_patch(func) per AGENTS.md and technical debt documentation.
    • core/libs/prx/libSceIcu/include/LegacyExports.hpp and LegacyExports.cpp: verified removal of old stub declarations and definitions without orphan exports or linkage collisions.
    • docs/dev/debt/changes/feat-icu-uastrcpy-uastrncpy.md: verified debt change fragment accurately documents known limitations and unverified console behavior per AGENTS.md conventions.
    • core/libs/tests/GuestIcuVersion.cpp: verified comprehensive test coverage for ASCII widening, bounds, nonpositive counts, null pointers, and rejection of invalid arguments.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5957074298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22862#pullrequestreview-5957074298). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T13:03:11Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `324a6a29b7`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_version_tests` built cleanly. - **CTest** (`guest_icu_version`): ``` 1/1 Test #3827: guest_icu_version ................ Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Invariant.cpp`, `core/libs/prx/libSceIcu/Invariant.hpp`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceIcu/Invariant.cpp: verified null pointer checks and APS5_INVALID_ARG_EX exceptions for u_uastrcpy and u_uastrncpy (matching u_austrcpy/u_austrncpy behavior). - core/libs/prx/libSceIcu/Invariant.cpp: verified bounds checking, non-positive count handling (early return of units), and NUL-termination behavior against upstream ICU 78.1 ustr_cnv.cpp specification. - core/libs/prx/libSceIcu/Invariant.cpp: verified strict check for non-ASCII input (> 0x7f) correctly routing to NotImplemented_nid_no_patch(__func__) per AGENTS.md and technical debt documentation. - core/libs/prx/libSceIcu/include/LegacyExports.hpp and LegacyExports.cpp: verified removal of old stub declarations and definitions without orphan exports or linkage collisions. - docs/dev/debt/changes/feat-icu-uastrcpy-uastrncpy.md: verified debt change fragment accurately documents known limitations and unverified console behavior per AGENTS.md conventions. - core/libs/tests/GuestIcuVersion.cpp: verified comprehensive test coverage for ASCII widening, bounds, nonpositive counts, null pointers, and rejection of invalid arguments. Looks Good To Me
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!22862
No description provided.