feat(libSceIcu): implement uloc_getTableStringWithFallback #26259

Merged
MarrasFederico merged 2 commits from upstream-pr/26259 into main 2026-11-25 08:26:43 +00:00
MarrasFederico commented 2026-11-23 15:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-23T15:10:43Z.


What

uloc_getTableStringWithFallback now has the seven-argument ICU prototype and forwards to upstream locresdata.cpp, built into icu_common, with checked guest reads of the path, locale and keys and checked writes of the length and status. A new guest test compares the fallback export with the same upstream function built natively on synthetic resource bundles. Every case now has an expected string or an expected null result plus the exact status, checked unconditionally before the native comparison. The synthetic bundles now resolve the nested sub-table, a value found through locale fallback, and a value found through a Fallback entry; they also cover direct lookups, deprecated country replacement, prefailed status and throwing paths. ucol_getRules is left untouched and still throws on this branch.

Tested

Linux, native guest test executables. Head 3eb469710e8cf98a34daede1764f198abf04a60c.

  • nice -n 19 cmake --build build --parallel 7 --target guest_icu_locale_table_fallback_tests, then ctest --test-dir build -R '^guest_icu_locale_table_fallback$' --repeat until-fail:3 — 3/3 runs passed (0.01 s).
  • guest_icu_locale_table_fallback now also covers a u"\u2205\u2205\u2205" no-inheritance item (asserting nullptr, U_MISSING_RESOURCE_ERROR, and *pLength == 0), a missing-locale fallback warning (de_AT -> U_USING_FALLBACK_WARNING), and a valid call with pLength == nullptr, each compared against native ICU.
  • Negative control: reverting core/libs/prx/libSceIcu/LocaleTableFallback.cpp to b47b9b838d fails at core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp:229 ("expected fallback miss length"); restored.
  • Negative control: changing if (outgoing != incoming) to if (outgoing > 0 && outgoing != incoming) in core/libs/prx/libSceIcu/LocaleTableFallback.cpp (dropping warning statuses) fails at core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp:232 ("expected fallback hit status"); restored (d07d1a263af1a2d1fb17cb8b28133b0ff8314d1b486460685119f020baf03509), then 3/3 rerun passed.
  • nice -n 19 cmake --build build --parallel 7 --target guest_icu_recovered_signatures_tests, then ctest --test-dir build -R '^guest_icu_recovered_signatures$' — passed 1/1.

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:5455693665 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26259). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-23T15:10:43Z. --- ### What `uloc_getTableStringWithFallback` now has the seven-argument ICU prototype and forwards to upstream `locresdata.cpp`, built into `icu_common`, with checked guest reads of the path, locale and keys and checked writes of the length and status. A new guest test compares the fallback export with the same upstream function built natively on synthetic resource bundles. Every case now has an expected string or an expected null result plus the exact status, checked unconditionally before the native comparison. The synthetic bundles now resolve the nested sub-table, a value found through locale fallback, and a value found through a `Fallback` entry; they also cover direct lookups, deprecated country replacement, prefailed status and throwing paths. `ucol_getRules` is left untouched and still throws on this branch. ### Tested Linux, native guest test executables. Head `3eb469710e8cf98a34daede1764f198abf04a60c`. - `nice -n 19 cmake --build build --parallel 7 --target guest_icu_locale_table_fallback_tests`, then `ctest --test-dir build -R '^guest_icu_locale_table_fallback$' --repeat until-fail:3` — 3/3 runs passed (0.01 s). - `guest_icu_locale_table_fallback` now also covers a `u"\u2205\u2205\u2205"` no-inheritance item (asserting `nullptr`, `U_MISSING_RESOURCE_ERROR`, and `*pLength == 0`), a missing-locale fallback warning (`de_AT` -> `U_USING_FALLBACK_WARNING`), and a valid call with `pLength == nullptr`, each compared against native ICU. - Negative control: reverting `core/libs/prx/libSceIcu/LocaleTableFallback.cpp` to `b47b9b838d` fails at `core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp:229` (`"expected fallback miss length"`); restored. - Negative control: changing `if (outgoing != incoming)` to `if (outgoing > 0 && outgoing != incoming)` in `core/libs/prx/libSceIcu/LocaleTableFallback.cpp` (dropping warning statuses) fails at `core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp:232` (`"expected fallback hit status"`); restored (`d07d1a263af1a2d1fb17cb8b28133b0ff8314d1b486460685119f020baf03509`), then 3/3 rerun passed. - `nice -n 19 cmake --build build --parallel 7 --target guest_icu_recovered_signatures_tests`, then `ctest --test-dir build -R '^guest_icu_recovered_signatures$'` — passed 1/1. ### 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-23 15:27:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-23T15:27:55Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_locale_table_fallback_tests built cleanly.
  • CTest (guest_icu_locale_table_fallback):
    1/1 Test #4189: guest_icu_locale_table_fallback ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/LocaleTableFallback.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified signature and ABI linkage in core/libs/prx/libSceIcu/include/LegacyExports.hpp and core/libs/prx/libSceIcu/LocaleTableFallback.cpp match the ICU 7-argument prototype returning const char16_t*.
    • Verified guest memory safety in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: pErrorCode, tableKey, itemKey, and pLength are checked before dereference, string reads are bounded by MaximumStringLength (0x10000), and errno is preserved across GuestCopyIn/GuestCopyOut.
    • Verified error code semantics: pre-failed status (> 0) immediately returns nullptr without invoking ICU, and outgoing status changes are copied back to guest pErrorCode.
    • Verified AGENTS.md compliance: no disallowed comments in new source files, technical debt fragment correctly recorded at docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md, and upstream ICU locresdata.cpp added via cmake/Icu.cmake.
    • Verified test rigor in core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp covering direct lookups, nested subtables, deprecated country code replacement (YU -> RS), Fallback aliases, missing keys, pre-failed statuses, and bad guest pointer throws.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6024346627 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26259#pullrequestreview-6024346627). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-23T15:27:55Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b47b9b838d`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_locale_table_fallback_tests` built cleanly. - **CTest** (`guest_icu_locale_table_fallback`): ``` 1/1 Test #4189: guest_icu_locale_table_fallback ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/LocaleTableFallback.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified signature and ABI linkage in core/libs/prx/libSceIcu/include/LegacyExports.hpp and core/libs/prx/libSceIcu/LocaleTableFallback.cpp match the ICU 7-argument prototype returning const char16_t*. - Verified guest memory safety in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: pErrorCode, tableKey, itemKey, and pLength are checked before dereference, string reads are bounded by MaximumStringLength (0x10000), and errno is preserved across GuestCopyIn/GuestCopyOut. - Verified error code semantics: pre-failed status (> 0) immediately returns nullptr without invoking ICU, and outgoing status changes are copied back to guest pErrorCode. - Verified AGENTS.md compliance: no disallowed comments in new source files, technical debt fragment correctly recorded at docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md, and upstream ICU locresdata.cpp added via cmake/Icu.cmake. - Verified test rigor in core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp covering direct lookups, nested subtables, deprecated country code replacement (YU -> RS), Fallback aliases, missing keys, pre-failed statuses, and bad guest pointer throws. Looks Good To Me
PrivacyOnion commented 2026-11-23 18:13:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-23T18:13:47Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 3eb469710e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_locale_table_fallback_tests built cleanly.
  • CTest (guest_icu_locale_table_fallback):
    1/1 Test #4189: guest_icu_locale_table_fallback ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/LocaleTableFallback.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified uloc_getTableStringWithFallback_nid_postfix prototype and ABI linkage in core/libs/prx/libSceIcu/include/LegacyExports.hpp and core/libs/prx/libSceIcu/LocaleTableFallback.cpp match ICU locresdata.cpp (7-argument signature returning const char16_t*).
    • Verified guest memory safety and pointer handling in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: validated pErrorCode via Icu::RequireStatus, handled null and non-null pLength with CopyIn/CopyOut, checked required keys (tableKey, itemKey), safely read bounded strings (MaximumStringLength 0x10000), and preserved errno across GuestCopyIn/GuestCopyOut.
    • Verified error code and status semantics in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: prefailed status (incoming > 0) immediately returns nullptr, and outgoing status modifications are propagated back to guest memory.
    • Verified pLength contract in core/libs/prx/libSceIcu/LocaleTableFallback.cpp against upstream ICU behavior: accepted null pLength, passed length address to upstream, and wrote back length on non-null return or when length changed (supporting no-inheritance ∅∅∅ writing 0 while regular misses preserve pLength).
    • Verified build and test integration in cmake/Icu.cmake and core/libs/prx/libSceIcu/CMakeLists.txt, including upstream locresdata.cpp addition and synthetic resource bundle test coverage in core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp.
    • Verified AGENTS.md compliance: no unauthorized comments, technical debt properly registered in docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md, and all mechanical convention checks passing.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6027009878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26259#pullrequestreview-6027009878). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-23T18:13:47Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `3eb469710e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_locale_table_fallback_tests` built cleanly. - **CTest** (`guest_icu_locale_table_fallback`): ``` 1/1 Test #4189: guest_icu_locale_table_fallback ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/LocaleTableFallback.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified uloc_getTableStringWithFallback_nid_postfix prototype and ABI linkage in core/libs/prx/libSceIcu/include/LegacyExports.hpp and core/libs/prx/libSceIcu/LocaleTableFallback.cpp match ICU locresdata.cpp (7-argument signature returning const char16_t*). - Verified guest memory safety and pointer handling in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: validated pErrorCode via Icu::RequireStatus, handled null and non-null pLength with CopyIn/CopyOut, checked required keys (tableKey, itemKey), safely read bounded strings (MaximumStringLength 0x10000), and preserved errno across GuestCopyIn/GuestCopyOut. - Verified error code and status semantics in core/libs/prx/libSceIcu/LocaleTableFallback.cpp: prefailed status (incoming > 0) immediately returns nullptr, and outgoing status modifications are propagated back to guest memory. - Verified pLength contract in core/libs/prx/libSceIcu/LocaleTableFallback.cpp against upstream ICU behavior: accepted null pLength, passed length address to upstream, and wrote back length on non-null return or when length changed (supporting no-inheritance ∅∅∅ writing 0 while regular misses preserve pLength). - Verified build and test integration in cmake/Icu.cmake and core/libs/prx/libSceIcu/CMakeLists.txt, including upstream locresdata.cpp addition and synthetic resource bundle test coverage in core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp. - Verified AGENTS.md compliance: no unauthorized comments, technical debt properly registered in docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md, and all mechanical convention checks passing. Looks Good To Me
MarcZX10 commented 2026-11-25 07:47:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:47:18Z.

Review: APPROVED


Reviewed — looks good

The changed implementation and its tests support merging at head 3eb469710e8cf98a34daede1764f198abf04a60c; no checks were run in this review, and console ABI behavior remains unverified.

What I ran

Read the prepared diff and all changed-file contents at the pinned head. No commands or tests were run in this review; build and test results in the PR description are author-reported.

Results

Check Result Note
Diff and changed code passed All changed files read
Build and tests not run Author reports Linux runs passed
Console behavior not run Debt note records this limitation

Findings

Blocking

None.

Non-blocking

None.

Not verified

No build or tests were run during this review. Console ABI and behavior were not verified. Read all changed files listed in review/manifest.json: cmake/Icu.cmake, core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/LocaleTableFallback.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp, and docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6053667782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26259#pullrequestreview-6053667782). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T07:47:18Z. **Review:** APPROVED --- # Reviewed — looks good The changed implementation and its tests support merging at head `3eb469710e8cf98a34daede1764f198abf04a60c`; no checks were run in this review, and console ABI behavior remains unverified. ## What I ran Read the prepared diff and all changed-file contents at the pinned head. No commands or tests were run in this review; build and test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | All changed files read | | Build and tests | not run | Author reports Linux runs passed | | Console behavior | not run | Debt note records this limitation | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No build or tests were run during this review. Console ABI and behavior were not verified. Read all changed files listed in `review/manifest.json`: `cmake/Icu.cmake`, `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/LocaleTableFallback.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/tests/LocaleTableFallback.cpp`, and `docs/dev/debt/changes/feat-libsceicu-locale-table-fallback.md`. No changed files were excluded. ## 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!26259
No description provided.