feat(libSceIcu): implement uprv_isASCIILetter from ICU 68.2 #19951

Merged
MarcZX10 merged 17 commits from upstream-pr/19951 into main 2026-11-24 09:22:25 +00:00
MarcZX10 commented 2026-11-14 09:20:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T09:20:09Z.


What

One libSceIcu export is still a stub that throws NotImplemented_nid_no_patch: uprv_isASCIILetter. This PR implements it in core/libs/prx/libSceIcu/AsciiStrings.cpp, following ICU 68.2's common/cstring.cpp, and keeps its debt fragment.

The other four helpers (uprv_toupper, uprv_stricmp, uprv_strnicmp, uprv_asciitolower) are already implemented on main in InvariantChars.cpp, so this PR no longer defines them again.

Tested

  • Environment: Linux x86-64 (Debian 12, GCC 12.2), throwaway archive build of the branch head 54edec3b4f.
  • ctest -R '^guest_icu': 44 of 44 tests pass, including the new guest_icu_ascii_strings.
  • The new test checks every byte for the three character helpers against the C locale (<cctype>), and checks the string helpers against a C-locale reference for n from 0 to 4 and for the full strings, comparing signs. It also pins exact values by hand: "Z" vs "[" gives 31, "\xC3" vs "\xE3" gives -32, strnicmp("abcdef","ABCxyz",4) gives -20.
  • Negative control: not run. The base has the five names as stubs that throw NotImplemented_nid_no_patch, so the new tests are expected to abort on base; that expectation has not been checked.
  • tools/check_conventions.py --base upstream/main: passed.
  • tools/pr_precheck.py (no-build): see the comment on this PR.

Not run: the console, Windows, macOS, and the ICU data-driven helpers. The ASCII charset family is assumed, not measured on the console; the debt doc says so.

Overlap

  • No open PR names these five functions in its title, body or diff.
  • tools/pr_overlap.py --branch fails closed: it could not compare the shared files CMakeLists.txt, LegacyExports.cpp, include/LegacyExports.hpp and docs/dev/debt/libSceIcu.md with the open PRs that touch them (14340, 14443, 16250, 17297, 17852, 17916, 18203, 18208, 18210, 18344, 18557, 19435, among others).
  • Manual comparison: none of the open PRs that touch the libSceIcu legacy files adds or removes any of these five names. The removed lines are five stub blocks; a textual conflict with a neighbouring hunk in another PR is still possible, and would be resolved by rebasing this branch.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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:5309644491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19951). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T09:20:09Z. --- ### What One libSceIcu export is still a stub that throws `NotImplemented_nid_no_patch`: `uprv_isASCIILetter`. This PR implements it in `core/libs/prx/libSceIcu/AsciiStrings.cpp`, following ICU 68.2's `common/cstring.cpp`, and keeps its debt fragment. The other four helpers (`uprv_toupper`, `uprv_stricmp`, `uprv_strnicmp`, `uprv_asciitolower`) are already implemented on `main` in `InvariantChars.cpp`, so this PR no longer defines them again. ### Tested - Environment: Linux x86-64 (Debian 12, GCC 12.2), throwaway archive build of the branch head `54edec3b4f`. - `ctest -R '^guest_icu'`: 44 of 44 tests pass, including the new `guest_icu_ascii_strings`. - The new test checks every byte for the three character helpers against the C locale (`<cctype>`), and checks the string helpers against a C-locale reference for `n` from 0 to 4 and for the full strings, comparing signs. It also pins exact values by hand: `"Z"` vs `"["` gives 31, `"\xC3"` vs `"\xE3"` gives -32, `strnicmp("abcdef","ABCxyz",4)` gives -20. - Negative control: not run. The base has the five names as stubs that throw `NotImplemented_nid_no_patch`, so the new tests are expected to abort on base; that expectation has not been checked. - `tools/check_conventions.py --base upstream/main`: passed. - `tools/pr_precheck.py` (no-build): see the comment on this PR. Not run: the console, Windows, macOS, and the ICU data-driven helpers. The ASCII charset family is assumed, not measured on the console; the debt doc says so. ### Overlap - No open PR names these five functions in its title, body or diff. - `tools/pr_overlap.py --branch` fails closed: it could not compare the shared files `CMakeLists.txt`, `LegacyExports.cpp`, `include/LegacyExports.hpp` and `docs/dev/debt/libSceIcu.md` with the open PRs that touch them (14340, 14443, 16250, 17297, 17852, 17916, 18203, 18208, 18210, 18344, 18557, 19435, among others). - Manual comparison: none of the open PRs that touch the libSceIcu legacy files adds or removes any of these five names. The removed lines are five stub blocks; a textual conflict with a neighbouring hunk in another PR is still possible, and would be resolved by rebasing this branch. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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
PrivacyOnion commented 2026-11-14 09:31:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T09:31:12Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 54edec3b4f:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_icu_ascii_strings_tests built cleanly.
  • CTest (guest_icu_ascii_strings):
    1/1 Test #3420: guest_icu_ascii_strings ..........   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • AsciiStrings.cpp (uprv_isASCIILetter_nid_postfix): verified ASCII letter range logic and int8_t return type across all 256 byte values and signed char negative values.
    • AsciiStrings.cpp (uprv_toupper_nid_postfix, uprv_asciitolower_nid_postfix): verified case conversions, offset arithmetic ('A' - 'a', 0x20), and preservation of non-ASCII/high-bit bytes.
    • AsciiStrings.cpp (uprv_stricmp_nid_postfix): verified null pointer handling, unsigned char promotion before lowercasing, and string termination logic.
    • AsciiStrings.cpp / LegacyExports.hpp: verified export signatures, return types, and LP64/LLP64 32-bit int/uint32_t portability against ICU 68.2 common/cstring.h.
    • LegacyExports.cpp: verified clean removal of the five previous NotImplemented_nid_no_patch stubs without orphaned declarations or duplicate exports.
    • docs/dev/debt/libSceIcu.md: verified debt documentation updates and relative link paths for the implemented ASCII string helpers.
  • Concerns:
    • core/libs/prx/libSceIcu/AsciiStrings.cpp:47-48: uprv_strnicmp_nid_postfix validates null pointers before checking n == 0. When n == 0, zero bytes are compared and the function must return 0 regardless of inputs, matching upstream ICU 68.2's cstring.cpp (where if (dst == src || n == 0) return 0; precedes null checks). Calling uprv_strnicmp_nid_postfix(nullptr, "abc", 0) returns -1 instead of 0, and calling uprv_strnicmp_nid_postfix("abc", nullptr, 0) returns 1 instead of 0.
    • core/libs/prx/libSceIcu/AsciiStrings.cpp:1-10: Lines 1-10 contain 10 lines of file header and copyright comments, violating the strict repository rule in AGENTS.md: 'No comments in code, except #endif and namespace ends.'
  • Note: the AI-assisted checkbox can stay.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5903438678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19951#pullrequestreview-5903438678). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T09:31:12Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `54edec3b4f`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_icu_ascii_strings_tests` built cleanly. - **CTest** (`guest_icu_ascii_strings`): ``` 1/1 Test #3420: guest_icu_ascii_strings .......... Passed 0.00 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - AsciiStrings.cpp (uprv_isASCIILetter_nid_postfix): verified ASCII letter range logic and int8_t return type across all 256 byte values and signed char negative values. - AsciiStrings.cpp (uprv_toupper_nid_postfix, uprv_asciitolower_nid_postfix): verified case conversions, offset arithmetic ('A' - 'a', 0x20), and preservation of non-ASCII/high-bit bytes. - AsciiStrings.cpp (uprv_stricmp_nid_postfix): verified null pointer handling, unsigned char promotion before lowercasing, and string termination logic. - AsciiStrings.cpp / LegacyExports.hpp: verified export signatures, return types, and LP64/LLP64 32-bit int/uint32_t portability against ICU 68.2 common/cstring.h. - LegacyExports.cpp: verified clean removal of the five previous NotImplemented_nid_no_patch stubs without orphaned declarations or duplicate exports. - docs/dev/debt/libSceIcu.md: verified debt documentation updates and relative link paths for the implemented ASCII string helpers. - **Concerns**: - core/libs/prx/libSceIcu/AsciiStrings.cpp:47-48: uprv_strnicmp_nid_postfix validates null pointers before checking n == 0. When n == 0, zero bytes are compared and the function must return 0 regardless of inputs, matching upstream ICU 68.2's cstring.cpp (where `if (dst == src || n == 0) return 0;` precedes null checks). Calling uprv_strnicmp_nid_postfix(nullptr, "abc", 0) returns -1 instead of 0, and calling uprv_strnicmp_nid_postfix("abc", nullptr, 0) returns 1 instead of 0. - core/libs/prx/libSceIcu/AsciiStrings.cpp:1-10: Lines 1-10 contain 10 lines of file header and copyright comments, violating the strict repository rule in AGENTS.md: 'No comments in code, except `#endif` and namespace ends.' - Note: the AI-assisted checkbox can stay. Requesting changes for the points above.
PrivacyOnion commented 2026-11-14 11:28:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T11:28:51Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 1f577cc77e:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_icu_ascii_strings_tests built cleanly.
  • CTest (guest_icu_ascii_strings):
    1/1 Test #3420: guest_icu_ascii_strings ..........   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceIcu/AsciiStrings.cpp: verified null-pointer handling and boundary logic in uprv_stricmp_nid_postfix and uprv_strnicmp_nid_postfix, confirming that nullptr inputs return correct relative ordering (-1, 0, 1) and that n == 0 in uprv_strnicmp_nid_postfix evaluates null checks first before returning 0 without dereferencing pointers, matching ICU 68.2 common/cstring.cpp.
    • core/libs/prx/libSceIcu/AsciiStrings.cpp: verified character mapping and unsigned byte conversions in uprv_isASCIILetter_nid_postfix, uprv_toupper_nid_postfix, and uprv_asciitolower_nid_postfix across all 256 byte values, ensuring non-ASCII bytes (> 127) and negative char values are left unmodified without signed arithmetic overflow or undefined behavior.
    • core/libs/prx/libSceIcu/LegacyExports.cpp and core/libs/prx/libSceIcu/include/LegacyExports.hpp: verified that all five NotImplemented_nid_no_patch stubs were cleanly removed from LegacyExports.cpp without duplicate symbols, and that their declarations in LegacyExports.hpp match their exact return types, parameter types, and APS5_VABI calling convention.
    • core/libs/tests/GuestIcuAsciiStrings.cpp: verified comprehensive test coverage across the full [0, 255] byte domain against , exact difference verification, null string edge cases, and bounded comparisons against a C-locale reference implementation across varied sample strings and lengths.
    • core/libs/prx/libSceIcu/CMakeLists.txt: verified build wiring for AsciiStrings.cpp in libSceIcu and correct registration of the guest_icu_ascii_strings test executable with proper include directories, library dependencies, and Windows environment modifications.
    • docs/dev/debt/libSceIcu.md: verified AGENTS.md technical debt compliance, confirming that the five newly implemented helpers are added to the functional inventory list and that the unverified console ASCII charset family assumption is accurately documented.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904090015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19951#pullrequestreview-5904090015). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T11:28:51Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `1f577cc77e`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_icu_ascii_strings_tests` built cleanly. - **CTest** (`guest_icu_ascii_strings`): ``` 1/1 Test #3420: guest_icu_ascii_strings .......... Passed 0.00 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceIcu/AsciiStrings.cpp: verified null-pointer handling and boundary logic in uprv_stricmp_nid_postfix and uprv_strnicmp_nid_postfix, confirming that nullptr inputs return correct relative ordering (-1, 0, 1) and that n == 0 in uprv_strnicmp_nid_postfix evaluates null checks first before returning 0 without dereferencing pointers, matching ICU 68.2 common/cstring.cpp. - core/libs/prx/libSceIcu/AsciiStrings.cpp: verified character mapping and unsigned byte conversions in uprv_isASCIILetter_nid_postfix, uprv_toupper_nid_postfix, and uprv_asciitolower_nid_postfix across all 256 byte values, ensuring non-ASCII bytes (> 127) and negative char values are left unmodified without signed arithmetic overflow or undefined behavior. - core/libs/prx/libSceIcu/LegacyExports.cpp and core/libs/prx/libSceIcu/include/LegacyExports.hpp: verified that all five NotImplemented_nid_no_patch stubs were cleanly removed from LegacyExports.cpp without duplicate symbols, and that their declarations in LegacyExports.hpp match their exact return types, parameter types, and APS5_VABI calling convention. - core/libs/tests/GuestIcuAsciiStrings.cpp: verified comprehensive test coverage across the full [0, 255] byte domain against <cctype>, exact difference verification, null string edge cases, and bounded comparisons against a C-locale reference implementation across varied sample strings and lengths. - core/libs/prx/libSceIcu/CMakeLists.txt: verified build wiring for AsciiStrings.cpp in libSceIcu and correct registration of the guest_icu_ascii_strings test executable with proper include directories, library dependencies, and Windows environment modifications. - docs/dev/debt/libSceIcu.md: verified AGENTS.md technical debt compliance, confirming that the five newly implemented helpers are added to the functional inventory list and that the unverified console ASCII charset family assumption is accurately documented. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!19951
No description provided.