diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-12-13 22:21:58 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-12-13 22:21:58 +0000 |
commit | 29e4399d11095ac948b0186828501781a7e5d1de (patch) | |
tree | a075f76f82c76ecedab70c65e3e8a9153e5f8113 /xmllint.c | |
parent | ae74399da8a5f235723f4ca71f1664b0ff6c4db7 (diff) | |
download | android_external_libxml2-29e4399d11095ac948b0186828501781a7e5d1de.tar.gz android_external_libxml2-29e4399d11095ac948b0186828501781a7e5d1de.tar.bz2 android_external_libxml2-29e4399d11095ac948b0186828501781a7e5d1de.zip |
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
Diffstat (limited to 'xmllint.c')
-rw-r--r-- | xmllint.c | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -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++; |