All pastes #542761 Raw Edit

Something

public text v1 · immutable
·published 2007-06-05 22:28 UTC
rendered paste body
Index: error.h
===================================================================
RCS file: /cvsroot/alcc/alcc/error.h,v
retrieving revision 1.9
diff -u -r1.9 error.h
--- error.h     15 Jan 2007 03:19:24 -0000      1.9
+++ error.h     5 Jun 2007 22:26:02 -0000
@@ -25,7 +25,7 @@
        char            message[256];
        int             errorCode;
 
-       LegacyError(char *msg, int err)
+       LegacyError(const char *msg, int err)
        {
                strncpy(message, msg, 255);
                errorCode = err;
Index: log.cpp
===================================================================
RCS file: /cvsroot/alcc/alcc/log.cpp,v
retrieving revision 1.5
diff -u -r1.5 log.cpp
--- log.cpp     15 Jan 2007 03:19:24 -0000      1.5
+++ log.cpp     5 Jun 2007 22:26:10 -0000
@@ -71,35 +71,26 @@
 {
        time_t          t;
        char            formattedTime[26];          // See ctime(3)
-       char           *level;
+        static struct {
+                Log::LogLevel   num;
+                const char     *name;
+        } levels[] = {
+                { NOTICE,       "NOTICE" },
+                { WARNING,      "WARNING" },
+                { ERROR,        "ERROR" },
+                { CRITICAL,     "CRITICAL" },
+                { NONE,         "***" },
+        };
 
-       if (lvl >= logLevel && logLevel != NONE &&
-               output != NULL)
+       if (lvl >= logLevel && logLevel != NONE && output != NULL)
        {
                (void)time(&t);
                (void)ctime_r(&t, formattedTime);
                formattedTime[24] = '\0';               // Get rid of trailing \                                                                                          n
 
-               switch (lvl)
-               {
-               case NOTICE:
-                       level = "NOTICE";
-                       break;
-               case WARNING:
-                       level = "WARNING";
-                       break;
-               case ERROR:
-                       level = "ERROR";
-                       break;
-               case CRITICAL:
-                       level = "CRITICAL";
-                       break;
-               default:
-                       level = "***";
-               }
-
                pthread_mutex_lock(&mutex);
-               fprintf(output, "[%s] %s: %s\n", formattedTime, level, msg);
+               fprintf(output, "[%s] %s: %s\n", formattedTime,
+                               levels[lvl].name, msg);
                pthread_mutex_unlock(&mutex);
        }
 }
Index: log.h
===================================================================
RCS file: /cvsroot/alcc/alcc/log.h,v
retrieving revision 1.4
diff -u -r1.4 log.h
--- log.h       15 Jan 2007 03:19:24 -0000      1.4
+++ log.h       5 Jun 2007 22:26:10 -0000
@@ -19,7 +19,7 @@
 {
 public:
        enum LogLevel {
-               NOTICE,
+               NOTICE = 0,
                WARNING,
                ERROR,
                CRITICAL,