fix: don't treat 0x prefix as hex identifier

This commit is contained in:
iff 2023-08-28 19:36:28 +02:00 committed by Simon Ser
parent 89f8531268
commit 9e2925f539

View file

@ -11,11 +11,21 @@ static bool parse_coords(const char *str, double *x, double *y, bool *mm) {
*mm = false; *mm = false;
char *end; char *end;
*x = strtod(str, &end);
if (end[0] != 'x') { // Check for "0x" prefix to avoid strtod treating the string as hex
return false; 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); *y = strtod(end, &end);
if (end[0] == 'm') { if (end[0] == 'm') {