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

Signed-off-by: Jonas Ådahl <[email protected]>
---
 src/scanner.c | 10 ++++++++--
 1 file 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);
-- 
1.8.5.1

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to