diff options
author | Dodji Seketeli <dodji@src.gnome.org> | 2003-06-09 13:45:43 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-06-09 13:45:43 +0000 |
commit | dbe4c464a5e2079fa21f05ad74fe36c93cb64670 (patch) | |
tree | 8ef3169fe49392b1f570893e2c5c7812d8b61f92 | |
parent | aba3d6844be54f028b33c3f4aa66274a35fb1bdc (diff) | |
download | libcroco-dbe4c464a5e2079fa21f05ad74fe36c93cb64670.tar.gz |
fixed a bug that prevented this parsing function to be called outside the
* src/parser/cr-parser.c (cr_parser_parse_declaration):
fixed a bug that prevented this parsing function to be called outside
the stylesheet parsing context.
Dodji.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/parser/cr-declaration.c | 26 | ||||
-rw-r--r-- | src/parser/cr-parser.c | 22 | ||||
-rw-r--r-- | tests/test4-main.c | 28 |
4 files changed, 66 insertions, 14 deletions
@@ -1,5 +1,9 @@ 2003-06-09 Dodji <dodji@seketeli.org> + * src/parser/cr-parser.c (cr_parser_parse_declaration): + fixed a bug that prevented this parsing function to be called outside + the stylesheet parsing context. + * src/seleng/cr-style.[ch]: went forward in the font properties gathering. diff --git a/src/parser/cr-declaration.c b/src/parser/cr-declaration.c index 66f0d99..2a1a6b9 100644 --- a/src/parser/cr-declaration.c +++ b/src/parser/cr-declaration.c @@ -115,14 +115,17 @@ cr_declaration_new (CRStatement *a_statement, { CRDeclaration *result = NULL ; - g_return_val_if_fail (a_statement - && ((a_statement->type - == RULESET_STMT) - || (a_statement->type - == AT_FONT_FACE_RULE_STMT) - || (a_statement->type - == AT_PAGE_RULE_STMT)), - NULL) ; + g_return_val_if_fail (a_property, NULL) ; + + if (a_statement) + g_return_val_if_fail (a_statement + && ((a_statement->type + == RULESET_STMT) + || (a_statement->type + == AT_FONT_FACE_RULE_STMT) + || (a_statement->type + == AT_PAGE_RULE_STMT)), + NULL) ; result = g_try_malloc (sizeof (CRDeclaration)) ; if (!result) @@ -165,9 +168,10 @@ cr_declaration_parse (CRStatement *a_statement, CRDeclaration *result = NULL ; CRParser * parser = NULL ; - g_return_val_if_fail (a_statement - && a_statement->type == RULESET_STMT - && a_str, NULL); + g_return_val_if_fail (a_str, NULL) ; + if (a_statement) + g_return_val_if_fail (a_statement->type == RULESET_STMT, + NULL); parser = cr_parser_new_from_buf (a_str, strlen (a_str), diff --git a/src/parser/cr-parser.c b/src/parser/cr-parser.c index 8d96c56..b3034b3 100644 --- a/src/parser/cr-parser.c +++ b/src/parser/cr-parser.c @@ -2328,6 +2328,7 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) CRInputPos init_pos ; CRTerm *expr = NULL, *expr2 = NULL ; guchar next_byte = 0 ; + gulong nb_terms = 0 ; g_return_val_if_fail (a_this && PRIVATE (a_this) && a_expr, @@ -2342,8 +2343,24 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) for (;;) { guchar operator = 0 ; - - PEEK_BYTE (a_this, 1, &next_byte) ; + status = cr_tknzr_peek_byte (PRIVATE (a_this)->tknzr, + 1, &next_byte) ; + if (status != CR_OK) + { + if (status == CR_END_OF_INPUT_ERROR) + { + if (!nb_terms) + { + goto error ; + } + status = CR_OK ; + break ; + } + else + { + goto error ; + } + } if (next_byte == '/' || next_byte == ',') { @@ -2376,6 +2393,7 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) expr = cr_term_append_term (expr, expr2) ; expr2 = NULL ; operator = 0 ; + nb_terms ++ ; } if (status == CR_OK) diff --git a/tests/test4-main.c b/tests/test4-main.c index 9f68c43..6ece7d2 100644 --- a/tests/test4-main.c +++ b/tests/test4-main.c @@ -35,6 +35,9 @@ CRDocHandler * gv_test_handler = {0} ; +const guchar * gv_decl= +"toto: tutu, tata" ; + static void display_help (char *prg_name) ; @@ -114,6 +117,21 @@ test_cr_parser_parse (guchar * a_file_uri) return status ; } +static enum CRStatus +test_cr_declaration_parse (void) +{ + CRDeclaration * decl = NULL ; + + decl = cr_declaration_parse (NULL, gv_decl, + CR_UTF_8) ; + + if (decl) + { + cr_declaration_destroy (decl) ; + return CR_OK ; + } + return CR_ERROR ; +} /** *The entry point of the testing routine. @@ -123,6 +141,14 @@ main (int argc, char ** argv) { struct Options options ; enum CRStatus status = CR_OK ; + + status = test_cr_declaration_parse () ; + + if (status != CR_OK) + { + g_print ("\nKO\n") ; + return 0 ; + } cr_test_utils_parse_cmd_line (argc, argv, &options) ; @@ -143,7 +169,7 @@ main (int argc, char ** argv) display_help (argv[0]) ; return 0 ; } - + status = test_cr_parser_parse (options.files_list[0]) ; |