Difference between revisions of "GccStyleErrorMessages"

From CSWiki
Jump to: navigation, search
m (Updated for chuck 1.0.0.7)
Line 3: Line 3:
 
mode.
 
mode.
 
<pre>
 
<pre>
*** chuck_errmsg.cpp 2006/04/27 20:45:51 1.1
+
--- chuck_errmsg.cpp   2006-09-19 14:54:42.000000000 -0600
--- chuck_errmsg.cpp 2006/04/27 20:47:15
+
+++ chuck_errmsg.cpp    2006-10-14 22:23:33.000000000 -0600
***************
+
@@ -40,6 +40,8 @@
*** 128,133 ****
+
#include "util_thread.h"
--- 128,141 ----
+
 
          num--;
+
 
      }
+
+#define GCC_STYLE_ERROR_MESSAGES
 
+
+
+ #define GCC_STYLE_ERROR_MESSAGES
+
// global
+ #ifdef GCC_STYLE_ERROR_MESSAGES
+
int EM_tokPos = 0;
 +
int EM_lineNum = 1;
 +
@@ -128,6 +130,13 @@
 +
        num--;
 +
    }
 +
 
 +
+#ifdef GCC_STYLE_ERROR_MESSAGES
 
+  fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", num);
 
+  fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", num);
 
+  va_start(ap, message);
 
+  va_start(ap, message);
Line 18: Line 24:
 
+  va_end(ap);
 
+  va_end(ap);
 
+  fprintf(stderr, "\n");
 
+  fprintf(stderr, "\n");
+ #else
+
+#else
      fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
+
    fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
      sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
+
    sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
      if(lines)
+
    if(lines)
***************
+
@@ -145,6 +154,7 @@
*** 144,149 ****
+
    fprintf(stderr, "\n");
--- 152,158 ----
+
    fflush( stderr );
      va_end(ap);
+
    strcat( g_lasterror, g_buffer );
      fprintf(stderr, "\n");
+
+#endif
      strcat( g_lasterror, g_buffer );
+
}
+ #endif
+
 
  }
+
 
 
+
@@ -153,6 +163,14 @@
 
+
{
***************
+
    va_list ap;
*** 152,157 ****
+
 
--- 161,173 ----
+
+
  {
+
+#ifdef GCC_STYLE_ERROR_MESSAGES
      va_list ap;
+
+    fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
 
+
+    va_start(ap, message);
+ #ifdef GCC_STYLE_ERROR_MESSAGES
+
+    vfprintf(stderr, message, ap);
 +
+    va_end(ap);
 +
+    fprintf(stderr, "\n");
 +
+#else
 +
    fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
 +
    sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
 +
    if(line)
 +
@@ -171,6 +189,7 @@
 +
 
 +
    strcat( g_lasterror, g_buffer );
 +
    fprintf( stderr, "\n" );
 +
+#endif
 +
    fflush( stderr );
 +
}
 +
 
 +
@@ -180,6 +199,13 @@
 +
{
 +
    va_list ap;
 +
 
 +
+#ifdef GCC_STYLE_ERROR_MESSAGES
 
+  fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
 
+  fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
 
+  va_start(ap, message);
 
+  va_start(ap, message);
Line 44: Line 69:
 
+  va_end(ap);
 
+  va_end(ap);
 
+  fprintf(stderr, "\n");
 
+  fprintf(stderr, "\n");
+ #else
+
+#else
      fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
+
    fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
      sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
+
    sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
      if(line)
+
    if(line)
***************
+
@@ -190,7 +216,8 @@
*** 170,175 ****
+
    }
--- 186,192 ----
+
    fprintf( stderr, " " );
 
+
    strcat( g_lasterror, " " );
      strcat( g_lasterror, g_buffer );
+
-
      fprintf( stderr, "\n" );
+
+#endif
+ #endif   
+
+
  }
+
    va_start( ap, message );
 
+
    vfprintf( stderr, message, ap );
 
+
    vsprintf( g_buffer, message, ap );
***************
 
*** 178,183 ****
 
--- 195,207 ----
 
  {
 
      va_list ap;
 
 
 
+ #ifdef GCC_STYLE_ERROR_MESSAGES
 
+   fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
 
va_start(ap, message);
 
vfprintf(stderr, message, ap);
 
+  va_end(ap);
 
+  fprintf(stderr, "\n");
 
+ #else
 
      fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
 
      sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
 
      if(line)
 
***************
 
*** 196,201 ****
 
--- 220,226 ----
 
 
 
      strcat( g_lasterror, g_buffer );
 
      fprintf( stdout, "\n" );
 
+ #endif
 
  }
 
 
</pre>
 
</pre>

Revision as of 23:45, 14 October 2006

Causes chuck to generate gcc style/format error messages to make the edit/compile/listen cycle much easier using emacs compilation mode.

--- chuck_errmsg.cpp    2006-09-19 14:54:42.000000000 -0600
+++ chuck_errmsg.cpp    2006-10-14 22:23:33.000000000 -0600
@@ -40,6 +40,8 @@
 #include "util_thread.h"


+#define GCC_STYLE_ERROR_MESSAGES
+
 // global
 int EM_tokPos = 0;
 int EM_lineNum = 1;
@@ -128,6 +130,13 @@
         num--;
     }

+#ifdef GCC_STYLE_ERROR_MESSAGES
+   fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", num);
+   va_start(ap, message);
+   vfprintf(stderr, message, ap);
+   va_end(ap);
+   fprintf(stderr, "\n");
+#else
     fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     if(lines)
@@ -145,6 +154,7 @@
     fprintf(stderr, "\n");
     fflush( stderr );
     strcat( g_lasterror, g_buffer );
+#endif
 }


@@ -153,6 +163,14 @@
 {
     va_list ap;

+
+#ifdef GCC_STYLE_ERROR_MESSAGES
+    fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
+    va_start(ap, message);
+    vfprintf(stderr, message, ap);
+    va_end(ap);
+    fprintf(stderr, "\n");
+#else
     fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     if(line)
@@ -171,6 +189,7 @@

     strcat( g_lasterror, g_buffer );
     fprintf( stderr, "\n" );
+#endif
     fflush( stderr );
 }

@@ -180,6 +199,13 @@
 {
     va_list ap;

+#ifdef GCC_STYLE_ERROR_MESSAGES
+   fprintf(stderr, "%s:%d: error: ", *fileName ? mini(fileName) : "chuck", line);
+   va_start(ap, message);
+   vfprintf(stderr, message, ap);
+   va_end(ap);
+   fprintf(stderr, "\n");
+#else
     fprintf( stderr, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     sprintf( g_lasterror, "[%s]:", *fileName ? mini(fileName) : "chuck" );
     if(line)
@@ -190,7 +216,8 @@
     }
     fprintf( stderr, " " );
     strcat( g_lasterror, " " );
-
+#endif
+
     va_start( ap, message );
     vfprintf( stderr, message, ap );
     vsprintf( g_buffer, message, ap );