feat(libSceIcu): implement u_strCompareIter and u_getUnicodeVersion #13457
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13457"
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 KernelPanicNT on 2026-10-30T15:49:21Z.
Source of the behaviour
Not measured on a device. Both exports follow ICU 78.1 (release-78.1, commit 049e0d6), the ICU version the tree already follows for libSceIcu. The code is written from ICU's contract, not copied.
u_strCompareIter: ustring.cpp L828-L882; the iterator layout and callback order from uiter.h L341-L475, withUITER_STARTat L52.u_getUnicodeVersion: uchar.cpp L484-L489 copiesdataVersion{0x11, 0, 0, 0}, which matchesU_UNICODE_VERSION "17.0".u_strCompareIter(iter1, iter2, codePointOrder)move(iter, 0, UITER_START)on iter1 then iter2, thennexton each in turn until the units differ; both-1(end) gives 0codePointOrdernonzerocurrent, a trail callsprevioustwice), iter1 firstu_getUnicodeVersion(version)Where ICU's behaviour is undefined, the export does not invent a result: a null callback that ICU would call throws
std::invalid_argument(ICU dereferences it), and the final difference wraps as two's-complement arithmetic instead of overflowing.codePointOrderis read as one byte, nonzero meaning true.In-tree lines that change: the two throwing placeholders in Export.cpp (zGuhKwXM9I0, TNZrG2iXikw), the end of Version.cpp, libSceIcu.hpp and the debt file.
What
u_strCompareIter(TNZrG2iXikw) andu_getUnicodeVersion(zGuhKwXM9I0) no longer throw; they behave as the table above shows.u_strCompareIterdrives caller-ownedUCharIterators only through their function pointers, called with the guest ABI, in ICU's order, so a caller's own iterator sees the same calls. The 112-byteUCharIteratorlayout and theUCharIteratorOriginconstants go in a newIterator.hpp, with one function pointer type per callback as uiter.h declares them.Relation to open pull requests:
core/libs/prx/libSceIcu/Iterator.hppdeclaring the same public ICU struct, and addsu_getVersionnext to the same lines of Version.cpp and Version.hpp, as #11115 does. This branch'sIterator.hppwas written separately from uiter.h; the file name is the same on purpose, so the two conflict as files and can never both be built with two definitions ofUCharIterator, and whichever merges second keeps one header. #11136'suiter_setString/uiter_setUTF8iterators can be compared with this export once both are in.u_strCompareIter, and #11115 addsu_getVersion(notu_getUnicodeVersion) next to the same lines of Version.cpp and Version.hpp.A new debt entry records that neither export was compared with a console and the cases above where ICU is undefined.
Tested
mainwith this branch applied: the newguest_icu_compare_iterpasses, and the other sixguest_icu_*tests still pass. The test drives the export through a guest-ABI iterator that records every callback, and checks: null and identical iterators (no calls), that iterators starting mid-text are reset, equal texts, empty texts, prefixes, code unit order, code point order with a supplementary character on either side, lone leads and trails, pairs that differ in the trail, units above 0xFFFF, acodePointOrderof 0x80, the exact callback sequence of each case, a nullmove,next,currentorprevious(throws only when ICU would call it), and wrapping atINT32_MIN/INT32_MAX.u_getUnicodeVersionwrites 17, 0, 0, 0 and nothing past four bytes, and accepts null.NotImplemented_nid_no_patch, the test fails withu_strCompareIter_nid_postfix not implemented; with onlyu_getUnicodeVersionreverted it fails withu_getUnicodeVersion_nid_postfix not implemented.python3 tools/check_conventions.py --base origin/mainpasses.tools/progress.pyagainstmain: +2 implemented functions (u_getUnicodeVersion,u_strCompareIter); libSceIcu 25/124 to 27/124.tools/pr_overlap.py: reports #11136 (same new fileIterator.hpp) and #13410 (renames the same placeholders), both explained above; the other ICU pull requests it could not compare were checked by hand and implement neither export.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-30T16:18:08Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The ICU implementation and focused test are internally consistent, but integration order for overlapping open ICU PRs has not been agreed or recorded.
What I ran
Reviewed head
d1499225373ff23a47ec40f71fff70dcb0bd46e4against PR base9f748f4d8e36ce3714f3b95f3386316e110a9b22. A read-only merge preview onto currentmain9304896d89f070f65b8f38bd3a8024d5c19f8fe1was clean (tree32a2c10ad0b45aa84831510d0817260601510a7e). Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0.Results
${CMAKE_CURRENT_SOURCE_DIR}Unedited output from the direct checks
Negative control
Not run locally: exercising the new C++ assertions requires building the exact PR head. The author reports a negative control in the PR description; I did not independently reproduce it.
Findings
Blocking
The new
Iterator.hppoverlaps with #11136, which adds a different declaration of the same publicUCharIteratortype. The headers are not drop-in interchangeable: #11136 types themoveorigin asint32_tand omitsUCharIteratorOrigin, while this PR uses an enum type; combining the PRs requires reconciling the callback assignments and callers. #13410 also changes the same two export entries that this PR replaces. The repository asks authors to agree on order for overlapping files/exports and record the requiredDepends onrelationship. Please coordinate with those authors, settle the shared header/export order, and update the checklist accordingly.Non-blocking
The implementation follows the cited ICU algorithm, but no console comparison is available; that limitation is recorded in the debt file.
Sources
u_strCompareIter, pinned to commit 049e0d6a4206Iterator.hppat head 53768b8910a0d540408c4ca9e362bb27599b5faeIterator.hppat reviewed headNot verified
I did not build or run the C++ tests locally. Hosted checks were queued at the final refresh. I did not independently verify the PR author's reported Linux test, negative controls, or console behavior.
To get this to a good state
Please coordinate the shared-header and export landing order with #11136 and #13410, then update
Depends onto reflect the agreement. I will rerun the same relevant checks on the new head.