lib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent()

Now that we have virXMLParseWithIndent() and
virXMLParseStringCtxtWithIndent(), we can use them directly and
drop calls to xmlKeepBlanksDefault().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2023-11-20 16:20:51 +01:00
parent 69958ba310
commit 1fdca3083b
6 changed files with 15 additions and 31 deletions

View File

@ -276,13 +276,11 @@ virDomainBackupDefParseString(const char *xmlStr,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
"domainbackup", &ctxt, "domainbackup.rng", validate);
xmlKeepBlanksDefault(keepBlanksDefault);
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_backup)"),
"domainbackup", &ctxt, "domainbackup.rng",
validate);
if (!xml)
return NULL;

View File

@ -192,12 +192,10 @@ virDomainCheckpointDefParseString(const char *xmlStr,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
"domaincheckpoint", &ctxt, "domaincheckpoint.rng", true);
xmlKeepBlanksDefault(keepBlanksDefault);
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_checkpoint)"),
"domaincheckpoint", &ctxt,
"domaincheckpoint.rng", true);
if (!xml)
return NULL;

View File

@ -19503,14 +19503,11 @@ virDomainDefParse(const char *xmlStr,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
xml = virXMLParse(filename, xmlStr, _("(domain_definition)"),
xml = virXMLParseWithIndent(filename, xmlStr, _("(domain_definition)"),
"domain", &ctxt, "domain.rng", validate);
xmlKeepBlanksDefault(keepBlanksDefault);
if (!xml)
return NULL;
@ -19566,10 +19563,8 @@ virDomainObjParseFile(const char *filename,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
xmlKeepBlanksDefault(keepBlanksDefault);
xml = virXMLParseWithIndent(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
if (!xml)
return NULL;

View File

@ -1962,11 +1962,9 @@ virNetworkDefParse(const char *xmlStr,
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
xml = virXMLParseWithIndent(filename, xmlStr, _("(network_definition)"),
"network", &ctxt, "network.rng", validate);
xmlKeepBlanksDefault(keepBlanksDefault);
if (!xml)
return NULL;

View File

@ -426,13 +426,11 @@ virDomainSnapshotDefParseString(const char *xmlStr,
{
g_autoptr(xmlXPathContext) ctxt = NULL;
g_autoptr(xmlDoc) xml = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
"domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
xmlKeepBlanksDefault(keepBlanksDefault);
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_snapshot)"),
"domainsnapshot", &ctxt, "domainsnapshot.rng",
validate);
if (!xml)
return NULL;

View File

@ -474,16 +474,13 @@ virshDumpXML(vshControl *ctl,
g_autofree xmlNodePtr *nodes = NULL;
int nnodes = 0;
size_t i;
int oldblanks;
if (xpath == NULL) {
vshPrint(ctl, "%s", xml);
return true;
}
oldblanks = xmlKeepBlanksDefault(0);
doc = virXMLParseStringCtxt(xml, url, &ctxt);
xmlKeepBlanksDefault(oldblanks);
doc = virXMLParseStringCtxtWithIndent(xml, url, &ctxt);
if (!doc)
return false;