[xml/sgml-pkgs] Bug#1035554: libxml2-utils: xmllint ignores --output option and writes to stdout
Tj
debian at iam.tj
Fri May 5 15:23:21 BST 2023
I've done some follow-up debugging (on upstream git) to be sure the
problem seems to exist upstream - unless I'm severely misunderstanding
what --output is supposed to do. Anyhow; the trace shows it reaches
doXPathDump(). Note that 'buf' is hard-coded to use stdout. The call to
xmlOutputBufferClose(buf) causes the output to be sent. In gdb I confirm
'output' is set immediately after that:
$ gdb -directory /srv/NAS/Sunny/SourceCode/libxml2/libxml2 -args
/srv/NAS/Sunny/SourceCode/libxml2/libxml2/.libs/xmllint --output
test.txt --html --xpath '//div[contains(@class,
'\''test'\'')]/div/ul/li/a/@href' xmllint-test.html
2038 break;
(gdb) p output
$1 = 0x7fffffffe1d5 "test.txt"
xmllint.c:
static void doXPathDump(xmlXPathObjectPtr cur) {
switch(cur->type) {
case XPATH_NODESET: {
int i;
xmlNodePtr node;
#ifdef LIBXML_OUTPUT_ENABLED
xmlOutputBufferPtr buf;
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr
<= 0)) {
if (!quiet) {
fprintf(stderr, "XPath set is empty\n");
}
break;
}
buf = xmlOutputBufferCreateFile(stdout, NULL);
if (buf == NULL) {
fprintf(stderr, "Out of memory for XPath\n");
progresult = XMLLINT_ERR_MEM;
return;
}
for (i = 0;i < cur->nodesetval->nodeNr;i++) {
node = cur->nodesetval->nodeTab[i];
xmlNodeDumpOutput(buf, NULL, node, 0, 0, NULL);
xmlOutputBufferWrite(buf, 1, "\n");
}
xmlOutputBufferClose(buf);
More information about the debian-xml-sgml-pkgs
mailing list