r4585 takkaria - /trunk/hubbub/test/tree2.c

netsurf at semichrome.net netsurf at semichrome.net
Fri Jul 11 10:53:24 BST 2008


Author: takkaria
Date: Fri Jul 11 04:53:24 2008
New Revision: 4585

URL: http://source.netsurf-browser.org?rev=4585&view=rev
Log:
Sort out the harness' DOCTYPE prettyprinting and up in the input line length to 2048 characters.

Modified:
    trunk/hubbub/test/tree2.c

Modified: trunk/hubbub/test/tree2.c
URL: http://source.netsurf-browser.org/trunk/hubbub/test/tree2.c?rev=4585&r1=4584&r2=4585&view=diff
==============================================================================
--- trunk/hubbub/test/tree2.c (original)
+++ trunk/hubbub/test/tree2.c Fri Jul 11 04:53:24 2008
@@ -224,7 +224,7 @@
 int main(int argc, char **argv)
 {
 	FILE *fp;
-	char line[1024];
+	char line[2048];
 
 	bool passed = true;
 
@@ -249,7 +249,7 @@
 		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 @@
 	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 @@
 	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, "<");




More information about the netsurf-commits mailing list