feat(libSceIcu): give six ucal and udat exports their ICU 68.2 signatures and early returns #23839

Merged
ToRaNek merged 2 commits from upstream-pr/23839 into main 2026-11-19 20:35:13 +00:00
ToRaNek commented 2026-11-19 18:37:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ToRaNek on 2026-11-19T18:37:29Z.


What

Six calendar and date format exports of libSceIcu were parameterless int placeholders in RecoveredInventory.cpp that threw on every call: ucal_getAttribute, ucal_getDayOfWeekType, ucal_openTimeZoneIDEnumeration, ucal_openTimeZones, udat_countSymbols and udat_getCalendar. They now have their ICU 68.2 prototypes and do what ucal.cpp and udat.cpp do before the object is needed, in Calendar.cpp and DateFormat.cpp, the way #17265 did it for 70 other recovered exports. No UCalendar or UDateFormat object can exist yet (ucal_open and udat_open throw on a valid call), so every path that reads one still throws NotImplemented_nid_no_patch.

Export Returns without the object Lines
ucal_getAttribute an attribute outside 0..4 (UCAL_LENIENT to UCAL_SKIPPED_WALL_TIME): -1, the default of its switch, without reading the calendar ucal.cpp 339-364
ucal_getDayOfWeekType failing status: UCAL_WEEKDAY (0), status untouched ucal.cpp 625-632
ucal_openTimeZoneIDEnumeration failing status: null, status untouched (TZEnumeration::create returns null, then uenum_openFromStringEnumeration returns null) ucal.cpp 52-57
ucal_openTimeZones failing status: null, status untouched (uenum_openFromStringEnumeration deletes the enumeration and returns null) ucal.cpp 59-62
udat_countSymbols null format: 0, since neither dynamic_cast matches udat.cpp 748-880
udat_getCalendar nothing: it calls a virtual method on the format at once, so it only gets its prototype and throws for every input udat.cpp 447-451

A null UErrorCode throws, as for the other calendar exports: the console dereferences it.

Debt: two entries are added next to the existing calendar and date format ones (those two are close to the 1000-character limit, so the new exports get their own entries). The recovered inventory exports entry goes from 39 to 33 placeholders left; tools/debt_fold.py --check refuses two fragments that change the same entry and asks to merge them, so that count is edited in the pending feat-libsceicu-field-position-iterator.md fragment.

Stacked on #23819. That PR edits the same count line (47 to 39) for eight usearch exports, and pr_overlap reports the two as conflicting there. This branch is therefore one commit on top of #23819's commit 72d2b41c59; until #23819 merges, the diff shows both commits, and only e045338414 belongs to this PR. The functions of the two PRs are different.

Tested

Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on 72d2b41c59 (#23819, itself on main 9d5f50bdf0); the branch merges into current main without conflict. Not run on a console; the console behaviour of these exports is unverified, as the debt entries say.

  • guest_icu_recovered_signatures passes. tests/Calendar.cpp and tests/DateFormat.cpp gain one group per export: a static_assert on the prototype; the values returned without the object (attributes below 0 and above 4, seven failing status values with a null and a non-null handle, a null format with seven symbol types); a throw where the object is needed (attributes 0 to 4, four non-failing status values, a non-null format, udat_getCalendar with a null and a non-null format); a null status; the status and the fake object's bytes unchanged.
  • Red: on main the placeholders are int(), so the new checks cannot compile against them (by construction, not built). Five one-line mutations of the new code each fail the test, then it passes again with the code restored: the attribute bound off by one; a negative attribute reaching the object; ucal_getDayOfWeekType returning 1 on a failing status; ucal_openTimeZones ignoring a failing status; udat_countSymbols returning -1 for a null format.
  • ctest -R icu: 76 of 76 pass.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.
  • python tools/pr_overlap.py --names over the six names: each is a stub on main and no open PR adds or edits it. --branch reports #23819 (above) and could not compare six open PRs that conflict with main on the recovered inventory files (#18210, #19635, #19645, #19670, #19720, #23196); compared by hand, none of them touches one of the six exports. #19645 rewrites other ucal exports in Calendar.cpp over real calendar objects and conflicts with main already.

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: #23819
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5400787745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23839). Originally posted by [ToRaNek](https://github.com/ToRaNek) on 2026-11-19T18:37:29Z. --- ### What Six calendar and date format exports of libSceIcu were parameterless `int` placeholders in `RecoveredInventory.cpp` that threw on every call: `ucal_getAttribute`, `ucal_getDayOfWeekType`, `ucal_openTimeZoneIDEnumeration`, `ucal_openTimeZones`, `udat_countSymbols` and `udat_getCalendar`. They now have their ICU 68.2 prototypes and do what [ucal.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/i18n/ucal.cpp) and [udat.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/i18n/udat.cpp) do before the object is needed, in `Calendar.cpp` and `DateFormat.cpp`, the way #17265 did it for 70 other recovered exports. No `UCalendar` or `UDateFormat` object can exist yet (`ucal_open` and `udat_open` throw on a valid call), so every path that reads one still throws `NotImplemented_nid_no_patch`. | Export | Returns without the object | Lines | |---|---|---| | `ucal_getAttribute` | an attribute outside 0..4 (`UCAL_LENIENT` to `UCAL_SKIPPED_WALL_TIME`): -1, the `default` of its `switch`, without reading the calendar | ucal.cpp 339-364 | | `ucal_getDayOfWeekType` | failing status: `UCAL_WEEKDAY` (0), status untouched | ucal.cpp 625-632 | | `ucal_openTimeZoneIDEnumeration` | failing status: null, status untouched (`TZEnumeration::create` returns null, then `uenum_openFromStringEnumeration` returns null) | ucal.cpp 52-57 | | `ucal_openTimeZones` | failing status: null, status untouched (`uenum_openFromStringEnumeration` deletes the enumeration and returns null) | ucal.cpp 59-62 | | `udat_countSymbols` | null format: 0, since neither `dynamic_cast` matches | udat.cpp 748-880 | | `udat_getCalendar` | nothing: it calls a virtual method on the format at once, so it only gets its prototype and throws for every input | udat.cpp 447-451 | A null `UErrorCode` throws, as for the other calendar exports: the console dereferences it. Debt: two entries are added next to the existing calendar and date format ones (those two are close to the 1000-character limit, so the new exports get their own entries). The `recovered inventory exports` entry goes from 39 to 33 placeholders left; `tools/debt_fold.py --check` refuses two fragments that change the same entry and asks to merge them, so that count is edited in the pending `feat-libsceicu-field-position-iterator.md` fragment. **Stacked on #23819.** That PR edits the same count line (47 to 39) for eight `usearch` exports, and `pr_overlap` reports the two as conflicting there. This branch is therefore one commit on top of #23819's commit `72d2b41c59`; until #23819 merges, the diff shows both commits, and only `e045338414` belongs to this PR. The functions of the two PRs are different. ### Tested Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on `72d2b41c59` (#23819, itself on `main` `9d5f50bdf0`); the branch merges into current `main` without conflict. Not run on a console; the console behaviour of these exports is unverified, as the debt entries say. - `guest_icu_recovered_signatures` passes. `tests/Calendar.cpp` and `tests/DateFormat.cpp` gain one group per export: a `static_assert` on the prototype; the values returned without the object (attributes below 0 and above 4, seven failing status values with a null and a non-null handle, a null format with seven symbol types); a throw where the object is needed (attributes 0 to 4, four non-failing status values, a non-null format, `udat_getCalendar` with a null and a non-null format); a null status; the status and the fake object's bytes unchanged. - Red: on `main` the placeholders are `int()`, so the new checks cannot compile against them (by construction, not built). Five one-line mutations of the new code each fail the test, then it passes again with the code restored: the attribute bound off by one; a negative attribute reaching the object; `ucal_getDayOfWeekType` returning 1 on a failing status; `ucal_openTimeZones` ignoring a failing status; `udat_countSymbols` returning -1 for a null format. - `ctest -R icu`: 76 of 76 pass. - `python tools/check_conventions.py --base origin/main` and `python tools/debt_fold.py --check` pass. - `python tools/pr_overlap.py --names` over the six names: each is a stub on `main` and no open PR adds or edits it. `--branch` reports #23819 (above) and could not compare six open PRs that conflict with `main` on the recovered inventory files (#18210, #19635, #19645, #19670, #19720, #23196); compared by hand, none of them touches one of the six exports. #19645 rewrites other `ucal` exports in `Calendar.cpp` over real calendar objects and conflicts with `main` already. ### 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) 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: #23819 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 19:05:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T19:05:24Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #3993: guest_icu_recovered_signatures ...   Passed    0.05 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/Calendar.cpp, core/libs/prx/libSceIcu/DateFormat.cpp, core/libs/prx/libSceIcu/RecoveredInventory.cpp, core/libs/prx/libSceIcu/RecoveredInventory.hpp, core/libs/prx/libSceIcu/RecoveredSignatures.hpp, core/libs/prx/libSceIcu/StringSearch.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified ucal_getAttribute, ucal_getDayOfWeekType, ucal_openTimeZoneIDEnumeration, ucal_openTimeZones in core/libs/prx/libSceIcu/Calendar.cpp match ICU 68.2 ucal.cpp signatures and early error handling (returns -1, 0, nullptr without dereferencing null/invalid handles or modifying status on error).
    • Verified udat_countSymbols and udat_getCalendar in core/libs/prx/libSceIcu/DateFormat.cpp match ICU 68.2 udat.cpp signatures and behavior (udat_countSymbols returns 0 for nullptr format; udat_getCalendar throws NotImplemented).
    • Verified usearch_* signatures and early returns in core/libs/prx/libSceIcu/StringSearch.cpp conform to ICU 68.2 usearch.cpp conventions with safe status check and guest memory copy preservation.
    • Verified technical debt fragments in docs/dev/debt/changes/ and inventory header/source deletions in RecoveredInventory.* maintain consistency.
    • Verified tests in core/libs/prx/libSceIcu/tests/ (Calendar.cpp, DateFormat.cpp, StringSearch.cpp) exercise all early return paths, boundary conditions, failing/passing status values, and null pointers.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5981474990 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23839#pullrequestreview-5981474990). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T19:05:24Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e045338414`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #3993: guest_icu_recovered_signatures ... Passed 0.05 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/Calendar.cpp`, `core/libs/prx/libSceIcu/DateFormat.cpp`, `core/libs/prx/libSceIcu/RecoveredInventory.cpp`, `core/libs/prx/libSceIcu/RecoveredInventory.hpp`, `core/libs/prx/libSceIcu/RecoveredSignatures.hpp`, `core/libs/prx/libSceIcu/StringSearch.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified ucal_getAttribute, ucal_getDayOfWeekType, ucal_openTimeZoneIDEnumeration, ucal_openTimeZones in core/libs/prx/libSceIcu/Calendar.cpp match ICU 68.2 ucal.cpp signatures and early error handling (returns -1, 0, nullptr without dereferencing null/invalid handles or modifying status on error). - Verified udat_countSymbols and udat_getCalendar in core/libs/prx/libSceIcu/DateFormat.cpp match ICU 68.2 udat.cpp signatures and behavior (udat_countSymbols returns 0 for nullptr format; udat_getCalendar throws NotImplemented). - Verified usearch_* signatures and early returns in core/libs/prx/libSceIcu/StringSearch.cpp conform to ICU 68.2 usearch.cpp conventions with safe status check and guest memory copy preservation. - Verified technical debt fragments in docs/dev/debt/changes/ and inventory header/source deletions in RecoveredInventory.* maintain consistency. - Verified tests in core/libs/prx/libSceIcu/tests/ (Calendar.cpp, DateFormat.cpp, StringSearch.cpp) exercise all early return paths, boundary conditions, failing/passing status values, and null pointers. 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!23839
No description provided.