From f6b4d5eabb3530b3beee5145e631c06003763a3a Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Fri, 28 Jun 2019 13:19:34 +0100 Subject: [PATCH] version: add colour for devel features --- version.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/version.c b/version.c index e105f4048..4a8269698 100644 --- a/version.c +++ b/version.c @@ -106,7 +106,7 @@ static const char *Notice = struct CompileOptions { const char *name; - bool enabled; + int enabled; // 0 Disabled, 1 Enabled, 2 Devel only }; /* These are sorted by the display string */ @@ -317,20 +317,29 @@ static void print_compile_options(struct CompileOptions *co, FILE *fp) fprintf(fp, "\n "); } used += len; - if (co[i].enabled) + const char *fmt = "?%s "; + switch (co[i].enabled) { - if (tty) - fprintf(fp, "\033[1;32m+%s\033[0m ", co[i].name); // Escape - else - fprintf(fp, "+%s ", co[i].name); - } - else - { - if (tty) - fprintf(fp, "\033[1;31m-%s\033[0m ", co[i].name); // Escape - else - fprintf(fp, "-%s ", co[i].name); + case 0: // Disabled + if (tty) + fmt = "\033[1;31m-%s\033[0m "; // Escape, red + else + fmt = "-%s "; + break; + case 1: // Enabled + if (tty) + fmt = "\033[1;32m+%s\033[0m "; // Escape, green + else + fmt = "+%s "; + break; + case 2: // Devel only + if (tty) + fmt = "\033[1;36m!%s\033[0m "; // Escape, cyan + else + fmt = "!%s "; + break; } + fprintf(fp, fmt, co[i].name); } fprintf(fp, "\n"); } -- 2.40.0