--- embedaddon/libxml2/xmllint.c 2013/07/22 01:22:22 1.1.1.2 +++ embedaddon/libxml2/xmllint.c 2014/06/15 19:53:29 1.1.1.3 @@ -168,8 +168,9 @@ static int nodefdtd = 0; #endif #ifdef LIBXML_PUSH_ENABLED static int push = 0; +static int pushsize = 4096; #endif /* LIBXML_PUSH_ENABLED */ -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP static int memory = 0; #endif static int testIO = 0; @@ -209,7 +210,7 @@ static xmlStreamCtxtPtr patstream = NULL; #ifdef LIBXML_XPATH_ENABLED static const char *xpathquery = NULL; #endif -static int options = XML_PARSE_COMPACT; +static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES; static int sax = 0; static int oldxml10 = 0; @@ -1669,6 +1670,7 @@ testSAX(const char *filename) { (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); + xmlSchemaValidateSetFilename(vctxt, filename); ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, (void *)user_data); @@ -1823,7 +1825,7 @@ static void processNode(xmlTextReaderPtr reader) { static void streamFile(char *filename) { xmlTextReaderPtr reader; int ret; -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP int fd = -1; struct stat info; const char *base = NULL; @@ -1873,7 +1875,8 @@ static void streamFile(char *filename) { xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); else #endif /* LIBXML_VALID_ENABLED */ - xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); + if (loaddtd) + xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); #ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) { if ((timing) && (!repeat)) { @@ -1974,7 +1977,7 @@ static void streamFile(char *filename) { patstream = NULL; } #endif -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP if (memory) { xmlFreeParserInputBuffer(input); munmap((char *) base, info.st_size); @@ -2139,7 +2142,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *qu progresult = XMLLINT_ERR_MEM; return; } - ctxt->node = xmlDocGetRootElement(doc); + ctxt->node = (xmlNodePtr) doc; res = xmlXPathEval(BAD_CAST query, ctxt); xmlXPathFreeContext(ctxt); @@ -2191,17 +2194,15 @@ static void parseAndPrintFile(char *filename, xmlParse f = fopen(filename, "r"); #endif if (f != NULL) { - int res, size = 3; + int res; char chars[4096]; htmlParserCtxtPtr ctxt; - /* if (repeat) */ - size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = htmlCreatePushParserCtxt(NULL, NULL, chars, res, filename, XML_CHAR_ENCODING_NONE); - while ((res = fread(chars, 1, size, f)) > 0) { + while ((res = fread(chars, 1, pushsize, f)) > 0) { htmlParseChunk(ctxt, chars, res, 0); } htmlParseChunk(ctxt, chars, 0, 1); @@ -2212,7 +2213,7 @@ static void parseAndPrintFile(char *filename, xmlParse } } #endif /* LIBXML_PUSH_ENABLED */ -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP else if ((html) && (memory)) { int fd; struct stat info; @@ -2327,7 +2328,7 @@ static void parseAndPrintFile(char *filename, xmlParse if (rectxt == NULL) xmlFreeParserCtxt(ctxt); } -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP } else if (memory) { int fd; struct stat info; @@ -2591,7 +2592,7 @@ static void parseAndPrintFile(char *filename, xmlParse } } else #endif -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP if (memory) { xmlChar *result; int len; @@ -2619,7 +2620,7 @@ static void parseAndPrintFile(char *filename, xmlParse } } else -#endif /* HAVE_SYS_MMAN_H */ +#endif /* HAVE_MMAP */ if (compress) { xmlSaveFile(output ? output : "-", doc); } else if (oldout) { @@ -3016,8 +3017,9 @@ static void usage(const char *name) { #endif #ifdef LIBXML_PUSH_ENABLED printf("\t--push : use the push mode of the parser\n"); + printf("\t--pushsmall : use the push mode of the parser using tiny increments\n"); #endif /* LIBXML_PUSH_ENABLED */ -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP printf("\t--memory : parse from memory\n"); #endif printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); @@ -3075,7 +3077,7 @@ static void usage(const char *name) { printf("\t--sax: do not build a tree but work just at the SAX level\n"); printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n"); #ifdef LIBXML_XPATH_ENABLED - printf("\t--xpath expr: evaluate the XPath expression, inply --noout\n"); + printf("\t--xpath expr: evaluate the XPath expression, imply --noout\n"); #endif printf("\nLibxml project home page: http://xmlsoft.org/\n"); @@ -3246,8 +3248,13 @@ main(int argc, char **argv) { else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) push++; + else if ((!strcmp(argv[i], "-pushsmall")) || + (!strcmp(argv[i], "--pushsmall"))) { + push++; + pushsize = 10; + } #endif /* LIBXML_PUSH_ENABLED */ -#ifdef HAVE_SYS_MMAN_H +#ifdef HAVE_MMAP else if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) memory++; @@ -3339,8 +3346,9 @@ main(int argc, char **argv) { } else if ((!strcmp(argv[i], "-noblanks")) || (!strcmp(argv[i], "--noblanks"))) { - noblanks++; - xmlKeepBlanksDefault(0); + noblanks++; + xmlKeepBlanksDefault(0); + options |= XML_PARSE_NOBLANKS; } else if ((!strcmp(argv[i], "-maxmem")) || (!strcmp(argv[i], "--maxmem"))) {