feat(libc): implement the ctype<char> widen and narrow members #15714
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15714"
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 B-Howell on 2026-11-04T09:07:41Z.
What
Implements the four
std::ctype<char>widen and narrow members that libSceLibcInternal declared as stubs throwing throughNotImplemented_nid_no_patchinInventoryExports2.cpp:_ZNKSt5ctypeIcE8do_widenEczwcNQT0Avck_ZNKSt5ctypeIcE8do_widenEPKcS2_PcW5OtP+WC800[first, last)to the destination, returnslast_ZNKSt5ctypeIcE9do_narrowEcc4SnCJmLL27U_ZNKSt5ctypeIcE9do_narrowEPKcS2_cPc-nCVE3kBjjA[first, last)to the destination, returnslastThe reference is the Dinkumware
ctype<char>in microsoft/STLstl/inc/xlocaleat e1ed302. There,do_widen(char _Byte)isreturn _Byte;, the range form is_CSTD memcpy(_Dest, _First, static_cast<size_t>(_Last - _First)); return _Last;, and the twodo_narrowforms do the same while ignoring the default character. An empty range returnslastwithout callingmemcpy, so a null destination is accepted for it. The facet pointer is not read. The NIDs were checked by computing them from the mangled names with the repository's NID algorithm.libc already calls the
widenandwidenRangeslots of guestctype<char>vtables throughGuestLocale::CtypeVtable(num_putwidens its digits throughwidenRangeat 0x48). This change addsnarrowandnarrowRangeafter them at 0x50 and 0x58, the declaration order inxlocale(do_widen(char),do_widen(range),do_narrow(char, char),do_narrow(range)), withstatic_asserts for all four offsets.Changes:
core/libs/prx/libc/src/LocaleSupport.cpp: the four members, next tocollate<char>::transform. They are declared inprx/libc/include/Api.hpp.core/libs/prx/libc/include/GuestLocale.hpp: thenarrowandnarrowRangeslots, plus offset asserts forwiden,narrowandnarrowRange.core/libs/prx/libSceLibcInternal/InventoryExports2.cpp: the four stubs are removed.core/libs/tests/GuestLocale.cpp:CheckCtypeCharConversionsputs the four exports into aCtypeVtableand calls them through a facet. It checks everycharvalue for both single forms (with?and\0defaults), a full range and a sub-range that include\0,\x7f,\x80and\xffwith an untouched guard byte after the destination, and empty ranges with a null destination.docs/dev/debt/libSceLibcInternal.md: the four "signatures and behavior are unverified" entries are removed.docs/dev/debt/libc.md: a Functional entry records the reference, the empty-range rule, the slot layout, and that the consolelibc.prxbodies were not read and the exportedctype<char>vtable object stays zeroed.tools/progress.pycollect_libraries(): origin/main has 9913 done of 37146 (libc 1628 done and 19 todo, libSceLibcInternal 92 done and 1045 todo). This branch has 9917 done (libc 1632 done and 19 todo, libSceLibcInternal 92 done and 1041 todo). Done goes up by 4 and no new todo appears.Tested
Only the focused test target and the libraries were built. No title was run.
ctest -R '^(guest_locale|conventions_unknown_nids|conventions_debt_length|conventions_doc_links|debt_split)$'ran 3 times, and each run passed 5 of 5 tests with 0 failures.guest_localeis the guest test that holds the new check.conventions_unknown_nids,conventions_debt_length,conventions_doc_linksanddebt_splitare the repository's checker self-tests for the conventions and the debt-file split. They were run because both debt files changed.LocaleSupport.cpp,Api.hpp,GuestLocale.hppandInventoryExports2.cppplus the new test fail to buildguest_locale_tests. The errors say the four_ZNKSt5ctypeIcE…_nid_postfixfunctions are not declared and thatGuestLocale::CtypeVtablehas no membernarrowornarrowRange.python3 tools/check_conventions.py --base origin/mainprinted "All conventions checks passed."python3 tools/pr_overlap.py --branch feat/r2-ctype-char-widenfound no PR exporting the same functions and no PR adding the same files. It found file-level matches only, inLocaleSupport.cpp,GuestLocale.cpp,GuestLocale.hpp,Api.hppand the libSceLibcInternal debt file (for example #10165, #12510, #12511, #12518, #12704 and #13486). I also grepped the added lines of all 1814 open PRs against main for these four symbols, their NIDs andnarrowRange. None of them has a match.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)🤖 Generated with Claude Code