mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-04-02 07:51:19 +00:00
added --nocolor and fixed bug
This commit is contained in:
parent
69408fd58d
commit
dcacaca2e8
2 changed files with 12 additions and 16 deletions
21
con.c
21
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");
|
||||
|
|
7
main.c
7
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;
|
||||
|
|
Loading…
Reference in a new issue