From 5aa7cba9d1d5d5630be796634b125560dae08f36 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 16 Aug 2018 15:35:13 +0100 Subject: [PATCH] use config code for neomutt -Q --- config/dump.c | 6 +++--- init.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/config/dump.c b/config/dump.c index 22d3e2719..2fce673ee 100644 --- a/config/dump.c +++ b/config/dump.c @@ -239,9 +239,9 @@ bool dump_config(struct ConfigSet *cs, int style, int flags) bool result = true; - struct Buffer *value = mutt_buffer_alloc(1024); - struct Buffer *initial = mutt_buffer_alloc(1024); - struct Buffer *tmp = mutt_buffer_alloc(1024); + struct Buffer *value = mutt_buffer_alloc(STRING); + struct Buffer *initial = mutt_buffer_alloc(STRING); + struct Buffer *tmp = mutt_buffer_alloc(STRING); for (size_t i = 0; list[i]; i++) { diff --git a/init.c b/init.c index 73cc04744..3b8f56a42 100644 --- a/init.c +++ b/init.c @@ -3417,30 +3417,44 @@ finish: int mutt_query_variables(struct ListHead *queries) { struct Buffer *value = mutt_buffer_alloc(STRING); - struct Buffer *err = mutt_buffer_alloc(STRING); + struct Buffer *tmp = mutt_buffer_alloc(STRING); int rc = 0; - mutt_buffer_init(value); - struct ListNode *np = NULL; STAILQ_FOREACH(np, queries, entries) { mutt_buffer_reset(value); - if (var_to_string2(np->data, true, value, err) < 0) + struct HashElem *he = cs_get_elem(Config, np->data); + if (!he) { - mutt_error("%s", err->data); rc = 1; - break; + continue; + } + + int rv = cs_he_string_get(Config, he, value); + if (CSR_RESULT(rv) != CSR_SUCCESS) + { + rc = 1; + continue; + } + + int type = DTYPE(he->type); + if ((type == DT_PATH) && !(he->type & DT_MAILBOX)) + mutt_pretty_mailbox(value->data, value->dsize); + + if ((type != DT_BOOL) && (type != DT_NUMBER) && (type != DT_LONG) && (type != DT_QUAD)) + { + mutt_buffer_reset(tmp); + size_t len = pretty_var(value->data, tmp); + mutt_str_strfcpy(value->data, tmp->data, len + 1); } - printf("set %s=%s\n", np->data, value->data); - // dump_config_mutt(Config, he, &value, NULL, 0); - // dump_config_neo(Config, he, value, NULL, 0); + dump_config_neo(Config, he, value, NULL, 0); } mutt_buffer_free(&value); - mutt_buffer_free(&err); + mutt_buffer_free(&tmp); return rc; // TEST16: neomutt -Q charset } -- 2.40.0