[xml] [PATCH 5/6] Factor out xmlNodeDumpOutputInternalFormatted()



---
 xmlsave.c |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/xmlsave.c b/xmlsave.c
index 086b31e..5e9d1eb 100644
--- a/xmlsave.c
+++ b/xmlsave.c
@@ -801,6 +801,31 @@ xmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
 }
 
 
+/**
+ * xmlNodeDumpOutputInternalFormatted
+ * @ctxt: the context to dump to
+ * @cur:  the node to dump
+ *
+ * Dump a single XML node, with any appropriate formatting.
+ */
+static void
+xmlNodeDumpOutputInternalFormatted(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
+    xmlOutputBufferPtr buf;
+    buf = ctxt->buf;
+    if ((ctxt->format == 1) && (xmlIndentTreeOutput) &&
+        ((cur->type == XML_ELEMENT_NODE) ||
+         (cur->type == XML_COMMENT_NODE) ||
+         (cur->type == XML_PI_NODE)))
+        xmlOutputBufferWrite(buf, ctxt->indent_size *
+                             (ctxt->level > ctxt->indent_nr ? 
+                              ctxt->indent_nr : ctxt->level),
+                             ctxt->indent);
+    xmlNodeDumpOutputInternal(ctxt, cur);
+    if (ctxt->format == 1) {
+        xmlOutputBufferWrite(buf, 1, "\n");
+    }
+}
+
 
 /**
  * xmlNodeListDumpOutput:
@@ -810,23 +835,9 @@ xmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
  */
 static void
 xmlNodeListDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
-    xmlOutputBufferPtr buf;
-
     if (cur == NULL) return;
-    buf = ctxt->buf;
     while (cur != NULL) {
-       if ((ctxt->format == 1) && (xmlIndentTreeOutput) &&
-           ((cur->type == XML_ELEMENT_NODE) ||
-            (cur->type == XML_COMMENT_NODE) ||
-            (cur->type == XML_PI_NODE)))
-           xmlOutputBufferWrite(buf, ctxt->indent_size *
-                                (ctxt->level > ctxt->indent_nr ? 
-                                 ctxt->indent_nr : ctxt->level),
-                                ctxt->indent);
-        xmlNodeDumpOutputInternal(ctxt, cur);
-       if (ctxt->format == 1) {
-           xmlOutputBufferWrite(buf, 1, "\n");
-       }
+       xmlNodeDumpOutputInternalFormatted(ctxt, cur);
        cur = cur->next;
     }
 }
-- 
1.7.1




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]