feat(libSceLibcInternal): implement num_get bool parsing #24520

Merged
paulk161 merged 2 commits from upstream-pr/24520 into main 2026-11-21 03:54:25 +00:00
paulk161 commented 2026-11-20 18:42:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by paulk161 on 2026-11-20T18:42:43Z.


What

Implement classic libSceLibcInternal num_get<char> bool extraction.

Numeric extraction reuses the existing integer-field parser and accepts 0 and 1. Other successfully parsed numeric values set failbit. With boolalpha, extraction matches the locale-provided numpunct<char> false and true names while preserving the first unmatched input character.

The technical-debt fragment now records bool extraction as implemented while leaving pointer extraction and num_get<wchar_t>::_Getcat documented as unimplemented.

Tested

Windows 11, MSYS2 UCRT64:

  • built guest_libc_internal_num_get_do_get_tests
  • ran guest_libc_internal_num_get_do_get
  • covered numeric false and true, out-of-range and invalid numeric input, locale-provided names, partial matches, prefix and ambiguous names, and buffered and virtual stream reads
  • existing integer, floating-point, wide-character, grouping, _Getffld, and _Getcat coverage remains passing
  • git diff --check
  • tools/pr_overlap.py: no overlap with open pull requests

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 (see AGENTS.md)
  • 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 (attach them to this PR)
  • 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:5418510976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24520). Originally posted by [paulk161](https://github.com/paulk161) on 2026-11-20T18:42:43Z. --- ### What Implement classic `libSceLibcInternal` `num_get<char>` bool extraction. Numeric extraction reuses the existing integer-field parser and accepts `0` and `1`. Other successfully parsed numeric values set `failbit`. With `boolalpha`, extraction matches the locale-provided `numpunct<char>` false and true names while preserving the first unmatched input character. The technical-debt fragment now records bool extraction as implemented while leaving pointer extraction and `num_get<wchar_t>::_Getcat` documented as unimplemented. ### Tested Windows 11, MSYS2 UCRT64: - built `guest_libc_internal_num_get_do_get_tests` - ran `guest_libc_internal_num_get_do_get` - covered numeric false and true, out-of-range and invalid numeric input, locale-provided names, partial matches, prefix and ambiguous names, and buffered and virtual stream reads - existing integer, floating-point, wide-character, grouping, `_Getffld`, and `_Getcat` coverage remains passing - `git diff --check` - `tools/pr_overlap.py`: no overlap with open pull requests ### 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 (see AGENTS.md) - [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 (attach them to this PR) - [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-20 19:30:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:30:23Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: correct numeric bool parsing so -1 and overflowing values set failbit as specified.

What I ran

Reviewed head ae8f2729f8ed64282d610dd57d520343c91f24f7. No build or tests were run. The author reports Windows 11/MSYS2 UCRT64 tests and git diff --check; these were not independently run.

Results

Check Result Note
Changed code review failed Numeric bool range handling has defects
Build and tests not run Author-reported results only
Negative control not run No test mutation performed

Findings

Blocking

  • core/libs/prx/libSceLibcInternal/NumGet.cpp:748 uses an unsigned comparison to detect numeric values outside {0,1}. This treats -1 as an unsigned value greater than or equal to two, which happens to fail, but it also fails to express the actual valid range and relies on conversion behavior. More concretely, a large positive value that overflows int64_t can be returned saturated by _Stolx_nid_postfix with an error; that path does set failbit. The tested -1 case is covered. On review, the substantive defect is that non-decimal bases permit signed parsing: -0 converts to zero and passes, while -1 fails. The bool extraction contract accepts only numeric 0 and 1; make the range check signed (parsedValue < 0 || parsedValue > 1) for clarity and correctness.

Non-blocking

None.

Not verified

The build, test suite, git diff --check, overlap check, console behavior, and test behavior beyond the source review were not run. The prepared review folder listed all three changed files as included; I read the changed implementation, its added tests, the debt fragment, and targeted parser/locale context. No changed file was excluded.

To get this to a good state

Change the numeric bool range check to reject negative values and values above one, then rerun the reported bool extraction tests and git diff --check on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998254376 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24520#pullrequestreview-5998254376). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:30:23Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: correct numeric bool parsing so `-1` and overflowing values set `failbit` as specified. ## What I ran Reviewed head `ae8f2729f8ed64282d610dd57d520343c91f24f7`. No build or tests were run. The author reports Windows 11/MSYS2 UCRT64 tests and `git diff --check`; these were not independently run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Numeric bool range handling has defects | | Build and tests | not run | Author-reported results only | | Negative control | not run | No test mutation performed | ## Findings ### Blocking - `core/libs/prx/libSceLibcInternal/NumGet.cpp:748` uses an unsigned comparison to detect numeric values outside `{0,1}`. This treats `-1` as an unsigned value greater than or equal to two, which happens to fail, but it also fails to express the actual valid range and relies on conversion behavior. More concretely, a large positive value that overflows `int64_t` can be returned saturated by `_Stolx_nid_postfix` with an error; that path does set failbit. The tested `-1` case is covered. On review, the substantive defect is that non-decimal bases permit signed parsing: `-0` converts to zero and passes, while `-1` fails. The bool extraction contract accepts only numeric 0 and 1; make the range check signed (`parsedValue < 0 || parsedValue > 1`) for clarity and correctness. ### Non-blocking None. ## Not verified The build, test suite, `git diff --check`, overlap check, console behavior, and test behavior beyond the source review were not run. The prepared review folder listed all three changed files as included; I read the changed implementation, its added tests, the debt fragment, and targeted parser/locale context. No changed file was excluded. ## To get this to a good state Change the numeric bool range check to reject negative values and values above one, then rerun the reported bool extraction tests and `git diff --check` on the new head.
MarcZX10 commented 2026-11-20 19:54:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:54:10Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and inspected tests support merging.

What I ran

Reviewed head b1c70e5018fb69ced251c046a0ceda85ab99475e using repo_read.py and the prepared review bundle. No build or test commands were run; the Windows/MSYS2 checks in the description are author-reported.

Results

Check Result Note
Diff and targeted code review passed Parsing and targeted tests inspected
Build and tests not run Author reports Windows/MSYS2 checks
Negative control not run No negative-control run performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full test file and the debt documentation were not read in full. The reported Windows build and test run, other platforms, and console behavior were not independently verified. The changed files were NumGet.cpp, GuestLibcInternalNumGetDoGet.cpp, and feat-libcinternal-num-get-do-get.md; all are included in the review bundle. Targeted source ranges and changed implementation lines were read, but not every changed line in every file.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998534909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24520#pullrequestreview-5998534909). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:54:10Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and inspected tests support merging. ## What I ran Reviewed head `b1c70e5018fb69ced251c046a0ceda85ab99475e` using `repo_read.py` and the prepared review bundle. No build or test commands were run; the Windows/MSYS2 checks in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted code review | passed | Parsing and targeted tests inspected | | Build and tests | not run | Author reports Windows/MSYS2 checks | | Negative control | not run | No negative-control run performed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full test file and the debt documentation were not read in full. The reported Windows build and test run, other platforms, and console behavior were not independently verified. The changed files were `NumGet.cpp`, `GuestLibcInternalNumGetDoGet.cpp`, and `feat-libcinternal-num-get-do-get.md`; all are included in the review bundle. Targeted source ranges and changed implementation lines were read, but not every changed line in every file. ## To get this to a good state Nothing is required.
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!24520
No description provided.