summaryrefslogtreecommitdiff
path: root/xmllint.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmllint.c')
-rw-r--r--xmllint.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/xmllint.c b/xmllint.c
index 26d8db1..40a2194 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -168,9 +168,8 @@ static int nodefdtd = 0;
#endif
#ifdef LIBXML_PUSH_ENABLED
static int push = 0;
-static int pushsize = 4096;
#endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
static int memory = 0;
#endif
static int testIO = 0;
@@ -210,7 +209,7 @@ static xmlStreamCtxtPtr patstream = NULL;
#ifdef LIBXML_XPATH_ENABLED
static const char *xpathquery = NULL;
#endif
-static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
+static int options = XML_PARSE_COMPACT;
static int sax = 0;
static int oldxml10 = 0;
@@ -1670,7 +1669,6 @@ testSAX(const char *filename) {
(xmlSchemaValidityErrorFunc) fprintf,
(xmlSchemaValidityWarningFunc) fprintf,
stderr);
- xmlSchemaValidateSetFilename(vctxt, filename);
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
(void *)user_data);
@@ -1825,7 +1823,7 @@ static void processNode(xmlTextReaderPtr reader) {
static void streamFile(char *filename) {
xmlTextReaderPtr reader;
int ret;
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
int fd = -1;
struct stat info;
const char *base = NULL;
@@ -1875,8 +1873,7 @@ static void streamFile(char *filename) {
xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1);
else
#endif /* LIBXML_VALID_ENABLED */
- if (loaddtd)
- xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1);
+ xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1);
#ifdef LIBXML_SCHEMAS_ENABLED
if (relaxng != NULL) {
if ((timing) && (!repeat)) {
@@ -1977,7 +1974,7 @@ static void streamFile(char *filename) {
patstream = NULL;
}
#endif
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
if (memory) {
xmlFreeParserInputBuffer(input);
munmap((char *) base, info.st_size);
@@ -2142,7 +2139,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) {
progresult = XMLLINT_ERR_MEM;
return;
}
- ctxt->node = (xmlNodePtr) doc;
+ ctxt->node = xmlDocGetRootElement(doc);
res = xmlXPathEval(BAD_CAST query, ctxt);
xmlXPathFreeContext(ctxt);
@@ -2194,15 +2191,17 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
f = fopen(filename, "r");
#endif
if (f != NULL) {
- int res;
+ int res, size = 3;
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, pushsize, f)) > 0) {
+ while ((res = fread(chars, 1, size, f)) > 0) {
htmlParseChunk(ctxt, chars, res, 0);
}
htmlParseChunk(ctxt, chars, 0, 1);
@@ -2213,7 +2212,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
}
#endif /* LIBXML_PUSH_ENABLED */
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
else if ((html) && (memory)) {
int fd;
struct stat info;
@@ -2328,7 +2327,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (rectxt == NULL)
xmlFreeParserCtxt(ctxt);
}
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
} else if (memory) {
int fd;
struct stat info;
@@ -2592,7 +2591,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
} else
#endif
-#ifdef HAVE_MMAP
+#ifdef HAVE_SYS_MMAN_H
if (memory) {
xmlChar *result;
int len;
@@ -2620,7 +2619,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
} else
-#endif /* HAVE_MMAP */
+#endif /* HAVE_SYS_MMAN_H */
if (compress) {
xmlSaveFile(output ? output : "-", doc);
} else if (oldout) {
@@ -3017,9 +3016,8 @@ 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_MMAP
+#ifdef HAVE_SYS_MMAN_H
printf("\t--memory : parse from memory\n");
#endif
printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
@@ -3077,7 +3075,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, imply --noout\n");
+ printf("\t--xpath expr: evaluate the XPath expression, inply --noout\n");
#endif
printf("\nLibxml project home page: http://xmlsoft.org/\n");
@@ -3248,13 +3246,8 @@ 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_MMAP
+#ifdef HAVE_SYS_MMAN_H
else if ((!strcmp(argv[i], "-memory")) ||
(!strcmp(argv[i], "--memory")))
memory++;
@@ -3346,9 +3339,8 @@ main(int argc, char **argv) {
}
else if ((!strcmp(argv[i], "-noblanks")) ||
(!strcmp(argv[i], "--noblanks"))) {
- noblanks++;
- xmlKeepBlanksDefault(0);
- options |= XML_PARSE_NOBLANKS;
+ noblanks++;
+ xmlKeepBlanksDefault(0);
}
else if ((!strcmp(argv[i], "-maxmem")) ||
(!strcmp(argv[i], "--maxmem"))) {