Explorar el Código

Added xml comment node type.

woollybah hace 6 años
padre
commit
2dda7d15f3
Se han modificado 3 ficheros con 40 adiciones y 2 borrados
  1. 1 1
      mxml.mod/mxml/mxml-file.c
  2. 36 0
      mxml.mod/mxml/mxml-node.c
  3. 3 1
      mxml.mod/mxml/mxml.h

+ 1 - 1
mxml.mod/mxml/mxml-file.c

@@ -2123,7 +2123,7 @@ mxml_load_data(
           goto error;
 	}
 
-	if ((node = mxmlNewElement(parent, buffer)) == NULL)
+	if ((node = mxmlNewComment(parent, buffer)) == NULL)
 	{
 	 /*
 	  * Just print error for now...

+ 36 - 0
mxml.mod/mxml/mxml-node.c

@@ -624,6 +624,42 @@ mxmlNewTextf(mxml_node_t *parent,	/* I - Parent node or @code MXML_NO_PARENT@ */
   return (node);
 }
 
+/*
+ * 'mxmlNewComment()' - Create a new element node.
+ *
+ * The new element node is added to the end of the specified parent's child
+ * list. The constant @code MXML_NO_PARENT@ can be used to specify that the new
+ * element node has no parent.
+ */
+
+mxml_node_t *				/* O - New node */
+mxmlNewComment(mxml_node_t *parent,	/* I - Parent node or @code MXML_NO_PARENT@ */
+               const char  *name)	/* I - Name of element */
+{
+    mxml_node_t	*node;			/* New node */
+
+
+#ifdef DEBUG
+    fprintf(stderr, "mxmlNewElement(parent=%p, name=\"%s\")\n", parent,
+          name ? name : "(null)");
+#endif /* DEBUG */
+
+    /*
+     * Range check input...
+     */
+
+    if (!name)
+        return (NULL);
+
+    /*
+     * Create the node and set the element name...
+     */
+
+    if ((node = mxml_new(parent, MXML_COMMENT)) != NULL)
+        node->value.element.name = strdup(name);
+
+    return (node);
+}
 
 /*
  * 'mxmlRemove()' - Remove a node from its parent.

+ 3 - 1
mxml.mod/mxml/mxml.h

@@ -85,7 +85,8 @@ typedef enum mxml_type_e		/**** The XML node type. ****/
   MXML_OPAQUE,				/* Opaque string */
   MXML_REAL,				/* Real value */
   MXML_TEXT,				/* Text fragment */
-  MXML_CUSTOM				/* Custom data @since Mini-XML 2.1@ */
+  MXML_CUSTOM,				/* Custom data @since Mini-XML 2.1@ */
+  MXML_COMMENT				/* XML comment */
 } mxml_type_t;
 
 typedef void (*mxml_custom_destroy_cb_t)(void *);
@@ -203,6 +204,7 @@ __attribute__ ((__format__ (__printf__, 2, 3)))
 extern mxml_node_t	*mxmlNewReal(mxml_node_t *parent, double real);
 extern mxml_node_t	*mxmlNewText(mxml_node_t *parent, int whitespace, const char *string);
 extern mxml_node_t	*mxmlNewTextf(mxml_node_t *parent, int whitespace, const char *format, ...)
+extern mxml_node_t	*mxmlNewComment(mxml_node_t *parent, const char *name);
 #    ifdef __GNUC__
 __attribute__ ((__format__ (__printf__, 3, 4)))
 #    endif /* __GNUC__ */