summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji <dodji@gnome.org>2004-03-06 22:49:56 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-03-06 22:49:56 +0000
commit9fd0686e5a84f3c62e3a3ce4c11777e4f2050cb7 (patch)
tree95ec9181b898929edb2f561ac6e71a000b9a21a6
parent406526f52125bbf6dbf95eee6f01655544a70b24 (diff)
downloadlibcroco-9fd0686e5a84f3c62e3a3ce4c11777e4f2050cb7.tar.gz
when you reach an EOF, don't assume it's an error. Return the already
2004-03-06 Dodji <dodji@gnome.org> * src/cr-tknzr.c: (cr_tknzr_parse_num): when you reach an EOF, don't assume it's an error. Return the already parsed part of the number. Next attempt of parsing will result in an * tests/test4-main.c: udpated this test the fix made above. CR_END_OF_INPUT_ERROR.
-rw-r--r--ChangeLog7
-rw-r--r--src/cr-parser.c2
-rw-r--r--src/cr-term.c1
-rw-r--r--src/cr-tknzr.c10
-rw-r--r--tests/test4-main.c59
5 files changed, 57 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index c6cb33c..cbaa322 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,17 @@
2004-03-06 Dodji <dodji@gnome.org>
+ * src/cr-tknzr.c:
+ (cr_tknzr_parse_num): when you reach an EOF, don't assume it's
+ an error. Return the already parsed part of the number.
+ Next attempt of parsing will result in an CR_END_OF_INPUT_ERROR.
+ * tests/test4-main.c: udpated this test the fix made above.
* Doxyfile: reflect the removal of src/parser src/seleng and
src/layeng
* src/cr-declaration.c:
(cr_declaration_list_to_string2): added this new method.
* src/cr-sel-eng.c: fix a bug in the !important handling
in the cascading algorithm.
-
+
2004-03-06 Dodji Seketeli <dodji@gnome.org>
* csslint/csslint.c: applied a patch from Rob BUIS
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 6b1bb2a..67e51be 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -3722,7 +3722,7 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr)
{
goto error ;
}
- */
+ */
status = CR_OK ;
break ;
}
diff --git a/src/cr-term.c b/src/cr-term.c
index 6f5ae9f..7bfab93 100644
--- a/src/cr-term.c
+++ b/src/cr-term.c
@@ -131,7 +131,6 @@ cr_term_parse_expression_from_buf (const guchar *a_buf,
{
goto cleanup ;
}
-
status = cr_parser_parse_expr (parser, &result) ;
if (status != CR_OK)
{
diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c
index 2b9e06f..8bcc349 100644
--- a/src/cr-tknzr.c
+++ b/src/cr-tknzr.c
@@ -1677,8 +1677,14 @@ cr_tknzr_parse_num (CRTknzr *a_this, CRNum ** a_num)
for (;;)
{
- PEEK_NEXT_CHAR (a_this, &next_char) ;
-
+ status = cr_tknzr_peek_char (a_this,
+ &next_char) ;
+ if (status != CR_OK)
+ {
+ if (status == CR_END_OF_INPUT_ERROR)
+ status = CR_OK ;
+ break ;
+ }
if (next_char == '.')
{
if (parsing_dec == TRUE)
diff --git a/tests/test4-main.c b/tests/test4-main.c
index 4d0b68e..997e2ec 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -35,6 +35,8 @@
CRDocHandler * gv_test_handler = {0} ;
+const guchar * gv_term_buf= "106" ;
+
const guchar * gv_decl_buf =
"toto: tutu, tata" ;
@@ -149,6 +151,32 @@ test_cr_parser_parse (guchar * a_file_uri)
return status ;
}
+
+static enum CRStatus
+test_cr_term_parse_expression_from_buf (void)
+{
+ guchar * tmp_str = NULL ;
+ CRTerm * term = NULL ;
+
+ term = cr_term_parse_expression_from_buf (gv_term_buf,
+ CR_UTF_8) ;
+
+ if (!term)
+ return CR_ERROR ;
+ tmp_str = cr_term_to_string (term) ;
+ if (term)
+ {
+ cr_term_destroy (term) ;
+ term = NULL ;
+ }
+ if (tmp_str)
+ {
+ g_free (tmp_str) ;
+ tmp_str = NULL ;
+ }
+ return CR_OK ;
+}
+
static enum CRStatus
test_cr_declaration_parse (void)
{
@@ -397,66 +425,63 @@ main (int argc, char ** argv)
struct Options options ;
enum CRStatus status = CR_OK ;
+ status = test_cr_term_parse_expression_from_buf() ;
+ if (status != CR_OK)
+ {
+ g_print ("\ntest \"cr_term_parse_expression_from_buf failed\"") ;
+ }
status = test_cr_declaration_parse () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\n test \"cr_declaration_parse() failed\"\n") ;
}
status = test_cr_declaration_parse_list () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_declaration_parse_list() failed\n") ;
}
status = test_cr_statement_ruleset_parse () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_ruleset_parse() failed\n") ;
}
status = test_cr_statement_at_media_rule_parse () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_at_media_rule_parse() failed\n") ;
}
test_cr_statement_at_page_rule_parse () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
+ g_print ("\ntest cr_statement_at_page_rule_parse() failed\n") ;
return 0 ;
}
status = test_cr_statement_at_charset_rule_parse () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_at_charset_rule_parse() failed\n") ;
}
status = test_cr_statement_font_face_rule_parse_from_buf () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_font_face_rule_parse_from_buf() failed\n") ;
}
test_cr_statement_at_import_rule_parse_from_buf () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_at_import_rule() failed\n") ;
}
status = test_cr_statement_parse_from_buf () ;
if (status != CR_OK)
{
- g_print ("\nKO\n") ;
- return 0 ;
+ g_print ("\ntest cr_statement_parse_from_buf() failed\n") ;
}
cr_test_utils_parse_cmd_line (argc, argv, &options) ;