feat(icu): implement uscript_getCode #22237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22237"
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 vanshrana369 on 2026-11-17T09:40:10Z.
What
Implements the recovered
uscript_getCodeexport by forwarding to the pinned ICU 78.1 common library, with guest string, output array, and status copied through the guest-memory helpers.The branch is rebased on current
main(1f2a418f008). It retainsmain's generatedCommonData.cpp, adds ICU'scommon/sources.txtandi18n/sources.txtsource lists, and usesICU_NORMALIZATION_SOURCEinstead ofstubdata.cppso there is one ICU data entry point. The locale/data-dependent collation, date, display-name, plural, relative-date, and string-search families and their success-path tests were removed from this PR.Tested
Added
uscript_getCode("Latn")coverage toguest_icu_script_tests.python tools/check_conventions.py --base origin/mainandgit diff --checkpass locally. This environment has no C++ compiler, so the Linux and Windows builds andguest_icu_recovered_signatureshave not been run locally; I will rely on the repository Build workflow after updating the PR head.Checklist
main; no other open PR implements the same functionNotImplemented_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 PrivacyOnion on 2026-11-17T09:42:41Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
adf4780105:tools/check_conventions.pypassed.guest_icu_recovered_signatures_testsfailed to build.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:49:40Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: invalid-handle errors in the ICU close paths must match what the existing tests expect (see Blocking, item 1).
The change throws
std::invalid_argumentwhere two existing tests expectstd::runtime_error, so those tests would fail on this head.What I ran
adf4780105a7387e232eb075ffc6d45fb6c573a7, basemain.diff.patch(3741 lines),manifest.json,files.json,description.md,commits.md, and the house sections "Readable reviews", "Standard PR response format" and "Accuracy and evidence".Results
check_conventions.pyruntime_errorFindings
Blocking
RequireOpenincore/libs/prx/libSceIcu/DateFormat.cpp:42andcore/libs/prx/libSceIcu/RelativeDateTimeFormatter.cpp:41throwsstd::invalid_argument. The existing tests pass a foreign, non-null handle toudat_closeandureldatefmt_close, and expectstd::runtime_errorfrom the NotImplemented path, with the NotImplemented counter rising by one.std::invalid_argumentderives fromstd::logic_error, notstd::runtime_error, so the test's catch misses it. The same file family is inconsistent:LocaleDisplayNames.cppandPluralRules.cppcallNotImplemented_nid_no_patchin theirRequireOpen.NotImplemented_nid_no_patch(caller)in theseRequireOpenhelpers, as the other files do, or change the tests in this PR and say so.Non-blocking
core/libs/prx/libSceIcu/Collator.cpp:610:ucol_mergeSortkeysskips the guest-copy path when either length is 0 and passes the guest pointers straight to ICU. The other branches useCopySortKey, and the debt file says sort keys go through guest helpers. Whether this is a real problem depends on guest-memory mapping, which I did not check. Use the copy path, or document why it is safe.core/libs/prx/libSceIcu/Collator.cpp:431andCollator.cpp:305:ucol_setAttributeanducol_getAttributereturn silently for a null collator without writing status, so the caller sees success.ucol_strcollUTF8reportsIcu::IllegalArgumentfor the same case.tests/Calendar.cppandtests/Collator.cpp. For example,core/libs/prx/libSceIcu/Script.cpp:20(uscript_getCode) has no test here.Not verified
diff.patch. I did not open the full-text copies in the review folder'sfiles/.files.jsonlists no excluded files.core/libs/prx/libSceIcu/RecoveredSignatures.hpp:33-35:UCalendar,UDateFormat,UDateTimePatternGeneratorandUNumberFormatare now aliases ofvoid*. That makesconst UCalendar*avoid* const*, andudat_getCalendarreturns ICU'sconst UCalendar*through it. I did not check ICU's declarations, so whether this compiles is not verified; the author reports a syntax-only pass.core/libs/prx/libSceIcu/Collator.cpp:346(ucol_getReorderCodes): the capacity-0 preflight returns 0 on anyU_FAILURE, includingU_BUFFER_OVERFLOW_ERROR. If ICU 78.1 reports overflow there when reorder codes exist, callers get 0 instead of the count. Not checked against ICU.StringSearch.cpphandle checks andtests/Collator.cppL316 (rejectsRuntime) use the sameinvalid_argumentpattern. I did not confirm which calls theRejectshelper intests/StringSearch.cppexercises, so those tests may fail as well.usearch_openrejects a null locale withU_ILLEGAL_ARGUMENT_ERROR. I did not check ICU's contract for a null locale.To get this to a good state
DateFormat.cppandRelativeDateTimeFormatter.cppto the NotImplemented path the tests expect, or update those tests in this PR. CheckCollator.cppandStringSearch.cppfor the same mismatch.DateFormat,RelativeDateTimeFormatter,CollatorandStringSearchon the new head.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T10:07:47Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
b3dc3f46c4:tools/check_conventions.pyfailed.guest_icu_recovered_signatures_testsfailed to build.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T11:07:45Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
83093eb244:tools/check_conventions.pyfailed.guest_icu_recovered_signatures_tests,guest_icu_script_testsfailed to build.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T12:06:01Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: a guest-supplied
UNumberFormatpointer reaches host ICU without a check that this module returned it.What I ran
description.md,commits.md,manifest.jsonand all ofdiff.patch(4,104 lines) at head6905e6b54c9542bef03882778543308bd8850dd9againstmain.git diff --check. This run has no compiler.manifest.json, throughdiff.patch. Not read:files.json(the exclusion list) and the full texts infiles/. Any excluded file is therefore not covered.Results
tests/docs/dev/debt/changes/Findings
Blocking
core/libs/prx/libSceIcu/RelativeDateTimeFormatter.cpp:153:ureldatefmt_openpasses the guest'sUNumberFormat*straight to host ICU. The debt entry says ICU adopts it, so ICU frees it when the relative formatter closes. Nothing checks that the pointer came from this module.unum_openis stillNotImplemented(core/libs/prx/libSceIcu/NumberFormat.cpp:60), so no tracked number formatter exists at all. Scenario:ureldatefmt_open("en", <any non-null value>, ...)succeeds, and the laterureldatefmt_closefrees that value on the host. The same unchecked pass-through is atcore/libs/prx/libSceIcu/PluralRules.cpp:147, where ICU reads the formatter. Smallest fix: keep NULL allowed, and throwNotImplemented_nid_no_patchfor any non-null number format until number-format handles are tracked.Non-blocking
core/libs/prx/libSceIcu/Collator.cpp:317,:349,:392,:445: with a null collator and no earlier error, these return without writingstatus, so the guest reads success.ucol_clone,ucol_strcollUTF8anducol_getLocaleByTypein the same file writeU_ILLEGAL_ARGUMENT_ERRORin this case. Fix: writeIcu::IllegalArgumentwhen!colland the incoming status is clear.description.md:15: the description says invalid arguments to APIs without a status argument "return a neutral value or no-op". The code throws instead.RequireOpenatcore/libs/prx/libSceIcu/Collator.cpp:55raisesNotImplemented_nid_no_patchfor a null handle, and the same pattern is inDateFormat.cpp,LocaleDisplayNames.cpp,PluralRules.cpp,RelativeDateTimeFormatter.cppandStringSearch.cpp. That matches the debt entry ("invalid or untracked handles throw"). Fix: correct the line in the description.core/libs/prx/libSceIcu/DateFormat.cpp:103,:372: output buffers are sized from the guest'sresultLengthwith no upper bound, so one call can request up to 2^31 UChar. The input paths are capped atMaximumTextLength; the output paths should be capped the same way.Not verified
RecoveredSignatures.hppreplaces the forward-declaredUCalendar,UDateFormat,UDateTimePatternGeneratorandUNumberFormatstructs withvoid*aliases, andDateFormat.cppincludes that header before<unicode/udat.h>. If the ICU 78.1 headers declare these as structs, the translation unit does not compile. The3rdpartyICU tree is not readable throughrepo_read.py, so this stays open.cmake/Icu.cmake:3-8readscommon/sources.txtandi18n/sources.txtwithfile(STRINGS). Those files could not be read, so their token format and the existence of every listed source are unverified.udat_openwith a NULLtimezoneand length -1 returnsU_ILLEGAL_ARGUMENT_ERROR(DateFormat.cpp:486, viaCopyUtf16Input). Whether ICU 78.1 accepts that is unverified. Collation, date and plural data behaviour is unverified, as the PR says.core/libs/prx/libSceIcu/tests/were read, not run. Their expected values (for exampleLatn→ 25, and"one"with length 3) were not checked against ICU output.files.jsonand the full texts underfiles/were not read.To get this to a good state
UNumberFormat*inureldatefmt_openanduplrules_selectWithFormatwithNotImplemented_nid_no_patch, and keep NULL allowed.guest_icu_recovered_signatures(thelibSceIcurecovered-signature tests).Sources
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T12:19:25Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: the libSceIcu test cannot compile against the header that still declares the old
uscript_getCodeexport.What I ran
8ccea05d1ba7517257ea774e82e1ef03127eebdf, basemain. No merged-preview check.Results
Findings
Blocking
core/libs/prx/libSceIcu/tests/Script.cpp:22callsuscript_getCode_nid_postfix("Latn", codes.data(), ..., &codeStatus). The test includeslibSceIcu.hpp, which includesRecoveredInventory.hpp:45and still declaresint APS5_VABI uscript_getCode_nid_postfix();with C linkage. The new definition atcore/libs/prx/libSceIcu/Script.cpp:20is not declared inScript.hpp, which has nouscript_getCodedeclaration. The call therefore matches a zero-argument declaration, and the test does not compile. The diff removes only the.cppstub inRecoveredInventory.cpp, not the header declaration.Non-blocking
docs/dev/debt/libSceIcu.md:215saysuscript_getCodestill throws without locale resources. The PR changes that path and does not update the note. Check the wording once the build runs.Not verified
guest_icu_recovered_signatures. Not run here.common/sources.txtandi18n/sources.txtformat, whichcmake/Icu.cmake:23-26reads withfile(STRINGS). The submodule is not readable at head.USCRIPT_LATINis 25 in ICU 78.1. The header was not read, and the test asserts 25.uscript_getCodeshape.Files
cmake/Icu.cmake,core/libs/prx/libSceIcu/RecoveredInventory.cpp,core/libs/prx/libSceIcu/Script.cpp,core/libs/prx/libSceIcu/tests/Script.cpp, all through the diff. Head-side reads coverScript.cpplines 1–16 and 60–110, with the rest of the file read only through its diff hunks.To get this to a good state
int APS5_VABI uscript_getCode_nid_postfix();fromcore/libs/prx/libSceIcu/RecoveredInventory.hpp:45.core/libs/prx/libSceIcu/Script.hpp, inside the existingextern "C"block:guest_icu_recovered_signatures.Pull request closed