summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-02-13 23:08:08 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-02-13 23:08:08 +0000
commit7e0fccbf68db9dc79f502a2c5685718194404d60 (patch)
tree28e2ba954a92779300ca02072193edbe6b6c743b
parent63f60598e030911846c399c3aab45e0cc8ee2993 (diff)
downloadlibcroco-7e0fccbf68db9dc79f502a2c5685718194404d60.tar.gz
when we encounter an EOF right after a ';' don't return an error. fix a
2004-02-13 Dodji Seketeli <dodji@gnome.org> * src/cr-declaration.c: (cr_declaration_parse_list_from_buf): when we encounter an EOF right after a ';' don't return an error. * src/cr-parser.c: (CHECK_PARSING_STATUS_ERR): fix a possibly nasty typo. (cr_parser_parse_property): when there is an error here, return the underlying error instead of returning just CR_PARSING_ERROR. (cr_parser_parse_declaration): when we encounter an EOF just at the beginning of parsing, return CR_END_OF_INPUT_ERROR instead of CR_PARSING_ERROR. More generaly, we should always return CR_END_OF_INPUT_ERROR when we encounter that error, and not return CR_PARSING_ERROR instead. tests/test4-main.c: (test_cr_declaration_parse_list): updated this to reflect catch trailing ';' at the end of declaration list.
-rw-r--r--ChangeLog18
-rw-r--r--src/cr-declaration.c10
-rw-r--r--src/cr-parser.c12
-rw-r--r--tests/test4-main.c6
4 files changed, 36 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index e3d8645..f772e5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-02-13 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-declaration.c:
+ (cr_declaration_parse_list_from_buf): when we encounter an EOF
+ right after a ';' don't return an error.
+ * src/cr-parser.c:
+ (CHECK_PARSING_STATUS_ERR): fix a possibly nasty typo.
+ (cr_parser_parse_property): when there is an error here,
+ return the underlying error instead of returning just CR_PARSING_ERROR.
+ (cr_parser_parse_declaration): when we encounter an EOF just at
+ the beginning of parsing, return CR_END_OF_INPUT_ERROR instead
+ of CR_PARSING_ERROR. More generaly, we should always return
+ CR_END_OF_INPUT_ERROR when we encounter that error, and not return
+ CR_PARSING_ERROR instead.
+ tests/test4-main.c:
+ (test_cr_declaration_parse_list): updated this to reflect catch
+ trailing ';' at the end of declaration list.
+
2004-02-12 Dodji Seketeli <dodji@gnome.org>
* src/cr-declaration.[ch]:
diff --git a/src/cr-declaration.c b/src/cr-declaration.c
index 352bebe..aee63a8 100644
--- a/src/cr-declaration.c
+++ b/src/cr-declaration.c
@@ -3,8 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
@@ -18,6 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ *See COPYRIGHTS file for copyright information.
*/
/*
@@ -289,7 +289,13 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
status = cr_parser_parse_declaration (parser, &property,
&value) ;
if (status != CR_OK || !property)
+ {
+ if (status == CR_END_OF_INPUT_ERROR)
+ {
+ status = CR_OK ;
+ }
break ;
+ }
cur_decl = cr_declaration_new (NULL, property, value) ;
if (cur_decl)
{
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 6cb5219..71df4c0 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -3,7 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the
@@ -19,6 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ * See COPYRIGHTS file for copyrights information.
*/
/*
@@ -185,9 +186,9 @@ if ((status) != CR_OK) \
*/
#define CHECK_PARSING_STATUS_ERR(a_this, a_status, a_is_exception,\
a_err_msg, a_err_status) \
-if ((status) != CR_OK) \
+if ((a_status) != CR_OK) \
{ \
- if (a_is_exception == FALSE) status = CR_PARSING_ERROR ; \
+ if (a_is_exception == FALSE) a_status = CR_PARSING_ERROR ; \
cr_parser_push_error (a_this, a_err_msg, a_err_status) ; \
goto error ; \
}
@@ -1990,7 +1991,7 @@ cr_parser_parse_property (CRParser *a_this, GString **a_property)
status = cr_parser_parse_ident (a_this, a_property) ;
- CHECK_PARSING_STATUS (status, FALSE) ;
+ CHECK_PARSING_STATUS (status, TRUE) ;
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
@@ -3788,12 +3789,13 @@ cr_parser_parse_declaration (CRParser *a_this, GString **a_property,
status = cr_parser_parse_property (a_this, a_property) ;
+ if (status == CR_END_OF_INPUT_ERROR)
+ goto error ;
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
"while parsing declaration: next property is malformed",
CR_SYNTAX_ERROR) ;
-
READ_NEXT_CHAR (a_this, &cur_char) ;
if (cur_char != ':')
diff --git a/tests/test4-main.c b/tests/test4-main.c
index 5db1383..4d0b68e 100644
--- a/tests/test4-main.c
+++ b/tests/test4-main.c
@@ -3,8 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
@@ -18,6 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ * See COPYRIGHTS file for copyrights information.
*/
/*
@@ -39,7 +39,7 @@ const guchar * gv_decl_buf =
"toto: tutu, tata" ;
const guchar * gv_decl_list_buf =
-"toto: titi; prop1:val1 ; prop2:val2" ;
+"toto: titi; prop1:val1 ; prop2:val2;" ;
const guchar *gv_ruleset_buf =
"s1 > s2 {toto: tutu, tata} "