]> granicus.if.org Git - neomutt/commitdiff
mailcap_path -> slist
authorRichard Russon <rich@flatcap.org>
Mon, 10 Jun 2019 13:44:18 +0000 (14:44 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Jun 2019 23:23:35 +0000 (00:23 +0100)
Convert `$mailcap_path` to use the new DT_SLIST type (string list).

globals.h
init.h
rfc1524.c

index 64dbc1b8a4dd6b9fb29a9ae3cce9154bc55773c9..8b01a6babfcc0a6bfa85e15e077a17e9afa88331 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -110,7 +110,7 @@ WHERE char *C_IndexFormat;                   ///< Config: printf-like format str
 WHERE char *C_ImapUser;                      ///< Config: (imap) Username for the IMAP server
 #endif
 WHERE char *C_Mbox;                          ///< Config: Folder that receives read emails (see Move)
-WHERE char *C_MailcapPath;                   ///< Config: Colon-separated list of mailcap files
+WHERE struct Slist *C_MailcapPath;           ///< Config: Colon-separated list of mailcap files
 WHERE char *C_Folder;                        ///< Config: Base folder for a set of mailboxes
 #ifdef USE_HCACHE
 WHERE char *C_HeaderCache;                   ///< Config: (hcache) Directory/file for the header cache database
diff --git a/init.h b/init.h
index 6d3b5da084aa914ba31675b22b8354520226ebcb..2fe76dacf0404993198ef614032887b17c0cbccc 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1954,7 +1954,7 @@ struct ConfigDef MuttVars[] = {
   ** When $$mail_check_stats is \fIset\fP, this variable configures
   ** how often (in seconds) NeoMutt will update message counts.
   */
-  { "mailcap_path", DT_STRING, &C_MailcapPath, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap" },
+  { "mailcap_path", DT_SLIST|SLIST_SEP_COLON, &C_MailcapPath, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap" },
   /*
   ** .pp
   ** This variable specifies which files to consult when attempting to
index 90a88a0e7689e2e5b2350bbe2f573108c932e209..17e2d2fec68b24aa0723d5a064e20d90dcd475a5 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -468,16 +468,12 @@ void rfc1524_free_entry(struct Rfc1524MailcapEntry **entry)
 bool rfc1524_mailcap_lookup(struct Body *a, char *type,
                             struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt)
 {
-  char path[PATH_MAX];
-  int found = false;
-  char *curr = C_MailcapPath;
-
   /* rfc1524 specifies that a path of mailcap files should be searched.
    * joy.  They say
    * $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap, etc
    * and overridden by the MAILCAPS environment variable, and, just to be nice,
    * we'll make it specifiable in .neomuttrc */
-  if (!curr || !*curr)
+  if (!C_MailcapPath || (C_MailcapPath->count == 0))
   {
     mutt_error(_("No mailcap path specified"));
     return false;
@@ -485,25 +481,19 @@ bool rfc1524_mailcap_lookup(struct Body *a, char *type,
 
   mutt_check_lookup_list(a, type, 128);
 
-  while (!found && *curr)
-  {
-    int x = 0;
-    while (*curr && (*curr != ':') && (x < sizeof(path) - 1))
-    {
-      path[x++] = *curr;
-      curr++;
-    }
-    if (*curr)
-      curr++;
-
-    if (x == 0)
-      continue;
+  char path[PATH_MAX];
+  bool found = false;
 
-    path[x] = '\0';
+  struct ListNode *np = NULL;
+  STAILQ_FOREACH(np, &C_MailcapPath->head, entries)
+  {
+    mutt_str_strfcpy(path, np->data, sizeof(path));
     mutt_expand_path(path, sizeof(path));
 
     mutt_debug(LL_DEBUG2, "Checking mailcap file: %s\n", path);
     found = rfc1524_mailcap_parse(a, path, type, entry, opt);
+    if (found)
+      break;
   }
 
   if (entry && !found)