libc: strtol family leaves the end pointer at a bare 0x prefix on Windows; fix branch ready #3075
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:04Z.
On Windows, the libc
strtolfamily (strtol,strtoul,strtoimax,wcstol,wcstoul,_Stoul, ...) sets the end pointer to the start of the string for a bare0xprefix with no hex digit after it, in base 0 and 16:strtoul("0xg", &end, 16)leavesendat"0xg"instead of just after the0. The C standard's subject-sequence rule, FreeBSD and glibc all return 0 with the end pointer after the0; the Linux build already does. The cause is the shared Windows helperStopAtBinaryPrefix_nid_no_patchin Strings.cpp, which only handles the0bprefix the host C runtime accepts.Fix branch ready:
screamm:fix/libc-strtol-0x-prefix(63cce467, one commit onmain262c0316). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. The helper is renamedStopAtPrefixLetter_nid_no_patchand also stops at a0xwithout a hex digit; five rows are added to the existingguest_mathstrtol/strtoimax and strtoul tables (" -0xz!"base 0,"0xg"and"0x"base 16," +0Xg!"base 0,"0x!"base 16), each expecting 0 with the end pointer after the0.Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs:guest_math3/3;ctest -j8 -E "^agc_|video_out"388/388 with this commit alone;tools/check_conventions.py --base mainandgit diff --checkpass. Not run on Linux, where the helper is not used.Written with Claude Code assistance (found and fixed by a subagent while testing
_WStoul, reviewed and validated in this session).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T01:08:49Z.
Fixed by #3082.