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>
This commit is contained in:
Jonas Ådahl 2023-03-07 22:39:57 +01:00 committed by Marge Bot
parent 2fd9834d94
commit 86b5d9d809
2 changed files with 5 additions and 10 deletions

View File

@ -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;

View File

@ -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;