fix(simu): force C locale for numeric parsing in simulator - #7613
Open
bultodepapas wants to merge 1 commit into
Open
fix(simu): force C locale for numeric parsing in simulator#7613bultodepapas wants to merge 1 commit into
bultodepapas wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes simulator failures under non-C host locales by forcing locale-independent numeric parsing (so Lua number parsing via strtof/strtod continues to expect . as the decimal separator). The change is applied in simuInit(), the shared simulator entry point used by SDL, tests, and the WASM host.
Changes:
- Force
LC_NUMERICto"C"during simulator initialization to prevent locale-dependent float parsing. - Add the required locale header include (
<clocale>) forsetlocale.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7453
Summary
The Companion / SDL simulator failed to run when the host locale is not
C/English (e.g.LANG=es_ES.UTF-8): all float numbers parsed by the Lua engine produced errors becausestrtof/strtoduse the locale's decimal separator (,in es_ES) instead of..Fix
Force
LC_NUMERICto"C"insimuInit()(radio/src/targets/simu/simulib.cpp), which is the shared entry point for both the SDL and the WASM simulator. This makes numeric conversions locale-independent inside the simulator while leaving the rest of the process untouched.Verification
Compiled a small host test that calls
setlocale(LC_NUMERIC, "C")and confirmedstrtod("1.5")parses correctly regardless of the host locale.