feat(libSceIcu): implement the locale display exports #24335
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24335"
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 larpsahur333 on 2026-11-20T14:22:07Z.
What
Eight
libSceIcuexports that answeredNotImplemented_nid_no_patchnow forward to ICU 78.1's own entry points:uloc_getDisplayName,uloc_getDisplayLanguage,uloc_getDisplayScript,uloc_getDisplayCountry,uloc_getDisplayVariantuloc_getDisplayKeyword,uloc_getDisplayKeywordValueuloc_getLineOrientationEach one reads its guest locale strings through
CopyGuestString, calls ICU with host strings, and copies the result out of a bounded hostUCharbuffer throughGuestCopyOut. The guestUErrorCodeword is copied in and out throughGuestCopyIn/GuestCopyOutinstead of being dereferenced, and a null status is answered without a write. A null output with a positive capacity, a negative capacity and a capacity above 8192 reportU_ILLEGAL_ARGUMENT_ERROR.In ICU 78 these entry points live in
common/locdispnames.cppandcommon/locresdata.cpp, which the curatedicu_commontarget did not compile.cmake/Icu.cmakeadds them together with the translation units they call (locdspnm.cpp,simpleformatter.cpp,static_unicode_sets.cpp,ucurr.cpp,ulist.cpp,usetiter.cpp,ustrcase_locale.cpp), the same way the earlier locale work addeduloc.cpp,uloc_tag.cppanduloc_keytype.cpp.locdspnm.cppis built withUCONFIG_NO_BREAK_ITERATIONbecause this ICU subset has no break iterator.Tested
Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (WinLibs), CMake 3.29.2, Ninja.
guest_icu_locale_display(new,core/libs/prx/libSceIcu/tests/LocaleDisplay.cpp) passes. It initialises the guest heap, then for the seven exports that write a buffer:U_ILLEGAL_ARGUMENT_ERRORU_ILLEGAL_ARGUMENT_ERRORU_ILLEGAL_ARGUMENT_ERRORand for every export,
uloc_getLineOrientationincluded:uloc_getLineOrientationanswersULOC_LAYOUT_UNKNOWNNot covered: this build ships no
icudtdata, so no display name can be produced. The test asserts the argument checks and the null-status paths only and never compares display text; the names themselves need a title that loads ICU data throughudata_setCommonData.python core/libs/tests/test_public_headers.py --compiler g++reports413 libraries, 34755 exports: unique declarations and umbrella coverage verifiedandStandalone headers verified.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 repositoryImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:34:43Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: copy the terminating NUL into the guest output buffer for the seven display functions.
What I ran
Inspected the prepared diff and targeted source at head
43c7ea7b83098b5f8cf09050ebb94570956790d2usingrepo_read.py. No build or tests were run. I read the description, commits, manifest, full diff, and head text forLocaleDisplay.cpp,tests/LocaleDisplay.cpp, and the first 55 lines ofCMakeLists.txt.Results
Negative control
Not run; no test or code change was made to confirm a failure.
Findings
Blocking
core/libs/prx/libSceIcu/LocaleDisplay.cpp:223:CopyOutcopies at mostlengthUTF-16 code units, while ICU’s display APIs include a terminating NUL in the output buffer contract. For results shorter than capacity, the wrapper therefore leaves the guest buffer unterminated (and for an empty result, writes nothing). Copy the terminator when capacity permits, while preserving truncation behavior.Non-blocking
None.
Sources
Not verified
No build or tests were run. The other changed files’ full head text was not read; their changed lines were inspected in the prepared diff. Display text behavior with ICU data was not verified; the description says the test environment lacks
icudtdata.To get this to a good state
Copy the terminating NUL for successful display results, add coverage that checks termination for non-empty and empty results, then rerun the locale display test on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:55:55Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The wrapper skips copying ICU’s partial output on buffer overflow, so callers with small buffers receive no result even though ICU wrote one.
What I ran
Reviewed head
9059589be3d96f1b40eb22d32d15b30c31f3988cusing the prepared diff andrepo_read.py. No tests or builds were run. The author reports a Windows test run and public header checks; those results were not independently verified.Results
Negative control
Not run; no tests were run during this review.
Findings
Blocking
core/libs/prx/libSceIcu/LocaleDisplay.cpp:92(also lines 108, 124, 140, 156, 173, and 192): the wrapper copies its host buffer only whenlocal <= 0. ICU reportsU_BUFFER_OVERFLOW_ERRORwhen the destination is too small, while still filling the host buffer with the available prefix. Because that status is positive, the guest output is left untouched. Copy the available output back on overflow as well, respecting the guest capacity; ensure successful output includes its terminating NUL. The current tests exercise argument validation and null-status paths only, so they do not catch this behavior.Sources
core/libs/prx/libSceIcu/LocaleDisplay.cpp, especially the overflow guard andCopyOuthelper.core/libs/prx/libSceIcu/tests/LocaleDisplay.cpp, which tests argument checks and null-status cases.cmake/Icu.cmakeandcore/libs/prx/libSceIcu/CMakeLists.txt, reviewed for build integration.Not verified
LegacyExports.cpp,LocaleDisplay.hpp,include/LegacyExports.hpp,libSceIcu.hpp, and the debt note; their changes were reviewed in the prepared diff. All nine changed paths were present in the manifest and included in the diff.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T15:08:56Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
9059589be3:tools/check_conventions.pypassed.guest_icu_locale_display_testsbuilt cleanly.guest_icu_locale_display):core/libs/prx/libSceIcu/LegacyExports.cpp,core/libs/prx/libSceIcu/include/LegacyExports.hpp,core/libs/prx/libSceIcu/libSceIcu.hpp,core/libs/prx/libSceIcu/LocaleDisplay.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:35:09Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected implementation forwards the locale display exports through guest-safe buffers; this review is incomplete because the full legacy export inventory and build/test results were not inspected or run.
What I ran
35ee7065c9808a9746aa89f7ff12e70ccae90f34and selected changed source, header, and test ranges withrepo_read.py.Results
Findings
Blocking
None found in the inspected code.
Non-blocking
None.
Not verified
LegacyExports.cppandinclude/LegacyExports.hppcontents were not read; only the changed removals were inspected in the diff. Therefore the complete review and approval criteria are not met.guest_icu_locale_displayand public-header checks passing on Windows 11 x86-64 with MinGW-w64 GCC 15.2.0.To get this to a good state
Nothing is required. Optional: verify the reported checks on this head and inspect the remaining legacy export context before requesting a formal approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T16:15:25Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: copy the terminating UTF-16 NUL to the guest output buffer when capacity permits.
What I ran
Reviewed head
05b3c372c2d6042fd0c1cb0171e17a44d83d6078using the prepared diff and targeted source reads. No build or tests were run.Results
Negative control
Not run; no test execution was performed.
Findings
Blocking
core/libs/prx/libSceIcu/LocaleDisplay.cpp:92copies onlylengthUTF-16 units when the result fits. ICU returns the character count excluding the terminating NUL, so successful short results are copied without their terminator. Callers that treat these results as NUL-terminated strings can read beyond the copied output. Copy up tomin(length + 1, capacity)units so the terminator is included when space is available. The same copy logic appears in the other display wrappers at lines 108, 124, 140, 156, 173, and 192.Sources
core/libs/prx/libSceIcu/LocaleDisplay.cpp:69-75, 89-93— copy length and display-name call.core/libs/prx/libSceIcu/LocaleDisplay.cpp:106-108, 122-124, 138-140, 154-156, 170-173, 189-192— same copy behavior in the other display wrappers.Not verified
description.md,commits.md,manifest.json,diff.patch,cmake/Icu.cmake,core/libs/prx/libc/src/General.cpp,core/libs/prx/libSceIcu/CMakeLists.txt,core/libs/prx/libSceIcu/DefaultLocale.cpp,core/libs/prx/libSceIcu/Locale.cpp,core/libs/prx/libSceIcu/LocaleDisplay.cpp, andcore/libs/prx/libSceIcu/tests/LocaleDisplay.cpp.To get this to a good state
Pull request closed