feat(libSceIcu): implement C string conversion helpers #12294
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12294"
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 Ninot1Quyi on 2026-10-28T07:57:44Z.
What
The five ICU C-string helpers currently resolve to inventory stubs and throw. Implement their integer formatting/parsing and in-place ASCII case conversion, with canonical public declarations and runtime coverage.
T_CString_int64ToString2m4vg20UoXIT_CString_integerToStringwwOr3NA7FRcT_CString_stringToIntegerRGVOIIycuyAT_CString_toLowerCase9duJwhiYGCET_CString_toUpperCasewuiJZ6Iy6McNames/NIDs come from the PS5 3.20 inventory; signatures and semantics follow ICU 78.1 cstring.h and cstring.cpp. The implementation is independently written.
Formatting preserves 32/64-bit width, supports bases 2–16 and treats negative values as signed only in decimal. Parsing uses guest LP64
strtoul, preserving its errno behavior before taking the low 32 bits. Case conversion changes ASCII letters only and accepts null pointers. Unsigned arithmetic and caller storage avoid upstream signed-minimum and temporary-buffer undefined behavior. Invalid formatting arguments and a null parse source throw; native invalid-input behavior and firmware availability remain unverified in the library debt.The existing progress tool reports libSceIcu 6/120 → 11/120, replacing five inventory stubs without changing the total.
Tested
Ubuntu 24.04 x86-64, GCC 13.3, Release, full CMake configuration with
BUILD_TESTING=ONand bundled dependencies; based on main660a0b306d.libSceIcu, its reallibc/libkerneldependencies,nid_patcher, and all three ICU test executables.ctest --test-dir build -R '^guest_icu_(cstring|version|unescape)$' --output-on-failure: 3/3 passed, 0.08 seconds, including after rebasing.std::to_chars, all formatting bases and signed extrema, length/NUL/canaries, parsing bases 2–36, LP64 overflow and errno, and all 256 byte values for ASCII conversion.-fsanitize=undefined -fno-sanitize-recover=undefined, linked to the real runtime libraries: passed without UBSan reports.nid_patcher: baseline ICU sources atb99bbebacd(unchanged in660a0b306d) threw in 5/5 cases; this implementation passed 5/5. The probe exercises values and output buffers, not only symbol presence.python3 core/libs/tests/test_public_headers.py --audit-only,python3 tools/check_conventions.py --base origin/main, andgit diff --check: passed.tools/pr_overlap.py --branch codex/system-librariesagainst 1,374 applicable open PR heads using a read-only adapter for the GitHub-plugin PR listing. No confirmed overlaps or duplicate exports. Manually checked #11088, #11115, #11118, #11122, #11132 and #11136, which already conflict with main: their exports are disjoint, and this change adds no shared-file merge conflicts.No Windows, macOS, console or game run is claimed; the full repository test suite was not run.
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-28T08:46:02Z.
Review: APPROVED
Reviewed the five exports against the pinned ICU 78.1 C-string implementation and the test coverage. The formatting paths preserve signed decimal and unsigned non-decimal behavior, including safe handling of minimum signed values; the parse wrapper delegates to the project’s guest
strtoul; and case conversion is limited to ASCII bytes as ICU’s configured path is for this target. Tests cover the NIDs through the provider, formatting bases/extrema/canaries, parse overflow/errno, and all byte values. Hosted Windows and conventions checks pass; Linux focused runs and UBSan are reported by the author, while macOS and console runs are explicitly not claimed. I found no blocking issue.