feat(libSceLibcInternal): format numbers through num_put #17746
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17746"
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 QW1CKS on 2026-11-09T14:03:20Z.
What
Implements the 24
std::num_putexports that were import-resolution stubs:num_put<char>::do_putandnum_put<wchar_t>::putanddo_put, each in the eightbool,long,unsigned long,long long,unsigned long long,double,long doubleandconst void*forms. They format through the same code thenum_putfacet inlibcalready uses, so a value prints as it does through a stream that owns that facet: the base, case, show-base, show-point, show-pos, adjust-field, width, fill and precision flags, thenumpunctdecimal point, thousands separator and grouping, theboolalphanames, and the width reset after the field. A stream whose buffer refuses the overflow gets a failed iterator back.The argument lists come from the mangled names. The wide forms write two bytes per character and take a 16-bit
wchar_tfill, the guest wide character width theStringandnumpunct<wchar_t>code already uses.This leaves the
_Fput,_Iput,_Ffmt,_Ifmt,_Putand_Repmembers throwing: they take scratch buffers whose layout and Dinkumware-specific output are not established. The narrowputoverloads do not exist in this tree yet and are not added here.Tested
Linux (Ubuntu 24.04, GCC 13.3, Ninja),
build-gccwithBUILD_TESTING=ON, 2026-11-09, onmainca761cadc5:guest_libc_internal_num_put(new) passes. It covers decimal, zero and the smallestlong; width padding with the default and left adjust;hex|showbase|uppercase|internalplacement; the largestunsigned long longin both the narrow and wide forms and their agreement;doubleandlong double;boolwith and withoutboolalphain both widths; the pointer form in both widths; the width reset; and a full buffer whose overflow refuses, in both widths.num_put<char>::do_put(long)put back toNotImplemented_nid_no_patch, the same test aborts at_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE6do_putES3_RSt8ios_basecl_nid_postfix not implemented.guest_libc_internal_*tests,guest_wide_compare_blocksandguest_printfstill pass; 44 of 44.check_conventions.py --base upstream/mainpasses.tools/progress.py: 309/1137 before and 333/1137 after inlibSceLibcInternal; the overall figure moves 13417/38567 to 13441/38567 (+0.06 points).Not tested: a console. The debt entry lists what is unmeasured: the guest
long doublewidth, which the host side handles as its own 80-bit value; that a title's wide streambuf advances its put pointer by two bytes per character; and the module's answer for a missing locale or facet.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T08:46:39Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
328b110ac377183bd24bdf18e2ec386fdc874723from the prepared diff and inspected the changed implementations and relevant locale helpers throughrepo_read.py. No commands or tests were run by me; test results below are reported by the author.Results
num_puttestupstream/mainFindings
Blocking
None.
Non-blocking
Not verified
No repository files were excluded by the prepared manifest. I read
core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libc/include/GuestLocale.hpp, andcore/libs/prx/libc/src/LocaleSupport.cpp, plus the changed test and debt documentation in the prepared diff. I did not read the full test or debt documentation. Console behavior, guestlong doublewidth, wide stream buffer pointer advancement, and missing-locale/facet behavior remain unverified.To get this to a good state
Nothing is required. Optional: add tests for invalid precision and locale-specific wide grouping.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T23:40:05Z.
Review: COMMENTED
Actionable comments posted: 5
Architecture findings (2)
Advisory architecture findings (2)
0e1d5deb-a4f6-40a9-9262-1f1742ec50d4Reviewing files that changed from the base of the PR and between
1bc45d0dacand316e0cf48e.core/libs/prx/libSceLibcInternal/CMakeLists.txtcore/libs/prx/libSceLibcInternal/Err.cppcore/libs/prx/libSceLibcInternal/NumPutField.cppcore/libs/prx/libSceLibcInternal/include/ErrExports.hppcore/libs/prx/libc/include/GuestLocale.hppcore/libs/prx/libc/src/LocaleSupport.cppcore/libs/tests/GuestLibcInternalNumPut.cppdocs/dev/debt/libSceLibcInternal.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T23:43:30Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: guard the wide grouping code against empty grouping strings.
What I ran
316e0cf48e92c6f3fcc5be8afa88fb51989c9395using the preparedreviewbundle andrepo_read.py.Results
Findings
Blocking
core/libs/prx/libc/src/LocaleSupport.cpp:1123readsgrouping[0]without checking whether the string is empty.PutWideIntegerobtains this string from the widenumpunctfacet immediately before the access. An empty grouping value therefore causes an out-of-bounds read during wide integer formatting. Guard the empty case before indexing, as the behavior of the narrow path also assumes a nonempty grouping value.Non-blocking
None.
Not verified
core/libs/prx/libc/src/LocaleSupport.cpp,core/libs/prx/libSceLibcInternal/NumPutField.cpp,core/libs/tests/GuestLibcInternalNumPut.cpp, andcore/libs/prx/libSceLibcInternal/Err.cpp. Other changed full texts listed as included in the manifest were not read in full; the manifest lists no excluded files.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T01:59:51Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (2)
Advisory architecture findings (2)
7af0361c-d687-461a-b5b7-71655a9a190cReviewing files that changed from the base of the PR and between
316e0cf48eandf9c0ce97b6.core/libs/prx/libc/src/LocaleSupport.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T02:02:34Z.
Review: COMMENTED
Reviewed — no blocking findings
The code reviewed has no verified blocking defect; checks were not run during this review, so a formal approval is not justified.
What I ran
Reviewed head
f9c0ce97b607fff2f216e8fa1e2382c105e01dcfagainstmainusing the prepared diff and the pinnedrepo_read.pyreader. No commands or tests were run.Results
Negative control
Not run during this review. The description reports that the new test failed when a formatter was restored to its unimplemented state; this was not independently verified.
Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed the prepared diff and changed code at the pinned head, including LocaleSupport.cpp, Err.cpp, and GuestLibcInternalNumPut.cpp.
Not verified
No tests, build, or prechecks were run. Console behavior, including wide stream buffer advancement and guest
long doublehandling, remains unverified as described by the author. Read all changed files listed in the manifest; no changed files were excluded.To get this to a good state
Nothing is required. Optional: run the reported test and prechecks on this head and validate the behavior on console hardware.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:55:28Z.
Review: COMMENTED
The Linux integration build passed the registered libc-internal num_put test.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T16:46:05Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
0b1a2acbd108c1c80a50eab2c1a87f666d308c0fhas no verified blocking defects.What I ran
Reviewed the prepared diff and changed-file context using
repo_read.py. No tests or builds were run.Results
Negative control
Not run; no source mutation or test execution was performed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No tests or build were run by this review. Console behavior and the author-reported test and tool results were not independently verified. Read all eight files listed under
reviewedinfiles.json:core/libs/prx/libSceLibcInternal/CMakeLists.txt,core/libs/prx/libSceLibcInternal/Err.cpp,core/libs/prx/libSceLibcInternal/NumPutField.cpp,core/libs/prx/libSceLibcInternal/include/ErrExports.hpp,core/libs/prx/libc/include/GuestLocale.hpp,core/libs/prx/libc/src/LocaleSupport.cpp,core/libs/tests/GuestLibcInternalNumPut.cpp, anddocs/dev/debt/libSceLibcInternal.md. The manifest lists no excluded files.To get this to a good state
Nothing is required.
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.