feat(libc): implement isascii and toascii #8919

Merged
iAbdulrrahman merged 1 commit from upstream-pr/8919 into main 2026-10-24 05:21:46 +00:00
iAbdulrrahman commented 2026-10-21 06:11:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iAbdulrrahman on 2026-10-21T06:11:19Z.


What

Implement standard ASCII character classification and conversion exports isascii (NID 29nFZNtp8s) and oascii (NID UAg7CJ8TXis) in libc.
Extend unit tests in core/libs/tests/GuestCharacter.cpp covering ASCII validation and bitmasking over values in and outside the standard range.

Tested

  • Unit test coverage extended in GuestCharacter.cpp verifying standard range values (0..127 true for isascii, false otherwise; bitmask & 0x7F for oascii) as well as out-of-range and negative character values.
  • Passed python3 tools/check_conventions.py --base origin/main.
  • Passed python3 tools/pr_overlap.py --branch feat/libc-isascii-toascii with zero overlapping exports or conflicts.

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:4947230313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919). Originally posted by [iAbdulrrahman](https://github.com/iAbdulrrahman) on 2026-10-21T06:11:19Z. --- ### What Implement standard ASCII character classification and conversion exports isascii (NID 29nFZNtp8s) and oascii (NID UAg7CJ8TXis) in libc. Extend unit tests in core/libs/tests/GuestCharacter.cpp covering ASCII validation and bitmasking over values in and outside the standard range. ### Tested - Unit test coverage extended in GuestCharacter.cpp verifying standard range values (0..127 true for isascii, false otherwise; bitmask & 0x7F for oascii) as well as out-of-range and negative character values. - Passed python3 tools/check_conventions.py --base origin/main. - Passed python3 tools/pr_overlap.py --branch feat/libc-isascii-toascii with zero overlapping exports or conflicts. ### 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
MarcZX10 commented 2026-10-21 06:16:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:16:33Z.


The conventions check currently fails with section 'What' is missing or empty, even though the section is visible in the PR body. The body starts with a UTF-8 BOM (\uFEFF) before ### What; removing that leading BOM should let the required-heading parser recognize it. The implementation and boundary tests look straightforward, but I have not run the full build/test target.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309444533 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919#issuecomment-6309444533). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:16:33Z. --- The conventions check currently fails with `section 'What' is missing or empty`, even though the section is visible in the PR body. The body starts with a UTF-8 BOM (`\uFEFF`) before `### What`; removing that leading BOM should let the required-heading parser recognize it. The implementation and boundary tests look straightforward, but I have not run the full build/test target.
MarcZX10 commented 2026-10-21 06:20:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:20:41Z.

Review: APPROVED


The author removed the leading BOM and the current conventions check now passes. The implementation matches the ASCII range check and low-seven-bit conversion, and the tests cover negative and above-ASCII values. I reviewed the diff but did not run the guest test binary locally; the PR description reports the cases added, and runtime CI is not providing a build here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5595689762 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919#pullrequestreview-5595689762). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:20:41Z. **Review:** APPROVED --- The author removed the leading BOM and the current conventions check now passes. The implementation matches the ASCII range check and low-seven-bit conversion, and the tests cover negative and above-ASCII values. I reviewed the diff but did not run the guest test binary locally; the PR description reports the cases added, and runtime CI is not providing a build here.
iAbdulrrahman commented 2026-10-21 06:20:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iAbdulrrahman on 2026-10-21T06:20:48Z.


Thanks for pointing that out! The leading UTF-8 BOM has been removed from the description, and the conventions check is now passing green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309503952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919#issuecomment-6309503952). Originally posted by [iAbdulrrahman](https://github.com/iAbdulrrahman) on 2026-10-21T06:20:48Z. --- Thanks for pointing that out! The leading UTF-8 BOM has been removed from the description, and the conventions check is now passing green.
r1p0N commented 2026-10-21 07:29:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by r1p0N on 2026-10-21T07:29:41Z.


(c & ~0x7F) == 0 and c & 0x7F match glibc's isascii/toascii for every int in -70000..70000 (checked in isolation). Negative inputs and values above 255 are handled correctly, and the test covers them (-100, 128, 256, 258, -1).
LGTM. Not run: the full guest_character test through ctest.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310561075 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919#issuecomment-6310561075). Originally posted by [r1p0N](https://github.com/r1p0N) on 2026-10-21T07:29:41Z. --- (c & ~0x7F) == 0 and c & 0x7F match glibc's isascii/toascii for every int in -70000..70000 (checked in isolation). Negative inputs and values above 255 are handled correctly, and the test covers them (-100, 128, 256, 258, -1). LGTM. Not run: the full guest_character test through ctest.
tkcm01 commented 2026-10-21 18:12:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tkcm01 on 2026-10-21T18:12:36Z.


Windows data point for 285275e678, merged onto main 99844c7ee (clean merge). GitHub Actions windows-latest running this repo's Build workflow (full Windows build, WinLibs GCC, Release, BUILD_TESTING=ON) on my fork.

  • With the PR: 1814 tests, all passed, guest_character included (run).
  • Negative control, main plus only this PR's GuestCharacter.cpp: guest_character_tests does not link (isascii_nid_postfix and toascii_nid_postfix undefined), as expected for new exports (run).

Not tested: Linux, macOS, a title.
AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323165192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8919#issuecomment-6323165192). Originally posted by [tkcm01](https://github.com/tkcm01) on 2026-10-21T18:12:36Z. --- Windows data point for `285275e678`, merged onto `main` `99844c7ee` (clean merge). GitHub Actions `windows-latest` running this repo's Build workflow (full Windows build, WinLibs GCC, Release, `BUILD_TESTING=ON`) on my fork. - With the PR: 1814 tests, all passed, `guest_character` included ([run](https://github.com/tkcm01/AnyPS5/actions/runs/39644092212)). - Negative control, `main` plus only this PR's `GuestCharacter.cpp`: `guest_character_tests` does not link (`isascii_nid_postfix` and `toascii_nid_postfix` undefined), as expected for new exports ([run](https://github.com/tkcm01/AnyPS5/actions/runs/39644100661)). Not tested: Linux, macOS, a title. 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!8919
No description provided.