more constness.
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index e8c3b0a..6ac482f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -206,7 +206,7 @@ static int bool_from_string (struct option_t* dst, const char* val,
 static void num_to_string (char* dst, size_t dstlen,
                            struct option_t* option) {
   /* XXX puke */
 static void num_to_string (char* dst, size_t dstlen,
                            struct option_t* option) {
   /* XXX puke */
-  const char* fmt = (str_cmp (option->option, "umask") == 0) ? 
+  const char* fmt = (str_cmp (option->option, "umask") == 0) ?
                     "%s=%04o" : "%s=%d";
   snprintf (dst, dstlen, fmt, option->option,
             *((short*) option->data));
                     "%s=%04o" : "%s=%d";
   snprintf (dst, dstlen, fmt, option->option,
             *((short*) option->data));
@@ -277,8 +277,8 @@ static void sys_to_string (char* dst, size_t dstlen,
      * if name starts with $folder, just strip it to keep hierarchy
      * $folder=imap://host, path=imap://host/inbox/b -> inbox/b
      */
      * if name starts with $folder, just strip it to keep hierarchy
      * $folder=imap://host, path=imap://host/inbox/b -> inbox/b
      */
-    if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir, 
-                                      Maildirlength) == 0 && 
+    if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir,
+                                      Maildirlength) == 0 &&
        str_len (CurrentFolder) > Maildirlength) {
      val = CurrentFolder + Maildirlength;
      if (Maildir[strlen(Maildir)-1]!='/')
        str_len (CurrentFolder) > Maildirlength) {
      val = CurrentFolder + Maildirlength;
      if (Maildir[strlen(Maildir)-1]!='/')
@@ -379,15 +379,14 @@ static int quad_from_string (struct option_t* dst, const char* val,
 static void sort_to_string (char* dst, size_t dstlen,
                             struct option_t* option) {
   const struct mapping_t *map = get_sortmap (option);
 static void sort_to_string (char* dst, size_t dstlen,
                             struct option_t* option) {
   const struct mapping_t *map = get_sortmap (option);
-  char* p = NULL;
+  const char *p = NULL;
 
   if (!map) {
     snprintf (dst, sizeof (dst), "%s=unknown", option->option);
     return;
   }
 
 
   if (!map) {
     snprintf (dst, sizeof (dst), "%s=unknown", option->option);
     return;
   }
 
-  p = mutt_getnamebyvalue (*((short *) option->data) & SORT_MASK,
-                           map);
+  p = mutt_getnamebyvalue(*((short *)option->data) & SORT_MASK, map);
 
   snprintf (dst, dstlen, "%s=%s%s%s", option->option,
             (*((short *) option->data) & SORT_REVERSE) ?
 
   snprintf (dst, dstlen, "%s=%s%s%s", option->option,
             (*((short *) option->data) & SORT_REVERSE) ?
@@ -1103,9 +1102,9 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
 
     if (!buf->data || *buf->data == '\0')
       continue;
 
     if (!buf->data || *buf->data == '\0')
       continue;
-    
+
     a = mem_malloc(sizeof(ATTACH_MATCH));
     a = mem_malloc(sizeof(ATTACH_MATCH));
-    
+
     /* some cheap hacks that I expect to remove */
     if (!str_casecmp(buf->data, "any"))
       a->major = str_dup("*/.*");
     /* some cheap hacks that I expect to remove */
     if (!str_casecmp(buf->data, "any"))
       a->major = str_dup("*/.*");
@@ -1113,7 +1112,7 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
       a->major = str_dup("cheap_hack/this_should_never_match");
     else
       a->major = str_dup(buf->data);
       a->major = str_dup("cheap_hack/this_should_never_match");
     else
       a->major = str_dup(buf->data);
-    
+
     if ((p = strchr(a->major, '/'))) {
       *p = '\0';
       ++p;
     if ((p = strchr(a->major, '/'))) {
       *p = '\0';
       ++p;
@@ -1128,10 +1127,10 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata,
     tmpminor[0] = '^';
     tmpminor[len+1] = '$';
     tmpminor[len+2] = '\0';
     tmpminor[0] = '^';
     tmpminor[len+1] = '$';
     tmpminor[len+2] = '\0';
-    
+
     a->major_int = mutt_check_mime_type(a->major);
     regcomp(&a->minor_rx, tmpminor, REG_ICASE|REG_EXTENDED);
     a->major_int = mutt_check_mime_type(a->major);
     regcomp(&a->minor_rx, tmpminor, REG_ICASE|REG_EXTENDED);
-    
+
     mem_free (&tmpminor);
 
     debug_print (5, ("parse_attach_list: added %s/%s [%d]\n",
     mem_free (&tmpminor);
 
     debug_print (5, ("parse_attach_list: added %s/%s [%d]\n",
@@ -1162,14 +1161,14 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata, BUFFER *er
 
   do {
     mutt_extract_token (buf, s, 0);
 
   do {
     mutt_extract_token (buf, s, 0);
-    
+
     if (!str_casecmp(buf->data, "any"))
       tmp = str_dup("*/.*");
     else if (!str_casecmp(buf->data, "none"))
       tmp = str_dup("cheap_hack/this_should_never_match");
     else
       tmp = str_dup(buf->data);
     if (!str_casecmp(buf->data, "any"))
       tmp = str_dup("*/.*");
     else if (!str_casecmp(buf->data, "none"))
       tmp = str_dup("cheap_hack/this_should_never_match");
     else
       tmp = str_dup(buf->data);
-    
+
     if ((minor = strchr(tmp, '/'))) {
       *minor = '\0';
       ++minor;
     if ((minor = strchr(tmp, '/'))) {
       *minor = '\0';
       ++minor;
@@ -1177,7 +1176,7 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata, BUFFER *er
       minor = "unknown";
     }
     major = mutt_check_mime_type(tmp);
       minor = "unknown";
     }
     major = mutt_check_mime_type(tmp);
-    
+
     /* We must do our own walk here because remove_from_list() will only
      * remove the LIST->data, not anything pointed to by the LIST->data. */
     lastp = NULL;
     /* We must do our own walk here because remove_from_list() will only
      * remove the LIST->data, not anything pointed to by the LIST->data. */
     lastp = NULL;
@@ -1190,26 +1189,26 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata, BUFFER *er
                         a->major, a->minor, a->major_int));
         regfree(&a->minor_rx);
         mem_free(&a->major);
                         a->major, a->minor, a->major_int));
         regfree(&a->minor_rx);
         mem_free(&a->major);
-        
+
         /* Relink backward */
         if (lastp)
           lastp->next = lp->next;
         else
           *ldata = lp->next;
         /* Relink backward */
         if (lastp)
           lastp->next = lp->next;
         else
           *ldata = lp->next;
-        
+
         newlp = lp->next;
         mem_free(&lp->data); /* same as a */
         mem_free(&lp);
         lp = newlp;
         continue;
       }
         newlp = lp->next;
         mem_free(&lp->data); /* same as a */
         mem_free(&lp);
         lp = newlp;
         continue;
       }
-        
+
       lastp = lp;
       lp = lp->next;
     }
   }
   while (MoreArgs (s));
       lastp = lp;
       lp = lp->next;
     }
   }
   while (MoreArgs (s));
-  
+
   mem_free (&tmp);
   _attachments_clean();
   return 0;
   mem_free (&tmp);
   _attachments_clean();
   return 0;
@@ -1222,23 +1221,23 @@ static int print_attach_list (LIST *lp, char op, const char *name) {
            ((ATTACH_MATCH *)lp->data)->minor);
     lp = lp->next;
   }
            ((ATTACH_MATCH *)lp->data)->minor);
     lp = lp->next;
   }
-  
+
   return 0;
 }
 
 static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
   char op, *category;
   LIST **listp;
   return 0;
 }
 
 static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
   char op, *category;
   LIST **listp;
-  
+
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
     strfcpy(err->data, _("attachments: no disposition"), err->dsize);
     return -1;
   }
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
     strfcpy(err->data, _("attachments: no disposition"), err->dsize);
     return -1;
   }
+
   category = buf->data;
   op = *category++;
   category = buf->data;
   op = *category++;
-  
+
   if (op == '?') {
     mutt_endwin (NULL);
     fflush (stdout);
   if (op == '?') {
     mutt_endwin (NULL);
     fflush (stdout);
@@ -1272,20 +1271,20 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
     strfcpy(err->data, _("attachments: invalid disposition"), err->dsize);
     return -1;
   }
     strfcpy(err->data, _("attachments: invalid disposition"), err->dsize);
     return -1;
   }
-  
+
   return parse_attach_list(buf, s, listp, err);
 }
 
 static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
   char op, *p;
   LIST **listp;
   return parse_attach_list(buf, s, listp, err);
 }
 
 static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
   char op, *p;
   LIST **listp;
-  
+
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
     strfcpy(err->data, _("unattachments: no disposition"), err->dsize);
     return -1;
   }
   mutt_extract_token(buf, s, 0);
   if (!buf->data || *buf->data == '\0') {
     strfcpy(err->data, _("unattachments: no disposition"), err->dsize);
     return -1;
   }
-  
+
   p = buf->data;
   op = *p++;
   if (op != '+' && op != '-') {
   p = buf->data;
   op = *p++;
   if (op != '+' && op != '-') {
@@ -1308,7 +1307,7 @@ static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFF
     strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize);
     return -1;
   }
     strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize);
     return -1;
   }
-  
+
   return parse_unattach_list(buf, s, listp, err);
 }
 
   return parse_unattach_list(buf, s, listp, err);
 }
 
@@ -1853,7 +1852,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
     mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
 
     /* resolve synonyms */
     mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
 
     /* resolve synonyms */
-    if ((option = hash_find (ConfigOptions, tmp->data)) != NULL && 
+    if ((option = hash_find (ConfigOptions, tmp->data)) != NULL &&
         DTYPE (option->type == DT_SYN)) {
       struct option_t* newopt = hash_find (ConfigOptions, (char*) option->data);
       syn_add (newopt, option);
         DTYPE (option->type == DT_SYN)) {
       struct option_t* newopt = hash_find (ConfigOptions, (char*) option->data);
       syn_add (newopt, option);
@@ -2205,13 +2204,13 @@ finish:
 
 #define NUMVARS (sizeof (MuttVars)/sizeof (MuttVars[0]))
 #define NUMCOMMANDS (sizeof (Commands)/sizeof (Commands[0]))
 
 #define NUMVARS (sizeof (MuttVars)/sizeof (MuttVars[0]))
 #define NUMCOMMANDS (sizeof (Commands)/sizeof (Commands[0]))
-/* initial string that starts completion. No telling how much crap 
+/* initial string that starts completion. No telling how much crap
  * the user has typed so far. Allocate LONG_STRING just to be sure! */
 char User_typed[LONG_STRING] = { 0 };
 
 int Num_matched = 0;            /* Number of matches for completion */
 char Completed[STRING] = { 0 }; /* completed string (command or variable) */
  * the user has typed so far. Allocate LONG_STRING just to be sure! */
 char User_typed[LONG_STRING] = { 0 };
 
 int Num_matched = 0;            /* Number of matches for completion */
 char Completed[STRING] = { 0 }; /* completed string (command or variable) */
-char *Matches[MAX (NUMVARS, NUMCOMMANDS) + 1];  /* all the matches + User_typed */
+const char *Matches[MAX (NUMVARS, NUMCOMMANDS) + 1];  /* all the matches + User_typed */
 
 /* helper function for completion.  Changes the dest buffer if
    necessary/possible to aid completion.
 
 /* helper function for completion.  Changes the dest buffer if
    necessary/possible to aid completion.
@@ -2429,7 +2428,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
         snprintf (tmp, sizeof (tmp), "%d", (*((short *) option->data)));
       else if (DTYPE (option->type) == DT_SORT) {
         const struct mapping_t *map;
         snprintf (tmp, sizeof (tmp), "%d", (*((short *) option->data)));
       else if (DTYPE (option->type) == DT_SORT) {
         const struct mapping_t *map;
-        char *p;
+        const char *p;
 
         switch (option->type & DT_SUBTYPE_MASK) {
         case DT_SORT_ALIAS:
 
         switch (option->type & DT_SUBTYPE_MASK) {
         case DT_SORT_ALIAS:
@@ -2448,15 +2447,11 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
           map = SortMethods;
           break;
         }
           map = SortMethods;
           break;
         }
-        p =
-          mutt_getnamebyvalue (*((short *) option->data) & SORT_MASK,
-                               map);
-        snprintf (tmp, sizeof (tmp), "%s%s%s",
-                  (*((short *) option->data) & SORT_REVERSE) ?
-                  "reverse-" : "",
-                  (*((short *) option->data) & SORT_LAST) ? "last-" :
-                  "", p);
-      } 
+        p = mutt_getnamebyvalue(*((short *) option->data) & SORT_MASK, map);
+        snprintf(tmp, sizeof (tmp), "%s%s%s",
+                 (*((short *)option->data) & SORT_REVERSE) ? "reverse-" : "",
+                 (*((short *)option->data) & SORT_LAST) ? "last-" : "", p);
+      }
       else if (DTYPE (option->type) == DT_MAGIC) {
         const char *p;
         switch (DefaultMagic) {
       else if (DTYPE (option->type) == DT_MAGIC) {
         const char *p;
         switch (DefaultMagic) {
@@ -2582,7 +2577,7 @@ void mutt_init (int skip_sys_rc, LIST * commands)
   err.data = error;
   err.dsize = sizeof (error);
 
   err.data = error;
   err.dsize = sizeof (error);
 
-  /* use 3*sizeof(muttvars) instead of 2*sizeof() 
+  /* use 3*sizeof(muttvars) instead of 2*sizeof()
    * to have some room for $user_ vars */
   ConfigOptions = hash_create (sizeof (MuttVars) * 3);
   for (i = 0; MuttVars[i].option; i++) {
    * to have some room for $user_ vars */
   ConfigOptions = hash_create (sizeof (MuttVars) * 3);
   for (i = 0; MuttVars[i].option; i++) {
@@ -2594,7 +2589,7 @@ void mutt_init (int skip_sys_rc, LIST * commands)
                                DT_SYS, 0), 0);
   }
 
                                DT_SYS, 0), 0);
   }
 
-  /* 
+  /*
    * XXX - use something even more difficult to predict?
    */
   snprintf (AttachmentMarker, sizeof (AttachmentMarker),
    * XXX - use something even more difficult to predict?
    */
   snprintf (AttachmentMarker, sizeof (AttachmentMarker),
@@ -2667,9 +2662,9 @@ void mutt_init (int skip_sys_rc, LIST * commands)
     if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) {
       buffer[0] = '\0';
       fgets (buffer, sizeof (buffer), f);
     if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) {
       buffer[0] = '\0';
       fgets (buffer, sizeof (buffer), f);
-      p = (char*)&buffer;
+      p = buffer;
       SKIPWS (p);
       SKIPWS (p);
-      q = p;
+      q = (char*)p;
       while (*q && !isspace(*q))
         q++;
       *q = '\0';
       while (*q && !isspace(*q))
         q++;
       *q = '\0';
@@ -2762,13 +2757,13 @@ void mutt_init (int skip_sys_rc, LIST * commands)
 
 
   /*
 
 
   /*
-   * 
+   *
    *                       BIG FAT WARNING
    *                       BIG FAT WARNING
-   * 
+   *
    * When changing the code which looks for a configuration file,
    * please also change the corresponding code in muttbug.sh.in.
    * When changing the code which looks for a configuration file,
    * please also change the corresponding code in muttbug.sh.in.
-   * 
-   * 
+   *
+   *
    */
 
 
    */