]> git.llucax.com Git - software/druntime.git/commitdiff
fix support for file/line
authorwalter <walter@4a9d5153-6564-4b3f-b5e1-7e8e9dac548f>
Mon, 13 Oct 2008 21:39:33 +0000 (21:39 +0000)
committerwalter <walter@4a9d5153-6564-4b3f-b5e1-7e8e9dac548f>
Mon, 13 Oct 2008 21:39:33 +0000 (21:39 +0000)
git-svn-id: http://svn.dsource.org/projects/druntime/trunk@28 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f

src/compiler/dmd/dmain2.d
src/compiler/dmd/object_.d

index ec42e66fe26e10cb67e0486c1ea324544fc91831..8c2205249aac6fdadb2d45af5be590ca9f9a225c 100644 (file)
@@ -241,7 +241,7 @@ extern (C) int main(int argc, char **argv)
                     if (e.file)
                     {
                        // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg);
-                       console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.toString)("\n");
+                       console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n");
                     }
                     else
                     {
index 4e78220bdbdc077056859dad67d6af11438a8c88..8c5115f08ea0bc207bcb65a94fa3fa2214cdcb3f 100644 (file)
@@ -1064,6 +1064,7 @@ class Exception : Object
     size_t      line;
     TraceInfo   info;
     Exception   next;
+    char[]      buffer;
 
     this( string msg, Exception next = null )
     {
@@ -1082,7 +1083,35 @@ class Exception : Object
 
     override string toString()
     {
-        return msg;
+        if (file.length == 0 && line == 0)
+           return msg;
+       if (buffer.length == 0)
+        {
+           // Write into buffer[] the following: "file(line): msg"
+           buffer.length = 4 + file.length + line.sizeof * 3 + msg.length;
+           auto i = file.length;
+           buffer[0 .. i] = file[];
+           buffer[i] = '(';
+           i++;
+
+           auto n = line;
+           auto j = i;
+           do
+           {
+               buffer[i] = cast(char)((n % 10) + '0');
+               n /= 10;
+               i++;
+           } while (n);
+           buffer[j .. i].reverse;
+           buffer[i..i+3] = "): "[];
+           i += 3;
+
+           buffer[i .. i + msg.length] = msg[];
+           i += msg.length;
+
+           buffer = buffer[0 .. i];
+       }
+        return cast(invariant)buffer;
     }
 }