aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/input/map_from_region.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/input/map_from_region.c')
-rw-r--r--sway/commands/input/map_from_region.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c
index de00b714..4400e111 100644
--- a/sway/commands/input/map_from_region.c
+++ b/sway/commands/input/map_from_region.c
@@ -11,11 +11,21 @@ static bool parse_coords(const char *str, double *x, double *y, bool *mm) {
11 *mm = false; 11 *mm = false;
12 12
13 char *end; 13 char *end;
14 *x = strtod(str, &end); 14
15 if (end[0] != 'x') { 15 // Check for "0x" prefix to avoid strtod treating the string as hex
16 return false; 16 if (str[0] == '0' && str[1] == 'x') {
17 if (strlen(str) < 3) {
18 return false;
19 }
20 *x = 0;
21 end = (char *)str + 2;
22 } else {
23 *x = strtod(str, &end);
24 if (end[0] != 'x') {
25 return false;
26 }
27 ++end;
17 } 28 }
18 ++end;
19 29
20 *y = strtod(end, &end); 30 *y = strtod(end, &end);
21 if (end[0] == 'm') { 31 if (end[0] == 'm') {