[gtk/wip/otte/css: 31/66] cssparser: Add gtk_css_parser_try_at_keyword()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 31/66] cssparser: Add gtk_css_parser_try_at_keyword()
- Date: Thu, 11 Apr 2019 22:43:14 +0000 (UTC)
commit 08a716fe73b1d67cc5b1698daaf37b2fd1fe1e61
Author: Benjamin Otte <otte redhat com>
Date: Tue Apr 2 00:21:02 2019 +0200
cssparser: Add gtk_css_parser_try_at_keyword()
gtk/gtkcssparser.c | 22 ++++++++++++++++++++++
gtk/gtkcssparserprivate.h | 2 ++
gtk/gtkcssprovider.c | 6 +++---
3 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index c9412e26bf..774b1dbdfa 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -276,6 +276,28 @@ _gtk_css_parser_try (GtkCssParser *parser,
return TRUE;
}
+gboolean
+gtk_css_parser_try_at_keyword (GtkCssParser *parser,
+ const char *keyword)
+{
+ gsize len;
+
+ g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), FALSE);
+ g_return_val_if_fail (keyword != NULL, FALSE);
+
+ len = strlen (keyword);
+
+ if (parser->data[0] != '@' ||
+ g_ascii_strncasecmp (&parser->data[1], keyword, len) != 0)
+ return FALSE;
+
+ parser->data += len + 1;
+
+ _gtk_css_parser_skip_whitespace (parser);
+
+ return TRUE;
+}
+
gboolean
gtk_css_parser_try_ident (GtkCssParser *parser,
const char *ident)
diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h
index 1611dea07c..1a77c58cd3 100644
--- a/gtk/gtkcssparserprivate.h
+++ b/gtk/gtkcssparserprivate.h
@@ -79,6 +79,8 @@ gboolean gtk_css_parser_has_function (GtkCssParser *parser
*/
gboolean gtk_css_parser_try_ident (GtkCssParser *parser,
const char *ident);
+gboolean gtk_css_parser_try_at_keyword (GtkCssParser *parser,
+ const char *keyword);
gboolean gtk_css_parser_try_token (GtkCssParser *parser,
GtkCssTokenType token_type);
gboolean _gtk_css_parser_try (GtkCssParser *parser,
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 3658b18d1e..f7a611d369 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -776,7 +776,7 @@ parse_import (GtkCssScanner *scanner)
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_IMPORT);
- if (!_gtk_css_parser_try (scanner->parser, "@import", TRUE))
+ if (!gtk_css_parser_try_at_keyword (scanner->parser, "import"))
{
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
return FALSE;
@@ -843,7 +843,7 @@ parse_color_definition (GtkCssScanner *scanner)
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
- if (!_gtk_css_parser_try (scanner->parser, "@define-color", TRUE))
+ if (!gtk_css_parser_try_at_keyword (scanner->parser, "define-color"))
{
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
return FALSE;
@@ -901,7 +901,7 @@ parse_keyframes (GtkCssScanner *scanner)
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
- if (!_gtk_css_parser_try (scanner->parser, "@keyframes", TRUE))
+ if (!gtk_css_parser_try_at_keyword (scanner->parser, "keyframes"))
{
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]