changeset 397:c99f8aeb7b4a

Empty source files are handled correctly now.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 21 Sep 2007 13:46:17 +0200
parents 0a4619735ce9
children f7bb892d64c2
files trunk/src/dil/File.d trunk/src/dil/Lexer.d
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/File.d	Fri Sep 21 12:47:47 2007 +0200
+++ b/trunk/src/dil/File.d	Fri Sep 21 13:46:17 2007 +0200
@@ -15,6 +15,9 @@
 
 char[] data2Utf8(ubyte[] data)
 {
+  if (data.length == 0)
+    return null;
+
   char[] text;
   BOM bom = tellBOM(data);
 
@@ -69,7 +72,6 @@
   default:
     assert(0);
   }
-  assert(text !is null);
   return text;
 }
 
--- a/trunk/src/dil/Lexer.d	Fri Sep 21 12:47:47 2007 +0200
+++ b/trunk/src/dil/Lexer.d	Fri Sep 21 13:46:17 2007 +0200
@@ -54,7 +54,7 @@
     this.fileName = fileName;
 
     this.text = text;
-    if (text[$-1] != 0)
+    if (text.length == 0 || text[$-1] != 0)
     {
       this.text.length = this.text.length + 1;
       this.text[$-1] = 0;
@@ -169,8 +169,8 @@
   }
   out
   {
-    assert(text.ptr <= t.start && t.start < end);
-    assert(text.ptr < t.end && t.end <= end, Token.toString(t.type));
+    assert(text.ptr <= t.start && t.start < end, Token.toString(t.type));
+    assert(text.ptr <= t.end && t.end <= end, Token.toString(t.type));
   }
   body
   {