scanner: Improve XML parse error reporting

Print the parse error and exit with a failure if expat can't parse the
XML.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Jonas Ådahl 2014-09-22 22:11:18 +02:00 committed by Pekka Paalanen
parent f3e7eedf1c
commit 2028227acc

View file

@ -1296,8 +1296,14 @@ int main(int argc, char *argv[])
fprintf(stderr, "fread: %m\n");
exit(EXIT_FAILURE);
}
XML_ParseBuffer(ctx.parser, len, len == 0);
if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {
fprintf(stderr,
"Error parsing XML at line %ld col %ld: %s\n",
XML_GetCurrentLineNumber(ctx.parser),
XML_GetCurrentColumnNumber(ctx.parser),
XML_ErrorString(XML_GetErrorCode(ctx.parser)));
exit(EXIT_FAILURE);
}
} while (len > 0);
XML_ParserFree(ctx.parser);