From: Dale Weiler Date: Thu, 15 Nov 2012 00:50:05 +0000 (+0000) Subject: added --nocolor and fixed bug X-Git-Tag: 0.1~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dcacaca2e84dfa914f0f1d16eea99fdaba5b372e;p=xonotic%2Fgmqcc.git added --nocolor and fixed bug --- diff --git a/con.c b/con.c index 7ab5fcb..3a15cc6 100644 --- 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 c634fd0..1d151c5 100644 --- 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;