forked from AuroraMiddleware/gtk
cssparser: Add error functions that take locations
... and use them to report better error locations for the warning when blocks aren't terminated properly.
This commit is contained in:
parent
2e0a56665a
commit
79238b0d8f
@ -415,13 +415,21 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
|
||||
if (gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_warn_syntax (self, "Unterminated block at end of document");
|
||||
gtk_css_parser_warn (self,
|
||||
GTK_CSS_PARSER_WARNING_SYNTAX,
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Unterminated block at end of document");
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else if (gtk_css_token_is (&self->token, block->inherited_end_token))
|
||||
{
|
||||
g_assert (block->end_token == GTK_CSS_TOKEN_SEMICOLON);
|
||||
gtk_css_parser_warn_syntax (self, "Expected ';' at end of block");
|
||||
gtk_css_parser_warn (self,
|
||||
GTK_CSS_PARSER_WARNING_SYNTAX,
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Expected ';' at end of block");
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else
|
||||
@ -498,6 +506,26 @@ gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
self->error_func (self, start, end, error, self->user_data);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_error (GtkCssParser *self,
|
||||
GtkCssParserError code,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
GError *error;
|
||||
|
||||
va_start (args, format);
|
||||
error = g_error_new_valist (GTK_CSS_PARSER_ERROR,
|
||||
code,
|
||||
format, args);
|
||||
gtk_css_parser_emit_error (self, start, end, error);
|
||||
g_error_free (error);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_error_syntax (GtkCssParser *self,
|
||||
const char *format,
|
||||
@ -558,6 +586,26 @@ gtk_css_parser_error_import (GtkCssParser *self,
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_warn (GtkCssParser *self,
|
||||
GtkCssParserWarning code,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
GError *error;
|
||||
|
||||
va_start (args, format);
|
||||
error = g_error_new_valist (GTK_CSS_PARSER_WARNING,
|
||||
code,
|
||||
format, args);
|
||||
gtk_css_parser_emit_error (self, start, end, error);
|
||||
g_error_free (error);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_warn_syntax (GtkCssParser *self,
|
||||
const char *format,
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef __GTK_CSS_PARSER_H__
|
||||
#define __GTK_CSS_PARSER_H__
|
||||
|
||||
#include "gtkcssenums.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
@ -87,6 +88,12 @@ void gtk_css_parser_emit_error (GtkCssParser
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end,
|
||||
const GError *error);
|
||||
void gtk_css_parser_error (GtkCssParser *self,
|
||||
GtkCssParserError code,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(5, 6);
|
||||
void gtk_css_parser_error_syntax (GtkCssParser *self,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(2, 3);
|
||||
@ -96,6 +103,12 @@ void gtk_css_parser_error_value (GtkCssParser
|
||||
void gtk_css_parser_error_import (GtkCssParser *self,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(2, 3);
|
||||
void gtk_css_parser_warn (GtkCssParser *self,
|
||||
GtkCssParserWarning code,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(5, 6);
|
||||
void gtk_css_parser_warn_syntax (GtkCssParser *self,
|
||||
const char *format,
|
||||
...) G_GNUC_PRINTF(2, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user