summaryrefslogtreecommitdiff
path: root/test/tree2.c
diff options
context:
space:
mode:
authorAndrew Sidwell <andy@entai.co.uk>2008-07-11 14:26:07 +0000
committerAndrew Sidwell <andy@entai.co.uk>2008-07-11 14:26:07 +0000
commit480a852229e9616dc51976d0900e4d41e1e290ed (patch)
tree74cb6dcbbaa4d542ae127e1c31461ea2b7068dba /test/tree2.c
parent022cca7bf5e0e21b247aaf27e6894df75b41a89f (diff)
downloadlibhubbub-480a852229e9616dc51976d0900e4d41e1e290ed.tar.gz
libhubbub-480a852229e9616dc51976d0900e4d41e1e290ed.tar.bz2
- Ignore #document-fragment sections better
- Remove a debugging statement svn path=/trunk/hubbub/; revision=4596
Diffstat (limited to 'test/tree2.c')
-rw-r--r--test/tree2.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/test/tree2.c b/test/tree2.c
index 7c3b5eb..79809ca 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -184,6 +184,8 @@ void buffer_handler(const uint8_t *buffer, size_t len, void *pw)
/*** Buffer handling bits ***/
static void buf_clear(buf_t *buf)
{
+ if (!buf || !buf->buf) return;
+
buf->buf[0] = '\0';
buf->pos = 0;
}
@@ -215,6 +217,7 @@ static void buf_add(buf_t *buf, const char *str)
/* States for reading in data from the tree construction file */
enum reading_state {
+ ERASE_DATA,
EXPECT_DATA,
READING_DATA,
READING_DATA_AFTER_FIRST,
@@ -257,6 +260,15 @@ int main(int argc, char **argv)
switch (state)
{
+ case ERASE_DATA:
+ buf_clear(&got);
+ buf_clear(&expected);
+
+ hubbub_parser_destroy(parser);
+ Document = NULL;
+
+ state = EXPECT_DATA;
+
case EXPECT_DATA:
if (strcmp(line, "#data\n") == 0) {
parser = setup_parser();
@@ -289,8 +301,8 @@ int main(int argc, char **argv)
case READING_ERRORS:
if (strcmp(line, "#document-fragment\n") == 0) {
- hubbub_parser_destroy(parser);
- state = EXPECT_DATA;
+ state = ERASE_DATA;
+ reprocess = true;
}
if (strcmp(line, "#document\n") == 0)
@@ -314,13 +326,7 @@ int main(int argc, char **argv)
printf("%s", got.buf);
}
- buf_clear(&got);
- buf_clear(&expected);
-
- hubbub_parser_destroy(parser);
- Document = NULL;
-
- state = EXPECT_DATA;
+ state = ERASE_DATA;
reprocess = true;
} else {
buf_add(&expected, line);