summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2014-09-22 20:11:18 (GMT)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2014-09-23 08:40:46 (GMT)
commit2028227acc4fe08836706278698acf1c09851fa1 (patch)
treec3cb2d9d3b16c6dbbee0307beb991c52f9ee861e
parentf3e7eedf1c0824639a816519ccfbdacb946cc63f (diff)
downloadwayland-2028227acc4fe08836706278698acf1c09851fa1.tar.gz
wayland-2028227acc4fe08836706278698acf1c09851fa1.tar.xz
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>
-rw-r--r--src/scanner.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/scanner.c b/src/scanner.c
index 72fd3e8..6be1d7a 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -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);