css: Fix parsing of scientific notation

The parser got its chars mixed up while parsing numbers
like 2.3e-04. While it is unlikely to meet such numbers
in human-generated css, we do have them e.g. when saving
render node trees with transforms.

Also add some css parser tests for number parsing.
This commit is contained in:
Matthias Clasen 2020-08-29 12:12:09 -04:00
parent f6adba57bb
commit 0f42d37f8b
3 changed files with 65 additions and 4 deletions

View File

@ -1056,13 +1056,12 @@ gtk_css_tokenizer_read_numeric (GtkCssTokenizer *tokenizer,
}
}
if (data + 1 < tokenizer->end && (*data == 'e' || *data == 'E') &&
(g_ascii_isdigit (data[1]) ||
(data + 2 < tokenizer->end && (data[1] == '+' || data[2] == '-') && g_ascii_isdigit (data[2]))))
if (data + 1 < tokenizer->end && (*data == 'e' || *data == 'E') &&
(g_ascii_isdigit (data[1]) ||
(data + 2 < tokenizer->end && (data[1] == '+' || data[1] == '-') && g_ascii_isdigit (data[2]))))
{
is_int = FALSE;
data++;
exponent = g_ascii_digit_value (*data);
if (*data == '-')
{

View File

@ -0,0 +1,31 @@
a {
-gtk-dpi: 0;
}
b {
-gtk-dpi: 100;
}
c {
-gtk-dpi: -39;
}
d {
-gtk-dpi: 0.5;
}
e {
-gtk-dpi: 2.6e2;
}
f {
-gtk-dpi: 2.6E20;
}
g {
-gtk-dpi: 5e-1;
}
h {
-gtk-dpi: 2E-19;
}

View File

@ -0,0 +1,31 @@
a {
-gtk-dpi: 0;
}
b {
-gtk-dpi: 100;
}
c {
-gtk-dpi: -39;
}
d {
-gtk-dpi: 0.5;
}
e {
-gtk-dpi: 260;
}
f {
-gtk-dpi: 2.6e+20;
}
g {
-gtk-dpi: 0.5;
}
h {
-gtk-dpi: 2e-19;
}