diff options
author | hhb <haibohuang2010@gmail.com> | 2021-02-02 22:27:52 +0000 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2021-02-20 16:49:45 +0100 |
commit | 02bee4c41444fa5c50e3b9ad5f851656b6d0b086 (patch) | |
tree | 76b54e168b90ece605b73b8b8ae2a09d6627b4f2 /xmllint.c | |
parent | 4defa2c24a6d21a7b8f712dd2ea39f43ff113307 (diff) | |
download | libxml2-02bee4c41444fa5c50e3b9ad5f851656b6d0b086.tar.gz |
Add a flag to not output anything when xmllint succeeded
Diffstat (limited to 'xmllint.c')
-rw-r--r-- | xmllint.c | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -165,6 +165,7 @@ static int xinclude = 0; static int dtdattrs = 0; static int loaddtd = 0; static xmllintReturnCode progresult = XMLLINT_RETURN_OK; +static int quiet = 0; static int timing = 0; static int generate = 0; static int dropdtd = 0; @@ -1665,7 +1666,9 @@ testSAX(const char *filename) { (void *)user_data); if (repeat == 0) { if (ret == 0) { - fprintf(stderr, "%s validates\n", filename); + if (!quiet) { + fprintf(stderr, "%s validates\n", filename); + } } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; @@ -1948,7 +1951,9 @@ static void streamFile(char *filename) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; } else { - fprintf(stderr, "%s validates\n", filename); + if (!quiet) { + fprintf(stderr, "%s validates\n", filename); + } } } #endif @@ -2840,7 +2845,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { #endif ret = xmlSchematronValidateDoc(ctxt, doc); if (ret == 0) { - fprintf(stderr, "%s validates\n", filename); + if (!quiet) { + fprintf(stderr, "%s validates\n", filename); + } } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; @@ -2868,7 +2875,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); ret = xmlRelaxNGValidateDoc(ctxt, doc); if (ret == 0) { - fprintf(stderr, "%s validates\n", filename); + if (!quiet) { + fprintf(stderr, "%s validates\n", filename); + } } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; @@ -2893,7 +2902,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); ret = xmlSchemaValidateDoc(ctxt, doc); if (ret == 0) { - fprintf(stderr, "%s validates\n", filename); + if (!quiet) { + fprintf(stderr, "%s validates\n", filename); + } } else if (ret > 0) { fprintf(stderr, "%s fails to validate\n", filename); progresult = XMLLINT_ERR_VALID; @@ -3010,6 +3021,7 @@ static void usage(FILE *f, const char *name) { fprintf(f, "\t--dtdvalid URL : do a posteriori validation against a given DTD\n"); fprintf(f, "\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n"); #endif /* LIBXML_VALID_ENABLED */ + fprintf(f, "\t--quiet : be quiet when succeeded\n"); fprintf(f, "\t--timing : print some timings\n"); fprintf(f, "\t--output file or -o file: save to a given file\n"); fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n"); @@ -3244,6 +3256,9 @@ main(int argc, char **argv) { else if ((!strcmp(argv[i], "-insert")) || (!strcmp(argv[i], "--insert"))) insert++; + else if ((!strcmp(argv[i], "-quiet")) || + (!strcmp(argv[i], "--quiet"))) + quiet++; else if ((!strcmp(argv[i], "-timing")) || (!strcmp(argv[i], "--timing"))) timing++; |