mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2026-01-26 21:41:34 +03:00
xmllint: Warn about options with no effect
This commit is contained in:
134
xmllint.c
134
xmllint.c
@@ -2261,13 +2261,7 @@ static void usage(FILE *f, const char *name) {
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
fprintf(f, "\t--version : display the version of the XML library used\n");
|
||||
fprintf(f, "\t--shell : run a navigating shell\n");
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
fprintf(f, "\t--debug : dump a debug tree of the in-memory document\n");
|
||||
#else
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
fprintf(f, "\t--debug : dump the nodes content when using --stream\n");
|
||||
#endif /* LIBXML_READER_ENABLED */
|
||||
#endif
|
||||
fprintf(f, "\t--debug : show additional debug information\n");
|
||||
fprintf(f, "\t--copy : used to test the internal copy implementation\n");
|
||||
fprintf(f, "\t--recover : output what was parsable on broken XML documents\n");
|
||||
fprintf(f, "\t--huge : remove any internal arbitrary parser limits\n");
|
||||
@@ -2451,9 +2445,15 @@ xmllintInit(xmllintState *lint) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
xmllintOptWarnNoSupport(FILE *errStream, const char *opt, const char *nosupp) {
|
||||
fprintf(errStream, "Warning: Option %s doesn't support %s\n", opt, nosupp);
|
||||
}
|
||||
|
||||
static int
|
||||
xmllintParseOptions(xmllintState *lint, int argc, const char **argv) {
|
||||
FILE *errStream = lint->errStream;
|
||||
const char *specialMode = NULL;
|
||||
int i;
|
||||
|
||||
if (argc <= 1) {
|
||||
@@ -2773,6 +2773,126 @@ xmllintParseOptions(xmllintState *lint, int argc, const char **argv) {
|
||||
if (lint->shell)
|
||||
lint->repeat = 1;
|
||||
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
if (lint->stream) {
|
||||
specialMode = "--stream";
|
||||
|
||||
if (lint->sax)
|
||||
xmllintOptWarnNoSupport(errStream, "--stream", "--sax");
|
||||
#ifdef LIBXML_PUSH_ENABLED
|
||||
if (lint->push)
|
||||
xmllintOptWarnNoSupport(errStream, "--stream", "--push");
|
||||
#endif
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (lint->html)
|
||||
xmllintOptWarnNoSupport(errStream, "--stream", "--html");
|
||||
#endif
|
||||
}
|
||||
#endif /* LIBXML_READER_ENABLED */
|
||||
|
||||
if (lint->sax) {
|
||||
specialMode = "--sax";
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
if (lint->xinclude)
|
||||
xmllintOptWarnNoSupport(errStream, "--sax", "--xinclude");
|
||||
#endif
|
||||
#ifdef LIBXML_RELAXNG_ENABLED
|
||||
if (lint->relaxng != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, "--sax", "--relaxng");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (specialMode != NULL) {
|
||||
if (lint->generate)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--auto");
|
||||
if (lint->dropdtd)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--dropdtd");
|
||||
if (lint->shell)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--shell");
|
||||
if (lint->copy)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--copy");
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
if (lint->xpathquery != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--xpath");
|
||||
#endif
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
if (lint->walker)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--walker");
|
||||
#endif
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
if (lint->insert)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--insert");
|
||||
if (lint->dtdvalid != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--dtdvalid");
|
||||
if (lint->dtdvalidfpi != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--dtdvalidfpi");
|
||||
if (lint->postvalid)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--postvalid");
|
||||
#endif
|
||||
#ifdef LIBXML_SCHEMATRON_ENABLED
|
||||
if (lint->schematron != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--schematron");
|
||||
#endif
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
if (lint->output != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--output");
|
||||
if (lint->encoding != NULL)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--encode");
|
||||
if (lint->format > 0)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode,
|
||||
"--format or -pretty");
|
||||
if (lint->compress)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--compress");
|
||||
#endif
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (lint->xmlout)
|
||||
xmllintOptWarnNoSupport(errStream, specialMode, "--xmlout");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
|
||||
if (lint->pattern && !(lint->stream || lint->walker))
|
||||
fprintf(errStream, "Warning: Option %s requires %s\n",
|
||||
"--pattern", "--stream or --walker");
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
if (lint->html) {
|
||||
if (lint->options & XML_PARSE_DTDATTR)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--dtdattr");
|
||||
if (lint->options & XML_PARSE_DTDLOAD)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--loaddtd");
|
||||
if (lint->maxAmpl)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--max-ampl");
|
||||
if (lint->options & XML_PARSE_NOCDATA)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--nocdata");
|
||||
if (lint->options & XML_PARSE_NODICT)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--nodict");
|
||||
if (lint->options & XML_PARSE_NOENT)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--noent");
|
||||
if (lint->options & XML_PARSE_NONET)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--nonet");
|
||||
if (lint->options & XML_PARSE_NSCLEAN)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--nsclean");
|
||||
if (lint->options & XML_PARSE_OLD10)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--oldxml10");
|
||||
if (lint->options & XML_PARSE_PEDANTIC)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--pedantic");
|
||||
if (lint->options & XML_PARSE_DTDVALID)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--valid");
|
||||
if (lint->options & XML_PARSE_SAX1)
|
||||
xmllintOptWarnNoSupport(errStream, "--html", "--sax1");
|
||||
} else {
|
||||
if (lint->htmlOptions & HTML_PARSE_NODEFDTD)
|
||||
fprintf(errStream, "Warning: Option %s requires %s\n",
|
||||
"--nodefdtd", "--html");
|
||||
if (lint->xmlout)
|
||||
fprintf(errStream, "Warning: Option %s requires %s\n",
|
||||
"--xmlout", "--html");
|
||||
}
|
||||
#endif
|
||||
|
||||
return(XMLLINT_RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user