feat(libSceIcu): implement the code point set exports #11122
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11122"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T18:46:15Z.
What
Implements eight of the
uset_exports that firmware 13.42'slibSceIcuhas (BunnyFl's export list):uset_openEmpty,uset_close,uset_add,uset_addRange,uset_addAll,uset_contains,uset_getItemCountanduset_getItem. These build and query sets of code points and need no Unicode data.uset_openPattern, the ninth, needs property data and is not part of this PR.Behaviour follows ICU 78.1's uset.cpp C wrappers and the
UnicodeSetmethods they call in uniset.cpp:uset_addpins the code point to 0..10FFFF first (pinCodePoint), so −5 adds U+0000 and 0x200000 adds U+10FFFF.uset_addRangepins both ends and adds the range when the pinned start is not above the pinned end. As inUnicodeSet::add(start, end), a range that lies entirely below 0 or above 10FFFF adds the single code point it pins to, and a reversed range adds nothing.uset_getItemCountis the number of maximal runs, anduset_getItemreturns each run's inclusive start and end.uset_addAllis the union and leaves the added set unchanged; adding a set to itself changes nothing.uset_containsis not pinned: anything outside 0..10FFFF is not a member.uset_getItemfollows the wrapper's order: an error that is already set returns 0 untouched; then a negative index setsU_ILLEGAL_ARGUMENT_ERRORand returns −1, before the set is read; then an index past the items setsU_INDEX_OUTOFBOUNDS_ERRORand returns −1. For a range item it returns 0 and does not touch the string buffer.Sets hold no strings, because no export here can add one. ICU's string items come only from patterns and string adds. The debt entry records that, and that allocation failure throws where
UnicodeSetwould become bogus. ICU casts the handle without checking it. Here the handle is a host object with a magic value in its first four bytes, so null or foreign sets, and null range outputs or error pointers, throwAPS5_INVALID_ARG_EXwhere ICU would dereference them.uset_close(nullptr)does nothing, asdeleteof null does in ICU.Depends on #11118 (stacked on it). The agreed ICU order is #11013 → #10961 → … → #10967 → #11088 → #11115 → #11118, and this PR comes after #11118. Until those merge, the diff also shows their commits. This PR's own change is the last commit,
3d3b228b9f.Tested
Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, on #11118 (c65ef82953).guest_icu_set:INT32_MIN/INT32_MAXrange ends.uset_getItembranch, including a negative index on a null set.uset_containsfor every code point and the item list against the bitmap's maximal runs.ctest -R "guest_icu_|patched_libraries": all 6 pass. The NID-patchedlibSceIcu.prxbuilds.tools/progress.py --module libSceIcu: 46 implemented, 0 stubs.tools/check_test_registration.py build: 1345 test executables, none built and not run.python3 tools/check_conventions.py --base origin/mainpasses. Overlap: no open PR implements or names anyuset_function (checked 2026-10-25).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T18:49:23Z.
Review: CHANGES_REQUESTED
I compared this against the pinned ICU 78.1
UnicodeSet::add(start, end)inuniset.cppand found a semantic mismatch in the range insertion path. ICU callspinCodePointon both endpoints and inserts only whenpinCodePoint(start) < pinCodePoint(end)(the source is atuniset.cpparound line 765);uset_addRangeforwards directly to that method inuset.cpp. This PR instead usesstart <= endafter pinning and inserts an equal-endpoint range. Consequentlyuset_addRange(set, 5, 5)should add nothing, and ranges wholly below 0 or wholly above U+10FFFF also pin to equal endpoints and should add nothing. The PR body and current tests claim those out-of-range intervals add a singleton, contrary to ICU. Please change the condition to strict<and update/add tests for equal endpoints and both wholly out-of-range intervals. Cross-boundary ranges whose pinned endpoints differ should still add normally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T18:56:40Z.
Review: CHANGES_REQUESTED
Reviewed the updated head
0bcb2ae1aa002a2534c77cb4cf84394e3cb12ba5. The new tests still encode the mismatch: they expectuset_addRange(0x41, 0x41)and fully out-of-range ranges to add singleton code points. In the pinned ICU 78.1 source,uset_addRangeforwards toUnicodeSet::add(start, end), which inserts only whenpinCodePoint(start) < pinCodePoint(end)(uniset.cpp:765-767). The implementation on this head still usesstart <= end, so the behavior and new expectations remain inconsistent with the cited source. I compiled and ranSet.cppwithGuestIcuSet.cppon GCC 12.2; it passes because the test currently asserts the implementation’s behavior, which does not validate ICU equivalence. Please use strict<, change the equal/out-of-range expectations to empty, and add the corrected cases.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:00:57Z.
Review: APPROVED
Correction to my two earlier reviews: I missed the
else if (start == end) { add(start); }branch in pinned ICU 78.1UnicodeSet::add(start, end)(uniset.cpp:801-802). SincepinCodePointmutates both references before that check, equal endpoints after clamping correctly add one code point. The implementation and added tests on0bcb2ae1aamatch this behavior; my earlier claim that equality and wholly out-of-range intervals should add nothing was wrong. I rechecked the forwarding wrapper inuset.cpp; it delegates directly to this method. The focusedguest_icu_settest andctest -R "guest_icu_|patched_libraries"results reported in the PR are consistent with the source.