From 86b5d9d809546127525da39a7727b097cacf96a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 7 Mar 2023 22:39:57 +0100 Subject: [PATCH] Replace using sscanf() to parse mode strings with new helper This fixes issues when the locale uses characters other than `.` in floating point numbers. Part-of: --- src/backends/meta-monitor-manager-dummy.c | 8 +++----- src/core/meta-context-main.c | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index ef3c3c330..315117e5c 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -159,12 +159,10 @@ append_monitor (MetaMonitorManager *manager, for (i = 0; specs[i]; ++i) { int width, height; - float refresh_rate = 60.0; + float refresh_rate; - if (sscanf (specs[i], "%dx%d@%f", - &width, &height, &refresh_rate) == 3 || - sscanf (specs[i], "%dx%d", - &width, &height) == 2) + if (meta_parse_monitor_mode (specs[i], &width, &height, &refresh_rate, + 60.0)) { CrtcModeSpec *spec; diff --git a/src/core/meta-context-main.c b/src/core/meta-context-main.c index cc930116e..f673432f5 100644 --- a/src/core/meta-context-main.c +++ b/src/core/meta-context-main.c @@ -533,12 +533,9 @@ add_virtual_monitor_cb (const char *option_name, { MetaContextMain *context_main = user_data; int width, height; - float refresh_rate = 60.0; + float refresh_rate; - if (sscanf (value, "%dx%d@%f", - &width, &height, &refresh_rate) == 3 || - sscanf (value, "%dx%d", - &width, &height) == 2) + if (meta_parse_monitor_mode (value, &width, &height, &refresh_rate, 60.0)) { g_autofree char *serial = NULL; MetaVirtualMonitorInfo *virtual_monitor;