diff dmd/lexer.c @ 846:bc982f1ad106

Merged DMD 1.037 frontend
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 13 Dec 2008 13:15:31 +0100
parents 661384d6a936
children aa953cc960b6
line wrap: on
line diff
--- a/dmd/lexer.c	Sat Dec 13 06:48:00 2008 +0100
+++ b/dmd/lexer.c	Sat Dec 13 13:15:31 2008 +0100
@@ -2656,10 +2656,13 @@
 
 void Lexer::getDocComment(Token *t, unsigned lineComment)
 {
-    OutBuffer buf;
+    /* ct tells us which kind of comment it is: '/', '*', or '+'
+     */
     unsigned char ct = t->ptr[2];
+
+    /* Start of comment text skips over / * *, / + +, or / / /
+     */
     unsigned char *q = t->ptr + 3;	// start of comment text
-    int linestart = 0;
 
     unsigned char *qend = p;
     if (ct == '*' || ct == '+')
@@ -2684,6 +2687,12 @@
 	}
     }
 
+    /* Comment is now [q .. qend].
+     * Canonicalize it into buf[].
+     */
+    OutBuffer buf;
+    int linestart = 0;
+
     for (; q < qend; q++)
     {
 	unsigned char c = *q;
@@ -2760,11 +2769,14 @@
 }
 
 /********************************************
- * Combine two document comments into one.
+ * Combine two document comments into one,
+ * separated by a newline.
  */
 
 unsigned char *Lexer::combineComments(unsigned char *c1, unsigned char *c2)
 {
+    //printf("Lexer::combineComments('%s', '%s')\n", c1, c2);
+
     unsigned char *c = c2;
 
     if (c1)
@@ -2775,9 +2787,12 @@
 
 	    c = (unsigned char *)mem.malloc(len1 + 1 + len2 + 1);
 	    memcpy(c, c1, len1);
-	    c[len1] = '\n';
-	    memcpy(c + len1 + 1, c2, len2);
-	    c[len1 + 1 + len2] = 0;
+	    if (len1 && c1[len1 - 1] != '\n')
+	    {	c[len1] = '\n';
+		len1++;
+	    }
+	    memcpy(c + len1, c2, len2);
+	    c[len1 + len2] = 0;
 	}
     }
     return c;
@@ -2951,6 +2966,7 @@
     {	"__FILE__",	TOKfile		},
     {	"__LINE__",	TOKline		},
     {	"shared",	TOKshared	},
+    {	"immutable",	TOKimmutable	},
 #endif
 };