feat(libc): implement _Iswctype #1993
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1993"
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 overlordxrz-source on 2026-10-09T04:13:27Z.
What
Implements
_Iswctype(CyXs2l-1kNA), which still throws onmainaslibcCyberUnknown07. Cyberpunk 2077 (PPSA04029, import list in #266) and GTA III Definitive Edition (import list in #267) import it._Iswctype(wint_t wc, wctype_t desc)is Dinkumware's internal classifier.descis not a hostwctype_tand not a bit mask. It is a 1-based index into Dinkumware's_Wctypeclass table. Plauger's own headers and sources (Dinkumware C library V5.00, as shipped in QNX's libc) give the full order:xwcc.hdefinesiswalnumas_Iswctype(wc, 1), thenalpha2,cntrl3,digit4,graph5,lower6,print7,punct8,space9,upper10,xdigit11 andblank12: https://github.com/vocho/openqnx/blob/master/trunk/lib/c/public/xwcc.hxwctytab.cbuilds the table in that order, with entry 0 holding the range-table pointer: https://github.com/vocho/openqnx/blob/master/trunk/lib/c/ansi/xwctytab.cwctype.csearches from index 1 and returns 0 for an unknown name: https://github.com/vocho/openqnx/blob/master/trunk/lib/c/ansi/wctype.cxwctype.c(_Iswctypeitself) scans the ranges betweentable[desc]andtable[desc + 1], sodesc0 is an empty range and returns 0: https://github.com/vocho/openqnx/blob/master/trunk/lib/c/ansi/xwctype.cThis agrees with the one value already confirmed in Sony's
libc.prx: its_WStoulcalls_Iswctype(c, 9)for white space (review of #492).The classes are tested the same way as the narrow
is*exports inLocaleSupport.cpp:ClassifyCharacterwith the classicstd::ctype<char>, so_Iswctype(c, n)matches the narrow function for every value fromEOFto 255. Above 255, and forWEOF, it returns 0, as in Dinkumware's C-locale table (ASCII ranges only) and the narrow table, which classifies nothing above 127.desc0 returns 0. Adescabove 12 throwsstd::invalid_argument, because Dinkumware would read past its table and the repo loads no locale that could add classes.wcis taken as 32 bits, the same as Dinkumware's comparisons on the fullwint_t.Two known differences from Plauger's 2006 C-locale table, kept on purpose so the wide classes match the narrow ones: that table leaves NUL and DEL out of
cntrl, and puts\n,\v,\fand\rinblank. Sony's own table couldn't be checked.#1498 also replaces this stub, but it treats
descas a bit mask (ClassificationBits(c) & desc), so_Iswctype(c, 9)from_WStoulwould test two unrelated mask bits instead of white space. #1783 implements the FreeBSDiswctype/wctype(_CTYPE_*masks), which is a separate export with its owndescmeaning. It doesn't overlap with this PR, and the two merge cleanly.Log
I don't own either title, so I can't paste a stop line from
main. The evidence is the import lists in #266 and #267.Tested
aarch64 Debian 13 host. The full project can't be built here because it needs x86-64.
core/libs/tests/GuestCharacter.cppnow checks all 12 classes against the host C-localeis*forEOF..255,desc0, all classes returning 0 for 256..0xFFFF and above, and the throw fordesc13. It passes natively and under UBSan. Swapping thepunct/spaceentries makes it fail, as it should.LocaleSupport.cpp,Export.cppand the test compile for x86_64-linux-gnu and x86_64-windows-gnu with-Wall -Wextra(Zig 0.17 clang). The only warning is the existing-Wreturn-type-c-linkagefromGeneral.hpp.tools/nid_names.pycomputesCyXs2l-1kNAfor_Iswctype.python3 tools/check_conventions.py --base origin/mainpasses.Export.cpp, only because they delete or replace the stubs next to this one. Resolving it means keeping both sides' deletions.Checklist
main. The one other open PR that changes this function is #1498, which also changes this stub as part of a larger change; see WhatNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T04:13:48Z.
Progress report (
f145139→2406209)📈 System libraries: 84.79% (+0.03%, +1 implemented, -1 removed functions)
✅ 1 implemented
_Iswctype_nid_postfix🗑️ 1 removed
libcCyberUnknown07Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:20:49Z.
Review: APPROVED
Reviewed the full diff and the cited Dinkumware sources. The 1-based class ordering and C-locale table behavior match the implementation; the PS5-side
_WStoulcall to_Iswctype(c, 9)grounds the whitespace descriptor. The tests cover all 12 classes, upper Unicode values, and invalid descriptors, and Linux, Windows, Conventions, and Progress checks pass on this head. The unverified differences are recorded in TechnicalDebt.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:50Z.
Closing: only the import lists in #266 and #267 show
_Iswctype, with no stop line from main. Reopen with thenot implementedline when a title stops here.Pull request closed