Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Sep 2010 09:00:09 GMT
From:      "Schweigert, Udo CERT" <Udo.Schweigert@siemens.com>
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   Re: ports/150703: maintainer-update of mail/mutt-devel
Message-ID:  <201009190900.o8J9094f056446@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR ports/150703; it has been noted by GNATS.

From: "Schweigert, Udo CERT" <Udo.Schweigert@siemens.com>
To: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Cc: bug-followup@freebsd.org
Subject: Re: ports/150703: maintainer-update of mail/mutt-devel
Date: Sun, 19 Sep 2010 10:51:43 +0200

 --VbJkn9YxBvnuCH5J
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Sat, Sep 18, 2010 at 19:00:11 +0000, Eygene Ryabinkin wrote:
 > The following reply was made to PR ports/150703; it has been noted by GNATS.
 > 
 > From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
 > To: bug-followup@freebsd.org
 > Cc:  
 > Subject: ports/150703: maintainer-update of mail/mutt-devel
 > Date: Sat, 18 Sep 2010 22:55:36 +0400
 > 
 >  Udo, your mktemp patch is slightly incorrect: since _mutt_mktemp now has
 >  'slen' argument, you should use it instead of _POSIX_PATH_MAX and check
 >  for slen > 6 to avoid signed underflow in snprintf().
 
 Eygene,
 
 you're of course right, the simple copy of the old code was not a good idea.
 Attached is a new patch for the whole port upgrade.
 The _mutt_mktemp now looks like this:
 
 void _mutt_mktemp (char *s, size_t slen, const char *src, int line)
 {
   size_t n = snprintf (s, slen, "%s/mutt-%s-XXXXXXXX", NONULL (Tempdir), NONULL (Hostname));
   if (n >= slen)
     dprint (1, (debugfile, "%s:%d: ERROR: insufficient buffer space to hold temporary filename! slen=%zu but need %zu\n",
             src, line, slen, n));
   if (mktemp (s)) {
     dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
   } else {
     dprint (1, (debugfile, "%s:%d: ERROR: mktemp(\"%s\"): %s (errno %d)\n", src, line, s, strerror (errno), errno));
   }
 }
 
 
 Thanks for having looked at this.
 
 
 Regards,
 
 Udo
 
 --VbJkn9YxBvnuCH5J
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="mutt-devel.diff"
 
 diff -ru  /usr/ports/mail/mutt-devel/Makefile ./Makefile
 --- /usr/ports/mail/mutt-devel/Makefile	2010-09-16 06:06:34.000000000 +0200
 +++ ./Makefile	2010-09-17 16:48:55.000000000 +0200
 @@ -117,8 +117,8 @@
  #
  
  PORTNAME=	mutt-devel
 -PORTVERSION=	1.5.20
 -PORTREVISION?=	7
 +PORTVERSION=	1.5.21
 +PORTREVISION?=	0
  CATEGORIES+=	mail ipv6
  .if defined(WITH_MUTT_NNTP)
  CATEGORIES+=	news
 @@ -145,9 +145,7 @@
  		ftp://ftp3.mutt.org.ua/pub/mutt/mutt-${VVV_PATCH_VERSION}/:vvv \
  		http://home.woolridge.ca/mutt/patches/:dw \
  		http://www.spinnaker.de/mutt/compressed/:rr \
 -		http://www.emaillab.org/mutt/${AC_PATCH_VERSION}/:jp \
 -		http://vc.org.ua/mutt/:vc \
 -		http://yz.kiev.ua/mutt/:vc
 +		http://www.emaillab.org/mutt/${AC_PATCH_VERSION}/:jp
  
  MAINTAINER?=	udo.schweigert@siemens.com
  COMMENT?=	The Mongrel of Mail User Agents (development version)
 @@ -178,7 +176,6 @@
  
  DW_PATCH_VERSION=	1.5.6
  AC_PATCH_VERSION=	1.5.9
 -VC_PATCH_VERSION=	1.5.16
  DW_MBOX_PATCH_VERSION=	1.5.18
  .if !defined(VVV_PATCH_VERSION)
  VVV_PATCH_VERSION=	${PORTVERSION}
 @@ -195,9 +192,6 @@
  .if !defined(AC_PATCH_VERSION)
  AC_PATCH_VERSION=	${PORTVERSION}
  .endif
 -.if !defined(VC_PATCH_VERSION)
 -VC_PATCH_VERSION=	${PORTVERSION}
 -.endif
  .if defined(WITH_MUTT_MAILDIR_HEADER_CACHE)
  WITH_MUTT_IMAP_HEADER_CACHE=	yes
  .endif
 @@ -438,7 +432,8 @@
  .endif
  .endif
  .if defined(WITH_MUTT_GREETING_PATCH)
 -PATCHFILES+=	mutt-${VC_PATCH_VERSION}.vc.greeting:vc
 +post-patch::
 +	@${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-greeting
  .endif
  .if defined(WITH_MUTT_TRASH_PATCH)
  post-patch::
 @@ -446,7 +441,7 @@
  .endif
  
  WRKSRC=		${WRKDIR}/${DISTNAME:S/i$//}
 -MAN1=		mutt.1 mutt_dotlock.1 flea.1 muttbug.1
 +MAN1=		mutt.1 mutt_dotlock.1 flea.1 muttbug.1 smime_keys.1
  MAN5=		muttrc.5
  .if !defined(WITHOUT_MUTT_MAILBOX_MANPAGES)
  MAN5+=		mbox.5 mmdf.5
 diff -ru  /usr/ports/mail/mutt-devel/distinfo ./distinfo
 --- /usr/ports/mail/mutt-devel/distinfo	2009-06-23 00:52:30.000000000 +0200
 +++ ./distinfo	2010-09-17 17:01:00.000000000 +0200
 @@ -1,24 +1,15 @@
 -MD5 (mutt/mutt-1.5.20.tar.gz) = 027cdd9959203de0c3c64149a7ee351c
 -SHA256 (mutt/mutt-1.5.20.tar.gz) = 9579fc079d74ff5c89223ff09df402ef4e508ba8ca925c49e74aa09c02a9a796
 -SIZE (mutt/mutt-1.5.20.tar.gz) = 3635047
 -MD5 (mutt/patch-1.5.20.rr.compressed.gz) = 5e608027bda1fddc2bc38c03a560f0a9
 -SHA256 (mutt/patch-1.5.20.rr.compressed.gz) = 87a7eed23ee234fcb3564e13bb034a3bfe858fb69677c7f8e7321446acf01034
 -SIZE (mutt/patch-1.5.20.rr.compressed.gz) = 10190
 -MD5 (mutt/patch-1.5.20.vvv.nntp.gz) = 80355166f8ae9bff064124f2d2e6870f
 -SHA256 (mutt/patch-1.5.20.vvv.nntp.gz) = ea199ed303519ed816bded493cc4fe2985b497ec29b1c1c201f1428b1354260b
 -SIZE (mutt/patch-1.5.20.vvv.nntp.gz) = 55449
 -MD5 (mutt/patch-1.5.4.cd.ifdef.1) = a545036cdb55519154d0b35465f52daa
 -SHA256 (mutt/patch-1.5.4.cd.ifdef.1) = 7d11892bcc688bbc82b5996ca0fda2d4446d8e928bec50b2731f8a3a5d9be373
 -SIZE (mutt/patch-1.5.4.cd.ifdef.1) = 3545
 -MD5 (mutt/patch-1.5.20.vvv.initials.gz) = c71ebc64f20f516f45168530d57f6c21
 -SHA256 (mutt/patch-1.5.20.vvv.initials.gz) = fc2cf1dadfab02545116fc70855cfe14f4efd8e1a32b9a6c366fc5e09bdafd23
 -SIZE (mutt/patch-1.5.20.vvv.initials.gz) = 690
 -MD5 (mutt/patch-1.5.20.vvv.quote.gz) = 1d6213598d354942006f17b2c46720f2
 -SHA256 (mutt/patch-1.5.20.vvv.quote.gz) = 7f3ea7999f00738c2dab0e67d69d76d354d14d0615c00784233e6d1149cb749d
 -SIZE (mutt/patch-1.5.20.vvv.quote.gz) = 1772
 -MD5 (mutt/p0-patch-1.5.18.dw.mbox-hook.1) = ae70a6668e297bdc804b2673221b4727
 -SHA256 (mutt/p0-patch-1.5.18.dw.mbox-hook.1) = 12b9f41476850a5e2eed2334be9326e4905e8a6d786740689b6966a5d285070c
 -SIZE (mutt/p0-patch-1.5.18.dw.mbox-hook.1) = 6812
 -MD5 (mutt/mutt-1.5.16.vc.greeting) = 4bd9beeb74d075e4418e86e8ed887aa0
 -SHA256 (mutt/mutt-1.5.16.vc.greeting) = cf05aeab5f1813864aa72b68f59a579c46dacf2fbd8e5fd064b920012320b986
 -SIZE (mutt/mutt-1.5.16.vc.greeting) = 4526
 +MD5 (mutt/mutt-1.5.21.tar.gz) = a29db8f1d51e2f10c070bf88e8a553fd
 +SHA256 (mutt/mutt-1.5.21.tar.gz) = 2141f36e8d0f4f71c9ca6780001e7cc679fe313e643953fc07f001223e67c4a0
 +SIZE (mutt/mutt-1.5.21.tar.gz) = 3716886
 +MD5 (mutt/patch-1.5.21.rr.compressed.gz) = 0632fd94c96b3e452144b730e3cf0fd3
 +SHA256 (mutt/patch-1.5.21.rr.compressed.gz) = 5056b181222c4322667fd99a6314e80a4a8b4613357364d9deddef626136b4d9
 +SIZE (mutt/patch-1.5.21.rr.compressed.gz) = 10133
 +MD5 (mutt/patch-1.5.21.vvv.nntp.gz) = afcf40f7e53a016b953cbf6af27b3cd8
 +SHA256 (mutt/patch-1.5.21.vvv.nntp.gz) = 514cb4c3404bb68fef08781c17be41c6cd1251d05442db4105c6258f0b9d4928
 +SIZE (mutt/patch-1.5.21.vvv.nntp.gz) = 55611
 +MD5 (mutt/patch-1.5.21.vvv.initials.gz) = 9444edd98d52e6f6a4fa17bcc3160a93
 +SHA256 (mutt/patch-1.5.21.vvv.initials.gz) = ecce3643b04d1aced7085bca506896298bd56d991a5d1af057922c8358abf141
 +SIZE (mutt/patch-1.5.21.vvv.initials.gz) = 691
 +MD5 (mutt/patch-1.5.21.vvv.quote.gz) = 93185b8fdf8d12f13a7a65136204193c
 +SHA256 (mutt/patch-1.5.21.vvv.quote.gz) = b0613d305932b31eaf005ee0740558d46561a6d7a333c97a00d34a1d0c1ef843
 +SIZE (mutt/patch-1.5.21.vvv.quote.gz) = 1280
 diff -ru  /usr/ports/mail/mutt-devel/files/extra-patch-doc-xml ./files/extra-patch-doc-xml
 --- /usr/ports/mail/mutt-devel/files/extra-patch-doc-xml	2007-03-06 19:34:16.000000000 +0100
 +++ ./files/extra-patch-doc-xml	2010-09-17 16:33:17.000000000 +0200
 @@ -1,11 +1,11 @@
 ---- doc/Makefile.am.orig2	Tue Mar  6 17:40:41 2007
 -+++ doc/Makefile.am	Tue Mar  6 17:42:51 2007
 -@@ -42,7 +42,7 @@
 - all: ../makedoc$(EXEEXT)
 - 	$(MAKE) makedoc-all
 +--- doc/Makefile.am.orig	2010-09-17 16:23:30.000000000 +0200
 ++++ doc/Makefile.am	2010-09-17 16:25:01.000000000 +0200
 +@@ -47,7 +47,7 @@
   
 --makedoc-all: mutt.1 muttrc.man
 -+makedoc-all: mutt.1 muttrc.man manual.html stamp-doc-chunked manual.txt
 + all: makedoc-all
 + 
 +-makedoc-all: mutt.1 smime_keys.1 muttrc.man
 ++makedoc-all: mutt.1 smime_keys.1 muttrc.man manual.html stamp-doc-chunked manual.txt
   
   install-data-local: makedoc-all instdoc
   	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
 diff -ru  /usr/ports/mail/mutt-devel/files/extra-patch-greeting ./files/extra-patch-greeting
 --- /usr/ports/mail/mutt-devel/files/extra-patch-greeting	1970-01-01 01:00:00.000000000 +0100
 +++ ./files/extra-patch-greeting	2010-09-17 16:55:39.000000000 +0200
 @@ -0,0 +1,160 @@
 +diff -urN mutt-1.5.19/globals.h mutt-1.5.19-vc/globals.h
 +--- mutt-1.5.19/globals.h	2009-01-04 01:27:10.000000000 +0200
 ++++ mutt-1.5.19-vc/globals.h	2009-02-09 19:30:31.000000000 +0200
 +@@ -52,6 +52,7 @@
 + WHERE char *FolderFormat;
 + WHERE char *ForwFmt;
 + WHERE char *Fqdn;
 ++WHERE char *Greeting;
 + WHERE char *HdrFmt;
 + WHERE char *HistFile;
 + WHERE char *Homedir;
 +diff -urN mutt-1.5.19/hdrline.c mutt-1.5.19-vc/hdrline.c
 +--- mutt-1.5.19/hdrline.c	2009-01-05 21:20:53.000000000 +0200
 ++++ mutt-1.5.19-vc/hdrline.c	2009-02-09 19:30:31.000000000 +0200
 +@@ -741,3 +741,62 @@
 + {
 +   mutt_FormatString (dst, dstlen, 0, s, hdr_format_str, (unsigned long) hfi, flags);
 + }
 ++
 ++/* %n = recipient name
 ++ * %u = user (login) name of recipient
 ++ * %v = first name of recipient	*/
 ++const char *
 ++greeting_string (char *dest,
 ++		size_t destlen,
 ++		size_t col,
 ++		char op,
 ++		const char *src,
 ++		const char *prefix,
 ++		const char *ifstring,
 ++		const char *elsestring,
 ++		unsigned long data,
 ++		format_flag flags)
 ++{
 ++  HEADER *hdr = (HEADER *)data;
 ++  char *p, buf2[SHORT_STRING];
 ++
 ++  dest[0] = '\0';
 ++  switch (op)
 ++  {
 ++    case 'n':
 ++      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->to));
 ++      break;
 ++
 ++    case 'u':
 ++      if (hdr->env->to)
 ++      {
 ++	strfcpy (buf2, mutt_addr_for_display (hdr->env->to), sizeof (buf2));
 ++	if ((p = strpbrk (buf2, "%@")))
 ++	  *p = '\0';
 ++      }
 ++      else
 ++	buf2[0] = '\0';
 ++      mutt_format_s (dest, destlen, prefix, buf2);
 ++      break;
 ++
 ++    case 'v':
 ++      if (hdr->env->to)
 ++	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->to));
 ++      else if (hdr->env->cc)
 ++	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->cc));
 ++      else
 ++	*buf2 = '\0';
 ++      if ((p = strpbrk (buf2, " %@")))
 ++	*p = '\0';
 ++      mutt_format_s (dest, destlen, prefix, buf2);
 ++      break;
 ++
 ++    default:
 ++      snprintf (dest, destlen, "%%%s%c", prefix, op);
 ++      break;
 ++  }
 ++  if (flags & M_FORMAT_OPTIONAL)
 ++    mutt_FormatString (dest, destlen, col, elsestring, greeting_string, data, flags);
 ++
 ++  return(src);
 ++}
 +diff -urN mutt-1.5.19/init.h mutt-1.5.19-vc/init.h
 +--- mutt-1.5.19/init.h	2009-01-05 21:20:53.000000000 +0200
 ++++ mutt-1.5.19-vc/init.h	2009-02-09 19:30:31.000000000 +0200
 +@@ -745,6 +745,22 @@
 +   ** .pp
 +   ** This setting defaults to the contents of the environment variable \fC$$$EMAIL\fP.
 +   */
 ++  { "greeting",		DT_STR,	 R_NONE, UL &Greeting, UL "" },
 ++  /*
 ++  ** .pp
 ++  ** When set, this is the string that will precede every message as a
 ++  ** greeting phrase to the recipients.
 ++  ** .pp
 ++  ** ``Format strings'' are similar to the strings used in the ``C''
 ++  ** function printf to format output (see the man page for more detail).
 ++  ** The following sequences are defined in Mutt:
 ++  ** .pp
 ++  ** .dl
 ++  ** .dt %n .dd recipient name
 ++  ** .dt %u .dd user (login) name of recipient
 ++  ** .dt %v .dd first name of recipient
 ++  ** .de
 ++  */
 +   { "gecos_mask",	DT_RX,	 R_NONE, UL &GecosMask, UL "^[^,]*" },
 +   /*
 +   ** .pp
 +diff -urN mutt-1.5.19/PATCHES mutt-1.5.19-vc/PATCHES
 +--- mutt-1.5.19/PATCHES	2008-03-19 22:07:06.000000000 +0200
 ++++ mutt-1.5.19-vc/PATCHES	2009-02-09 19:30:31.000000000 +0200
 +@@ -0,0 +1 @@
 ++vc.greeting
 +diff -urN mutt-1.5.19/protos.h mutt-1.5.19-vc/protos.h
 +--- mutt-1.5.19/protos.h	2009-01-05 21:20:53.000000000 +0200
 ++++ mutt-1.5.19-vc/protos.h	2009-02-09 19:32:15.000000000 +0200
 +@@ -526,6 +526,9 @@
 + void ci_bounce_message (HEADER *, int *);
 + int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);
 + 
 ++const char *greeting_string (char *, size_t, size_t, char, const char *, const char *,
 ++		const char *, const char *, unsigned long, format_flag);
 ++
 + /* prototypes for compatibility functions */
 + 
 + #ifndef HAVE_SETENV
 +diff -urN mutt-1.5.19/send.c mutt-1.5.19-vc/send.c
 +--- mutt-1.5.19/send.c.orig	2010-09-17 16:49:09.000000000 +0200
 ++++ mutt-1.5.19-vc/send.c	2010-09-17 16:53:15.000000000 +0200
 +@@ -469,6 +469,18 @@
 +   }
 + }
 + 
 ++void mutt_make_greeting (HEADER *hdr, FILE *out, int flags)
 ++{
 ++  char buffer[STRING];
 ++  if (Greeting)
 ++  {
 ++    mutt_FormatString(buffer, sizeof(buffer), 0, Greeting, greeting_string,
 ++		      (unsigned long) hdr, flags);
 ++    fputs(buffer, out);
 ++    fputc ('\n', out);
 ++  }
 ++}
 ++
 + void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out)
 + {
 +   char buffer[STRING];
 +@@ -1003,7 +1015,6 @@
 +   }
 + }
 + 
 +-
 + /* look through the recipients of the message we are replying to, and if
 +    we find an address that matches $alternates, we use that as the default
 +    from field */
 +@@ -1439,6 +1450,8 @@
 +     if (option (OPTHDRS))
 +       process_user_header (msg->env);
 + 
 ++    mutt_make_greeting(msg, tempfp, flags);
 ++
 +     if (flags & SENDBATCH)
 +        mutt_copy_stream (stdin, tempfp);
 + 
 diff -ru  /usr/ports/mail/mutt-devel/files/extra-patch-sidebar ./files/extra-patch-sidebar
 --- /usr/ports/mail/mutt-devel/files/extra-patch-sidebar	2009-06-23 00:52:30.000000000 +0200
 +++ ./files/extra-patch-sidebar	2010-09-18 15:32:01.000000000 +0200
 @@ -1,252 +1,220 @@
 -*** mutt-1.5.20-orig/buffy.c	2009-06-02 12:16:26.000000000 -0500
 ---- mutt-1.5.20-patched/buffy.c	2009-06-19 22:37:02.000000000 -0500
 -***************
 -*** 159,164 ****
 ---- 159,207 ----
 -    }
 -  }
 -  
 -+ static int buffy_compare_name(const void *a, const void *b) {
 -+   const BUFFY *b1 = * (BUFFY * const *) a;
 -+   const BUFFY *b2 = * (BUFFY * const *) b;
 -+ 
 -+   return mutt_strcoll(b1->path, b2->path);
 -+ }
 -+ 
 -+ static BUFFY *buffy_sort(BUFFY *b)
 -+ {
 -+   BUFFY *tmp = b;
 -+   int buffycount = 0;
 -+   BUFFY **ary;
 -+   int i;
 -+ 
 -+   if (!option(OPTSIDEBARSORT))
 -+     return b;
 -+ 
 -+   for (; tmp != NULL; tmp = tmp->next)
 -+     buffycount++;
 -+ 
 -+   ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
 -+ 
 -+   tmp = b;
 -+   for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
 -+     ary[i] = tmp;
 -+   }
 -+ 
 -+   qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
 -+ 
 -+   for (i = 0; i < buffycount - 1; i++) {
 -+     ary[i]->next = ary[i+1];
 -+   }
 -+   ary[buffycount - 1]->next = NULL;
 -+   for (i = 1; i < buffycount; i++) {
 -+     ary[i]->prev = ary[i-1];
 -+   }
 -+   ary[0]->prev = NULL;
 -+ 
 -+   tmp = ary[0];
 -+   free(ary);
 -+   return tmp;
 -+ }
 -+ 
 -  BUFFY *mutt_find_mailbox (const char *path)
 -  {
 -    BUFFY *tmp = NULL;
 -***************
 -*** 271,276 ****
 ---- 314,320 ----
 -      else
 -        (*tmp)->size = 0;
 -    }
 -+   Incoming = buffy_sort(Incoming);
 -    return 0;
 -  }
 -  
 -***************
 -*** 290,295 ****
 ---- 334,340 ----
 -    char path[_POSIX_PATH_MAX];
 -    struct stat contex_sb;
 -    time_t t;
 -+   CONTEXT *ctx;
 -  
 -    sb.st_size=0;
 -    contex_sb.st_dev=0;
 -***************
 -*** 329,334 ****
 ---- 374,381 ----
 -    
 -    for (tmp = Incoming; tmp; tmp = tmp->next)
 -    {
 -+     if ( tmp->new == 1 )
 +--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
 ++++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
 +@@ -161,6 +161,49 @@
 +   }
 + }
 + 
 ++static int buffy_compare_name(const void *a, const void *b) {
 ++  const BUFFY *b1 = * (BUFFY * const *) a;
 ++  const BUFFY *b2 = * (BUFFY * const *) b;
 ++
 ++  return mutt_strcoll(b1->path, b2->path);
 ++}
 ++
 ++static BUFFY *buffy_sort(BUFFY *b)
 ++{
 ++  BUFFY *tmp = b;
 ++  int buffycount = 0;
 ++  BUFFY **ary;
 ++  int i;
 ++
 ++  if (!option(OPTSIDEBARSORT))
 ++    return b;
 ++
 ++  for (; tmp != NULL; tmp = tmp->next)
 ++    buffycount++;
 ++
 ++  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
 ++
 ++  tmp = b;
 ++  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
 ++    ary[i] = tmp;
 ++  }
 ++
 ++  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
 ++
 ++  for (i = 0; i < buffycount - 1; i++) {
 ++    ary[i]->next = ary[i+1];
 ++  }
 ++  ary[buffycount - 1]->next = NULL;
 ++  for (i = 1; i < buffycount; i++) {
 ++    ary[i]->prev = ary[i-1];
 ++  }
 ++  ary[0]->prev = NULL;
 ++
 ++  tmp = ary[0];
 ++  free(ary);
 ++  return tmp;
 ++}
 ++
 + BUFFY *mutt_find_mailbox (const char *path)
 + {
 +   BUFFY *tmp = NULL;
 +@@ -282,6 +325,7 @@
 +     else
 +       (*tmp)->size = 0;
 +   }
 ++  Incoming = buffy_sort(Incoming);
 +   return 0;
 + }
 + 
 +@@ -371,12 +415,17 @@
 +   return rc;
 + }
 + 
 ++#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
 ++#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
 ++#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
 ++
 + int mutt_buffy_check (int force)
 + {
 +   BUFFY *tmp;
 +   struct stat sb;
 +   struct stat contex_sb;
 +   time_t t;
 ++  CONTEXT *ctx;
 + 
 +   sb.st_size=0;
 +   contex_sb.st_dev=0;
 +@@ -416,6 +465,8 @@
 +   
 +   for (tmp = Incoming; tmp; tmp = tmp->next)
 +   {
 ++    if ( tmp->new == 1 )
  +       tmp->has_new = 1;
 -  #ifdef USE_IMAP
 -      if (tmp->magic != M_IMAP)
 -  #endif
 -***************
 -*** 385,394 ****
 -        case M_MBOX:
 -        case M_MMDF:
 -  
 -! 	if (STAT_CHECK)
 -  	{
 -! 	  BuffyCount++;
 -! 	  tmp->new = 1;
 -  	}
 -  	else if (option(OPTCHECKMBOXSIZE))
 -  	{
 ---- 432,458 ----
 -        case M_MBOX:
 -        case M_MMDF:
 -  
 -!         {
 -! 	if (STAT_CHECK || tmp->msgcount == 0)
 -  	{
 -! 	  BUFFY b = *tmp;
 -!  	  int msgcount = 0;
 -!  	  int msg_unread = 0;
 -!  	  /* parse the mailbox, to see how much mail there is */
 -!  	  ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
 -!  	  if(ctx)
 -!  	  {
 -!             msgcount = ctx->msgcount;
 -!  	    msg_unread = ctx->unread;
 -!  	    mx_close_mailbox(ctx, 0);
 -!  	  }
 -!  	  *tmp = b;
 -!  	  tmp->msgcount = msgcount;
 -!  	  tmp->msg_unread = msg_unread;
 -!  	  if(STAT_CHECK) {
 -!  	    tmp->has_new = tmp->new = 1;
 -! 	    BuffyCount++;
 -!           }  
 -  	}
 -  	else if (option(OPTCHECKMBOXSIZE))
 -  	{
 -***************
 -*** 398,432 ****
 -  	if (tmp->newly_created &&
 -  	    (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 -  	  tmp->newly_created = 0;
 -! 
 -  	break;
 -  
 -        case M_MAILDIR:
 -  
 -  	snprintf (path, sizeof (path), "%s/new", tmp->path);
 -  	if ((dirp = opendir (path)) == NULL)
 -  	{
 -  	  tmp->magic = 0;
 -  	  break;
 -  	}
 -  	while ((de = readdir (dirp)) != NULL)
 -  	{
 -  	  char *p;
 -  	  if (*de->d_name != '.' && 
 -  	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 -  	  {
 -! 	    /* one new and undeleted message is enough */
 -! 	    BuffyCount++;
 -! 	    tmp->new = 1;
 -! 	    break;
 -  	  }
 -  	}
 -  	closedir (dirp);
 -  	break;
 -  
 -        case M_MH:
 -  	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 -  	  BuffyCount++;
 -  	break;
 -        }
 -      }
 ---- 462,547 ----
 -  	if (tmp->newly_created &&
 -  	    (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 -  	  tmp->newly_created = 0;
 -!         }
 -  	break;
 -  
 -        case M_MAILDIR:
 -  
 -+         /* count new message */
 -  	snprintf (path, sizeof (path), "%s/new", tmp->path);
 -  	if ((dirp = opendir (path)) == NULL)
 -  	{
 -  	  tmp->magic = 0;
 -  	  break;
 -  	}
 -+   	tmp->msgcount = 0;
 -+   	tmp->msg_unread = 0;
 -+   	tmp->msg_flagged = 0;
 -  	while ((de = readdir (dirp)) != NULL)
 -  	{
 -  	  char *p;
 -  	  if (*de->d_name != '.' && 
 -  	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 -  	  {
 -!  	    tmp->has_new = tmp->new = 1;
 -!             tmp->msgcount++;
 -!             tmp->msg_unread++;
 -!  	  }
 -!  	}
 -!         if(tmp->msg_unread)
 -!           BuffyCount++;
 -!  
 -!  	closedir (dirp);
 -!  
 -!         /*
 -!          * count read messages (for folderlist (sidebar) we also need to count
 -!          * messages in cur so that we the total number of messages
 -!          */
 -!  	snprintf (path, sizeof (path), "%s/cur", tmp->path);
 -!  	if ((dirp = opendir (path)) == NULL)
 -!   	{
 -!   	  tmp->magic = 0;
 -!   	  break;
 -!   	}
 -!   	while ((de = readdir (dirp)) != NULL)
 -!   	{
 -!   	  char *p;
 -!           if (*de->d_name != '.') {
 -!                   if ((p = strstr (de->d_name, ":2,"))) {
 -!                           if (!strchr (p + 3, 'T')) {
 -!                                   tmp->msgcount++;
 -!                                   if ( !strchr (p + 3, 'S'))
 -!                                           tmp->msg_unread++;
 -!                                   if (strchr(p + 3, 'F'))
 -!                                           tmp->msg_flagged++;
 -!                           }
 -!                   } else
 -!                           tmp->msgcount++;
 -  	  }
 -  	}
 -  	closedir (dirp);
 -  	break;
 -  
 -        case M_MH:
 -+       {
 -+       DIR *dp;
 -+       struct dirent *de;
 -  	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 -  	  BuffyCount++;
 -+     
 -+       if ((dp = opendir (path)) == NULL)
 -+         break;
 -+       tmp->msgcount = 0;
 -+       while ((de = readdir (dp)))
 -+       {
 -+         if (mh_valid_message (de->d_name))
 -+         {
 -+ 	  tmp->msgcount++;
 -+  	  tmp->has_new = tmp->new = 1;
 -+         }
 -+       }
 -+       closedir (dp);
 -+       }
 -  	break;
 -        }
 -      }
 +     if (tmp->magic != M_IMAP)
 +     {
 +       tmp->new = 0;
 +@@ -455,18 +506,122 @@
 +       {
 +       case M_MBOX:
 +       case M_MMDF:
 +-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
 +-	  BuffyCount++;
 +-	break;
 ++        {
 ++          if (STAT_CHECK || tmp->msgcount == 0)
 ++          {
 ++            BUFFY b = *tmp;
 ++            int msgcount = 0;
 ++            int msg_unread = 0;
 ++            /* parse the mailbox, to see how much mail there is */
 ++            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
 ++            if(ctx)
 ++            {
 ++              msgcount = ctx->msgcount;
 ++              msg_unread = ctx->unread;
 ++              mx_close_mailbox(ctx, 0);
 ++            }
 ++            *tmp = b;
 ++            tmp->msgcount = msgcount;
 ++            tmp->msg_unread = msg_unread;
 ++            if(STAT_CHECK) {
 ++              tmp->has_new = tmp->new = 1;
 ++              BuffyCount++;
 ++            }
 ++          }
 ++          else if (option(OPTCHECKMBOXSIZE))
 ++          {
 ++            /* some other program has deleted mail from the folder */
 ++            tmp->size = (off_t) sb.st_size;
 ++          }
 ++          if (tmp->newly_created &&
 ++              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 ++            tmp->newly_created = 0;
 ++        }
 ++        break;
 ++
 + 
 +       case M_MAILDIR:
 +-	if (buffy_maildir_hasnew (tmp) > 0)
 +-	  BuffyCount++;
 ++        { 
 ++        char path[_POSIX_PATH_MAX];
 ++        DIR *dirp;
 ++        struct dirent *de;
 ++        /* count new message */
 ++        snprintf (path, sizeof (path), "%s/new", tmp->path);
 ++        if ((dirp = opendir (path)) == NULL)
 ++        {
 ++          tmp->magic = 0;
 ++          break;
 ++        }
 ++        tmp->msgcount = 0;
 ++        tmp->msg_unread = 0;
 ++        tmp->msg_flagged = 0;
 ++        while ((de = readdir (dirp)) != NULL)
 ++        {
 ++          char *p;
 ++          if (*de->d_name != '.' &&
 ++              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 ++          {
 ++            tmp->has_new = tmp->new = 1;
 ++            tmp->msgcount++;
 ++            tmp->msg_unread++;
 ++          }
 ++        }
 ++        if(tmp->msg_unread)
 ++          BuffyCount++;
 ++
 ++        closedir (dirp);
 ++
 ++        /*
 ++         * count read messages (for folderlist (sidebar) we also need to count
 ++         * messages in cur so that we the total number of messages
 ++         */
 ++        snprintf (path, sizeof (path), "%s/cur", tmp->path);
 ++        if ((dirp = opendir (path)) == NULL)
 ++        {
 ++          tmp->magic = 0;
 ++          break;
 ++        }
 ++        while ((de = readdir (dirp)) != NULL)
 ++        {
 ++          char *p;
 ++          if (*de->d_name != '.') {
 ++                  if ((p = strstr (de->d_name, ":2,"))) {
 ++                          if (!strchr (p + 3, 'T')) {
 ++                                  tmp->msgcount++;
 ++                                  if ( !strchr (p + 3, 'S'))
 ++                                          tmp->msg_unread++;
 ++                                  if (strchr(p + 3, 'F'))
 ++                                          tmp->msg_flagged++;
 ++                          }
 ++                  } else
 ++                          tmp->msgcount++;
 ++          }
 ++        }
 ++        closedir (dirp);
 ++        } 
 + 	break;
 + 
 +       case M_MH:
 +-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 +-	  BuffyCount++;
 ++        {
 ++        DIR *dp;
 ++        char path[_POSIX_PATH_MAX];
 ++        struct dirent *de;
 ++        if ((tmp->new = mh_buffy (tmp->path)) > 0)
 ++          BuffyCount++;
 ++
 ++        if ((dp = opendir (path)) == NULL)
 ++          break;
 ++        tmp->msgcount = 0;
 ++        while ((de = readdir (dp)))
 ++        {
 ++          if (mh_valid_message (de->d_name))
 ++          {
 ++            tmp->msgcount++;
 ++            tmp->has_new = tmp->new = 1;
 ++          }
 ++        }
 ++        closedir (dp);
 ++        }
 + 	break;
 +       }
 +     }
  *** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
  --- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
  ***************
 @@ -277,236 +245,6 @@
      { NULL,		0 }
    };
    
 -*** mutt-1.5.20-orig/compose.c	2009-03-31 01:52:43.000000000 -0500
 ---- mutt-1.5.20-patched/compose.c	2009-06-19 22:07:04.000000000 -0500
 -***************
 -*** 72,78 ****
 -  
 -  #define HDR_XOFFSET 10
 -  #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
 -! #define W (COLS - HDR_XOFFSET)
 -  
 -  static char *Prompts[] =
 -  {
 ---- 72,78 ----
 -  
 -  #define HDR_XOFFSET 10
 -  #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
 -! #define W (COLS - HDR_XOFFSET - SidebarWidth)
 -  
 -  static char *Prompts[] =
 -  {
 -***************
 -*** 115,130 ****
 -    if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
 -    {     
 -      if (!msg->security)
 -!       mvaddstr (HDR_CRYPT, 0,     "Security: ");
 -      else if (msg->security & APPLICATION_SMIME)
 -!       mvaddstr (HDR_CRYPT, 0,     "  S/MIME: ");
 -      else if (msg->security & APPLICATION_PGP)
 -!       mvaddstr (HDR_CRYPT, 0,     "     PGP: ");
 -    }
 -    else if ((WithCrypto & APPLICATION_SMIME))
 -!     mvaddstr (HDR_CRYPT, 0,     "  S/MIME: ");
 -    else if ((WithCrypto & APPLICATION_PGP))
 -!     mvaddstr (HDR_CRYPT, 0,     "     PGP: ");
 -    else
 -      return;
 -  
 ---- 115,130 ----
 -    if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
 -    {     
 -      if (!msg->security)
 -!       mvaddstr (HDR_CRYPT, SidebarWidth,     "Security: ");
 -      else if (msg->security & APPLICATION_SMIME)
 -!       mvaddstr (HDR_CRYPT, SidebarWidth,     "  S/MIME: ");
 -      else if (msg->security & APPLICATION_PGP)
 -!       mvaddstr (HDR_CRYPT, SidebarWidth,     "     PGP: ");
 -    }
 -    else if ((WithCrypto & APPLICATION_SMIME))
 -!     mvaddstr (HDR_CRYPT, SidebarWidth,     "  S/MIME: ");
 -    else if ((WithCrypto & APPLICATION_PGP))
 -!     mvaddstr (HDR_CRYPT, SidebarWidth,     "     PGP: ");
 -    else
 -      return;
 -  
 -***************
 -*** 148,154 ****
 -      }
 -    clrtoeol ();
 -  
 -!   move (HDR_CRYPTINFO, 0);
 -    clrtoeol ();
 -    if ((WithCrypto & APPLICATION_PGP)
 -        && msg->security & APPLICATION_PGP  && msg->security & SIGN)
 ---- 148,154 ----
 -      }
 -    clrtoeol ();
 -  
 -!   move (HDR_CRYPTINFO, SidebarWidth);
 -    clrtoeol ();
 -    if ((WithCrypto & APPLICATION_PGP)
 -        && msg->security & APPLICATION_PGP  && msg->security & SIGN)
 -***************
 -*** 164,170 ****
 -        && (msg->security & ENCRYPT)
 -        && SmimeCryptAlg
 -        && *SmimeCryptAlg) {
 -!       mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
 -  		NONULL(SmimeCryptAlg));
 -        off = 20;
 -    }
 ---- 164,170 ----
 -        && (msg->security & ENCRYPT)
 -        && SmimeCryptAlg
 -        && *SmimeCryptAlg) {
 -!       mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
 -  		NONULL(SmimeCryptAlg));
 -        off = 20;
 -    }
 -***************
 -*** 178,184 ****
 -    int c;
 -    char *t;
 -  
 -!   mvaddstr (HDR_MIX, 0,     "     Mix: ");
 -  
 -    if (!chain)
 -    {
 ---- 178,184 ----
 -    int c;
 -    char *t;
 -  
 -!   mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
 -  
 -    if (!chain)
 -    {
 -***************
 -*** 193,199 ****
 -      if (t && t[0] == '0' && t[1] == '\0')
 -        t = "<random>";
 -      
 -!     if (c + mutt_strlen (t) + 2 >= COLS)
 -        break;
 -  
 -      addstr (NONULL(t));
 ---- 193,199 ----
 -      if (t && t[0] == '0' && t[1] == '\0')
 -        t = "<random>";
 -      
 -!     if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
 -        break;
 -  
 -      addstr (NONULL(t));
 -***************
 -*** 245,251 ****
 -  
 -    buf[0] = 0;
 -    rfc822_write_address (buf, sizeof (buf), addr, 1);
 -!   mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
 -    mutt_paddstr (W, buf);
 -  }
 -  
 ---- 245,251 ----
 -  
 -    buf[0] = 0;
 -    rfc822_write_address (buf, sizeof (buf), addr, 1);
 -!   mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
 -    mutt_paddstr (W, buf);
 -  }
 -  
 -***************
 -*** 255,264 ****
 -    draw_envelope_addr (HDR_TO, msg->env->to);
 -    draw_envelope_addr (HDR_CC, msg->env->cc);
 -    draw_envelope_addr (HDR_BCC, msg->env->bcc);
 -!   mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
 -    mutt_paddstr (W, NONULL (msg->env->subject));
 -    draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
 -!   mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
 -    mutt_paddstr (W, fcc);
 -  
 -    if (WithCrypto)
 ---- 255,264 ----
 -    draw_envelope_addr (HDR_TO, msg->env->to);
 -    draw_envelope_addr (HDR_CC, msg->env->cc);
 -    draw_envelope_addr (HDR_BCC, msg->env->bcc);
 -!   mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
 -    mutt_paddstr (W, NONULL (msg->env->subject));
 -    draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
 -!   mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
 -    mutt_paddstr (W, fcc);
 -  
 -    if (WithCrypto)
 -***************
 -*** 269,275 ****
 -  #endif
 -  
 -    SETCOLOR (MT_COLOR_STATUS);
 -!   mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
 -    BKGDSET (MT_COLOR_STATUS);
 -    clrtoeol ();
 -  
 ---- 269,275 ----
 -  #endif
 -  
 -    SETCOLOR (MT_COLOR_STATUS);
 -!   mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
 -    BKGDSET (MT_COLOR_STATUS);
 -    clrtoeol ();
 -  
 -***************
 -*** 307,313 ****
 -    /* redraw the expanded list so the user can see the result */
 -    buf[0] = 0;
 -    rfc822_write_address (buf, sizeof (buf), *addr, 1);
 -!   move (line, HDR_XOFFSET);
 -    mutt_paddstr (W, buf);
 -    
 -    return 0;
 ---- 307,313 ----
 -    /* redraw the expanded list so the user can see the result */
 -    buf[0] = 0;
 -    rfc822_write_address (buf, sizeof (buf), *addr, 1);
 -!   move (line, HDR_XOFFSET+SidebarWidth);
 -    mutt_paddstr (W, buf);
 -    
 -    return 0;
 -***************
 -*** 552,558 ****
 -  	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
 -  	{
 -  	  mutt_str_replace (&msg->env->subject, buf);
 -! 	  move (HDR_SUBJECT, HDR_XOFFSET);
 -  	  clrtoeol ();
 -  	  if (msg->env->subject)
 -  	    mutt_paddstr (W, msg->env->subject);
 ---- 552,558 ----
 -  	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
 -  	{
 -  	  mutt_str_replace (&msg->env->subject, buf);
 -! 	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
 -  	  clrtoeol ();
 -  	  if (msg->env->subject)
 -  	    mutt_paddstr (W, msg->env->subject);
 -***************
 -*** 569,575 ****
 -  	{
 -  	  strfcpy (fcc, buf, fcclen);
 -  	  mutt_pretty_mailbox (fcc, fcclen);
 -! 	  move (HDR_FCC, HDR_XOFFSET);
 -  	  mutt_paddstr (W, fcc);
 -  	  fccSet = 1;
 -  	}
 ---- 569,575 ----
 -  	{
 -  	  strfcpy (fcc, buf, fcclen);
 -  	  mutt_pretty_mailbox (fcc, fcclen);
 -! 	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
 -  	  mutt_paddstr (W, fcc);
 -  	  fccSet = 1;
 -  	}
  *** mutt-1.5.20-orig/curs_main.c	2009-06-13 21:48:36.000000000 -0500
  --- mutt-1.5.20-patched/curs_main.c	2009-06-19 22:07:04.000000000 -0500
  ***************
 @@ -766,81 +504,46 @@
    
    /* mx_open_new_message() */
    #define M_ADD_FROM	1	/* add a From_ line */
 -*** mutt-1.5.20-orig/Makefile.am	2009-01-04 20:11:29.000000000 -0600
 ---- mutt-1.5.20-patched/Makefile.am	2009-06-19 22:07:04.000000000 -0500
 -***************
 -*** 29,35 ****
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  
 ---- 29,36 ----
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h \
 -!         sidebar.c
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  
 -*** mutt-1.5.20-orig/Makefile.in	2009-06-09 01:50:44.000000000 -0500
 ---- mutt-1.5.20-patched/Makefile.in	2009-06-19 22:07:04.000000000 -0500
 -***************
 -*** 85,91 ****
 -  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 -  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 -  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 -! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT)
 -  am__objects_1 = patchlist.$(OBJEXT)
 -  nodist_mutt_OBJECTS = $(am__objects_1)
 -  mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
 ---- 85,92 ----
 -  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 -  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 -  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 -! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) \
 -! 	sidebar.$(OBJEXT)
 -  am__objects_1 = patchlist.$(OBJEXT)
 -  nodist_mutt_OBJECTS = $(am__objects_1)
 -  mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
 -***************
 -*** 356,362 ****
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 ---- 357,364 ----
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h \
 -! 	sidebar.c
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 -***************
 -*** 388,394 ****
 -  	README.SSL smime.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
 -  
 -  EXTRA_SCRIPTS = smime_keys
 -  mutt_dotlock_SOURCES = mutt_dotlock.c
 ---- 390,396 ----
 -  	README.SSL smime.h \
 -  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
 -  	ChangeLog mkchangelog.sh mutt_idna.h \
 -! 	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
 -  
 -  EXTRA_SCRIPTS = smime_keys
 -  mutt_dotlock_SOURCES = mutt_dotlock.c
 +--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
 +@@ -34,7 +34,7 @@
 + 	score.c send.c sendlib.c signal.c sort.c \
 + 	status.c system.c thread.c charset.c history.c lib.c \
 + 	muttlib.c editmsg.c mbyte.c \
 +-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
 ++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
 + 
 + nodist_mutt_SOURCES = $(BUILT_SOURCES)
 + 
 +--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
 +@@ -89,7 +89,7 @@
 + 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 + 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 + 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 +-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
 ++	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
 + am__objects_1 =
 + am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
 + nodist_mutt_OBJECTS = $(am__objects_2)
 +@@ -363,7 +363,7 @@
 + 	score.c send.c sendlib.c signal.c sort.c \
 + 	status.c system.c thread.c charset.c history.c lib.c \
 + 	muttlib.c editmsg.c mbyte.c \
 +-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
 ++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
 + 
 + nodist_mutt_SOURCES = $(BUILT_SOURCES)
 + mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 +@@ -397,7 +397,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
 ++	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
 + 
 + EXTRA_SCRIPTS = smime_keys
 + mutt_dotlock_SOURCES = mutt_dotlock.c
  *** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
  --- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
  ***************
 @@ -1231,171 +934,115 @@
  + OP_SIDEBAR_NEXT "go down to next mailbox"
  + OP_SIDEBAR_PREV "go to previous mailbox"
  + OP_SIDEBAR_OPEN "open hilighted mailbox"
 -*** mutt-1.5.20-orig/pager.c	2009-06-03 15:48:31.000000000 -0500
 ---- mutt-1.5.20-patched/pager.c	2009-06-19 22:19:58.000000000 -0500
 -***************
 -*** 29,34 ****
 ---- 29,35 ----
 -  #include "pager.h"
 -  #include "attach.h"
 -  #include "mbyte.h"
 -+ #include "sidebar.h"
 -  
 -  #include "mutt_crypt.h"
 -  
 -***************
 -*** 1071,1076 ****
 ---- 1072,1079 ----
 -    mbstate_t mbstate;
 -  
 -    int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
 -+ 
 -+   wrap_cols -= SidebarWidth;
 -    
 -    /* FIXME: this should come from lineInfo */
 -    memset(&mbstate, 0, sizeof(mbstate));
 -***************
 -*** 1717,1723 ****
 -      if ((redraw & REDRAW_BODY) || topline != oldtopline)
 -      {
 -        do {
 -! 	move (bodyoffset, 0);
 -  	curline = oldtopline = topline;
 -  	lines = 0;
 -  	force_redraw = 0;
 ---- 1720,1726 ----
 -      if ((redraw & REDRAW_BODY) || topline != oldtopline)
 -      {
 -        do {
 -! 	move (bodyoffset, SidebarWidth);
 -  	curline = oldtopline = topline;
 -  	lines = 0;
 -  	force_redraw = 0;
 -***************
 -*** 1730,1735 ****
 ---- 1733,1739 ----
 -  			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
 -  	    lines++;
 -  	  curline++;
 -+   	  move(lines + bodyoffset, SidebarWidth);
 -  	}
 -  	last_offset = lineInfo[curline].offset;
 -        } while (force_redraw);
 -***************
 -*** 1743,1748 ****
 ---- 1747,1753 ----
 -  	  addch ('~');
 -  	addch ('\n');
 -  	lines++;
 -+   	move(lines + bodyoffset, SidebarWidth);
 -        }
 -        /* We are going to update the pager status bar, so it isn't
 -         * necessary to reset to normal color now. */
 -***************
 -*** 1766,1786 ****
 -        /* print out the pager status bar */
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       CLEARLINE (statusoffset);
 -  
 -        if (IsHeader (extra) || IsMsgAttach (extra))
 -        {
 -! 	size_t l1 = COLS * MB_LEN_MAX;
 -  	size_t l2 = sizeof (buffer);
 -  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 -  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 -! 	mutt_paddstr (COLS, buffer);
 -        }
 -        else
 -        {
 -  	char bn[STRING];
 -  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 -! 	mutt_paddstr (COLS, bn);
 -        }
 -        BKGDSET (MT_COLOR_NORMAL);
 -        SETCOLOR (MT_COLOR_NORMAL);
 ---- 1771,1791 ----
 -        /* print out the pager status bar */
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       CLEARLINE_WIN (statusoffset);
 -  
 -        if (IsHeader (extra) || IsMsgAttach (extra))
 -        {
 -! 	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
 -  	size_t l2 = sizeof (buffer);
 -  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 -  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 -! 	mutt_paddstr (COLS-SidebarWidth, buffer);
 -        }
 -        else
 -        {
 -  	char bn[STRING];
 -  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 -! 	mutt_paddstr (COLS-SidebarWidth, bn);
 -        }
 -        BKGDSET (MT_COLOR_NORMAL);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -***************
 -*** 1791,1808 ****
 -        /* redraw the pager_index indicator, because the
 -         * flags for this message might have changed. */
 -        menu_redraw_current (index);
 -  
 -        /* print out the index status bar */
 -        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
 -   
 -!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       mutt_paddstr (COLS, buffer);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -        BKGDSET (MT_COLOR_NORMAL);
 -      }
 -  
 -      redraw = 0;
 -  
 -      if (option(OPTBRAILLEFRIENDLY)) {
 ---- 1796,1818 ----
 -        /* redraw the pager_index indicator, because the
 -         * flags for this message might have changed. */
 -        menu_redraw_current (index);
 -+       draw_sidebar(MENU_PAGER);
 -  
 -        /* print out the index status bar */
 -        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
 -   
 -!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       mutt_paddstr (COLS-SidebarWidth, buffer);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -        BKGDSET (MT_COLOR_NORMAL);
 -      }
 -  
 -+     /* if we're not using the index, update every time */
 -+     if ( index == 0 )
 -+       draw_sidebar(MENU_PAGER);
 -+ 
 -      redraw = 0;
 -  
 -      if (option(OPTBRAILLEFRIENDLY)) {
 -***************
 -*** 2729,2734 ****
 ---- 2739,2751 ----
 -  	mutt_what_key ();
 -  	break;
 -  
 -+       case OP_SIDEBAR_SCROLL_UP:
 -+       case OP_SIDEBAR_SCROLL_DOWN:
 -+       case OP_SIDEBAR_NEXT:
 -+       case OP_SIDEBAR_PREV:
 -+ 	scroll_sidebar(ch, MENU_PAGER);
 -+  	break;
 -+ 
 -        default:
 -  	ch = -1;
 -  	break;
 +--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
 +@@ -29,6 +29,7 @@
 + #include "pager.h"
 + #include "attach.h"
 + #include "mbyte.h"
 ++#include "sidebar.h"
 + 
 + #include "mutt_crypt.h"
 + 
 +@@ -1104,6 +1105,7 @@
 +   if (check_attachment_marker ((char *)buf) == 0)
 +     wrap_cols = COLS;
 + 
 ++  wrap_cols -= SidebarWidth;
 +   /* FIXME: this should come from lineInfo */
 +   memset(&mbstate, 0, sizeof(mbstate));
 + 
 +@@ -1778,7 +1780,7 @@
 +     if ((redraw & REDRAW_BODY) || topline != oldtopline)
 +     {
 +       do {
 +-	move (bodyoffset, 0);
 ++	move (bodyoffset, SidebarWidth);
 + 	curline = oldtopline = topline;
 + 	lines = 0;
 + 	force_redraw = 0;
 +@@ -1791,6 +1793,7 @@
 + 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
 + 	    lines++;
 + 	  curline++;
 ++  	  move(lines + bodyoffset, SidebarWidth);
 + 	}
 + 	last_offset = lineInfo[curline].offset;
 +       } while (force_redraw);
 +@@ -1804,6 +1807,7 @@
 + 	  addch ('~');
 + 	addch ('\n');
 + 	lines++;
 ++  	move(lines + bodyoffset, SidebarWidth);
 +       }
 +       /* We are going to update the pager status bar, so it isn't
 +        * necessary to reset to normal color now. */
 +@@ -1827,21 +1831,21 @@
 +       /* print out the pager status bar */
 +       SETCOLOR (MT_COLOR_STATUS);
 +       BKGDSET (MT_COLOR_STATUS);
 +-      CLEARLINE (statusoffset);
 ++      CLEARLINE_WIN (statusoffset);
 + 
 +       if (IsHeader (extra) || IsMsgAttach (extra))
 +       {
 +-	size_t l1 = COLS * MB_LEN_MAX;
 ++	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
 + 	size_t l2 = sizeof (buffer);
 + 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 + 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 +-	mutt_paddstr (COLS, buffer);
 ++	mutt_paddstr (COLS-SidebarWidth, buffer);
 +       }
 +       else
 +       {
 + 	char bn[STRING];
 + 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 +-	mutt_paddstr (COLS, bn);
 ++	mutt_paddstr (COLS-SidebarWidth, bn);
 +       }
 +       BKGDSET (MT_COLOR_NORMAL);
 +       SETCOLOR (MT_COLOR_NORMAL);
 +@@ -1852,18 +1856,23 @@
 +       /* redraw the pager_index indicator, because the
 +        * flags for this message might have changed. */
 +       menu_redraw_current (index);
 ++      draw_sidebar(MENU_PAGER);
 + 
 +       /* print out the index status bar */
 +       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
 +  
 +-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
 ++      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
 +       SETCOLOR (MT_COLOR_STATUS);
 +       BKGDSET (MT_COLOR_STATUS);
 +-      mutt_paddstr (COLS, buffer);
 ++      mutt_paddstr (COLS-SidebarWidth, buffer);
 +       SETCOLOR (MT_COLOR_NORMAL);
 +       BKGDSET (MT_COLOR_NORMAL);
 +     }
 + 
 ++    /* if we're not using the index, update every time */
 ++    if ( index == 0 )
 ++      draw_sidebar(MENU_PAGER);
 ++
 +     redraw = 0;
 + 
 +     if (option(OPTBRAILLEFRIENDLY)) {
 +@@ -2852,6 +2861,13 @@
 + 	mutt_what_key ();
 + 	break;
 + 
 ++      case OP_SIDEBAR_SCROLL_UP:
 ++      case OP_SIDEBAR_SCROLL_DOWN:
 ++      case OP_SIDEBAR_NEXT:
 ++      case OP_SIDEBAR_PREV:
 ++	scroll_sidebar(ch, MENU_PAGER);
 ++ 	break;
 ++
 +       default:
 + 	ch = -1;
 + 	break;
  *** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
  --- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
  ***************
 @@ -1849,3 +1496,108 @@
            FREE (&value);
            return;
          }
 +--- orig/compose.c.orig	2010-04-14 20:50:19.000000000 +0200
 ++++ new/compose.c	2010-09-18 15:29:09.000000000 +0200
 +@@ -72,7 +72,7 @@
 + 
 + #define HDR_XOFFSET 10
 + #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
 +-#define W (COLS - HDR_XOFFSET)
 ++#define W (COLS - HDR_XOFFSET - SidebarWidth)
 + 
 + static char *Prompts[] =
 + {
 +@@ -112,7 +112,7 @@
 + {
 +   int off = 0;
 + 
 +-  mvaddstr (HDR_CRYPT, 0, "Security: ");
 ++  mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
 + 
 +   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
 +   {
 +@@ -144,7 +144,7 @@
 +   }
 + 
 +   clrtoeol ();
 +-  move (HDR_CRYPTINFO, 0);
 ++  move (HDR_CRYPTINFO, SidebarWidth);
 +   clrtoeol ();
 + 
 +   if ((WithCrypto & APPLICATION_PGP)
 +@@ -161,7 +161,7 @@
 +       && (msg->security & ENCRYPT)
 +       && SmimeCryptAlg
 +       && *SmimeCryptAlg) {
 +-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
 ++      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
 + 		NONULL(SmimeCryptAlg));
 +       off = 20;
 +   }
 +@@ -190,7 +190,7 @@
 +     if (t && t[0] == '0' && t[1] == '\0')
 +       t = "<random>";
 +     
 +-    if (c + mutt_strlen (t) + 2 >= COLS)
 ++    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
 +       break;
 + 
 +     addstr (NONULL(t));
 +@@ -242,7 +242,7 @@
 + 
 +   buf[0] = 0;
 +   rfc822_write_address (buf, sizeof (buf), addr, 1);
 +-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
 ++  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
 +   mutt_paddstr (W, buf);
 + }
 + 
 +@@ -252,10 +252,10 @@
 +   draw_envelope_addr (HDR_TO, msg->env->to);
 +   draw_envelope_addr (HDR_CC, msg->env->cc);
 +   draw_envelope_addr (HDR_BCC, msg->env->bcc);
 +-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
 ++  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
 +   mutt_paddstr (W, NONULL (msg->env->subject));
 +   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
 +-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
 ++  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
 +   mutt_paddstr (W, fcc);
 + 
 +   if (WithCrypto)
 +@@ -266,7 +266,7 @@
 + #endif
 + 
 +   SETCOLOR (MT_COLOR_STATUS);
 +-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
 ++  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
 +   BKGDSET (MT_COLOR_STATUS);
 +   clrtoeol ();
 + 
 +@@ -304,7 +304,7 @@
 +   /* redraw the expanded list so the user can see the result */
 +   buf[0] = 0;
 +   rfc822_write_address (buf, sizeof (buf), *addr, 1);
 +-  move (line, HDR_XOFFSET);
 ++  move (line, HDR_XOFFSET+SidebarWidth);
 +   mutt_paddstr (W, buf);
 +   
 +   return 0;
 +@@ -549,7 +549,7 @@
 + 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
 + 	{
 + 	  mutt_str_replace (&msg->env->subject, buf);
 +-	  move (HDR_SUBJECT, HDR_XOFFSET);
 ++	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
 + 	  clrtoeol ();
 + 	  if (msg->env->subject)
 + 	    mutt_paddstr (W, msg->env->subject);
 +@@ -566,7 +566,7 @@
 + 	{
 + 	  strfcpy (fcc, buf, fcclen);
 + 	  mutt_pretty_mailbox (fcc, fcclen);
 +-	  move (HDR_FCC, HDR_XOFFSET);
 ++	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
 + 	  mutt_paddstr (W, fcc);
 + 	  fccSet = 1;
 + 	}
 diff -ru  /usr/ports/mail/mutt-devel/files/extra-patch-sidebar-nntp ./files/extra-patch-sidebar-nntp
 --- /usr/ports/mail/mutt-devel/files/extra-patch-sidebar-nntp	2009-06-23 00:52:30.000000000 +0200
 +++ ./files/extra-patch-sidebar-nntp	2010-09-18 14:22:29.000000000 +0200
 @@ -1,252 +1,220 @@
 -*** mutt-1.5.20-orig/buffy.c	2009-06-02 12:16:26.000000000 -0500
 ---- mutt-1.5.20-patched/buffy.c	2009-06-19 22:37:02.000000000 -0500
 -***************
 -*** 159,164 ****
 ---- 159,207 ----
 -    }
 -  }
 -  
 -+ static int buffy_compare_name(const void *a, const void *b) {
 -+   const BUFFY *b1 = * (BUFFY * const *) a;
 -+   const BUFFY *b2 = * (BUFFY * const *) b;
 -+ 
 -+   return mutt_strcoll(b1->path, b2->path);
 -+ }
 -+ 
 -+ static BUFFY *buffy_sort(BUFFY *b)
 -+ {
 -+   BUFFY *tmp = b;
 -+   int buffycount = 0;
 -+   BUFFY **ary;
 -+   int i;
 -+ 
 -+   if (!option(OPTSIDEBARSORT))
 -+     return b;
 -+ 
 -+   for (; tmp != NULL; tmp = tmp->next)
 -+     buffycount++;
 -+ 
 -+   ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
 -+ 
 -+   tmp = b;
 -+   for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
 -+     ary[i] = tmp;
 -+   }
 -+ 
 -+   qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
 -+ 
 -+   for (i = 0; i < buffycount - 1; i++) {
 -+     ary[i]->next = ary[i+1];
 -+   }
 -+   ary[buffycount - 1]->next = NULL;
 -+   for (i = 1; i < buffycount; i++) {
 -+     ary[i]->prev = ary[i-1];
 -+   }
 -+   ary[0]->prev = NULL;
 -+ 
 -+   tmp = ary[0];
 -+   free(ary);
 -+   return tmp;
 -+ }
 -+ 
 -  BUFFY *mutt_find_mailbox (const char *path)
 -  {
 -    BUFFY *tmp = NULL;
 -***************
 -*** 271,276 ****
 ---- 314,320 ----
 -      else
 -        (*tmp)->size = 0;
 -    }
 -+   Incoming = buffy_sort(Incoming);
 -    return 0;
 -  }
 -  
 -***************
 -*** 290,295 ****
 ---- 334,340 ----
 -    char path[_POSIX_PATH_MAX];
 -    struct stat contex_sb;
 -    time_t t;
 -+   CONTEXT *ctx;
 -  
 -    sb.st_size=0;
 -    contex_sb.st_dev=0;
 -***************
 -*** 329,334 ****
 ---- 374,381 ----
 -    
 -    for (tmp = Incoming; tmp; tmp = tmp->next)
 -    {
 -+     if ( tmp->new == 1 )
 +--- orig/buffy.c.orig	2010-09-18 14:12:40.000000000 +0200
 ++++ new/buffy.c	2010-09-18 14:17:36.000000000 +0200
 +@@ -161,6 +161,49 @@
 +   }
 + }
 + 
 ++static int buffy_compare_name(const void *a, const void *b) {
 ++  const BUFFY *b1 = * (BUFFY * const *) a;
 ++  const BUFFY *b2 = * (BUFFY * const *) b;
 ++
 ++  return mutt_strcoll(b1->path, b2->path);
 ++}
 ++
 ++static BUFFY *buffy_sort(BUFFY *b)
 ++{
 ++  BUFFY *tmp = b;
 ++  int buffycount = 0;
 ++  BUFFY **ary;
 ++  int i;
 ++
 ++  if (!option(OPTSIDEBARSORT))
 ++    return b;
 ++
 ++  for (; tmp != NULL; tmp = tmp->next)
 ++    buffycount++;
 ++
 ++  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
 ++
 ++  tmp = b;
 ++  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
 ++    ary[i] = tmp;
 ++  }
 ++
 ++  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
 ++
 ++  for (i = 0; i < buffycount - 1; i++) {
 ++    ary[i]->next = ary[i+1];
 ++  }
 ++  ary[buffycount - 1]->next = NULL;
 ++  for (i = 1; i < buffycount; i++) {
 ++    ary[i]->prev = ary[i-1];
 ++  }
 ++  ary[0]->prev = NULL;
 ++
 ++  tmp = ary[0];
 ++  free(ary);
 ++  return tmp;
 ++}
 ++
 + BUFFY *mutt_find_mailbox (const char *path)
 + {
 +   BUFFY *tmp = NULL;
 +@@ -282,6 +325,7 @@
 +     else
 +       (*tmp)->size = 0;
 +   }
 ++  Incoming = buffy_sort(Incoming);
 +   return 0;
 + }
 + 
 +@@ -371,12 +415,17 @@
 +   return rc;
 + }
 + 
 ++#define STAT_CHECK_SIZE (sb.st_size > tmp->size)
 ++#define STAT_CHECK_TIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
 ++#define STAT_CHECK (option(OPTCHECKMBOXSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_TIME)
 ++
 + int mutt_buffy_check (int force)
 + {
 +   BUFFY *tmp;
 +   struct stat sb;
 +   struct stat contex_sb;
 +   time_t t;
 ++  CONTEXT *ctx;
 + 
 +   sb.st_size=0;
 +   contex_sb.st_dev=0;
 +@@ -416,6 +465,8 @@
 +   
 +   for (tmp = Incoming; tmp; tmp = tmp->next)
 +   {
 ++    if ( tmp->new == 1 )
  +       tmp->has_new = 1;
 -  #ifdef USE_IMAP
 -      if (tmp->magic != M_IMAP)
 -  #endif
 -***************
 -*** 385,394 ****
 -        case M_MBOX:
 -        case M_MMDF:
 -  
 -! 	if (STAT_CHECK)
 -  	{
 -! 	  BuffyCount++;
 -! 	  tmp->new = 1;
 -  	}
 -  	else if (option(OPTCHECKMBOXSIZE))
 -  	{
 ---- 432,458 ----
 -        case M_MBOX:
 -        case M_MMDF:
 -  
 -!         {
 -! 	if (STAT_CHECK || tmp->msgcount == 0)
 -  	{
 -! 	  BUFFY b = *tmp;
 -!  	  int msgcount = 0;
 -!  	  int msg_unread = 0;
 -!  	  /* parse the mailbox, to see how much mail there is */
 -!  	  ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
 -!  	  if(ctx)
 -!  	  {
 -!             msgcount = ctx->msgcount;
 -!  	    msg_unread = ctx->unread;
 -!  	    mx_close_mailbox(ctx, 0);
 -!  	  }
 -!  	  *tmp = b;
 -!  	  tmp->msgcount = msgcount;
 -!  	  tmp->msg_unread = msg_unread;
 -!  	  if(STAT_CHECK) {
 -!  	    tmp->has_new = tmp->new = 1;
 -! 	    BuffyCount++;
 -!           }  
 -  	}
 -  	else if (option(OPTCHECKMBOXSIZE))
 -  	{
 -***************
 -*** 398,432 ****
 -  	if (tmp->newly_created &&
 -  	    (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 -  	  tmp->newly_created = 0;
 -! 
 -  	break;
 -  
 -        case M_MAILDIR:
 -  
 -  	snprintf (path, sizeof (path), "%s/new", tmp->path);
 -  	if ((dirp = opendir (path)) == NULL)
 -  	{
 -  	  tmp->magic = 0;
 -  	  break;
 -  	}
 -  	while ((de = readdir (dirp)) != NULL)
 -  	{
 -  	  char *p;
 -  	  if (*de->d_name != '.' && 
 -  	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 -  	  {
 -! 	    /* one new and undeleted message is enough */
 -! 	    BuffyCount++;
 -! 	    tmp->new = 1;
 -! 	    break;
 -  	  }
 -  	}
 -  	closedir (dirp);
 -  	break;
 -  
 -        case M_MH:
 -  	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 -  	  BuffyCount++;
 -  	break;
 -        }
 -      }
 ---- 462,547 ----
 -  	if (tmp->newly_created &&
 -  	    (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 -  	  tmp->newly_created = 0;
 -!         }
 -  	break;
 -  
 -        case M_MAILDIR:
 -  
 -+         /* count new message */
 -  	snprintf (path, sizeof (path), "%s/new", tmp->path);
 -  	if ((dirp = opendir (path)) == NULL)
 -  	{
 -  	  tmp->magic = 0;
 -  	  break;
 -  	}
 -+   	tmp->msgcount = 0;
 -+   	tmp->msg_unread = 0;
 -+   	tmp->msg_flagged = 0;
 -  	while ((de = readdir (dirp)) != NULL)
 -  	{
 -  	  char *p;
 -  	  if (*de->d_name != '.' && 
 -  	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 -  	  {
 -!  	    tmp->has_new = tmp->new = 1;
 -!             tmp->msgcount++;
 -!             tmp->msg_unread++;
 -!  	  }
 -!  	}
 -!         if(tmp->msg_unread)
 -!           BuffyCount++;
 -!  
 -!  	closedir (dirp);
 -!  
 -!         /*
 -!          * count read messages (for folderlist (sidebar) we also need to count
 -!          * messages in cur so that we the total number of messages
 -!          */
 -!  	snprintf (path, sizeof (path), "%s/cur", tmp->path);
 -!  	if ((dirp = opendir (path)) == NULL)
 -!   	{
 -!   	  tmp->magic = 0;
 -!   	  break;
 -!   	}
 -!   	while ((de = readdir (dirp)) != NULL)
 -!   	{
 -!   	  char *p;
 -!           if (*de->d_name != '.') {
 -!                   if ((p = strstr (de->d_name, ":2,"))) {
 -!                           if (!strchr (p + 3, 'T')) {
 -!                                   tmp->msgcount++;
 -!                                   if ( !strchr (p + 3, 'S'))
 -!                                           tmp->msg_unread++;
 -!                                   if (strchr(p + 3, 'F'))
 -!                                           tmp->msg_flagged++;
 -!                           }
 -!                   } else
 -!                           tmp->msgcount++;
 -  	  }
 -  	}
 -  	closedir (dirp);
 -  	break;
 -  
 -        case M_MH:
 -+       {
 -+       DIR *dp;
 -+       struct dirent *de;
 -  	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 -  	  BuffyCount++;
 -+     
 -+       if ((dp = opendir (path)) == NULL)
 -+         break;
 -+       tmp->msgcount = 0;
 -+       while ((de = readdir (dp)))
 -+       {
 -+         if (mh_valid_message (de->d_name))
 -+         {
 -+ 	  tmp->msgcount++;
 -+  	  tmp->has_new = tmp->new = 1;
 -+         }
 -+       }
 -+       closedir (dp);
 -+       }
 -  	break;
 -        }
 -      }
 +     if (tmp->magic != M_IMAP)
 +     {
 +       tmp->new = 0;
 +@@ -455,18 +506,122 @@
 +       {
 +       case M_MBOX:
 +       case M_MMDF:
 +-	if (buffy_mbox_hasnew (tmp, &sb) > 0)
 +-	  BuffyCount++;
 +-	break;
 ++        {
 ++          if (STAT_CHECK || tmp->msgcount == 0)
 ++          {
 ++            BUFFY b = *tmp;
 ++            int msgcount = 0;
 ++            int msg_unread = 0;
 ++            /* parse the mailbox, to see how much mail there is */
 ++            ctx = mx_open_mailbox( tmp->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
 ++            if(ctx)
 ++            {
 ++              msgcount = ctx->msgcount;
 ++              msg_unread = ctx->unread;
 ++              mx_close_mailbox(ctx, 0);
 ++            }
 ++            *tmp = b;
 ++            tmp->msgcount = msgcount;
 ++            tmp->msg_unread = msg_unread;
 ++            if(STAT_CHECK) {
 ++              tmp->has_new = tmp->new = 1;
 ++              BuffyCount++;
 ++            }
 ++          }
 ++          else if (option(OPTCHECKMBOXSIZE))
 ++          {
 ++            /* some other program has deleted mail from the folder */
 ++            tmp->size = (off_t) sb.st_size;
 ++          }
 ++          if (tmp->newly_created &&
 ++              (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 ++            tmp->newly_created = 0;
 ++        }
 ++        break;
 ++
 + 
 +       case M_MAILDIR:
 +-	if (buffy_maildir_hasnew (tmp) > 0)
 +-	  BuffyCount++;
 ++        { 
 ++        char path[_POSIX_PATH_MAX];
 ++        DIR *dirp;
 ++        struct dirent *de;
 ++        /* count new message */
 ++        snprintf (path, sizeof (path), "%s/new", tmp->path);
 ++        if ((dirp = opendir (path)) == NULL)
 ++        {
 ++          tmp->magic = 0;
 ++          break;
 ++        }
 ++        tmp->msgcount = 0;
 ++        tmp->msg_unread = 0;
 ++        tmp->msg_flagged = 0;
 ++        while ((de = readdir (dirp)) != NULL)
 ++        {
 ++          char *p;
 ++          if (*de->d_name != '.' &&
 ++              (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 ++          {
 ++            tmp->has_new = tmp->new = 1;
 ++            tmp->msgcount++;
 ++            tmp->msg_unread++;
 ++          }
 ++        }
 ++        if(tmp->msg_unread)
 ++          BuffyCount++;
 ++
 ++        closedir (dirp);
 ++
 ++        /*
 ++         * count read messages (for folderlist (sidebar) we also need to count
 ++         * messages in cur so that we the total number of messages
 ++         */
 ++        snprintf (path, sizeof (path), "%s/cur", tmp->path);
 ++        if ((dirp = opendir (path)) == NULL)
 ++        {
 ++          tmp->magic = 0;
 ++          break;
 ++        }
 ++        while ((de = readdir (dirp)) != NULL)
 ++        {
 ++          char *p;
 ++          if (*de->d_name != '.') {
 ++                  if ((p = strstr (de->d_name, ":2,"))) {
 ++                          if (!strchr (p + 3, 'T')) {
 ++                                  tmp->msgcount++;
 ++                                  if ( !strchr (p + 3, 'S'))
 ++                                          tmp->msg_unread++;
 ++                                  if (strchr(p + 3, 'F'))
 ++                                          tmp->msg_flagged++;
 ++                          }
 ++                  } else
 ++                          tmp->msgcount++;
 ++          }
 ++        }
 ++        closedir (dirp);
 ++        } 
 + 	break;
 + 
 +       case M_MH:
 +-	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 +-	  BuffyCount++;
 ++        {
 ++        DIR *dp;
 ++        char path[_POSIX_PATH_MAX];
 ++        struct dirent *de;
 ++        if ((tmp->new = mh_buffy (tmp->path)) > 0)
 ++          BuffyCount++;
 ++
 ++        if ((dp = opendir (path)) == NULL)
 ++          break;
 ++        tmp->msgcount = 0;
 ++        while ((de = readdir (dp)))
 ++        {
 ++          if (mh_valid_message (de->d_name))
 ++          {
 ++            tmp->msgcount++;
 ++            tmp->has_new = tmp->new = 1;
 ++          }
 ++        }
 ++        closedir (dp);
 ++        }
 + 	break;
 +       }
 +     }
  *** mutt-1.5.20-orig/buffy.h	2009-04-30 00:36:16.000000000 -0500
  --- mutt-1.5.20-patched/buffy.h	2009-06-19 22:07:04.000000000 -0500
  ***************
 @@ -536,81 +504,46 @@
    
    /* mx_open_new_message() */
    #define M_ADD_FROM	1	/* add a From_ line */
 -*** mutt-1.5.20-orig/Makefile.am	2009-01-04 20:11:29.000000000 -0600
 ---- mutt-1.5.20-patched/Makefile.am	2009-06-19 22:07:04.000000000 -0500
 -***************
 -*** 29,35 ****
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  
 ---- 29,36 ----
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h \
 -!         sidebar.c
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  
 -*** mutt-1.5.20-orig/Makefile.in	2009-06-09 01:50:44.000000000 -0500
 ---- mutt-1.5.20-patched/Makefile.in	2009-06-19 22:07:04.000000000 -0500
 -***************
 -*** 85,91 ****
 -  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 -  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 -  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 -! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT)
 -  am__objects_1 = patchlist.$(OBJEXT)
 -  nodist_mutt_OBJECTS = $(am__objects_1)
 -  mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
 ---- 85,92 ----
 -  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 -  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 -  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 -! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) \
 -! 	sidebar.$(OBJEXT)
 -  am__objects_1 = patchlist.$(OBJEXT)
 -  nodist_mutt_OBJECTS = $(am__objects_1)
 -  mutt_OBJECTS = $(am_mutt_OBJECTS) $(nodist_mutt_OBJECTS)
 -***************
 -*** 356,362 ****
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 ---- 357,364 ----
 -  	score.c send.c sendlib.c signal.c sort.c \
 -  	status.c system.c thread.c charset.c history.c lib.c \
 -  	muttlib.c editmsg.c mbyte.c \
 -! 	url.c ascii.c crypt-mod.c crypt-mod.h \
 -! 	sidebar.c
 -  
 -  nodist_mutt_SOURCES = $(BUILT_SOURCES)
 -  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 -***************
 -*** 388,394 ****
 -  	README.SSL smime.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
 -  
 -  EXTRA_SCRIPTS = smime_keys
 -  mutt_dotlock_SOURCES = mutt_dotlock.c
 ---- 390,396 ----
 -  	README.SSL smime.h \
 -  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
 -  	ChangeLog mkchangelog.sh mutt_idna.h \
 -! 	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
 -  
 -  EXTRA_SCRIPTS = smime_keys
 -  mutt_dotlock_SOURCES = mutt_dotlock.c
 +--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
 +@@ -34,7 +34,7 @@
 + 	score.c send.c sendlib.c signal.c sort.c \
 + 	status.c system.c thread.c charset.c history.c lib.c \
 + 	muttlib.c editmsg.c mbyte.c \
 +-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
 ++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
 + 
 + nodist_mutt_SOURCES = $(BUILT_SOURCES)
 + 
 +--- orig/Makefile.in.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/Makefile.in	2010-09-18 13:27:19.000000000 +0200
 +@@ -89,7 +89,7 @@
 + 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
 + 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
 + 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
 +-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
 ++	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
 + am__objects_1 =
 + am__objects_2 = patchlist.$(OBJEXT) $(am__objects_1)
 + nodist_mutt_OBJECTS = $(am__objects_2)
 +@@ -363,7 +363,7 @@
 + 	score.c send.c sendlib.c signal.c sort.c \
 + 	status.c system.c thread.c charset.c history.c lib.c \
 + 	muttlib.c editmsg.c mbyte.c \
 +-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
 ++	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
 + 
 + nodist_mutt_SOURCES = $(BUILT_SOURCES)
 + mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
 +@@ -397,7 +397,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
 ++	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in
 + 
 + EXTRA_SCRIPTS = smime_keys
 + mutt_dotlock_SOURCES = mutt_dotlock.c
  *** mutt-1.5.20-orig/mbox.c	2009-06-10 23:29:41.000000000 -0500
  --- mutt-1.5.20-patched/mbox.c	2009-06-19 22:07:04.000000000 -0500
  ***************
 @@ -1001,171 +934,115 @@
  + OP_SIDEBAR_NEXT "go down to next mailbox"
  + OP_SIDEBAR_PREV "go to previous mailbox"
  + OP_SIDEBAR_OPEN "open hilighted mailbox"
 -*** mutt-1.5.20-orig/pager.c	2009-06-03 15:48:31.000000000 -0500
 ---- mutt-1.5.20-patched/pager.c	2009-06-19 22:19:58.000000000 -0500
 -***************
 -*** 29,34 ****
 ---- 29,35 ----
 -  #include "pager.h"
 -  #include "attach.h"
 -  #include "mbyte.h"
 -+ #include "sidebar.h"
 -  
 -  #include "mutt_crypt.h"
 -  
 -***************
 -*** 1071,1076 ****
 ---- 1072,1079 ----
 -    mbstate_t mbstate;
 -  
 -    int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
 -+ 
 -+   wrap_cols -= SidebarWidth;
 -    
 -    /* FIXME: this should come from lineInfo */
 -    memset(&mbstate, 0, sizeof(mbstate));
 -***************
 -*** 1717,1723 ****
 -      if ((redraw & REDRAW_BODY) || topline != oldtopline)
 -      {
 -        do {
 -! 	move (bodyoffset, 0);
 -  	curline = oldtopline = topline;
 -  	lines = 0;
 -  	force_redraw = 0;
 ---- 1720,1726 ----
 -      if ((redraw & REDRAW_BODY) || topline != oldtopline)
 -      {
 -        do {
 -! 	move (bodyoffset, SidebarWidth);
 -  	curline = oldtopline = topline;
 -  	lines = 0;
 -  	force_redraw = 0;
 -***************
 -*** 1730,1735 ****
 ---- 1733,1739 ----
 -  			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
 -  	    lines++;
 -  	  curline++;
 -+   	  move(lines + bodyoffset, SidebarWidth);
 -  	}
 -  	last_offset = lineInfo[curline].offset;
 -        } while (force_redraw);
 -***************
 -*** 1743,1748 ****
 ---- 1747,1753 ----
 -  	  addch ('~');
 -  	addch ('\n');
 -  	lines++;
 -+   	move(lines + bodyoffset, SidebarWidth);
 -        }
 -        /* We are going to update the pager status bar, so it isn't
 -         * necessary to reset to normal color now. */
 -***************
 -*** 1766,1786 ****
 -        /* print out the pager status bar */
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       CLEARLINE (statusoffset);
 -  
 -        if (IsHeader (extra) || IsMsgAttach (extra))
 -        {
 -! 	size_t l1 = COLS * MB_LEN_MAX;
 -  	size_t l2 = sizeof (buffer);
 -  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 -  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 -! 	mutt_paddstr (COLS, buffer);
 -        }
 -        else
 -        {
 -  	char bn[STRING];
 -  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 -! 	mutt_paddstr (COLS, bn);
 -        }
 -        BKGDSET (MT_COLOR_NORMAL);
 -        SETCOLOR (MT_COLOR_NORMAL);
 ---- 1771,1791 ----
 -        /* print out the pager status bar */
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       CLEARLINE_WIN (statusoffset);
 -  
 -        if (IsHeader (extra) || IsMsgAttach (extra))
 -        {
 -! 	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
 -  	size_t l2 = sizeof (buffer);
 -  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 -  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 -! 	mutt_paddstr (COLS-SidebarWidth, buffer);
 -        }
 -        else
 -        {
 -  	char bn[STRING];
 -  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 -! 	mutt_paddstr (COLS-SidebarWidth, bn);
 -        }
 -        BKGDSET (MT_COLOR_NORMAL);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -***************
 -*** 1791,1808 ****
 -        /* redraw the pager_index indicator, because the
 -         * flags for this message might have changed. */
 -        menu_redraw_current (index);
 -  
 -        /* print out the index status bar */
 -        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
 -   
 -!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       mutt_paddstr (COLS, buffer);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -        BKGDSET (MT_COLOR_NORMAL);
 -      }
 -  
 -      redraw = 0;
 -  
 -      if (option(OPTBRAILLEFRIENDLY)) {
 ---- 1796,1818 ----
 -        /* redraw the pager_index indicator, because the
 -         * flags for this message might have changed. */
 -        menu_redraw_current (index);
 -+       draw_sidebar(MENU_PAGER);
 -  
 -        /* print out the index status bar */
 -        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
 -   
 -!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
 -        SETCOLOR (MT_COLOR_STATUS);
 -        BKGDSET (MT_COLOR_STATUS);
 -!       mutt_paddstr (COLS-SidebarWidth, buffer);
 -        SETCOLOR (MT_COLOR_NORMAL);
 -        BKGDSET (MT_COLOR_NORMAL);
 -      }
 -  
 -+     /* if we're not using the index, update every time */
 -+     if ( index == 0 )
 -+       draw_sidebar(MENU_PAGER);
 -+ 
 -      redraw = 0;
 -  
 -      if (option(OPTBRAILLEFRIENDLY)) {
 -***************
 -*** 2729,2734 ****
 ---- 2739,2751 ----
 -  	mutt_what_key ();
 -  	break;
 +--- orig/pager.c.orig	2010-09-18 13:23:19.000000000 +0200
 ++++ new/pager.c	2010-09-18 14:03:08.000000000 +0200
 +@@ -29,6 +29,7 @@
 + #include "pager.h"
 + #include "attach.h"
 + #include "mbyte.h"
 ++#include "sidebar.h"
 + 
 + #include "mutt_crypt.h"
 + 
 +@@ -1104,6 +1105,7 @@
 +   if (check_attachment_marker ((char *)buf) == 0)
 +     wrap_cols = COLS;
 + 
 ++  wrap_cols -= SidebarWidth;
 +   /* FIXME: this should come from lineInfo */
 +   memset(&mbstate, 0, sizeof(mbstate));
 + 
 +@@ -1778,7 +1780,7 @@
 +     if ((redraw & REDRAW_BODY) || topline != oldtopline)
 +     {
 +       do {
 +-	move (bodyoffset, 0);
 ++	move (bodyoffset, SidebarWidth);
 + 	curline = oldtopline = topline;
 + 	lines = 0;
 + 	force_redraw = 0;
 +@@ -1791,6 +1793,7 @@
 + 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
 + 	    lines++;
 + 	  curline++;
 ++  	  move(lines + bodyoffset, SidebarWidth);
 + 	}
 + 	last_offset = lineInfo[curline].offset;
 +       } while (force_redraw);
 +@@ -1804,6 +1807,7 @@
 + 	  addch ('~');
 + 	addch ('\n');
 + 	lines++;
 ++  	move(lines + bodyoffset, SidebarWidth);
 +       }
 +       /* We are going to update the pager status bar, so it isn't
 +        * necessary to reset to normal color now. */
 +@@ -1827,21 +1831,21 @@
 +       /* print out the pager status bar */
 +       SETCOLOR (MT_COLOR_STATUS);
 +       BKGDSET (MT_COLOR_STATUS);
 +-      CLEARLINE (statusoffset);
 ++      CLEARLINE_WIN (statusoffset);
 + 
 +       if (IsHeader (extra) || IsMsgAttach (extra))
 +       {
 +-	size_t l1 = COLS * MB_LEN_MAX;
 ++	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
 + 	size_t l2 = sizeof (buffer);
 + 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
 + 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
 +-	mutt_paddstr (COLS, buffer);
 ++	mutt_paddstr (COLS-SidebarWidth, buffer);
 +       }
 +       else
 +       {
 + 	char bn[STRING];
 + 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
 +-	mutt_paddstr (COLS, bn);
 ++	mutt_paddstr (COLS-SidebarWidth, bn);
 +       }
 +       BKGDSET (MT_COLOR_NORMAL);
 +       SETCOLOR (MT_COLOR_NORMAL);
 +@@ -1852,18 +1856,23 @@
 +       /* redraw the pager_index indicator, because the
 +        * flags for this message might have changed. */
 +       menu_redraw_current (index);
 ++      draw_sidebar(MENU_PAGER);
 + 
 +       /* print out the index status bar */
 +       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
    
 -+       case OP_SIDEBAR_SCROLL_UP:
 -+       case OP_SIDEBAR_SCROLL_DOWN:
 -+       case OP_SIDEBAR_NEXT:
 -+       case OP_SIDEBAR_PREV:
 -+ 	scroll_sidebar(ch, MENU_PAGER);
 -+  	break;
 -+ 
 -        default:
 -  	ch = -1;
 -  	break;
 +-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
 ++      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
 +       SETCOLOR (MT_COLOR_STATUS);
 +       BKGDSET (MT_COLOR_STATUS);
 +-      mutt_paddstr (COLS, buffer);
 ++      mutt_paddstr (COLS-SidebarWidth, buffer);
 +       SETCOLOR (MT_COLOR_NORMAL);
 +       BKGDSET (MT_COLOR_NORMAL);
 +     }
 + 
 ++    /* if we're not using the index, update every time */
 ++    if ( index == 0 )
 ++      draw_sidebar(MENU_PAGER);
 ++
 +     redraw = 0;
 + 
 +     if (option(OPTBRAILLEFRIENDLY)) {
 +@@ -2852,6 +2861,13 @@
 + 	mutt_what_key ();
 + 	break;
 + 
 ++      case OP_SIDEBAR_SCROLL_UP:
 ++      case OP_SIDEBAR_SCROLL_DOWN:
 ++      case OP_SIDEBAR_NEXT:
 ++      case OP_SIDEBAR_PREV:
 ++	scroll_sidebar(ch, MENU_PAGER);
 ++ 	break;
 ++
 +       default:
 + 	ch = -1;
 + 	break;
  *** mutt-1.5.20-orig/PATCHES	2008-11-11 13:55:46.000000000 -0600
  --- mutt-1.5.20-patched/PATCHES	2009-06-19 22:20:31.000000000 -0500
  ***************
 @@ -1619,8 +1496,8 @@
            FREE (&value);
            return;
          }
 ---- mutt-1.5.20-orig/compose.c.orig	2009-06-22 15:29:56.000000000 +0200
 -+++ mutt-1.5.20-patched/compose.c	2009-06-22 15:33:16.000000000 +0200
 +--- orig/compose.c.orig	2010-09-18 13:23:18.000000000 +0200
 ++++ new/compose.c	2010-09-18 14:01:09.000000000 +0200
  @@ -80,7 +80,7 @@
   
   #define HDR_XOFFSET 14
 @@ -1630,37 +1507,24 @@
   
   static char *Prompts[] =
   {
 -@@ -146,16 +146,16 @@
 -   if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
 -   {     
 -     if (!msg->security)
 --      mvaddstr (HDR_CRYPT, 0,     "    Security: ");
 -+      mvaddstr (HDR_CRYPT, SidebarWidth,     "    Security: ");
 -     else if (msg->security & APPLICATION_SMIME)
 --      mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
 -+      mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
 -     else if (msg->security & APPLICATION_PGP)
 --      mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
 -+      mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
 +@@ -143,7 +143,7 @@
 + {
 +   int off = 0;
 + 
 +-  mvprintw (HDR_CRYPT, 0, TITLE_FMT, "Security: ");
 ++  mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: ");
 + 
 +   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
 +   {
 +@@ -175,7 +175,7 @@
     }
 -   else if ((WithCrypto & APPLICATION_SMIME))
 --    mvaddstr (HDR_CRYPT, 0,     "      S/MIME: ");
 -+    mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
 -   else if ((WithCrypto & APPLICATION_PGP))
 --    mvaddstr (HDR_CRYPT, 0,     "         PGP: ");
 -+    mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
 -   else
 -     return;
   
 -@@ -179,7 +179,7 @@
 -     }
     clrtoeol ();
 - 
  -  move (HDR_CRYPTINFO, 0);
  +  move (HDR_CRYPTINFO, SidebarWidth);
     clrtoeol ();
 + 
     if ((WithCrypto & APPLICATION_PGP)
 -       && msg->security & APPLICATION_PGP  && msg->security & SIGN)
  @@ -195,7 +195,7 @@
         && (msg->security & ENCRYPT)
         && SmimeCryptAlg
 @@ -1670,15 +1534,6 @@
   		NONULL(SmimeCryptAlg));
         off = 20;
     }
 -@@ -209,7 +209,7 @@
 -   int c;
 -   char *t;
 - 
 --  mvaddstr (HDR_MIX, 0,     "     Mix: ");
 -+  mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
 - 
 -   if (!chain)
 -   {
  @@ -224,7 +224,7 @@
       if (t && t[0] == '0' && t[1] == '\0')
         t = "<random>";
 @@ -1759,4 +1614,3 @@
  +	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
   	  mutt_paddstr (W, fcc);
   	  fccSet = 1;
 - 	}
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-02 ./files/patch-02
 --- /usr/ports/mail/mutt-devel/files/patch-02	2009-02-09 17:58:46.000000000 +0100
 +++ ./files/patch-02	2010-09-17 16:33:17.000000000 +0200
 @@ -1,15 +1,15 @@
 ---- doc/Makefile.am.orig	2009-02-06 13:25:21.000000000 +0100
 -+++ doc/Makefile.am	2009-02-06 13:27:06.000000000 +0100
 -@@ -44,7 +44,7 @@
 +--- doc/Makefile.am.orig	2010-09-17 16:04:58.000000000 +0200
 ++++ doc/Makefile.am	2010-09-17 16:09:09.000000000 +0200
 +@@ -47,7 +47,7 @@
   
   all: makedoc-all
   
 --makedoc-all: mutt.1 muttrc.man manual.html stamp-doc-rc stamp-doc-chunked manual.txt
 -+makedoc-all: mutt.1 muttrc.man
 +-makedoc-all: mutt.1 smime_keys.1 muttrc.man manual.html stamp-doc-rc stamp-doc-chunked manual.txt
 ++makedoc-all: mutt.1 smime_keys.1 muttrc.man
   
   install-data-local: makedoc-all instdoc
   	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/man1
 -@@ -66,9 +66,6 @@
 +@@ -70,9 +70,6 @@
   		$(INSTALL) -m 644 $(srcdir)/$$f $(DESTDIR)$(docdir) ; \
   	done
   	-$(INSTALL) -m 644 manual.txt $(DESTDIR)$(docdir)
 @@ -19,14 +19,14 @@
   	$(INSTALL) -m 644 Muttrc $(DESTDIR)$(sysconfdir)/Muttrc.dist
   	-if [ -f $(DESTDIR)$(pkgdatadir)/Muttrc ] ; then \
   		mv $(DESTDIR)$(pkgdatadir)/Muttrc* $(DESTDIR)$(sysconfdir) ; \
 -@@ -99,9 +96,7 @@
 +@@ -103,9 +100,7 @@
   
   check:
   manual.txt: manual.html
 --	-LC_ALL=C lynx -dump -nolist -with_backspaces manual.html > $@ || \
 +-	-LC_ALL=C lynx -dump -nolist -with_backspaces -display_charset=us-ascii manual.html > $@ || \
  -	LC_ALL=C w3m -dump manual.html > $@ || \
  -	LC_ALL=C elinks -dump -no-numbering -no-references manual.html | sed -e 's,\\001, ,g' > $@
 -+	-LC_ALL=C lynx -dump -nolist -with_backspaces manual.html > $@
 ++	-LC_ALL=C lynx -dump -nolist -with_backspaces -display_charset=us-ascii manual.html > $@
   
   Muttrc: stamp-doc-rc
   
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-buffy.c ./files/patch-buffy.c
 --- /usr/ports/mail/mutt-devel/files/patch-buffy.c	2010-05-21 13:13:47.000000000 +0200
 +++ ./files/patch-buffy.c	1970-01-01 01:00:00.000000000 +0100
 @@ -1,10 +0,0 @@
 ---- buffy.c.orig	2009-06-02 19:16:26.000000000 +0200
 -+++ buffy.c	2010-05-18 07:41:47.000000000 +0200
 -@@ -236,7 +236,6 @@
 -     {
 -       if(*tmp)
 -       {
 --        FREE (&((*tmp)->path));
 -         tmp1=(*tmp)->next;
 -         FREE (tmp);		/* __FREE_CHECKED__ */
 -         *tmp=tmp1;
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-doc-manual.xml.head ./files/patch-doc-manual.xml.head
 --- /usr/ports/mail/mutt-devel/files/patch-doc-manual.xml.head	2009-06-23 00:52:30.000000000 +0200
 +++ ./files/patch-doc-manual.xml.head	2010-09-17 16:33:18.000000000 +0200
 @@ -8,12 +8,3 @@
   <book>
   
   <bookinfo>
 -@@ -7271,7 +7271,7 @@
 - <para>
 - The built-in SMTP support supports encryption (the <literal>smtps</literal> protocol
 - using SSL or TLS) as well as SMTP authentication using SASL. The authentication mechanisms
 --for SASL are specified in <link linkend="smtp-authenticators">&dollar;smtp&lowbar;authenticators</link>
 -+for SASL are specified in <literal>&dollar;smtp&lowbar;authenticators</literal>
 - defaulting to an empty list which makes Mutt try all available methods
 - from most-secure to least-secure.
 - </para>
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-mktemp ./files/patch-mktemp
 --- /usr/ports/mail/mutt-devel/files/patch-mktemp	2009-02-09 17:58:46.000000000 +0100
 +++ ./files/patch-mktemp	2010-09-19 10:38:08.000000000 +0200
 @@ -1,15 +1,23 @@
 ---- muttlib.c.orig	2009-02-06 13:39:51.000000000 +0100
 -+++ muttlib.c	2009-02-06 13:42:35.000000000 +0100
 -@@ -733,7 +733,11 @@
 +--- muttlib.c.orig	2010-09-19 09:58:24.000000000 +0200
 ++++ muttlib.c	2010-09-19 10:36:26.000000000 +0200
 +@@ -788,14 +788,15 @@
   
 - void _mutt_mktemp (char *s, const char *src, int line)
 + void _mutt_mktemp (char *s, size_t slen, const char *src, int line)
   {
 --  snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d-%d", NONULL (Tempdir), NONULL(Hostname), (int) getuid(), (int) getpid (), Counter++);
 -+  char t[7];
 -+  snprintf (t, 7, "-%05d", Counter++);
 -+  snprintf (s, _POSIX_PATH_MAX-6, "%s/mutt-%s-XXXXXXXX", NONULL(Tempdir), NONULL(Hostname));
 -+  mktemp (s);
 -+  strncat(s, t, 6);
 -   dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
 -   unlink (s);
 +-  size_t n = snprintf (s, slen, "%s/mutt-%s-%d-%d-%ld%ld", NONULL (Tempdir), NONULL (Hostname),
 +-      (int) getuid (), (int) getpid (), random (), random ());
 ++  size_t n = snprintf (s, slen, "%s/mutt-%s-XXXXXXXX", NONULL (Tempdir), NONULL (Hostname));
 +   if (n >= slen)
 +     dprint (1, (debugfile, "%s:%d: ERROR: insufficient buffer space to hold temporary filename! slen=%zu but need %zu\n",
 + 	    src, line, slen, n));
 +-  dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
 +-  if (unlink (s) && errno != ENOENT)
 +-    dprint (1, (debugfile, "%s:%d: ERROR: unlink(\"%s\"): %s (errno %d)\n", src, line, s, strerror (errno), errno));
 ++  if (mktemp (s)) { 
 ++    dprint (3, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
 ++  } else {
 ++    dprint (1, (debugfile, "%s:%d: ERROR: mktemp(\"%s\"): %s (errno %d)\n", src, line, s, strerror (errno), errno));
 ++  }
   }
 + 
 + void mutt_free_alias (ALIAS **p)
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-mutt-ssl.c ./files/patch-mutt-ssl.c
 --- /usr/ports/mail/mutt-devel/files/patch-mutt-ssl.c	2010-05-05 23:27:19.000000000 +0200
 +++ ./files/patch-mutt-ssl.c	1970-01-01 01:00:00.000000000 +0100
 @@ -1,11 +0,0 @@
 ---- mutt_ssl.c.orig	2009-06-10 07:08:29.000000000 +0200
 -+++ mutt_ssl.c	2010-05-03 10:45:21.000000000 +0200
 -@@ -652,7 +652,7 @@
 -   char *buf = NULL;
 -   int bufsize;
 -   /* needed to get the DNS subjectAltNames: */
 --  STACK *subj_alt_names;
 -+  STACK_OF(GENERAL_NAME) *subj_alt_names;
 -   int subj_alt_names_count;
 -   GENERAL_NAME *subj_alt_name;
 -   /* did we find a name matching hostname? */
 diff -ru  /usr/ports/mail/mutt-devel/files/patch-pgp ./files/patch-pgp
 --- /usr/ports/mail/mutt-devel/files/patch-pgp	1970-01-01 01:00:00.000000000 +0100
 +++ ./files/patch-pgp	2010-09-17 16:59:16.000000000 +0200
 @@ -0,0 +1,134 @@
 +--- crypt-gpgme.c~	2010-09-10 07:41:33.584316201 +1000
 ++++ crypt-gpgme.c	2010-09-10 08:22:32.948976728 +1000
 +@@ -2003,12 +2003,14 @@
 +   {
 +     if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15))
 +     {
 +-      if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
 ++      if (!mutt_strcmp ("MESSAGE-----\n", buf + 15) ||
 ++	  !mutt_strcmp ("MESSAGE-----\r\n", buf + 15))
 +       {
 + 	enc = 1;
 + 	break;
 +       }
 +-      else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
 ++      else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) ||
 ++	       !mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15))
 +       {
 + 	sgn = 1;
 + 	break;
 +@@ -2128,7 +2130,8 @@
 +       continue;
 +     }
 + 
 +-    if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
 ++    if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") ||
 ++	!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\r\n"))
 +       break;
 +     
 +     if (armor_header)
 +@@ -2196,14 +2199,17 @@
 +           clearsign = 0;
 +           start_pos = last_pos;
 +           
 +-          if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
 ++          if (!mutt_strcmp ("MESSAGE-----\n", buf + 15) ||
 ++	      !mutt_strcmp ("MESSAGE-----\r\n", buf + 15))
 +             needpass = 1;
 +-          else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
 ++          else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) ||
 ++		   !mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15))
 +             {
 +               clearsign = 1;
 +               needpass = 0;
 +             }
 +-          else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15))
 ++          else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) ||
 ++		   !mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15))
 +           {
 +             needpass = 0;
 +             pgp_keyblock = 1;
 +--- pgp.c~	2009-05-31 03:20:08.000000000 +1000
 ++++ pgp.c	2010-09-10 08:27:40.317064142 +1000
 +@@ -219,7 +219,8 @@
 +       continue;
 +     }
 + 
 +-    if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
 ++    if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0 ||
 ++	mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\r\n") == 0)
 +       break;
 +     
 +     if (armor_header)
 +@@ -287,14 +288,17 @@
 +       clearsign = 0;
 +       start_pos = last_pos;
 + 
 +-      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
 ++      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0 ||
 ++	  mutt_strcmp ("MESSAGE-----\r\n", buf + 15) == 0)
 +         needpass = 1;
 +-      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
 ++      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0 ||
 ++	       mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15) == 0)
 +       {
 + 	clearsign = 1;
 +         needpass = 0;
 +       }
 +-      else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15))
 ++      else if (!mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) ||
 ++	       !mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15))
 +       {
 +         needpass = 0;
 +         pgp_keyblock = 1;
 +@@ -327,10 +331,14 @@
 + 	
 + 	fputs (buf, tmpfp);
 + 
 +-	if ((needpass && mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0) ||
 +-	    (!needpass 
 +-             && (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0
 +-                 || mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0)))
 ++	if ((needpass &&
 ++	     (mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0 ||
 ++	      mutt_strcmp ("-----END PGP MESSAGE-----\r\n", buf) == 0)) ||
 ++	    (!needpass &&
 ++	     (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0 ||
 ++	      mutt_strcmp ("-----END PGP SIGNATURE-----\r\n", buf) == 0 ||
 ++	      mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0 ||
 ++	      mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\r\n",buf) == 0)))
 + 	  break;
 + 	/* remember optional Charset: armor header as defined by RfC4880 */
 + 	if (mutt_strncmp ("Charset: ", buf, 9) == 0)
 +@@ -554,11 +562,14 @@
 +   {
 +     if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
 +     {
 +-      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
 ++      if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0 ||
 ++	  mutt_strcmp ("MESSAGE-----\r\n", buf + 15) == 0)
 + 	enc = 1;
 +-      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
 ++      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0 ||
 ++	       mutt_strcmp ("SIGNED MESSAGE-----\r\n", buf + 15) == 0)
 + 	sgn = 1;
 +-      else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
 ++      else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0 ||
 ++	       mutt_strcmp ("PUBLIC KEY BLOCK-----\r\n", buf + 15) == 0)
 + 	key = 1;
 +     }
 +   }
 +@@ -1067,9 +1078,11 @@
 +    */
 +   while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL)
 +   {
 +-    if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0)
 ++    if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0 ||
 ++	mutt_strcmp ("-----BEGIN PGP MESSAGE-----\r\n", buffer) == 0)
 +       fputs ("-----BEGIN PGP SIGNATURE-----\n", fp);
 +-    else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0)
 ++    else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0 ||
 ++	     mutt_strcmp("-----END PGP MESSAGE-----\r\n", buffer) == 0)
 +       fputs ("-----END PGP SIGNATURE-----\n", fp);
 +     else
 +       fputs (buffer, fp);
 
 --VbJkn9YxBvnuCH5J--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009190900.o8J9094f056446>