]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc/girimporter: Don't guess length of xml header, iterate forward to <repository>
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 20 Mar 2021 15:19:35 +0000 (16:19 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 4 Apr 2021 13:43:21 +0000 (15:43 +0200)
If e.g. the xml header is missing, it resulted in errors like:

    error: expected start element of `repository'
    error: unsupported GIR version (null) (supported: 1.2)

libvaladoc/importer/girdocumentationimporter.vala

index b7d475043361dcc504612e727884b5e439d27bab..e0ae01d6cab4786d9c37f60f04049db14faa3a01 100644 (file)
@@ -69,10 +69,14 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
                this.reader = new Vala.MarkupReader (source_file);
 
                // xml prolog
-               next ();
-               next ();
+               do {
+                       next ();
+                       if (current_token == Vala.MarkupTokenType.EOF) {
+                               error ("unexpected end of file");
+                               return;
+                       }
+               } while (current_token != Vala.MarkupTokenType.START_ELEMENT && reader.name != "repository");
 
-               next ();
                parse_repository ();
 
                reader = null;