]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
added --nocolor and fixed bug
authorDale Weiler <killfieldengine@gmail.com>
Thu, 15 Nov 2012 00:50:05 +0000 (00:50 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Thu, 15 Nov 2012 00:50:05 +0000 (00:50 +0000)
con.c
main.c

diff --git a/con.c b/con.c
index 7ab5fcbe4caa398dd9a81ab9d5ed389e32f6032e..3a15cc6982cb406042361bb9464de6426d07c949 100644 (file)
--- a/con.c
+++ b/con.c
@@ -326,21 +326,14 @@ void con_vprintmsg(int level, const char *name, size_t line, const char *msgtype
         CON_RED
     };
     
-    int   err   = !!(level == LVL_ERROR);
-    int   color = (err) ? console.color_err : console.color_out;
+    int  err                        = !!(level == LVL_ERROR);
+    int  color                      = (err) ? console.color_err : console.color_out;
+    int (*print)(const char *, ...) = (err) ? &con_err          : &con_out;
     
-    /* this might confuse you :P */
-    ((err) ? &con_err : &con_out)(
-        (color) ? 
-            "\033[0;%dm%s:%d: \033[0;%dm%s: \033[0m" : 
-            "%s:%d: %s: ",
-            
-        CON_CYAN,
-        name,
-        (int)line,
-        sel[level],
-        msgtype
-    );
+    if (color)
+        print("\033[0;%dm%s:%d: \033[0;%dm%s: \033[0m", CON_CYAN, name, (int)line, sel[level], msgtype);
+    else
+        print("%s:%d: %s: ", name, (int)line, msgtype);
         
     con_verr(msg, ap);
     fprintf (stderr, "\n");
diff --git a/main.c b/main.c
index c634fd01a0d56f27df43e374392bdce0ee25efaa..1d151c5782152049fc2e1664977c4334bc64e93c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -227,6 +227,10 @@ static bool options_parse(int argc, char **argv) {
                 opts_memchk = true;
                 continue;
             }
+            if (!strcmp(argv[0]+1, "nocolor")) {
+                con_color(0);
+                continue;
+            }
 
             switch (argv[0][1]) {
                 /* -h, show usage but exit with 0 */
@@ -371,8 +375,7 @@ static bool options_parse(int argc, char **argv) {
 }
 
 /* returns the line number, or -1 on error */
-static bool progs_nextline(char **out, size_t *alen,FILE *src)
-{
+static bool progs_nextline(char **out, size_t *alen,FILE *src) {
     int    len;
     char  *line;
     char  *start;