libc: _WStoul, _Iswctype and swscanf_s are stubs; fix branch ready #3077
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 screamm on 2026-10-10T21:46:24Z.
In libc (Export.cpp)
_WStoul,_Iswctypeandswscanf_sareNotImplemented_nid_no_patchstubs._Iswctypeis what Dinkumware'siswalphaand friends expand to, so a title whose C++ runtime classifies wide characters through libc.prx stops on it.Fix branch ready:
screamm:feat/libc-wide-conversions(51fca3ce, on top of the strtol fix63cce467from #3075, both onmain262c0316). Depends on #3075. I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are._WStoul(const wchar_t*, wchar_t**, int)calls the existingwcstoul, which returns 64 bits (the Windowsunsigned longpitfall from #2424 cannot apply); base 1, a negative base and a base above 36 throw, because Windows, FreeBSD and Dinkumware disagree there._Iswctype(wint_t, wctype_t)maps Dinkumware's class numbers 1 to 12 (alnum, alpha, cntrl, digit, graph, lower, print, punct, space, upper, xdigit, blank) onto the checks the existingisw*exports use; the numbering is from Dinkumware'sxwcc.h(P.J. Plauger, as shipped in TI's compiler headers). Other numbers throw, including the FreeBSD masks the existingwctypereturns.swscanf_s(const wchar_t*, const wchar_t*, ...): a new 16-bit wide scanner inScanningWide.cpp(the existingScanGuestreads narrow strings through the hostsscanf), reading arguments with the existingLibcDetail::FormatArguments. It handles%d %i %o %u %x %Xwith all sizes, the float conversions,%s %c %[narrow orl,%nand%%; the_ssize argument is read asunsigned intlike the existingsscanf_s, a null buffer, format or target returns EOF, a too-small buffer is a matching failure with a zeroed first element.%p,%S,%C, unknown length modifiers, ranges in[...],%nwith*or a width, a zero width and characters above 255 into a narrow target throw. Sources: C11 7.29.2.2 and K.3.9.1, FreeBSD 11vfwscanf.cfor integer truncation._ssize width, the matching-failure choices).guest_wide_conversioncovers values above 32 bits, ERANGE, bases and prefixes, non-ASCII stops and throwing bases for_WStoul; every class 1 to 12 against itsisw*function over code points 0 to 0x2FF for_Iswctype; and%d,%lswith a size, a too-small buffer, null arguments,%lc,%l[,%ln, floats including%Lfand the failure cases forswscanf_s.Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs:guest_wide_conversion,guest_math,guest_wide_strings,guest_rune_locale,guest_scan_countandguest_wide_formatting3/3;ctest -j8 -E "^agc_|video_out"389/389;tools/check_conventions.py --base mainandgit diff --checkpass. Not run on Linux.Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:01:33Z.
Fixed by #3083:
_WStoul,_Iswctypeandswscanf_sare implemented, covered byguest_wide_conversion.