Mercurial > projects > ddmd
diff dmd/Lexer.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | ef02e2e203c2 |
children | e28b18c23469 |
line wrap: on
line diff
--- a/dmd/Lexer.d Sun Aug 29 14:39:08 2010 +0100 +++ b/dmd/Lexer.d Mon Aug 30 03:57:51 2010 +0200 @@ -2614,6 +2614,9 @@ case 8: // past end of exponent digits goto done; + + default: + assert(0, "inreal.dblstate has unexpected value"); } break; } @@ -2772,33 +2775,26 @@ return true; } - /// TODO: reimplement based on strings - static ubyte* combineComments(ubyte* c1, ubyte* c2) + /// TODO: use normal string append when GC works + static string combineComments(const(char)[] c1, const(char)[] c2) { - //printf("Lexer.combineComments('%s', '%s')\n", c1, c2); + //writef("Lexer.combineComments('%s', '%s')\n", c1, c2); - ubyte* c = c2; - - if (c1) + char[] c = cast(char[]) c2; + + if (c1 !is null) { - c = c1; - if (c2) + c = cast(char[]) c1; + if (c2 !is null) { - size_t len1 = strlen(cast(char*)c1); - size_t len2 = strlen(cast(char*)c2); - - c = cast(ubyte*)GC.malloc(len1 + 1 + len2 + 1); - memcpy(c, c1, len1); - if (len1 && c1[len1 - 1] != '\n') - { - c[len1] = '\n'; - len1++; - } - memcpy(c + len1, c2, len2); - c[len1 + len2] = 0; + c = cast(char[]) (GC.malloc(c1.length + 1 + c2.length)[0 .. c1.length + 1 + c2.length]); + size_t len1 = c1.length; + c[0..len1] = c1[]; + c[len1++] = '\n'; + c[len1 .. len1 + c2.length] = c2[]; } } - - return c; + + return cast(string)c; } } \ No newline at end of file