Commit 8a1b1853 authored by Daniel Veillard's avatar Daniel Veillard

applied patch from Lukas Schroeder for register callbacks modified patch

* tree.c : applied patch from Lukas Schroeder for register callbacks
* valid.c: modified patch from Lukas Schroeder to test
  register callbacks with --chkregister
Daniel
parent 067bae5f
Sun Jan 5 23:35:47 CET 2003 Daniel Veillard <daniel@veillard.com>
* tree.c : applied patch from Lukas Schroeder for register callbacks
* valid.c: modified patch from Lukas Schroeder to test
register callbacks with --chkregister
Sun Jan 5 02:23:20 CET 2003 Daniel Veillard <daniel@veillard.com>
* xmlreader.c: seriously changed the way data are pushed to
......
......@@ -447,6 +447,9 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
}
}
}
if (xmlRegisterNodeDefaultValue)
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
return(cur);
}
......@@ -1300,6 +1303,9 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
cur->prev = prev;
}
}
if (xmlRegisterNodeDefaultValue)
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
return(cur);
}
......@@ -1579,6 +1585,9 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
cur->name = name;
cur->ns = ns;
if (xmlRegisterNodeDefaultValue)
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
return(cur);
}
......@@ -3202,13 +3211,22 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
if (parent != NULL) {
xmlNodePtr tmp;
/*
* this is a tricky part for the node register thing:
* in case ret does get coalesced in xmlAddChild
* the deregister-node callback is called; so we register ret now already
*/
if (xmlRegisterNodeDefaultValue)
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
tmp = xmlAddChild(parent, ret);
/* node could have coalesced */
if (tmp != ret)
return(tmp);
}
if (!recursive) return(ret);
if (!recursive)
goto out;
if (node->nsDef != NULL)
ret->nsDef = xmlCopyNamespaceList(node->nsDef);
......@@ -3255,6 +3273,11 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
ret->children = xmlStaticCopyNodeList(node->children, doc, ret);
UPDATE_LAST_CHILD_AND_PARENT(ret)
}
out:
/* if parent != NULL we already registered the node above */
if (parent == NULL && xmlRegisterNodeDefaultValue)
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
return(ret);
}
......
......@@ -11,6 +11,8 @@
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#if defined (_WIN32) && !defined(__CYGWIN__)
#ifdef _MSC_VER
#include <winsock2.h>
......@@ -126,6 +128,7 @@ static int catalogs = 0;
static int nocatalogs = 0;
#endif
static int stream = 0;
static int chkregister = 0;
static const char *output = NULL;
......@@ -908,7 +911,7 @@ static void parseAndPrintFile(char *filename) {
printf("%d element types can be inserted under root:\n",
nb);
for (i = 0;i < nb;i++) {
printf("%s\n", list[i]);
printf("%s\n", (char *) list[i]);
}
}
}
......@@ -1175,9 +1178,24 @@ static void usage(const char *name) {
printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
printf("\t--stream : use the streaming interface to process very large files\n");
printf("\t--chkregister : verify the node registration code\n");
printf("\nLibxml project home page: http://xmlsoft.org/\n");
printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\n");
}
static void registerNode(xmlNodePtr node)
{
node->_private = malloc(sizeof(long));
*(long*)node->_private = (long) 0x81726354;
}
static void deregisterNode(xmlNodePtr node)
{
assert(node->_private != NULL);
assert(*(long*)node->_private == (long) 0x81726354);
free(node->_private);
}
int
main(int argc, char **argv) {
int i, acount;
......@@ -1350,6 +1368,10 @@ main(int argc, char **argv) {
else if ((!strcmp(argv[i], "-stream")) ||
(!strcmp(argv[i], "--stream"))) {
stream++;
}
else if ((!strcmp(argv[i], "-chkregister")) ||
(!strcmp(argv[i], "--chkregister"))) {
chkregister++;
} else {
fprintf(stderr, "Unknown option %s\n", argv[i]);
usage(argv[0]);
......@@ -1371,6 +1393,12 @@ main(int argc, char **argv) {
}
}
#endif
if (chkregister) {
xmlRegisterNodeDefault(registerNode);
xmlDeregisterNodeDefault(deregisterNode);
}
xmlLineNumbersDefault(1);
if (loaddtd != 0)
xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment