feat(libSceIcu): implement locale_getKeywordsStart #14050

Merged
danielhorngt merged 1 commit from upstream-pr/14050 into main 2026-11-05 23:14:52 +00:00
danielhorngt commented 2026-10-31 17:06:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danielhorngt on 2026-10-31T17:06:05Z.


What

Implements locale_getKeywordsStart (NID wlK146pHnQ4, in the PS5 3.20 inventory), which was a throwing stub. It returns a pointer to the first @ of a locale ID, or null when there is none. A null locale, which ICU dereferences, throws.

The signature needed evidence, because ICU changed it. ICU 65.1, 68.2 and 76.1 take const char*; ICU 77.1 and the 78.1 commit pinned in the debt notes take std::string_view. Firmware 3.20's module is ICU 68: tools-style NID hashing of _ZN6icu_6813BreakIterator23createCharacterInstanceERKNS_6LocaleER10UErrorCode gives BufsAiaX0+s, a 3.20 inventory NID, and the icu_65 spelling does not match. So this uses const char* and follows ICU 68.2 uloc.cpp. The EBCDIC branch there does not apply. The debt entry records that the ICU version of later firmware is unverified.

The stub counts in docs/dev/debt/libSceIcu.md go from 93 to 92 and from 73 to 72.

Tested

Windows 11 Pro, i9-12900K, WinLibs GCC 15.2.0 r7, full build tree. No title or console was used.

  • ctest -R '^guest_icu_': all 9 passed, including the new guest_icu_locale.
  • ctest -R '^(public_headers|conventions_wrapped_declarations)$': passed.
  • guest_icu_locale checks the exact returned pointer: first @ of several, @ first and last, bytes above 0x7f, no @, an empty string, a @ after the terminator, 64 KiB strings, and a null locale throwing std::invalid_argument.
  • Replacing strchr with strrchr made guest_icu_locale fail. That edit was reverted.
  • python tools/check_conventions.py --base upstream/main passed.
  • python tools/pr_overlap.py --branch feat/icu-locale-keywords-start exited 2. It lists #11115, #11118, #11122, #11132, #11136, #12320, #12738 and #13578, which share CMakeLists.txt and the debt file, and for #12320 and #13578 Export.cpp. None of their diffs names locale_getKeywordsStart, so any conflict is at the ends of those shared files, not the same function.

Not run: the full test suite, the libs target, Linux, macOS, or the relinker on a module that imports this function.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5099715953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14050). Originally posted by [danielhorngt](https://github.com/danielhorngt) on 2026-10-31T17:06:05Z. --- ### What Implements `locale_getKeywordsStart` (NID `wlK146pHnQ4`, in the PS5 3.20 inventory), which was a throwing stub. It returns a pointer to the first `@` of a locale ID, or null when there is none. A null locale, which ICU dereferences, throws. The signature needed evidence, because ICU changed it. ICU 65.1, 68.2 and 76.1 take `const char*`; ICU 77.1 and the 78.1 commit pinned in the debt notes take `std::string_view`. Firmware 3.20's module is ICU 68: `tools`-style NID hashing of `_ZN6icu_6813BreakIterator23createCharacterInstanceERKNS_6LocaleER10UErrorCode` gives `BufsAiaX0+s`, a 3.20 inventory NID, and the `icu_65` spelling does not match. So this uses `const char*` and follows [ICU 68.2 `uloc.cpp`](https://github.com/unicode-org/icu/blob/release-68-2/icu4c/source/common/uloc.cpp). The EBCDIC branch there does not apply. The debt entry records that the ICU version of later firmware is unverified. The stub counts in `docs/dev/debt/libSceIcu.md` go from 93 to 92 and from 73 to 72. ### Tested Windows 11 Pro, i9-12900K, WinLibs GCC 15.2.0 r7, full build tree. No title or console was used. - `ctest -R '^guest_icu_'`: all 9 passed, including the new `guest_icu_locale`. - `ctest -R '^(public_headers|conventions_wrapped_declarations)$'`: passed. - `guest_icu_locale` checks the exact returned pointer: first `@` of several, `@` first and last, bytes above 0x7f, no `@`, an empty string, a `@` after the terminator, 64 KiB strings, and a null locale throwing `std::invalid_argument`. - Replacing `strchr` with `strrchr` made `guest_icu_locale` fail. That edit was reverted. - `python tools/check_conventions.py --base upstream/main` passed. - `python tools/pr_overlap.py --branch feat/icu-locale-keywords-start` exited 2. It lists #11115, #11118, #11122, #11132, #11136, #12320, #12738 and #13578, which share `CMakeLists.txt` and the debt file, and for #12320 and #13578 `Export.cpp`. None of their diffs names `locale_getKeywordsStart`, so any conflict is at the ends of those shared files, not the same function. Not run: the full test suite, the `libs` target, Linux, macOS, or the relinker on a module that imports this function. ### 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) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
BunnyFl commented 2026-11-02 01:58:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T01:58:54Z.

Review: APPROVED


Windows 11, WinLibs GCC 15.2.0 r7, Release. Head c0bf834527 merged into upstream/main 93dbd0f82a:

  • All 9 guest_icu_* tests pass, including the new guest_icu_locale.
  • Mutation check: with std::strchr changed to std::strrchr, guest_icu_locale fails (locale "en@a=b@c=d": expected offset 2, got 6).
  • tools/check_conventions.py --base upstream/main --head c0bf834527: passes.

I recomputed the version argument independently. _ZN6icu_6813BreakIterator23createCharacterInstanceERKNS_6LocaleER10UErrorCode hashes to BufsAiaX0+s, which main already exports from libSceIcu, while the icu_65 spelling gives EfNWIZF8McY. And locale_getKeywordsStart hashes to wlK146pHnQ4. So ICU 68's const char* signature and its uprv_strchr(localeID, '@') body are the right reference.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731371918 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14050#pullrequestreview-5731371918). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T01:58:54Z. **Review:** APPROVED --- Windows 11, WinLibs GCC 15.2.0 r7, Release. Head c0bf834527 merged into upstream/main 93dbd0f82a: - All 9 `guest_icu_*` tests pass, including the new `guest_icu_locale`. - Mutation check: with `std::strchr` changed to `std::strrchr`, `guest_icu_locale` fails (`locale "en@a=b@c=d": expected offset 2, got 6`). - `tools/check_conventions.py --base upstream/main --head c0bf834527`: passes. I recomputed the version argument independently. `_ZN6icu_6813BreakIterator23createCharacterInstanceERKNS_6LocaleER10UErrorCode` hashes to `BufsAiaX0+s`, which main already exports from libSceIcu, while the `icu_65` spelling gives `EfNWIZF8McY`. And `locale_getKeywordsStart` hashes to `wlK146pHnQ4`. So ICU 68's `const char*` signature and its `uprv_strchr(localeID, '@')` body are the right reference.
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!14050
No description provided.