Commit Graph

10 Commits

Author SHA1 Message Date
Adrià 7e4edf509a
Merge pull request #4616 from EagleBearerYS/fix/libc-strtod-quiet-nan-windows
fix(libc): return the default quiet NaN from the strtod family
2026-10-13 17:11:55 +02:00
Adrià 3b94f923a5
Merge pull request #4633 from QRMOE/fix-libc-wcsxfrm-truncation
fix(libc): terminate truncated wcsxfrm results
2026-10-13 17:00:13 +02:00
Feuris cd0e9dccd7 feat(libc): implement wcscat 2026-10-13 08:38:02 -03:00
Yunus Shaikh c55f377fb0 refactor(libc): place the NaN helpers and test includes apart from neighbouring changes 2026-10-12 11:03:36 -07:00
QRMOE 79d88af192
test(libc): cover wide transform output bounds 2026-10-12 19:04:00 +02:00
Yunus Shaikh aa4a9b4faf fix(libc): return the default quiet NaN from the strtod family
C17 7.22.1.3 and 7.29.4.1.1 interpret NAN(n-char-sequence) as a quiet
NaN. With MinGW-w64, std::strtod, strtof and strtold are mingw-w64's
gdtoa functions, which copy the hex digits into the significand
without the quiet bit, and for long double without the x87 integer
bit: strtod("nan(0x123)") returned the signaling NaN
0x7ff0000000000123 and strtold a pseudo-NaN. A payload whose only set
bit is the implicit or x87 integer bit gave infinity:
strtof("nan(0x800000)"), strtod("nan(0x10000000000000)") and
strtold("nan(0x8000000000000000)") returned +inf. glibc returns quiet
NaNs that keep the payload.

C17 7.12.11.2p2 makes nan("n-char-sequence") equivalent to
strtod("NAN(n-char-sequence)", NULL), and nan and nanf already return
the console's fixed quiet NaNs, ignoring the tag. ParseFloat, which
strtod, strtof, strtold, atof and the wide variants share, now returns
the same values, 0x7ff8000000000000 and 0x7fc00000, negated after a
minus sign, on Windows and Linux. strtold returns the x87 default
quiet NaN, since no console nanl was observed.
2026-10-12 09:04:31 -07:00
DariusHQ 6ef110af48 feat(libc): implement wcstok
PS5MC (PPSA99420) stops at start-up on wcstok once sendfile is in. It
follows FreeBSD's three-argument wcstok over the guest's 16-bit wchar_t:
leading delimiters are skipped, the token ends at the next delimiter,
which is overwritten with 0, and *last is set to null when the string
runs out.
2026-10-11 16:41:50 +03:00
Claude 8c714f76af
fix(libc): stop the wcstol family at a binary prefix on Linux
wcstol, wcstoll, wcstoul and wcstoull parse the ASCII prefix of the
guest's UTF-16 text with std::strtoll and std::strtoull, which glibc 2.38
and later bind to the C23 __isoc23_* functions: wcstol(u"0b101", &end, 0)
returned 5 with the end pointer after the whole string. They now check
StopAtBinaryPrefix_nid_no_patch first, like the narrow functions, and the
end pointer maps back through ParseAsciiPrefix as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 21:26:13 +00:00
Fishybeing 5b0d28392c fix(libc): parse and collate guest wide strings as 16-bit units
wcstod, wcstof, wcstold, wcstol, wcstoll, wcstoul, wcstoull, wcscoll and wcsxfrm still forwarded to the host's wchar_t functions, which use 32-bit units on Linux. The wcsto* functions now parse the ASCII prefix of the guest string with the narrow parsers, as the C locale accepts only ASCII white space and digits. wcscoll compares like wcscmp and wcsxfrm copies, as strcoll and strxfrm do in the C locale.
2026-10-08 10:27:00 +02:00
Fishybeing cd39c8db54 fix(libc): read guest wide strings as 16-bit units
The guest's wchar_t is 16 bits, but wcslen, wcscmp, wcsncmp, wcscpy, wcsncpy, wcschr, wcsrchr, wcsstr, wcspbrk, wcsspn and the wmem functions forwarded to the host's wchar_t functions, which use 32-bit units on Linux. Implement them on char16_t. The wide conversions that still use the host's wchar_t are listed in TechnicalDebt.
2026-10-08 09:39:55 +02:00