]> granicus.if.org Git - neomutt/commitdiff
use config code for neomutt -Q
authorRichard Russon <rich@flatcap.org>
Thu, 16 Aug 2018 14:35:13 +0000 (15:35 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 16 Aug 2018 15:18:56 +0000 (16:18 +0100)
config/dump.c
init.c

index 22d3e27193f11f62ccad7129bb640a7d93d7e45b..2fce673eed80e43692175c0f3be47a3b7731aeee 100644 (file)
@@ -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 73cc04744fc95830e3d39b47a643e075a0daee27..3b8f56a42cadae349115a52b981422d60be93925 100644 (file)
--- 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
 }