aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-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) {
*mm = false;
char *end;
- *x = strtod(str, &end);
- if (end[0] != 'x') {
- return false;
+
+ // Check for "0x" prefix to avoid strtod treating the string as hex
+ if (str[0] == '0' && str[1] == 'x') {
+ if (strlen(str) < 3) {
+ return false;
+ }
+ *x = 0;
+ end = (char *)str + 2;
+ } else {
+ *x = strtod(str, &end);
+ if (end[0] != 'x') {
+ return false;
+ }
+ ++end;
}
- ++end;
*y = strtod(end, &end);
if (end[0] == 'm') {