diff dmd/mars.c @ 1124:e7f0c2b48047

Fix a bug where ::warning() was called with a va_list argument instead of an actual vararg list. Also cleaned up the format for warnings. (Previously some would start with "warning - warning - Warning:" which was a bit redundant)
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 18 Mar 2009 15:03:17 +0100
parents b30fe7e1dbb9
children eeb8b95ea92e
line wrap: on
line diff
--- a/dmd/mars.c	Wed Mar 18 00:25:36 2009 +0100
+++ b/dmd/mars.c	Wed Mar 18 15:03:17 2009 +0100
@@ -109,13 +109,10 @@
 {
     if (global.params.warnings && !global.gag)
     {
-    fprintf(stdmsg, "warning - ");
-    va_list ap;
-    va_start(ap, format);
-    char* p = loc.toChars();
-    fprintf(stdmsg, "Warning: %s:", p?p:"");
-    vfprintf(stdmsg, format, ap);
-    va_end( ap );
+        va_list ap;
+        va_start(ap, format);
+        vwarning(loc, format, ap);
+        va_end( ap );
     }
 }
 
@@ -137,6 +134,23 @@
     global.errors++;
 }
 
+void vwarning(Loc loc, const char *format, va_list ap)
+{
+    if (global.params.warnings && !global.gag)
+    {
+        char *p = loc.toChars();
+
+        if (*p)
+            fprintf(stdmsg, "%s: ", p);
+        mem.free(p);
+
+        fprintf(stdmsg, "Warning: ");
+        vfprintf(stdmsg, format, ap);
+        fprintf(stdmsg, "\n");
+        fflush(stdmsg);
+    }
+}
+
 /***************************************
  * Call this after printing out fatal error messages to clean up and exit
  * the compiler.