Commit Graph

16 Commits

Author SHA1 Message Date
Timm Bäder
42fedfc870 csstokenizer: Keep a GString for name parsing around
We only every parse one of those at a time, so keep a GString around for
it. This way we don't have to create a new GString every time we parse
an identifier. Doesn't spare us the strdup though.
2021-01-05 08:53:13 +01:00
Timm Bäder
24836c0351 csstokenizer: Add separate init functions for token types
Using a variadic function is just awkward there. Use different init
functions and use them as appropriate; we already know which one to call
everywhere.
2021-01-05 08:53:13 +01:00
Matthias Clasen
90676540ec css: Fix tokenization of CDO
A CDO is 4 characters: <!--, not 3 as our tokenizer
was pretending.
2020-10-31 00:38:49 -04:00
Matthias Clasen
0f42d37f8b 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.
2020-08-29 12:44:26 -04:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Timm Bäder
a1c75795bc Replace fallthrough comments with G_GNUC_FALLTHROUGH 2020-03-06 10:39:42 +01:00
Timm Bäder
581f5bd749 csstokenizer: Plug a leak 2019-11-19 09:37:45 +01:00
Benjamin Otte
89fb752a8f css: Use %f, not %.17f
The testusite failures explain why:
We don't want to print "1.00000000000000000", but "1".
2019-05-29 14:30:13 +02:00
Benjamin Otte
d71c196c5c css: Don't print numbers with exponent
CSS does not do exponents, so printing numbers close to 0 as 1.234e-15
does not work.

Also up the accuracy to 17 digits because that's what everyone else
uses.
2019-05-29 07:14:31 +02:00
Benjamin Otte
bc7972dfa7 csstokenizer: Handle backslash at end of document
Testcases included.
2019-05-08 00:58:52 +02:00
Benjamin Otte
562e492056 csstokenizer: Consume the \ when encountering an error
Otherwise we infinitely end up with the error again.

Testcases added.
2019-05-06 05:56:06 +02:00
Benjamin Otte
32e256e5ab css: Split GtkCssLocation into its own file
And make the struct public, so we can use it in signal handlers.
2019-04-12 19:34:28 +02:00
Benjamin Otte
d4d46e8125 csstokenizer: Add gtk_css_token_is_preserved() 2019-04-12 19:34:28 +02:00
Benjamin Otte
661720ef8b tokenizer: Pass error arg to read_token()
Instead of an error vfunc, have the tokenizer vfunc take a GError
argument. Note that even when an error is returned, there is still a
token to be read.
2019-04-12 19:34:28 +02:00
Benjamin Otte
013591d68d css: Add GtkCssTokenizer
This is copied from an old branch of mine.
2019-04-12 19:34:28 +02:00