changeset: 6651:f1f1af650910
user:      Kevin McCarthy <ke...@8t8.us>
date:      Tue May 24 12:08:46 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/f1f1af650910

Fix infinite loop when help is bound to a named key combination.

Commit a07e8215a0ef introduced a bug in km_error_key, which is called
when an unbound key is pressed.

If help is bound to a sequence containing named keys (e.g. <esc>), the
raw (untokenized) string would be pushed back into the unget buffer.
This could lead to an infinite loop of unbound key presses triggering
more unbound keys being put into the unget buffer.

Change km_error_key to tokenize the string before putting it in the unget 
buffer.

Much thanks to Jiri Bohac for his bug report, analysis, and initial patch!

changeset: 6652:79c379cb0c21
user:      Kevin McCarthy <ke...@8t8.us>
date:      Tue May 24 12:45:21 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/79c379cb0c21

merge stable

diffs (truncated from 13298 to 950 lines):

diff -r e3bc23cbe3d1 -r 79c379cb0c21 Makefile.am
--- a/Makefile.am       Sat Apr 30 14:25:49 2016 -0700
+++ b/Makefile.am       Tue May 24 12:45:21 2016 -0700
@@ -72,7 +72,7 @@
        README.SSL smime.h group.h \
        muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
        ChangeLog mkchangelog.sh mutt_idna.h \
-       snprintf.c regex.c crypt-gpgme.h hcachever.sh.in sys_socket.h \
+       snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
        txt2c.c txt2c.sh version.sh check_sec.sh
 
 EXTRA_SCRIPTS = smime_keys
diff -r e3bc23cbe3d1 -r 79c379cb0c21 account.c
--- a/account.c Sat Apr 30 14:25:49 2016 -0700
+++ b/account.c Tue May 24 12:45:21 2016 -0700
@@ -39,7 +39,7 @@
     return 0;
 
 #ifdef USE_IMAP
-  if (a1->type == M_ACCT_TYPE_IMAP)
+  if (a1->type == MUTT_ACCT_TYPE_IMAP)
   {
     if (ImapUser)
       user = ImapUser;
@@ -47,15 +47,15 @@
 #endif
 
 #ifdef USE_POP
-  if (a1->type == M_ACCT_TYPE_POP && PopUser)
+  if (a1->type == MUTT_ACCT_TYPE_POP && PopUser)
     user = PopUser;
 #endif
   
-  if (a1->flags & a2->flags & M_ACCT_USER)
+  if (a1->flags & a2->flags & MUTT_ACCT_USER)
     return (!strcmp (a1->user, a2->user));
-  if (a1->flags & M_ACCT_USER)
+  if (a1->flags & MUTT_ACCT_USER)
     return (!strcmp (a1->user, user));
-  if (a2->flags & M_ACCT_USER)
+  if (a2->flags & MUTT_ACCT_USER)
     return (!strcmp (a2->user, user));
 
   return 1;
@@ -73,17 +73,17 @@
   if (url->user)
   {
     strfcpy (account->user, url->user, sizeof (account->user));
-    account->flags |= M_ACCT_USER;
+    account->flags |= MUTT_ACCT_USER;
   }
   if (url->pass)
   {
     strfcpy (account->pass, url->pass, sizeof (account->pass));
-    account->flags |= M_ACCT_PASS;
+    account->flags |= MUTT_ACCT_PASS;
   }
   if (url->port)
   {
     account->port = url->port;
-    account->flags |= M_ACCT_PORT;
+    account->flags |= MUTT_ACCT_PORT;
   }
 
   return 0;
@@ -101,9 +101,9 @@
   url->port = 0;
 
 #ifdef USE_IMAP
-  if (account->type == M_ACCT_TYPE_IMAP)
+  if (account->type == MUTT_ACCT_TYPE_IMAP)
   {
-    if (account->flags & M_ACCT_SSL)
+    if (account->flags & MUTT_ACCT_SSL)
       url->scheme = U_IMAPS;
     else
       url->scheme = U_IMAP;
@@ -111,9 +111,9 @@
 #endif
 
 #ifdef USE_POP
-  if (account->type == M_ACCT_TYPE_POP)
+  if (account->type == MUTT_ACCT_TYPE_POP)
   {
-    if (account->flags & M_ACCT_SSL)
+    if (account->flags & MUTT_ACCT_SSL)
       url->scheme = U_POPS;
     else
       url->scheme = U_POP;
@@ -121,9 +121,9 @@
 #endif
 
 #ifdef USE_SMTP
-  if (account->type == M_ACCT_TYPE_SMTP)
+  if (account->type == MUTT_ACCT_TYPE_SMTP)
   {
-    if (account->flags & M_ACCT_SSL)
+    if (account->flags & MUTT_ACCT_SSL)
       url->scheme = U_SMTPS;
     else
       url->scheme = U_SMTP;
@@ -131,11 +131,11 @@
 #endif
 
   url->host = account->host;
-  if (account->flags & M_ACCT_PORT)
+  if (account->flags & MUTT_ACCT_PORT)
     url->port = account->port;
-  if (account->flags & M_ACCT_USER)
+  if (account->flags & MUTT_ACCT_USER)
     url->user = account->user;
-  if (account->flags & M_ACCT_PASS)
+  if (account->flags & MUTT_ACCT_PASS)
     url->pass = account->pass;
 }
 
@@ -145,14 +145,14 @@
   char prompt[SHORT_STRING];
 
   /* already set */
-  if (account->flags & M_ACCT_USER)
+  if (account->flags & MUTT_ACCT_USER)
     return 0;
 #ifdef USE_IMAP
-  else if ((account->type == M_ACCT_TYPE_IMAP) && ImapUser)
+  else if ((account->type == MUTT_ACCT_TYPE_IMAP) && ImapUser)
     strfcpy (account->user, ImapUser, sizeof (account->user));
 #endif
 #ifdef USE_POP
-  else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
+  else if ((account->type == MUTT_ACCT_TYPE_POP) && PopUser)
     strfcpy (account->user, PopUser, sizeof (account->user));
 #endif
   else if (option (OPTNOCURSES))
@@ -166,7 +166,7 @@
       return -1;
   }
 
-  account->flags |= M_ACCT_USER;
+  account->flags |= MUTT_ACCT_USER;
 
   return 0;
 }
@@ -174,26 +174,26 @@
 int mutt_account_getlogin (ACCOUNT* account)
 {
   /* already set */
-  if (account->flags & M_ACCT_LOGIN)
+  if (account->flags & MUTT_ACCT_LOGIN)
     return 0;
 #ifdef USE_IMAP
-  else if (account->type == M_ACCT_TYPE_IMAP)
+  else if (account->type == MUTT_ACCT_TYPE_IMAP)
   {
     if (ImapLogin)
     {
       strfcpy (account->login, ImapLogin, sizeof (account->login));
-      account->flags |= M_ACCT_LOGIN;
+      account->flags |= MUTT_ACCT_LOGIN;
     }
   }
 #endif
 
-  if (!(account->flags & M_ACCT_LOGIN))
+  if (!(account->flags & MUTT_ACCT_LOGIN))
   {
     mutt_account_getuser (account);
     strfcpy (account->login, account->user, sizeof (account->login));
   }
 
-  account->flags |= M_ACCT_LOGIN;
+  account->flags |= MUTT_ACCT_LOGIN;
 
   return 0;
 }
@@ -203,18 +203,18 @@
 {
   char prompt[SHORT_STRING];
 
-  if (account->flags & M_ACCT_PASS)
+  if (account->flags & MUTT_ACCT_PASS)
     return 0;
 #ifdef USE_IMAP
-  else if ((account->type == M_ACCT_TYPE_IMAP) && ImapPass)
+  else if ((account->type == MUTT_ACCT_TYPE_IMAP) && ImapPass)
     strfcpy (account->pass, ImapPass, sizeof (account->pass));
 #endif
 #ifdef USE_POP
-  else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
+  else if ((account->type == MUTT_ACCT_TYPE_POP) && PopPass)
     strfcpy (account->pass, PopPass, sizeof (account->pass));
 #endif
 #ifdef USE_SMTP
-  else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
+  else if ((account->type == MUTT_ACCT_TYPE_SMTP) && SmtpPass)
     strfcpy (account->pass, SmtpPass, sizeof (account->pass));
 #endif
   else if (option (OPTNOCURSES))
@@ -222,19 +222,19 @@
   else
   {
     snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
-              account->flags & M_ACCT_LOGIN ? account->login : account->user,
+              account->flags & MUTT_ACCT_LOGIN ? account->login : 
account->user,
               account->host);
     account->pass[0] = '\0';
     if (mutt_get_password (prompt, account->pass, sizeof (account->pass)))
       return -1;
   }
 
-  account->flags |= M_ACCT_PASS;
+  account->flags |= MUTT_ACCT_PASS;
 
   return 0;
 }
 
 void mutt_account_unsetpass (ACCOUNT* account)
 {
-  account->flags &= ~M_ACCT_PASS;
+  account->flags &= ~MUTT_ACCT_PASS;
 }
diff -r e3bc23cbe3d1 -r 79c379cb0c21 account.h
--- a/account.h Sat Apr 30 14:25:49 2016 -0700
+++ b/account.h Tue May 24 12:45:21 2016 -0700
@@ -26,18 +26,18 @@
 /* account types */
 enum
 {
-  M_ACCT_TYPE_NONE = 0,
-  M_ACCT_TYPE_IMAP,
-  M_ACCT_TYPE_POP,
-  M_ACCT_TYPE_SMTP
+  MUTT_ACCT_TYPE_NONE = 0,
+  MUTT_ACCT_TYPE_IMAP,
+  MUTT_ACCT_TYPE_POP,
+  MUTT_ACCT_TYPE_SMTP
 };
 
 /* account flags */
-#define M_ACCT_PORT  (1<<0)
-#define M_ACCT_USER  (1<<1)
-#define M_ACCT_LOGIN (1<<2)
-#define M_ACCT_PASS  (1<<3)
-#define M_ACCT_SSL   (1<<4)
+#define MUTT_ACCT_PORT  (1<<0)
+#define MUTT_ACCT_USER  (1<<1)
+#define MUTT_ACCT_LOGIN (1<<2)
+#define MUTT_ACCT_PASS  (1<<3)
+#define MUTT_ACCT_SSL   (1<<4)
 
 typedef struct
 {
diff -r e3bc23cbe3d1 -r 79c379cb0c21 addrbook.c
--- a/addrbook.c        Sat Apr 30 14:25:49 2016 -0700
+++ b/addrbook.c        Tue May 24 12:45:21 2016 -0700
@@ -43,7 +43,7 @@
 };
 
 static const char *
-alias_format_str (char *dest, size_t destlen, size_t col, char op, const char 
*src,
+alias_format_str (char *dest, size_t destlen, size_t col, int cols, char op, 
const char *src,
                  const char *fmt, const char *ifstring, const char *elsestring,
                  unsigned long data, format_flag flags)
 {
@@ -80,7 +80,7 @@
 
 static void alias_entry (char *s, size_t slen, MUTTMENU *m, int num)
 {
-  mutt_FormatString (s, slen, 0, NONULL (AliasFmt), alias_format_str, 
(unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL (AliasFmt), 
alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], 
MUTT_FORMAT_ARROWCURSOR);
 }
 
 static int alias_tag (MUTTMENU *menu, int n, int m)
diff -r e3bc23cbe3d1 -r 79c379cb0c21 alias.c
--- a/alias.c   Sat Apr 30 14:25:49 2016 -0700
+++ b/alias.c   Tue May 24 12:45:21 2016 -0700
@@ -269,9 +269,9 @@
   
   if (mutt_check_alias_name (buf, fixed, sizeof (fixed)))
   {
-    switch (mutt_yesorno (_("Warning: This alias name may not work.  Fix 
it?"), M_YES))
+    switch (mutt_yesorno (_("Warning: This alias name may not work.  Fix 
it?"), MUTT_YES))
     {
-      case M_YES:
+      case MUTT_YES:
        strfcpy (buf, fixed, sizeof (buf));
        goto retry_name;
       case -1: 
@@ -326,7 +326,7 @@
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), new->addr, 1);
   snprintf (prompt, sizeof (prompt), _("[%s = %s] Accept?"), new->name, buf);
-  if (mutt_yesorno (prompt, M_YES) != M_YES)
+  if (mutt_yesorno (prompt, MUTT_YES) != MUTT_YES)
   {
     mutt_free_alias (&new);
     return;
@@ -344,7 +344,7 @@
     Aliases = new;
 
   strfcpy (buf, NONULL (AliasFile), sizeof (buf));
-  if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), M_FILE) != 0)
+  if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), MUTT_FILE) != 0)
     return;
   mutt_expand_path (buf, sizeof (buf));
   if ((rc = fopen (buf, "a+")))
@@ -423,6 +423,8 @@
     {
       if (dry)
        return -1;
+      if (l == (size_t)(-1))
+        memset (&mb, 0, sizeof (mbstate_t));
       *dest++ = '_';
       rv = -1;
     }
diff -r e3bc23cbe3d1 -r 79c379cb0c21 attach.c
--- a/attach.c  Sat Apr 30 14:25:49 2016 -0700
+++ b/attach.c  Tue May 24 12:45:21 2016 -0700
@@ -94,7 +94,7 @@
   int rc = 0;
   
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
-  if (rfc1524_mailcap_lookup (a, type, entry, M_COMPOSE))
+  if (rfc1524_mailcap_lookup (a, type, entry, MUTT_COMPOSE))
   {
     if (entry->composecommand || entry->composetypecommand)
     {
@@ -110,7 +110,7 @@
                                  a->filename, newfile));
        if (safe_symlink (a->filename, newfile) == -1)
        {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != 
M_YES)
+         if (mutt_yesorno (_("Can't match nametemplate, continue?"), MUTT_YES) 
!= MUTT_YES)
            goto bailout;
        }
        else
@@ -229,7 +229,7 @@
   int rc = 0;
   
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
-  if (rfc1524_mailcap_lookup (a, type, entry, M_EDIT))
+  if (rfc1524_mailcap_lookup (a, type, entry, MUTT_EDIT))
   {
     if (entry->editcommand)
     {
@@ -242,7 +242,7 @@
                                  a->filename, newfile));
        if (safe_symlink (a->filename, newfile) == -1)
        {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != 
M_YES)
+         if (mutt_yesorno (_("Can't match nametemplate, continue?"), MUTT_YES) 
!= MUTT_YES)
            goto bailout;
        }
        else
@@ -350,8 +350,8 @@
   if (WithCrypto && is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
       !crypt_valid_passphrase(a->hdr->security))
     return (rc);
-  use_mailcap = (flag == M_MAILCAP ||
-               (flag == M_REGULAR && mutt_needs_mailcap (a)));
+  use_mailcap = (flag == MUTT_MAILCAP ||
+               (flag == MUTT_REGULAR && mutt_needs_mailcap (a)));
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
   
   if (use_mailcap)
@@ -359,12 +359,12 @@
     entry = rfc1524_new_entry (); 
     if (!rfc1524_mailcap_lookup (a, type, entry, 0))
     {
-      if (flag == M_REGULAR)
+      if (flag == MUTT_REGULAR)
       {
        /* fallback to view as text */
        rfc1524_free_entry (&entry);
        mutt_error _("No matching mailcap entry found.  Viewing as text.");
-       flag = M_AS_TEXT;
+       flag = MUTT_AS_TEXT;
        use_mailcap = 0;
       }
       else
@@ -397,7 +397,7 @@
        /* send case: the file is already there */
        if (safe_symlink (a->filename, tempfile) == -1)
        {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) == 
M_YES)
+         if (mutt_yesorno (_("Can't match nametemplate, continue?"), MUTT_YES) 
== MUTT_YES)
            strfcpy (tempfile, a->filename, sizeof (tempfile));
          else
            goto return_error;
@@ -502,7 +502,7 @@
   {
     /* Don't use mailcap; the attachment is viewed in the pager */
 
-    if (flag == M_AS_TEXT)
+    if (flag == MUTT_AS_TEXT)
     {
       /* just let me see the raw data */
       if (fp)
@@ -524,7 +524,7 @@
          goto return_error;
        }
        decode_state.fpin = fp;
-       decode_state.flags = M_CHARCONV;
+       decode_state.flags = MUTT_CHARCONV;
        mutt_decode_attachment(a, &decode_state);
        if (fclose(decode_state.fpout) == EOF)
          dprint(1, (debugfile, "mutt_view_attachment:%d fclose errno=%d %s\n", 
__LINE__, pagerfile, errno, strerror(errno)));
@@ -544,7 +544,7 @@
       /* Use built-in handler */
       set_option (OPTVIEWATTACH); /* disable the "use 'v' to view this part"
                                   * message in case of error */
-      if (mutt_decode_save_attachment (fp, a, pagerfile, M_DISPLAY, 0))
+      if (mutt_decode_save_attachment (fp, a, pagerfile, MUTT_DISPLAY, 0))
       {
        unset_option (OPTVIEWATTACH);
        goto return_error;
@@ -576,7 +576,7 @@
     info.hdr = hdr;
 
     rc = mutt_do_pager (descrip, pagerfile,
-                       M_PAGER_ATTACHMENT | (is_message ? M_PAGER_MESSAGE : 
0), &info);
+                       MUTT_PAGER_ATTACHMENT | (is_message ? 
MUTT_PAGER_MESSAGE : 0), &info);
     *pagerfile = '\0';
   }
   else
@@ -691,9 +691,9 @@
 static FILE *
 mutt_save_attachment_open (char *path, int flags)
 {
-  if (flags == M_SAVE_APPEND)
+  if (flags == MUTT_SAVE_APPEND)
     return fopen (path, "a");
-  if (flags == M_SAVE_OVERWRITE)
+  if (flags == MUTT_SAVE_OVERWRITE)
     return fopen (path, "w");          /* __FOPEN_CHECKED__ */
   
   return safe_fopen (path, "w");
@@ -729,16 +729,16 @@
       fseeko (fp, m->offset, 0);
       if (fgets (buf, sizeof (buf), fp) == NULL)
        return -1;
-      if (mx_open_mailbox(path, M_APPEND | M_QUIET, &ctx) == NULL)
+      if (mx_open_mailbox(path, MUTT_APPEND | MUTT_QUIET, &ctx) == NULL)
        return -1;
-      if ((msg = mx_open_new_message (&ctx, hn, is_from (buf, NULL, 0, NULL) ? 
0 : M_ADD_FROM)) == NULL)
+      if ((msg = mx_open_new_message (&ctx, hn, is_from (buf, NULL, 0, NULL) ? 
0 : MUTT_ADD_FROM)) == NULL)
       {
        mx_close_mailbox(&ctx, NULL);
        return -1;
       }
-      if (ctx.magic == M_MBOX || ctx.magic == M_MMDF)
+      if (ctx.magic == MUTT_MBOX || ctx.magic == MUTT_MMDF)
        chflags = CH_FROM | CH_UPDATE_LEN;
-      chflags |= (ctx.magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
+      chflags |= (ctx.magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
       if (_mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags) == 0 
          && mx_commit_message (msg, &ctx) == 0)
        r = 0;
@@ -818,9 +818,9 @@
   memset (&s, 0, sizeof (s));
   s.flags = displaying;
 
-  if (flags == M_SAVE_APPEND)
+  if (flags == MUTT_SAVE_APPEND)
     s.fpout = fopen (path, "a");
-  else if (flags == M_SAVE_OVERWRITE)
+  else if (flags == MUTT_SAVE_OVERWRITE)
     s.fpout = fopen (path, "w");       /* __FOPEN_CHECKED__ */
   else
     s.fpout = safe_fopen (path, "w");
@@ -861,12 +861,12 @@
     mutt_parse_part (s.fpin, m);
 
     if (m->noconv || is_multipart (m))
-      s.flags |= M_CHARCONV;
+      s.flags |= MUTT_CHARCONV;
   }
   else
   {
     s.fpin = fp;
-    s.flags |= M_CHARCONV;
+    s.flags |= MUTT_CHARCONV;
   }
 
   mutt_body_handler (m, &s);
@@ -905,7 +905,7 @@
   
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
 
-  if (rfc1524_mailcap_lookup (a, type, NULL, M_PRINT)) 
+  if (rfc1524_mailcap_lookup (a, type, NULL, MUTT_PRINT)) 
   {
     char command[_POSIX_PATH_MAX+STRING];
     rfc1524_entry *entry;
@@ -914,7 +914,7 @@
     dprint (2, (debugfile, "Using mailcap...\n"));
     
     entry = rfc1524_new_entry ();
-    rfc1524_mailcap_lookup (a, type, entry, M_PRINT);
+    rfc1524_mailcap_lookup (a, type, entry, MUTT_PRINT);
     if (rfc1524_expand_filename (entry->nametemplate, a->filename,
                                                  newfile, sizeof (newfile)))
     {
@@ -922,7 +922,7 @@
       {
        if (safe_symlink(a->filename, newfile) == -1)
        {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != 
M_YES)
+         if (mutt_yesorno (_("Can't match nametemplate, continue?"), MUTT_YES) 
!= MUTT_YES)
          {
            rfc1524_free_entry (&entry);
            return 0;
@@ -996,7 +996,7 @@
     fpout = NULL;
     
     mutt_mktemp (newfile, sizeof (newfile));
-    if (mutt_decode_save_attachment (fp, a, newfile, M_PRINTING, 0) == 0)
+    if (mutt_decode_save_attachment (fp, a, newfile, MUTT_PRINTING, 0) == 0)
     {
       
       dprint (2, (debugfile, "successfully decoded %s type attachment to %s\n",
diff -r e3bc23cbe3d1 -r 79c379cb0c21 browser.c
--- a/browser.c Sat Apr 30 14:25:49 2016 -0700
+++ b/browser.c Tue May 24 12:45:21 2016 -0700
@@ -142,7 +142,7 @@
 }
 
 static const char *
-folder_format_str (char *dest, size_t destlen, size_t col, char op, const char 
*src,
+folder_format_str (char *dest, size_t destlen, size_t col, int cols, char op, 
const char *src,
                   const char *fmt, const char *ifstring, const char 
*elsestring,
                   unsigned long data, format_flag flags)
 {
@@ -152,7 +152,7 @@
   FOLDER *folder = (FOLDER *) data;
   struct passwd *pw;
   struct group *gr;
-  int optional = (flags & M_FORMAT_OPTIONAL);
+  int optional = (flags & MUTT_FORMAT_OPTIONAL);
 
   switch (op)
   {
@@ -317,9 +317,9 @@
   }
 
   if (optional)
-    mutt_FormatString (dest, destlen, col, ifstring, folder_format_str, data, 
0);
-  else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, col, elsestring, folder_format_str, 
data, 0);
+    mutt_FormatString (dest, destlen, col, cols, ifstring, folder_format_str, 
data, 0);
+  else if (flags & MUTT_FORMAT_OPTIONAL)
+    mutt_FormatString (dest, destlen, col, cols, elsestring, 
folder_format_str, data, 0);
 
   return (src);
 }
@@ -515,8 +515,8 @@
   folder.ff = &((struct folder_file *) menu->data)[num];
   folder.num = num;
   
-  mutt_FormatString (s, slen, 0, NONULL(FolderFormat), folder_format_str, 
-      (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat), 
folder_format_str, 
+      (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
 }
 
 static void init_menu (struct browser_state *state, MUTTMENU *menu, char 
*title,
@@ -579,9 +579,9 @@
   MUTTMENU *menu;
   struct stat st;
   int i, killPrefix = 0;
-  int multiple = (flags & M_SEL_MULTI)  ? 1 : 0;
-  int folder   = (flags & M_SEL_FOLDER) ? 1 : 0;
-  int buffy    = (flags & M_SEL_BUFFY)  ? 1 : 0;
+  int multiple = (flags & MUTT_SEL_MULTI)  ? 1 : 0;
+  int folder   = (flags & MUTT_SEL_FOLDER) ? 1 : 0;
+  int buffy    = (flags & MUTT_SEL_BUFFY)  ? 1 : 0;
 
   buffy = buffy && folder;
   
@@ -964,7 +964,7 @@
          }
          snprintf (msg, sizeof (msg), _("Really delete mailbox \"%s\"?"),
             mx.mbox);
-         if (mutt_yesorno (msg, M_NO) == M_YES)
+         if (mutt_yesorno (msg, MUTT_NO) == MUTT_YES)
           {
            if (!imap_delete_mailbox (Context, mx))
             {
@@ -1001,7 +1001,7 @@
            buf[len]='/';
        }
 
-       if (mutt_get_field (_("Chdir to: "), buf, sizeof (buf), M_FILE) == 0 &&
+       if (mutt_get_field (_("Chdir to: "), buf, sizeof (buf), MUTT_FILE) == 0 
&&
            buf[0])
        {
          buffy = 0;      
@@ -1205,7 +1205,7 @@
       case OP_BROWSER_NEW_FILE:
 
        snprintf (buf, sizeof (buf), "%s/", LastDir);
-       if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) == 
0)
+       if (mutt_get_field (_("New file name: "), buf, sizeof (buf), MUTT_FILE) 
== 0)
        {
          strfcpy (f, buf, flen);
          destroy_state (&state);
@@ -1248,7 +1248,7 @@
          b = mutt_make_file_attach (buf);
          if (b != NULL)
          {
-           mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
+           mutt_view_attachment (NULL, b, MUTT_REGULAR, NULL, NULL, 0);
            mutt_free_body (&b);
            menu->redraw = REDRAW_FULL;
          }
diff -r e3bc23cbe3d1 -r 79c379cb0c21 buffy.c
--- a/buffy.c   Sat Apr 30 14:25:49 2016 -0700
+++ b/buffy.c   Tue May 24 12:45:21 2016 -0700
@@ -124,7 +124,7 @@
 
   typ = mx_get_magic (path);
 
-  if (typ != M_MBOX && typ != M_MMDF)
+  if (typ != MUTT_MBOX && typ != MUTT_MMDF)
     return 0;
 
   if ((f = fopen (path, "rb")))
@@ -223,7 +223,7 @@
     mutt_extract_token (path, s, 0);
     strfcpy (buf, path->data, sizeof (buf));
 
-    if(data == M_UNMAILBOXES && mutt_strcmp(buf,"*") == 0)
+    if(data == MUTT_UNMAILBOXES && mutt_strcmp(buf,"*") == 0)
     {
       for (tmp = &Incoming; *tmp;)
       {
@@ -251,7 +251,7 @@
       }
     }
 
-    if(data == M_UNMAILBOXES)
+    if(data == MUTT_UNMAILBOXES)
     {
       if(*tmp)
       {
@@ -421,7 +421,7 @@
 #endif
 
   /* check device ID and serial number instead of comparing paths */
-  if (!Context || Context->magic == M_IMAP || Context->magic == M_POP
+  if (!Context || Context->magic == MUTT_IMAP || Context->magic == MUTT_POP
       || stat (Context->path, &contex_sb) != 0)
   {
     contex_sb.st_dev=0;
@@ -430,12 +430,12 @@
   
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
-    if (tmp->magic != M_IMAP)
+    if (tmp->magic != MUTT_IMAP)
     {
       tmp->new = 0;
 #ifdef USE_POP
       if (mx_is_pop (tmp->path))
-       tmp->magic = M_POP;
+       tmp->magic = MUTT_POP;
       else
 #endif
       if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 
0) ||
@@ -453,24 +453,24 @@
     /* check to see if the folder is the currently selected folder
      * before polling */
     if (!Context || !Context->path ||
-       (( tmp->magic == M_IMAP || tmp->magic == M_POP )
+       (( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP )
            ? mutt_strcmp (tmp->path, Context->path) :
              (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
     {
       switch (tmp->magic)
       {
-      case M_MBOX:
-      case M_MMDF:
+      case MUTT_MBOX:
+      case MUTT_MMDF:
        if (buffy_mbox_hasnew (tmp, &sb) > 0)
          BuffyCount++;
        break;
 
-      case M_MAILDIR:
+      case MUTT_MAILDIR:
        if (buffy_maildir_hasnew (tmp) > 0)
          BuffyCount++;
        break;
 
-      case M_MH:
+      case MUTT_MH:
        mh_buffy(tmp);
        if (tmp->new)
          BuffyCount++;
@@ -511,7 +511,8 @@
     strfcpy (path, tmp->path, sizeof (path));
     mutt_pretty_mailbox (path, sizeof (path));
     
-    if (!first && (COLS - 7 >= 0) && (pos + strlen (path) >= (size_t)COLS - 7))
+    if (!first && (MuttMessageWindow->cols >= 7) &&
+        (pos + strlen (path) >= (size_t)MuttMessageWindow->cols - 7))
       break;
     
     if (!first)
diff -r e3bc23cbe3d1 -r 79c379cb0c21 buffy.h
--- a/buffy.h   Sat Apr 30 14:25:49 2016 -0700
+++ b/buffy.h   Tue May 24 12:45:21 2016 -0700
@@ -17,8 +17,8 @@
  */
 
 /*parameter to mutt_parse_mailboxes*/
-#define M_MAILBOXES   1
-#define M_UNMAILBOXES 2 
+#define MUTT_MAILBOXES   1
+#define MUTT_UNMAILBOXES 2 
 
 typedef struct buffy_t
 {
diff -r e3bc23cbe3d1 -r 79c379cb0c21 charset.c
--- a/charset.c Sat Apr 30 14:25:49 2016 -0700
+++ b/charset.c Tue May 24 12:45:21 2016 -0700
@@ -349,15 +349,15 @@
 /*
  * Like iconv_open, but canonicalises the charsets, applies
  * charset-hooks, recanonicalises, and finally applies iconv-hooks.
- * Parameter flags=0 skips charset-hooks, while M_ICONV_HOOK_FROM
+ * Parameter flags=0 skips charset-hooks, while MUTT_ICONV_HOOK_FROM
  * applies them to fromcode. Callers should use flags=0 when fromcode
  * can safely be considered true, either some constant, or some value
- * provided by the user; M_ICONV_HOOK_FROM should be used only when
+ * provided by the user; MUTT_ICONV_HOOK_FROM should be used only when
  * fromcode is unsure, taken from a possibly wrong incoming MIME label,
- * or such. Misusing M_ICONV_HOOK_FROM leads to unwanted interactions
+ * or such. Misusing MUTT_ICONV_HOOK_FROM leads to unwanted interactions
  * in some setups. Note: By design charset-hooks should never be, and
  * are never, applied to tocode. Highlight note: The top-well-named
- * M_ICONV_HOOK_FROM acts on charset-hooks, not at all on iconv-hooks.
+ * MUTT_ICONV_HOOK_FROM acts on charset-hooks, not at all on iconv-hooks.
  */
 
 iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags)
@@ -376,7 +376,7 @@
   /* maybe apply charset-hooks and recanonicalise fromcode,
    * but only when caller asked us to sanitize a potentialy wrong
    * charset name incoming from the wild exterior. */
-  if ((flags & M_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook (fromcode1)))
+  if ((flags & MUTT_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook (fromcode1)))
     mutt_canonical_charset (fromcode1, sizeof (fromcode1), tmp);
 
   /* always apply iconv-hooks to suit system's iconv tastes */
diff -r e3bc23cbe3d1 -r 79c379cb0c21 charset.h
--- a/charset.h Sat Apr 30 14:25:49 2016 -0700
+++ b/charset.h Tue May 24 12:45:21 2016 -0700
@@ -51,10 +51,10 @@
 
 /* flags for charset.c:mutt_convert_string(), fgetconv_open(), and
  * mutt_iconv_open(). Note that applying charset-hooks to tocode is
- * never needed, and sometimes hurts: Hence there is no M_ICONV_HOOK_TO
+ * never needed, and sometimes hurts: Hence there is no MUTT_ICONV_HOOK_TO
  * flag.
  */
-#define M_ICONV_HOOK_FROM 1    /* apply charset-hooks to fromcode */
+#define MUTT_ICONV_HOOK_FROM 1 /* apply charset-hooks to fromcode */
 
 /* Check if given character set is valid (either officially assigned or
  * known to local iconv implementation). If strict is non-zero, check
diff -r e3bc23cbe3d1 -r 79c379cb0c21 color.c
--- a/color.c   Sat Apr 30 14:25:49 2016 -0700
+++ b/color.c   Tue May 24 12:45:21 2016 -0700
@@ -549,7 +549,7 @@
 
       strfcpy(buf, NONULL(s), sizeof(buf));
       mutt_check_simple (buf, sizeof (buf), NONULL(SimpleSearch));
-      if((tmp->color_pattern = mutt_pattern_comp (buf, M_FULL_MSG, err)) == 
NULL)
+      if((tmp->color_pattern = mutt_pattern_comp (buf, MUTT_FULL_MSG, err)) == 
NULL)
       {
        mutt_free_color_line(&tmp, 1);
        return -1;
diff -r e3bc23cbe3d1 -r 79c379cb0c21 commands.c
--- a/commands.c        Sat Apr 30 14:25:49 2016 -0700
+++ b/commands.c        Tue May 24 12:45:21 2016 -0700
@@ -60,7 +60,7 @@
 {
   char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
   int rc = 0, builtin = 0;
-  int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV;
+  int cmflags = MUTT_CM_DECODE | MUTT_CM_DISPLAY | MUTT_CM_CHARCONV;
   FILE *fpout = NULL;
   FILE *fpfilterout = NULL;
   pid_t filterpid = -1;
@@ -70,7 +70,7 @@
            cur->content->subtype);
 
   mutt_parse_mime_message (Context, cur);
-  mutt_message_hook (Context, cur, M_MESSAGEHOOK);
+  mutt_message_hook (Context, cur, MUTT_MESSAGEHOOK);
 
   /* see if crypto is needed for this message.  if so, we should exit curses */
   if (WithCrypto && cur->security)
@@ -82,19 +82,19 @@
       if(!crypt_valid_passphrase(cur->security))
        return 0;
 
-      cmflags |= M_CM_VERIFY;
+      cmflags |= MUTT_CM_VERIFY;
     }
     else if (cur->security & SIGN)
     {
       /* find out whether or not the verify signature */
-      if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == 
M_YES)
+      if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == 
MUTT_YES)
       {
-       cmflags |= M_CM_VERIFY;
+       cmflags |= MUTT_CM_VERIFY;
       }
     }
   }
   
-  if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
+  if (cmflags & MUTT_CM_VERIFY || cur->security & ENCRYPT)
   {
     if (cur->security & APPLICATION_PGP)
     {
@@ -140,7 +140,7 @@
     hfi.ctx = Context;
     hfi.pager_progress = ExtPagerProgress;
     hfi.hdr = cur;
-    mutt_make_string_info (buf, sizeof (buf), NONULL(PagerFmt), &hfi, 
M_FORMAT_MAKEPRINT);
+    mutt_make_string_info (buf, sizeof (buf), NONULL(PagerFmt), &hfi, 
MUTT_FORMAT_MAKEPRINT);
     fputs (buf, fpout);
     fputs ("\n\n", fpout);
   }
@@ -181,7 +181,7 @@
     pager_t info;
 
     if (WithCrypto 
-        && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
+        && (cur->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
     {
       if (cur->security & GOODSIGN)
       {
@@ -197,7 +197,7 @@
     }
 
     if (WithCrypto 
-        && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
+        && (cur->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
     {
       if (cur->security & GOODSIGN)
        mutt_message (_("PGP signature successfully verified."));
@@ -211,7 +211,7 @@
     memset (&info, 0, sizeof (pager_t));
     info.hdr = cur;
     info.ctx = Context;
-    rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
+    rc = mutt_pager (NULL, tempfile, MUTT_PAGER_MESSAGE, &info);
   }
   else
   {
@@ -225,7 +225,7 @@
     if (!option (OPTNOCURSES))
       keypad (stdscr, TRUE);
     if (r != -1)
-      mutt_set_flag (Context, cur, M_READ, 1);
+      mutt_set_flag (Context, cur, MUTT_READ, 1);
     if (r != -1 && option (OPTPROMPTAFTER))
     {
       mutt_unget_event (mutt_any_key_to_continue _("Command: "), 0);
@@ -275,7 +275,7 @@
   else
     strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
   
-  rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
+  rc = mutt_get_field (prompt, buf, sizeof (buf), MUTT_ALIAS);
 
   if (option (OPTNEEDREDRAW))
   {
@@ -309,25 +309,25 @@
   snprintf (scratch, sizeof (scratch),
            (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
 
-  if (mutt_strwidth (prompt) > COLS - extra_space)
+  if (mutt_strwidth (prompt) > MuttMessageWindow->cols - extra_space)
   {
     mutt_format_string (prompt, sizeof (prompt),
-                       0, COLS-extra_space, FMT_LEFT, 0,
+                       0, MuttMessageWindow->cols-extra_space, FMT_LEFT, 0,
                        scratch, sizeof (scratch), 0);
     safe_strcat (prompt, sizeof (prompt), "...?");
   }
   else
     snprintf (prompt, sizeof (prompt), "%s?", scratch);
 
-  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
+  if (query_quadoption (OPT_BOUNCE, prompt) != MUTT_YES)
   {
     rfc822_free_address (&adr);
-    CLEARLINE (LINES - 1);
+    mutt_window_clearline (MuttMessageWindow, 0);
     mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
     return;
   }
 
-  CLEARLINE (LINES - 1);
+  mutt_window_clearline (MuttMessageWindow, 0);
   
   rc = mutt_bounce_message (NULL, h, adr);
   rfc822_free_address (&adr);
@@ -340,18 +340,18 @@
 {
   if (decode)
   {
-    *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
+    *cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
     *chflags |= CH_DECODE | CH_REORDER;
     
     if (option (OPTWEED))
     {
       *chflags |= CH_WEED;
-      *cmflags |= M_CM_WEED;
+      *cmflags |= MUTT_CM_WEED;
     }
   }
   
   if (print)
-    *cmflags |= M_CM_PRINTING;
+    *cmflags |= MUTT_CM_PRINTING;
   
 }
 
@@ -398,7 +398,7 @@
   if (h)
   {
 
-    mutt_message_hook (Context, h, M_MESSAGEHOOK);
+    mutt_message_hook (Context, h, MUTT_MESSAGEHOOK);
 
     if (WithCrypto && decode)
     {
@@ -426,7 +426,7 @@
       for (i = 0; i < Context->vcount; i++)
        if(Context->hdrs[Context->v2r[i]]->tagged)
        {
-         mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], 
M_MESSAGEHOOK);
+         mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], 
MUTT_MESSAGEHOOK);

Reply via email to