Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: third_party/libxml/xmllint.c

Issue 2951008: Update libxml to 2.7.7. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libxml/xmllint.c
diff --git a/third_party/libxml/xmllint.c b/third_party/libxml/xmllint.c
index ee41697d98369b02c93c657a9948f3364183450f..2a75e3bd53d69145c5f53d94159754a82062bc24 100644
--- a/third_party/libxml/xmllint.c
+++ b/third_party/libxml/xmllint.c
@@ -108,15 +108,16 @@
typedef enum {
XMLLINT_RETURN_OK = 0, /* No error */
- XMLLINT_ERR_UNCLASS, /* Unclassified */
- XMLLINT_ERR_DTD, /* Error in DTD */
- XMLLINT_ERR_VALID, /* Validation error */
- XMLLINT_ERR_RDFILE, /* CtxtReadFile error */
- XMLLINT_ERR_SCHEMACOMP, /* Schema compilation */
- XMLLINT_ERR_OUT, /* Error writing output */
- XMLLINT_ERR_SCHEMAPAT, /* Error in schema pattern */
- XMLLINT_ERR_RDREGIS, /* Error in Reader registration */
- XMLLINT_ERR_MEM /* Out of memory error */
+ XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
+ XMLLINT_ERR_DTD = 2, /* Error in DTD */
+ XMLLINT_ERR_VALID = 3, /* Validation error */
+ XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
+ XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
+ XMLLINT_ERR_OUT = 6, /* Error writing output */
+ XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
+ XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
+ XMLLINT_ERR_MEM = 9, /* Out of memory error */
+ XMLLINT_ERR_XPATH = 10 /* XPath evaluation error */
} xmllintReturnCode;
#ifdef LIBXML_DEBUG_ENABLED
static int shell = 0;
@@ -184,6 +185,7 @@ static int nocatalogs = 0;
#endif
#ifdef LIBXML_C14N_ENABLED
static int canonical = 0;
+static int canonical_11 = 0;
static int exc_canonical = 0;
#endif
#ifdef LIBXML_READER_ENABLED
@@ -200,8 +202,12 @@ static const char *pattern = NULL;
static xmlPatternPtr patternc = NULL;
static xmlStreamCtxtPtr patstream = NULL;
#endif
+#ifdef LIBXML_XPATH_ENABLED
+static const char *xpathquery = NULL;
+#endif
static int options = XML_PARSE_COMPACT;
static int sax = 0;
+static int oldxml10 = 0;
/************************************************************************
* *
@@ -246,7 +252,7 @@ void parsePath(const xmlChar *path) {
static xmlExternalEntityLoader defaultEntityLoader = NULL;
-static xmlParserInputPtr
+static xmlParserInputPtr
xmllintExternalEntityLoader(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt) {
xmlParserInputPtr ret;
@@ -304,10 +310,10 @@ xmllintExternalEntityLoader(const char *URL, const char *ID,
ctxt->sax->error = err;
if (load_trace) {
fprintf \
- (stderr,
- "Loaded URL=\"%s\" ID=\"%s\"\n",
+ (stderr,
+ "Loaded URL=\"%s\" ID=\"%s\"\n",
newURL,
- ID ? ID : "(null)");
+ ID ? ID : "(null)");
}
xmlFree(newURL);
return(ret);
@@ -327,9 +333,9 @@ xmllintExternalEntityLoader(const char *URL, const char *ID,
return(NULL);
}
/************************************************************************
- * *
+ * *
* Memory allocation consumption debugging *
- * *
+ * *
************************************************************************/
static void
@@ -390,13 +396,13 @@ myStrdupFunc(const char *str)
return (ret);
}
/************************************************************************
- * *
+ * *
* Internal timing routines to remove the necessity to have *
* unix-specific function calls. *
- * *
+ * *
************************************************************************/
-#ifndef HAVE_GETTIMEOFDAY
+#ifndef HAVE_GETTIMEOFDAY
#ifdef HAVE_SYS_TIMEB_H
#ifdef HAVE_SYS_TIME_H
#ifdef HAVE_FTIME
@@ -522,9 +528,9 @@ endTimer(char *format, ...)
}
#endif
/************************************************************************
- * *
- * HTML ouput *
- * *
+ * *
+ * HTML ouput *
+ * *
************************************************************************/
static char buffer[50000];
@@ -543,7 +549,7 @@ xmlHTMLEncodeSend(void) {
/**
* xmlHTMLPrintFileInfo:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays the associated file and line informations for the current input
*/
@@ -567,7 +573,7 @@ xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
/**
* xmlHTMLPrintFileContext:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays current context within the input content for error tracking
*/
@@ -592,7 +598,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
n = 0;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
len = strlen(buffer);
- snprintf(&buffer[len], sizeof(buffer) - len, "%c",
+ snprintf(&buffer[len], sizeof(buffer) - len, "%c",
(unsigned char) *cur++);
n++;
}
@@ -618,7 +624,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
@@ -635,7 +641,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
input = ctxt->inputTab[ctxt->inputNr - 2];
}
-
+
xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>error</b>: ");
@@ -655,7 +661,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
@@ -672,13 +678,13 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
input = ctxt->inputTab[ctxt->inputNr - 2];
}
-
+
xmlHTMLPrintFileInfo(input);
-
+
xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: ");
va_start(args, msg);
- len = strlen(buffer);
+ len = strlen(buffer);
vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args);
va_end(args);
xmlHTMLEncodeSend();
@@ -693,7 +699,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
@@ -709,7 +715,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
-
+
xmlHTMLPrintFileInfo(input);
xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: ");
@@ -730,7 +736,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
@@ -748,10 +754,10 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlHTMLPrintFileInfo(input);
-
+
xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: ");
va_start(args, msg);
- len = strlen(buffer);
+ len = strlen(buffer);
vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args);
va_end(args);
xmlHTMLEncodeSend();
@@ -762,9 +768,9 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
}
/************************************************************************
- * *
- * Shell Interface *
- * *
+ * *
+ * Shell Interface *
+ * *
************************************************************************/
#ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED
@@ -773,7 +779,7 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
* @prompt: the prompt value
*
* Read a string
- *
+ *
* Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string.
*/
@@ -812,9 +818,9 @@ xmlShellReadline(char *prompt) {
#endif /* LIBXML_DEBUG_ENABLED */
/************************************************************************
- * *
- * I/O Interfaces *
- * *
+ * *
+ * I/O Interfaces *
+ * *
************************************************************************/
static int myRead(FILE *f, char * buf, int len) {
@@ -828,7 +834,7 @@ static void myClose(FILE *f) {
/************************************************************************
* *
- * SAX based tests *
+ * SAX based tests *
* *
************************************************************************/
@@ -998,7 +1004,7 @@ resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xm
return(NULL);
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
-
+
fprintf(stdout, "SAX.resolveEntity(");
if (publicId != NULL)
fprintf(stdout, "%s", (char *)publicId);
@@ -1053,8 +1059,8 @@ getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
/**
* entityDeclDebug:
* @ctxt: An XML parser context
- * @name: the entity name
- * @type: the entity type
+ * @name: the entity name
+ * @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
@@ -1083,8 +1089,8 @@ const xmlChar *nullstr = BAD_CAST "(null)";
/**
* attributeDeclDebug:
* @ctxt: An XML parser context
- * @name: the attribute name
- * @type: the attribute type
+ * @name: the attribute name
+ * @type: the attribute type
*
* An attribute definition has been parsed
*/
@@ -1108,8 +1114,8 @@ attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem,
/**
* elementDeclDebug:
* @ctxt: An XML parser context
- * @name: the element name
- * @type: the element type
+ * @name: the element name
+ * @type: the element type
* @content: the element value (without processing).
*
* An element definition has been parsed
@@ -1295,7 +1301,7 @@ charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
* @ctxt: An XML parser context
* @name: The entity name
*
- * called when an entity reference is detected.
+ * called when an entity reference is detected.
*/
static void
referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
@@ -1531,7 +1537,7 @@ startElementNsDebug(void *ctx ATTRIBUTE_UNUSED,
else
fprintf(stdout, ", '%s'", (char *) URI);
fprintf(stdout, ", %d", nb_namespaces);
-
+
if (namespaces != NULL) {
for (i = 0;i < nb_namespaces * 2;i++) {
fprintf(stdout, ", xmlns");
@@ -1694,7 +1700,7 @@ testSAX(const char *filename) {
goto error;
}
inputPush(ctxt, inputStream);
-
+
/* do the parsing */
xmlParseDocument(ctxt);
@@ -1713,9 +1719,9 @@ error:
}
/************************************************************************
- * *
- * Stream Test processing *
- * *
+ * *
+ * Stream Test processing *
+ * *
************************************************************************/
#ifdef LIBXML_READER_ENABLED
static void processNode(xmlTextReaderPtr reader) {
@@ -1732,8 +1738,8 @@ static void processNode(xmlTextReaderPtr reader) {
value = xmlTextReaderConstValue(reader);
-
- printf("%d %d %s %d %d",
+
+ printf("%d %d %s %d %d",
xmlTextReaderDepth(reader),
type,
name,
@@ -1749,14 +1755,19 @@ static void processNode(xmlTextReaderPtr reader) {
if (patternc) {
xmlChar *path = NULL;
int match = -1;
-
+
if (type == XML_READER_TYPE_ELEMENT) {
/* do the check only on element start */
match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
if (match) {
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
path = xmlGetNodePath(xmlTextReaderCurrentNode(reader));
printf("Node %s matches pattern %s\n", path, pattern);
+#else
+ printf("Node %s matches pattern %s\n",
+ xmlTextReaderConstName(reader), pattern);
+#endif
}
}
if (patstream != NULL) {
@@ -1771,19 +1782,23 @@ static void processNode(xmlTextReaderPtr reader) {
xmlFreeStreamCtxt(patstream);
patstream = NULL;
} else if (ret != match) {
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
if (path == NULL) {
path = xmlGetNodePath(
xmlTextReaderCurrentNode(reader));
}
+#endif
fprintf(stderr,
"xmlPatternMatch and xmlStreamPush disagree\n");
- fprintf(stderr,
- " pattern %s node %s\n",
- pattern, path);
+ if (path != NULL)
+ fprintf(stderr, " pattern %s node %s\n",
+ pattern, path);
+ else
+ fprintf(stderr, " pattern %s node %s\n",
+ pattern, xmlTextReaderConstName(reader));
}
-
- }
+ }
if ((type == XML_READER_TYPE_END_ELEMENT) ||
((type == XML_READER_TYPE_ELEMENT) && (empty))) {
ret = xmlStreamPop(patstream);
@@ -1810,7 +1825,7 @@ static void streamFile(char *filename) {
xmlParserInputBufferPtr input = NULL;
if (memory) {
- if (stat(filename, &info) < 0)
+ if (stat(filename, &info) < 0)
return;
if ((fd = open(filename, O_RDONLY)) < 0)
return;
@@ -1979,7 +1994,7 @@ static void walkDoc(xmlDocPtr doc) {
namespaces[i++] = ns->prefix;
}
namespaces[i++] = NULL;
- namespaces[i++] = NULL;
+ namespaces[i] = NULL;
if (pattern != NULL) {
patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict,
@@ -2039,10 +2054,104 @@ static void walkDoc(xmlDocPtr doc) {
}
#endif /* LIBXML_READER_ENABLED */
+#ifdef LIBXML_XPATH_ENABLED
/************************************************************************
- * *
- * Tree Test processing *
- * *
+ * *
+ * XPath Query *
+ * *
+ ************************************************************************/
+
+static void doXPathDump(xmlXPathObjectPtr cur) {
+ switch(cur->type) {
+ case XPATH_NODESET: {
+ int i;
+ xmlNodePtr node;
+#ifdef LIBXML_OUTPUT_ENABLED
+ xmlSaveCtxtPtr ctxt;
+
+ if (cur->nodesetval->nodeNr <= 0) {
+ fprintf(stderr, "XPath set is empty\n");
+ progresult = XMLLINT_ERR_XPATH;
+ break;
+ }
+ ctxt = xmlSaveToFd(1, NULL, 0);
+ if (ctxt == NULL) {
+ fprintf(stderr, "Out of memory for XPath\n");
+ progresult = XMLLINT_ERR_MEM;
+ return;
+ }
+ for (i = 0;i < cur->nodesetval->nodeNr;i++) {
+ node = cur->nodesetval->nodeTab[i];
+ xmlSaveTree(ctxt, node);
+ }
+ xmlSaveClose(ctxt);
+#else
+ printf("xpath returned %d nodes\n", cur->nodesetval->nodeNr);
+#endif
+ break;
+ }
+ case XPATH_BOOLEAN:
+ if (cur->boolval) printf("true");
+ else printf("false");
+ break;
+ case XPATH_NUMBER:
+ switch (xmlXPathIsInf(cur->floatval)) {
+ case 1:
+ printf("Infinity");
+ break;
+ case -1:
+ printf("-Infinity");
+ break;
+ default:
+ if (xmlXPathIsNaN(cur->floatval)) {
+ printf("NaN");
+ } else {
+ printf("%0g", cur->floatval);
+ }
+ }
+ break;
+ case XPATH_STRING:
+ printf("%s", (const char *) cur->stringval);
+ break;
+ case XPATH_UNDEFINED:
+ fprintf(stderr, "XPath Object is uninitialized\n");
+ progresult = XMLLINT_ERR_XPATH;
+ break;
+ default:
+ fprintf(stderr, "XPath object of unexpected type\n");
+ progresult = XMLLINT_ERR_XPATH;
+ break;
+ }
+}
+
+static void doXPathQuery(xmlDocPtr doc, const char *query) {
+ xmlXPathContextPtr ctxt;
+ xmlXPathObjectPtr res;
+
+ ctxt = xmlXPathNewContext(doc);
+ if (ctxt == NULL) {
+ fprintf(stderr, "Out of memory for XPath\n");
+ progresult = XMLLINT_ERR_MEM;
+ return;
+ }
+ ctxt->node = xmlDocGetRootElement(doc);
+ res = xmlXPathEval(BAD_CAST query, ctxt);
+ xmlXPathFreeContext(ctxt);
+
+ if (res == NULL) {
+ fprintf(stderr, "XPath evaluation failure\n");
+ progresult = XMLLINT_ERR_XPATH;
+ return;
+ }
+ doXPathDump(res);
+ xmlXPathFreeObject(res);
+}
+#endif /* LIBXML_XPATH_ENABLED */
+
+/************************************************************************
+ * *
+ * Tree Test processing *
+ * *
************************************************************************/
static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlDocPtr doc = NULL;
@@ -2052,7 +2161,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if ((timing) && (!repeat))
startTimer();
-
+
#ifdef LIBXML_TREE_ENABLED
if (filename == NULL) {
@@ -2103,7 +2212,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
int fd;
struct stat info;
const char *base;
- if (stat(filename, &info) < 0)
+ if (stat(filename, &info) < 0)
return;
if ((fd = open(filename, O_RDONLY)) < 0)
return;
@@ -2113,7 +2222,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
doc = htmlReadMemory((char *) base, info.st_size, filename,
NULL, options);
-
+
munmap((char *) base, info.st_size);
close(fd);
}
@@ -2164,6 +2273,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
doc = NULL;
}
}
+ if (f != stdin)
+ fclose(f);
}
} else
#endif /* LIBXML_PUSH_ENABLED */
@@ -2198,7 +2309,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
ctxt = xmlNewParserCtxt();
else
ctxt = rectxt;
- if (ctxt == NULL) {
+ if (ctxt == NULL) {
doc = NULL;
} else {
ctxt->sax->error = xmlHTMLError;
@@ -2216,7 +2327,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
int fd;
struct stat info;
const char *base;
- if (stat(filename, &info) < 0)
+ if (stat(filename, &info) < 0)
return;
if ((fd = open(filename, O_RDONLY)) < 0)
return;
@@ -2230,7 +2341,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
else
doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
filename, NULL, options);
-
+
munmap((char *) base, info.st_size);
close(fd);
#endif
@@ -2242,7 +2353,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
ctxt = xmlNewParserCtxt();
else
ctxt = rectxt;
- if (ctxt == NULL) {
+ if (ctxt == NULL) {
doc = NULL;
} else {
doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
@@ -2305,6 +2416,12 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
#endif
+#ifdef LIBXML_XPATH_ENABLED
+ if (xpathquery != NULL) {
+ doXPathQuery(doc, xpathquery);
+ }
+#endif
+
#ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED
/*
@@ -2363,7 +2480,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
}
}
- }
+ }
}else
#endif /* LIBXML_VALID_ENABLED */
#ifdef LIBXML_READER_ENABLED
@@ -2428,7 +2545,19 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlChar *result = NULL;
int size;
- size = xmlC14NDocDumpMemory(doc, NULL, 0, NULL, 1, &result);
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
+ if (size >= 0) {
+ write(1, result, size);
+ xmlFree(result);
+ } else {
+ fprintf(stderr, "Failed to canonicalize\n");
+ progresult = XMLLINT_ERR_OUT;
+ }
+ } else if (canonical) {
+ xmlChar *result = NULL;
+ int size;
+
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
if (size >= 0) {
write(1, result, size);
xmlFree(result);
@@ -2441,7 +2570,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlChar *result = NULL;
int size;
- size = xmlC14NDocDumpMemory(doc, NULL, 1, NULL, 1, &result);
+ size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
if (size >= 0) {
write(1, result, size);
xmlFree(result);
@@ -2459,7 +2588,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (encoding != NULL) {
if ( format ) {
xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1);
- } else {
+ } else {
xmlDocDumpMemoryEnc(doc, &result, &len, encoding);
}
} else {
@@ -2527,6 +2656,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (format)
saveOpts |= XML_SAVE_FORMAT;
+#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
+ if (xmlout)
+ saveOpts |= XML_SAVE_AS_XML;
+#endif
+
if (output == NULL)
ctxt = xmlSaveToFd(1, encoding, saveOpts);
else
@@ -2579,9 +2713,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
startTimer();
}
if (dtdvalid != NULL)
- dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
+ dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
else
- dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL);
+ dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL);
if ((timing) && (!repeat)) {
endTimer("Parsing DTD");
}
@@ -2752,9 +2886,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
#endif
#ifdef LIBXML_DEBUG_ENABLED
+#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
if ((debugent) && (!html))
xmlDebugDumpEntities(stderr, doc);
#endif
+#endif
/*
* free it.
@@ -2769,9 +2905,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
/************************************************************************
- * *
- * Usage and Main *
- * *
+ * *
+ * Usage and Main *
+ * *
************************************************************************/
static void showVersion(const char *name) {
@@ -2785,28 +2921,28 @@ static void showVersion(const char *name) {
if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns ");
if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer ");
if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 ");
- if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP ");
- if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP ");
+ if (xmlHasFeature(XML_WITH_FTP)) fprintf(stderr, "FTP ");
+ if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP ");
if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid ");
- if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML ");
- if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy ");
- if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N ");
- if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog ");
- if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath ");
- if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer ");
- if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude ");
- if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv ");
- if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X ");
- if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode ");
- if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");
- if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata ");
- if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr ");
- if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas ");
- if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron ");
- if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules ");
- if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug ");
- if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
- if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
+ if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML ");
+ if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy ");
+ if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N ");
+ if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog ");
+ if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath ");
+ if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer ");
+ if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude ");
+ if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv ");
+ if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X ");
+ if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode ");
+ if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");
+ if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata ");
+ if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr ");
+ if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas ");
+ if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron ");
+ if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules ");
+ if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug ");
+ if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
+ if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
fprintf(stderr, "\n");
}
@@ -2832,6 +2968,7 @@ static void usage(const char *name) {
printf("\t--copy : used to test the internal copy implementation\n");
#endif /* LIBXML_TREE_ENABLED */
printf("\t--recover : output what was parsable on broken XML documents\n");
+ printf("\t--huge : remove any internal arbitrary parser limits\n");
printf("\t--noent : substitute entity references by their value\n");
printf("\t--noout : don't output the result tree\n");
printf("\t--path 'paths': provide a set of paths for resources\n");
@@ -2874,7 +3011,8 @@ static void usage(const char *name) {
printf("\t--encode encoding : output in the given encoding\n");
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
#endif /* LIBXML_OUTPUT_ENABLED */
- printf("\t--c14n : save in W3C canonical format (with comments)\n");
+ printf("\t--c14n : save in W3C canonical format v1.0 (with comments)\n");
+ printf("\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n");
printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n");
#ifdef LIBXML_C14N_ENABLED
#endif /* LIBXML_C14N_ENABLED */
@@ -2890,6 +3028,7 @@ static void usage(const char *name) {
#ifdef LIBXML_XINCLUDE_ENABLED
printf("\t--xinclude : do XInclude processing\n");
printf("\t--noxincludenode : same but do not generate XInclude nodes\n");
+ printf("\t--nofixup-base-uris : do not fixup xml:base uris\n");
#endif
printf("\t--loaddtd : fetch external DTD\n");
printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
@@ -2912,6 +3051,10 @@ static void usage(const char *name) {
printf("\t--sax1: use the old SAX1 interfaces for processing\n");
#endif
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");
+#endif
printf("\nLibxml project home page: http://xmlsoft.org/\n");
printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\n");
@@ -2938,7 +3081,7 @@ main(int argc, char **argv) {
int files = 0;
int version = 0;
const char* indent;
-
+
if (argc <= 1) {
usage(argv[0]);
return(1);
@@ -2958,7 +3101,7 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--shell"))) {
shell++;
noout = 1;
- } else
+ } else
#endif
#ifdef LIBXML_TREE_ENABLED
if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
@@ -2969,6 +3112,9 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--recover"))) {
recovery++;
options |= XML_PARSE_RECOVER;
+ } else if ((!strcmp(argv[i], "-huge")) ||
+ (!strcmp(argv[i], "--huge"))) {
+ options |= XML_PARSE_HUGE;
} else if ((!strcmp(argv[i], "-noent")) ||
(!strcmp(argv[i], "--noent"))) {
noent++;
@@ -3091,6 +3237,12 @@ main(int argc, char **argv) {
options |= XML_PARSE_XINCLUDE;
options |= XML_PARSE_NOXINCNODE;
}
+ else if ((!strcmp(argv[i], "-nofixup-base-uris")) ||
+ (!strcmp(argv[i], "--nofixup-base-uris"))) {
+ xinclude++;
+ options |= XML_PARSE_XINCLUDE;
+ options |= XML_PARSE_NOBASEFIX;
+ }
#endif
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef HAVE_ZLIB_H
@@ -3118,19 +3270,24 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--debugent"))) {
debugent++;
xmlParserDebugEntities = 1;
- }
+ }
#endif
#ifdef LIBXML_C14N_ENABLED
else if ((!strcmp(argv[i], "-c14n")) ||
(!strcmp(argv[i], "--c14n"))) {
canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
- }
+ }
+ else if ((!strcmp(argv[i], "-c14n11")) ||
+ (!strcmp(argv[i], "--c14n11"))) {
+ canonical_11++;
+ options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
+ }
else if ((!strcmp(argv[i], "-exc-c14n")) ||
(!strcmp(argv[i], "--exc-c14n"))) {
exc_canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
- }
+ }
#endif
#ifdef LIBXML_CATALOG_ENABLED
else if ((!strcmp(argv[i], "-catalogs")) ||
@@ -3139,7 +3296,7 @@ main(int argc, char **argv) {
} else if ((!strcmp(argv[i], "-nocatalogs")) ||
(!strcmp(argv[i], "--nocatalogs"))) {
nocatalogs++;
- }
+ }
#endif
else if ((!strcmp(argv[i], "-encode")) ||
(!strcmp(argv[i], "--encode"))) {
@@ -3187,16 +3344,17 @@ main(int argc, char **argv) {
#ifdef LIBXML_SAX1_ENABLED
else if ((!strcmp(argv[i], "-sax1")) ||
(!strcmp(argv[i], "--sax1"))) {
- sax1++;
+ sax1++;
+ options |= XML_PARSE_SAX1;
}
#endif /* LIBXML_SAX1_ENABLED */
else if ((!strcmp(argv[i], "-sax")) ||
(!strcmp(argv[i], "--sax"))) {
- sax++;
+ sax++;
}
else if ((!strcmp(argv[i], "-chkregister")) ||
(!strcmp(argv[i], "--chkregister"))) {
- chkregister++;
+ chkregister++;
#ifdef LIBXML_SCHEMAS_ENABLED
} else if ((!strcmp(argv[i], "-relaxng")) ||
(!strcmp(argv[i], "--relaxng"))) {
@@ -3237,6 +3395,17 @@ main(int argc, char **argv) {
i++;
pattern = argv[i];
#endif
+#ifdef LIBXML_XPATH_ENABLED
+ } else if ((!strcmp(argv[i], "-xpath")) ||
+ (!strcmp(argv[i], "--xpath"))) {
+ i++;
+ noout++;
+ xpathquery = argv[i];
+#endif
+ } else if ((!strcmp(argv[i], "-oldxml10")) ||
+ (!strcmp(argv[i], "--oldxml10"))) {
+ oldxml10++;
+ options |= XML_PARSE_OLD10;
} else {
fprintf(stderr, "Unknown option %s\n", argv[i]);
usage(argv[0]);
@@ -3270,12 +3439,12 @@ main(int argc, char **argv) {
xmlRegisterNodeDefault(registerNode);
xmlDeregisterNodeDefault(deregisterNode);
}
-
+
indent = getenv("XMLLINT_INDENT");
if(indent != NULL) {
xmlTreeIndentString = indent;
}
-
+
defaultEntityLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xmllintExternalEntityLoader);
@@ -3297,7 +3466,7 @@ main(int argc, char **argv) {
xmlGenericError(xmlGenericErrorContext,
"<html><head><title>%s output</title></head>\n",
argv[0]);
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
argv[0]);
}
@@ -3311,7 +3480,7 @@ main(int argc, char **argv) {
xmlSchematronParserCtxtPtr ctxt;
/* forces loading the DTDs */
- xmlLoadExtDtdDefaultValue |= 1;
+ xmlLoadExtDtdDefaultValue |= 1;
options |= XML_PARSE_DTDLOAD;
if (timing) {
startTimer();
@@ -3345,7 +3514,7 @@ main(int argc, char **argv) {
xmlRelaxNGParserCtxtPtr ctxt;
/* forces loading the DTDs */
- xmlLoadExtDtdDefaultValue |= 1;
+ xmlLoadExtDtdDefaultValue |= 1;
options |= XML_PARSE_DTDLOAD;
if (timing) {
startTimer();
@@ -3425,7 +3594,7 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--dtdvalid"))) {
i++;
continue;
- }
+ }
if ((!strcmp(argv[i], "-path")) ||
(!strcmp(argv[i], "--path"))) {
i++;
@@ -3464,6 +3633,13 @@ main(int argc, char **argv) {
continue;
}
#endif
+#ifdef LIBXML_XPATH_ENABLED
+ if ((!strcmp(argv[i], "-xpath")) ||
+ (!strcmp(argv[i], "--xpath"))) {
+ i++;
+ continue;
+ }
+#endif
if ((timing) && (repeat))
startTimer();
/* Remember file names. "-" means stdin. <sven@zen.org> */
@@ -3515,7 +3691,7 @@ main(int argc, char **argv) {
}
}
}
- if (generate)
+ if (generate)
parseAndPrintFile(NULL, NULL);
if ((htmlout) && (!nowrap)) {
xmlGenericError(xmlGenericErrorContext, "</body></html>\n");

Powered by Google App Engine
This is Rietveld 408576698