From f9e27c558b9b8f0f8e0bc2e8a182e8e05c475725 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 8 Jul 2017 17:17:16 +0100 Subject: [PATCH] compile-time output: use two lists When asking NeoMutt for a list of compile-time features, the current implementation assumes a mixture of options which can be enabled through ./configure, and some which default to on, without compile-time exclusion. Instead, separate this output in NeoMutt. --- version.c | 103 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/version.c b/version.c index aa5831207..1b5cbbe80 100644 --- a/version.c +++ b/version.c @@ -95,8 +95,43 @@ struct CompileOptions }; /* These are sorted by the display string */ -static struct CompileOptions comp_opts[] = { + +static struct CompileOptions comp_opts_default[] = { { "attach_headers_color", 1 }, + { "compose_to_sender", 1 }, + { "compress", 1 }, + { "cond_date", 1 }, + { "encrypt_to_self", 1 }, + { "forgotten_attachments", 1 }, + { "forwref", 1 }, + { "ifdef", 1 }, + { "imap", 1 }, + { "index_color", 1 }, + { "initials", 1 }, + { "keywords", 1 }, + { "limit_current_thread", 1 }, + { "lmdb", 1 }, + { "multiple_fcc", 1 }, + { "nested_if", 1 }, + { "new_mail", 1 }, + { "nntp", 1 }, + { "pop", 1 }, + { "progress", 1 }, + { "quasi_delete", 1 }, + { "regcomp", 1 }, + { "reply_with_xorig", 1 }, + { "sensible_browser", 1 }, + { "sidebar", 1 }, + { "skip_quoted", 1 }, + { "smtp", 1 }, + { "status_color", 1 }, + { "timeout", 1 }, + { "tls_sni", 1 }, + { "trash", 1 }, + { NULL, 0 }, +}; + +static struct CompileOptions comp_opts[] = { #ifdef HAVE_BKGDSET { "bkgdset", 1 }, #else @@ -107,9 +142,6 @@ static struct CompileOptions comp_opts[] = { #else { "color", 0 }, #endif - { "compose_to_sender", 1 }, - { "compress", 1 }, - { "cond_date", 1 }, #ifdef HAVE_CURS_SET { "curs_set", 1 }, #else @@ -120,7 +152,6 @@ static struct CompileOptions comp_opts[] = { #else { "debug", 0 }, #endif - { "encrypt_to_self", 1 }, #ifdef USE_FCNTL { "fcntl", 1 }, #else @@ -136,8 +167,6 @@ static struct CompileOptions comp_opts[] = { #else { "fmemopen", 0 }, #endif - { "forgotten_attachments", 1 }, - { "forwref", 1 }, #ifdef HAVE_FUTIMENS { "futimens", 1 }, #else @@ -178,18 +207,11 @@ static struct CompileOptions comp_opts[] = { #else { "iconv_nontrans", 0 }, #endif - { "ifdef", 1 }, - { "imap", 1 }, - { "index_color", 1 }, - { "initials", 1 }, - { "keywords", 1 }, #ifdef HAVE_LIBIDN { "idn", 1 }, #else { "idn", 0 }, #endif - { "limit_current_thread", 1 }, - { "lmdb", 1 }, #ifdef LOCALES_HACK { "locales_hack", 1 }, #else @@ -210,15 +232,11 @@ static struct CompileOptions comp_opts[] = { #else { "mixmaster", 0 }, #endif - { "multiple_fcc", 1 }, - { "nested_if", 1 }, - { "new_mail", 1 }, #ifdef ENABLE_NLS { "nls", 1 }, #else { "nls", 0 }, #endif - { "nntp", 1 }, #ifdef USE_NOTMUCH { "notmuch", 1 }, #else @@ -234,11 +252,6 @@ static struct CompileOptions comp_opts[] = { #else { "pgp", 0 }, #endif - { "pop", 1 }, - { "progress", 1 }, - { "quasi_delete", 1 }, - { "regcomp", 1 }, - { "reply_with_xorig", 1 }, #ifdef HAVE_RESIZETERM { "resizeterm", 1 }, #else @@ -249,27 +262,19 @@ static struct CompileOptions comp_opts[] = { #else { "sasl", 0 }, #endif - { "sensible_browser", 1 }, - { "sidebar", 1 }, - { "skip_quoted", 1 }, #ifdef CRYPT_BACKEND_CLASSIC_SMIME { "smime", 1 }, #else { "smime", 0 }, #endif - { "smtp", 1 }, #ifdef HAVE_START_COLOR { "start_color", 1 }, #else { "start_color", 0 }, #endif - { "status_color", 1 }, #ifdef SUN_ATTACHMENT { "sun_attachment", 1 }, #endif - { "timeout", 1 }, - { "tls_sni", 1 }, - { "trash", 1 }, #ifdef HAVE_TYPEAHEAD { "typeahead", 1 }, #else @@ -284,43 +289,45 @@ static struct CompileOptions comp_opts[] = { }; /** - * print_compile_options - Print a list of enabled/disabled features + * print_compile_options - Print a list of enabled/disabled features. + * + * Two lists are generated and passed to this function: * - * The configure script lets uses enable/disable features. - * This shows the Mutt user which features are/aren't available. + * One list which just uses the configure state of each feature. + * One list which just uses feature which are set to on directly in NeoMutt. * * The output is of the form: "+enabled_feature -disabled_feature" and is * wrapped to SCREEN_WIDTH characters. */ -static void print_compile_options(void) +static void print_compile_options(struct CompileOptions *co) { int len; int used = 2; bool tty = stdout ? isatty(fileno(stdout)) : false; printf(" "); - for (int i = 0; comp_opts[i].name; i++) + for (int i = 0; co[i].name; i++) { - len = strlen(comp_opts[i].name) + 2; /* +/- and a space */ + len = strlen(co[i].name) + 2; /* +/- and a space */ if ((used + len) > SCREEN_WIDTH) { used = 2; printf("\n "); } used += len; - if (comp_opts[i].enabled) + if (co[i].enabled) { if (tty) - printf("\033[1;32m+%s\033[0m ", comp_opts[i].name); + printf("\033[1;32m+%s\033[0m ", co[i].name); else - printf("+%s ", comp_opts[i].name); + printf("+%s ", co[i].name); } else { if (tty) - printf("\033[1;31m-%s\033[0m ", comp_opts[i].name); + printf("\033[1;31m-%s\033[0m ", co[i].name); else - printf("-%s ", comp_opts[i].name); + printf("-%s ", co[i].name); } } puts(""); @@ -403,8 +410,11 @@ void print_version(void) rstrip_in_place((char *) cc_cflags); printf("\nCompilation CFLAGS: %s\n", (char *) cc_cflags); + puts(_("\nDefault options:")); + print_compile_options(comp_opts_default); + puts(_("\nCompile options:")); - print_compile_options(); + print_compile_options(comp_opts); #ifdef DOMAIN printf("DOMAIN=\"%s\"\n", DOMAIN); @@ -459,6 +469,13 @@ bool feature_enabled(const char *name) { if (!name) return false; + for (int i = 0; comp_opts_default[i].name; i++) + { + if (mutt_strcmp(name, comp_opts_default[i].name) == 0) + { + return true; + } + } for (int i = 0; comp_opts[i].name; i++) { if (mutt_strcmp(name, comp_opts[i].name) == 0) -- 2.40.0