Ver código fonte

Fixed setContent not removing all existing child nodes. (#35)

Brucey 9 meses atrás
pai
commit
f4af7944cb
1 arquivos alterados com 4 adições e 9 exclusões
  1. 4 9
      xml.mod/glue.c

+ 4 - 9
xml.mod/glue.c

@@ -174,16 +174,11 @@ int bmx_mxmlSaveStdout(mxml_node_t * node, int format) {
 void bmx_mxmlSetContent(mxml_node_t * node, BBString * content) {
 void bmx_mxmlSetContent(mxml_node_t * node, BBString * content) {
 	mxml_node_t * child = mxmlGetFirstChild(node);
 	mxml_node_t * child = mxmlGetFirstChild(node);
 	while (child != NULL) {
 	while (child != NULL) {
-		mxml_node_t * txt = NULL;
-		if (mxmlGetType(child) == MXML_TEXT) {
-			txt = child;
-		}
-		child = mxmlGetNextSibling(child);
-		if (txt) {
-			mxmlDelete(txt);
-		}
+		mxml_node_t * next = mxmlGetNextSibling(child);
+		mxmlDelete(child);
+		child = next;
 	}
 	}
-	char * c = bbStringToUTF8String(content);
+	char * c = (char*)bbStringToUTF8String(content);
 	mxmlNewText(node, 0, c);
 	mxmlNewText(node, 0, c);
 	bbMemFree(c);
 	bbMemFree(c);
 }
 }