<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Speed and size improvements



The first attached patch adds a few strategic inlines and an unnecessary
list traversal that improves mutt's startup time on a 50 message
local mbox by 15% on my configuration.

The second patch reduces the .data section (decreasing unsharable RAM
requirements) by 25% by marking a bunch of static arrays const.

These patches are against a recent 1.5.17 daily snapshot.

>>> Dan
-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
diff -ru /tmp/mutt-1.5.17cvs/ascii.c /home/dan/src/mutt-1.5.17cvs/ascii.c
--- /tmp/mutt-1.5.17cvs/ascii.c Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/ascii.c        Thu Mar 27 16:12:36 2008
@@ -34,17 +34,17 @@
 #include <stdlib.h>
 #include "ascii.h"
 
-int ascii_isupper (int c)
+inline int ascii_isupper (int c)
 {
   return (c >= 'A') && (c <= 'Z');
 }
 
-int ascii_islower (int c)
+inline int ascii_islower (int c)
 {
   return (c >= 'a') && (c <= 'z');
 }
 
-int ascii_toupper (int c)
+inline int ascii_toupper (int c)
 {
   if (ascii_islower (c))
     return c & ~32;
@@ -52,7 +52,7 @@
   return c;
 }
 
-int ascii_tolower (int c)
+inline int ascii_tolower (int c)
 {
   if (ascii_isupper (c))
     return c | 32;
diff -ru /tmp/mutt-1.5.17cvs/group.c /home/dan/src/mutt-1.5.17cvs/group.c
--- /tmp/mutt-1.5.17cvs/group.c Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/group.c        Thu Mar 27 16:16:28 2008
@@ -81,19 +81,17 @@
 
 void mutt_group_add_adrlist (group_t *g, ADDRESS *a)
 {
-  ADDRESS **p, *q;
+  ADDRESS *q;
 
   if (!g)
     return;
   if (!a)
     return;
   
-  for (p = &g->as; *p; p = &((*p)->next))
-    ;
-  
   q = rfc822_cpy_adr (a);
   q = mutt_remove_xrefs (g->as, q);
-  *p = q;
+  q->next = g->as;
+  g->as = q;
 }
 
 int mutt_group_add_rx (group_t *g, const char *s, int flags, BUFFER *err)
diff -ru /tmp/mutt-1.5.17cvs/addrbook.c /home/dan/src/mutt-1.5.17cvs/addrbook.c
--- /tmp/mutt-1.5.17cvs/addrbook.c      Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/addrbook.c     Thu Mar 27 13:55:28 2008
@@ -33,7 +33,7 @@
 
 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x
 
-static struct mapping_t AliasHelp[] = {
+static const struct mapping_t AliasHelp[] = {
   { N_("Exit"),   OP_EXIT },
   { N_("Del"),    OP_DELETE },
   { N_("Undel"),  OP_UNDELETE },
diff -ru /tmp/mutt-1.5.17cvs/browser.c /home/dan/src/mutt-1.5.17cvs/browser.c
--- /tmp/mutt-1.5.17cvs/browser.c       Thu Sep  6 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/browser.c      Thu Mar 27 13:55:23 2008
@@ -41,7 +41,7 @@
 #include <sys/stat.h>
 #include <errno.h>
 
-static struct mapping_t FolderHelp[] = {
+static const struct mapping_t FolderHelp[] = {
   { N_("Exit"),  OP_EXIT },
   { N_("Chdir"), OP_CHANGE_DIRECTORY },
   { N_("Mask"),  OP_ENTER_MASK },
diff -ru /tmp/mutt-1.5.17cvs/charset.c /home/dan/src/mutt-1.5.17cvs/charset.c
--- /tmp/mutt-1.5.17cvs/charset.c       Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/charset.c      Thu Mar 27 13:55:01 2008
@@ -50,10 +50,10 @@
  * a preferred MIME name is given.
  */
 
-static struct 
+static const const struct 
 {
-  char *key;
-  char *pref;
+  const char *key;
+  const char *pref;
 }
 PreferredMIMENames[] = 
 {
diff -ru /tmp/mutt-1.5.17cvs/color.c /home/dan/src/mutt-1.5.17cvs/color.c
--- /tmp/mutt-1.5.17cvs/color.c Fri Nov  9 00:00:11 2007
+++ /home/dan/src/mutt-1.5.17cvs/color.c        Thu Mar 27 15:30:22 2008
@@ -55,7 +55,7 @@
 static COLOR_LIST *ColorList = NULL;
 static int UserColors = 0;
 
-static struct mapping_t Colors[] =
+static const struct mapping_t Colors[] =
 {
   { "black",   COLOR_BLACK },
   { "blue",    COLOR_BLUE },
@@ -73,7 +73,7 @@
 
 #endif /* HAVE_COLOR */
 
-static struct mapping_t Fields[] =
+static const struct mapping_t Fields[] =
 {
   { "hdrdefault",      MT_COLOR_HDEFAULT },
   { "quoted",          MT_COLOR_QUOTED },
@@ -159,7 +159,7 @@
 #ifdef USE_SLANG_CURSES
 static char *get_color_name (char *dest, size_t destlen, int val)
 {
-  static char * missing[3] = {"brown", "lightgray", "default"};
+  static const char * const missing[3] = {"brown", "lightgray", "default"};
   int i;
 
   switch (val)
diff -ru /tmp/mutt-1.5.17cvs/compose.c /home/dan/src/mutt-1.5.17cvs/compose.c
--- /tmp/mutt-1.5.17cvs/compose.c       Mon Mar 10 00:00:05 2008
+++ /home/dan/src/mutt-1.5.17cvs/compose.c      Thu Mar 27 13:53:57 2008
@@ -74,7 +74,7 @@
 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
 #define W (COLS - HDR_XOFFSET)
 
-static char *Prompts[] =
+static const char * const Prompts[] =
 {
   "From: ",
   "To: ",
@@ -85,7 +85,7 @@
   "Fcc: "
 };
 
-static struct mapping_t ComposeHelp[] = {
+static const struct mapping_t ComposeHelp[] = {
   { N_("Send"),    OP_COMPOSE_SEND_MESSAGE },
   { N_("Abort"),   OP_EXIT },
   { "To",      OP_COMPOSE_EDIT_TO },
diff -ru /tmp/mutt-1.5.17cvs/crypt-gpgme.c 
/home/dan/src/mutt-1.5.17cvs/crypt-gpgme.c
--- /tmp/mutt-1.5.17cvs/crypt-gpgme.c   Sun Jul 15 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/crypt-gpgme.c  Thu Mar 27 15:46:27 2008
@@ -126,7 +126,7 @@
  * General helper functions.
  */
 
-/* return true when S pints to a didgit or letter. */
+/* return true when s points to a digit or letter. */
 static int
 digit_or_letter (const unsigned char *s)
 {
@@ -2750,7 +2750,7 @@
 static void
 print_dn_parts (FILE *fp, struct dn_array_s *dn)
 {
-  const char *stdpart[] = {
+  static const char * const stdpart[] = {
     "CN", "OU", "O", "STREET", "L", "ST", "C", NULL 
   };
   int any=0, any2=0, i;
diff -ru /tmp/mutt-1.5.17cvs/curs_lib.c /home/dan/src/mutt-1.5.17cvs/curs_lib.c
--- /tmp/mutt-1.5.17cvs/curs_lib.c      Thu Feb 28 00:00:04 2008
+++ /home/dan/src/mutt-1.5.17cvs/curs_lib.c     Thu Mar 27 14:02:45 2008
@@ -128,7 +128,7 @@
   return (ch == ctrl ('G') ? err : ret);
 }
 
-int _mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int 
complete, int multiple, char ***files, int *numfiles)
+int _mutt_get_field (const char *field, char *buf, size_t buflen, int 
complete, int multiple, char ***files, int *numfiles)
 {
   int ret;
   int x, y;
@@ -138,7 +138,7 @@
   do
   {
     CLEARLINE (LINES-1);
-    addstr (field);
+    addstr ((char *)field); /* cast to get around bad prototypes */
     mutt_refresh ();
     getyx (stdscr, y, x);
     ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, 
numfiles, es);
diff -ru /tmp/mutt-1.5.17cvs/curs_main.c 
/home/dan/src/mutt-1.5.17cvs/curs_main.c
--- /tmp/mutt-1.5.17cvs/curs_main.c     Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/curs_main.c    Thu Mar 27 13:53:16 2008
@@ -403,7 +403,7 @@
   menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
 }
 
-struct mapping_t IndexHelp[] = {
+static const struct mapping_t IndexHelp[] = {
   { N_("Quit"),  OP_QUIT },
   { N_("Del"),   OP_DELETE },
   { N_("Undel"), OP_UNDELETE },
diff -ru /tmp/mutt-1.5.17cvs/date.c /home/dan/src/mutt-1.5.17cvs/date.c
--- /tmp/mutt-1.5.17cvs/date.c  Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/date.c Thu Mar 27 15:30:52 2008
@@ -69,7 +69,7 @@
 {
   time_t g;
 
-  static int AccumDaysPerMonth[12] = {
+  static const int AccumDaysPerMonth[12] = {
     0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
   };
 
@@ -118,7 +118,7 @@
 
 void mutt_normalize_time (struct tm *tm)
 {
-  static char DaysPerMonth[12] = {
+  static const char DaysPerMonth[12] = {
     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
   };
   int nLeap;
diff -ru /tmp/mutt-1.5.17cvs/enter.c /home/dan/src/mutt-1.5.17cvs/enter.c
--- /tmp/mutt-1.5.17cvs/enter.c Wed Dec 12 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/enter.c        Thu Mar 27 13:52:36 2008
@@ -191,7 +191,7 @@
  */
 static inline int is_shell_char(wchar_t ch)
 {
-  static wchar_t shell_chars[] = L"<>&()$?*;{}| "; /* ! not included because 
it can be part of a pathname in Mutt */
+  static const wchar_t shell_chars[] = L"<>&()$?*;{}| "; /* ! not included 
because it can be part of a pathname in Mutt */
   return wcschr(shell_chars, ch) != NULL;
 }
 
diff -ru /tmp/mutt-1.5.17cvs/handler.c /home/dan/src/mutt-1.5.17cvs/handler.c
--- /tmp/mutt-1.5.17cvs/handler.c       Wed Jul 11 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/handler.c      Thu Mar 27 15:31:30 2008
@@ -43,7 +43,7 @@
 
 typedef int (*handler_t) (BODY *, STATE *);
 
-int Index_hex[128] = {
+const int Index_hex[128] = {
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
@@ -54,7 +54,7 @@
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1
 };
 
-int Index_64[128] = {
+const int Index_64[128] = {
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
@@ -426,7 +426,7 @@
   RICH_INDENT, RICH_INDENT_RIGHT, RICH_EXCERPT, RICH_CENTER, RICH_FLUSHLEFT,
   RICH_FLUSHRIGHT, RICH_COLOR, RICH_LAST_TAG };
 
-static struct {
+static const struct {
   const char *tag_name;
   int index;
 } EnrichedTags[] = {
diff -ru /tmp/mutt-1.5.17cvs/help.c /home/dan/src/mutt-1.5.17cvs/help.c
--- /tmp/mutt-1.5.17cvs/help.c  Thu Sep  6 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/help.c Thu Mar 27 13:57:27 2008
@@ -66,7 +66,7 @@
 }
 
 char *
-mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items)
+mutt_compile_help (char *buf, size_t buflen, int menu, const struct mapping_t 
*items)
 {
   int i;
   size_t len;
diff -ru /tmp/mutt-1.5.17cvs/imap/auth.c 
/home/dan/src/mutt-1.5.17cvs/imap/auth.c
--- /tmp/mutt-1.5.17cvs/imap/auth.c     Tue May 29 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/imap/auth.c    Thu Mar 27 15:11:37 2008
@@ -28,7 +28,7 @@
 #include "imap_private.h"
 #include "auth.h"
 
-static imap_auth_t imap_authenticators[] = {
+static const imap_auth_t imap_authenticators[] = {
 #ifdef USE_SASL
   { imap_auth_sasl, NULL },
 #else
@@ -50,7 +50,7 @@
  *   authentication method if specified, or any. */
 int imap_authenticate (IMAP_DATA* idata)
 {
-  imap_auth_t* authenticator;
+  const imap_auth_t* authenticator;
   char* methods;
   char* method;
   char* delim;
diff -ru /tmp/mutt-1.5.17cvs/imap/command.c 
/home/dan/src/mutt-1.5.17cvs/imap/command.c
--- /tmp/mutt-1.5.17cvs/imap/command.c  Fri Nov  9 00:00:11 2007
+++ /home/dan/src/mutt-1.5.17cvs/imap/command.c Thu Mar 27 15:06:25 2008
@@ -50,7 +50,7 @@
 static void cmd_parse_search (IMAP_DATA* idata, const char* s);
 static void cmd_parse_status (IMAP_DATA* idata, char* s);
 
-static char *Capabilities[] = {
+static const char * const Capabilities[] = {
   "IMAP4",
   "IMAP4rev1",
   "STATUS",
diff -ru /tmp/mutt-1.5.17cvs/imap/message.c 
/home/dan/src/mutt-1.5.17cvs/imap/message.c
--- /tmp/mutt-1.5.17cvs/imap/message.c  Wed Nov  7 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/imap/message.c Thu Mar 27 15:45:25 2008
@@ -71,7 +71,7 @@
   int rc, mfhrc, oldmsgcount;
   int fetchlast = 0;
   int maxuid = 0;
-  const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES 
CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL";
+  static const char * const want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID 
REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES 
LIST-POST X-LABEL";
   progress_t progress;
 
 #if USE_HCACHE
diff -ru /tmp/mutt-1.5.17cvs/imap/utf7.c 
/home/dan/src/mutt-1.5.17cvs/imap/utf7.c
--- /tmp/mutt-1.5.17cvs/imap/utf7.c     Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/imap/utf7.c    Thu Mar 27 15:08:40 2008
@@ -24,7 +24,7 @@
 #include "charset.h"
 #include "imap_private.h"
 
-static int Index_64[128] = {
+static const int Index_64[128] = {
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, 63,-1,-1,-1,
@@ -35,7 +35,7 @@
     41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
 };
 
-static char B64Chars[64] = {
+static const char B64Chars[64] = {
   'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
   'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
   'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
diff -ru /tmp/mutt-1.5.17cvs/imap/util.c 
/home/dan/src/mutt-1.5.17cvs/imap/util.c
--- /tmp/mutt-1.5.17cvs/imap/util.c     Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/imap/util.c    Thu Mar 27 15:07:17 2008
@@ -557,7 +557,8 @@
  *   surround string with quotes, escape " and \ with \ */
 void imap_quote_string (char *dest, size_t dlen, const char *src)
 {
-  char quote[] = "\"\\", *pt;
+  static const char quote[] = "\"\\";
+  char *pt;
   const char *s;
 
   pt = dest;
diff -ru /tmp/mutt-1.5.17cvs/init.c /home/dan/src/mutt-1.5.17cvs/init.c
--- /tmp/mutt-1.5.17cvs/init.c  Tue Sep 18 00:00:06 2007
+++ /home/dan/src/mutt-1.5.17cvs/init.c Thu Mar 27 14:28:37 2008
@@ -1688,7 +1688,8 @@
 {
   int query, unset, inv, reset, r = 0;
   int idx = -1;
-  char *p, scratch[_POSIX_PATH_MAX];
+  const char *p;
+  char scratch[_POSIX_PATH_MAX];
   char* myvar;
 
   while (MoreArgs (s))
@@ -2092,7 +2093,7 @@
     {
       if (query)
       {
-       char *vals[] = { "no", "yes", "ask-no", "ask-yes" };
+       static const char * const vals[] = { "no", "yes", "ask-no", "ask-yes" };
 
        snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option,
                  vals [ quadoption (MuttVars[idx].data) ]);
@@ -2457,7 +2458,7 @@
           || !mutt_strncmp (buffer, "reset", 5)
           || !mutt_strncmp (buffer, "toggle", 6))
   {            /* complete variables */
-    char *prefixes[] = { "no", "inv", "?", "&", 0 };
+    static const char * const prefixes[] = { "no", "inv", "?", "&", 0 };
     
     pt++;
     /* loop through all the possible prefixes (no, inv, ...) */
@@ -2608,7 +2609,7 @@
 static int var_to_string (int idx, char* val, size_t len)
 {
   char tmp[LONG_STRING];
-  char *vals[] = { "no", "yes", "ask-no", "ask-yes" };
+  static const char * const vals[] = { "no", "yes", "ask-no", "ask-yes" };
 
   tmp[0] = '\0';
 
@@ -2639,7 +2640,7 @@
   else if (DTYPE (MuttVars[idx].type) == DT_SORT)
   {
     const struct mapping_t *map;
-    char *p;
+    const char *p;
 
     switch (MuttVars[idx].type & DT_SUBTYPE_MASK)
     {
@@ -2765,7 +2766,7 @@
   return 0;
 }
 
-char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
+const char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
 {
   int i;
 
diff -ru /tmp/mutt-1.5.17cvs/keymap.c /home/dan/src/mutt-1.5.17cvs/keymap.c
--- /tmp/mutt-1.5.17cvs/keymap.c        Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/keymap.c       Thu Mar 27 13:48:59 2008
@@ -33,7 +33,7 @@
 
 #include "functions.h"
 
-struct mapping_t Menus[] = {
+const struct mapping_t Menus[] = {
  { "alias",    MENU_ALIAS },
  { "attach",   MENU_ATTACH },
  { "browser",  MENU_FOLDER },
@@ -61,7 +61,7 @@
 
 #define mutt_check_menu(s) mutt_getvaluebyname(s, Menus)
 
-static struct mapping_t KeyNames[] = {
+static const struct mapping_t KeyNames[] = {
   { "<PageUp>",        KEY_PPAGE },
   { "<PageDown>",      KEY_NPAGE },
   { "<Up>",    KEY_UP },
diff -ru /tmp/mutt-1.5.17cvs/keymap.h /home/dan/src/mutt-1.5.17cvs/keymap.h
--- /tmp/mutt-1.5.17cvs/keymap.h        Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/keymap.h       Thu Mar 27 13:49:24 2008
@@ -87,7 +87,7 @@
 /* dokey() records the last real key pressed  */
 extern int LastKey;
 
-extern struct mapping_t Menus[];
+extern const struct mapping_t Menus[];
 
 struct binding_t
 {
diff -ru /tmp/mutt-1.5.17cvs/lib.c /home/dan/src/mutt-1.5.17cvs/lib.c
--- /tmp/mutt-1.5.17cvs/lib.c   Sat Dec  8 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/lib.c  Thu Mar 27 13:48:34 2008
@@ -51,7 +51,7 @@
 #include "lib.h"
 
 
-static struct sysexits
+static const struct sysexits
 {
   int v;
   const char *str;
@@ -636,7 +636,7 @@
     return (fopen (path, mode));
 }
 
-static char safe_chars[] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/";
+static const char safe_chars[] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/";
 
 void mutt_sanitize_filename (char *f, short slash)
 {
@@ -651,7 +651,7 @@
 
 /* these characters must be escaped in regular expressions */
 
-static char rx_special_chars[] = "^.[$()|*+?{\\";
+static const char rx_special_chars[] = "^.[$()|*+?{\\";
 
 int mutt_rx_sanitize_string (char *dest, size_t destlen, const char *src)
 {
diff -ru /tmp/mutt-1.5.17cvs/mapping.h /home/dan/src/mutt-1.5.17cvs/mapping.h
--- /tmp/mutt-1.5.17cvs/mapping.h       Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/mapping.h      Thu Mar 27 14:16:17 2008
@@ -21,12 +21,12 @@
 
 struct mapping_t
 {
-  char *name;
+  const char *name;
   int value;
 };
 
-char *mutt_getnamebyvalue (int, const struct mapping_t *);
-char *mutt_compile_help (char *, size_t, int, struct mapping_t *);
+const char *mutt_getnamebyvalue (int, const struct mapping_t *);
+char *mutt_compile_help (char *, size_t, int, const struct mapping_t *);
 
 int mutt_getvaluebyname (const char *, const struct mapping_t *);
 
diff -ru /tmp/mutt-1.5.17cvs/mbyte.c /home/dan/src/mutt-1.5.17cvs/mbyte.c
--- /tmp/mutt-1.5.17cvs/mbyte.c Wed Nov 21 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/mbyte.c        Thu Mar 27 14:50:08 2008
@@ -179,8 +179,8 @@
   else
   {
     /* use the real input */
-    ib = s;
-    ibmax = s + n;
+    ib = (ICONV_CONST char *)s;
+    ibmax = (ICONV_CONST char *)s + n;
   }
 
   ob = bufo;
@@ -205,8 +205,8 @@
       else if (k && ib > bufi + k && bufi + k + n > ibmax)
       {
        /* switch to using real input */
-       ib = s + (ib - bufi - k);
-       ibmax = s + n;
+       ib = (ICONV_CONST char *)s + (ib - bufi - k);
+       ibmax = (ICONV_CONST char *)s + n;
        k = 0;
        ++ibl;
       }
diff -ru /tmp/mutt-1.5.17cvs/mime.h /home/dan/src/mutt-1.5.17cvs/mime.h
--- /tmp/mutt-1.5.17cvs/mime.h  Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/mime.h Thu Mar 27 15:31:43 2008
@@ -54,9 +54,9 @@
 /* MIME encoding/decoding global vars */
 
 #ifndef _SENDLIB_C
-extern int Index_hex[];
-extern int Index_64[];
-extern char B64Chars[];
+extern const int Index_hex[];
+extern const int Index_64[];
+extern const char B64Chars[];
 #endif
 
 #define hexval(c) Index_hex[(unsigned int)(c)]
diff -ru /tmp/mutt-1.5.17cvs/mutt_ssl.c /home/dan/src/mutt-1.5.17cvs/mutt_ssl.c
--- /tmp/mutt-1.5.17cvs/mutt_ssl.c      Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/mutt_ssl.c     Thu Mar 27 13:48:03 2008
@@ -590,8 +590,8 @@
 
 static int ssl_check_certificate (sslsockdata * data)
 {
-  char *part[] =
-  {"/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C="};
+  static const char *part[] =
+    {"/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C="};
   char helpstr[LONG_STRING];
   char buf[SHORT_STRING];
   MUTTMENU *menu;
diff -ru /tmp/mutt-1.5.17cvs/pager.c /home/dan/src/mutt-1.5.17cvs/pager.c
--- /tmp/mutt-1.5.17cvs/pager.c Thu Sep  6 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/pager.c        Thu Mar 27 13:47:25 2008
@@ -1476,13 +1476,13 @@
   return cur;
 }
 
-static struct mapping_t PagerHelp[] = {
+static const struct mapping_t PagerHelp[] = {
   { N_("Exit"),        OP_EXIT },
   { N_("PrevPg"), OP_PREV_PAGE },
   { N_("NextPg"), OP_NEXT_PAGE },
   { NULL,      0 }
 };
-static struct mapping_t PagerHelpExtra[] = {
+static const struct mapping_t PagerHelpExtra[] = {
   { N_("View Attachm."), OP_VIEW_ATTACHMENTS },
   { N_("Del"), OP_DELETE },
   { N_("Reply"), OP_REPLY },
diff -ru /tmp/mutt-1.5.17cvs/parse.c /home/dan/src/mutt-1.5.17cvs/parse.c
--- /tmp/mutt-1.5.17cvs/parse.c Sat Dec  1 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/parse.c        Thu Mar 27 13:46:34 2008
@@ -717,7 +717,7 @@
   return buf;
 }
 
-static struct tz_t
+static const struct tz_t
 {
   char tzname[5];
   unsigned char zhours;
diff -ru /tmp/mutt-1.5.17cvs/pattern.c /home/dan/src/mutt-1.5.17cvs/pattern.c
--- /tmp/mutt-1.5.17cvs/pattern.c       Wed Nov 21 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/pattern.c      Thu Mar 27 13:46:20 2008
@@ -46,7 +46,7 @@
 static int eat_range (pattern_t *pat, BUFFER *, BUFFER *);
 static int patmatch (const pattern_t *pat, const char *buf);
 
-struct pattern_flags
+static const struct pattern_flags
 {
   int tag;     /* character used to represent this op */
   int op;      /* operation to perform */
diff -ru /tmp/mutt-1.5.17cvs/pgpkey.c /home/dan/src/mutt-1.5.17cvs/pgpkey.c
--- /tmp/mutt-1.5.17cvs/pgpkey.c        Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/pgpkey.c       Thu Mar 27 13:45:41 2008
@@ -52,7 +52,7 @@
 
 static struct pgp_cache *id_defaults = NULL;
 
-static char trust_flags[] = "?- +";
+static const char trust_flags[] = "?- +";
 
 static char *pgp_key_abilities (int flags)
 {
diff -ru /tmp/mutt-1.5.17cvs/pgpmicalg.c 
/home/dan/src/mutt-1.5.17cvs/pgpmicalg.c
--- /tmp/mutt-1.5.17cvs/pgpmicalg.c     Tue May 29 00:00:08 2007
+++ /home/dan/src/mutt-1.5.17cvs/pgpmicalg.c    Thu Mar 27 13:45:31 2008
@@ -36,7 +36,7 @@
 #include <string.h>
 #include <ctype.h>
 
-static struct 
+static const struct 
 {
   short id;
   const char *name;
diff -ru /tmp/mutt-1.5.17cvs/pop_auth.c /home/dan/src/mutt-1.5.17cvs/pop_auth.c
--- /tmp/mutt-1.5.17cvs/pop_auth.c      Tue Aug 28 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/pop_auth.c     Thu Mar 27 14:54:06 2008
@@ -277,7 +277,7 @@
   return POP_A_FAILURE;
 }
 
-static pop_auth_t pop_authenticators[] = {
+static const pop_auth_t pop_authenticators[] = {
 #ifdef USE_SASL
   { pop_auth_sasl, NULL },
 #endif
@@ -296,7 +296,7 @@
 int pop_authenticate (POP_DATA* pop_data)
 {
   ACCOUNT *acct = &pop_data->conn->account;
-  pop_auth_t* authenticator;
+  const pop_auth_t* authenticator;
   char* methods;
   char* comma;
   char* method;
diff -ru /tmp/mutt-1.5.17cvs/postpone.c /home/dan/src/mutt-1.5.17cvs/postpone.c
--- /tmp/mutt-1.5.17cvs/postpone.c      Tue May 29 00:00:10 2007
+++ /home/dan/src/mutt-1.5.17cvs/postpone.c     Thu Mar 27 13:44:00 2008
@@ -39,7 +39,7 @@
 #include <string.h>
 #include <sys/stat.h>
 
-static struct mapping_t PostponeHelp[] = {
+static const struct mapping_t PostponeHelp[] = {
   { N_("Exit"),  OP_EXIT },
   { N_("Del"),   OP_DELETE },
   { N_("Undel"), OP_UNDELETE },
diff -ru /tmp/mutt-1.5.17cvs/protos.h /home/dan/src/mutt-1.5.17cvs/protos.h
--- /tmp/mutt-1.5.17cvs/protos.h        Fri Nov 16 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/protos.h       Thu Mar 27 14:03:00 2008
@@ -302,7 +302,7 @@
 int  mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
 int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, 
ENTER_STATE *);
 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
-int _mutt_get_field (char *, char *, size_t, int, int, char ***, int *);
+int _mutt_get_field (const char *, char *, size_t, int, int, char ***, int *);
 int mutt_get_hook_type (const char *);
 int mutt_get_field_unbuffered (char *, char *, size_t, int);
 #define mutt_get_password(A,B,C) mutt_get_field_unbuffered(A,B,C,M_PASS)
diff -ru /tmp/mutt-1.5.17cvs/query.c /home/dan/src/mutt-1.5.17cvs/query.c
--- /tmp/mutt-1.5.17cvs/query.c Wed Jan 16 00:00:05 2008
+++ /home/dan/src/mutt-1.5.17cvs/query.c        Thu Mar 27 13:44:10 2008
@@ -45,7 +45,7 @@
   QUERY *data;
 } ENTRY;
 
-static struct mapping_t QueryHelp[] = {
+static const struct mapping_t QueryHelp[] = {
   { N_("Exit"),   OP_EXIT },
   { N_("Mail"),   OP_MAIL },
   { N_("New Query"),  OP_QUERY },
diff -ru /tmp/mutt-1.5.17cvs/recvattach.c 
/home/dan/src/mutt-1.5.17cvs/recvattach.c
--- /tmp/mutt-1.5.17cvs/recvattach.c    Wed Jan 16 00:00:05 2008
+++ /home/dan/src/mutt-1.5.17cvs/recvattach.c   Thu Mar 27 13:43:00 2008
@@ -50,7 +50,7 @@
     break; \
 }
 
-static struct mapping_t AttachHelp[] = {
+static const struct mapping_t AttachHelp[] = {
   { N_("Exit"),  OP_EXIT },
   { N_("Save"),  OP_SAVE },
   { N_("Pipe"),  OP_PIPE },
diff -ru /tmp/mutt-1.5.17cvs/remailer.c /home/dan/src/mutt-1.5.17cvs/remailer.c
--- /tmp/mutt-1.5.17cvs/remailer.c      Tue May 29 00:00:10 2007
+++ /home/dan/src/mutt-1.5.17cvs/remailer.c     Thu Mar 27 13:42:20 2008
@@ -480,7 +480,7 @@
   return 0;
 }
 
-static struct mapping_t RemailerHelp[] = 
+static const struct mapping_t RemailerHelp[] = 
 {
   { N_("Append"), OP_MIX_APPEND },
   { N_("Insert"), OP_MIX_INSERT },
diff -ru /tmp/mutt-1.5.17cvs/rfc2047.c /home/dan/src/mutt-1.5.17cvs/rfc2047.c
--- /tmp/mutt-1.5.17cvs/rfc2047.c       Tue May 29 00:00:10 2007
+++ /home/dan/src/mutt-1.5.17cvs/rfc2047.c      Thu Mar 27 13:42:06 2008
@@ -234,7 +234,7 @@
 static size_t q_encoder (char *s, ICONV_CONST char *d, size_t dlen,
                         const char *tocode)
 {
-  char hex[] = "0123456789ABCDEF";
+  static const char hex[] = "0123456789ABCDEF";
   char *s0 = s;
 
   memcpy (s, "=?", 2), s += 2;
diff -ru /tmp/mutt-1.5.17cvs/sendlib.c /home/dan/src/mutt-1.5.17cvs/sendlib.c
--- /tmp/mutt-1.5.17cvs/sendlib.c       Sat Dec  1 00:00:05 2007
+++ /home/dan/src/mutt-1.5.17cvs/sendlib.c      Thu Mar 27 15:10:27 2008
@@ -66,7 +66,7 @@
 
 const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
 
-char B64Chars[64] = {
+const char B64Chars[64] = {
   'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
   'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
   'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
diff -ru /tmp/mutt-1.5.17cvs/url.c /home/dan/src/mutt-1.5.17cvs/url.c
--- /tmp/mutt-1.5.17cvs/url.c   Mon Nov  5 00:00:07 2007
+++ /home/dan/src/mutt-1.5.17cvs/url.c  Thu Mar 27 13:39:25 2008
@@ -32,7 +32,7 @@
 
 #include <ctype.h>
 
-static struct mapping_t UrlMap[] =
+static const struct mapping_t UrlMap[] =
 {
   { "file",    U_FILE },
   { "imap",    U_IMAP },