diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2023-03-07 22:39:57 +0100 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2023-04-18 18:38:03 +0000 |
commit | 86b5d9d809546127525da39a7727b097cacf96a3 (patch) | |
tree | 98070e6c003fa8337e04378a51e0c139aa0a877a | |
parent | 2fd9834d94b19df019131d588910b47c1be8d18d (diff) | |
download | mutter-86b5d9d809546127525da39a7727b097cacf96a3.tar.gz |
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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
-rw-r--r-- | src/backends/meta-monitor-manager-dummy.c | 8 | ||||
-rw-r--r-- | 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; |