mirror of
https://github.com/swaywm/sway.git
synced 2026-04-21 06:46:22 -04:00
fix: don't treat 0x prefix as hex identifier
This commit is contained in:
parent
89f8531268
commit
9e2925f539
1 changed files with 14 additions and 4 deletions
|
|
@ -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') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue