[gtk+] cssprovider: Clean up declaration parser to conform to more tests
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssprovider: Clean up declaration parser to conform to more tests
- Date: Wed, 18 May 2011 20:26:48 +0000 (UTC)
commit cb8a595a6563e7a6be0f3dba29fd5c879de46a86
Author: Benjamin Otte <otte redhat com>
Date: Sun Apr 10 01:48:55 2011 +0200
cssprovider: Clean up declaration parser to conform to more tests
The tests will follow with the next commits
gtk/gtkcssprovider.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 8bb594d..8fb9f6e 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2413,10 +2413,14 @@ parse_rule (GtkCssProvider *css_provider,
if (scanner->token != G_TOKEN_IDENTIFIER)
{
g_free (prop);
+ /* the error value here is hacky. But strings should be used for
+ * strings really, so a string is not a syntax error but a broken
+ * value for everything that we support. */
gtk_css_provider_error (css_provider,
GTK_CSS_PROVIDER_ERROR,
- GTK_CSS_PROVIDER_ERROR_PROPERTY_VALUE,
- "Could not parse property value");
+ scanner->token == G_TOKEN_STRING ? GTK_CSS_PROVIDER_ERROR_PROPERTY_VALUE
+ : GTK_CSS_PROVIDER_ERROR_SYNTAX,
+ "Not a property value");
css_provider_pop_scope (css_provider);
goto find_end_of_declaration;
}
@@ -2424,6 +2428,18 @@ parse_rule (GtkCssProvider *css_provider,
value_str = scanner->value.v_identifier;
g_strchomp (value_str);
+ css_provider_pop_scope (css_provider);
+ g_scanner_peek_next_token (scanner);
+
+ if (scanner->next_token != ';' &&
+ scanner->next_token != G_TOKEN_RIGHT_CURLY &&
+ scanner->next_token != G_TOKEN_EOF)
+ {
+ gtk_css_provider_invalid_token (css_provider, "';'");
+ g_free (prop);
+ goto find_end_of_declaration;
+ }
+
if (pspec)
{
GValue *val;
@@ -2508,17 +2524,17 @@ parse_rule (GtkCssProvider *css_provider,
else
g_free (prop);
- css_provider_pop_scope (css_provider);
g_scanner_get_next_token (scanner);
- if (scanner->token != ';' &&
- scanner->token != G_TOKEN_RIGHT_CURLY)
+ if (g_scanner_eof (scanner))
{
- gtk_css_provider_invalid_token (css_provider, "';'");
+ gtk_css_provider_invalid_token (css_provider, "}");
+ break;
}
find_end_of_declaration:
- while (scanner->token != G_TOKEN_RIGHT_CURLY &&
+ while (scanner->token != ';' &&
+ scanner->token != G_TOKEN_RIGHT_CURLY &&
!g_scanner_eof (scanner))
g_scanner_get_next_token (scanner);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]