fix(libc): return the console's class bits from the ctype functions #10387
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10387"
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 JJenkx on 2026-10-23T20:36:31Z.
What
The ctype classifiers (
isalnum,isalpha,isblank,iscntrl,isdigit,isgraph,islower,isprint,ispunct,isspace,isupper,isxdigit) return 1 for a match. Thelibc.prxthat titles ship returns the matching bits of its classification table instead. For example:isdigit('0')is0x20;isupper('A')is0x02andislower('a')is0x10;isspace(' ')is0x04andisspace('\t')is0x40;isblank('\t')is0x400;iscntrlgives0x80andispunctgives0x08.Which characters match is the same on both sides. Only the nonzero values differ, which shows in code like
count += isdigit(c)or a table indexed by the result.That table is the one
_Getpctypealready exports, in the same bit layout, with one difference: the console marks tab with0x400as well (0x4c0), andmainhad0xc0. The classifiers now return the exported table's bits under the console's masks, and the table gains the tab bit:isalnum0x32isalpha0x12isblank0x404iscntrl0x80isdigit0x20isgraph0x3aislower0x10isprint0x3eispunct0x08isspace0x44isupper0x02isxdigit0x01EOFstill gives 0, and out-of-range values still throw as before.Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main40564ce897.libc.prxof eleven titles natively: PPSA04158, PPSA05916, PPSA07923, PPSA09614, PPSA13934, PPSA20423, PPSA25636, PPSA26528, PPSA33655, PPSA34008 and PPSA35169.EOFand every byte, all eleven print identical values._Getpctype's tab entry is0x4c0there.main'slibc.prxDLL, the values differ on 438 of the 3,084, and the true/false sets on none.libc.prxDLL, all 3,084 values and all 257_Getpctypeentries match PPSA07923's and PPSA13934's.guest_character: the newCheckConsoleClassValueschecks spot values from the console and every input against the console's table and masks. The existing truthiness checks still pass.guest_locale: the_Getpctypetab expectation is now the console's0x4c0.guest_character,guest_localeandguest_rune_localepass in three runs out of three on the exact head.main'sLocaleSupport.cppand these tests,guest_characterandguest_localeabort in aRequire, whileguest_rune_localestill passes.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.isw*functions.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)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T21:20:18Z.
Review: APPROVED
Reviewed the implementation and test diff. The title-binary comparison across eleven libc.prx versions is strong evidence for the exact return masks and tab classification change; the per-byte test checks the exported table against those masks, and EOF/range behavior is preserved. I also checked the overlapping open isascii/toascii PR (#8919): it adds separate exports and tests without overlapping these classifier changes.\n\nCI on this head passed conventions, intake, eligibility, labels, Ubuntu/Windows relinker, macOS x86_64 relinker, ASan relinker, and register-context/write-watch jobs. The macos-latest relinker job failed in unrelated conventions fixture and NID database cache tests; Linux and Windows product jobs were skipped by workflow policy, so those are not validated by hosted CI here. The PR's local Windows test evidence covers guest_character, guest_locale, and guest_rune_locale, but no console/hardware or non-Windows runtime validation is reported. I found no blocking issue in the changed behavior.