feat(icu): implement buffer termination exports #17804

Merged
DonRyuzaki merged 5 commits from upstream-pr/17804 into main 2026-11-12 14:16:47 +00:00
DonRyuzaki commented 2026-11-09 16:49:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DonRyuzaki on 2026-11-09T16:49:13Z.


What

Implement the 3.20 libSceIcu exports u_terminateChars (PuLoqDSNPPw) and u_terminateUChar32s (TuExC-Sja8o). Both follow ICU's buffer termination status rules: write NUL when space remains, report U_STRING_NOT_TERMINATED_WARNING at exact capacity, and report U_BUFFER_OVERFLOW_ERROR when the length exceeds capacity. Calls with a prior failure or a negative length leave the status and buffer alone. A null destination throws only when the call would write to it.

The two legacy placeholders are removed, and a focused guest test covers boundary lengths, all status classes, untouched sentinels and null destinations. The console ABI and behavior remain unverified and are recorded in technical debt.

Scope check: #14144 already implements u_terminateUChars and the two uprv_isInvariant* helpers from my older unpublished five-helper branch, so those are excluded here. The still-open #17297 names these same two NIDs as throwing aliases; this PR adds their behavior and does not depend on #17297. The branches overlap in the legacy export files. Whichever merges second must rebase and remove the duplicate throwing definitions and declarations so each NID remains exported once.

Tested

Latest update (2026-11-12): Pushed head 2e60137227d07533bbf309ffaf648896f68b2093 includes Dean’s requested debt correction: 1689 of 2347 named exports, both termination functions in the implemented list, and 654 remaining placeholder names. It merges cleanly with upstream d78d7858043d6442ae68c82b4e4e9fe87945ed90. On the preceding code-identical head ad80c33dabd47d07323fd7247d0825fe01c9a7a6, the full Linux libs target and guest_icu_terminate_buffer_tests built over upstream dbf944245d55084dded6c74b490e9d3108412084; guest_icu_terminate_buffer passed three CTest repeats. The final commit changes only the debt text. check_conventions.py and git diff --check passed on the final patch. Hosted checks for the latest head are pending; no hosted result is claimed yet.

Merged upstream main dff7484fd1ba7b6827c355a0524e191c47073e76 into the existing branch; then-pushed head b298ebc2a55eee366f2c0d0ff4d0a5a1113b2aa1. The only merge conflict was the ICU CMake list. It now retains upstream LanguageTag.cpp, this PR's TerminateBuffer.cpp, and both focused test registrations alongside LocaleCore. The worktree is clean.

  • git diff --check dff7484fd1ba7b6827c355a0524e191c47073e76...HEAD: passed.
  • python3 tools/check_conventions.py --base origin/main: passed on the merged branch.
  • Ubuntu 24.04 WSL2, Release, BUILD_TESTING=ON: overlaid the eight exact PR files on a clean, pinned dff7484 source tree and built the full libs target plus focused ICU test targets successfully (861 Ninja steps). The generated libSceIcu.prx was NID-patched. guest_icu_terminate_buffer, guest_icu_language_tag, guest_icu_locale_core, and public_headers each passed three CTest repeats (12/12 runs, no failures). SHA-256: unpatched aa706ee28a97c082dbe14ae9cc7c324e50db785ff4d52f6805187a1cfcec8f32; patched c18e9ddef0c44469977e46857262677f6b9af9fcc261c6fa2674ce32d841f782.
  • Exact-head GitHub Build, Emscripten portability, and Progress report all completed successfully on that earlier merge commit.
  • The patched-library load test and full CTest suite were not run on this head.

No console, game, local Windows or macOS focused test, or full project test-suite result is claimed.

Checklist

  • Based on current main; #17297 declares the same NIDs as throwing aliases but does not implement their behavior
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5227617081 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17804). Originally posted by [DonRyuzaki](https://github.com/DonRyuzaki) on 2026-11-09T16:49:13Z. --- ### What Implement the 3.20 `libSceIcu` exports `u_terminateChars` (`PuLoqDSNPPw`) and `u_terminateUChar32s` (`TuExC-Sja8o`). Both follow ICU's buffer termination status rules: write NUL when space remains, report `U_STRING_NOT_TERMINATED_WARNING` at exact capacity, and report `U_BUFFER_OVERFLOW_ERROR` when the length exceeds capacity. Calls with a prior failure or a negative length leave the status and buffer alone. A null destination throws only when the call would write to it. The two legacy placeholders are removed, and a focused guest test covers boundary lengths, all status classes, untouched sentinels and null destinations. The console ABI and behavior remain unverified and are recorded in technical debt. Scope check: #14144 already implements `u_terminateUChars` and the two `uprv_isInvariant*` helpers from my older unpublished five-helper branch, so those are excluded here. The still-open #17297 names these same two NIDs as throwing aliases; this PR adds their behavior and does not depend on #17297. The branches overlap in the legacy export files. Whichever merges second must rebase and remove the duplicate throwing definitions and declarations so each NID remains exported once. ### Tested **Latest update (2026-11-12):** Pushed head `2e60137227d07533bbf309ffaf648896f68b2093` includes Dean’s requested debt correction: 1689 of 2347 named exports, both termination functions in the implemented list, and 654 remaining placeholder names. It merges cleanly with upstream `d78d7858043d6442ae68c82b4e4e9fe87945ed90`. On the preceding code-identical head `ad80c33dabd47d07323fd7247d0825fe01c9a7a6`, the full Linux `libs` target and `guest_icu_terminate_buffer_tests` built over upstream `dbf944245d55084dded6c74b490e9d3108412084`; `guest_icu_terminate_buffer` passed three CTest repeats. The final commit changes only the debt text. `check_conventions.py` and `git diff --check` passed on the final patch. Hosted checks for the latest head are pending; no hosted result is claimed yet. Merged upstream main `dff7484fd1ba7b6827c355a0524e191c47073e76` into the existing branch; then-pushed head `b298ebc2a55eee366f2c0d0ff4d0a5a1113b2aa1`. The only merge conflict was the ICU CMake list. It now retains upstream `LanguageTag.cpp`, this PR's `TerminateBuffer.cpp`, and both focused test registrations alongside LocaleCore. The worktree is clean. - `git diff --check dff7484fd1ba7b6827c355a0524e191c47073e76...HEAD`: passed. - `python3 tools/check_conventions.py --base origin/main`: passed on the merged branch. - Ubuntu 24.04 WSL2, Release, `BUILD_TESTING=ON`: overlaid the eight exact PR files on a clean, pinned `dff7484` source tree and built the full `libs` target plus focused ICU test targets successfully (861 Ninja steps). The generated `libSceIcu.prx` was NID-patched. `guest_icu_terminate_buffer`, `guest_icu_language_tag`, `guest_icu_locale_core`, and `public_headers` each passed three CTest repeats (12/12 runs, no failures). SHA-256: unpatched `aa706ee28a97c082dbe14ae9cc7c324e50db785ff4d52f6805187a1cfcec8f32`; patched `c18e9ddef0c44469977e46857262677f6b9af9fcc261c6fa2674ce32d841f782`. - Exact-head GitHub [Build](https://github.com/boykopovar/AnyPS5/actions/runs/43100143004), [Emscripten portability](https://github.com/boykopovar/AnyPS5/actions/runs/43100143080), and [Progress report](https://github.com/boykopovar/AnyPS5/actions/runs/43100143215) all completed successfully on that earlier merge commit. - The patched-library load test and full CTest suite were not run on this head. No console, game, local Windows or macOS focused test, or full project test-suite result is claimed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; #17297 declares the same NIDs as throwing aliases but does not implement their behavior - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17804
No description provided.