xmllint use xmlGetNodePath when not compiled in

* xmllint.c: clean up usages of xmlGetNodePath() to make sure it was
  compiled in. Also clear some space issues, solves #545581
This commit is contained in:
Daniel Veillard 2009-08-10 14:43:18 +02:00
parent a194ccb8d1
commit f1edb10c80

225
xmllint.c
View File

@ -248,7 +248,7 @@ void parsePath(const xmlChar *path) {
static xmlExternalEntityLoader defaultEntityLoader = NULL; static xmlExternalEntityLoader defaultEntityLoader = NULL;
static xmlParserInputPtr static xmlParserInputPtr
xmllintExternalEntityLoader(const char *URL, const char *ID, xmllintExternalEntityLoader(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt) { xmlParserCtxtPtr ctxt) {
xmlParserInputPtr ret; xmlParserInputPtr ret;
@ -306,10 +306,10 @@ xmllintExternalEntityLoader(const char *URL, const char *ID,
ctxt->sax->error = err; ctxt->sax->error = err;
if (load_trace) { if (load_trace) {
fprintf \ fprintf \
(stderr, (stderr,
"Loaded URL=\"%s\" ID=\"%s\"\n", "Loaded URL=\"%s\" ID=\"%s\"\n",
newURL, newURL,
ID ? ID : "(null)"); ID ? ID : "(null)");
} }
xmlFree(newURL); xmlFree(newURL);
return(ret); return(ret);
@ -329,9 +329,9 @@ xmllintExternalEntityLoader(const char *URL, const char *ID,
return(NULL); return(NULL);
} }
/************************************************************************ /************************************************************************
* * * *
* Memory allocation consumption debugging * * Memory allocation consumption debugging *
* * * *
************************************************************************/ ************************************************************************/
static void static void
@ -392,13 +392,13 @@ myStrdupFunc(const char *str)
return (ret); return (ret);
} }
/************************************************************************ /************************************************************************
* * * *
* Internal timing routines to remove the necessity to have * * Internal timing routines to remove the necessity to have *
* unix-specific function calls. * * unix-specific function calls. *
* * * *
************************************************************************/ ************************************************************************/
#ifndef HAVE_GETTIMEOFDAY #ifndef HAVE_GETTIMEOFDAY
#ifdef HAVE_SYS_TIMEB_H #ifdef HAVE_SYS_TIMEB_H
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
#ifdef HAVE_FTIME #ifdef HAVE_FTIME
@ -524,9 +524,9 @@ endTimer(char *format, ...)
} }
#endif #endif
/************************************************************************ /************************************************************************
* * * *
* HTML ouput * * HTML ouput *
* * * *
************************************************************************/ ************************************************************************/
static char buffer[50000]; static char buffer[50000];
@ -545,7 +545,7 @@ xmlHTMLEncodeSend(void) {
/** /**
* xmlHTMLPrintFileInfo: * xmlHTMLPrintFileInfo:
* @input: an xmlParserInputPtr input * @input: an xmlParserInputPtr input
* *
* Displays the associated file and line informations for the current input * Displays the associated file and line informations for the current input
*/ */
@ -569,7 +569,7 @@ xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
/** /**
* xmlHTMLPrintFileContext: * xmlHTMLPrintFileContext:
* @input: an xmlParserInputPtr input * @input: an xmlParserInputPtr input
* *
* Displays current context within the input content for error tracking * Displays current context within the input content for error tracking
*/ */
@ -594,7 +594,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
n = 0; n = 0;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) { while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
len = strlen(buffer); len = strlen(buffer);
snprintf(&buffer[len], sizeof(buffer) - len, "%c", snprintf(&buffer[len], sizeof(buffer) - len, "%c",
(unsigned char) *cur++); (unsigned char) *cur++);
n++; n++;
} }
@ -620,7 +620,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
* @ctx: an XML parser context * @ctx: an XML parser context
* @msg: the message to display/transmit * @msg: the message to display/transmit
* @...: extra parameters for the message display * @...: extra parameters for the message display
* *
* Display and format an error messages, gives file, line, position and * Display and format an error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
@ -637,7 +637,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
input = ctxt->inputTab[ctxt->inputNr - 2]; input = ctxt->inputTab[ctxt->inputNr - 2];
} }
xmlHTMLPrintFileInfo(input); xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>error</b>: "); xmlGenericError(xmlGenericErrorContext, "<b>error</b>: ");
@ -657,7 +657,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context * @ctx: an XML parser context
* @msg: the message to display/transmit * @msg: the message to display/transmit
* @...: extra parameters for the message display * @...: extra parameters for the message display
* *
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
@ -674,13 +674,13 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
input = ctxt->inputTab[ctxt->inputNr - 2]; input = ctxt->inputTab[ctxt->inputNr - 2];
} }
xmlHTMLPrintFileInfo(input); xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: "); xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: ");
va_start(args, msg); va_start(args, msg);
len = strlen(buffer); len = strlen(buffer);
vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args);
va_end(args); va_end(args);
xmlHTMLEncodeSend(); xmlHTMLEncodeSend();
@ -695,7 +695,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
* @ctx: an XML parser context * @ctx: an XML parser context
* @msg: the message to display/transmit * @msg: the message to display/transmit
* @...: extra parameters for the message display * @...: extra parameters for the message display
* *
* Display and format an validity error messages, gives file, * Display and format an validity error messages, gives file,
* line, position and extra parameters. * line, position and extra parameters.
*/ */
@ -711,7 +711,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
input = ctxt->input; input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1)) if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2]; input = ctxt->inputTab[ctxt->inputNr - 2];
xmlHTMLPrintFileInfo(input); xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: "); xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: ");
@ -732,7 +732,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context * @ctx: an XML parser context
* @msg: the message to display/transmit * @msg: the message to display/transmit
* @...: extra parameters for the message display * @...: extra parameters for the message display
* *
* Display and format a validity warning messages, gives file, line, * Display and format a validity warning messages, gives file, line,
* position and extra parameters. * position and extra parameters.
*/ */
@ -750,10 +750,10 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
input = ctxt->inputTab[ctxt->inputNr - 2]; input = ctxt->inputTab[ctxt->inputNr - 2];
xmlHTMLPrintFileInfo(input); xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: "); xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: ");
va_start(args, msg); va_start(args, msg);
len = strlen(buffer); len = strlen(buffer);
vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args); vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args);
va_end(args); va_end(args);
xmlHTMLEncodeSend(); xmlHTMLEncodeSend();
@ -764,9 +764,9 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
} }
/************************************************************************ /************************************************************************
* * * *
* Shell Interface * * Shell Interface *
* * * *
************************************************************************/ ************************************************************************/
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED #ifdef LIBXML_XPATH_ENABLED
@ -775,7 +775,7 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
* @prompt: the prompt value * @prompt: the prompt value
* *
* Read a string * Read a string
* *
* Returns a pointer to it or NULL on EOF the caller is expected to * Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string. * free the returned string.
*/ */
@ -814,9 +814,9 @@ xmlShellReadline(char *prompt) {
#endif /* LIBXML_DEBUG_ENABLED */ #endif /* LIBXML_DEBUG_ENABLED */
/************************************************************************ /************************************************************************
* * * *
* I/O Interfaces * * I/O Interfaces *
* * * *
************************************************************************/ ************************************************************************/
static int myRead(FILE *f, char * buf, int len) { static int myRead(FILE *f, char * buf, int len) {
@ -830,7 +830,7 @@ static void myClose(FILE *f) {
/************************************************************************ /************************************************************************
* * * *
* SAX based tests * * SAX based tests *
* * * *
************************************************************************/ ************************************************************************/
@ -1000,7 +1000,7 @@ resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
return(NULL); return(NULL);
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
fprintf(stdout, "SAX.resolveEntity("); fprintf(stdout, "SAX.resolveEntity(");
if (publicId != NULL) if (publicId != NULL)
fprintf(stdout, "%s", (char *)publicId); fprintf(stdout, "%s", (char *)publicId);
@ -1055,8 +1055,8 @@ getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
/** /**
* entityDeclDebug: * entityDeclDebug:
* @ctxt: An XML parser context * @ctxt: An XML parser context
* @name: the entity name * @name: the entity name
* @type: the entity type * @type: the entity type
* @publicId: The public ID of the entity * @publicId: The public ID of the entity
* @systemId: The system ID of the entity * @systemId: The system ID of the entity
* @content: the entity value (without processing). * @content: the entity value (without processing).
@ -1085,8 +1085,8 @@ const xmlChar *nullstr = BAD_CAST "(null)";
/** /**
* attributeDeclDebug: * attributeDeclDebug:
* @ctxt: An XML parser context * @ctxt: An XML parser context
* @name: the attribute name * @name: the attribute name
* @type: the attribute type * @type: the attribute type
* *
* An attribute definition has been parsed * An attribute definition has been parsed
*/ */
@ -1110,8 +1110,8 @@ attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
/** /**
* elementDeclDebug: * elementDeclDebug:
* @ctxt: An XML parser context * @ctxt: An XML parser context
* @name: the element name * @name: the element name
* @type: the element type * @type: the element type
* @content: the element value (without processing). * @content: the element value (without processing).
* *
* An element definition has been parsed * An element definition has been parsed
@ -1297,7 +1297,7 @@ charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
* @ctxt: An XML parser context * @ctxt: An XML parser context
* @name: The entity name * @name: The entity name
* *
* called when an entity reference is detected. * called when an entity reference is detected.
*/ */
static void static void
referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
@ -1533,7 +1533,7 @@ startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
else else
fprintf(stdout, ", '%s'", (char *) URI); fprintf(stdout, ", '%s'", (char *) URI);
fprintf(stdout, ", %d", nb_namespaces); fprintf(stdout, ", %d", nb_namespaces);
if (namespaces != NULL) { if (namespaces != NULL) {
for (i = 0;i < nb_namespaces * 2;i++) { for (i = 0;i < nb_namespaces * 2;i++) {
fprintf(stdout, ", xmlns"); fprintf(stdout, ", xmlns");
@ -1696,7 +1696,7 @@ testSAX(const char *filename) {
goto error; goto error;
} }
inputPush(ctxt, inputStream); inputPush(ctxt, inputStream);
/* do the parsing */ /* do the parsing */
xmlParseDocument(ctxt); xmlParseDocument(ctxt);
@ -1715,9 +1715,9 @@ error:
} }
/************************************************************************ /************************************************************************
* * * *
* Stream Test processing * * Stream Test processing *
* * * *
************************************************************************/ ************************************************************************/
#ifdef LIBXML_READER_ENABLED #ifdef LIBXML_READER_ENABLED
static void processNode(xmlTextReaderPtr reader) { static void processNode(xmlTextReaderPtr reader) {
@ -1734,8 +1734,8 @@ static void processNode(xmlTextReaderPtr reader) {
value = xmlTextReaderConstValue(reader); value = xmlTextReaderConstValue(reader);
printf("%d %d %s %d %d", printf("%d %d %s %d %d",
xmlTextReaderDepth(reader), xmlTextReaderDepth(reader),
type, type,
name, name,
@ -1751,14 +1751,19 @@ static void processNode(xmlTextReaderPtr reader) {
if (patternc) { if (patternc) {
xmlChar *path = NULL; xmlChar *path = NULL;
int match = -1; int match = -1;
if (type == XML_READER_TYPE_ELEMENT) { if (type == XML_READER_TYPE_ELEMENT) {
/* do the check only on element start */ /* do the check only on element start */
match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader)); match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
if (match) { if (match) {
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
path = xmlGetNodePath(xmlTextReaderCurrentNode(reader)); path = xmlGetNodePath(xmlTextReaderCurrentNode(reader));
printf("Node %s matches pattern %s\n", path, pattern); printf("Node %s matches pattern %s\n", path, pattern);
#else
printf("Node %s matches pattern %s\n",
xmlTextReaderConstName(reader), pattern);
#endif
} }
} }
if (patstream != NULL) { if (patstream != NULL) {
@ -1773,19 +1778,23 @@ static void processNode(xmlTextReaderPtr reader) {
xmlFreeStreamCtxt(patstream); xmlFreeStreamCtxt(patstream);
patstream = NULL; patstream = NULL;
} else if (ret != match) { } else if (ret != match) {
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
if (path == NULL) { if (path == NULL) {
path = xmlGetNodePath( path = xmlGetNodePath(
xmlTextReaderCurrentNode(reader)); xmlTextReaderCurrentNode(reader));
} }
#endif
fprintf(stderr, fprintf(stderr,
"xmlPatternMatch and xmlStreamPush disagree\n"); "xmlPatternMatch and xmlStreamPush disagree\n");
fprintf(stderr, if (path != NULL)
" pattern %s node %s\n", fprintf(stderr, " pattern %s node %s\n",
pattern, path); pattern, path);
else
fprintf(stderr, " pattern %s node %s\n",
pattern, xmlTextReaderConstName(reader));
} }
} }
if ((type == XML_READER_TYPE_END_ELEMENT) || if ((type == XML_READER_TYPE_END_ELEMENT) ||
((type == XML_READER_TYPE_ELEMENT) && (empty))) { ((type == XML_READER_TYPE_ELEMENT) && (empty))) {
ret = xmlStreamPop(patstream); ret = xmlStreamPop(patstream);
@ -1812,7 +1821,7 @@ static void streamFile(char *filename) {
xmlParserInputBufferPtr input = NULL; xmlParserInputBufferPtr input = NULL;
if (memory) { if (memory) {
if (stat(filename, &info) < 0) if (stat(filename, &info) < 0)
return; return;
if ((fd = open(filename, O_RDONLY)) < 0) if ((fd = open(filename, O_RDONLY)) < 0)
return; return;
@ -2042,9 +2051,9 @@ static void walkDoc(xmlDocPtr doc) {
#endif /* LIBXML_READER_ENABLED */ #endif /* LIBXML_READER_ENABLED */
/************************************************************************ /************************************************************************
* * * *
* Tree Test processing * * Tree Test processing *
* * * *
************************************************************************/ ************************************************************************/
static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
@ -2054,7 +2063,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if ((timing) && (!repeat)) if ((timing) && (!repeat))
startTimer(); startTimer();
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
if (filename == NULL) { if (filename == NULL) {
@ -2105,7 +2114,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
int fd; int fd;
struct stat info; struct stat info;
const char *base; const char *base;
if (stat(filename, &info) < 0) if (stat(filename, &info) < 0)
return; return;
if ((fd = open(filename, O_RDONLY)) < 0) if ((fd = open(filename, O_RDONLY)) < 0)
return; return;
@ -2115,7 +2124,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
doc = htmlReadMemory((char *) base, info.st_size, filename, doc = htmlReadMemory((char *) base, info.st_size, filename,
NULL, options); NULL, options);
munmap((char *) base, info.st_size); munmap((char *) base, info.st_size);
close(fd); close(fd);
} }
@ -2200,7 +2209,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
ctxt = xmlNewParserCtxt(); ctxt = xmlNewParserCtxt();
else else
ctxt = rectxt; ctxt = rectxt;
if (ctxt == NULL) { if (ctxt == NULL) {
doc = NULL; doc = NULL;
} else { } else {
ctxt->sax->error = xmlHTMLError; ctxt->sax->error = xmlHTMLError;
@ -2218,7 +2227,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
int fd; int fd;
struct stat info; struct stat info;
const char *base; const char *base;
if (stat(filename, &info) < 0) if (stat(filename, &info) < 0)
return; return;
if ((fd = open(filename, O_RDONLY)) < 0) if ((fd = open(filename, O_RDONLY)) < 0)
return; return;
@ -2232,7 +2241,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
else else
doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
filename, NULL, options); filename, NULL, options);
munmap((char *) base, info.st_size); munmap((char *) base, info.st_size);
close(fd); close(fd);
#endif #endif
@ -2244,7 +2253,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
ctxt = xmlNewParserCtxt(); ctxt = xmlNewParserCtxt();
else else
ctxt = rectxt; ctxt = rectxt;
if (ctxt == NULL) { if (ctxt == NULL) {
doc = NULL; doc = NULL;
} else { } else {
doc = xmlCtxtReadFile(ctxt, filename, NULL, options); doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
@ -2365,7 +2374,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} }
} }
} }
} }
}else }else
#endif /* LIBXML_VALID_ENABLED */ #endif /* LIBXML_VALID_ENABLED */
#ifdef LIBXML_READER_ENABLED #ifdef LIBXML_READER_ENABLED
@ -2473,7 +2482,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (encoding != NULL) { if (encoding != NULL) {
if ( format ) { if ( format ) {
xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1); xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1);
} else { } else {
xmlDocDumpMemoryEnc(doc, &result, &len, encoding); xmlDocDumpMemoryEnc(doc, &result, &len, encoding);
} }
} else { } else {
@ -2593,9 +2602,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
startTimer(); startTimer();
} }
if (dtdvalid != NULL) if (dtdvalid != NULL)
dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid); dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
else else
dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL); dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL);
if ((timing) && (!repeat)) { if ((timing) && (!repeat)) {
endTimer("Parsing DTD"); endTimer("Parsing DTD");
} }
@ -2785,9 +2794,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} }
/************************************************************************ /************************************************************************
* * * *
* Usage and Main * * Usage and Main *
* * * *
************************************************************************/ ************************************************************************/
static void showVersion(const char *name) { static void showVersion(const char *name) {
@ -2801,28 +2810,28 @@ static void showVersion(const char *name) {
if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns "); if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns ");
if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer "); if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer ");
if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 "); if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 ");
if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP "); if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP ");
if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP "); if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP ");
if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid "); if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid ");
if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML "); if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML ");
if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy "); if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy ");
if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N "); if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N ");
if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog "); if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog ");
if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath "); if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath ");
if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer ");
if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude ");
if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv ");
if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X ");
if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode ");
if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");
if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata ");
if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr ");
if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas ");
if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron ");
if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules ");
if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug ");
if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
@ -2958,7 +2967,7 @@ main(int argc, char **argv) {
int files = 0; int files = 0;
int version = 0; int version = 0;
const char* indent; const char* indent;
if (argc <= 1) { if (argc <= 1) {
usage(argv[0]); usage(argv[0]);
return(1); return(1);
@ -2978,7 +2987,7 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--shell"))) { (!strcmp(argv[i], "--shell"))) {
shell++; shell++;
noout = 1; noout = 1;
} else } else
#endif #endif
#ifdef LIBXML_TREE_ENABLED #ifdef LIBXML_TREE_ENABLED
if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
@ -3147,24 +3156,24 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--debugent"))) { (!strcmp(argv[i], "--debugent"))) {
debugent++; debugent++;
xmlParserDebugEntities = 1; xmlParserDebugEntities = 1;
} }
#endif #endif
#ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_C14N_ENABLED
else if ((!strcmp(argv[i], "-c14n")) || else if ((!strcmp(argv[i], "-c14n")) ||
(!strcmp(argv[i], "--c14n"))) { (!strcmp(argv[i], "--c14n"))) {
canonical++; canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
} }
else if ((!strcmp(argv[i], "-c14n11")) || else if ((!strcmp(argv[i], "-c14n11")) ||
(!strcmp(argv[i], "--c14n11"))) { (!strcmp(argv[i], "--c14n11"))) {
canonical_11++; canonical_11++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
} }
else if ((!strcmp(argv[i], "-exc-c14n")) || else if ((!strcmp(argv[i], "-exc-c14n")) ||
(!strcmp(argv[i], "--exc-c14n"))) { (!strcmp(argv[i], "--exc-c14n"))) {
exc_canonical++; exc_canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD; options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
} }
#endif #endif
#ifdef LIBXML_CATALOG_ENABLED #ifdef LIBXML_CATALOG_ENABLED
else if ((!strcmp(argv[i], "-catalogs")) || else if ((!strcmp(argv[i], "-catalogs")) ||
@ -3173,7 +3182,7 @@ main(int argc, char **argv) {
} else if ((!strcmp(argv[i], "-nocatalogs")) || } else if ((!strcmp(argv[i], "-nocatalogs")) ||
(!strcmp(argv[i], "--nocatalogs"))) { (!strcmp(argv[i], "--nocatalogs"))) {
nocatalogs++; nocatalogs++;
} }
#endif #endif
else if ((!strcmp(argv[i], "-encode")) || else if ((!strcmp(argv[i], "-encode")) ||
(!strcmp(argv[i], "--encode"))) { (!strcmp(argv[i], "--encode"))) {
@ -3309,12 +3318,12 @@ main(int argc, char **argv) {
xmlRegisterNodeDefault(registerNode); xmlRegisterNodeDefault(registerNode);
xmlDeregisterNodeDefault(deregisterNode); xmlDeregisterNodeDefault(deregisterNode);
} }
indent = getenv("XMLLINT_INDENT"); indent = getenv("XMLLINT_INDENT");
if(indent != NULL) { if(indent != NULL) {
xmlTreeIndentString = indent; xmlTreeIndentString = indent;
} }
defaultEntityLoader = xmlGetExternalEntityLoader(); defaultEntityLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xmllintExternalEntityLoader); xmlSetExternalEntityLoader(xmllintExternalEntityLoader);
@ -3336,7 +3345,7 @@ main(int argc, char **argv) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"<html><head><title>%s output</title></head>\n", "<html><head><title>%s output</title></head>\n",
argv[0]); argv[0]);
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n", "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
argv[0]); argv[0]);
} }
@ -3350,7 +3359,7 @@ main(int argc, char **argv) {
xmlSchematronParserCtxtPtr ctxt; xmlSchematronParserCtxtPtr ctxt;
/* forces loading the DTDs */ /* forces loading the DTDs */
xmlLoadExtDtdDefaultValue |= 1; xmlLoadExtDtdDefaultValue |= 1;
options |= XML_PARSE_DTDLOAD; options |= XML_PARSE_DTDLOAD;
if (timing) { if (timing) {
startTimer(); startTimer();
@ -3384,7 +3393,7 @@ main(int argc, char **argv) {
xmlRelaxNGParserCtxtPtr ctxt; xmlRelaxNGParserCtxtPtr ctxt;
/* forces loading the DTDs */ /* forces loading the DTDs */
xmlLoadExtDtdDefaultValue |= 1; xmlLoadExtDtdDefaultValue |= 1;
options |= XML_PARSE_DTDLOAD; options |= XML_PARSE_DTDLOAD;
if (timing) { if (timing) {
startTimer(); startTimer();
@ -3464,7 +3473,7 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--dtdvalid"))) { (!strcmp(argv[i], "--dtdvalid"))) {
i++; i++;
continue; continue;
} }
if ((!strcmp(argv[i], "-path")) || if ((!strcmp(argv[i], "-path")) ||
(!strcmp(argv[i], "--path"))) { (!strcmp(argv[i], "--path"))) {
i++; i++;
@ -3554,7 +3563,7 @@ main(int argc, char **argv) {
} }
} }
} }
if (generate) if (generate)
parseAndPrintFile(NULL, NULL); parseAndPrintFile(NULL, NULL);
if ((htmlout) && (!nowrap)) { if ((htmlout) && (!nowrap)) {
xmlGenericError(xmlGenericErrorContext, "</body></html>\n"); xmlGenericError(xmlGenericErrorContext, "</body></html>\n");