From f277f3130e78df0df95b08049ca99bce5b71a71b Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Mon, 9 Jun 2014 20:13:18 +0200
Subject: Fix include paths for Haiku.


diff --git a/Makefile b/Makefile
index 2e2d4f5..0c49610 100644
--- a/Makefile
+++ b/Makefile
@@ -47,11 +47,11 @@ include $(NSBUILD)/Makefile.top
 
 # Extra installation rules
 Is := include/dom
-I := /include/dom
+I := /$(INCLUDEDIR)/dom
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/dom.h;$(Is)/functypes.h
 
 Is := include/dom/core
-I := /include/dom/core
+I := /$(INCLUDEDIR)/dom/core
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/attr.h;$(Is)/characterdata.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/cdatasection.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/comment.h
@@ -66,7 +66,7 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/pi.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/text.h;$(Is)/typeinfo.h
 
 Is := include/dom/events
-I := /include/dom/events
+I := /$(INCLUDEDIR)/dom/events
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/event.h;$(Is)/ui_event.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/custom_event.h;$(Is)/mouse_event.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/keyboard_event.h;$(Is)/text_event.h
@@ -78,7 +78,7 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/event_listener.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/document_event.h
 
 Is := include/dom/html
-I := /include/dom/html
+I := /$(INCLUDEDIR)/dom/html
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_document.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_collection.h
 INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_element.h
diff --git a/bindings/hubbub/Makefile b/bindings/hubbub/Makefile
index 946219d..984ea3f 100644
--- a/bindings/hubbub/Makefile
+++ b/bindings/hubbub/Makefile
@@ -1,7 +1,7 @@
 ifeq ($(WITH_HUBBUB_BINDING),yes)
   DIR_SOURCES := parser.c
 
-  DIR_INSTALL_ITEMS := /include/dom/bindings/hubbub:errors.h;parser.h
+  DIR_INSTALL_ITEMS := /$(INCLUDEDIR)/dom/bindings/hubbub:errors.h;parser.h
 
   # Hubbub
   ifneq ($(PKGCONFIG),)
diff --git a/bindings/xml/Makefile b/bindings/xml/Makefile
index ea7653c..1211c5e 100644
--- a/bindings/xml/Makefile
+++ b/bindings/xml/Makefile
@@ -26,7 +26,7 @@ ifeq ($(WITH_EXPAT_BINDING),yes)
 endif
 
 ifeq ($(DO_XML_INSTALL),yes)
-  DIR_INSTALL_ITEMS := /include/dom/bindings/xml:xmlerror.h;xmlparser.h
+  DIR_INSTALL_ITEMS := /$(INCLUDEDIR)/dom/bindings/xml:xmlerror.h;xmlparser.h
 endif
 
 include $(NSBUILD)/Makefile.subdir
diff --git a/libdom.pc.in b/libdom.pc.in
index b6e82cf..406ed9e 100644
--- a/libdom.pc.in
+++ b/libdom.pc.in
@@ -1,7 +1,7 @@
 prefix=PREFIX
 exec_prefix=${prefix}
 libdir=${exec_prefix}/LIBDIR
-includedir=${prefix}/include
+includedir=${prefix}/INCLUDEDIR
 
 Name: libdom
 Description: W3C DOM implementation
-- 
1.8.3.4


From fcadc23dde5471290018f727391f076d2a5bee84 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Mon, 1 Sep 2014 10:59:21 +0200
Subject: gcc2 fixes.


diff --git a/src/html/html_collection.c b/src/html/html_collection.c
index 43a26c5..90e35a0 100644
--- a/src/html/html_collection.c
+++ b/src/html/html_collection.c
@@ -219,6 +219,7 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
 		if (n->type == DOM_ELEMENT_NODE &&
 		    col->ic(n, col->ctx) == true) {
 			dom_string *id = NULL;
+			dom_string *id_name = NULL;
 
 			err = _dom_element_get_id((struct dom_element *) n,
 					&id);
@@ -238,7 +239,6 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
 				dom_string_unref(id);
 
 			/* Check for Name attr if id not matched/found */
-			dom_string *id_name = NULL;
 			err = _dom_element_get_attribute((dom_element *)n,
 					doc->memoised[hds_name], &id_name);
 			if(err != DOM_NO_ERR) {
diff --git a/src/html/html_table_element.c b/src/html/html_table_element.c
index 23351f0..54091c5 100644
--- a/src/html/html_table_element.c
+++ b/src/html/html_table_element.c
@@ -207,6 +207,8 @@ dom_exception dom_html_table_element_set_caption(
 	dom_node_internal *check_node = ((dom_node_internal *)caption);
 	dom_html_document *doc = (dom_html_document *)(((dom_node_internal *)table)->owner);
 	dom_exception exp;
+    dom_node *new_caption;
+
 	if(check_node == NULL) {
 		return DOM_HIERARCHY_REQUEST_ERR;
 	}
@@ -220,8 +222,6 @@ dom_exception dom_html_table_element_set_caption(
 		return exp;
 
 	/* Create a new caption */
-        dom_node *new_caption;
-
 	return dom_node_append_child(table, caption,
 			&new_caption);
 }
@@ -262,6 +262,7 @@ dom_exception dom_html_table_element_set_t_head(
 	dom_node_internal *check_node = ((dom_node_internal *)t_head);
 	dom_html_document *doc = (dom_html_document *)(((dom_node_internal *)table)->owner);
 	dom_exception exp;
+	dom_node *new_t_head;
 
 	if (check_node == NULL) {
 		return DOM_HIERARCHY_REQUEST_ERR;
@@ -274,8 +275,6 @@ dom_exception dom_html_table_element_set_t_head(
 	if(exp != DOM_NO_ERR)
 		return exp;
 
-	dom_node *new_t_head;
-
 	return dom_node_append_child(table,
 			t_head, &new_t_head);
 
@@ -318,6 +317,7 @@ dom_exception dom_html_table_element_set_t_foot(
 	dom_node_internal *check_node = ((dom_node_internal *)t_foot); /*< temporary node to check for raised exceptions */
 	dom_html_document *doc = (dom_html_document *)(((dom_node_internal *)table)->owner);
 	dom_exception exp;
+	dom_node *new_t_foot;
 
 	if(check_node == NULL) {
 		return DOM_HIERARCHY_REQUEST_ERR;
@@ -331,8 +331,6 @@ dom_exception dom_html_table_element_set_t_foot(
 	if(exp != DOM_NO_ERR)
 		return exp;
 
-	dom_node *new_t_foot;
-
 	return dom_node_append_child(table, t_foot,
 				&new_t_foot);
 
@@ -728,14 +726,15 @@ dom_exception dom_html_table_element_insert_row(
 			*row = (dom_html_element *)new_row;
 		}
 	} else {
+		uint32_t window_len = 0, section_len;
+		dom_html_table_section_element *t_head;
+		dom_html_table_section_element *t_foot;
+		dom_node_internal *n;
+
 		if(index ==-1) {
 			index = (int32_t)len;
 		}
 
-		dom_html_table_section_element *t_head;
-		dom_html_table_section_element *t_foot;
-		uint32_t window_len = 0, section_len;
-
 		exp = dom_html_table_element_get_t_head(element, &t_head);
 		if (exp != DOM_NO_ERR)
 			return exp;
@@ -763,7 +762,7 @@ dom_exception dom_html_table_element_insert_row(
 
 		window_len += section_len;
 
-		dom_node_internal *n = (dom_node_internal *)element;
+		n = (dom_node_internal *)element;
 
 		dom_html_collection_unref(rows);
 
@@ -846,15 +845,17 @@ dom_exception dom_html_table_element_delete_row(
 		dom_html_collection_unref(rows);
 		return DOM_INDEX_SIZE_ERR;
 	} else {
+		uint32_t window_len = 0, section_len;
+		dom_html_table_section_element *t_head;
+		dom_html_table_section_element *t_foot;
+		dom_node_internal *n;
+
 		if(index ==-1) {
 			index = (int32_t)len-1;
 		}
 
 		dom_html_collection_unref(rows);
 
-		dom_html_table_section_element *t_head;
-		dom_html_table_section_element *t_foot;
-		uint32_t window_len = 0, section_len;
 		exp = dom_html_table_element_get_t_head(element, &t_head);
 		if(exp != DOM_NO_ERR)
 			return exp;
@@ -876,7 +877,7 @@ dom_exception dom_html_table_element_delete_row(
 					index-window_len);
 		}
 		window_len += section_len;
-		dom_node_internal *n = (dom_node_internal *)element;
+		n = (dom_node_internal *)element;
 
 		for (n = n->first_child; n != NULL; n = n->next) {
 			if((n->type == DOM_ELEMENT_NODE) &&
diff --git a/src/html/html_tablecell_element.c b/src/html/html_tablecell_element.c
index 83ebb0c..403e796 100644
--- a/src/html/html_tablecell_element.c
+++ b/src/html/html_tablecell_element.c
@@ -183,13 +183,14 @@ dom_exception dom_html_table_cell_element_get_cell_index(
 	dom_node_internal *n = ((dom_node_internal *)table_cell)->parent;
 	dom_html_document *doc = (dom_html_document *)(n->owner);
 	int32_t cnt = 0;
+	dom_node_internal *root;
 	while(n != NULL) {
 		if(dom_string_caseless_isequal(doc->memoised[hds_TR],n->name)) {
 			break;
 		}
 		n = n->parent;
 	}
-	dom_node_internal *root = n;
+	root = n;
 	while(n != NULL) {
 		if(n == (dom_node_internal *)table_cell) {
 			break;
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
index 0e4c3a8..e4d3514 100644
--- a/src/html/html_tablerow_element.c
+++ b/src/html/html_tablerow_element.c
@@ -201,9 +201,10 @@ dom_exception dom_html_table_row_element_get_row_index(
 			(dom_string_caseless_isequal(parent->name, doc->memoised[hds_TBODY]) ||
 			dom_string_caseless_isequal(parent->name, doc->memoised[hds_TFOOT]))) {
 		uint32_t len;
-		n = parent->parent;
 		dom_html_table_section_element *t_head;
 		dom_html_collection *rows;
+
+		n = parent->parent;
 		exp = dom_html_table_element_get_t_head(
 				(dom_html_table_element *)(parent->parent),
 				&t_head);
-- 
1.8.3.4

