Skip to content

fix(json): make real number conversion locale independent - #2069

Closed
STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/json-locale-independent-numbers
Closed

STUPIDCONTEM wants to merge 1 commit into
boykopovar:mainfrom
STUPIDCONTEM:fix/json-locale-independent-numbers

Conversation

@STUPIDCONTEM

@STUPIDCONTEM STUPIDCONTEM commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Evidence review (2026-10-09)

Closed by maintainer; not ready to reopen. Required evidence: A title that actually reaches a non-C numeric locale; guest setlocale currently accepts only C/POSIX.

Game/title ID: none verified. No PS5 title execution is claimed.

Deferred after maintainer review: guest setlocale currently accepts only C/POSIX, so the host-locale regression does not demonstrate a reachable title failure. Reopening requires a title that encounters this behavior. See maintainer feedback. The patch and test results below are historical and excluded from the current proposed integration.

What

When the host C numeric locale uses a comma decimal separator, libSceJson2 parses valid JSON 1.5 as 1 and serializes real 1.5 as invalid JSON 1,5. JSON requires a literal decimal point (RFC 8259 section 6).

Parse real numbers with an immutable C numeric locale and verify the full token was consumed. Format real numbers with locale-independent to_chars at the existing 17-digit precision. Preserve native strtod range/subnormal handling and existing -0 spelling. No process-wide locale changes are made by the library.

Tested

Windows 10 Pro 19045, WinLibs GCC 15.2.0 UCRT posix SEH r7, Release, BUILD_TESTING=ON. Independent branch from f145139676a48306681d3a4d5fabf83938759daf.

  • Extended guest_json fails on unchanged upstream at comma-locale ParseReal("1.5") == 1.5 and passes three focused runs with the fix.
  • Cases cover fractional/exponent parsing and serialization, signed zero and underflow, smallest subnormal and maximum finite double round trips, existing overflow rejection, and restoration of the previous host locale.
  • The comma-decimal locale is available and exercised on this Windows host. That portion is conditional on locale availability on other systems; C-locale cases always run.
  • Full default and explicit libs builds passed; full CTest: 488/488, 29.52 seconds. Committed-head conventions, whitespace and test-registration checks passed.
  • Parent independently reviewed and tested the final implementation; a second agent reviewed locale ownership and numeric boundaries.

Guest setlocale currently accepts C/POSIX only, so this fixes dependence on locale changes made by host/native code. Linux, PS5 hardware and titles were not tested locally. Open #1390 changes initializer/RTTI exports and #2004 changes object emptiness; neither implements these numeric functions.

Checklist

  • Based on current main; no other open PR implements the same change (historical base; current readiness not asserted)
  • One topic per PR; follow-ups go in a new PR
  • No comments added to code
  • Unimplemented paths throw; no silent stubs added
  • No investigation notes, reports or images added to the repository
  • No third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes; parent independently reviewed and tested the final change.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: guest setlocale only accepts C/POSIX, so no title can put the library in a comma locale here. Reopen with a title that hits it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants