[gtk/wip/otte/for-master: 3/3] css: Emit a special error for a common error
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 3/3] css: Emit a special error for a common error
- Date: Wed, 20 Oct 2021 22:11:52 +0000 (UTC)
commit 0546253f246bc2020ada24a666915af8a02c137a
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 21 00:05:56 2021 +0200
css: Emit a special error for a common error
This CSS:
calc(5px+3px)
is wrong because it gets broken to:
calc( 5px +3px )
which is 2 numbers inside the calc, and what you want is:
calc( 5px + 3px )
but you need to add a space to get this, like so:
calc(5px + 3px)
which is the recommended way to write calc() statements.
So whenever we encounter an error, check if the next token is a signed
number and if so, include it in the error message.
gtk/gtkcsscalcvalue.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/gtk/gtkcsscalcvalue.c b/gtk/gtkcsscalcvalue.c
index ad7380b990..d0731b267b 100644
--- a/gtk/gtkcsscalcvalue.c
+++ b/gtk/gtkcsscalcvalue.c
@@ -166,6 +166,14 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
}
else
{
+ if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_INTEGER) ||
+ gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_NUMBER) ||
+ gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION) ||
+ gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_DIMENSION))
+ {
+ gtk_css_parser_error_syntax (parser, "Unexpected signed number, did you forget a space between
sign and number?");
+ gtk_css_parser_consume_token (parser);
+ }
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]