From 550a1dadf1dd667ce95a1b0cbb5b0cc186a4e467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 7 Mar 2023 00:17:25 +0100 Subject: [PATCH] monitor: Don't use locale dependent mode ID string The result of printf("%f", number) depends on the locale. To avoid unpredictable mode IDs, make sure they always are generated the same no matter the locale. Part-of: --- src/backends/meta-monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 112ed97f6..72bae35b3 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -613,14 +613,17 @@ static char * generate_mode_id (MetaMonitorModeSpec *monitor_mode_spec) { gboolean is_interlaced; + char rate_str[G_ASCII_DTOSTR_BUF_SIZE]; is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE); + g_ascii_formatd (rate_str, sizeof (rate_str), + "%.3f", monitor_mode_spec->refresh_rate); - return g_strdup_printf ("%dx%d%s@%.3f", + return g_strdup_printf ("%dx%d%s@%s", monitor_mode_spec->width, monitor_mode_spec->height, is_interlaced ? "i" : "", - monitor_mode_spec->refresh_rate); + rate_str); } static gboolean