Skip to content

PresetFileParser: always use C locale in float parsing - #1050

Open
lstrsrt wants to merge 1 commit into
projectM-visualizer:masterfrom
lstrsrt:stof-locale-fix
Open

lstrsrt wants to merge 1 commit into
projectM-visualizer:masterfrom
lstrsrt:stof-locale-fix

Conversation

@lstrsrt

@lstrsrt lstrsrt commented Oct 15, 2026

Copy link
Copy Markdown

This fixes a regression in the preset parser. The bug also existed in the previous parser where someone else noticed and fixed it but the fix wasn't brought over to the new one. In short, GetFloat calls std::stof which calls strtof. This is a locale-dependent function so when using a locale that defines the decimal point to be a comma (like German or Czech), incorrect values will be returned. For example "0.8" just becomes 0 which obviously breaks a ton of stuff. Fix is the same as before: just use a stringstream imbued with a C locale.

@kblaschke kblaschke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, those nasty locales...

Thanks for the heads-up!

@lstrsrt

lstrsrt commented Nov 1, 2026

Copy link
Copy Markdown
Author

Oops, I initialized the stringstream with lowerKey instead of m_presetValues.at(lowerKey). Fixed.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants