summaryrefslogtreecommitdiff
path: root/xmllint.c
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2012-05-25 04:03:35 +0000
committerAron Xu <aron@debian.org>2012-05-25 04:03:35 +0000
commitd7372d053bbd1d58216fbb04d1771ffa4cc3e624 (patch)
tree62b661911406394bbeaca8951d660bb6d8aac0de /xmllint.c
parent2d1849b271fa8697b88d07ba7d78dc83591e1363 (diff)
downloadlibxml2-d7372d053bbd1d58216fbb04d1771ffa4cc3e624.tar.gz
Imported Upstream version 2.8.0+dfsg1upstream/2.8.0+dfsg1
Diffstat (limited to 'xmllint.c')
-rw-r--r--xmllint.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/xmllint.c b/xmllint.c
index b7af32f..40a2194 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -130,6 +130,7 @@ static int copy = 0;
#endif /* LIBXML_TREE_ENABLED */
static int recovery = 0;
static int noent = 0;
+static int noenc = 0;
static int noblanks = 0;
static int noout = 0;
static int nowrap = 0;
@@ -519,10 +520,11 @@ endTimer(char *format, ...)
* We cannot do anything because we don't have a timing function
*/
#ifdef HAVE_STDARG_H
+ va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
- fprintf(stderr, " was not timed\n", msec);
+ fprintf(stderr, " was not timed\n");
#else
/* We don't have gettimeofday, time or stdarg.h, what crazy world is
* this ?!
@@ -2072,7 +2074,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
#ifdef LIBXML_OUTPUT_ENABLED
xmlSaveCtxtPtr ctxt;
- if (cur->nodesetval->nodeNr <= 0) {
+ if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
fprintf(stderr, "XPath set is empty\n");
progresult = XMLLINT_ERR_XPATH;
break;
@@ -2550,7 +2552,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
if (size >= 0) {
- write(1, result, size);
+ if (write(1, result, size) == -1) {
+ fprintf(stderr, "Can't write data\n");
+ }
xmlFree(result);
} else {
fprintf(stderr, "Failed to canonicalize\n");
@@ -2562,7 +2566,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
if (size >= 0) {
- write(1, result, size);
+ if (write(1, result, size) == -1) {
+ fprintf(stderr, "Can't write data\n");
+ }
xmlFree(result);
} else {
fprintf(stderr, "Failed to canonicalize\n");
@@ -2575,7 +2581,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
if (size >= 0) {
- write(1, result, size);
+ if (write(1, result, size) == -1) {
+ fprintf(stderr, "Can't write data\n");
+ }
xmlFree(result);
} else {
fprintf(stderr, "Failed to canonicalize\n");
@@ -2604,7 +2612,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
fprintf(stderr, "Failed to save\n");
progresult = XMLLINT_ERR_OUT;
} else {
- write(1, result, len);
+ if (write(1, result, len) == -1) {
+ fprintf(stderr, "Can't write data\n");
+ }
xmlFree(result);
}
@@ -2949,6 +2959,7 @@ static void showVersion(const char *name) {
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 ");
+ if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma ");
fprintf(stderr, "\n");
}
@@ -2975,6 +2986,7 @@ static void usage(const char *name) {
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--noenc : ignore any encoding specified inside the document\n");
printf("\t--noout : don't output the result tree\n");
printf("\t--path 'paths': provide a set of paths for resources\n");
printf("\t--load-trace : print trace of all external entites loaded\n");
@@ -3129,6 +3141,10 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--noent"))) {
noent++;
options |= XML_PARSE_NOENT;
+ } else if ((!strcmp(argv[i], "-noenc")) ||
+ (!strcmp(argv[i], "--noenc"))) {
+ noenc++;
+ options |= XML_PARSE_IGNORE_ENC;
} else if ((!strcmp(argv[i], "-nsclean")) ||
(!strcmp(argv[i], "--nsclean"))) {
options |= XML_PARSE_NSCLEAN;
@@ -3349,11 +3365,11 @@ main(int argc, char **argv) {
i++;
#ifdef LIBXML_OUTPUT_ENABLED
format = atoi(argv[i]);
-#endif /* LIBXML_OUTPUT_ENABLED */
if (format == 1) {
noblanks++;
xmlKeepBlanksDefault(0);
}
+#endif /* LIBXML_OUTPUT_ENABLED */
}
#ifdef LIBXML_READER_ENABLED
else if ((!strcmp(argv[i], "-stream")) ||