diff options
author | Andrew Sidwell <andy@entai.co.uk> | 2008-07-11 09:53:24 +0000 |
---|---|---|
committer | Andrew Sidwell <andy@entai.co.uk> | 2008-07-11 09:53:24 +0000 |
commit | f16259819ac409814b6de4fe83735e723986ddac (patch) | |
tree | 0eae70e1a1ea177d2e9a9d31390f7d288357dbaf | |
parent | 8fc0e8d8cca0df211b1521ab3d8a6bfd354ff696 (diff) | |
download | libhubbub-f16259819ac409814b6de4fe83735e723986ddac.tar.gz libhubbub-f16259819ac409814b6de4fe83735e723986ddac.tar.bz2 |
Sort out the harness' DOCTYPE prettyprinting and up in the input line length to 2048 characters.
svn path=/trunk/hubbub/; revision=4585
-rw-r--r-- | test/tree2.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/test/tree2.c b/test/tree2.c index 8527642..afedc3a 100644 --- a/test/tree2.c +++ b/test/tree2.c @@ -224,7 +224,7 @@ enum reading_state { int main(int argc, char **argv) { FILE *fp; - char line[1024]; + char line[2048]; bool passed = true; @@ -249,7 +249,7 @@ int main(int argc, char **argv) return 1; } - /* We rely on lines not being anywhere near 1024 characters... */ + /* We rely on lines not being anywhere near 2048 characters... */ while (passed && fgets(line, sizeof line, fp) == line) { switch (state) { @@ -343,12 +343,16 @@ int create_doctype(void *ctx, const hubbub_string *qname, node->type = DOCTYPE; node->data.doctype.name = strndup((char *)ptr_from_hubbub_string(qname), qname->len); - node->data.doctype.public_id = - strndup((char *)ptr_from_hubbub_string(public_id), - public_id->len); - node->data.doctype.system_id = strndup( - (char *)ptr_from_hubbub_string(system_id), - system_id->len); + if (public_id->len) { + node->data.doctype.public_id = strndup( + (char *)ptr_from_hubbub_string(public_id), + public_id->len); + } + if (system_id->len) { + node->data.doctype.system_id = strndup( + (char *)ptr_from_hubbub_string(system_id), + system_id->len); + } *result = node; @@ -682,7 +686,19 @@ static void node_print(buf_t *buf, node_t *node, unsigned depth) switch (node->type) { case DOCTYPE: - buf_add(buf, "<!DOCTYPE \n"); + buf_add(buf, "<!DOCTYPE "); + buf_add(buf, node->data.doctype.name); + + if (node->data.doctype.public_id) { + buf_add(buf, " "); + buf_add(buf, node->data.doctype.public_id); + } + if (node->data.doctype.system_id) { + buf_add(buf, " "); + buf_add(buf, node->data.doctype.system_id); + } + + buf_add(buf, ">\n"); break; case ELEMENT: buf_add(buf, "<"); |