nodeparser: Move an error check

By putting the check earlier, it will be emitted for the right token.
This commit is contained in:
Benjamin Otte 2023-05-14 23:12:23 +02:00
parent bac41ce644
commit 2b0e3a5b1a
5 changed files with 15 additions and 14 deletions

View File

@ -1081,20 +1081,21 @@ parse_declarations (GtkCssParser *parser,
{
if (gtk_css_parser_try_ident (parser, declarations[i].name))
{
if (parsed & (1 << i))
{
gtk_css_parser_warn_syntax (parser, "Variable \"%s\" defined multiple times", declarations[i].name);
/* Unset, just to be sure */
parsed &= ~(1 << i);
if (declarations[i].clear_func)
declarations[i].clear_func (declarations[i].result);
}
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COLON))
{
gtk_css_parser_error_syntax (parser, "Expected ':' after variable declaration");
}
else
{
if (parsed & (1 << i))
{
gtk_css_parser_warn_syntax (parser, "Variable \"%s\" defined multiple times", declarations[i].name);
/* Unset, just to be sure */
parsed &= ~(1 << i);
if (declarations[i].clear_func)
declarations[i].clear_func (declarations[i].result);
}
if (!declarations[i].parse_func (parser, context, declarations[i].result))
{
/* nothing to do */

View File

@ -1,2 +1,2 @@
<data>:5:10-11: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:6:8-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:5:3-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:6:3-8: error: GTK_CSS_PARSER_WARNING_SYNTAX

View File

@ -1 +1 @@
<data>:3:8-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:3:3-8: error: GTK_CSS_PARSER_WARNING_SYNTAX

View File

@ -2,7 +2,7 @@
<data>:2:11-13: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:2:13-14: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:2:13-14: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:3:9-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:3:2-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:3:11-13: error: GTK_CSS_PARSER_ERROR_SYNTAX
<data>:3:11-13: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:3:13-14: error: GTK_CSS_PARSER_ERROR_SYNTAX

View File

@ -1,3 +1,3 @@
<data>:4:7-8: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:6:9-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:4:3-7: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:6:3-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
<data>:8:1-2: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE