feat(libc): implement the std::__sce_v2 money_put virtuals #17331
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17331"
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 Danigamer05 on 2026-11-08T18:14:02Z.
What
Builds on #17296: this branch contains its commits, and through them #17277, #16975, #16949, #16944, #16924, #16919, #16560, #16516, #16214, #16178 and #15923, with current
main. It needs none of their code beyond themoneypunctvirtuals of #17277, which it calls, and their place inLocaleSupport.cpp, so it stacks to avoid conflicts. Until they merge, only the last commit is this PR's change.Implement the two virtuals of
std::__sce_v2::money_put<char>andmoney_put<wchar_t>, which_Makelocbuilds andstd::put_moneycalls. Before this PR, each of their four slots threwNotImplemented_nid_no_patch. These slots are not exports, so this PR adds no NID.The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), vtables0x18CBC0and itswchar_ttwin, read from the disassembly ofdo_put(0xDCD70,0xDD1B0) and of the shared field writer (0xDD610). The writer follows Dinkumware's_Putmfld, as its descendant in microsoft/STL (stl/inc/xlocmon) does, with this module's pattern encoding:$symbol,+sign,vvalue,xnone andspace; other bytes are skipped. A space field writes the fill character, not a space.do_putof digits widens0123456789-through the stream'sctype, takes a leading minus as the sign, keeps the digits up to the first other character, and writes0for none.do_putof along doubletakes the sign from0 > value, divides values of at least 1e35 by 1e10 up to 500 times and appends ten zeros per division, prints the rest withsprintf_s("%.0Lf")and widens it. A negative zero or NaN prints with the minus signsprintf_sgives it, among the digits.grouping, takes the currency symbol only undershowbase, and fills on the left, inside anoneorspacefield underinternal, or on the right. Only the first character of the sign goes in its field; the rest follows the last field.decimal_point,thousands_sep,grouping,frac_digits, the signs, the patterns andcurr_symbolare called through themoneypunctfacet's vtable, so a facet with other virtuals is honored.The
_Makelocdebt entry now names the facets that still throw, and a new entry records that the digits of along doublecome from this library'ssprintf_s.Tested
Windows 11, MinGW GCC 15.2, Release, head on top of #17296. Not run on Linux or macOS, not run in a title.
guest_sce_v2_money_put: the C locale's facets with right, left and internal fill; empty, partial and lone-minus digit strings;long doublerounding, sign and negative zero; thenmoneypunctfacets with set fields: grouping, fraction digits (including a negative count), a space field, a multi-character sign, the international facet, and thewchar_tfacet with non-ASCII separators and signs._Makeloc. Each call randomizes bothmoneypunctfacets' fields (grouping withCHAR_MAXand negative bytes, symbols and signs of up to 7 characters, fraction digits from -20 to 20, shuffled patterns with stray bytes), the stream's flags and width, the fill, the input (digit strings with stray characters;long doubleintegers, fractions, values up to 1e4000, infinities, NaNs and negative zero), and the stream buffer (direct room, overflow, a rejecting overflow, no buffer, an already failed iterator). It compares every character written, the iterator, the stream's width and flags.sprintf_sredirected to this library's: 900,000 calls over 3 seeds, 0 differences.long doubleamounts of 2^66 or more, where the twosprintf_sprint%.0Lfdifferently (the new debt entry).guest_sce_v2_*, locale, string andpublic_headerstest): all pass.sprintf_s. The harness catches 11; the twelfth, dropping the0written for an empty digit string, changes nothing, because the writer pads an empty value with the same zeros. The first test run missed 5 (a trailingnonefield underinternal, grouping bytes that change, a minus among the digits, and the 500-division limit, which only an infinity reaches), so the test was strengthened and they were rerun: the final test catches the same 11.check_conventions,git diff --check: clean. Merges cleanly withmain.pr_overlapreports no open PR with the same functions or conflicting code; it could not compare 52 PRs that conflict withmainon shared files. Of the 4 that touchLocaleSupport.cpp, #12518 exports the unversionedstd::money_put<char>vtable as zeroed data, a different symbol, and #9526, #11172 and #12704 do not touchmoney_put.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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-08T19:51:57Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
850ca12686:tools/check_conventions.pypassed;git diff --checkclean.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T22:02:19Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
a9cd4cc3fb:tools/check_conventions.pypassed;git diff --checkclean.guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_facet_ids_tests,guest_sce_v2_makeloc_tests,guest_sce_v2_messages_tests,guest_sce_v2_money_put_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsfailed to build.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T21:08:20Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
edd201a22c:tools/check_conventions.pypassed;git diff --checkclean.guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_facet_ids_tests,guest_sce_v2_makeloc_tests,guest_sce_v2_messages_tests,guest_sce_v2_money_put_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsbuilt cleanly.guest_sce_v2_makeloc,guest_sce_v2_char_facet_virtuals,guest_sce_v2_num_put_char,guest_sce_v2_num_put_wide,guest_sce_v2_codecvt_wide,guest_sce_v2_collate_moneypunct,guest_sce_v2_messages,guest_sce_v2_money_put,guest_sce_v2_num_get_char,guest_sce_v2_num_get_wide,guest_sce_v2_facet_ids):core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T21:31:57Z.
Review: COMMENTED
Partial review of money_put — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
46eba50533f0702ee02a2ea774f3413bbdec8f4efrom the review folder only (description.md,commits.md,manifest.json,files.json,diff.patch). I read themoney_putwriter and its twodo_putentry points inLocaleSupport.cpp(diff lines 1116–1128, 2553–2724), plus the#includechange. No build, no test run, no repository reader calls.Results
money_putwriterFindings
Blocking
None found in the code I read.
Non-blocking
core/libs/prx/libc/src/LocaleSupport.cpp(diff.patch lines 2596–2597, 2621, 2661–2665): the insertion at line 2597 padsvaluetofractionDigits + 1characters. After that, thevalue.size() <= fractionDigitsbranch at line 2661 and the matching term invalueWidthat line 2621 can never be true. The output is correct, but the branch is dead code. Dropping it would make the writer easier to follow.Not verified
num_get,num_put,ctype,numpunct,codecvt,collate,moneypunct,messages, and their tests (core/libs/tests/*.cpp,core/libs/prx/libc/CMakeLists.txt,docs/dev/debt/libc.md). I did not read them, so this review does not cover the whole PR.maincontains the stacked commits as well. I did not check whether that matches the stack the author intends.SonyLconv(chars[]indices used inSetSceV2MoneyFormats) and ofSceV2IosBase(width,flags) against their declarations. The author's differential test covers this against the module, which I did not run.ios_basefunctions (_Addstd,_Ios_base_dtor) show as removed and re-added at other positions in the diff. I did not confirm the moved bodies are identical.sprintf_soutput forlong doublevalues of 2^66 or more, which the author reports differs from the module's ownsprintf_s. This is recorded in the technical debt entry, not checked here.To get this to a good state
Nothing is required.
Optional: remove the dead branch noted above. Before a formal approval, someone should read the rest of the diff and rerun the libc tests on this head.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T11:39:49Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
bf11a35015:tools/check_conventions.pypassed.guest_sce_v2_char_facet_virtuals_tests,guest_sce_v2_codecvt_wide_tests,guest_sce_v2_collate_moneypunct_tests,guest_sce_v2_messages_tests,guest_sce_v2_money_put_tests,guest_sce_v2_num_get_char_tests,guest_sce_v2_num_get_wide_tests,guest_sce_v2_num_put_char_tests,guest_sce_v2_num_put_wide_testsbuilt cleanly.guest_sce_v2_char_facet_virtuals,guest_sce_v2_num_put_char,guest_sce_v2_num_put_wide,guest_sce_v2_codecvt_wide,guest_sce_v2_collate_moneypunct,guest_sce_v2_messages,guest_sce_v2_money_put,guest_sce_v2_num_get_char,guest_sce_v2_num_get_wide):core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:28:30Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: no blocking defect was verified, but the review is incomplete because the large shared implementation and the other changed tests were not fully inspected.
What I ran
Inspected the prepared diff and selected source ranges at head
bf11a35015a364ef11f5c2371e6b848e3cb10af4usingrepo_read.py. No build, test, or merged-preview check was run by me.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The money output logic and its focused test, locale layout, and relevant technical debt entry were read. The prepared diff was read only through line 300 of 4321;
LocaleSupport.cpponly through selected ranges; the remaining changed tests and CMake changes were not inspected. All files listed as changed in the manifest are included, but not all were read. Author-reported Windows build/tests, differential harness, negative control, and convention checks were not run by me; Linux, macOS, and console behavior were not verified.To get this to a good state
Nothing is required. Optional: complete review of the remaining diff and changed files before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:17:19Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this review; the change is not approved because the full stacked change has not been reviewed.
What I ran
Read the prepared diff at head
95cc41c2757eee263229cd58c2965a0548b7e129and targeted source and test ranges throughrepo_read.py. No commands or tests were run.Results
Findings
Blocking
None identified in the code read.
Non-blocking
None.
Not verified
Read
description.md,commits.md,manifest.json, anddiff.patch, pluscore/libs/prx/libc/include/GuestLocale.hpp, the money formatting implementation incore/libs/prx/libc/src/LocaleSupport.cpp, andcore/libs/tests/GuestSceV2MoneyPut.cpp. All changed files are listed as included in the manifest; the other changed files were not read:core/libs/prx/libc/CMakeLists.txt, the remaining sections ofLocaleSupport.cpp,core/libs/tests/GuestSceV2CharFacetVirtuals.cpp,GuestSceV2CodecvtWide.cpp,GuestSceV2CollateMoneypunct.cpp,GuestSceV2Messages.cpp,GuestSceV2NumGetChar.cpp,GuestSceV2NumGetWide.cpp,GuestSceV2NumPutChar.cpp,GuestSceV2NumPutWide.cpp, anddocs/dev/debt/libc.md. Build and test results in the PR description were not independently verified.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:12:33Z.
Review: COMMENTED
Built the branch’s locale implementation and matching headers against the existing Linux runtime. The focused
GuestSceV2MoneyPutfixture passed.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.