feat(libSceLibcInternal): implement wide num_put::_Fput #24911

Open
0x70776c wants to merge 2 commits from upstream-pr/24911 into main
0x70776c commented 2026-11-21 10:19:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 0x70776c on 2026-11-21T10:19:47Z.


What

Implement std::num_put<wchar_t>::_Fput(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, const char*, size_t) (_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_FputES3_RSt8ios_basewPKcm, NID IdV-tXejEGQ) in libSceLibcInternal:

  • Read guest digits, widen through ctype<wchar_t> when present (or unsigned byte widening fallback), apply numpunct<wchar_t> decimal point and grouping/thousands separators (skipping inf/nan, stopping at exponents, and guarding empty grouping patterns), preserve sign and 0x/0X prefixes for internal padding, and reset stream->width to 0.
  • Short-circuit writes if out.failed becomes true.
  • Add unit tests in core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp (guest_libc_internal_wide_num_put_float_field).
  • Remove the resolved debt entry via docs/dev/debt/changes/feat-libcinternal-wide-num-put-fput.md.

Tested

  • python3 tools/check_conventions.py --base origin/main
  • cmake --build build --target guest_libc_internal_wide_num_put_float_field_tests --parallel
  • ctest --test-dir build --output-on-failure -R '^(guest_libc_internal_wide_num_put_float_field|public_headers)$' (2/2 passed)

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5426809406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911). Originally posted by [0x70776c](https://github.com/0x70776c) on 2026-11-21T10:19:47Z. --- ### What Implement `std::num_put<wchar_t>::_Fput(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, const char*, size_t)` (`_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_FputES3_RSt8ios_basewPKcm`, NID `IdV-tXejEGQ`) in `libSceLibcInternal`: - Read guest `digits`, widen through `ctype<wchar_t>` when present (or unsigned byte widening fallback), apply `numpunct<wchar_t>` decimal point and grouping/thousands separators (skipping `inf`/`nan`, stopping at exponents, and guarding empty grouping patterns), preserve sign and `0x`/`0X` prefixes for `internal` padding, and reset `stream->width` to 0. - Short-circuit writes if `out.failed` becomes true. - Add unit tests in `core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp` (`guest_libc_internal_wide_num_put_float_field`). - Remove the resolved debt entry via `docs/dev/debt/changes/feat-libcinternal-wide-num-put-fput.md`. ### Tested - `python3 tools/check_conventions.py --base origin/main` - `cmake --build build --target guest_libc_internal_wide_num_put_float_field_tests --parallel` - `ctest --test-dir build --output-on-failure -R '^(guest_libc_internal_wide_num_put_float_field|public_headers)$'` (2/2 passed) ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt and the licence notice of code adapted from upstream - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-21 10:23:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:23:31Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: fix unsafe handling of an empty grouping pattern and add coverage for it.

What I ran

Reviewed head dd7830c373e32ba4cbb29684a7c2c4bab861ade4. No build or test commands were run; the run folder reports author-side test results only.

Results

Check Result Note
Diff and source review passed All six changed files included
Build and tests not run Author reports build and two tests passed

Findings

Blocking

  • core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp:82 — InsertWideSeparators dereferences *group without first checking that grouping contains a byte. An empty grouping string therefore reads beyond its valid contents when the grouping loop is entered, which can happen for a finite value with enough integer digits and no decimal separator. Guard the loop on *group != '\0' and add a test with an empty grouping pattern.

Non-blocking

None.

Not verified

Build and tests were not run here; reported checks came from the PR description. No files were excluded by the manifest. Read the changed implementation, test, export declaration, CMake section and relevant Err.cpp context, plus the description, commits, manifest and diff.

To get this to a good state

Fix the empty-pattern read and add a regression test; rerun the reported build and tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004609534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911#pullrequestreview-6004609534). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T10:23:31Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: fix unsafe handling of an empty grouping pattern and add coverage for it. ## What I ran Reviewed head `dd7830c373e32ba4cbb29684a7c2c4bab861ade4`. No build or test commands were run; the run folder reports author-side test results only. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | All six changed files included | | Build and tests | not run | Author reports build and two tests passed | ## Findings ### Blocking - `core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp:82` — `InsertWideSeparators` dereferences `*group` without first checking that `grouping` contains a byte. An empty grouping string therefore reads beyond its valid contents when the grouping loop is entered, which can happen for a finite value with enough integer digits and no decimal separator. Guard the loop on `*group != '\0'` and add a test with an empty grouping pattern. ### Non-blocking None. ## Not verified Build and tests were not run here; reported checks came from the PR description. No files were excluded by the manifest. Read the changed implementation, test, export declaration, CMake section and relevant `Err.cpp` context, plus the description, commits, manifest and diff. ## To get this to a good state Fix the empty-pattern read and add a regression test; rerun the reported build and tests on the updated head.
PrivacyOnion commented 2026-11-21 10:26:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T10:26:01Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against dd7830c373:

  • Conventions: tools/check_conventions.py failed.
    (pull request): error: [pr-template] Fill in the pull request template: answer AI-assisted with yes or no
    (pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none
    2 findings, 2 errors; GitHub shows at most 10 error annotations, the job summary lists all
    
  • Build: guest_libc_internal_wide_num_put_float_field_tests built cleanly.
  • CTest (guest_libc_internal_wide_num_put_float_field):
    1/1 Test #4444: guest_libc_internal_wide_num_put_float_field ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004626088 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911#pullrequestreview-6004626088). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T10:26:01Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `dd7830c373`: - **Conventions**: `tools/check_conventions.py` failed. ``` (pull request): error: [pr-template] Fill in the pull request template: answer AI-assisted with yes or no (pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none 2 findings, 2 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` - **Build**: `guest_libc_internal_wide_num_put_float_field_tests` built cleanly. - **CTest** (`guest_libc_internal_wide_num_put_float_field`): ``` 1/1 Test #4444: guest_libc_internal_wide_num_put_float_field ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` Requesting changes for the points above.
PrivacyOnion commented 2026-11-21 11:03:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T11:03:31Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7fd6adf3ab:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_wide_num_put_float_field_tests built cleanly.
  • CTest (guest_libc_internal_wide_num_put_float_field):
    1/1 Test #4444: guest_libc_internal_wide_num_put_float_field ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/Err.cpp, core/libs/prx/libSceLibcInternal/include/ErrExports.hpp, core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_FputES3_RSt8ios_basewPKcm_nid_postfix validates stream, stream->locale, and *stream->locale, and verifies digit buffer readability via GuestCopyIn_nid_no_patch, throwing std::invalid_argument on null or inaccessible memory.
    • Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that InsertWideSeparators properly guards against empty grouping strings and trailing null terminators (*group != '\0'), respects CHAR_MAX / non-positive grouping limits, and avoids grouping inf/nan values.
    • Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that alignment and padding logic handles IosLeft (0x2), IosInternal (0x8), and default right alignment while preserving sign and 0x/0X prefixes, short-circuits writes when out.failed is set, and resets stream->width to 0.
    • Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that WidenDigits properly looks up _ZNSt5ctypeIwE2idE_nid_postfix to invoke widenMethods[1] with fallback to unsigned byte widening when the facet is not installed.
    • Verified that core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp registers the test application heap, tests empty and non-empty grouping patterns, padding modes, and error conditions, and restores global facet IDs upon completion without leaking state.
    • Verified that docs/dev/debt/changes/feat-libcinternal-wide-num-put-fput.md correctly documents the removed debt entry and that no code comments or convention violations are present.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004792984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911#pullrequestreview-6004792984). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T11:03:31Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `7fd6adf3ab`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_wide_num_put_float_field_tests` built cleanly. - **CTest** (`guest_libc_internal_wide_num_put_float_field`): ``` 1/1 Test #4444: guest_libc_internal_wide_num_put_float_field ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibcInternal/Err.cpp`, `core/libs/prx/libSceLibcInternal/include/ErrExports.hpp`, `core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE5_FputES3_RSt8ios_basewPKcm_nid_postfix validates stream, stream->locale, and *stream->locale, and verifies digit buffer readability via GuestCopyIn_nid_no_patch, throwing std::invalid_argument on null or inaccessible memory. - Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that InsertWideSeparators properly guards against empty grouping strings and trailing null terminators (*group != '\0'), respects CHAR_MAX / non-positive grouping limits, and avoids grouping inf/nan values. - Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that alignment and padding logic handles IosLeft (0x2), IosInternal (0x8), and default right alignment while preserving sign and 0x/0X prefixes, short-circuits writes when out.failed is set, and resets stream->width to 0. - Verified in core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp that WidenDigits properly looks up _ZNSt5ctypeIwE2idE_nid_postfix to invoke widenMethods[1] with fallback to unsigned byte widening when the facet is not installed. - Verified that core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp registers the test application heap, tests empty and non-empty grouping patterns, padding modes, and error conditions, and restores global facet IDs upon completion without leaking state. - Verified that docs/dev/debt/changes/feat-libcinternal-wide-num-put-fput.md correctly documents the removed debt entry and that no code comments or convention violations are present. Looks Good To Me
MarcZX10 commented 2026-11-21 11:07:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:07:00Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation changes wide floating field formatting at head 7fd6adf3ab872dda4dfb51164dd5db9eebe0fa30; I found no verified blocking defect, but did not run the reported checks or verify all changed files.

What I ran

No commands were run. I inspected the prepared diff and bundled file contents; repo_read.py was unavailable as a callable command in this review interface.

Results

Check Result Note
Code inspection passed Core implementation and test source read
Reported build and tests not run Results in the PR description are author-reported
Complete changed-file review not run Some changed files were not inspected

Findings

Blocking

None verified in the inspected implementation.

Non-blocking

None.

Not verified

Read: description.md, commits.md, manifest.json, diff.patch, files/core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp, files/core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp, files/core/libs/prx/libSceLibcInternal/include/ErrExports.hpp, and core/libs/prx/libc/include/GuestLocale.hpp.

Not read: the full contents of core/libs/prx/libSceLibcInternal/CMakeLists.txt and Err.cpp, the full changed-file inventory in files.json, and any changed files other than those listed above. The repository reader search command and checks reported in the description were not run.

To get this to a good state

Nothing is required. Optional: complete inspection of the remaining changed files and run the reported build and tests before relying on this review as approval evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004804589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911#pullrequestreview-6004804589). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T11:07:00Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation changes wide floating field formatting at head `7fd6adf3ab872dda4dfb51164dd5db9eebe0fa30`; I found no verified blocking defect, but did not run the reported checks or verify all changed files. ## What I ran No commands were run. I inspected the prepared diff and bundled file contents; `repo_read.py` was unavailable as a callable command in this review interface. ## Results | Check | Result | Note | |---|---|---| | Code inspection | passed | Core implementation and test source read | | Reported build and tests | not run | Results in the PR description are author-reported | | Complete changed-file review | not run | Some changed files were not inspected | ## Findings ### Blocking None verified in the inspected implementation. ### Non-blocking None. ## Not verified Read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `files/core/libs/prx/libSceLibcInternal/WideNumPutFloatField.cpp`, `files/core/libs/prx/libSceLibcInternal/tests/WideNumPutFloatField.cpp`, `files/core/libs/prx/libSceLibcInternal/include/ErrExports.hpp`, and `core/libs/prx/libc/include/GuestLocale.hpp`. Not read: the full contents of `core/libs/prx/libSceLibcInternal/CMakeLists.txt` and `Err.cpp`, the full changed-file inventory in `files.json`, and any changed files other than those listed above. The repository reader search command and checks reported in the description were not run. ## To get this to a good state Nothing is required. Optional: complete inspection of the remaining changed files and run the reported build and tests before relying on this review as approval evidence.
ligmaSec commented 2026-12-03 12:43:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:43:19Z.

Review: COMMENTED


Compiled and ran WideNumPutFloatField on Linux with the branch’s changed sources and the existing libc runtime. The wide float output, overflow, and rejected-input assertions passed.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170032990 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24911#pullrequestreview-6170032990). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:43:19Z. **Review:** COMMENTED --- Compiled and ran `WideNumPutFloatField` on Linux with the branch’s changed sources and the existing libc runtime. The wide float output, overflow, and rejected-input assertions passed. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/24911:upstream-pr/24911'
git switch 'upstream-pr/24911'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/24911'
git switch 'upstream-pr/24911'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/24911'
git switch 'upstream-pr/24911'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/24911'
git switch 'main'
git merge --squash 'upstream-pr/24911'
git switch 'main'
git merge --ff-only 'upstream-pr/24911'
git switch 'main'
git merge 'upstream-pr/24911'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!24911
No description provided.