]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Fix wrong usage of nullable structs as parameters
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 13 Jul 2011 18:17:56 +0000 (20:17 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 13 Jul 2011 18:17:56 +0000 (20:17 +0200)
vala/valagirparser.vala

index 9b014e14ef0568d5f66d5461ef1e01a05ed3b88c..4980be82fdfa88e8ea3598cbe574c147cfddfccc 100644 (file)
@@ -246,10 +246,11 @@ public class Vala.GirParser : CodeVisitor {
                }
 
                SourceReference get_src (SourceLocation begin, SourceLocation? end = null) {
-                       if (end == null) {
-                               end = this.end;
+                       var e = this.end;
+                       if (end != null) {
+                               e = end;
                        }
-                       return new SourceReference (scanner.source_file, begin.line, begin.column, end.line, end.column);
+                       return new SourceReference (scanner.source_file, begin.line, begin.column, e.line, e.column);
                }
 
                public Metadata parse_metadata (SourceFile metadata_file) {
@@ -278,13 +279,15 @@ public class Vala.GirParser : CodeVisitor {
                }
 
                string get_string (SourceLocation? begin = null, SourceLocation? end = null) {
-                       if (begin == null) {
-                               begin = this.begin;
+                       var b = this.begin;
+                       var e = this.end;
+                       if (begin != null) {
+                               b = begin;
                        }
-                       if (end == null) {
-                               end = this.end;
+                       if (end != null) {
+                               e = end;
                        }
-                       return ((string) begin.pos).substring (0, (int) (end.pos - begin.pos));
+                       return ((string) b.pos).substring (0, (int) (e.pos - b.pos));
                }
 
                string? parse_identifier (bool is_glob) {