fix(json2): keep numeric conversion independent of host locale #7215

Merged
simonbronk merged 6 commits from upstream-pr/7215 into main 2026-10-22 10:05:27 +00:00
simonbronk commented 2026-10-17 17:08:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-17T17:08:46Z.


What

With a decimal-comma host LC_NUMERIC, Json2 emits invalid JSON (1.5 becomes 1,5) and silently reads JSON 1.5 as 1. In the regression, {"value":1.5,"list":[2.5,-0.125]} becomes {"value":1,"list":[2,-0]} after parsing and serializing.

Use to_chars with the existing 17 significant digits for output and from_chars for input. On an out-of-range input only, use a stream explicitly imbued with the classic locale to retain the prior underflow-to-signed-zero behavior and overflow exception. Do not change the process locale. The numeric grammar still rejects a decimal comma.

RFC 8259 section 6 requires . as the decimal point. The C++ numeric conversion specification specifies C-locale formatting. Console rounding and formatting remain unmeasured and are recorded in Json2 debt. No title unblock, percentage increase or performance gain is claimed.

Tested

Windows, WinLibs MinGW-w64 GCC 15.2.0r7 UCRT, Release, actual shared libSceJson2.prx and its CMake test executable; base 66702f1cffd3646f2d674ed093fde0a85a70761f:

  • Original production with the final regression: existing guest_json passes, new guest_json_numeric_locale fails. The output records invalid decimal commas, truncated input values, and the corrupted nested document above.
  • Fixed tree aa92ad8072ff2efc82851c64fc6c95c6af31bded: both CTests pass, no skips (2/2, 0.43 s). The comma locale selected is de_DE.UTF-8.
  • Covers fractions, exponents, maximum and minimum normal doubles, the smallest subnormal, rounding on each side of half that subnormal, integer input above uint64, positive/negative underflow to zero, nested numeric values, invalid decimal commas, overflow rejection and preservation of the host locale.
  • The locale test returns 77 (CTest skip) if no tested decimal-comma locale is installed; it did run on this Windows host.
  • check_conventions.py against the pinned base and git diff --check pass for the final committed change.
  • Built the relevant shared runtime library and test target. The full all-target build and full CTest suite were not completed. No Linux/macOS, game, console or GPU run.
  • pr_overlap.py cannot execute because gh is unavailable; live connector searches found no open Json2 numeric-locale fix. #6126 adds callbacks (including special-float handling), #6593 handles allocation failures, and #6447 is a broader compatibility batch; those address different behavior but may require textual reconciliation.

AI assistance: OpenAI Codex. Evidence is attached below.

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
  • 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
    json-numeric-locale-evidence-20261017.zip
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4902181643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-17T17:08:46Z. --- ### What With a decimal-comma host `LC_NUMERIC`, Json2 emits invalid JSON (`1.5` becomes `1,5`) and silently reads JSON `1.5` as `1`. In the regression, `{"value":1.5,"list":[2.5,-0.125]}` becomes `{"value":1,"list":[2,-0]}` after parsing and serializing. Use `to_chars` with the existing 17 significant digits for output and `from_chars` for input. On an out-of-range input only, use a stream explicitly imbued with the classic locale to retain the prior underflow-to-signed-zero behavior and overflow exception. Do not change the process locale. The numeric grammar still rejects a decimal comma. [RFC 8259 section 6](https://www.rfc-editor.org/rfc/rfc8259.html#section-6) requires `.` as the decimal point. The [C++ numeric conversion specification](https://eel.is/c++draft/charconv.to.chars) specifies C-locale formatting. Console rounding and formatting remain unmeasured and are recorded in Json2 debt. No title unblock, percentage increase or performance gain is claimed. ### Tested Windows, WinLibs MinGW-w64 GCC 15.2.0r7 UCRT, Release, actual shared `libSceJson2.prx` and its CMake test executable; base `66702f1cffd3646f2d674ed093fde0a85a70761f`: - Original production with the final regression: existing `guest_json` passes, new `guest_json_numeric_locale` fails. The output records invalid decimal commas, truncated input values, and the corrupted nested document above. - Fixed tree `aa92ad8072ff2efc82851c64fc6c95c6af31bded`: both CTests pass, no skips (2/2, 0.43 s). The comma locale selected is `de_DE.UTF-8`. - Covers fractions, exponents, maximum and minimum normal doubles, the smallest subnormal, rounding on each side of half that subnormal, integer input above uint64, positive/negative underflow to zero, nested numeric values, invalid decimal commas, overflow rejection and preservation of the host locale. - The locale test returns 77 (CTest skip) if no tested decimal-comma locale is installed; it did run on this Windows host. - `check_conventions.py` against the pinned base and `git diff --check` pass for the final committed change. - Built the relevant shared runtime library and test target. The full all-target build and full CTest suite were not completed. No Linux/macOS, game, console or GPU run. - `pr_overlap.py` cannot execute because `gh` is unavailable; live connector searches found no open Json2 numeric-locale fix. #6126 adds callbacks (including special-float handling), #6593 handles allocation failures, and #6447 is a broader compatibility batch; those address different behavior but may require textual reconciliation. AI assistance: OpenAI Codex. Evidence is attached below. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/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 [json-numeric-locale-evidence-20261017.zip](https://github.com/user-attachments/files/33603018/json-numeric-locale-evidence-20261017.zip)
oneandonlydean commented 2026-10-17 17:23:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T17:23:58Z.


Full CI on 8706b8258 (run 39052899521): every test passes on both lanes, and guest_json_numeric_locale runs and passes on Windows. The Linux job still fails at tools/check_skips.py:

error: guest_json_numeric_locale skipped
1 test(s) skipped for a reason that is not expected: the job lost that coverage and ctest still reports every test as passed

The Linux runner has no decimal-comma locale, so the test exits 77 with "No decimal-comma numeric locale is installed". On Linux, the guard only accepts skips that report a device limitation. Could you make the test cover Linux without an installed locale? For example, build the numeric facet in the test, or set LC_NUMERIC from a locale the test generates. If that is not practical, only register the case where it can run. We will re-run full CI on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237540886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6237540886). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T17:23:58Z. --- Full CI on 8706b8258 ([run 39052899521](https://github.com/boykopovar/AnyPS5/actions/runs/39052899521)): every test passes on both lanes, and `guest_json_numeric_locale` runs and passes on Windows. The Linux job still fails at `tools/check_skips.py`: ``` error: guest_json_numeric_locale skipped 1 test(s) skipped for a reason that is not expected: the job lost that coverage and ctest still reports every test as passed ``` The Linux runner has no decimal-comma locale, so the test exits 77 with "No decimal-comma numeric locale is installed". On Linux, the guard only accepts skips that report a device limitation. Could you make the test cover Linux without an installed locale? For example, build the numeric facet in the test, or set `LC_NUMERIC` from a locale the test generates. If that is not practical, only register the case where it can run. We will re-run full CI on the new head.
github-actions[bot] commented 2026-10-17 17:36:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T17:36:29Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9628 docs/dev/debt/libSceJson2.md L4

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6039 docs/dev/debt/libSceJson2.md
PR 6044 core/libs/prx/libSceJson2/CMakeLists.txt
core/libs/tests/GuestJson.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6237775622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6237775622). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T17:36:29Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 9628](https://www.github.com/boykopovar/AnyPS5/pull/9628) | `docs/dev/debt/libSceJson2.md` [L4](https://github.com/boykopovar/AnyPS5/blob/7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29d/docs/dev/debt/libSceJson2.md#L4) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6039](https://www.github.com/boykopovar/AnyPS5/pull/6039) | `docs/dev/debt/libSceJson2.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceJson2/CMakeLists.txt`<br>`core/libs/tests/GuestJson.cpp` |
MarcZX10 commented 2026-10-17 18:37:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T18:37:47Z.


I checked the Linux skip path in NumericLocale(): it needs an installed comma-decimal locale only to change the process LC_NUMERIC, which makes the serializer/parser regression locale-sensitive. A portable fix is to expose the conversion logic through a small internal helper that takes an explicit locale (or use a test-only locale facet for the legacy host conversion), then assert the JSON path always uses . while the host locale remains unchanged. If the goal is specifically exercising setlocale, the Linux test can generate/install a locale in CI, but that adds runner setup; conditionally unregistering the test would lose Linux coverage. I have not modified this PR. The check_skips.py report on the current head is a real required-CI failure, so please update the test and request a fresh full CI run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6238715287 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6238715287). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T18:37:47Z. --- I checked the Linux skip path in `NumericLocale()`: it needs an installed comma-decimal locale only to change the process `LC_NUMERIC`, which makes the serializer/parser regression locale-sensitive. A portable fix is to expose the conversion logic through a small internal helper that takes an explicit locale (or use a test-only locale facet for the legacy host conversion), then assert the JSON path always uses `.` while the host locale remains unchanged. If the goal is specifically exercising `setlocale`, the Linux test can generate/install a locale in CI, but that adds runner setup; conditionally unregistering the test would lose Linux coverage. I have not modified this PR. The `check_skips.py` report on the current head is a real required-CI failure, so please update the test and request a fresh full CI run.
jotitadev commented 2026-10-17 23:33:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T23:33:38Z.

Review: COMMENTED


Linux run of guest_json_numeric_locale with a decimal-comma locale, since the Linux CI job skips it (no such locale installed) and the description has no Linux run.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build.
Head 8706b8258 merged onto main 5de7a46e0 (clean merge).

The host has only C, C.utf8 and en_US.utf8. I generated de_DE.UTF-8 into a user directory without root (localedef -i de_DE -f UTF-8 <dir>/de_DE.UTF-8) and pointed glibc at it with LOCPATH=<dir>.

  • With the PR and LOCPATH set: guest_json and guest_json_numeric_locale pass, 5 of 5 runs. The test reports JSON numeric locale: de_DE.UTF-8.
  • With the PR and no LOCPATH: guest_json_numeric_locale exits 77 and CTest shows it as skipped, as in CI.
  • Test file and its registration only, on main, with LOCPATH set: guest_json_numeric_locale fails with the bug described above, e.g. Decimal-point serialization failed: 1,5, Decimal-point parsing failed: 1.5 and Nested numeric serialization failed: {"value":1,"list":[2,-0]}. So the test covers the change on Linux too.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out", no LOCPATH): 698/698, the 697 tests of main plus guest_json_numeric_locale counted as passed with its skip.

On the CI skip: on glibc a test-local locale works without installing one system-wide, as long as localedef and the locale sources (/usr/share/i18n/locales) are present. I did not check whether the GitHub runner image has them.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5560634901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#pullrequestreview-5560634901). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-17T23:33:38Z. **Review:** COMMENTED --- Linux run of `guest_json_numeric_locale` with a decimal-comma locale, since the Linux CI job skips it (no such locale installed) and the description has no Linux run. Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`, full build. Head `8706b8258` merged onto `main` `5de7a46e0` (clean merge). The host has only `C`, `C.utf8` and `en_US.utf8`. I generated `de_DE.UTF-8` into a user directory without root (`localedef -i de_DE -f UTF-8 <dir>/de_DE.UTF-8`) and pointed glibc at it with `LOCPATH=<dir>`. - With the PR and `LOCPATH` set: `guest_json` and `guest_json_numeric_locale` pass, 5 of 5 runs. The test reports `JSON numeric locale: de_DE.UTF-8`. - With the PR and no `LOCPATH`: `guest_json_numeric_locale` exits 77 and CTest shows it as skipped, as in CI. - Test file and its registration only, on `main`, with `LOCPATH` set: `guest_json_numeric_locale` fails with the bug described above, e.g. `Decimal-point serialization failed: 1,5`, `Decimal-point parsing failed: 1.5` and `Nested numeric serialization failed: {"value":1,"list":[2,-0]}`. So the test covers the change on Linux too. - Non-GPU suite (`ctest -E "^agc|gpu|vulkan|video_out"`, no `LOCPATH`): 698/698, the 697 tests of `main` plus `guest_json_numeric_locale` counted as passed with its skip. On the CI skip: on glibc a test-local locale works without installing one system-wide, as long as `localedef` and the locale sources (`/usr/share/i18n/locales`) are present. I did not check whether the GitHub runner image has them. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-17 23:50:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T23:50:41Z.


Thanks for running this with a generated de_DE.UTF-8 locale and checking the negative control on main. That confirms the regression on Linux when the locale is available, while the current CI skip is the expected no-locale path. I’ve updated my earlier review concern; the current required checks are green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243358182 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6243358182). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T23:50:41Z. --- Thanks for running this with a generated `de_DE.UTF-8` locale and checking the negative control on main. That confirms the regression on Linux when the locale is available, while the current CI skip is the expected no-locale path. I’ve updated my earlier review concern; the current required checks are green.
TheTerr4 commented 2026-10-18 14:59:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheTerr4 on 2026-10-18T14:59:39Z.


Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release.

This PR's head 8706b8258 merged cleanly into main 385ed71f2; the full build and libs both exit 0.

  • guest_json and guest_json_numeric_locale (the locale test ran under de_DE.UTF-8, so it was not skipped) pass, three repeated -j1 runs.
  • Negative control: with libSceJson2/Export.cpp restored to main's version, guest_json_numeric_locale fails; guest_json still passes.
  • Not run: the full suite, Linux, macOS.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251391394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6251391394). Originally posted by [TheTerr4](https://github.com/TheTerr4) on 2026-10-18T14:59:39Z. --- Windows runtime check. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7 (UCRT), Release. This PR's head `8706b8258` merged cleanly into `main` `385ed71f2`; the full build and `libs` both exit 0. - `guest_json` and `guest_json_numeric_locale` (the locale test ran under `de_DE.UTF-8`, so it was not skipped) pass, three repeated `-j1` runs. - Negative control: with `libSceJson2/Export.cpp` restored to `main`'s version, `guest_json_numeric_locale` fails; `guest_json` still passes. - Not run: the full suite, Linux, macOS. AI-assisted: yes (Claude Code).
MarcZX10 commented 2026-10-18 15:18:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T15:18:03Z.


Thanks for the Linux locale run and negative control. Generating de_DE.UTF-8 in a user directory confirms the test can exercise decimal-comma behavior without a system-wide locale install, and the restored-main failure shows it catches the bug. The Linux full-build subset also passed; platform limits are clear in your report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251579236 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6251579236). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T15:18:03Z. --- Thanks for the Linux locale run and negative control. Generating `de_DE.UTF-8` in a user directory confirms the test can exercise decimal-comma behavior without a system-wide locale install, and the restored-main failure shows it catches the bug. The Linux full-build subset also passed; platform limits are clear in your report.
oneandonlydean commented 2026-10-20 07:17:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T07:17:30Z.


Full CI on our merge-main head 0b51b5b482 (run 39383582595): every test passes, but the Linux job still fails at tools/check_skips.py, as it did on 17 Oct:

error: guest_json_numeric_locale skipped
1 test(s) skipped for a reason that is not expected: the job lost that coverage and ctest still reports every test as passed

The check is deliberate. A skip there means Linux CI never runs the case, and we won't add a "no locale" category to the guard. The Linux runner has no decimal-comma locale and we can't install one on it, so the test has to bring its own.

This works without root and without any system locale sources. Ship two small data files next to the test:

comma.charmap (ASCII only):

<code_set_name> ANYPS5_COMMA
<comment_char> %
<escape_char> /
<mb_cur_max> 1
<mb_cur_min> 1
CHARMAP
<U0000> /x00
...one line per code 0x00-0x7F...
<U007F> /x7f
END CHARMAP

comma.locale:

LC_NUMERIC
decimal_point "<U002C>"
thousands_sep ""
grouping -1
END LC_NUMERIC

Then build the locale in the build tree as a CTest fixture (Linux only), point the test at it with LOCPATH, and add xx_COMMA to the names NumericLocale() tries:

if(NOT WIN32)
    set(numeric_locale_dir ${CMAKE_CURRENT_BINARY_DIR}/numeric-locale)
    add_test(NAME guest_json_numeric_locale_setup COMMAND sh -c
        "rm -rf '${numeric_locale_dir}' && mkdir -p '${numeric_locale_dir}' && I18NPATH='${numeric_locale_dir}' localedef -c -f '<data>/comma.charmap' -i '<data>/comma.locale' '${numeric_locale_dir}/xx_COMMA'; test -f '${numeric_locale_dir}/xx_COMMA/LC_NUMERIC'")
    set_tests_properties(guest_json_numeric_locale_setup PROPERTIES FIXTURES_SETUP json_numeric_locale)
    set_tests_properties(guest_json_numeric_locale PROPERTIES FIXTURES_REQUIRED json_numeric_locale
        ENVIRONMENT "LOCPATH=${numeric_locale_dir}")
endif()

localedef -c exits 1 here because the other categories are missing, even though it writes the locale. That's why the fixture checks for the LC_NUMERIC file instead of the exit status. localedef comes with glibc (libc-bin on Ubuntu), and pointing I18NPATH at an empty directory proves nothing comes from /usr/share/i18n.

Checked on glibc with every system i18n path hidden: setlocale(LC_NUMERIC, "xx_COMMA") with LOCPATH set succeeds, decimal_point is ,, printf("%.2f", 1.5) prints 1,50 and strtod("1.5") returns 1. So the old snprintf/strtod code fails the test under this locale and the to_chars/from_chars code passes. Windows keeps its existing de-DE/German_Germany.1252 path, which ran and passed in CI.

Please also keep return 77 for hosts where the fixture can't run, and leave the rest of the test as it is. We'll rerun full CI on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285569600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6285569600). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T07:17:30Z. --- Full CI on our merge-main head 0b51b5b482 ([run 39383582595](https://github.com/boykopovar/AnyPS5/actions/runs/39383582595)): every test passes, but the Linux job still fails at `tools/check_skips.py`, as it did on 17 Oct: ``` error: guest_json_numeric_locale skipped 1 test(s) skipped for a reason that is not expected: the job lost that coverage and ctest still reports every test as passed ``` The check is deliberate. A skip there means Linux CI never runs the case, and we won't add a "no locale" category to the guard. The Linux runner has no decimal-comma locale and we can't install one on it, so the test has to bring its own. This works without root and without any system locale sources. Ship two small data files next to the test: `comma.charmap` (ASCII only): ``` <code_set_name> ANYPS5_COMMA <comment_char> % <escape_char> / <mb_cur_max> 1 <mb_cur_min> 1 CHARMAP <U0000> /x00 ...one line per code 0x00-0x7F... <U007F> /x7f END CHARMAP ``` `comma.locale`: ``` LC_NUMERIC decimal_point "<U002C>" thousands_sep "" grouping -1 END LC_NUMERIC ``` Then build the locale in the build tree as a CTest fixture (Linux only), point the test at it with `LOCPATH`, and add `xx_COMMA` to the names `NumericLocale()` tries: ```cmake if(NOT WIN32) set(numeric_locale_dir ${CMAKE_CURRENT_BINARY_DIR}/numeric-locale) add_test(NAME guest_json_numeric_locale_setup COMMAND sh -c "rm -rf '${numeric_locale_dir}' && mkdir -p '${numeric_locale_dir}' && I18NPATH='${numeric_locale_dir}' localedef -c -f '<data>/comma.charmap' -i '<data>/comma.locale' '${numeric_locale_dir}/xx_COMMA'; test -f '${numeric_locale_dir}/xx_COMMA/LC_NUMERIC'") set_tests_properties(guest_json_numeric_locale_setup PROPERTIES FIXTURES_SETUP json_numeric_locale) set_tests_properties(guest_json_numeric_locale PROPERTIES FIXTURES_REQUIRED json_numeric_locale ENVIRONMENT "LOCPATH=${numeric_locale_dir}") endif() ``` `localedef -c` exits 1 here because the other categories are missing, even though it writes the locale. That's why the fixture checks for the `LC_NUMERIC` file instead of the exit status. `localedef` comes with glibc (libc-bin on Ubuntu), and pointing `I18NPATH` at an empty directory proves nothing comes from `/usr/share/i18n`. Checked on glibc with every system i18n path hidden: `setlocale(LC_NUMERIC, "xx_COMMA")` with `LOCPATH` set succeeds, `decimal_point` is `,`, `printf("%.2f", 1.5)` prints `1,50` and `strtod("1.5")` returns 1. So the old `snprintf`/`strtod` code fails the test under this locale and the `to_chars`/`from_chars` code passes. Windows keeps its existing `de-DE`/`German_Germany.1252` path, which ran and passed in CI. Please also keep `return 77` for hosts where the fixture can't run, and leave the rest of the test as it is. We'll rerun full CI on the new head.
simonbronk commented 2026-10-22 09:07:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-22T09:07:15Z.


@oneandonlydean done as you described, with main merged in (one conflict in the libSceJson2 debt file; I kept main's entries and this PR's one line).

  • core/libs/tests/numeric-locale/comma.charmap (ASCII 0x00-0x7F) and comma.locale (LC_NUMERIC only, , as the decimal point).
  • guest_json_numeric_locale_setup builds xx_COMMA into the build tree with localedef -c and I18NPATH pointing at an empty directory, and checks for the LC_NUMERIC file. It is the fixture of guest_json_numeric_locale, which runs with LOCPATH set. NumericLocale() tries xx_COMMA first, and return 77 stays.
  • I limited the fixture to CMAKE_SYSTEM_NAME STREQUAL "Linux" rather than NOT WIN32. macOS has no glibc localedef, and its de_DE.UTF-8 is already found.

Tested: Linux, Ubuntu 24.04 x86-64 container (Colima/Rosetta), GCC 13, RelWithDebInfo with ASan, merged onto main d6eafa54d: guest_json_numeric_locale_setup and guest_json_numeric_locale both report Passed, not skipped. guest_json, guest_json_copy_failure, param_json_parser and param_json_utf8 pass too.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337028069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6337028069). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-22T09:07:15Z. --- @oneandonlydean done as you described, with `main` merged in (one conflict in the libSceJson2 debt file; I kept `main`'s entries and this PR's one line). - `core/libs/tests/numeric-locale/comma.charmap` (ASCII 0x00-0x7F) and `comma.locale` (`LC_NUMERIC` only, `,` as the decimal point). - `guest_json_numeric_locale_setup` builds `xx_COMMA` into the build tree with `localedef -c` and `I18NPATH` pointing at an empty directory, and checks for the `LC_NUMERIC` file. It is the fixture of `guest_json_numeric_locale`, which runs with `LOCPATH` set. `NumericLocale()` tries `xx_COMMA` first, and `return 77` stays. - I limited the fixture to `CMAKE_SYSTEM_NAME STREQUAL "Linux"` rather than `NOT WIN32`. macOS has no glibc `localedef`, and its `de_DE.UTF-8` is already found. **Tested:** Linux, Ubuntu 24.04 x86-64 container (Colima/Rosetta), GCC 13, RelWithDebInfo with ASan, merged onto `main` d6eafa54d: `guest_json_numeric_locale_setup` and `guest_json_numeric_locale` both report Passed, not skipped. `guest_json`, `guest_json_copy_failure`, `param_json_parser` and `param_json_utf8` pass too. AI-assisted: yes
oneandonlydean commented 2026-10-22 09:19:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T09:19:36Z.


@simonbronk thanks, the locale fixture does what I hoped. With the shipped charmap and LC_NUMERIC source, localedef -c builds xx_COMMA even with an empty I18NPATH, and under LOCPATH it gives , as the decimal point, so the test now runs on Linux instead of skipping.

One problem from the merge: core/libs/prx/libSceJson2/Export.cpp still has the conflict markers at lines 13-17, so the file doesn't compile:

<<<<<<< HEAD
#include <sstream>
=======
#include <memory>
>>>>>>> origin/main

Both includes are needed (<sstream> for the classic-locale fallback, <memory> from main). With the markers removed and both lines kept, it compiles cleanly here. Could you push that fix? I'll run the full CI on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337274329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6337274329). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-22T09:19:36Z. --- @simonbronk thanks, the locale fixture does what I hoped. With the shipped charmap and LC_NUMERIC source, `localedef -c` builds `xx_COMMA` even with an empty `I18NPATH`, and under `LOCPATH` it gives `,` as the decimal point, so the test now runs on Linux instead of skipping. One problem from the merge: `core/libs/prx/libSceJson2/Export.cpp` still has the conflict markers at lines 13-17, so the file doesn't compile: ``` <<<<<<< HEAD #include <sstream> ======= #include <memory> >>>>>>> origin/main ``` Both includes are needed (`<sstream>` for the classic-locale fallback, `<memory>` from `main`). With the markers removed and both lines kept, it compiles cleanly here. Could you push that fix? I'll run the full CI on the new head.
simonbronk commented 2026-10-22 09:47:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-22T09:47:55Z.


@oneandonlydean thank you for catching it, and sorry. My earlier Tested line was wrong. The merge left those markers in Export.cpp, the library failed to compile in my run, and ctest ran a binary left from an older build. I put the non-zero build exit down to an unrelated link failure and didn't check further. That's on me.

Fixed on the new head:

  • 2f579e0eb removes the markers and keeps both <memory> and <sstream>, as you said.
  • a07d5a507 updates the locale test to main's parser, which the merge brought in and which I hadn't run against before. main keeps object keys sorted, so the nested document now lists them in order, {"list":[2.5,-0.125],"value":1.5}. main also stops after the first value (parse("{} trailing") == 0 is in its tests), so "1,5" now has to parse as the unsigned integer 1 instead of failing.

Tested again, this time building the targets explicitly and checking the exit code: Linux, Ubuntu 24.04 x86-64 container (Colima/Rosetta), GCC 13, ASan, merged onto main 7e2ba73e4. cmake --build --target libSceJson2 guest_json_tests exits 0. guest_json_numeric_locale runs under xx_COMMA and passes, and so do guest_json, guest_json_numeric_locale_setup, guest_json_copy_failure, param_json_parser and param_json_utf8.

Negative control, with main's libSceJson2/Export.cpp swapped in: guest_json_numeric_locale fails. Serialization writes 1,5, -0,125, 1,25e+30 and so on, parsing 1.5 doesn't round-trip, and the nested document serializes as {"list":[2,-0],"value":1}.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337800011 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6337800011). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-22T09:47:55Z. --- @oneandonlydean thank you for catching it, and sorry. My earlier **Tested** line was wrong. The merge left those markers in `Export.cpp`, the library failed to compile in my run, and ctest ran a binary left from an older build. I put the non-zero build exit down to an unrelated link failure and didn't check further. That's on me. Fixed on the new head: - 2f579e0eb removes the markers and keeps both `<memory>` and `<sstream>`, as you said. - a07d5a507 updates the locale test to `main`'s parser, which the merge brought in and which I hadn't run against before. `main` keeps object keys sorted, so the nested document now lists them in order, `{"list":[2.5,-0.125],"value":1.5}`. `main` also stops after the first value (`parse("{} trailing") == 0` is in its tests), so `"1,5"` now has to parse as the unsigned integer 1 instead of failing. **Tested** again, this time building the targets explicitly and checking the exit code: Linux, Ubuntu 24.04 x86-64 container (Colima/Rosetta), GCC 13, ASan, merged onto `main` 7e2ba73e4. `cmake --build --target libSceJson2 guest_json_tests` exits 0. `guest_json_numeric_locale` runs under `xx_COMMA` and passes, and so do `guest_json`, `guest_json_numeric_locale_setup`, `guest_json_copy_failure`, `param_json_parser` and `param_json_utf8`. Negative control, with `main`'s `libSceJson2/Export.cpp` swapped in: `guest_json_numeric_locale` fails. Serialization writes `1,5`, `-0,125`, `1,25e+30` and so on, parsing `1.5` doesn't round-trip, and the nested document serializes as `{"list":[2,-0],"value":1}`. AI-assisted: yes
oneandonlydean commented 2026-10-22 10:06:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T10:06:01Z.


@simonbronk, merged, thanks. Full CI on a07d5a5 was green on Linux and Windows, and guest_json_numeric_locale now runs on Linux under the comma-decimal test locale instead of skipping.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6338137811 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7215#issuecomment-6338137811). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-22T10:06:01Z. --- @simonbronk, merged, thanks. Full CI on a07d5a5 was green on Linux and Windows, and `guest_json_numeric_locale` now runs on Linux under the comma-decimal test locale instead of skipping.
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!7215
No description provided.