diff --git a/xmllint.c b/xmllint.c index 4d496b1a9..f26e007fb 100644 --- a/xmllint.c +++ b/xmllint.c @@ -112,6 +112,60 @@ typedef struct { int usec; } xmlTime; +/* Boolean xmllint application options */ +typedef enum { + /** Do not build a tree but work just at the SAX level */ + XML_LINT_SAX_ENABLED = (1 << 0), + /** run a navigating shell */ + XML_LINT_NAVIGATING_SHELL = (1 << 1), + /** Show additional debug information */ + XML_LINT_DEBUG_ENABLED = (1 << 2), + /** Test the internal copy implementation */ + XML_LINT_COPY_ENABLED = (1 << 3), + /** Turn on gzip compression of output */ + XML_LINT_ZLIB_COMPRESSION = (1 << 4), + /** Save in W3C canonical format v1.0 (with comments) */ + XML_LINT_CANONICAL_V1_0 = (1 << 5), + /** Save in W3C canonical format v1.1 (with comments) */ + XML_LINT_CANONICAL_V1_1 = (1 << 6), + /** Save exclusive canonical format (with comments) */ + XML_LINT_CANONICAL_EXE = (1 << 7), + /** Do a posteriori validation, i.e after parsing */ + XML_LINT_POST_VALIDATION = (1 << 8), + /** Ad-hoc test for valid insertions */ + XML_LINT_VALID_INSERTIONS = (1 << 9), + /** Use the HTML parser */ + XML_LINT_HTML_ENABLED = (1 << 10), + /** Force to use the XML serializer when using XML_LINT_HTML_ENABLED */ + XML_LINT_XML_OUT = (1 << 11), + /** Use the push mode of the parser */ + XML_LINT_PUSH_ENABLED = (1 << 12), + /** Parse from memory */ + XML_LINT_MEMORY = (1 << 13), + /** Do XInclude processing */ + XML_LINT_XINCLUDE = (1 << 14), + /** Be quiet when succeeded */ + XML_LINT_QUIET = (1 << 15), + /** Print some timings */ + XML_LINT_TIMINGS = (1 << 16), + /** Generate a small doc on the fly */ + XML_LINT_GENERATE = (1 << 17), + /** Remove the DOCTYPE of the input docs */ + XML_LINT_DROP_DTD = (1 << 18), + /** Use the streaming interface to process very large files */ + XML_LINT_USE_STREAMING = (1 << 19), + /** Create a reader and walk though the resulting doc */ + XML_LINT_USE_WALKER = (1 << 20), + /** use SGML catalogs from $SGML_CATALOG_FILES */ + XML_LINT_USE_CATALOGS = (1 << 21), + /** Deactivate all catalogs */ + XML_LINT_USE_NO_CATALOGS = (1 << 22), + /** Print trace of all external entities loaded */ + XML_LINT_USE_LOAD_TRACE = (1 << 23) + + +} xmllintAppOptions; + typedef struct { FILE *errStream; xmlParserCtxtPtr ctxt; @@ -119,31 +173,17 @@ typedef struct { int version; int maxmem; - int sax; int callbacks; - int shell; - int debug; - int copy; int noout; #ifdef LIBXML_OUTPUT_ENABLED const char *output; const char *encoding; const char *indentString; int format; -#ifdef LIBXML_ZLIB_ENABLED - int compress; -#endif -#ifdef LIBXML_C14N_ENABLED - int canonical; - int canonical_11; - int exc_canonical; -#endif #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_VALID_ENABLED - int postvalid; const char *dtdvalid; const char *dtdvalidfpi; - int insert; #endif #ifdef LIBXML_RELAXNG_ENABLED const char *relaxng; @@ -159,31 +199,14 @@ typedef struct { #endif int repeat; #ifdef LIBXML_HTML_ENABLED - int html; int htmlOptions; -#ifdef LIBXML_OUTPUT_ENABLED - int xmlout; #endif -#endif -#ifdef LIBXML_PUSH_ENABLED - int push; -#endif /* LIBXML_PUSH_ENABLED */ #if HAVE_DECL_MMAP - int memory; char *memoryData; size_t memorySize; -#endif -#ifdef LIBXML_XINCLUDE_ENABLED - int xinclude; #endif xmllintReturnCode progresult; - int quiet; - int timing; - int generate; - int dropdtd; #ifdef LIBXML_READER_ENABLED - int stream; - int walker; #ifdef LIBXML_PATTERN_ENABLED const char *pattern; xmlPatternPtr patternc; @@ -192,17 +215,13 @@ typedef struct { #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_XPATH_ENABLED const char *xpathquery; -#endif -#ifdef LIBXML_CATALOG_ENABLED - int catalogs; - int nocatalogs; #endif int parseOptions; + unsigned appOptions; unsigned maxAmpl; xmlChar *paths[MAX_PATHS + 1]; int nbpaths; - int load_trace; xmlTime begin; xmlTime end; @@ -268,7 +287,7 @@ xmllintResourceLoader(void *ctxt, const char *URL, else code = xmlNewInputFromUrl(URL, flags, out); if (code != XML_IO_ENOENT) { - if ((lint->load_trace) && (code == XML_ERR_OK)) { + if ((lint->appOptions & XML_LINT_USE_LOAD_TRACE) && (code == XML_ERR_OK)) { fprintf(lint->errStream, "Loaded URL=\"%s\" ID=\"%s\"\n", URL, ID ? ID : "(null)"); } @@ -288,7 +307,7 @@ xmllintResourceLoader(void *ctxt, const char *URL, else code = xmlNewInputFromUrl((const char *) newURL, flags, out); if (code != XML_IO_ENOENT) { - if ((lint->load_trace) && (code == XML_ERR_OK)) { + if ((lint->appOptions & XML_LINT_USE_LOAD_TRACE) && (code == XML_ERR_OK)) { fprintf(lint->errStream, "Loaded URL=\"%s\" ID=\"%s\"\n", newURL, ID ? ID : "(null)"); } @@ -314,7 +333,7 @@ parseXml(xmllintState *lint, const char *filename) { xmlDocPtr doc; #ifdef LIBXML_PUSH_ENABLED - if (lint->push) { + if (lint->appOptions & XML_LINT_PUSH_ENABLED) { FILE *f; int res; char chars[4096]; @@ -344,7 +363,7 @@ parseXml(xmllintState *lint, const char *filename) { #endif /* LIBXML_PUSH_ENABLED */ #if HAVE_DECL_MMAP - if (lint->memory) { + if (lint->appOptions & XML_LINT_MEMORY) { xmlParserInputPtr input; input = xmlNewInputFromMemory(filename, @@ -376,7 +395,7 @@ parseHtml(xmllintState *lint, const char *filename) { xmlDocPtr doc; #ifdef LIBXML_PUSH_ENABLED - if (lint->push) { + if (lint->appOptions & XML_LINT_PUSH_ENABLED) { FILE *f; int res; char chars[4096]; @@ -406,7 +425,7 @@ parseHtml(xmllintState *lint, const char *filename) { #endif /* LIBXML_PUSH_ENABLED */ #if HAVE_DECL_MMAP - if (lint->memory) { + if (lint->appOptions & XML_LINT_MEMORY) { xmlParserInputPtr input; input = xmlNewInputFromMemory(filename, @@ -1197,7 +1216,7 @@ testSAX(xmllintState *lint, const char *filename) { ret = xmlSchemaValidateStream(vctxt, buf, 0, lint->ctxt->sax, lint); if (lint->repeat == 1) { if (ret == 0) { - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(lint->errStream, "%s validates\n", filename); } } else if (ret > 0) { @@ -1213,7 +1232,7 @@ testSAX(xmllintState *lint, const char *filename) { } else #endif #ifdef LIBXML_HTML_ENABLED - if (lint->html) { + if (lint->appOptions & XML_LINT_HTML_ENABLED) { parseHtml(lint, filename); } else #endif @@ -1235,7 +1254,7 @@ static void processNode(xmllintState *lint, xmlTextReaderPtr reader) { type = xmlTextReaderNodeType(reader); empty = xmlTextReaderIsEmptyElement(reader); - if (lint->debug) { + if (lint->appOptions & XML_LINT_DEBUG_ENABLED) { name = xmlTextReaderConstName(reader); if (name == NULL) name = BAD_CAST "--"; @@ -1320,7 +1339,7 @@ static void streamFile(xmllintState *lint, const char *filename) { int ret; #if HAVE_DECL_MMAP - if (lint->memory) { + if (lint->appOptions & XML_LINT_MEMORY) { reader = xmlReaderForMemory(lint->memoryData, lint->memorySize, filename, NULL, lint->parseOptions); if (reader == NULL) { @@ -1374,7 +1393,7 @@ static void streamFile(xmllintState *lint, const char *filename) { #ifdef LIBXML_RELAXNG_ENABLED if (lint->relaxng != NULL) { - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } ret = xmlTextReaderRelaxNGValidate(reader, lint->relaxng); @@ -1384,14 +1403,14 @@ static void streamFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_SCHEMACOMP; lint->relaxng = NULL; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Compiling the schemas"); } } #endif #ifdef LIBXML_SCHEMAS_ENABLED if (lint->schema != NULL) { - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } ret = xmlTextReaderSchemaValidate(reader, lint->schema); @@ -1401,7 +1420,7 @@ static void streamFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_SCHEMACOMP; lint->schema = NULL; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Compiling the schemas"); } } @@ -1410,12 +1429,12 @@ static void streamFile(xmllintState *lint, const char *filename) { /* * Process all nodes in sequence */ - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } ret = xmlTextReaderRead(reader); while (ret == 1) { - if ((lint->debug) + if ((lint->appOptions & XML_LINT_DEBUG_ENABLED) #ifdef LIBXML_PATTERN_ENABLED || (lint->patternc) #endif @@ -1423,7 +1442,7 @@ static void streamFile(xmllintState *lint, const char *filename) { processNode(lint, reader); ret = xmlTextReaderRead(reader); } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { #ifdef LIBXML_RELAXNG_ENABLED if (lint->relaxng != NULL) endTimer(lint, "Parsing and validating"); @@ -1463,7 +1482,7 @@ static void streamFile(xmllintState *lint, const char *filename) { fprintf(errStream, "%s fails to validate\n", filename); lint->progresult = XMLLINT_ERR_VALID; } else { - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(errStream, "%s validates\n", filename); } } @@ -1542,12 +1561,12 @@ static void walkDoc(xmllintState *lint, xmlDocPtr doc) { #endif /* LIBXML_PATTERN_ENABLED */ reader = xmlReaderWalker(doc); if (reader != NULL) { - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } ret = xmlTextReaderRead(reader); while (ret == 1) { - if ((lint->debug) + if ((lint->appOptions & XML_LINT_DEBUG_ENABLED) #ifdef LIBXML_PATTERN_ENABLED || (lint->patternc) #endif @@ -1555,7 +1574,7 @@ static void walkDoc(xmllintState *lint, xmlDocPtr doc) { processNode(lint, reader); ret = xmlTextReaderRead(reader); } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "walking through the doc"); } xmlFreeTextReader(reader); @@ -1600,7 +1619,7 @@ doXPathDump(xmllintState *lint, xmlXPathObjectPtr cur) { if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) { lint->progresult = XMLLINT_ERR_XPATH_EMPTY; - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(lint->errStream, "XPath set is empty\n"); } break; @@ -1675,7 +1694,7 @@ doXPathQuery(xmllintState *lint, xmlDocPtr doc, const char *query) { } #ifdef LIBXML_DEBUG_ENABLED - if (lint->debug) { + if (lint->appOptions & XML_LINT_DEBUG_ENABLED) { xmlXPathDebugDumpCompExpr(stdout, comp, 0); printf("\n"); } @@ -1708,7 +1727,7 @@ static xmlDocPtr parseFile(xmllintState *lint, const char *filename) { xmlDocPtr doc = NULL; - if ((lint->generate) && (filename == NULL)) { + if ((lint->appOptions & XML_LINT_GENERATE) && (filename == NULL)) { xmlNodePtr n; doc = xmlNewDoc(BAD_CAST "1.0"); @@ -1734,7 +1753,7 @@ parseFile(xmllintState *lint, const char *filename) { } #ifdef LIBXML_HTML_ENABLED - if (lint->html) { + if (lint->appOptions & XML_LINT_HTML_ENABLED) { doc = parseHtml(lint, filename); return(doc); } @@ -1766,7 +1785,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { /* Avoid unused variable warning */ (void) errStream; - if ((lint->timing) && (lint->repeat == 1)) + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) startTimer(lint); doc = parseFile(lint, filename); @@ -1776,11 +1795,11 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { return; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Parsing"); } - if (lint->dropdtd) { + if (lint->appOptions & XML_LINT_DROP_DTD) { xmlDtdPtr dtd; dtd = xmlGetIntSubset(doc); @@ -1791,11 +1810,11 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } #ifdef LIBXML_XINCLUDE_ENABLED - if (lint->xinclude) { + if (lint->appOptions & XML_LINT_XINCLUDE) { xmlXIncludeCtxt *xinc; int res; - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } @@ -1813,7 +1832,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { goto done; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Xinclude processing"); } } @@ -1822,7 +1841,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { /* * shell interaction */ - if (lint->shell) { + if (lint->appOptions & XML_LINT_NAVIGATING_SHELL) { #ifdef LIBXML_XPATH_ENABLED xmlXPathOrderDocElems(doc); #endif @@ -1840,11 +1859,11 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { /* * test intermediate copy if needed. */ - if (lint->copy) { + if (lint->appOptions & XML_LINT_COPY_ENABLED) { xmlDocPtr tmp; tmp = doc; - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { startTimer(lint); } doc = xmlCopyDoc(doc, 1); @@ -1853,22 +1872,22 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { xmlFreeDoc(tmp); return; } - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { endTimer(lint, "Copying"); } - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { startTimer(lint); } xmlFreeDoc(tmp); - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { endTimer(lint, "Freeing original"); } } #ifdef LIBXML_VALID_ENABLED - if ((lint->insert) + if ((lint->appOptions & XML_LINT_VALID_INSERTIONS) #ifdef LIBXML_HTML_ENABLED - && (!lint->html) + && ((lint->appOptions & XML_LINT_HTML_ENABLED) != XML_LINT_HTML_ENABLED) #endif ) { const xmlChar* list[256]; @@ -1899,14 +1918,14 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } else #endif /* LIBXML_VALID_ENABLED */ #ifdef LIBXML_READER_ENABLED - if (lint->walker) { + if (lint->appOptions & XML_LINT_USE_WALKER) { walkDoc(lint, doc); } #endif /* LIBXML_READER_ENABLED */ #ifdef LIBXML_OUTPUT_ENABLED if (lint->noout == 0) { #ifdef LIBXML_ZLIB_ENABLED - if (lint->compress) + if (lint->appOptions & XML_LINT_ZLIB_COMPRESSION) xmlSetDocCompressMode(doc, 9); #endif @@ -1914,13 +1933,13 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { * print it. */ #ifdef LIBXML_DEBUG_ENABLED - if (!lint->debug) { + if ((lint->appOptions & XML_LINT_DEBUG_ENABLED) != XML_LINT_DEBUG_ENABLED) { #endif - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } #ifdef LIBXML_C14N_ENABLED - if (lint->canonical) { + if (lint->appOptions & XML_LINT_CANONICAL_V1_0) { xmlChar *result = NULL; int size; @@ -1934,7 +1953,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { fprintf(errStream, "Failed to canonicalize\n"); lint->progresult = XMLLINT_ERR_OUT; } - } else if (lint->canonical_11) { + } else if (lint->appOptions & XML_LINT_CANONICAL_V1_1) { xmlChar *result = NULL; int size; @@ -1948,7 +1967,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { fprintf(errStream, "Failed to canonicalize\n"); lint->progresult = XMLLINT_ERR_OUT; } - } else if (lint->exc_canonical) { + } else if (lint->appOptions & XML_LINT_CANONICAL_EXE) { xmlChar *result = NULL; int size; @@ -1965,7 +1984,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } else #endif #ifdef LIBXML_ZLIB_ENABLED - if (lint->compress) { + if (lint->appOptions & XML_LINT_ZLIB_COMPRESSION) { xmlSaveFile(lint->output ? lint->output : "-", doc); } else #endif @@ -1979,7 +1998,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { saveOpts |= XML_SAVE_WSNONSIG; #if defined(LIBXML_HTML_ENABLED) - if (lint->xmlout) + if (lint->appOptions & XML_LINT_XML_OUT) saveOpts |= XML_SAVE_AS_XML; #endif @@ -2004,7 +2023,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_OUT; } } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Saving"); } #ifdef LIBXML_DEBUG_ENABLED @@ -2036,14 +2055,14 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { if ((lint->dtdvalid != NULL) || (lint->dtdvalidfpi != NULL)) { xmlDtdPtr dtd; - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } if (lint->dtdvalid != NULL) dtd = xmlParseDTD(NULL, BAD_CAST lint->dtdvalid); else dtd = xmlParseDTD(BAD_CAST lint->dtdvalidfpi, NULL); - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Parsing DTD"); } if (dtd == NULL) { @@ -2064,7 +2083,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { return; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } if (!xmlValidateDtd(cvp, doc, dtd)) { @@ -2078,13 +2097,13 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { filename, lint->dtdvalidfpi); lint->progresult = XMLLINT_ERR_VALID; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Validating against DTD"); } xmlFreeValidCtxt(cvp); xmlFreeDtd(dtd); } - } else if (lint->postvalid) { + } else if (lint->appOptions & XML_LINT_POST_VALIDATION) { xmlValidCtxtPtr cvp; cvp = xmlNewValidCtxt(); @@ -2094,7 +2113,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { return; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } if (!xmlValidateDocument(cvp, doc)) { @@ -2102,7 +2121,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { "Document %s does not validate\n", filename); lint->progresult = XMLLINT_ERR_VALID; } - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Validating"); } xmlFreeValidCtxt(cvp); @@ -2114,11 +2133,11 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { int ret; int flag; - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } - if (lint->debug) + if (lint->appOptions & XML_LINT_DEBUG_ENABLED) flag = XML_SCHEMATRON_OUT_XML; else flag = XML_SCHEMATRON_OUT_TEXT; @@ -2132,7 +2151,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } ret = xmlSchematronValidateDoc(ctxt, doc); if (ret == 0) { - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(errStream, "%s validates\n", filename); } } else if (ret > 0) { @@ -2144,7 +2163,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_VALID; } xmlSchematronFreeValidCtxt(ctxt); - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Validating"); } } @@ -2155,7 +2174,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { xmlRelaxNGValidCtxtPtr ctxt; int ret; - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } @@ -2167,7 +2186,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(errStream, "%s validates\n", filename); } } else if (ret > 0) { @@ -2179,7 +2198,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_VALID; } xmlRelaxNGFreeValidCtxt(ctxt); - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Validating"); } } @@ -2190,7 +2209,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { xmlSchemaValidCtxtPtr ctxt; int ret; - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } @@ -2202,7 +2221,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { } ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { - if (!lint->quiet) { + if ((lint->appOptions & XML_LINT_QUIET) != XML_LINT_QUIET) { fprintf(errStream, "%s validates\n", filename); } } else if (ret > 0) { @@ -2214,7 +2233,7 @@ parseAndPrintFile(xmllintState *lint, const char *filename) { lint->progresult = XMLLINT_ERR_VALID; } xmlSchemaFreeValidCtxt(ctxt); - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Validating"); } } @@ -2227,11 +2246,11 @@ done: /* * free it. */ - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { startTimer(lint); } xmlFreeDoc(doc); - if ((lint->timing) && (lint->repeat == 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat == 1)) { endTimer(lint, "Freeing"); } } @@ -2505,13 +2524,13 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { lint->maxmem = val; } else if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) { - lint->debug = 1; + lint->appOptions |= XML_LINT_DEBUG_ENABLED; } else if ((!strcmp(argv[i], "-shell")) || (!strcmp(argv[i], "--shell"))) { - lint->shell = 1; + lint->appOptions |= XML_LINT_NAVIGATING_SHELL; } else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) { - lint->copy = 1; + lint->appOptions |= XML_LINT_COPY_ENABLED; } else if ((!strcmp(argv[i], "-recover")) || (!strcmp(argv[i], "--recover"))) { lint->parseOptions |= XML_PARSE_RECOVER; @@ -2549,14 +2568,14 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #ifdef LIBXML_HTML_ENABLED } else if ((!strcmp(argv[i], "-html")) || (!strcmp(argv[i], "--html"))) { - lint->html = 1; + lint->appOptions |= XML_LINT_HTML_ENABLED; } else if ((!strcmp(argv[i], "-nodefdtd")) || (!strcmp(argv[i], "--nodefdtd"))) { lint->htmlOptions |= HTML_PARSE_NODEFDTD; #ifdef LIBXML_OUTPUT_ENABLED } else if ((!strcmp(argv[i], "-xmlout")) || (!strcmp(argv[i], "--xmlout"))) { - lint->xmlout = 1; + lint->appOptions |= XML_LINT_XML_OUT; #endif #endif /* LIBXML_HTML_ENABLED */ } else if ((!strcmp(argv[i], "-loaddtd")) || @@ -2571,7 +2590,7 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { lint->parseOptions |= XML_PARSE_DTDVALID; } else if ((!strcmp(argv[i], "-postvalid")) || (!strcmp(argv[i], "--postvalid"))) { - lint->postvalid = 1; + lint->appOptions |= XML_LINT_POST_VALIDATION; lint->parseOptions |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-dtdvalid")) || (!strcmp(argv[i], "--dtdvalid"))) { @@ -2585,20 +2604,20 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { lint->parseOptions |= XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-insert")) || (!strcmp(argv[i], "--insert"))) { - lint->insert = 1; + lint->appOptions |= XML_LINT_VALID_INSERTIONS; #endif /* LIBXML_VALID_ENABLED */ } else if ((!strcmp(argv[i], "-dropdtd")) || (!strcmp(argv[i], "--dropdtd"))) { - lint->dropdtd = 1; + lint->appOptions |= XML_LINT_DROP_DTD; } else if ((!strcmp(argv[i], "-quiet")) || (!strcmp(argv[i], "--quiet"))) { - lint->quiet = 1; + lint->appOptions |= XML_LINT_QUIET; } else if ((!strcmp(argv[i], "-timing")) || (!strcmp(argv[i], "--timing"))) { - lint->timing = 1; + lint->appOptions |= XML_LINT_TIMINGS; } else if ((!strcmp(argv[i], "-auto")) || (!strcmp(argv[i], "--auto"))) { - lint->generate = 1; + lint->appOptions |= XML_LINT_GENERATE; } else if ((!strcmp(argv[i], "-repeat")) || (!strcmp(argv[i], "--repeat"))) { #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION @@ -2612,26 +2631,26 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #ifdef LIBXML_PUSH_ENABLED } else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) { - lint->push = 1; + lint->appOptions |= XML_LINT_PUSH_ENABLED; #endif /* LIBXML_PUSH_ENABLED */ #if HAVE_DECL_MMAP } else if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) { - lint->memory = 1; + lint->appOptions |= XML_LINT_MEMORY; #endif #ifdef LIBXML_XINCLUDE_ENABLED } else if ((!strcmp(argv[i], "-xinclude")) || (!strcmp(argv[i], "--xinclude"))) { - lint->xinclude = 1; + lint->appOptions |= XML_LINT_XINCLUDE; lint->parseOptions |= XML_PARSE_XINCLUDE; } else if ((!strcmp(argv[i], "-noxincludenode")) || (!strcmp(argv[i], "--noxincludenode"))) { - lint->xinclude = 1; + lint->appOptions |= XML_LINT_XINCLUDE; lint->parseOptions |= XML_PARSE_XINCLUDE; lint->parseOptions |= XML_PARSE_NOXINCNODE; } else if ((!strcmp(argv[i], "-nofixup-base-uris")) || (!strcmp(argv[i], "--nofixup-base-uris"))) { - lint->xinclude = 1; + lint->appOptions |= XML_LINT_XINCLUDE; lint->parseOptions |= XML_PARSE_XINCLUDE; lint->parseOptions |= XML_PARSE_NOBASEFIX; #endif @@ -2649,10 +2668,10 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #ifdef LIBXML_CATALOG_ENABLED } else if ((!strcmp(argv[i], "-catalogs")) || (!strcmp(argv[i], "--catalogs"))) { - lint->catalogs = 1; + lint->appOptions |= XML_LINT_USE_CATALOGS; } else if ((!strcmp(argv[i], "-nocatalogs")) || (!strcmp(argv[i], "--nocatalogs"))) { - lint->nocatalogs = 1; + lint->appOptions |= XML_LINT_USE_NO_CATALOGS; lint->parseOptions |= XML_PARSE_NO_SYS_CATALOG; #endif } else if ((!strcmp(argv[i], "-noblanks")) || @@ -2692,30 +2711,30 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #ifdef LIBXML_ZLIB_ENABLED } else if ((!strcmp(argv[i], "-compress")) || (!strcmp(argv[i], "--compress"))) { - lint->compress = 1; + lint->appOptions |= XML_LINT_ZLIB_COMPRESSION; #endif #ifdef LIBXML_C14N_ENABLED } else if ((!strcmp(argv[i], "-c14n")) || (!strcmp(argv[i], "--c14n"))) { - lint->canonical = 1; + lint->appOptions |= XML_LINT_CANONICAL_V1_0; lint->parseOptions |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-c14n11")) || (!strcmp(argv[i], "--c14n11"))) { - lint->canonical_11 = 1; + lint->appOptions |= XML_LINT_CANONICAL_V1_1; lint->parseOptions |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; } else if ((!strcmp(argv[i], "-exc-c14n")) || (!strcmp(argv[i], "--exc-c14n"))) { - lint->exc_canonical = 1; + lint->appOptions |= XML_LINT_CANONICAL_EXE; lint->parseOptions |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; #endif /* LIBXML_C14N_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_READER_ENABLED } else if ((!strcmp(argv[i], "-stream")) || (!strcmp(argv[i], "--stream"))) { - lint->stream = 1; + lint->appOptions |= XML_LINT_USE_STREAMING; } else if ((!strcmp(argv[i], "-walker")) || (!strcmp(argv[i], "--walker"))) { - lint->walker = 1; + lint->appOptions |= XML_LINT_USE_WALKER; lint->noout = 1; #ifdef LIBXML_PATTERN_ENABLED } else if ((!strcmp(argv[i], "-pattern")) || @@ -2731,7 +2750,7 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #endif /* LIBXML_SAX1_ENABLED */ } else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) { - lint->sax = 1; + lint->appOptions |= XML_LINT_SAX_ENABLED; #ifdef LIBXML_RELAXNG_ENABLED } else if ((!strcmp(argv[i], "-relaxng")) || (!strcmp(argv[i], "--relaxng"))) { @@ -2764,7 +2783,7 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { #endif } else if ((!strcmp(argv[i], "-load-trace")) || (!strcmp(argv[i], "--load-trace"))) { - lint->load_trace = 1; + lint->appOptions |= XML_LINT_USE_LOAD_TRACE; } else if ((!strcmp(argv[i], "-path")) || (!strcmp(argv[i], "--path"))) { i++; @@ -2797,31 +2816,31 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { } } - if (lint->shell) + if (lint->appOptions & XML_LINT_NAVIGATING_SHELL) lint->repeat = 1; #ifdef LIBXML_READER_ENABLED - if (lint->stream) { + if (lint->appOptions & XML_LINT_USE_STREAMING) { specialMode = "--stream"; - if (lint->sax) + if (lint->appOptions & XML_LINT_SAX_ENABLED) xmllintOptWarnNoSupport(errStream, "--stream", "--sax"); #ifdef LIBXML_PUSH_ENABLED - if (lint->push) + if (lint->appOptions & XML_LINT_PUSH_ENABLED) xmllintOptWarnNoSupport(errStream, "--stream", "--push"); #endif #ifdef LIBXML_HTML_ENABLED - if (lint->html) + if (lint->appOptions & XML_LINT_HTML_ENABLED) xmllintOptWarnNoSupport(errStream, "--stream", "--html"); #endif } #endif /* LIBXML_READER_ENABLED */ - if (lint->sax) { + if (lint->appOptions & XML_LINT_SAX_ENABLED) { specialMode = "--sax"; #ifdef LIBXML_XINCLUDE_ENABLED - if (lint->xinclude) + if (lint->appOptions & XML_LINT_XINCLUDE) xmllintOptWarnNoSupport(errStream, "--sax", "--xinclude"); #endif #ifdef LIBXML_RELAXNG_ENABLED @@ -2831,30 +2850,30 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { } if (specialMode != NULL) { - if (lint->generate) + if (lint->appOptions & XML_LINT_GENERATE) xmllintOptWarnNoSupport(errStream, specialMode, "--auto"); - if (lint->dropdtd) + if (lint->appOptions & XML_LINT_DROP_DTD) xmllintOptWarnNoSupport(errStream, specialMode, "--dropdtd"); - if (lint->shell) + if (lint->appOptions & XML_LINT_NAVIGATING_SHELL) xmllintOptWarnNoSupport(errStream, specialMode, "--shell"); - if (lint->copy) + if (lint->appOptions & XML_LINT_COPY_ENABLED) xmllintOptWarnNoSupport(errStream, specialMode, "--copy"); #ifdef LIBXML_XPATH_ENABLED if (lint->xpathquery != NULL) xmllintOptWarnNoSupport(errStream, specialMode, "--xpath"); #endif #ifdef LIBXML_READER_ENABLED - if (lint->walker) + if (lint->appOptions & XML_LINT_USE_WALKER) xmllintOptWarnNoSupport(errStream, specialMode, "--walker"); #endif #ifdef LIBXML_VALID_ENABLED - if (lint->insert) + if (lint->appOptions & XML_LINT_VALID_INSERTIONS) xmllintOptWarnNoSupport(errStream, specialMode, "--insert"); if (lint->dtdvalid != NULL) xmllintOptWarnNoSupport(errStream, specialMode, "--dtdvalid"); if (lint->dtdvalidfpi != NULL) xmllintOptWarnNoSupport(errStream, specialMode, "--dtdvalidfpi"); - if (lint->postvalid) + if (lint->appOptions & XML_LINT_POST_VALIDATION) xmllintOptWarnNoSupport(errStream, specialMode, "--postvalid"); #endif #ifdef LIBXML_SCHEMATRON_ENABLED @@ -2870,32 +2889,32 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { xmllintOptWarnNoSupport(errStream, specialMode, "--format or -pretty"); #ifdef LIBXML_ZLIB_ENABLED - if (lint->compress) + if (lint->appOptions & XML_LINT_ZLIB_COMPRESSION) xmllintOptWarnNoSupport(errStream, specialMode, "--compress"); #endif #ifdef LIBXML_HTML_ENABLED - if (lint->xmlout) + if (lint->appOptions & XML_LINT_XML_OUT) xmllintOptWarnNoSupport(errStream, specialMode, "--xmlout"); #endif #ifdef LIBXML_C14N_ENABLED - if (lint->canonical) + if (lint->appOptions & XML_LINT_CANONICAL_V1_0) xmllintOptWarnNoSupport(errStream, specialMode, "--c14n"); - if (lint->canonical_11) + if (lint->appOptions & XML_LINT_CANONICAL_V1_1) xmllintOptWarnNoSupport(errStream, specialMode, "--c14n11"); - if (lint->exc_canonical) + if (lint->appOptions & XML_LINT_CANONICAL_EXE) xmllintOptWarnNoSupport(errStream, specialMode, "--exc-c14n"); #endif #endif /* LIBXML_OUTPUT_ENABLED */ } #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) - if (lint->pattern && !(lint->stream || lint->walker)) + if (lint->pattern && !((lint->appOptions & XML_LINT_USE_STREAMING) || (lint->appOptions & XML_LINT_USE_WALKER))) fprintf(errStream, "Warning: Option %s requires %s\n", "--pattern", "--stream or --walker"); #endif #ifdef LIBXML_HTML_ENABLED - if (lint->html) { + if (lint->appOptions & XML_LINT_HTML_ENABLED) { if (lint->parseOptions & XML_PARSE_DTDATTR) xmllintOptWarnNoSupport(errStream, "--html", "--dtdattr"); if (lint->parseOptions & XML_PARSE_DTDLOAD) @@ -2925,7 +2944,7 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) { fprintf(errStream, "Warning: Option %s requires %s\n", "--nodefdtd", "--html"); #ifdef LIBXML_OUTPUT_ENABLED - if (lint->xmlout) + if (lint->appOptions & XML_LINT_XML_OUT) fprintf(errStream, "Warning: Option %s requires %s\n", "--xmlout", "--html"); #endif @@ -2972,8 +2991,8 @@ xmllintMain(int argc, const char **argv, FILE *errStream, LIBXML_TEST_VERSION #ifdef LIBXML_CATALOG_ENABLED - if (lint->nocatalogs == 0) { - if (lint->catalogs) { + if ((lint->appOptions & XML_LINT_USE_NO_CATALOGS) != XML_LINT_USE_NO_CATALOGS) { + if (lint->appOptions & XML_LINT_USE_CATALOGS) { const char *catal; catal = getenv("SGML_CATALOG_FILES"); @@ -2996,16 +3015,16 @@ xmllintMain(int argc, const char **argv, FILE *errStream, #endif #ifdef LIBXML_SCHEMATRON_ENABLED - if ((lint->schematron != NULL) && (lint->sax == 0) + if ((lint->schematron != NULL) && ((lint->appOptions & XML_LINT_SAX_ENABLED) != XML_LINT_SAX_ENABLED) #ifdef LIBXML_READER_ENABLED - && (lint->stream == 0) + && ((lint->appOptions & XML_LINT_USE_STREAMING) != XML_LINT_USE_STREAMING) #endif /* LIBXML_READER_ENABLED */ ) { xmlSchematronParserCtxtPtr ctxt; /* forces loading the DTDs */ lint->parseOptions |= XML_PARSE_DTDLOAD; - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { startTimer(lint); } ctxt = xmlSchematronNewParserCtxt(lint->schematron); @@ -3021,23 +3040,23 @@ xmllintMain(int argc, const char **argv, FILE *errStream, lint->progresult = XMLLINT_ERR_SCHEMACOMP; goto error; } - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { endTimer(lint, "Compiling the schemas"); } } #endif #ifdef LIBXML_RELAXNG_ENABLED - if ((lint->relaxng != NULL) && (lint->sax == 0) + if ((lint->relaxng != NULL) && ((lint->appOptions & XML_LINT_SAX_ENABLED) != XML_LINT_SAX_ENABLED) #ifdef LIBXML_READER_ENABLED - && (lint->stream == 0) + && ((lint->appOptions & XML_LINT_USE_STREAMING) != XML_LINT_USE_STREAMING) #endif /* LIBXML_READER_ENABLED */ ) { xmlRelaxNGParserCtxtPtr ctxt; /* forces loading the DTDs */ lint->parseOptions |= XML_PARSE_DTDLOAD; - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { startTimer(lint); } ctxt = xmlRelaxNGNewParserCtxt(lint->relaxng); @@ -3054,7 +3073,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, lint->progresult = XMLLINT_ERR_SCHEMACOMP; goto error; } - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { endTimer(lint, "Compiling the schemas"); } } @@ -3063,12 +3082,12 @@ xmllintMain(int argc, const char **argv, FILE *errStream, #ifdef LIBXML_SCHEMAS_ENABLED if ((lint->schema != NULL) #ifdef LIBXML_READER_ENABLED - && (lint->stream == 0) + && ((lint->appOptions& XML_LINT_USE_STREAMING) != XML_LINT_USE_STREAMING) #endif ) { xmlSchemaParserCtxtPtr ctxt; - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { startTimer(lint); } ctxt = xmlSchemaNewParserCtxt(lint->schema); @@ -3085,14 +3104,14 @@ xmllintMain(int argc, const char **argv, FILE *errStream, lint->progresult = XMLLINT_ERR_SCHEMACOMP; goto error; } - if (lint->timing) { + if (lint->appOptions & XML_LINT_TIMINGS) { endTimer(lint, "Compiling the schemas"); } } #endif /* LIBXML_SCHEMAS_ENABLED */ #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) - if ((lint->pattern != NULL) && (lint->walker == 0)) { + if ((lint->pattern != NULL) && ((lint->appOptions & XML_LINT_USE_WALKER) != XML_LINT_USE_WALKER)) { res = xmlPatternCompileSafe(BAD_CAST lint->pattern, NULL, 0, NULL, &lint->patternc); if (lint->patternc == NULL) { @@ -3123,7 +3142,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, } #if HAVE_DECL_MMAP - if (lint->memory) { + if (lint->appOptions & XML_LINT_MEMORY) { struct stat info; if (stat(filename, &info) < 0) { lint->progresult = XMLLINT_ERR_RDFILE; @@ -3146,11 +3165,11 @@ xmllintMain(int argc, const char **argv, FILE *errStream, } #endif /* HAVE_DECL_MMAP */ - if ((lint->timing) && (lint->repeat > 1)) + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat > 1)) startTimer(lint); #ifdef LIBXML_READER_ENABLED - if (lint->stream != 0) { + if (lint->appOptions & XML_LINT_USE_STREAMING) { for (j = 0; j < lint->repeat; j++) streamFile(lint, filename); } else @@ -3159,9 +3178,9 @@ xmllintMain(int argc, const char **argv, FILE *errStream, xmlParserCtxtPtr ctxt; #ifdef LIBXML_HTML_ENABLED - if (lint->html) { + if (lint->appOptions & XML_LINT_HTML_ENABLED) { #ifdef LIBXML_PUSH_ENABLED - if (lint->push) { + if (lint->appOptions & XML_LINT_PUSH_ENABLED) { ctxt = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, filename, XML_CHAR_ENCODING_NONE); @@ -3175,7 +3194,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, #endif /* LIBXML_HTML_ENABLED */ { #ifdef LIBXML_PUSH_ENABLED - if (lint->push) { + if (lint->appOptions & XML_LINT_PUSH_ENABLED) { ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, filename); } else @@ -3190,7 +3209,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, goto error; } - if (lint->sax) { + if (lint->appOptions & XML_LINT_SAX_ENABLED) { const xmlSAXHandler *handler; if (lint->noout) { @@ -3216,7 +3235,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, for (j = 0; j < lint->repeat; j++) { if (j > 0) { #ifdef LIBXML_PUSH_ENABLED - if (lint->push) { + if (lint->appOptions & XML_LINT_PUSH_ENABLED) { xmlCtxtResetPush(ctxt, NULL, 0, NULL, NULL); } else #endif @@ -3225,7 +3244,7 @@ xmllintMain(int argc, const char **argv, FILE *errStream, } } - if (lint->sax) { + if (lint->appOptions & XML_LINT_SAX_ENABLED) { testSAX(lint, filename); } else { parseAndPrintFile(lint, filename); @@ -3235,24 +3254,24 @@ xmllintMain(int argc, const char **argv, FILE *errStream, xmlFreeParserCtxt(ctxt); } - if ((lint->timing) && (lint->repeat > 1)) { + if ((lint->appOptions & XML_LINT_TIMINGS) && (lint->repeat > 1)) { endTimer(lint, "%d iterations", lint->repeat); } files += 1; #if HAVE_DECL_MMAP - if (lint->memory) { + if (lint->appOptions & XML_LINT_MEMORY) { munmap(lint->memoryData, lint->memorySize); close(memoryFd); } #endif } - if (lint->generate) + if (lint->appOptions & XML_LINT_GENERATE) parseAndPrintFile(lint, NULL); - if ((files == 0) && (!lint->generate) && (lint->version == 0)) { + if ((files == 0) && ((lint->appOptions & XML_LINT_GENERATE) != XML_LINT_GENERATE) && (lint->version == 0)) { usage(errStream, argv[0]); lint->progresult = XMLLINT_ERR_UNCLASS; }