feat(libSceIcu): give six number formatter exports their ICU 68.2 signatures and early returns #23848

Merged
ToRaNek merged 4 commits from upstream-pr/23848 into main 2026-11-19 21:40:09 +00:00
ToRaNek commented 2026-11-19 19:16:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ToRaNek on 2026-11-19T19:16:36Z.


What

Six number formatting exports of libSceIcu were parameterless int placeholders in RecoveredInventory.cpp that threw on every call. They now have their ICU 68.2 prototypes and the early returns of number_capi.cpp and unum.cpp, in NumberFormatter.cpp and NumberFormat.cpp, the way #17265 did it for 70 other recovered exports. No UNumberFormatter, UFormattedNumber or UNumberFormat object can exist yet, so every path that reads one still throws NotImplemented_nid_no_patch.

Export Returns without the object Lines
unumf_formatDouble, unumf_formatDecimal failing status: nothing, status untouched; null formatter: U_ILLEGAL_ARGUMENT_ERROR. IcuCApiHelper::validate checks the formatter first, so a non-null formatter has its magic number read and throws, whatever the result handle is number_capi.cpp 124-134, 136-147
unumf_resultToString failing status: 0, status untouched; null result: 0 and U_ILLEGAL_ARGUMENT_ERROR. The buffer check comes after the magic number, so it is not reachable without the object number_capi.cpp 149-161
unumf_resultGetAllFieldPositions failing status: nothing, status untouched; null result: U_ILLEGAL_ARGUMENT_ERROR number_capi.cpp 184-198
unumf_openForSkeletonAndLocale nothing: it allocates the formatter and returns it even with a failing status, so it only gets its prototype and throws for every input number_capi.cpp 84-96
unum_formatDoubleForFields failing status: -1, status untouched; a result buffer and length that disagree: -1 and U_ILLEGAL_ARGUMENT_ERROR, checked before the format is read unum.cpp 255-281

unumf_openForSkeletonAndLocale is the one that differs from the usual pattern: returning null on a failing status would be wrong, since ICU returns an object there.

Debt: two entries are added next to the existing number format and number formatter ones. The recovered inventory exports entry goes from 24 to 18 placeholders left, edited in the pending feat-libsceicu-field-position-iterator.md fragment because tools/debt_fold.py --check refuses two fragments that change the same entry.

Stacked on #23844, which is stacked on #23839 and #23819. The four PRs change that same count line, so they cannot be independent. This branch is one commit, 830ba03e6d, on top of the previous one; until the others merge, the diff shows four commits and only the last belongs to this PR. The functions of the four PRs are different.

Tested

Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on 81dc9c3045 (#23844). Not run on a console; the console behaviour of these exports is unverified, as the debt entries say.

  • guest_icu_recovered_signatures passes. tests/NumberFormatter.cpp and tests/NumberFormat.cpp gain one group each: static_asserts on the six prototypes; seven failing status values (result returned, status unchanged, with null and non-null handles, and a throw from unumf_openForSkeletonAndLocale with the status unchanged); four non-failing status values against each illegal argument (U_ILLEGAL_ARGUMENT_ERROR) and against valid calls (a throw, status unchanged); a null status; the output buffer 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). Seven one-line mutations of the new code each fail the test, then it passes again with the code restored: unumf_formatDouble accepting a null formatter; unumf_formatDecimal ignoring a failing status; unumf_resultToString returning -1 for a null result; unumf_resultGetAllFieldPositions leaving the status for a null result; unumf_openForSkeletonAndLocale returning null on a failing status; unum_formatDoubleForFields returning 0 on a failing status; unum_formatDoubleForFields accepting a negative length.
  • 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 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. #19720 implements other classic unum exports 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: #23844
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5401358817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23848). Originally posted by [ToRaNek](https://github.com/ToRaNek) on 2026-11-19T19:16:36Z. --- ### What Six number formatting exports of libSceIcu were parameterless `int` placeholders in `RecoveredInventory.cpp` that threw on every call. They now have their ICU 68.2 prototypes and the early returns of [number_capi.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/i18n/number_capi.cpp) and [unum.cpp](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/i18n/unum.cpp), in `NumberFormatter.cpp` and `NumberFormat.cpp`, the way #17265 did it for 70 other recovered exports. No `UNumberFormatter`, `UFormattedNumber` or `UNumberFormat` object can exist yet, so every path that reads one still throws `NotImplemented_nid_no_patch`. | Export | Returns without the object | Lines | |---|---|---| | `unumf_formatDouble`, `unumf_formatDecimal` | failing status: nothing, status untouched; null formatter: `U_ILLEGAL_ARGUMENT_ERROR`. `IcuCApiHelper::validate` checks the formatter first, so a non-null formatter has its magic number read and throws, whatever the result handle is | number_capi.cpp 124-134, 136-147 | | `unumf_resultToString` | failing status: 0, status untouched; null result: 0 and `U_ILLEGAL_ARGUMENT_ERROR`. The buffer check comes after the magic number, so it is not reachable without the object | number_capi.cpp 149-161 | | `unumf_resultGetAllFieldPositions` | failing status: nothing, status untouched; null result: `U_ILLEGAL_ARGUMENT_ERROR` | number_capi.cpp 184-198 | | `unumf_openForSkeletonAndLocale` | nothing: it allocates the formatter and returns it even with a failing status, so it only gets its prototype and throws for every input | number_capi.cpp 84-96 | | `unum_formatDoubleForFields` | failing status: -1, status untouched; a result buffer and length that disagree: -1 and `U_ILLEGAL_ARGUMENT_ERROR`, checked before the format is read | unum.cpp 255-281 | `unumf_openForSkeletonAndLocale` is the one that differs from the usual pattern: returning null on a failing status would be wrong, since ICU returns an object there. Debt: two entries are added next to the existing number format and number formatter ones. The `recovered inventory exports` entry goes from 24 to 18 placeholders left, edited in the pending `feat-libsceicu-field-position-iterator.md` fragment because `tools/debt_fold.py --check` refuses two fragments that change the same entry. **Stacked on #23844, which is stacked on #23839 and #23819.** The four PRs change that same count line, so they cannot be independent. This branch is one commit, `830ba03e6d`, on top of the previous one; until the others merge, the diff shows four commits and only the last belongs to this PR. The functions of the four PRs are different. ### Tested Windows 11 IoT Enterprise LTSC 2024 (10.0.26100), WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on `81dc9c3045` (#23844). Not run on a console; the console behaviour of these exports is unverified, as the debt entries say. - `guest_icu_recovered_signatures` passes. `tests/NumberFormatter.cpp` and `tests/NumberFormat.cpp` gain one group each: `static_assert`s on the six prototypes; seven failing status values (result returned, status unchanged, with null and non-null handles, and a throw from `unumf_openForSkeletonAndLocale` with the status unchanged); four non-failing status values against each illegal argument (`U_ILLEGAL_ARGUMENT_ERROR`) and against valid calls (a throw, status unchanged); a null status; the output buffer 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). Seven one-line mutations of the new code each fail the test, then it passes again with the code restored: `unumf_formatDouble` accepting a null formatter; `unumf_formatDecimal` ignoring a failing status; `unumf_resultToString` returning -1 for a null result; `unumf_resultGetAllFieldPositions` leaving the status for a null result; `unumf_openForSkeletonAndLocale` returning null on a failing status; `unum_formatDoubleForFields` returning 0 on a failing status; `unum_formatDoubleForFields` accepting a negative length. - `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` 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. #19720 implements other classic `unum` exports 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: #23844 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 19:46:35 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_recovered_signatures_tests built cleanly.
  • CTest (guest_icu_recovered_signatures):
    1/1 Test #3996: guest_icu_recovered_signatures ...   Passed    0.03 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/DateIntervalFormat.cpp, core/libs/prx/libSceIcu/ListFormatter.cpp, core/libs/prx/libSceIcu/LocaleDisplayNames.cpp, core/libs/prx/libSceIcu/NumberFormat.cpp, core/libs/prx/libSceIcu/NumberFormatter.cpp, core/libs/prx/libSceIcu/PluralRules.cpp, core/libs/prx/libSceIcu/RecoveredInventory.cpp, core/libs/prx/libSceIcu/RecoveredInventory.hpp, core/libs/prx/libSceIcu/RecoveredSignatures.hpp, core/libs/prx/libSceIcu/RelativeDateTimeFormatter.cpp, 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 NumberFormatter.cpp early returns against ICU 68.2 number_capi.cpp: unumf_formatDecimal, unumf_formatDouble, unumf_resultGetAllFieldPositions, and unumf_resultToString properly check Icu::Failure(status) before validating non-null handles with Icu::IllegalArgument.
    • Verified NumberFormat.cpp unum_formatDoubleForFields early returns against ICU 68.2 unum.cpp: correctly validates status failure and mismatched buffer/length bounds before throwing NotImplemented_nid_no_patch.
    • Verified unumf_openForSkeletonAndLocale in NumberFormatter.cpp correctly lacks early returns and immediately invokes NotImplemented_nid_no_patch(func).
    • Verified debt tracking fragments and technical debt changes: feat-libsceicu-number-formatter-early-returns.md accurately documents gaps and matches repository conventions.
    • Verified 64-bit LP64/LLP64 portability and C++20 ABI conformity across all modified signatures and test assertions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5982150405 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23848#pullrequestreview-5982150405). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T19:46:35Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `830ba03e6d`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_recovered_signatures_tests` built cleanly. - **CTest** (`guest_icu_recovered_signatures`): ``` 1/1 Test #3996: guest_icu_recovered_signatures ... Passed 0.03 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/DateIntervalFormat.cpp`, `core/libs/prx/libSceIcu/ListFormatter.cpp`, `core/libs/prx/libSceIcu/LocaleDisplayNames.cpp`, `core/libs/prx/libSceIcu/NumberFormat.cpp`, `core/libs/prx/libSceIcu/NumberFormatter.cpp`, `core/libs/prx/libSceIcu/PluralRules.cpp`, `core/libs/prx/libSceIcu/RecoveredInventory.cpp`, `core/libs/prx/libSceIcu/RecoveredInventory.hpp`, `core/libs/prx/libSceIcu/RecoveredSignatures.hpp`, `core/libs/prx/libSceIcu/RelativeDateTimeFormatter.cpp`, `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 NumberFormatter.cpp early returns against ICU 68.2 number_capi.cpp: unumf_formatDecimal, unumf_formatDouble, unumf_resultGetAllFieldPositions, and unumf_resultToString properly check Icu::Failure(status) before validating non-null handles with Icu::IllegalArgument. - Verified NumberFormat.cpp unum_formatDoubleForFields early returns against ICU 68.2 unum.cpp: correctly validates status failure and mismatched buffer/length bounds before throwing NotImplemented_nid_no_patch. - Verified unumf_openForSkeletonAndLocale in NumberFormatter.cpp correctly lacks early returns and immediately invokes NotImplemented_nid_no_patch(__func__). - Verified debt tracking fragments and technical debt changes: feat-libsceicu-number-formatter-early-returns.md accurately documents gaps and matches repository conventions. - Verified 64-bit LP64/LLP64 portability and C++20 ABI conformity across all modified signatures and test assertions. 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!23848
No description provided.