[vala] genie: Add empty file check to read_token ()



commit a4ab6177c9a659b4b76f4fd22aedbb4b22920c55
Author: Alistair Thomas <astavale yahoo co uk>
Date:   Tue Oct 11 18:28:35 2016 +0100

    genie: Add empty file check to read_token ()
    
    Vala.SourceFile uses GLib.MappedFile.get_contents () to read a source
    file. This can return null if the file is empty.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=633083

 vala/valageniescanner.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index e2c5466..95a8984 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -777,7 +777,11 @@ public class Vala.Genie.Scanner {
 
 
        public TokenType read_token (out SourceLocation token_begin, out SourceLocation token_end) {
-               
+               if (current == null) {
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column);
+                       return TokenType.EOF;
+               }
 
                if (in_template ()) {
                        return read_template_token (out token_begin, out token_end);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]