tests: remove uses of `xmlKeepBlanksDefault()`
[lttng-tools.git] / tests / utils / xml-utils / pretty_xml.cpp
index 3f296f0235342ca17b5c2e032984899b7071f93b..7eb4710caf78dcc02c285800a4af02a57b48718a 100644 (file)
  * This allows a more human friendly format for xml testing when problems occur.
  */
 
+#include "common.hpp"
+
 #include <libxml/parser.h>
+#include <unistd.h>
 
-int main(void)
+int main()
 {
        xmlDocPtr doc = NULL;
 
        /* Init libxml. */
        xmlInitParser();
-       xmlKeepBlanksDefault(0);
 
-       /* Parse the XML document from stdin. */
-       doc = xmlParseFile("-");
-       if (!doc) {
-               fprintf(stderr, "ERR parsing: xml input invalid");
-               return -1;
-       }
+       {
+               xml_parser_ctx_uptr parserCtx{ xmlNewParserCtxt() };
+
+               /* Parse the XML document from stdin. */
+               doc = xmlCtxtReadFd(
+                       parserCtx.get(), STDIN_FILENO, nullptr, nullptr, XML_PARSE_NOBLANKS);
+               if (!doc) {
+                       fprintf(stderr, "ERR parsing: xml input invalid");
+                       return -1;
+               }
 
-       xmlDocFormatDump(stdout, doc, 1);
+               xmlDocFormatDump(stdout, doc, 1);
+
+               xmlFreeDoc(doc);
+       }
 
-       xmlFreeDoc(doc);
        /* Shutdown libxml. */
        xmlCleanupParser();
 
This page took 0.023475 seconds and 4 git commands to generate.