1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-09-01 13:49:23 +03:00

xmllint: Don't set deprecated globals

Setting parser options should be enough.
This commit is contained in:
Nick Wellnhofer
2022-08-24 15:51:28 +02:00
parent e70b0c5e03
commit 74c84a8c9f

View File

@ -112,8 +112,8 @@ static int noenc = 0;
static int noblanks = 0; static int noblanks = 0;
static int noout = 0; static int noout = 0;
static int nowrap = 0; static int nowrap = 0;
#ifdef LIBXML_OUTPUT_ENABLED
static int format = 0; static int format = 0;
#ifdef LIBXML_OUTPUT_ENABLED
static const char *output = NULL; static const char *output = NULL;
static int compress = 0; static int compress = 0;
static int oldout = 0; static int oldout = 0;
@ -2336,14 +2336,8 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
} else { } else {
if (rectxt != NULL) if (rectxt != NULL)
doc = xmlCtxtReadFile(rectxt, filename, NULL, options); doc = xmlCtxtReadFile(rectxt, filename, NULL, options);
else { else
#ifdef LIBXML_SAX1_ENABLED
if (sax1)
doc = xmlParseFile(filename);
else
#endif /* LIBXML_SAX1_ENABLED */
doc = xmlReadFile(filename, NULL, options); doc = xmlReadFile(filename, NULL, options);
}
} }
} }
@ -3143,8 +3137,7 @@ main(int argc, char **argv) {
options |= XML_PARSE_HUGE; options |= XML_PARSE_HUGE;
} else if ((!strcmp(argv[i], "-noent")) || } else if ((!strcmp(argv[i], "-noent")) ||
(!strcmp(argv[i], "--noent"))) { (!strcmp(argv[i], "--noent"))) {
noent++; noent = 1;
options |= XML_PARSE_NOENT;
} else if ((!strcmp(argv[i], "-noenc")) || } else if ((!strcmp(argv[i], "-noenc")) ||
(!strcmp(argv[i], "--noenc"))) { (!strcmp(argv[i], "--noenc"))) {
noenc++; noenc++;
@ -3297,15 +3290,13 @@ main(int argc, char **argv) {
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
else if ((!strcmp(argv[i], "-nowarning")) || else if ((!strcmp(argv[i], "-nowarning")) ||
(!strcmp(argv[i], "--nowarning"))) { (!strcmp(argv[i], "--nowarning"))) {
xmlGetWarningsDefaultValue = 0;
xmlPedanticParserDefault(0);
options |= XML_PARSE_NOWARNING; options |= XML_PARSE_NOWARNING;
options &= ~XML_PARSE_PEDANTIC;
} }
else if ((!strcmp(argv[i], "-pedantic")) || else if ((!strcmp(argv[i], "-pedantic")) ||
(!strcmp(argv[i], "--pedantic"))) { (!strcmp(argv[i], "--pedantic"))) {
xmlGetWarningsDefaultValue = 1;
xmlPedanticParserDefault(1);
options |= XML_PARSE_PEDANTIC; options |= XML_PARSE_PEDANTIC;
options &= XML_PARSE_NOWARNING;
} }
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
else if ((!strcmp(argv[i], "-debugent")) || else if ((!strcmp(argv[i], "-debugent")) ||
@ -3351,9 +3342,7 @@ main(int argc, char **argv) {
} }
else if ((!strcmp(argv[i], "-noblanks")) || else if ((!strcmp(argv[i], "-noblanks")) ||
(!strcmp(argv[i], "--noblanks"))) { (!strcmp(argv[i], "--noblanks"))) {
noblanks++; noblanks = 1;
xmlKeepBlanksDefault(0);
options |= XML_PARSE_NOBLANKS;
} }
else if ((!strcmp(argv[i], "-maxmem")) || else if ((!strcmp(argv[i], "-maxmem")) ||
(!strcmp(argv[i], "--maxmem"))) { (!strcmp(argv[i], "--maxmem"))) {
@ -3361,23 +3350,16 @@ main(int argc, char **argv) {
} }
else if ((!strcmp(argv[i], "-format")) || else if ((!strcmp(argv[i], "-format")) ||
(!strcmp(argv[i], "--format"))) { (!strcmp(argv[i], "--format"))) {
noblanks++;
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
format = 1; format = 1;
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
xmlKeepBlanksDefault(0);
} }
else if ((!strcmp(argv[i], "-pretty")) || else if ((!strcmp(argv[i], "-pretty")) ||
(!strcmp(argv[i], "--pretty"))) { (!strcmp(argv[i], "--pretty"))) {
i++; i++;
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
if (argv[i] != NULL) { if (argv[i] != NULL)
format = atoi(argv[i]); format = atoi(argv[i]);
if (format == 1) {
noblanks++;
xmlKeepBlanksDefault(0);
}
}
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
} }
#ifdef LIBXML_READER_ENABLED #ifdef LIBXML_READER_ENABLED
@ -3416,20 +3398,19 @@ main(int argc, char **argv) {
(!strcmp(argv[i], "--relaxng"))) { (!strcmp(argv[i], "--relaxng"))) {
i++; i++;
relaxng = argv[i]; relaxng = argv[i];
noent++; noent = 1;
options |= XML_PARSE_NOENT;
} else if ((!strcmp(argv[i], "-schema")) || } else if ((!strcmp(argv[i], "-schema")) ||
(!strcmp(argv[i], "--schema"))) { (!strcmp(argv[i], "--schema"))) {
i++; i++;
schema = argv[i]; schema = argv[i];
noent++; noent = 1;
#endif #endif
#ifdef LIBXML_SCHEMATRON_ENABLED #ifdef LIBXML_SCHEMATRON_ENABLED
} else if ((!strcmp(argv[i], "-schematron")) || } else if ((!strcmp(argv[i], "-schematron")) ||
(!strcmp(argv[i], "--schematron"))) { (!strcmp(argv[i], "--schematron"))) {
i++; i++;
schematron = argv[i]; schematron = argv[i];
noent++; noent = 1;
#endif #endif
} else if ((!strcmp(argv[i], "-nonet")) || } else if ((!strcmp(argv[i], "-nonet")) ||
(!strcmp(argv[i], "--nonet"))) { (!strcmp(argv[i], "--nonet"))) {
@ -3492,15 +3473,14 @@ main(int argc, char **argv) {
defaultEntityLoader = xmlGetExternalEntityLoader(); defaultEntityLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xmllintExternalEntityLoader); xmlSetExternalEntityLoader(xmllintExternalEntityLoader);
xmlLineNumbersDefault(1);
if (loaddtd != 0) if (loaddtd != 0)
xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
if (dtdattrs) if (dtdattrs)
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
if (noent != 0) xmlSubstituteEntitiesDefault(1); if (noent != 0)
#ifdef LIBXML_VALID_ENABLED options |= XML_PARSE_NOENT;
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; if ((noblanks != 0) || (format == 1))
#endif /* LIBXML_VALID_ENABLED */ options |= XML_PARSE_NOBLANKS;
if ((htmlout) && (!nowrap)) { if ((htmlout) && (!nowrap)) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n"); "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");