Commit 29e4399d authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fix the xmlStrdup() used in the previous patch. added --dropdtd fixed

* valid.c: fix the xmlStrdup() used in the previous patch.
* valid.c: added --dropdtd
* tree.c: fixed xmlUnlinkNode so it also removes the references
  from the document if the node is a DTD
Daniel
parent ae74399d
Thu Dec 13 23:19:50 CET 2001 Daniel Veillard <daniel@veillard.com>
* valid.c: fix the xmlStrdup() used in the previous patch.
* valid.c: added --dropdtd
* tree.c: fixed xmlUnlinkNode so it also removes the references
from the document if the node is a DTD
Thu Dec 13 15:54:35 CET 2001 Daniel Veillard <daniel@veillard.com>
* HTMLtree.c valid.c: cleanup some static declarations
......
......@@ -2486,6 +2486,14 @@ xmlUnlinkNode(xmlNodePtr cur) {
#endif
return;
}
if (cur->type == XML_DTD_NODE) {
xmlDocPtr doc;
doc = cur->doc;
if (doc->intSubset == (xmlDtdPtr) cur)
doc->intSubset = NULL;
if (doc->extSubset == (xmlDtdPtr) cur)
doc->extSubset = NULL;
}
if ((cur->parent != NULL) && (cur->parent->children == cur))
cur->parent->children = cur->next;
if ((cur->parent != NULL) && (cur->parent->last == cur))
......
......@@ -112,6 +112,7 @@ static int loaddtd = 0;
static int progresult = 0;
static int timing = 0;
static int generate = 0;
static int dropdtd = 0;
static struct timeval begin, end;
#ifdef LIBXML_CATALOG_ENABLED
static int catalogs = 0;
......@@ -373,13 +374,20 @@ xmlShellReadline(char *prompt) {
return (line_read);
#else
char line_read[501];
char *ret;
int len;
if (prompt != NULL)
fprintf(stdout, "%s", prompt);
if (!fgets(line_read, 500, stdin))
return(NULL);
line_read[500] = 0;
return((char *) xmlStrdup((xmlChar *) line_read));
len = strlen(line_read);
ret = (char *) malloc(len + 1);
if (ret != NULL) {
memcpy (ret, line_read, len + 1);
}
return(ret);
#endif
}
......@@ -601,6 +609,19 @@ static void parseAndPrintFile(char *filename) {
fprintf(stderr, "Parsing took %ld ms\n", msec);
}
/*
* Remove DOCTYPE nodes
*/
if (dropdtd) {
xmlDtdPtr dtd;
dtd = xmlGetIntSubset(doc);
if (dtd != NULL) {
xmlUnlinkNode((xmlNodePtr)dtd);
xmlFreeDtd(dtd);
}
}
#ifdef LIBXML_XINCLUDE_ENABLED
if (xinclude) {
if ((timing) && (!repeat)) {
......@@ -866,6 +887,7 @@ static void usage(const char *name) {
#endif
printf("\t--loaddtd : fetch external Dtd\n");
printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
}
int
main(int argc, char **argv) {
......@@ -945,6 +967,9 @@ main(int argc, char **argv) {
dtdvalid = argv[i];
loaddtd++;
}
else if ((!strcmp(argv[i], "-dropdtd")) ||
(!strcmp(argv[i], "--dropdtd")))
dropdtd++;
else if ((!strcmp(argv[i], "-insert")) ||
(!strcmp(argv[i], "--insert")))
insert++;
......
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