fix(libc): print a NaN's sign in swprintf as titles' libc.prx does #10379
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10379"
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 JJenkx on 2026-10-23T20:10:34Z.
What
The wide printf family (
swprintf,vswprintfand the rest) leaves NaN to the host. There, a negative NaN loses its sign, but a positive one gets+nanwith the+flag. Thelibc.prxthat titles ship formats a NaN inswprintfexactly as in itssnprintf, the way it formats an infinity:-nanfor a negative NaN;+nanwith the+flag andnanwith the space flag for a positive one;NANfor%F,%E,%Gand%A;-, and the0flag ignored.For example,
swprintf(u"[%f][%+f][% F][%5.1e]", -NAN, -NAN, NAN, -NAN)gives[-nan][-nan][ NAN][ -nan]there and[nan][+nan][ NAN][ nan]here.The wide formatter now builds that text itself for a NaN, in both the
doubleandlong doublepaths, through a smallWideNanTexthelper, and pads it with the existingAppendPadded.The narrow family's NaN sign is #10223's (orezraey, measured on a retail PS5's
libSceLibcInternal.sprx). This PR doesn't touch it. An earlier version of this PR changed it too, which duplicated #10223, so that part is gone. On #10223 I posted that eleven titles' bundledlibc.prxprint the narrow NaN text the same way.Tested
Current Linux refresh:
afe172cc68c82877b6c5f2309d70c6920a66e477on main637220db112a3daf4960984290a82fcf65ba7061. The stack is rebuilt linearly in the order #9699 → #9916 → #9927 → #9958 → #10379, with no merge commits or duplicated prerequisite commits. This PR adds one wide-NaN-sign commit. Fresh Release libc/fixture build andguest_formatting,guest_wide_formatting,guest_stdio_variadicpass (3/3) on this exact head; conventions against the tested main and whitespace checks pass. Final-stack conventions against origin/main have zero errors (six inherited debt-length warnings). All five heads also merge cleanly with newer mainc8d34aa8f4d8058d57169cc1e423ba6db00faaf0; that merge preview is not an additional runtime test. The originalWideNanTextbody and its two wide branches are retained after finite double/long-double support. Restored final-head tests pass three repeats. Reverting only this wide change also passes on Linux, so the Linux negative control does not distinguish the Windows bug. All five pinned heads, patches, checks and control logs (SHA-2569cda806ab2a54a4a0ce012517eafb7db0441ab2665d2e49884c3d1fc5b9e0c8a). No fresh Windows, title-library comparison, physical-console, game or performance result is claimed; Windows testing remains paused. The requested fresh Windows validation on #9699 is still outstanding.Historical validation on previous public head
6d8701ab2e86c426f600463dcbb9512fc6be7cbais retained below with its original scope; references there to ‘exact head’ refer to that historical run.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON, on #9958's head 89f761f7ab.libc.prxof PPSA07923 and PPSA13934 natively and calls theirswprintf(NIDnJz16JE1txM) on NaN formats. With this PR'slibc.prxDLL, both formats print byte-identical text to both titles'swprintf.maingives[nan][+nan][ NAN][ nan]and[nan ][ nan][NAN][-inf][+NAN].guest_wide_formatting: the newCheckNanSignchecks those formats against the console's text:[-nan][-nan][ NAN][ -nan];[nan ][ -nan][-NAN][-inf][+NAN].guest_wide_formattingandguest_formattingpass in three runs out of three on the exact head.FormattingWide.cppand these tests,guest_wide_formattingaborts in aRequire, whileguest_formattingstill passes.python tools/check_conventions.py --base#9958's head, andgit diff --check, pass.WindowsFormatting.hpp, so it doesn't conflict with #10223.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)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T20:12:16Z.
Review: DISMISSED
I reviewed the NaN formatting paths and the new narrow/wide test cases. The helper preserves the negative sign and
+/space precedence, and the reported same-title comparisons cover the relevant conversions and flags. Before merge, the shared-file order still needs to be recorded: pairwise merge previews with open #9916, #9927 and #9958 conflict inWindowsFormatting.hpp; #9927 and #9958 also conflict inFormattingWide.cpp. Those PRs are explicitly described here as needing to retain both sets of branches, but this PR's checklist saysDepends on: none. CONTRIBUTING requires agreement on the order and the prerequisite on the checklist. Please coordinate with the authors (these are your PRs per the descriptions), declare the agreed dependency/order—e.g. stack this after #9958 if that is the intended sequence—and confirm the final result keeps both the NaN-sign branch and the existing finite/wide/long-double formatting paths. No merge is requested before that coordination.