Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal separator read differently when starting and when reloading #8574

Open
Piripuz opened this issue Feb 17, 2025 · 4 comments
Open

Decimal separator read differently when starting and when reloading #8574

Piripuz opened this issue Feb 17, 2025 · 4 comments
Labels
bug Not working as intended

Comments

@Piripuz
Copy link

Piripuz commented Feb 17, 2025

Hello, I am having a problem with the decimal separator of my config.
In my sistem, the default separator is set to a comma (as it is used in Italy).

locale gives, as output,

LC_CTYPE="it_IT.UTF-8"
LC_NUMERIC="it_IT.UTF-8"
LC_TIME="it_IT.UTF-8"
LC_COLLATE="it_IT.UTF-8"
LC_MONETARY="it_IT.UTF-8"
LC_MESSAGES="it_IT.UTF-8"
LC_PAPER="it_IT.UTF-8"
LC_NAME="it_IT.UTF-8"
LC_ADDRESS="it_IT.UTF-8"
LC_TELEPHONE="it_IT.UTF-8"
LC_MEASUREMENT="it_IT.UTF-8"
LC_IDENTIFICATION="it_IT.UTF-8"
LC_ALL=

and locale decimal_point gives a comma.

Nonetheless, each time sway is started it uses the dot as decimal separator, and errors to my config at the line in which the decimal value is written. After erroring, reloading sway makes it read the config as expected (and thus without errors if in the config there are commas, with errors if there are dots).

A log with the error is here, and this is my config. The erroring lines are line 83 and 84 of the config.

I'm running sway 1.10.1, in arch linux.

@Piripuz Piripuz added the bug Not working as intended label Feb 17, 2025
@GabriF
Copy link

GabriF commented Feb 17, 2025

strtof() is not detecting the right locale at

float flt = strtof(value, &end);

Maybe a call to setlocale(LC_ALL, "") is needed at some point? what about in main()?

Also, I noticed some inconsistency in the use of the utility function parse_float(): some handlers are using it (eg. input_cmd_pointer_accel), but others are not (eg. cmd_gaps). Any reason for that?

I'm up to open a PR.

EDIT: that said, I don't think it's a good idea to have per-locale configuration. If you switch locale, you need to change the configuration. Using just one locale (point as decimal notation in this case) improves interoperability.

@emersion
Copy link
Member

Yeah, I don't think we should use the locale for number parsing.

@Piripuz
Copy link
Author

Piripuz commented Feb 18, 2025

Hello, I agree that using locale for the parsing is a bad idea. The problem is that when reloading sway is actually using locale.
Probably each choice would be acceptable, as long as the behaviour is consistent when starting and reloading

@emersion emersion reopened this Feb 18, 2025
@emersion
Copy link
Member

Ah, sorry, missed that! Agreed, we should be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

No branches or pull requests

3 participants