]> granicus.if.org Git - neomutt/commitdiff
Revert "Make path config variables relative"
authorRichard Russon <rich@flatcap.org>
Mon, 16 Jul 2018 10:53:09 +0000 (11:53 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 16 Jul 2018 10:53:44 +0000 (11:53 +0100)
This reverts commits:
dfc4e2e0a83b4f275b5f0931fd1e8b5e5dcc03bf
f2dfd2a4a0f37b7a0c6c3f8888ee4c19aa4bae10

A bug was discovered just before release.

init.c
mutt/file.c

diff --git a/init.c b/init.c
index e22e3ed63d5e384ef8b68f84348e86ffaafde230..ac49cd4b0606ee308a3996c9c8608f89691f48ac 100644 (file)
--- a/init.c
+++ b/init.c
@@ -58,7 +58,6 @@
 #include "pattern.h"
 #include "protos.h"
 #include "sidebar.h"
-#include "url.h"
 #include "version.h"
 #ifdef USE_NOTMUCH
 #include "mutt_notmuch.h"
@@ -1069,6 +1068,7 @@ static void restore_default(struct Option *p)
   switch (DTYPE(p->type))
   {
     case DT_STRING:
+    case DT_COMMAND:
       mutt_str_replace((char **) p->var, (char *) p->initial);
       break;
     case DT_MBTABLE:
@@ -1130,20 +1130,6 @@ static void restore_default(struct Option *p)
       *ptr = mutt_regex_create((const char *) p->initial, p->type, NULL);
       break;
     }
-    case DT_COMMAND:
-    {
-      char *init = (char *) p->initial;
-      FREE((char **) p->var);
-      if (init)
-      {
-        char command[LONG_STRING];
-        mutt_str_strfcpy(command, init, sizeof(command));
-        mutt_expand_path(command, sizeof(command));
-        *((char **) p->var) = mutt_str_strdup(command);
-      }
-
-      break;
-    }
   }
 
   if (p->flags & R_INDEX)
@@ -1182,11 +1168,11 @@ static void set_default(struct Option *p)
   switch (DTYPE(p->type))
   {
     case DT_STRING:
+    case DT_COMMAND:
       if (!p->initial && *((char **) p->var))
         p->initial = (unsigned long) mutt_str_strdup(*((char **) p->var));
       break;
     case DT_PATH:
-    case DT_COMMAND:
       if (!p->initial && *((char **) p->var))
       {
         char *cp = mutt_str_strdup(*((char **) p->var));
@@ -2167,13 +2153,6 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
           mutt_pretty_mailbox(tmp2, sizeof(tmp2));
           val = tmp2;
         }
-        else if (DTYPE(MuttVars[idx].type) == DT_COMMAND)
-        {
-          tmp2[0] = '\0';
-          mutt_str_strfcpy(tmp2, NONULL(*((char **) MuttVars[idx].var)), sizeof(tmp2));
-          mutt_pretty_mailbox(tmp2, sizeof(tmp2));
-          val = tmp2;
-        }
         else if (DTYPE(MuttVars[idx].type) == DT_MBTABLE)
         {
           struct MbTable *mbt = (*((struct MbTable **) MuttVars[idx].var));
@@ -2210,16 +2189,6 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
           char scratch[PATH_MAX];
           mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
           mutt_expand_path(scratch, sizeof(scratch));
-
-          if (url_check_scheme(scratch) == U_UNKNOWN) /* probably a local file */
-          {
-            struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
-            if (!mutt_file_to_absolute_path(scratch, np ? NONULL(np->data) : "./"))
-            {
-              mutt_error("Error: impossible to build path of '%s'.", scratch);
-            }
-          }
-
           if (mutt_str_strcmp(MuttVars[idx].name, "debug_file") == 0)
           {
             mutt_log_set_file(scratch, true);
@@ -2232,17 +2201,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
             *((char **) MuttVars[idx].var) = mutt_str_strdup(scratch);
           }
         }
-        else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_COMMAND))
-        {
-          char scratch[PATH_MAX];
-          mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
-          mutt_expand_path(scratch, sizeof(scratch));
-          /* MuttVars[idx].var is already 'char**' (or some 'void**') or...
-           * so cast to 'void*' is okay */
-          FREE((void *) MuttVars[idx].var);
-          *((char **) MuttVars[idx].var) = mutt_str_strdup(scratch);
-        }
-        else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_STRING))
+        else if ((idx >= 0) && ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_COMMAND)))
         {
           if ((strstr(MuttVars[idx].name, "charset") &&
                check_charset(&MuttVars[idx], buf->data) < 0) |
@@ -4261,28 +4220,6 @@ int mutt_option_set(const struct Option *val, struct Buffer *err)
         char scratch[LONG_STRING];
         mutt_str_strfcpy(scratch, NONULL((const char *) val->var), sizeof(scratch));
         mutt_expand_path(scratch, sizeof(scratch));
-
-        if (url_check_scheme(scratch) == U_UNKNOWN) /* probably a local file */
-        {
-          struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
-          if (!mutt_file_to_absolute_path(scratch, np ? NONULL(np->data) : "./"))
-          {
-            mutt_error("Error: impossible to build path of '%s'.", scratch);
-          }
-        }
-
-        /* MuttVars[idx].var is already 'char**' (or some 'void**') or...
-         * so cast to 'void*' is okay */
-        FREE((void *) MuttVars[idx].var);
-        *((char **) MuttVars[idx].var) = mutt_str_strdup(scratch);
-        break;
-      }
-      case DT_COMMAND:
-      {
-        char scratch[LONG_STRING];
-        mutt_str_strfcpy(scratch, NONULL((const char *) val->var), sizeof(scratch));
-        mutt_expand_path(scratch, sizeof(scratch));
-
         /* MuttVars[idx].var is already 'char**' (or some 'void**') or...
          * so cast to 'void*' is okay */
         FREE((void *) MuttVars[idx].var);
@@ -4290,6 +4227,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err)
         break;
       }
       case DT_STRING:
+      case DT_COMMAND:
       {
         /* MuttVars[idx].var is already 'char**' (or some 'void**') or...
          * so cast to 'void*' is okay */
@@ -4517,8 +4455,7 @@ int var_to_string(int idx, char *val, size_t len)
 
   tmp[0] = '\0';
 
-  if ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_PATH) ||
-      (DTYPE(MuttVars[idx].type) == DT_COMMAND))
+  if ((DTYPE(MuttVars[idx].type) == DT_STRING) || (DTYPE(MuttVars[idx].type) == DT_PATH))
   {
     mutt_str_strfcpy(tmp, NONULL(*((char **) MuttVars[idx].var)), sizeof(tmp));
     if (DTYPE(MuttVars[idx].type) == DT_PATH)
index a4fad5c54b3633516b5edbafae6665a944b91281..6cd7313e61b0a9c1cf6b78385e6be4f90e2eae5f 100644 (file)
@@ -1328,7 +1328,8 @@ int mutt_file_to_absolute_path(char *path, const char *reference)
   mutt_str_strncat(abs_path, sizeof(abs_path), path, path_len > 0 ? path_len : 0);
 
   path = realpath(abs_path, path);
-  if (!path && (errno != ENOENT))
+
+  if (!path)
   {
     printf("Error: issue converting path to absolute (%s)", strerror(errno));
     return false;