Andreas Krennmair:
authorak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 18 Mar 2005 08:34:27 +0000 (08:34 +0000)
committerak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 18 Mar 2005 08:34:27 +0000 (08:34 +0000)
reformatted source code using muttng_indent.sh script

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@194 e385b8ad-14ed-0310-8656-cc95a2468c6d

180 files changed:
Makefile.in
_regex.h
acconfig.h
account.c
account.h
aclocal.m4
addrbook.c
alias.c
ascii.c
attach.c
attach.h
base64.c
browser.c
browser.h
buffy.c
buffy.h
charset.c
charset.h
color.c
commands.c
complete.c
compose.c
compress.c
config.h.in
copy.c
copy.h
crypt-gpgme.c
crypt-gpgme.h
crypt-mod-pgp-classic.c
crypt-mod-pgp-gpgme.c
crypt-mod-smime-classic.c
crypt-mod-smime-gpgme.c
crypt-mod.c
crypt-mod.h
crypt.c
cryptglue.c
curs_lib.c
curs_main.c
date.c
dotlock.c
dotlock.h
edit.c
editmsg.c
enter.c
extlib.c
filter.c
flags.c
from.c
functions.h
getdomain.c
globals.h
gnupgparse.c
handler.c
hash.c
hash.h
hcache.c
hdrline.c
headers.c
help.c
history.c
history.h
hook.c
imap/Makefile.in
imap/auth.c
imap/auth.h
imap/auth_anon.c
imap/auth_cram.c
imap/auth_gss.c
imap/auth_login.c
imap/auth_sasl.c
imap/browse.c
imap/command.c
imap/imap.c
imap/imap.h
imap/imap_private.h
imap/message.c
imap/message.h
imap/utf7.c
imap/util.c
init.c
init.h
keymap.c
keymap.h
lib.c
lib.h
m4/Makefile.in
mailbox.h
main.c
makedoc.c
mapping.h
mbox.c
mbyte.c
mbyte.h
md5.h
md5c.c
menu.c
mh.c
mime.h
mutt.h
mutt_crypt.h
mutt_curses.h
mutt_idna.c
mutt_idna.h
mutt_libesmtp.c
mutt_libesmtp.h
mutt_menu.h
mutt_regex.h
mutt_sasl.c
mutt_sasl.h
mutt_socket.c
mutt_socket.h
mutt_ssl.c
mutt_ssl.h
mutt_ssl_gnutls.c
mutt_ssl_nss.c
mutt_tunnel.c
muttlib.c
mx.c
mx.h
newsrc.c
nntp.c
nntp.h
pager.c
pager.h
parse.c
pattern.c
pgp.c
pgp.h
pgpewrap.c
pgpinvoke.c
pgpkey.c
pgplib.c
pgplib.h
pgpmicalg.c
pgppacket.c
pgppacket.h
pgppubring.c
pop.c
pop.h
pop_auth.c
pop_lib.c
postpone.c
protos.h
query.c
recvattach.c
recvcmd.c
regex.c
remailer.c
remailer.h
resize.c
rfc1524.c
rfc1524.h
rfc2047.c
rfc2047.h
rfc2231.c
rfc2231.h
rfc822.c
rfc822.h
score.c
send.c
sendlib.c
sha1.c
sha1.h
sidebar.c
sidebar.h
signal.c
smime.c
smime.h
snprintf.c
sort.c
sort.h
status.c
strcasecmp.c
strdup.c
system.c
thread.c
url.c
url.h
utf8.c
wcwidth.c

index 19f47b4..d0746d7 100644 (file)
@@ -1,8 +1,6 @@
-# Makefile.in generated by automake 1.7.6 from Makefile.am.
-# @configure_input@
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-@SET_MAKE@
+
+SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+
 top_builddir = .
 
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
 INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+host_alias = @host_alias@
 host_triplet = @host@
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
 AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BUILD_IMAP_FALSE = @BUILD_IMAP_FALSE@
-BUILD_IMAP_TRUE = @BUILD_IMAP_TRUE@
 BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
 CATALOGS = @CATALOGS@
 CATOBJEXT = @CATOBJEXT@
 CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-
-
-# $(makedoc_OBJECTS): $(makedoc_SOURCES)
-#      $(HOST_CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) -c $<
-
-# makedoc: $(makedoc_OBJECTS) $(makedoc_DEPENDENCIES)
-#      @rm -rf makedoc
-#      $(HOST_CC) $(AM_CFLAGS) $(LDFLAGS) $(makedoc_LDFLAGS) $(makedoc_OBJECTS) $(makedoc_LDADD) -o makedoc
-CPP = @CPP@
-
-CPPFLAGS = @CPPFLAGS@ -I$(includedir)
-CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
 DBX = @DBX@
 DEBUGGER = @DEBUGGER@
-
-DEFS = -DPKGDATADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
-       -DBINDIR=\"$(bindir)\" -DMUTTLOCALEDIR=\"$(datadir)/locale\" \
-       -DHAVE_CONFIG_H=1
-
-DEPDIR = @DEPDIR@
 DOTLOCK_GROUP = @DOTLOCK_GROUP@
 DOTLOCK_PERMISSION = @DOTLOCK_PERMISSION@
 DOTLOCK_TARGET = @DOTLOCK_TARGET@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
 GDB = @GDB@
 GENCAT = @GENCAT@
 GLIBC21 = @GLIBC21@
 GMOFILES = @GMOFILES@
 GMSGFMT = @GMSGFMT@
 GPGME_CONFIG = @GPGME_CONFIG@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+HAVE_LIB = @HAVE_LIB@
 INSTOBJEXT = @INSTOBJEXT@
 INTLBISON = @INTLBISON@
 INTLLIBS = @INTLLIBS@
@@ -100,7 +84,7 @@ INTLOBJS = @INTLOBJS@
 INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
 ISPELL = @ISPELL@
 KRB5CFGPATH = @KRB5CFGPATH@
-LDFLAGS = @LDFLAGS@
+LIB = @LIB@
 LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
 LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
 LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
@@ -109,84 +93,30 @@ LIBGPGME_LIBS = @LIBGPGME_LIBS@
 LIBICONV = @LIBICONV@
 LIBIMAP = @LIBIMAP@
 LIBIMAPDEPS = @LIBIMAPDEPS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LTLIBOBJS = @LTLIBOBJS@
+LTLIB = @LTLIB@
 MAKEINFO = @MAKEINFO@
 MKINSTALLDIRS = @MKINSTALLDIRS@
 MSGFMT = @MSGFMT@
 MUTTLIBS = @MUTTLIBS@
 MUTT_LIB_OBJECTS = @MUTT_LIB_OBJECTS@
-OBJEXT = @OBJEXT@
-
-OPS = @OPS@
 PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
 PGPAUX_TARGET = @PGPAUX_TARGET@
 POFILES = @POFILES@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SDB = @SDB@
 SENDMAIL = @SENDMAIL@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
+SGML2HTML_CMD = @SGML2HTML_CMD@
+SGML2PS_CMD = @SGML2PS_CMD@
+SGML2TXT_CMD = @SGML2TXT_CMD@
 SMIMEAUX_TARGET = @SMIMEAUX_TARGET@
-STRIP = @STRIP@
 SUBVERSION = @SUBVERSION@
 U = @U@
-USE_GSS_FALSE = @USE_GSS_FALSE@
-USE_GSS_TRUE = @USE_GSS_TRUE@
 USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 USE_NLS = @USE_NLS@
-USE_SASL_FALSE = @USE_SASL_FALSE@
-USE_SASL_TRUE = @USE_SASL_TRUE@
-USE_SSL_FALSE = @USE_SSL_FALSE@
-USE_SSL_TRUE = @USE_SSL_TRUE@
 VERSION = @VERSION@
-XGETTEXT = @XGETTEXT@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
 docdir = @docdir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
 mutt_libesmtp_config_path = @mutt_libesmtp_config_path@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
 
 AUTOMAKE_OPTIONS = foreign
 EXTRA_PROGRAMS = muttng_dotlock pgpringng pgpewrapng makedoc
@@ -201,59 +131,39 @@ bin_SCRIPTS = muttngbug fleang
 BUILT_SOURCES = keymap_defs.h patchlist.c
 
 bin_PROGRAMS = muttng @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@
-muttng_SOURCES = $(BUILT_SOURCES) \
-       addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
-       compress.c crypt.c cryptglue.c \
-       commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
-       edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
-       handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
-       main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c \
-       postpone.c query.c recvattach.c recvcmd.c \
-       rfc822.c rfc1524.c rfc2047.c rfc2231.c \
-       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 utf8.c mbyte.c wcwidth.c md5c.c \
-       url.c ascii.c mutt_idna.c sidebar.c hcache.c crypt-mod.c crypt-mod.h
+muttng_SOURCES = $(BUILT_SOURCES)      addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c  compress.c crypt.c cryptglue.c  commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c    edit.c enter.c flags.c init.c filter.c from.c getdomain.c       handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c     main.c mbox.c menu.c mh.c mx.c pager.c parse.c pattern.c        postpone.c query.c recvattach.c recvcmd.c       rfc822.c rfc1524.c rfc2047.c rfc2231.c  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 utf8.c mbyte.c wcwidth.c md5c.c     url.c ascii.c mutt_idna.c sidebar.c hcache.c crypt-mod.c crypt-mod.h
 
 
-muttng_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
-       $(INTLLIBS) $(LIBICONV)
+muttng_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS)     $(INTLLIBS) $(LIBICONV)
 
 
-muttng_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) \
-       $(INTLDEPS)
+muttng_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS)      $(INTLDEPS)
 
 
 makedoc_SOURCES = makedoc.c
 makedoc_LDADD = 
 makedoc_DEPENDENCIES = 
 
+# $(makedoc_OBJECTS): $(makedoc_SOURCES)
+#      $(HOST_CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) -c $<
+
+# makedoc: $(makedoc_OBJECTS) $(makedoc_DEPENDENCIES)
+#      @rm -rf makedoc
+#      $(HOST_CC) $(AM_CFLAGS) $(LDFLAGS) $(makedoc_LDFLAGS) $(makedoc_OBJECTS) $(makedoc_LDADD) -o makedoc
+
+CPP = @CPP@
+
+DEFS = -DPKGDATADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\"   -DBINDIR=\"$(bindir)\" -DMUTTLOCALEDIR=\"$(datadir)/locale\"    -DHAVE_CONFIG_H=1
+
+
 INCLUDES = -I. -I$(top_srcdir) $(IMAP_INCLUDES) $(LIBGPGME_CFLAGS) -Iintl
 
-EXTRA_muttng_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \
-       mutt_tunnel.c pop.c pop_auth.c pop_lib.c smime.c pgp.c pgpinvoke.c pgpkey.c \
-       pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
-       browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c \
-       pgppacket.c mutt_idna.h nntp.c newsrc.c mutt_libesmtp.c \
-       sidebar.h crypt-mod-pgp-classic.c crypt-mod-smime-classic.c
-
-
-EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
-       configure acconfig.h account.h \
-       compress.h \
-       attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs \
-       globals.h hash.h history.h init.h keymap.h mutt_crypt.h \
-       mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
-       mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
-       mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \
-       rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \
-       nntp.h ChangeLog.nntp \
-       _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
-       mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttngrc.head Muttngrc \
-       makedoc.c stamp-doc-rc README.SSL smime.h\
-       muttngbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh       \
-       ChangeLog.old mkchangelog.sh cvslog2changelog.pl mutt_idna.h \
-       snprintf.c regex.c mutt_libesmtp.h crypt-gpgme.h
+CPPFLAGS = @CPPFLAGS@ -I$(includedir)
+
+EXTRA_muttng_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c   mutt_tunnel.c pop.c pop_auth.c pop_lib.c smime.c pgp.c pgpinvoke.c pgpkey.c     pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c  browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c       pgppacket.c mutt_idna.h nntp.c newsrc.c mutt_libesmtp.c         sidebar.h crypt-mod-pgp-classic.c crypt-mod-smime-classic.c
+
+
+EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO        configure acconfig.h account.h  compress.h      attach.h buffy.h charset.h copy.h crypthash.h dotlock.h functions.h gen_defs    globals.h hash.h history.h init.h keymap.h mutt_crypt.h         mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h       mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h         mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h         rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare     nntp.h ChangeLog.nntp   _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h        mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttngrc.head Muttngrc         makedoc.c stamp-doc-rc README.SSL smime.h       muttngbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh               ChangeLog.old mkchangelog.sh cvslog2changelog.pl mutt_idna.h    snprintf.c regex.c mutt_libesmtp.h crypt-gpgme.h
 
 
 muttng_dotlock_SOURCES = mutt_dotlock.c
@@ -268,221 +178,211 @@ pgpewrapng_SOURCES = pgpewrap.c
 pgpewrapng_LDADD = 
 pgpewrapng_DEPENDENCIES = 
 
-CLEANFILES = mutt_dotlock.c stamp-doc-rc makedoc \
-       keymap_alldefs.h keymap_defs.h patchlist.c
+CLEANFILES = mutt_dotlock.c stamp-doc-rc makedoc       keymap_alldefs.h keymap_defs.h patchlist.c
 
 
 ACLOCAL_AMFLAGS = -I m4
 
 LDADD = @LIBOBJS@ @INTLLIBS@
-subdir = .
+
+OPS = @OPS@
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = intl/Makefile doc/Makefile contrib/Makefile \
-       muttbug.sh Muttngrc.head doc/instdoc.sh
-EXTRA_PROGRAMS = muttng_dotlock$(EXEEXT) pgpringng$(EXEEXT) \
-       pgpewrapng$(EXEEXT) makedoc$(EXEEXT)
-bin_PROGRAMS = muttng$(EXEEXT) @DOTLOCK_TARGET@ @PGPAUX_TARGET@ \
-       @SMIMEAUX_TARGET@
-PROGRAMS = $(bin_PROGRAMS)
-
-am_makedoc_OBJECTS = makedoc.$(OBJEXT)
-makedoc_OBJECTS = $(am_makedoc_OBJECTS)
-makedoc_LDFLAGS =
-am__objects_1 = patchlist.$(OBJEXT)
-am_muttng_OBJECTS = $(am__objects_1) addrbook.$(OBJEXT) alias.$(OBJEXT) \
-       attach.$(OBJEXT) base64.$(OBJEXT) browser.$(OBJEXT) \
-       buffy.$(OBJEXT) color.$(OBJEXT) compress.$(OBJEXT) \
-       crypt.$(OBJEXT) cryptglue.$(OBJEXT) commands.$(OBJEXT) \
-       complete.$(OBJEXT) compose.$(OBJEXT) copy.$(OBJEXT) \
-       curs_lib.$(OBJEXT) curs_main.$(OBJEXT) date.$(OBJEXT) \
-       edit.$(OBJEXT) enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) \
-       filter.$(OBJEXT) from.$(OBJEXT) getdomain.$(OBJEXT) \
-       handler.$(OBJEXT) hash.$(OBJEXT) hdrline.$(OBJEXT) \
-       headers.$(OBJEXT) help.$(OBJEXT) hook.$(OBJEXT) \
-       keymap.$(OBJEXT) main.$(OBJEXT) mbox.$(OBJEXT) menu.$(OBJEXT) \
-       mh.$(OBJEXT) mx.$(OBJEXT) pager.$(OBJEXT) parse.$(OBJEXT) \
-       pattern.$(OBJEXT) postpone.$(OBJEXT) query.$(OBJEXT) \
-       recvattach.$(OBJEXT) recvcmd.$(OBJEXT) rfc822.$(OBJEXT) \
-       rfc1524.$(OBJEXT) rfc2047.$(OBJEXT) rfc2231.$(OBJEXT) \
-       score.$(OBJEXT) send.$(OBJEXT) sendlib.$(OBJEXT) \
-       signal.$(OBJEXT) sort.$(OBJEXT) status.$(OBJEXT) \
-       system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
-       history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
-       editmsg.$(OBJEXT) utf8.$(OBJEXT) mbyte.$(OBJEXT) \
-       wcwidth.$(OBJEXT) md5c.$(OBJEXT) url.$(OBJEXT) ascii.$(OBJEXT) \
-       mutt_idna.$(OBJEXT) sidebar.$(OBJEXT) hcache.$(OBJEXT) \
-       crypt-mod.$(OBJEXT)
-muttng_OBJECTS = $(am_muttng_OBJECTS)
-muttng_LDFLAGS =
-am_muttng_dotlock_OBJECTS = mutt_dotlock.$(OBJEXT)
-muttng_dotlock_OBJECTS = $(am_muttng_dotlock_OBJECTS)
-muttng_dotlock_LDFLAGS =
-am_pgpewrapng_OBJECTS = pgpewrap.$(OBJEXT)
-pgpewrapng_OBJECTS = $(am_pgpewrapng_OBJECTS)
-pgpewrapng_LDFLAGS =
-am_pgpringng_OBJECTS = pgppubring.$(OBJEXT) pgplib.$(OBJEXT) \
-       lib.$(OBJEXT) extlib.$(OBJEXT) sha1.$(OBJEXT) md5c.$(OBJEXT) \
-       pgppacket.$(OBJEXT) ascii.$(OBJEXT)
-pgpringng_OBJECTS = $(am_pgpringng_OBJECTS)
-pgpringng_LDFLAGS =
-SCRIPTS = $(bin_SCRIPTS)
-
-
-DEFAULT_INCLUDES =  -I. -I$(srcdir) -I.
-depcomp =
-am__depfiles_maybe =
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CONFIG_CLEAN_FILES =  muttbug.sh Muttngrc.head
+PROGRAMS =  $(bin_PROGRAMS)
+
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+muttng_dotlock_OBJECTS =  mutt_dotlock.o
+muttng_dotlock_LDFLAGS = 
+pgpringng_OBJECTS =  pgppubring.o pgplib.o lib.o extlib.o sha1.o md5c.o \
+pgppacket.o ascii.o
+pgpringng_LDFLAGS = 
+pgpewrapng_OBJECTS =  pgpewrap.o
+pgpewrapng_LDFLAGS = 
+makedoc_OBJECTS =  makedoc.o
+makedoc_LDFLAGS = 
+muttng_OBJECTS =  patchlist.o addrbook.o alias.o attach.o base64.o \
+browser.o buffy.o color.o compress.o crypt.o cryptglue.o commands.o \
+complete.o compose.o copy.o curs_lib.o curs_main.o date.o edit.o \
+enter.o flags.o init.o filter.o from.o getdomain.o handler.o hash.o \
+hdrline.o headers.o help.o hook.o keymap.o main.o mbox.o menu.o mh.o \
+mx.o pager.o parse.o pattern.o postpone.o query.o recvattach.o \
+recvcmd.o rfc822.o rfc1524.o rfc2047.o rfc2231.o score.o send.o \
+sendlib.o signal.o sort.o status.o system.o thread.o charset.o \
+history.o lib.o muttlib.o editmsg.o utf8.o mbyte.o wcwidth.o md5c.o \
+url.o ascii.o mutt_idna.o sidebar.o hcache.o crypt-mod.o
+muttng_LDFLAGS = 
+SCRIPTS =  $(bin_SCRIPTS)
+
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DIST_SOURCES = $(makedoc_SOURCES) $(muttng_SOURCES) \
-       $(EXTRA_muttng_SOURCES) $(muttng_dotlock_SOURCES) \
-       $(pgpewrapng_SOURCES) $(pgpringng_SOURCES)
-
-RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
-       ps-recursive install-info-recursive uninstall-info-recursive \
-       all-recursive install-data-recursive install-exec-recursive \
-       installdirs-recursive install-recursive uninstall-recursive \
-       check-recursive installcheck-recursive
-DIST_COMMON = README ABOUT-NLS ChangeLog INSTALL Makefile.am \
-       Makefile.in Muttngrc.head.in NEWS TODO acconfig.h aclocal.m4 \
-       config.guess config.h.in config.sub configure configure.in \
-       depcomp install-sh missing mkinstalldirs muttbug.sh.in regex.c \
-       snprintf.c strcasecmp.c strdup.c
-DIST_SUBDIRS = m4 po intl doc contrib imap
-SOURCES = $(makedoc_SOURCES) $(muttng_SOURCES) $(EXTRA_muttng_SOURCES) $(muttng_dotlock_SOURCES) $(pgpewrapng_SOURCES) $(pgpringng_SOURCES)
-
-all: $(BUILT_SOURCES) config.h
-       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON =  README ./stamp-h.in ABOUT-NLS ChangeLog INSTALL \
+Makefile.am Makefile.in Muttngrc.head.in NEWS TODO acconfig.h \
+aclocal.m4 config.guess config.h.in config.sub configure configure.in \
+install-sh missing mkinstalldirs muttbug.sh.in strcasecmp.c strdup.c
 
-.SUFFIXES:
-.SUFFIXES: .c .o .obj
 
-am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
-       cd $(top_srcdir) && \
-         $(AUTOMAKE) --foreign  --ignore-deps Makefile
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-       $(SHELL) ./config.status --recheck
-$(srcdir)/configure:  $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
-       cd $(srcdir) && $(AUTOCONF)
+TAR = tar
+GZIP_ENV = --best
+DIST_SUBDIRS =  m4 po intl doc contrib imap
+SOURCES = $(muttng_dotlock_SOURCES) $(pgpringng_SOURCES) $(pgpewrapng_SOURCES) $(makedoc_SOURCES) $(muttng_SOURCES) $(EXTRA_muttng_SOURCES)
+OBJECTS = $(muttng_dotlock_OBJECTS) $(pgpringng_OBJECTS) $(pgpewrapng_OBJECTS) $(makedoc_OBJECTS) $(muttng_OBJECTS)
 
-$(ACLOCAL_M4):  configure.in m4/codeset.m4 m4/curslib.m4 m4/funcdecl.m4 m4/gettext.m4 m4/glibc21.m4 m4/gssapi.m4 m4/iconv.m4 m4/lcmessage.m4 m4/libesmtp.m4 m4/libgnutls.m4 m4/progtest.m4 m4/types.m4
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+       cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4):  configure.in  m4/codeset.m4 m4/curslib.m4 m4/funcdecl.m4 \
+               m4/gettext.m4 m4/glibc21.m4 m4/gssapi.m4 m4/iconv.m4 \
+               m4/lcmessage.m4 m4/libesmtp.m4 m4/libgnutls.m4 \
+               m4/progtest.m4 m4/types.m4
        cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 
-config.h: stamp-h1
+config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+       cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+       @if test ! -f $@; then \
+               rm -f stamp-h; \
+               $(MAKE) stamp-h; \
+       else :; fi
+stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES= CONFIG_HEADERS=config.h \
+            $(SHELL) ./config.status
+       @echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
        @if test ! -f $@; then \
-         rm -f stamp-h1; \
-         $(MAKE) stamp-h1; \
+               rm -f $(srcdir)/stamp-h.in; \
+               $(MAKE) $(srcdir)/stamp-h.in; \
        else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
+       cd $(top_srcdir) && $(AUTOHEADER)
+       @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
 
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
-       @rm -f stamp-h1
-       cd $(top_builddir) && $(SHELL) ./config.status config.h
+mostlyclean-hdr:
 
-$(srcdir)/config.h.in:  $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h
-       cd $(top_srcdir) && $(AUTOHEADER)
-       touch $(srcdir)/config.h.in
+clean-hdr:
 
 distclean-hdr:
-       -rm -f config.h stamp-h1
-intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
-doc/Makefile: $(top_builddir)/config.status $(top_srcdir)/doc/Makefile.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
-contrib/Makefile: $(top_builddir)/config.status $(top_srcdir)/contrib/Makefile.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
+       -rm -f config.h
+
+maintainer-clean-hdr:
 muttbug.sh: $(top_builddir)/config.status muttbug.sh.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
+       cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
 Muttngrc.head: $(top_builddir)/config.status Muttngrc.head.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
-doc/instdoc.sh: $(top_builddir)/config.status $(top_srcdir)/doc/instdoc.sh.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+       cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
 install-binPROGRAMS: $(bin_PROGRAMS)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(bindir)
        @list='$(bin_PROGRAMS)'; for p in $$list; do \
-         p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-         if test -f $$p \
-         ; then \
-           f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-          echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
-          $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
+         if test -f $$p; then \
+           echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+            $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
          else :; fi; \
        done
 
 uninstall-binPROGRAMS:
        @$(NORMAL_UNINSTALL)
-       @list='$(bin_PROGRAMS)'; for p in $$list; do \
-         f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-         echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
-         rm -f $(DESTDIR)$(bindir)/$$f; \
+       list='$(bin_PROGRAMS)'; for p in $$list; do \
+         rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
        done
 
-clean-binPROGRAMS:
-       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-makedoc$(EXEEXT): $(makedoc_OBJECTS) $(makedoc_DEPENDENCIES) 
-       @rm -f makedoc$(EXEEXT)
-       $(LINK) $(makedoc_LDFLAGS) $(makedoc_OBJECTS) $(makedoc_LDADD) $(LIBS)
-muttng$(EXEEXT): $(muttng_OBJECTS) $(muttng_DEPENDENCIES) 
-       @rm -f muttng$(EXEEXT)
-       $(LINK) $(muttng_LDFLAGS) $(muttng_OBJECTS) $(muttng_LDADD) $(LIBS)
-muttng_dotlock$(EXEEXT): $(muttng_dotlock_OBJECTS) $(muttng_dotlock_DEPENDENCIES) 
-       @rm -f muttng_dotlock$(EXEEXT)
+.c.o:
+       $(COMPILE) -c $<
+
+.s.o:
+       $(COMPILE) -c $<
+
+.S.o:
+       $(COMPILE) -c $<
+
+mostlyclean-compile:
+       -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+       -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+muttng_dotlock: $(muttng_dotlock_OBJECTS) $(muttng_dotlock_DEPENDENCIES)
+       @rm -f muttng_dotlock
        $(LINK) $(muttng_dotlock_LDFLAGS) $(muttng_dotlock_OBJECTS) $(muttng_dotlock_LDADD) $(LIBS)
-pgpewrapng$(EXEEXT): $(pgpewrapng_OBJECTS) $(pgpewrapng_DEPENDENCIES) 
-       @rm -f pgpewrapng$(EXEEXT)
-       $(LINK) $(pgpewrapng_LDFLAGS) $(pgpewrapng_OBJECTS) $(pgpewrapng_LDADD) $(LIBS)
-pgpringng$(EXEEXT): $(pgpringng_OBJECTS) $(pgpringng_DEPENDENCIES) 
-       @rm -f pgpringng$(EXEEXT)
+
+pgpringng: $(pgpringng_OBJECTS) $(pgpringng_DEPENDENCIES)
+       @rm -f pgpringng
        $(LINK) $(pgpringng_LDFLAGS) $(pgpringng_OBJECTS) $(pgpringng_LDADD) $(LIBS)
-binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+
+pgpewrapng: $(pgpewrapng_OBJECTS) $(pgpewrapng_DEPENDENCIES)
+       @rm -f pgpewrapng
+       $(LINK) $(pgpewrapng_LDFLAGS) $(pgpewrapng_OBJECTS) $(pgpewrapng_LDADD) $(LIBS)
+
+makedoc: $(makedoc_OBJECTS) $(makedoc_DEPENDENCIES)
+       @rm -f makedoc
+       $(LINK) $(makedoc_LDFLAGS) $(makedoc_OBJECTS) $(makedoc_LDADD) $(LIBS)
+
+muttng: $(muttng_OBJECTS) $(muttng_DEPENDENCIES)
+       @rm -f muttng
+       $(LINK) $(muttng_LDFLAGS) $(muttng_OBJECTS) $(muttng_LDADD) $(LIBS)
+
 install-binSCRIPTS: $(bin_SCRIPTS)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(bindir)
        @list='$(bin_SCRIPTS)'; for p in $$list; do \
-         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         if test -f $$d$$p; then \
-           f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
-           echo " $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f"; \
-           $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f; \
-         else :; fi; \
+         if test -f $$p; then \
+           echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
+           $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+         else if test -f $(srcdir)/$$p; then \
+           echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
+           $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+         else :; fi; fi; \
        done
 
 uninstall-binSCRIPTS:
        @$(NORMAL_UNINSTALL)
-       @list='$(bin_SCRIPTS)'; for p in $$list; do \
-         f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
-         echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
-         rm -f $(DESTDIR)$(bindir)/$$f; \
+       list='$(bin_SCRIPTS)'; for p in $$list; do \
+         rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
        done
 
-mostlyclean-compile:
-       -rm -f *.$(OBJEXT) core *.core
-
-distclean-compile:
-       -rm -f *.tab.c
-
-.c.o:
-       $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
-
-.c.obj:
-       $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
-uninstall-info-am:
-
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
 # To change the values of `make' variables: instead of editing Makefiles,
 # (1) if the variable is set in `config.status', edit `config.status'
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-       @set fnord $$MAKEFLAGS; amf=$$2; \
+
+@SET_MAKE@
+
+all-recursive install-data-recursive install-exec-recursive \
+installdirs-recursive install-recursive uninstall-recursive  \
+check-recursive installcheck-recursive info-recursive dvi-recursive:
+       @set fnord $(MAKEFLAGS); amf=$$2; \
        dot_seen=no; \
        target=`echo $@ | sed s/-recursive//`; \
        list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -502,18 +402,13 @@ $(RECURSIVE_TARGETS):
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-       @set fnord $$MAKEFLAGS; amf=$$2; \
+       @set fnord $(MAKEFLAGS); amf=$$2; \
        dot_seen=no; \
-       case "$@" in \
-         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-         *) list='$(SUBDIRS)' ;; \
-       esac; \
-       rev=''; for subdir in $$list; do \
-         if test "$$subdir" = "."; then :; else \
-           rev="$$subdir $$rev"; \
-         fi; \
+       rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
+         rev="$$subdir $$rev"; \
+         test "$$subdir" = "." && dot_seen=yes; \
        done; \
-       rev="$$rev ."; \
+       test "$$dot_seen" = "no" && rev=". $$rev"; \
        target=`echo $@ | sed s/-recursive//`; \
        for subdir in $$rev; do \
          echo "Making $$target in $$subdir"; \
@@ -529,227 +424,132 @@ tags-recursive:
        list='$(SUBDIRS)'; for subdir in $$list; do \
          test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
        done
-ctags-recursive:
-       list='$(SUBDIRS)'; for subdir in $$list; do \
-         test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-       done
-
-ETAGS = etags
-ETAGSFLAGS =
-
-CTAGS = ctags
-CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP)
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       mkid -fID $$unique
+       here=`pwd` && cd $(srcdir) \
+         && mkid -f$$here/ID $$unique $(LISP)
 
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
        tags=; \
        here=`pwd`; \
-       if (etags --etags-include --version) >/dev/null 2>&1; then \
-         include_option=--etags-include; \
-       else \
-         include_option=--include; \
-       fi; \
        list='$(SUBDIRS)'; for subdir in $$list; do \
-         if test "$$subdir" = .; then :; else \
-           test -f $$subdir/TAGS && \
-             tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
-         fi; \
+   if test "$$subdir" = .; then :; else \
+           test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+   fi; \
        done; \
-       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       test -z "$(ETAGS_ARGS)$$tags$$unique" \
-         || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-            $$tags $$unique
+       test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
+         || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
 
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
-       tags=; \
-       here=`pwd`; \
-       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
-              END { for (i in files) print i; }'`; \
-       test -z "$(CTAGS_ARGS)$$tags$$unique" \
-         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-            $$tags $$unique
+mostlyclean-tags:
 
-GTAGS:
-       here=`$(am__cd) $(top_builddir) && pwd` \
-         && cd $(top_srcdir) \
-         && gtags -i $(GTAGS_ARGS) $$here
+clean-tags:
 
 distclean-tags:
-       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-
-top_distdir = .
-distdir = $(PACKAGE)-$(VERSION)
+       -rm -f TAGS ID
 
-am__remove_distdir = \
-  { test ! -d $(distdir) \
-    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
-         && rm -fr $(distdir); }; }
+maintainer-clean-tags:
 
-GZIP_ENV = --best
-distuninstallcheck_listfiles = find . -type f -print
-distcleancheck_listfiles = find . -type f -print
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
 
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       -rm -rf $(distdir)
+       GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+       mkdir $(distdir)/=build
+       mkdir $(distdir)/=inst
+       dc_install_base=`cd $(distdir)/=inst && pwd`; \
+       cd $(distdir)/=build \
+         && ../configure --with-included-gettext --srcdir=.. --prefix=$$dc_install_base \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) dist
+       -rm -rf $(distdir)
+       @banner="$(distdir).tar.gz is ready for distribution"; \
+       dashes=`echo "$$banner" | sed s/./=/g`; \
+       echo "$$dashes"; \
+       echo "$$banner"; \
+       echo "$$dashes"
+dist: distdir
+       -chmod -R a+r $(distdir)
+       GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+       -rm -rf $(distdir)
+dist-all: distdir
+       -chmod -R a+r $(distdir)
+       GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+       -rm -rf $(distdir)
 distdir: $(DISTFILES)
-       $(am__remove_distdir)
+       -rm -rf $(distdir)
        mkdir $(distdir)
-       $(mkinstalldirs) $(distdir)/. $(distdir)/contrib $(distdir)/doc $(distdir)/intl $(distdir)/po
-       @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-       list='$(DISTFILES)'; for file in $$list; do \
-         case $$file in \
-           $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-           $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-         esac; \
-         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-           dir="/$$dir"; \
-           $(mkinstalldirs) "$(distdir)$$dir"; \
-         else \
-           dir=''; \
-         fi; \
+       -chmod 777 $(distdir)
+       @for file in $(DISTFILES); do \
+         d=$(srcdir); \
          if test -d $$d/$$file; then \
-           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-           fi; \
-           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+           cp -pr $$d/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
-           || cp -p $$d/$$file $(distdir)/$$file \
-           || exit 1; \
+           || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+           || cp -p $$d/$$file $(distdir)/$$file || :; \
          fi; \
        done
-       list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+       for subdir in $(DIST_SUBDIRS); do \
          if test "$$subdir" = .; then :; else \
            test -d $(distdir)/$$subdir \
            || mkdir $(distdir)/$$subdir \
            || exit 1; \
-           (cd $$subdir && \
-             $(MAKE) $(AM_MAKEFLAGS) \
-               top_distdir="$(top_distdir)" \
-               distdir=../$(distdir)/$$subdir \
-               distdir) \
+           chmod 777 $(distdir)/$$subdir; \
+           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
              || exit 1; \
          fi; \
        done
-       $(MAKE) $(AM_MAKEFLAGS) \
-         top_distdir="$(top_distdir)" distdir="$(distdir)" \
-         dist-hook
-       -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
-         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
-         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
-         ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
-       || chmod -R a+r $(distdir)
-dist-gzip: distdir
-       $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-       $(am__remove_distdir)
-
-dist dist-all: distdir
-       $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-       $(am__remove_distdir)
-
-# This target untars the dist file and tries a VPATH configuration.  Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
-       $(am__remove_distdir)
-       GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
-       chmod -R a-w $(distdir); chmod a+w $(distdir)
-       mkdir $(distdir)/_build
-       mkdir $(distdir)/_inst
-       chmod a-w $(distdir)
-       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
-         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
-         && cd $(distdir)/_build \
-         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
-           $(DISTCHECK_CONFIGURE_FLAGS) \
-         && $(MAKE) $(AM_MAKEFLAGS) \
-         && $(MAKE) $(AM_MAKEFLAGS) dvi \
-         && $(MAKE) $(AM_MAKEFLAGS) check \
-         && $(MAKE) $(AM_MAKEFLAGS) install \
-         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
-         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
-         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
-               distuninstallcheck \
-         && chmod -R a-w "$$dc_install_base" \
-         && ({ \
-              (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
-              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
-              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
-              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
-                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
-             } || { rm -rf "$$dc_destdir"; exit 1; }) \
-         && rm -rf "$$dc_destdir" \
-         && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
-         && rm -f $(distdir).tar.gz \
-         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
-       $(am__remove_distdir)
-       @echo "$(distdir).tar.gz is ready for distribution" | \
-         sed 'h;s/./=/g;p;x;p;x'
-distuninstallcheck:
-       @cd $(distuninstallcheck_dir) \
-       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
-          || { echo "ERROR: files left after uninstall:" ; \
-               if test -n "$(DESTDIR)"; then \
-                 echo "  (check DESTDIR support)"; \
-               fi ; \
-               $(distuninstallcheck_listfiles) ; \
-               exit 1; } >&2
-distcleancheck: distclean
-       @if test '$(srcdir)' = . ; then \
-         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
-         exit 1 ; \
-       fi
-       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
-         || { echo "ERROR: files left in build directory after distclean:" ; \
-              $(distcleancheck_listfiles) ; \
-              exit 1; } >&2
+       $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
+info-am:
+info: info-recursive
+dvi-am:
+dvi: dvi-recursive
 check-am: all-am
-check: $(BUILT_SOURCES)
-       $(MAKE) $(AM_MAKEFLAGS) check-recursive
-all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
-installdirs: installdirs-recursive
-installdirs-am:
-       $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(bindir)
+check: check-recursive
+installcheck-am:
+installcheck: installcheck-recursive
+all-recursive-am: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
 
-install: $(BUILT_SOURCES)
-       $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+               install-exec-local
 install-exec: install-exec-recursive
+
+install-data-am: install-data-local
 install-data: install-data-recursive
-uninstall: uninstall-recursive
 
 install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-recursive
+install: install-recursive
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS
+uninstall: uninstall-recursive
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
+all-redirect: all-recursive-am
 install-strip:
-       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         INSTALL_STRIP_FLAG=-s \
-         `test -z '$(STRIP)' || \
-           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+       $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs: installdirs-recursive
+installdirs-am:
+       $(mkinstalldirs)  $(DESTDIR)$(bindir) $(DESTDIR)$(bindir)
+
+
 mostlyclean-generic:
 
 clean-generic:
@@ -757,81 +557,53 @@ clean-generic:
 
 distclean-generic:
        -rm -f Makefile $(CONFIG_CLEAN_FILES)
+       -rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-       @echo "This command is intended for maintainers to use"
-       @echo "it deletes files that may require special tools to rebuild."
        -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
-clean: clean-recursive
-
-clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
-
-distclean: distclean-recursive
-       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
-distclean-am: clean-am distclean-compile distclean-generic distclean-hdr \
-       distclean-tags
-
-dvi: dvi-recursive
-
-dvi-am:
-
-info: info-recursive
-
-info-am:
-
-install-data-am: install-data-local
-
-install-exec-am: install-binPROGRAMS install-binSCRIPTS \
-       install-exec-local
-
-install-info: install-info-recursive
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-recursive
-       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
-       -rm -rf $(top_srcdir)/autom4te.cache
-maintainer-clean-am: distclean-am maintainer-clean-generic
+mostlyclean-am:  mostlyclean-hdr mostlyclean-binPROGRAMS \
+               mostlyclean-compile mostlyclean-tags \
+               mostlyclean-generic
 
 mostlyclean: mostlyclean-recursive
 
-mostlyclean-am: mostlyclean-compile mostlyclean-generic
+clean-am:  clean-hdr clean-binPROGRAMS clean-compile clean-tags \
+               clean-generic mostlyclean-am
 
-pdf: pdf-recursive
-
-pdf-am:
-
-ps: ps-recursive
+clean: clean-recursive
 
-ps-am:
+distclean-am:  distclean-hdr distclean-binPROGRAMS distclean-compile \
+               distclean-tags distclean-generic clean-am
 
-uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
-       uninstall-info-am
+distclean: distclean-recursive
+       -rm -f config.status
 
-uninstall-info: uninstall-info-recursive
+maintainer-clean-am:  maintainer-clean-hdr maintainer-clean-binPROGRAMS \
+               maintainer-clean-compile maintainer-clean-tags \
+               maintainer-clean-generic distclean-am
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
 
-.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
-       clean-binPROGRAMS clean-generic clean-recursive ctags \
-       ctags-recursive dist dist-all dist-gzip distcheck distclean \
-       distclean-compile distclean-generic distclean-hdr \
-       distclean-recursive distclean-tags distcleancheck distdir \
-       distuninstallcheck dvi dvi-am dvi-recursive info info-am \
-       info-recursive install install-am install-binPROGRAMS \
-       install-binSCRIPTS install-data install-data-am \
-       install-data-local install-data-recursive install-exec \
-       install-exec-am install-exec-local install-exec-recursive \
-       install-info install-info-am install-info-recursive install-man \
-       install-recursive install-strip installcheck installcheck-am \
-       installdirs installdirs-am installdirs-recursive \
-       maintainer-clean maintainer-clean-generic \
-       maintainer-clean-recursive mostlyclean mostlyclean-compile \
-       mostlyclean-generic mostlyclean-recursive pdf pdf-am \
-       pdf-recursive ps ps-am ps-recursive tags tags-recursive \
-       uninstall uninstall-am uninstall-binPROGRAMS \
-       uninstall-binSCRIPTS uninstall-info-am uninstall-info-recursive \
-       uninstall-recursive
+maintainer-clean: maintainer-clean-recursive
+       -rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
+maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS \
+install-data-recursive uninstall-data-recursive install-exec-recursive \
+uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
+all-recursive check-recursive installcheck-recursive info-recursive \
+dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
+maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
+install-exec-local install-exec-am install-exec install-data-local \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs-am installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
 
 
 mutt_dotlock.c: dotlock.c
@@ -881,7 +653,7 @@ install-data-local: Muttngrc
        elif [ ! -f $(DESTDIR)$(sysconfdir)/Muttngrc ] ; then \
                $(INSTALL) -m 644 $(srcdir)/Muttngrc $(DESTDIR)$(sysconfdir) ; \
        fi
-       -if [ ! -f $(DESTDIR)$(sysconfdir)/mime.types ]; then \
+       -if [ ! -f $(DESTDIR)$(sysconfdir)/muttng-mime.types ]; then \
                $(INSTALL) -m 644 $(srcdir)/mime.types $(DESTDIR)$(sysconfdir)/muttng-mime.types; \
        fi
 
@@ -931,6 +703,7 @@ stamp-doc-rc: $(srcdir)/init.h makedoc Muttngrc.head
 
 .PHONY: commit pclean check-security commit-real commit-changelog
 .PHONY: changelog ChangeLog
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
index 8e2bd8f..f112d73 100644 (file)
--- a/_regex.h
+++ b/_regex.h
@@ -41,15 +41,15 @@ extern "C" {
    wide enough to hold a value of a pointer.  For most ANSI compilers
    ptrdiff_t and size_t should be likely OK.  Still size of these two
    types is 2 for Microsoft C.  Ugh... */
-typedef long int s_reg_t;
-typedef unsigned long int active_reg_t;
+  typedef long int s_reg_t;
+  typedef unsigned long int active_reg_t;
 
 /* The following bits are used to determine the regexp syntax we
    recognize.  The set/not-set meanings are chosen so that Emacs syntax
    remains the value 0.  The bits are given in alphabetical order, and
    the definitions shifted by one from the previous bit; thus, when we
    add or remove a bit, only one other definition need change.  */
-typedef unsigned long int reg_syntax_t;
+  typedef unsigned long int reg_syntax_t;
 
 /* If this bit is not set, then \ inside a bracket expression is literal.
    If set, then such a \ quotes the following character.  */
@@ -164,7 +164,7 @@ typedef unsigned long int reg_syntax_t;
    some interfaces).  When a regexp is compiled, the syntax used is
    stored in the pattern buffer, so changing this does not affect
    already-compiled regexps.  */
-extern reg_syntax_t re_syntax_options;
+  extern reg_syntax_t re_syntax_options;
 \f
 /* Define combinations of the above bits for the standard possibilities.
    (The [[[ comments delimit what gets put into the Texinfo file, so
@@ -280,31 +280,30 @@ extern reg_syntax_t re_syntax_options;
 
 /* If any error codes are removed, changed, or added, update the
    `re_error_msg' table in regex.c.  */
-typedef enum
-{
-  REG_NOERROR = 0,     /* Success.  */
-  REG_NOMATCH,         /* Didn't find a match (for regexec).  */
-
-  /* POSIX regcomp return error codes.  (In the order listed in the
-     standard.)  */
-  REG_BADPAT,          /* Invalid pattern.  */
-  REG_ECOLLATE,                /* Not implemented.  */
-  REG_ECTYPE,          /* Invalid character class name.  */
-  REG_EESCAPE,         /* Trailing backslash.  */
-  REG_ESUBREG,         /* Invalid back reference.  */
-  REG_EBRACK,          /* Unmatched left bracket.  */
-  REG_EPAREN,          /* Parenthesis imbalance.  */
-  REG_EBRACE,          /* Unmatched \{.  */
-  REG_BADBR,           /* Invalid contents of \{\}.  */
-  REG_ERANGE,          /* Invalid range end.  */
-  REG_ESPACE,          /* Ran out of memory.  */
-  REG_BADRPT,          /* No preceding re for repetition op.  */
-
-  /* Error codes we've added.  */
-  REG_EEND,            /* Premature end.  */
-  REG_ESIZE,           /* Compiled pattern bigger than 2^16 bytes.  */
-  REG_ERPAREN          /* Unmatched ) or \); not returned from regcomp.  */
-} reg_errcode_t;
+  typedef enum {
+    REG_NOERROR = 0,            /* Success.  */
+    REG_NOMATCH,                /* Didn't find a match (for regexec).  */
+
+    /* POSIX regcomp return error codes.  (In the order listed in the
+       standard.)  */
+    REG_BADPAT,                 /* Invalid pattern.  */
+    REG_ECOLLATE,               /* Not implemented.  */
+    REG_ECTYPE,                 /* Invalid character class name.  */
+    REG_EESCAPE,                /* Trailing backslash.  */
+    REG_ESUBREG,                /* Invalid back reference.  */
+    REG_EBRACK,                 /* Unmatched left bracket.  */
+    REG_EPAREN,                 /* Parenthesis imbalance.  */
+    REG_EBRACE,                 /* Unmatched \{.  */
+    REG_BADBR,                  /* Invalid contents of \{\}.  */
+    REG_ERANGE,                 /* Invalid range end.  */
+    REG_ESPACE,                 /* Ran out of memory.  */
+    REG_BADRPT,                 /* No preceding re for repetition op.  */
+
+    /* Error codes we've added.  */
+    REG_EEND,                   /* Premature end.  */
+    REG_ESIZE,                  /* Compiled pattern bigger than 2^16 bytes.  */
+    REG_ERPAREN                 /* Unmatched ) or \); not returned from regcomp.  */
+  } reg_errcode_t;
 \f
 /* This data structure represents a compiled pattern.  Before calling
    the pattern compiler, the fields `buffer', `allocated', `fastmap',
@@ -316,88 +315,86 @@ typedef enum
 #define RE_TRANSLATE_TYPE char *
 #endif
 
-struct re_pattern_buffer
-{
+  struct re_pattern_buffer {
 /* [[[begin pattern_buffer]]] */
-       /* Space that holds the compiled pattern.  It is declared as
-          `unsigned char *' because its elements are
-           sometimes used as array indexes.  */
-  unsigned char *buffer;
-
-       /* Number of bytes to which `buffer' points.  */
-  unsigned long int allocated;
-
-       /* Number of bytes actually used in `buffer'.  */
-  unsigned long int used;
-
-        /* Syntax setting with which the pattern was compiled.  */
-  reg_syntax_t syntax;
-
-        /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
-           the fastmap, if there is one, to skip over impossible
-           starting points for matches.  */
-  char *fastmap;
-
-        /* Either a translate table to apply to all characters before
-           comparing them, or zero for no translation.  The translation
-           is applied to a pattern when it is compiled and to a string
-           when it is matched.  */
-  RE_TRANSLATE_TYPE translate;
-
-       /* Number of subexpressions found by the compiler.  */
-  size_t re_nsub;
-
-        /* Zero if this pattern cannot match the empty string, one else.
-           Well, in truth it's used only in `re_search_2', to see
-           whether or not we should use the fastmap, so we don't set
-           this absolutely perfectly; see `re_compile_fastmap' (the
-           `duplicate' case).  */
-  unsigned can_be_null : 1;
-
-        /* If REGS_UNALLOCATED, allocate space in the `regs' structure
-             for `max (RE_NREGS, re_nsub + 1)' groups.
-           If REGS_REALLOCATE, reallocate space if necessary.
-           If REGS_FIXED, use what's there.  */
+    /* Space that holds the compiled pattern.  It is declared as
+       `unsigned char *' because its elements are
+       sometimes used as array indexes.  */
+    unsigned char *buffer;
+
+    /* Number of bytes to which `buffer' points.  */
+    unsigned long int allocated;
+
+    /* Number of bytes actually used in `buffer'.  */
+    unsigned long int used;
+
+    /* Syntax setting with which the pattern was compiled.  */
+    reg_syntax_t syntax;
+
+    /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
+       the fastmap, if there is one, to skip over impossible
+       starting points for matches.  */
+    char *fastmap;
+
+    /* Either a translate table to apply to all characters before
+       comparing them, or zero for no translation.  The translation
+       is applied to a pattern when it is compiled and to a string
+       when it is matched.  */
+    RE_TRANSLATE_TYPE translate;
+
+    /* Number of subexpressions found by the compiler.  */
+    size_t re_nsub;
+
+    /* Zero if this pattern cannot match the empty string, one else.
+       Well, in truth it's used only in `re_search_2', to see
+       whether or not we should use the fastmap, so we don't set
+       this absolutely perfectly; see `re_compile_fastmap' (the
+       `duplicate' case).  */
+    unsigned can_be_null:1;
+
+    /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+       for `max (RE_NREGS, re_nsub + 1)' groups.
+       If REGS_REALLOCATE, reallocate space if necessary.
+       If REGS_FIXED, use what's there.  */
 #define REGS_UNALLOCATED 0
 #define REGS_REALLOCATE 1
 #define REGS_FIXED 2
-  unsigned regs_allocated : 2;
+    unsigned regs_allocated:2;
 
-        /* Set to zero when `regex_compile' compiles a pattern; set to one
-           by `re_compile_fastmap' if it updates the fastmap.  */
-  unsigned fastmap_accurate : 1;
+    /* Set to zero when `regex_compile' compiles a pattern; set to one
+       by `re_compile_fastmap' if it updates the fastmap.  */
+    unsigned fastmap_accurate:1;
 
-        /* If set, `re_match_2' does not return information about
-           subexpressions.  */
-  unsigned no_sub : 1;
+    /* If set, `re_match_2' does not return information about
+       subexpressions.  */
+    unsigned no_sub:1;
 
-        /* If set, a beginning-of-line anchor doesn't match at the
-           beginning of the string.  */
-  unsigned not_bol : 1;
+    /* If set, a beginning-of-line anchor doesn't match at the
+       beginning of the string.  */
+    unsigned not_bol:1;
 
-        /* Similarly for an end-of-line anchor.  */
-  unsigned not_eol : 1;
+    /* Similarly for an end-of-line anchor.  */
+    unsigned not_eol:1;
 
-        /* If true, an anchor at a newline matches.  */
-  unsigned newline_anchor : 1;
+    /* If true, an anchor at a newline matches.  */
+    unsigned newline_anchor:1;
 
 /* [[[end pattern_buffer]]] */
-};
+  };
 
-typedef struct re_pattern_buffer regex_t;
+  typedef struct re_pattern_buffer regex_t;
 \f
 /* Type for byte offsets within the string.  POSIX mandates this.  */
-typedef int regoff_t;
+  typedef int regoff_t;
 
 
 /* This is the structure we store register match data in.  See
    regex.texinfo for a full description of what registers match.  */
-struct re_registers
-{
-  unsigned num_regs;
-  regoff_t *start;
-  regoff_t *end;
-};
+  struct re_registers {
+    unsigned num_regs;
+    regoff_t *start;
+    regoff_t *end;
+  };
 
 
 /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
@@ -411,11 +408,10 @@ struct re_registers
 /* POSIX specification for registers.  Aside from the different names than
    `re_registers', POSIX uses an array of structures, instead of a
    structure of arrays.  */
-typedef struct
-{
-  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
-  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
-} regmatch_t;
+  typedef struct {
+    regoff_t rm_so;             /* Byte offset from string's start to substring's start.  */
+    regoff_t rm_eo;             /* Byte offset from string's start to substring's end.  */
+  } regmatch_t;
 \f
 /* Declarations for routines.  */
 
@@ -429,28 +425,29 @@ typedef struct
 
 #define _RE_ARGS(args) args
 
-#else /* not __STDC__ */
+#else                           /* not __STDC__ */
 
 #define _RE_ARGS(args) ()
 
-#endif /* not __STDC__ */
+#endif                          /* not __STDC__ */
 
 /* Sets the current default syntax to SYNTAX, and return the old syntax.
    You can also simply assign to the `re_syntax_options' variable.  */
-extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
+  extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
 
 /* Compile the regular expression PATTERN, with length LENGTH
    and syntax given by the global `re_syntax_options', into the buffer
    BUFFER.  Return NULL if successful, and an error string if not.  */
-extern const char *re_compile_pattern
-  _RE_ARGS ((const char *pattern, size_t length,
-             struct re_pattern_buffer *buffer));
+  extern const char *re_compile_pattern
+    _RE_ARGS ((const char *pattern, size_t length,
+               struct re_pattern_buffer * buffer));
 
 
 /* Compile a fastmap for the compiled pattern in BUFFER; used to
    accelerate searches.  Return 0 if successful and -2 if was an
    internal error.  */
-extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
+  extern int re_compile_fastmap
+    _RE_ARGS ((struct re_pattern_buffer * buffer));
 
 
 /* Search in the string STRING (with length LENGTH) for the pattern
@@ -458,31 +455,31 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
    characters.  Return the starting position of the match, -1 for no
    match, or -2 for an internal error.  Also return register
    information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
-extern int re_search
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
-            int length, int start, int range, struct re_registers *regs));
+  extern int re_search
+    _RE_ARGS ((struct re_pattern_buffer * buffer, const char *string,
+               int length, int start, int range, struct re_registers * regs));
 
 
 /* Like `re_search', but search in the concatenation of STRING1 and
    STRING2.  Also, stop searching at index START + STOP.  */
-extern int re_search_2
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
-             int length1, const char *string2, int length2,
-             int start, int range, struct re_registers *regs, int stop));
+  extern int re_search_2
+    _RE_ARGS ((struct re_pattern_buffer * buffer, const char *string1,
+               int length1, const char *string2, int length2,
+               int start, int range, struct re_registers * regs, int stop));
 
 
 /* Like `re_search', but return how many characters in STRING the regexp
    in BUFFER matched, starting at position START.  */
-extern int re_match
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
-             int length, int start, struct re_registers *regs));
+  extern int re_match
+    _RE_ARGS ((struct re_pattern_buffer * buffer, const char *string,
+               int length, int start, struct re_registers * regs));
 
 
 /* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
-extern int re_match_2
-  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
-             int length1, const char *string2, int length2,
-             int start, struct re_registers *regs, int stop));
+  extern int re_match_2
+    _RE_ARGS ((struct re_pattern_buffer * buffer, const char *string1,
+               int length1, const char *string2, int length2,
+               int start, struct re_registers * regs, int stop));
 
 
 /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -497,36 +494,35 @@ extern int re_match_2
    Unless this function is called, the first search or match using
    PATTERN_BUFFER will allocate its own register data, without
    freeing the old data.  */
-extern void re_set_registers
-  _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
-             unsigned num_regs, regoff_t *starts, regoff_t *ends));
+  extern void re_set_registers
+    _RE_ARGS ((struct re_pattern_buffer * buffer, struct re_registers * regs,
+               unsigned num_regs, regoff_t * starts, regoff_t * ends));
 
 #ifdef _REGEX_RE_COMP
 #ifndef _CRAY
 /* 4.2 bsd compatibility.  */
-extern char *re_comp _RE_ARGS ((const char *));
-extern int re_exec _RE_ARGS ((const char *));
+  extern char *re_comp _RE_ARGS ((const char *));
+  extern int re_exec _RE_ARGS ((const char *));
 #endif
 #endif
 
 /* POSIX compatibility.  */
-extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
-extern int regexec
-  _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
-             regmatch_t pmatch[], int eflags));
-extern size_t regerror
-  _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
-             size_t errbuf_size));
-extern void regfree _RE_ARGS ((regex_t *preg));
+  extern int regcomp
+    _RE_ARGS ((regex_t * preg, const char *pattern, int cflags));
+  extern int regexec
+    _RE_ARGS ((const regex_t * preg, const char *string, size_t nmatch,
+               regmatch_t pmatch[], int eflags));
+  extern size_t regerror
+    _RE_ARGS ((int errcode, const regex_t * preg, char *errbuf,
+               size_t errbuf_size));
+  extern void regfree _RE_ARGS ((regex_t * preg));
 
 
 #ifdef __cplusplus
 }
-#endif /* C++ */
-
-#endif /* not __REGEXP_LIBRARY_H__ */
-\f
-/*
+#endif                          /* C++ */
+#endif                          /* not __REGEXP_LIBRARY_H__ */
+\f/*
 Local variables:
 make-backup-files: t
 version-control: t
index 1e85d56..1107312 100644 (file)
@@ -3,4 +3,3 @@
 #undef USE_NNTP
 /* The compressed mailboxes support */
 #undef USE_COMPRESSED
-
index 5b77531..a857829 100644 (file)
--- a/account.c
+++ b/account.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* remote host account manipulation (POP/IMAP) */
 
@@ -27,9 +27,9 @@
 #include "url.h"
 
 /* mutt_account_match: compare account info (host/port/user) */
-int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2)
+int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2)
 {
-  const charuser = NONULL (Username);
+  const char *user = NONULL (Username);
 
   if (a1->type != a2->type)
     return 0;
@@ -47,7 +47,7 @@ int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2)
   if (a1->type == M_ACCT_TYPE_POP && PopUser)
     user = PopUser;
 #endif
-  
+
 #ifdef USE_NNTP
   if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
     user = NntpUser;
@@ -64,7 +64,7 @@ int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* a2)
 }
 
 /* mutt_account_fromurl: fill account with information from url. */
-int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url)
+int mutt_account_fromurl (ACCOUNT * account, ciss_url_t * url)
 {
   /* must be present */
   if (url->host)
@@ -72,18 +72,15 @@ int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url)
   else
     return -1;
 
-  if (url->user)
-  {
+  if (url->user) {
     strfcpy (account->user, url->user, sizeof (account->user));
     account->flags |= M_ACCT_USER;
   }
-  if (url->pass)
-  {
+  if (url->pass) {
     strfcpy (account->pass, url->pass, sizeof (account->pass));
     account->flags |= M_ACCT_PASS;
   }
-  if (url->port)
-  {
+  if (url->port) {
     account->port = url->port;
     account->flags |= M_ACCT_PORT;
   }
@@ -95,7 +92,7 @@ int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url)
  *   is a set of pointers into account - don't free or edit account until
  *   you've finished with url (make a copy of account if you need it for
  *   a while). */
-void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
+void mutt_account_tourl (ACCOUNT * account, ciss_url_t * url)
 {
   url->scheme = U_UNKNOWN;
   url->user = NULL;
@@ -103,8 +100,7 @@ void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
   url->port = 0;
 
 #ifdef USE_IMAP
-  if (account->type == M_ACCT_TYPE_IMAP)
-  {
+  if (account->type == M_ACCT_TYPE_IMAP) {
     if (account->flags & M_ACCT_SSL)
       url->scheme = U_IMAPS;
     else
@@ -113,8 +109,7 @@ void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
 #endif
 
 #ifdef USE_POP
-  if (account->type == M_ACCT_TYPE_POP)
-  {
+  if (account->type == M_ACCT_TYPE_POP) {
     if (account->flags & M_ACCT_SSL)
       url->scheme = U_POPS;
     else
@@ -123,8 +118,7 @@ void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
 #endif
 
 #ifdef USE_NNTP
-  if (account->type == M_ACCT_TYPE_NNTP)
-  {
+  if (account->type == M_ACCT_TYPE_NNTP) {
     if (account->flags & M_ACCT_SSL)
       url->scheme = U_NNTPS;
     else
@@ -142,7 +136,7 @@ void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
 }
 
 /* mutt_account_getuser: retrieve username into ACCOUNT, if neccessary */
-int mutt_account_getuser (ACCOUNT* account)
+int mutt_account_getuser (ACCOUNT * account)
 {
   char prompt[SHORT_STRING];
 
@@ -162,8 +156,7 @@ int mutt_account_getuser (ACCOUNT* account)
     strfcpy (account->user, NntpUser, sizeof (account->user));
 #endif
   /* prompt (defaults to unix username), copy into account->user */
-  else
-  {
+  else {
     snprintf (prompt, sizeof (prompt), _("Username at %s: "), account->host);
     strfcpy (account->user, NONULL (Username), sizeof (account->user));
     if (mutt_get_field (prompt, account->user, sizeof (account->user), 0))
@@ -176,7 +169,7 @@ int mutt_account_getuser (ACCOUNT* account)
 }
 
 /* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */
-int mutt_account_getpass (ACCOUNT* account)
+int mutt_account_getpass (ACCOUNT * account)
 {
   char prompt[SHORT_STRING];
 
@@ -194,10 +187,9 @@ int mutt_account_getpass (ACCOUNT* account)
   else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
     strfcpy (account->pass, NntpPass, sizeof (account->pass));
 #endif
-  else
-  {
+  else {
     snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
-      account->user, account->host);
+              account->user, account->host);
     account->pass[0] = '\0';
     if (mutt_get_password (prompt, account->pass, sizeof (account->pass)))
       return -1;
@@ -208,7 +200,7 @@ int mutt_account_getpass (ACCOUNT* account)
   return 0;
 }
 
-void mutt_account_unsetpass (ACCOUNT* account)
+void mutt_account_unsetpass (ACCOUNT * account)
 {
   account->flags &= !M_ACCT_PASS;
 }
index a2aa59e..d3c7a76 100644 (file)
--- a/account.h
+++ b/account.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* remote host account manipulation (POP/IMAP) */
 
@@ -24,8 +24,7 @@
 #include "url.h"
 
 /* account types */
-enum
-{
+enum {
   M_ACCT_TYPE_NONE = 0,
   M_ACCT_TYPE_IMAP,
   M_ACCT_TYPE_NNTP,
@@ -38,8 +37,7 @@ enum
 #define M_ACCT_PASS (1<<2)
 #define M_ACCT_SSL  (1<<3)
 
-typedef struct
-{
+typedef struct {
   char user[64];
   char pass[64];
   char host[128];
@@ -48,11 +46,11 @@ typedef struct
   unsigned char flags;
 } ACCOUNT;
 
-int mutt_account_match (const ACCOUNT* a1, const ACCOUNT* m2);
-int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url);
-void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url);
-int mutt_account_getuser (ACCOUNT* account);
-int mutt_account_getpass (ACCOUNT* account);
-void mutt_account_unsetpass (ACCOUNT* account);
+int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * m2);
+int mutt_account_fromurl (ACCOUNT * account, ciss_url_t * url);
+void mutt_account_tourl (ACCOUNT * account, ciss_url_t * url);
+int mutt_account_getuser (ACCOUNT * account);
+int mutt_account_getpass (ACCOUNT * account);
+void mutt_account_unsetpass (ACCOUNT * account);
 
 #endif /* _MUTT_ACCOUNT_H_ */
index 3b6c48f..c54cad8 100644 (file)
-# generated automatically by aclocal 1.7.6 -*- Autoconf -*-
+dnl aclocal.m4 generated automatically by aclocal 1.4-p4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+# lib-prefix.m4 serial 3 (gettext-0.13)
+dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
-# Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
-
-# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+dnl From Bruno Haible.
 
-AC_PREREQ([2.52])
+dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
+dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
+dnl require excessive bracketing.
+ifdef([AC_HELP_STRING],
+[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
+[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
+
+dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
+dnl to access previously installed libraries. The basic assumption is that
+dnl a user will want packages to use other packages he previously installed
+dnl with the same --prefix option.
+dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
+dnl libraries, but is otherwise very convenient.
+AC_DEFUN([AC_LIB_PREFIX],
+[
+  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_LIB_ARG_WITH([lib-prefix],
+[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
+  --without-lib-prefix    don't search for libraries in includedir and libdir],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+])
+  if test $use_additional = yes; then
+    dnl Potentially add $additional_includedir to $CPPFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/include,
+    dnl   2. if it's already present in $CPPFLAGS,
+    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_includedir" != "X/usr/include"; then
+      haveit=
+      for x in $CPPFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-I$additional_includedir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_includedir" = "X/usr/local/include"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux*) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_includedir"; then
+            dnl Really add $additional_includedir to $CPPFLAGS.
+            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
+          fi
+        fi
+      fi
+    fi
+    dnl Potentially add $additional_libdir to $LDFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/lib,
+    dnl   2. if it's already present in $LDFLAGS,
+    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_libdir" != "X/usr/lib"; then
+      haveit=
+      for x in $LDFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-L$additional_libdir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_libdir" = "X/usr/local/lib"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux*) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_libdir"; then
+            dnl Really add $additional_libdir to $LDFLAGS.
+            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
+          fi
+        fi
+      fi
+    fi
+  fi
+])
 
-# serial 6
+dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
+dnl acl_final_exec_prefix, containing the values to which $prefix and
+dnl $exec_prefix will expand at the end of the configure script.
+AC_DEFUN([AC_LIB_PREPARE_PREFIX],
+[
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+])
 
-# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
-AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
+dnl variables prefix and exec_prefix bound to the values they will have
+dnl at the end of the configure script.
+AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
+[
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  $1
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+])
 
-# Do all the work for Automake.                            -*- Autoconf -*-
+# lib-link.m4 serial 4 (gettext-0.12)
+dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
 
-# This macro actually does too much some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
+dnl From Bruno Haible.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
+dnl augments the CPPFLAGS variable.
+AC_DEFUN([AC_LIB_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  define([Name],[translit([$1],[./-], [___])])
+  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
+    AC_LIB_LINKFLAGS_BODY([$1], [$2])
+    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
+    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
+    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
+  ])
+  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
+  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
+  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
+  dnl results of this search when this library appears as a dependency.
+  HAVE_LIB[]NAME=yes
+  undefine([Name])
+  undefine([NAME])
+])
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
+dnl searches for libname and the libraries corresponding to explicit and
+dnl implicit dependencies, together with the specified include files and
+dnl the ability to compile and link the specified testcode. If found, it
+dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
+dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  define([Name],[translit([$1],[./-], [___])])
+  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+
+  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
+  dnl accordingly.
+  AC_LIB_LINKFLAGS_BODY([$1], [$2])
+
+  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
+  dnl because if the user has installed lib[]Name and not disabled its use
+  dnl via --without-lib[]Name-prefix, he wants to use it.
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+
+  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIB[]NAME"
+    AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
+    LIBS="$ac_save_LIBS"
+  ])
+  if test "$ac_cv_lib[]Name" = yes; then
+    HAVE_LIB[]NAME=yes
+    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
+    AC_MSG_CHECKING([how to link with lib[]$1])
+    AC_MSG_RESULT([$LIB[]NAME])
+  else
+    HAVE_LIB[]NAME=no
+    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
+    dnl $INC[]NAME either.
+    CPPFLAGS="$ac_save_CPPFLAGS"
+    LIB[]NAME=
+    LTLIB[]NAME=
+  fi
+  AC_SUBST([HAVE_LIB]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  undefine([Name])
+  undefine([NAME])
+])
 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+dnl Determine the platform dependent parameters needed to use rpath:
+dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
+dnl hardcode_direct, hardcode_minus_L.
+AC_DEFUN([AC_LIB_RPATH],
+[
+  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
+  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
+  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
+  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+  AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+  ])
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+  dnl Determine whether the user wants rpath handling at all.
+  AC_ARG_ENABLE(rpath,
+    [  --disable-rpath         do not hardcode runtime library paths],
+    :, enable_rpath=yes)
+])
 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
+AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
+[
+  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_LIB_ARG_WITH([lib$1-prefix],
+[  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
+  --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+])
+  dnl Search the library and its dependencies in $additional_libdir and
+  dnl $LDFLAGS. Using breadth-first-seach.
+  LIB[]NAME=
+  LTLIB[]NAME=
+  INC[]NAME=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='$1 $2'
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
+        dnl or AC_LIB_HAVE_LINKFLAGS call.
+        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
+          else
+            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
+            dnl that this library doesn't exist. So just drop it.
+            :
+          fi
+        else
+          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
+          dnl and the already constructed $LIBNAME/$LTLIBNAME.
+          found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIB[]NAME; do
+              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+            dnl Found the library.
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+              dnl Linking with a shared library. We attempt to hardcode its
+              dnl directory into the executable's runpath, unless it's the
+              dnl standard /usr/lib.
+              if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                dnl No hardcoding is needed.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+              else
+                dnl Use an explicit option to hardcode DIR into the resulting
+                dnl binary.
+                dnl Potentially add DIR to ltrpathdirs.
+                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                dnl The hardcoding into $LIBNAME is system dependent.
+                if test "$hardcode_direct" = yes; then
+                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
+                  dnl resulting binary.
+                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                    dnl Use an explicit option to hardcode DIR into the resulting
+                    dnl binary.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    dnl Potentially add DIR to rpathdirs.
+                    dnl The rpathdirs will be appended to $LIBNAME at the end.
+                    haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                    dnl Rely on "-L$found_dir".
+                    dnl But don't add it if it's already contained in the LDFLAGS
+                    dnl or the already constructed $LIBNAME
+                    haveit=
+                    for x in $LDFLAGS $LIB[]NAME; do
+                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    else
+                      dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
+                      dnl here, because this doesn't fit in flags passed to the
+                      dnl compiler. So give up. No hardcoding. This affects only
+                      dnl very old systems.
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                dnl Linking with a static library.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
+              else
+                dnl We shouldn't come here, but anyway it's good to have a
+                dnl fallback.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
+              fi
+            fi
+            dnl Assume the include files are nearby.
+            additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+              dnl Potentially add $additional_includedir to $INCNAME.
+              dnl But don't add it
+              dnl   1. if it's the standard /usr/include,
+              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
+              dnl   3. if it's already present in $CPPFLAGS or the already
+              dnl      constructed $INCNAME,
+              dnl   4. if it doesn't exist as a directory.
+              if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INC[]NAME; do
+                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                      dnl Really add $additional_includedir to $INCNAME.
+                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+            dnl Look for dependencies.
+            if test -n "$found_la"; then
+              dnl Read the .la file. It defines the variables
+              dnl dlname, library_names, old_library, dependency_libs, current,
+              dnl age, revision, installed, dlopen, dlpreopen, libdir.
+              save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+              dnl We use only dependency_libs.
+              for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
+                    dnl But don't add it
+                    dnl   1. if it's the standard /usr/lib,
+                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
+                    dnl   3. if it's already present in $LDFLAGS or the already
+                    dnl      constructed $LIBNAME,
+                    dnl   4. if it doesn't exist as a directory.
+                    if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LIBNAME.
+                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LTLIBNAME.
+                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                      dnl Potentially add DIR to rpathdirs.
+                      dnl The rpathdirs will be appended to $LIBNAME at the end.
+                      haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                      dnl Potentially add DIR to ltrpathdirs.
+                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                      haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                    dnl Handle this in the next round.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                    dnl Handle this in the next round. Throw away the .la's
+                    dnl directory; it is already contained in a preceding -L
+                    dnl option.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                    dnl Most likely an immediate library name.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
+                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+            dnl Didn't find the library; assume it is in the system directories
+            dnl known to the linker and runtime loader. (All the system
+            dnl directories known to the linker should also be known to the
+            dnl runtime loader, otherwise the system is severely misconfigured.)
+            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+      dnl Weird platform: only the last -rpath option counts, the user must
+      dnl pass all path elements in one option. We can arrange that for a
+      dnl single library, but not when more than one $LIBNAMEs are used.
+      alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+      dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
+      acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+    else
+      dnl The -rpath options are cumulative.
+      for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+    dnl When using libtool, the option that works for both libraries and
+    dnl executables is -R. The -R options are cumulative.
+    for found_dir in $ltrpathdirs; do
+      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
+    done
+  fi
+])
 
-# serial 10
+dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
+dnl unless already present in VAR.
+dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
+dnl contains two or three consecutive elements that belong together.
+AC_DEFUN([AC_LIB_APPENDTOVAR],
+[
+  for element in [$2]; do
+    haveit=
+    for x in $[$1]; do
+      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      [$1]="${[$1]}${[$1]:+ }$element"
+    fi
+  done
+])
 
-AC_PREREQ([2.54])
-
-# Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
-# the ones we care about.
-m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-
-# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
-# AM_INIT_AUTOMAKE([OPTIONS])
-# -----------------------------------------------
-# The call with PACKAGE and VERSION arguments is the old style
-# call (pre autoconf-2.50), which is being phased out.  PACKAGE
-# and VERSION should now be passed to AC_INIT and removed from
-# the call to AM_INIT_AUTOMAKE.
-# We support both call styles for the transition.  After
-# the next Automake release, Autoconf can make the AC_INIT
-# arguments mandatory, and then we can depend on a new Autoconf
-# release and drop the old call support.
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
- AC_REQUIRE([AC_PROG_INSTALL])dnl
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
-   test -f $srcdir/config.status; then
-  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-fi
+# lib-ld.m4 serial 3 (gettext-0.13)
+dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl Subroutines of libtool.m4,
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
+
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
+AC_DEFUN([AC_LIB_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  acl_cv_prog_gnu_ld=yes ;;
+*)
+  acl_cv_prog_gnu_ld=no ;;
+esac])
+with_gnu_ld=$acl_cv_prog_gnu_ld
+])
 
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
-  if (cygpath --version) >/dev/null 2>/dev/null; then
-    CYGPATH_W='cygpath -w'
+dnl From libtool-1.4. Sets the variable LD.
+AC_DEFUN([AC_LIB_PROG_LD],
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
   else
-    CYGPATH_W=echo
+    PATH_SEPARATOR=:
   fi
+  rm -f conf$$.sh
 fi
-AC_SUBST([CYGPATH_W])
-
-# Define the identity of the package.
-dnl Distinguish between old-style and new-style calls.
-m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
- AC_SUBST([PACKAGE], [$1])dnl
- AC_SUBST([VERSION], [$2])],
-[_AM_SET_OPTIONS([$1])dnl
- AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
- AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
-
-_AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
-
-# Some tools Automake needs.
-AC_REQUIRE([AM_SANITY_CHECK])dnl
-AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_MISSING_PROG(AMTAR, tar)
-AM_PROG_INSTALL_SH
-AM_PROG_INSTALL_STRIP
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([AC_PROG_MAKE_SET])dnl
-AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-
-_AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_CC],
-                  [_AM_DEPENDENCIES(CC)],
-                  [define([AC_PROG_CC],
-                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_CXX],
-                  [_AM_DEPENDENCIES(CXX)],
-                  [define([AC_PROG_CXX],
-                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
-])
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]* | [A-Za-z]:[\\/]*)]
+      [re_direlt='/[^/][^/]*/\.\./']
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(acl_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break ;;
+      *)
+       test "$with_gnu_ld" != yes && break ;;
+      esac
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_LIB_PROG_LD_GNU
 ])
 
-
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated.  The stamp files are numbered to have different names.
-
-# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
-# loop where config.status creates the headers, so we can generate
-# our stamp files there.
-AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
-[# Compute $1's index in $config_headers.
-_am_stamp_count=1
-for _am_header in $config_headers :; do
-  case $_am_header in
-    $1 | $1:* )
-      break ;;
-    * )
-      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated.  We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+  case " <<$>>CONFIG_HEADERS " in
+  *" <<$>>am_file "*<<)>>
+    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+    ;;
   esac
-done
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
-
-# Copyright 2002  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+  am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
 
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
+# Do all the work for Automake.  This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
 
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-        [AM_AUTOMAKE_VERSION([1.7.6])])
-
-# Helper functions for option handling.                    -*- Autoconf -*-
-
-# Copyright 2001, 2002  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 2
+# serial 1
 
-# _AM_MANGLE_OPTION(NAME)
-# -----------------------
-AC_DEFUN([_AM_MANGLE_OPTION],
-[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
-
-# _AM_SET_OPTION(NAME)
-# ------------------------------
-# Set option NAME.  Presently that only means defining a flag for this option.
-AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
-
-# _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
-# OPTIONS is a space-separated list of Automake options.
-AC_DEFUN([_AM_SET_OPTIONS],
-[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
-
-# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
-# -------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-AC_DEFUN([_AM_IF_OPTION],
-[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
 
 #
 # Check to make sure that the build environment is sane.
 #
 
-# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 3
-
-# AM_SANITY_CHECK
-# ---------------
-AC_DEFUN([AM_SANITY_CHECK],
+AC_DEFUN(AM_SANITY_CHECK,
 [AC_MSG_CHECKING([whether build environment is sane])
 # Just in case
 sleep 1
-echo timestamp > conftest.file
+echo timestamp > conftestfile
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
-   if test "$[*]" = "X"; then
+   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+   if test "[$]*" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t $srcdir/configure conftestfile`
    fi
-   rm -f conftest.file
-   if test "$[*]" != "X $srcdir/configure conftest.file" \
-      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+   if test "[$]*" != "X $srcdir/configure conftestfile" \
+      && test "[$]*" != "X conftestfile $srcdir/configure"; then
 
       # If neither matched, then we have a broken ls.  This can happen
       # if, for instance, CONFIG_SHELL is bash and it inherits a
@@ -288,7 +918,7 @@ if (
 alias in your environment])
    fi
 
-   test "$[2]" = conftest.file
+   test "[$]2" = conftestfile
    )
 then
    # Ok.
@@ -297,569 +927,35 @@ else
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
+rm -f conftest*
 AC_MSG_RESULT(yes)])
 
-#  -*- Autoconf -*-
-
-
-# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 3
-
-# AM_MISSING_PROG(NAME, PROGRAM)
-# ------------------------------
-AC_DEFUN([AM_MISSING_PROG],
-[AC_REQUIRE([AM_MISSING_HAS_RUN])
-$1=${$1-"${am_missing_run}$2"}
-AC_SUBST($1)])
-
-
-# AM_MISSING_HAS_RUN
-# ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
-AC_DEFUN([AM_MISSING_HAS_RUN],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
-else
-  am_missing_run=
-  AC_MSG_WARN([`missing' script is too old or missing])
-fi
-])
-
-# AM_AUX_DIR_EXPAND
-
-# Copyright 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
-#
-# Of course, Automake must honor this variable whenever it calls a
-# tool from the auxiliary directory.  The problem is that $srcdir (and
-# therefore $ac_aux_dir as well) can be either absolute or relative,
-# depending on how configure is run.  This is pretty annoying, since
-# it makes $ac_aux_dir quite unusable in subdirectories: in the top
-# source directory, any form will work fine, but in subdirectories a
-# relative path needs to be adjusted first.
-#
-# $ac_aux_dir/missing
-#    fails when called from a subdirectory if $ac_aux_dir is relative
-# $top_srcdir/$ac_aux_dir/missing
-#    fails if $ac_aux_dir is absolute,
-#    fails when called from a subdirectory in a VPATH build with
-#          a relative $ac_aux_dir
-#
-# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
-# are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
-# start a VPATH build or use an absolute $srcdir.
-#
-# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
-# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
-#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
-# and then we would define $MISSING as
-#   MISSING="\${SHELL} $am_aux_dir/missing"
-# This will work as long as MISSING is not called from configure, because
-# unfortunately $(top_srcdir) has no meaning in configure.
-# However there are other variables, like CC, which are often used in
-# configure, and could therefore not use this "fixed" $ac_aux_dir.
-#
-# Another solution, used here, is to always expand $ac_aux_dir to an
-# absolute PATH.  The drawback is that using absolute paths prevent a
-# configured tree to be moved without reconfiguration.
-
-# Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])
-
-AC_DEFUN([AM_AUX_DIR_EXPAND], [
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-])
-
-# AM_PROG_INSTALL_SH
-# ------------------
-# Define $install_sh.
-
-# Copyright 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-AC_DEFUN([AM_PROG_INSTALL_SH],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
-AC_SUBST(install_sh)])
-
-# AM_PROG_INSTALL_STRIP
-
-# Copyright 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# One issue with vendor `install' (even GNU) is that you can't
-# specify the program used to strip binaries.  This is especially
-# annoying in cross-compiling environments, where the build's strip
-# is unlikely to handle the host's binaries.
-# Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
-# STRIPPROG with the value of the STRIP variable (set by the user).
-AC_DEFUN([AM_PROG_INSTALL_STRIP],
-[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
-if test "$cross_compiling" != no; then
-  AC_CHECK_TOOL([STRIP], [strip], :)
-fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
-AC_SUBST([INSTALL_STRIP_PROGRAM])])
-
-#                                                          -*- Autoconf -*-
-# Copyright (C) 2003  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 1
-
-# Check whether the underlying file-system supports filenames
-# with a leading dot.  For instance MS-DOS doesn't.
-AC_DEFUN([AM_SET_LEADING_DOT],
-[rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
-  am__leading_dot=.
-else
-  am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-AC_SUBST([am__leading_dot])])
-
-# serial 5                                             -*- Autoconf -*-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery.  Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
-
-
-
-# _AM_DEPENDENCIES(NAME)
-# ----------------------
-# See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
-# We try a few techniques and use that to set a single cache variable.
-#
-# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
-# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
-# dependency, and given that the user is not expected to run this macro,
-# just rely on AC_PROG_CC.
-AC_DEFUN([_AM_DEPENDENCIES],
-[AC_REQUIRE([AM_SET_DEPDIR])dnl
-AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
-AC_REQUIRE([AM_MAKE_INCLUDE])dnl
-AC_REQUIRE([AM_DEP_TRACK])dnl
-
-ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
-       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
-       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                   [depcc="$$1"   am_compiler_list=])
-
-AC_CACHE_CHECK([dependency style of $depcc],
-               [am_cv_$1_dependencies_compiler_type],
-[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
-
-  am_cv_$1_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
-  fi
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      : > sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
-    case $depmode in
-    nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
-      if test "x$enable_dependency_tracking" = xyes; then
-       continue
-      else
-       break
-      fi
-      ;;
-    none) break ;;
-    esac
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.
-    if depmode=$depmode \
-       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored.
-      if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
-        am_cv_$1_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
-
-  cd ..
-  rm -rf conftest.dir
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf.  Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+   $1=$2
+   AC_MSG_RESULT(found)
 else
-  am_cv_$1_dependencies_compiler_type=none
-fi
-])
-AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
-AM_CONDITIONAL([am__fastdep$1], [
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
-])
-
-
-# AM_SET_DEPDIR
-# -------------
-# Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
-AC_DEFUN([AM_SET_DEPDIR],
-[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
-])
-
-
-# AM_DEP_TRACK
-# ------------
-AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[  --disable-dependency-tracking Speeds up one-time builds
-  --enable-dependency-tracking  Do not reject slow dependency extractors])
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-fi
-AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])
-])
-
-# Generate code to set up dependency tracking.   -*- Autoconf -*-
-
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-#serial 2
-
-# _AM_OUTPUT_DEPENDENCY_COMMANDS
-# ------------------------------
-AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[for mf in $CONFIG_FILES; do
-  # Strip MF so we end up with the name of the file.
-  mf=`echo "$mf" | sed -e 's/:.*$//'`
-  # Check whether this is an Automake generated Makefile or not.
-  # We used to match only the files named `Makefile.in', but
-  # some people rename them; so instead we look at the file content.
-  # Grep'ing the first line is not enough: some people post-process
-  # each Makefile.in and add a new line on top of each file to say so.
-  # So let's grep whole file.
-  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
-    dirpart=`AS_DIRNAME("$mf")`
-  else
-    continue
-  fi
-  grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
-  # Extract the definition of DEP_FILES from the Makefile without
-  # running `make'.
-  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
-  test -z "$DEPDIR" && continue
-  # When using ansi2knr, U may be empty or an underscore; expand it
-  U=`sed -n -e '/^U = / s///p' < "$mf"`
-  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
-  # We invoke sed twice because it is the simplest approach to
-  # changing $(DEPDIR) to its actual value in the expansion.
-  for file in `sed -n -e '
-    /^DEP_FILES = .*\\\\$/ {
-      s/^DEP_FILES = //
-      :loop
-       s/\\\\$//
-       p
-       n
-       /\\\\$/ b loop
-      p
-    }
-    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
-       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-    # Make sure the directory exists.
-    test -f "$dirpart/$file" && continue
-    fdir=`AS_DIRNAME(["$file"])`
-    AS_MKDIR_P([$dirpart/$fdir])
-    # echo "creating $dirpart/$file"
-    echo '# dummy' > "$dirpart/$file"
-  done
-done
-])# _AM_OUTPUT_DEPENDENCY_COMMANDS
-
-
-# AM_OUTPUT_DEPENDENCY_COMMANDS
-# -----------------------------
-# This macro should only be invoked once -- use via AC_REQUIRE.
-#
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
-# need in order to bootstrap the dependency handling code.
-AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
-[AC_CONFIG_COMMANDS([depfiles],
-     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
-
-# Check to see how 'make' treats includes.     -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 2
-
-# AM_MAKE_INCLUDE()
-# -----------------
-# Check to see how make treats includes.
-AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
-       @echo done
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
-   am__include=include
-   am__quote=
-   _am_result=GNU
+   $1="$3/missing $2"
+   AC_MSG_RESULT(missing)
 fi
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
-      am__include=.include
-      am__quote="\""
-      _am_result=BSD
-   fi
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
-
-# AM_CONDITIONAL                                              -*- Autoconf -*-
-
-# Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 5
+AC_SUBST($1)])
 
-AC_PREREQ(2.52)
+# isc-posix.m4 serial 2 (gettext-0.11.2)
+dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
 
-# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-# -------------------------------------
-# Define a conditional.
-AC_DEFUN([AM_CONDITIONAL],
-[ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-        [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])
-AC_SUBST([$1_FALSE])
-if $2; then
-  $1_TRUE=
-  $1_FALSE='#'
-else
-  $1_TRUE='#'
-  $1_FALSE=
-fi
-AC_CONFIG_COMMANDS_PRE(
-[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-  AC_MSG_ERROR([conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.])
-fi])])
+# This file is not needed with autoconf-2.53 and newer.  Remove it in 2005.
 
-#serial 1
 # This test replaces the one in autoconf.
 # Currently this macro should have the same name as the autoconf macro
 # because gettext's gettext.m4 (distributed in the automake package)
@@ -878,26 +974,9 @@ AC_DEFUN([AC_ISC_POSIX],
 )
 
 
-# Copyright 1996, 1997, 1998, 2000, 2001, 2002  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 2
+# serial 1
 
-AC_DEFUN([AM_C_PROTOTYPES],
+AC_DEFUN(AM_C_PROTOTYPES,
 [AC_REQUIRE([AM_PROG_CC_STDC])
 AC_REQUIRE([AC_PROG_CPP])
 AC_MSG_CHECKING([for function prototypes])
@@ -908,35 +987,16 @@ if test "$am_cv_prog_cc_stdc" != no; then
 else
   AC_MSG_RESULT(no)
   U=_ ANSI2KNR=./ansi2knr
+  # Ensure some checks needed by ansi2knr itself.
+  AC_HEADER_STDC
+  AC_CHECK_HEADERS(string.h)
 fi
-# Ensure some checks needed by ansi2knr itself.
-AC_HEADER_STDC
-AC_CHECK_HEADERS(string.h)
 AC_SUBST(U)dnl
 AC_SUBST(ANSI2KNR)dnl
 ])
 
-AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
-
 
-# Copyright 1996, 1997, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 2
+# serial 1
 
 # @defmac AC_PROG_CC_STDC
 # @maindex PROG_CC_STDC
@@ -953,7 +1013,7 @@ AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
 # program @code{ansi2knr}, which comes with Ghostscript.
 # @end defmac
 
-AC_DEFUN([AM_PROG_CC_STDC],
+AC_DEFUN(AM_PROG_CC_STDC,
 [AC_REQUIRE([AC_PROG_CC])
 AC_BEFORE([$0], [AC_C_INLINE])
 AC_BEFORE([$0], [AC_C_CONST])
@@ -963,7 +1023,7 @@ dnl like #elif.
 dnl FIXME: can't do this because then AC_AIX won't work due to a
 dnl circular dependency.
 dnl AC_BEFORE([$0], [AC_PROG_CPP])
-AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
+AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
 AC_CACHE_VAL(am_cv_prog_cc_stdc,
 [am_cv_prog_cc_stdc=no
 ac_save_CC="$CC"
@@ -971,10 +1031,9 @@ ac_save_CC="$CC"
 # breaks some systems' header files.
 # AIX                  -qlanglvl=ansi
 # Ultrix and OSF/1     -std1
-# HP-UX 10.20 and later        -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
+# HP-UX                        -Aa -D_HPUX_SOURCE
 # SVR4                 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   AC_TRY_COMPILE(
@@ -1016,7 +1075,7 @@ CC="$ac_save_CC"
 if test -z "$am_cv_prog_cc_stdc"; then
   AC_MSG_RESULT([none needed])
 else
-  AC_MSG_RESULT([$am_cv_prog_cc_stdc])
+  AC_MSG_RESULT($am_cv_prog_cc_stdc)
 fi
 case "x$am_cv_prog_cc_stdc" in
   x|xno) ;;
@@ -1024,8 +1083,6 @@ case "x$am_cv_prog_cc_stdc" in
 esac
 ])
 
-AU_DEFUN([fp_PROG_CC_STDC], [AM_PROG_CC_STDC])
-
 dnl types.m4
 dnl macros for type checks not covered by autoconf
 
@@ -1210,6 +1267,19 @@ changequote([,])dnl
 ])dnl
 dnl ---------------------------------------------------------------------------
 
+# Define a conditional.
+
+AC_DEFUN(AM_CONDITIONAL,
+[AC_SUBST($1_TRUE)
+AC_SUBST($1_FALSE)
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi])
+
 # gssapi.m4: Find GSSAPI libraries in either Heimdal or MIT implementations
 # Brendan Cully <brendan@kublai.com> 20010529
 
@@ -1880,12 +1950,18 @@ fi
 AC_SUBST($1)dnl
 ])
 
-#serial 2
+# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40)
+dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
 
 # Test for the GNU C Library, version 2.1 or newer.
 # From Bruno Haible.
 
-AC_DEFUN([MUTT_jm_GLIBC21],
+AC_DEFUN([jm_GLIBC21],
   [
     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
       ac_cv_gnu_library_2_1,
@@ -2020,6 +2096,33 @@ AC_DEFUN([MUTT_AM_LC_MESSAGES],
     fi
   fi])
 
+#serial 2
+
+# Test for the GNU C Library, version 2.1 or newer.
+# From Bruno Haible.
+
+AC_DEFUN([MUTT_jm_GLIBC21],
+  [
+    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
+      ac_cv_gnu_library_2_1,
+      [AC_EGREP_CPP([Lucky GNU user],
+       [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
+  Lucky GNU user
+ #endif
+#endif
+       ],
+       ac_cv_gnu_library_2_1=yes,
+       ac_cv_gnu_library_2_1=no)
+      ]
+    )
+    AC_SUBST(GLIBC21)
+    GLIBC21="$ac_cv_gnu_library_2_1"
+  ]
+)
+
 dnl vim:ft=config:
 
 dnl Search for libesmtp, by Steven Engelhardt <sengelha@yahoo.com>
index 15f78a4..8be76f6 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x
 
 static struct mapping_t AliasHelp[] = {
-  { N_("Exit"),   OP_EXIT },
-  { N_("Del"),    OP_DELETE },
-  { N_("Undel"),  OP_UNDELETE },
-  { N_("Select"), OP_GENERIC_SELECT_ENTRY },
-  { N_("Help"),   OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("Del"), OP_DELETE},
+  {N_("Undel"), OP_UNDELETE},
+  {N_("Select"), OP_GENERIC_SELECT_ENTRY},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
-static const char *
-alias_format_str (char *dest, size_t destlen, char op, const char *src,
-                 const char *fmt, const char *ifstring, const char *elsestring,
-                 unsigned long data, format_flag flags)
+static const char *alias_format_str (char *dest, size_t destlen, char op,
+                                     const char *src, const char *fmt,
+                                     const char *ifstring,
+                                     const char *elsestring,
+                                     unsigned long data, format_flag flags)
 {
   char tmp[SHORT_STRING], adr[SHORT_STRING];
   ALIAS *alias = (ALIAS *) data;
 
-  switch (op)
-  {
-    case 'f':
-      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-      snprintf (dest, destlen, tmp, alias->del ? "D" : " ");
-      break;
-    case 'a':
-      mutt_format_s (dest, destlen, fmt, alias->name);
-      break;
-    case 'r':
-      adr[0] = 0;
-      rfc822_write_address (adr, sizeof (adr), alias->addr, 1);
-      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-      snprintf (dest, destlen, tmp, adr);
-      break;
-    case 'n':
-      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-      snprintf (dest, destlen, tmp, alias->num + 1);
-      break;
-    case 't':
-      dest[0] = alias->tagged ? '*' : ' ';
-      dest[1] = 0;
-      break;
+  switch (op) {
+  case 'f':
+    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+    snprintf (dest, destlen, tmp, alias->del ? "D" : " ");
+    break;
+  case 'a':
+    mutt_format_s (dest, destlen, fmt, alias->name);
+    break;
+  case 'r':
+    adr[0] = 0;
+    rfc822_write_address (adr, sizeof (adr), alias->addr, 1);
+    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+    snprintf (dest, destlen, tmp, adr);
+    break;
+  case 'n':
+    snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+    snprintf (dest, destlen, tmp, alias->num + 1);
+    break;
+  case 't':
+    dest[0] = alias->tagged ? '*' : ' ';
+    dest[1] = 0;
+    break;
   }
 
   return (src);
 }
 
-static void alias_entry (char *s, size_t slen, MUTTMENU *m, int num)
+static void alias_entry (char *s, size_t slen, MUTTMENU * m, int num)
 {
-  mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str,
+                     (unsigned long) ((ALIAS **) m->data)[num],
+                     M_FORMAT_ARROWCURSOR);
 }
 
-static int alias_tag (MUTTMENU *menu, int n, int m)
+static int alias_tag (MUTTMENU * menu, int n, int m)
 {
   ALIAS *cur = ((ALIAS **) menu->data)[n];
   int ot = cur->tagged;
-  
+
   cur->tagged = (m >= 0 ? m : !cur->tagged);
-  
+
   return cur->tagged - ot;
 }
 
@@ -114,8 +116,7 @@ static int alias_SortAddress (const void *a, const void *b)
     r = -1;
   else if (pb == NULL)
     r = 1;
-  else if (pa->personal)
-  { 
+  else if (pa->personal) {
     if (pb->personal)
       r = mutt_strcasecmp (pa->personal, pb->personal);
     else
@@ -128,7 +129,7 @@ static int alias_SortAddress (const void *a, const void *b)
   return (RSORT (r));
 }
 
-void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases)
+void mutt_alias_menu (char *buf, size_t buflen, ALIAS * aliases)
 {
   ALIAS *aliasp;
   MUTTMENU *menu;
@@ -139,31 +140,31 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases)
   char helpstr[SHORT_STRING];
 
   int omax;
-  
-  if (!aliases)
-  {
+
+  if (!aliases) {
     mutt_error _("You have no aliases!");
+
     return;
   }
-  
+
   /* tell whoever called me to redraw the screen when I return */
   set_option (OPTNEEDREDRAW);
-  
+
   menu = mutt_new_menu ();
   menu->make_entry = alias_entry;
   menu->tag = alias_tag;
   menu->menu = MENU_ALIAS;
   menu->title = _("Aliases");
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ALIAS, AliasHelp);
+  menu->help =
+    mutt_compile_help (helpstr, sizeof (helpstr), MENU_ALIAS, AliasHelp);
 
 new_aliases:
 
   omax = menu->max;
-  
+
   /* count the number of aliases */
-  for (aliasp = aliases; aliasp; aliasp = aliasp->next)
-  {
-    aliasp->self->del    = 0;
+  for (aliasp = aliases; aliasp; aliasp = aliasp->next) {
+    aliasp->self->del = 0;
     aliasp->self->tagged = 0;
     menu->max++;
   }
@@ -171,76 +172,67 @@ new_aliases:
   safe_realloc (&AliasTable, menu->max * sizeof (ALIAS *));
   menu->data = AliasTable;
 
-  for (i = omax, aliasp = aliases; aliasp; aliasp = aliasp->next, i++)
-  {
+  for (i = omax, aliasp = aliases; aliasp; aliasp = aliasp->next, i++) {
     AliasTable[i] = aliasp->self;
-    aliases       = aliasp;
+    aliases = aliasp;
   }
 
-  if ((SortAlias & SORT_MASK) != SORT_ORDER)
-  {
+  if ((SortAlias & SORT_MASK) != SORT_ORDER) {
     qsort (AliasTable, i, sizeof (ALIAS *),
-        (SortAlias & SORT_MASK) == SORT_ADDRESS ? alias_SortAddress : alias_SortAlias);
+           (SortAlias & SORT_MASK) ==
+           SORT_ADDRESS ? alias_SortAddress : alias_SortAlias);
   }
 
-  for (i=0; i<menu->max; i++) AliasTable[i]->num = i;
+  for (i = 0; i < menu->max; i++)
+    AliasTable[i]->num = i;
 
-  while (!done)
-  {
-    if (aliases->next)
-    {
+  while (!done) {
+    if (aliases->next) {
       menu->redraw |= REDRAW_FULL;
-      aliases       = aliases->next;
+      aliases = aliases->next;
       goto new_aliases;
     }
-    
-    switch ((op = mutt_menuLoop (menu)))
-    {
-      case OP_DELETE:
-      case OP_UNDELETE:
-        if (menu->tagprefix)
-        {
-         for (i = 0; i < menu->max; i++)
-           if (AliasTable[i]->tagged)
-             AliasTable[i]->del = (op == OP_DELETE) ? 1 : 0;
-         menu->redraw |= REDRAW_INDEX;
-       }
-        else
-        {
-         AliasTable[menu->current]->self->del = (op == OP_DELETE) ? 1 : 0;
-         menu->redraw |= REDRAW_CURRENT;
-         if (option (OPTRESOLVE) && menu->current < menu->max - 1)
-         {
-           menu->current++;
-           menu->redraw |= REDRAW_INDEX;
-         }
-       }
-        break;
-      case OP_GENERIC_SELECT_ENTRY:
-        t = menu->current;
-      case OP_EXIT:
-       done = 1;
-       break;
+
+    switch ((op = mutt_menuLoop (menu))) {
+    case OP_DELETE:
+    case OP_UNDELETE:
+      if (menu->tagprefix) {
+        for (i = 0; i < menu->max; i++)
+          if (AliasTable[i]->tagged)
+            AliasTable[i]->del = (op == OP_DELETE) ? 1 : 0;
+        menu->redraw |= REDRAW_INDEX;
+      }
+      else {
+        AliasTable[menu->current]->self->del = (op == OP_DELETE) ? 1 : 0;
+        menu->redraw |= REDRAW_CURRENT;
+        if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
+          menu->current++;
+          menu->redraw |= REDRAW_INDEX;
+        }
+      }
+      break;
+    case OP_GENERIC_SELECT_ENTRY:
+      t = menu->current;
+    case OP_EXIT:
+      done = 1;
+      break;
     }
   }
 
-  for (i = 0; i < menu->max; i++)
-  {
-    if (AliasTable[i]->tagged)
-    {
+  for (i = 0; i < menu->max; i++) {
+    if (AliasTable[i]->tagged) {
       mutt_addrlist_to_local (AliasTable[i]->addr);
       rfc822_write_address (buf, buflen, AliasTable[i]->addr, 0);
       t = -1;
     }
   }
 
-  if(t != -1)
-  {
-      mutt_addrlist_to_local (AliasTable[t]->addr);
+  if (t != -1) {
+    mutt_addrlist_to_local (AliasTable[t]->addr);
     rfc822_write_address (buf, buflen, AliasTable[t]->addr, 0);
   }
 
   mutt_menuDestroy (&menu);
   FREE (&AliasTable);
-  
+
 }
diff --git a/alias.c b/alias.c
index 5d83357..e664784 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -35,76 +35,71 @@ ADDRESS *mutt_lookup_alias (const char *s)
   for (; t; t = t->next)
     if (!mutt_strcasecmp (s, t->name))
       return (t->addr);
-  return (NULL);   /* no such alias */
+  return (NULL);                /* no such alias */
 }
 
-static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
+static ADDRESS *mutt_expand_aliases_r (ADDRESS * a, LIST ** expn)
 {
   ADDRESS *head = NULL, *last = NULL, *t, *w;
   LIST *u;
   char i;
   const char *fqdn;
-  
-  while (a)
-  {
-    if (!a->group && !a->personal && a->mailbox && strchr (a->mailbox, '@') == NULL)
-    {
+
+  while (a) {
+    if (!a->group && !a->personal && a->mailbox
+        && strchr (a->mailbox, '@') == NULL) {
       t = mutt_lookup_alias (a->mailbox);
 
-      if (t)
-      {        
+      if (t) {
         i = 0;
-        for (u = *expn; u; u = u->next)
-       {
-         if (mutt_strcmp (a->mailbox, u->data) == 0) /* alias already found */
-         {
-           dprint (1, (debugfile, "mutt_expand_aliases_r(): loop in alias found for '%s'\n", a->mailbox));
-           i = 1;
-           break;
-         }
-       }
-
-        if (!i)
-       {
+        for (u = *expn; u; u = u->next) {
+          if (mutt_strcmp (a->mailbox, u->data) == 0) { /* alias already found */
+            dprint (1,
+                    (debugfile,
+                     "mutt_expand_aliases_r(): loop in alias found for '%s'\n",
+                     a->mailbox));
+            i = 1;
+            break;
+          }
+        }
+
+        if (!i) {
           u = safe_malloc (sizeof (LIST));
           u->data = safe_strdup (a->mailbox);
           u->next = *expn;
           *expn = u;
-         w = rfc822_cpy_adr (t);
-         w = mutt_expand_aliases_r (w, expn);
-         if (head)
-           last->next = w;
-         else
-           head = last = w;
-         while (last && last->next)
-           last = last->next;
+          w = rfc822_cpy_adr (t);
+          w = mutt_expand_aliases_r (w, expn);
+          if (head)
+            last->next = w;
+          else
+            head = last = w;
+          while (last && last->next)
+            last = last->next;
         }
-       t = a;
-       a = a->next;
-       t->next = NULL;
-       rfc822_free_address (&t);
-       continue;
+        t = a;
+        a = a->next;
+        t->next = NULL;
+        rfc822_free_address (&t);
+        continue;
       }
-      else
-      {
-       struct passwd *pw = getpwnam (a->mailbox);
-
-       if (pw)
-       {
-         char namebuf[STRING];
-         
-         mutt_gecos_name (namebuf, sizeof (namebuf), pw);
-         mutt_str_replace (&a->personal, namebuf);
-         
+      else {
+        struct passwd *pw = getpwnam (a->mailbox);
+
+        if (pw) {
+          char namebuf[STRING];
+
+          mutt_gecos_name (namebuf, sizeof (namebuf), pw);
+          mutt_str_replace (&a->personal, namebuf);
+
 #ifdef EXACT_ADDRESS
-         FREE (&a->val);
+          FREE (&a->val);
 #endif
-       }
+        }
       }
     }
 
-    if (head)
-    {
+    if (head) {
       last->next = a;
       last = last->next;
     }
@@ -114,8 +109,7 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
     last->next = NULL;
   }
 
-  if (option (OPTUSEDOMAIN) && (fqdn = mutt_fqdn(1)))
-  {
+  if (option (OPTUSEDOMAIN) && (fqdn = mutt_fqdn (1))) {
     /* now qualify all local addresses */
     rfc822_qualify (head, fqdn);
   }
@@ -123,17 +117,17 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
   return (head);
 }
 
-ADDRESS *mutt_expand_aliases (ADDRESS *a)
+ADDRESS *mutt_expand_aliases (ADDRESS * a)
 {
   ADDRESS *t;
-  LIST *expn = NULL; /* previously expanded aliases to avoid loops */
+  LIST *expn = NULL;            /* previously expanded aliases to avoid loops */
 
   t = mutt_expand_aliases_r (a, &expn);
   mutt_free_list (&expn);
   return (mutt_remove_duplicates (t));
 }
 
-void mutt_expand_aliases_env (ENVELOPE *env)
+void mutt_expand_aliases_env (ENVELOPE * env)
 {
   env->from = mutt_expand_aliases (env->from);
   env->to = mutt_expand_aliases (env->to);
@@ -165,53 +159,47 @@ void mutt_expand_aliases_env (ENVELOPE *env)
  * variable.
  */
 
-static void write_safe_address (FILE *fp, char *s)
+static void write_safe_address (FILE * fp, char *s)
 {
-  while (*s)
-  {
-    if (*s == '\\' || *s == '`' || *s == '\'' || *s == '"'
-       || *s == '$')
+  while (*s) {
+    if (*s == '\\' || *s == '`' || *s == '\'' || *s == '"' || *s == '$')
       fputc ('\\', fp);
     fputc (*s, fp);
     s++;
   }
 }
 
-ADDRESS *mutt_get_address (ENVELOPE *env, char **pfxp)
+ADDRESS *mutt_get_address (ENVELOPE * env, char **pfxp)
 {
   ADDRESS *adr;
   char *pfx = NULL;
 
-  if (mutt_addr_is_user (env->from))
-  {
-    if (env->to && !mutt_is_mail_list (env->to))
-    {
+  if (mutt_addr_is_user (env->from)) {
+    if (env->to && !mutt_is_mail_list (env->to)) {
       pfx = "To";
       adr = env->to;
     }
-    else
-    {
+    else {
       pfx = "Cc";
       adr = env->cc;
     }
   }
-  else if (env->reply_to && !mutt_is_mail_list (env->reply_to))
-  {
+  else if (env->reply_to && !mutt_is_mail_list (env->reply_to)) {
     pfx = "Reply-To";
     adr = env->reply_to;
   }
-  else
-  {
+  else {
     adr = env->from;
     pfx = "From";
   }
 
-  if (pfxp) *pfxp = pfx;
+  if (pfxp)
+    *pfxp = pfx;
 
   return adr;
 }
 
-void mutt_create_alias (ENVELOPE *cur, ADDRESS *iadr)
+void mutt_create_alias (ENVELOPE * cur, ADDRESS * iadr)
 {
   ALIAS *new, *t;
   char buf[LONG_STRING], prompt[SHORT_STRING], *pc;
@@ -220,17 +208,14 @@ void mutt_create_alias (ENVELOPE *cur, ADDRESS *iadr)
   FILE *rc;
   ADDRESS *adr = NULL;
 
-  if (cur)
-  {
+  if (cur) {
     adr = mutt_get_address (cur, NULL);
   }
-  else if (iadr)
-  {
+  else if (iadr) {
     adr = iadr;
   }
 
-  if (adr && adr->mailbox)
-  {
+  if (adr && adr->mailbox) {
     strfcpy (buf, adr->mailbox, sizeof (buf));
     if ((pc = strchr (buf, '@')))
       *pc = 0;
@@ -240,70 +225,65 @@ void mutt_create_alias (ENVELOPE *cur, ADDRESS *iadr)
 
   /* Don't suggest a bad alias name in the event of a strange local part. */
   mutt_check_alias_name (buf, buf);
-  
+
 retry_name:
   /* add a new alias */
   if (mutt_get_field (_("Alias as: "), buf, sizeof (buf), 0) != 0 || !buf[0])
     return;
 
   /* check to see if the user already has an alias defined */
-  if (mutt_lookup_alias (buf))
-  {
+  if (mutt_lookup_alias (buf)) {
     mutt_error _("You already have an alias defined with that name!");
+
     return;
   }
-  
-  if (mutt_check_alias_name (buf, fixed))
-  {
-    switch (mutt_yesorno (_("Warning: This alias name may not work.  Fix it?"), M_YES))
-    {
-      case M_YES:
-       strfcpy (buf, fixed, sizeof (buf));
-       goto retry_name;
-      case -1: 
-       return;
+
+  if (mutt_check_alias_name (buf, fixed)) {
+    switch (mutt_yesorno
+            (_("Warning: This alias name may not work.  Fix it?"), M_YES)) {
+    case M_YES:
+      strfcpy (buf, fixed, sizeof (buf));
+      goto retry_name;
+    case -1:
+      return;
     }
   }
-  
-  new       = safe_calloc (1, sizeof (ALIAS));
+
+  new = safe_calloc (1, sizeof (ALIAS));
   new->self = new;
   new->name = safe_strdup (buf);
 
   mutt_addrlist_to_local (adr);
-  
+
   if (adr)
     strfcpy (buf, adr->mailbox, sizeof (buf));
   else
     buf[0] = 0;
 
   mutt_addrlist_to_idna (adr, NULL);
-  
-  do
-  {
-    if (mutt_get_field (_("Address: "), buf, sizeof (buf), 0) != 0 || !buf[0])
-    {
+
+  do {
+    if (mutt_get_field (_("Address: "), buf, sizeof (buf), 0) != 0 || !buf[0]) {
       mutt_free_alias (&new);
       return;
     }
-    
-    if((new->addr = rfc822_parse_adrlist (new->addr, buf)) == NULL)
+
+    if ((new->addr = rfc822_parse_adrlist (new->addr, buf)) == NULL)
       BEEP ();
-    if (mutt_addrlist_to_idna (new->addr, &err))
-    {
+    if (mutt_addrlist_to_idna (new->addr, &err)) {
       mutt_error (_("Error: '%s' is a bad IDN."), err);
       mutt_sleep (2);
       continue;
     }
   }
-  while(new->addr == NULL);
-  
+  while (new->addr == NULL);
+
   if (adr && adr->personal && !mutt_is_mail_list (adr))
     strfcpy (buf, adr->personal, sizeof (buf));
   else
     buf[0] = 0;
 
-  if (mutt_get_field (_("Personal name: "), buf, sizeof (buf), 0) != 0)
-  {
+  if (mutt_get_field (_("Personal name: "), buf, sizeof (buf), 0) != 0) {
     mutt_free_alias (&new);
     return;
   }
@@ -312,14 +292,12 @@ retry_name:
   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, M_YES) != M_YES) {
     mutt_free_alias (&new);
     return;
   }
 
-  if ((t = Aliases))
-  {
+  if ((t = Aliases)) {
     while (t->next)
       t = t->next;
     t->next = new;
@@ -331,8 +309,7 @@ retry_name:
   if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), M_FILE) != 0)
     return;
   mutt_expand_path (buf, sizeof (buf));
-  if ((rc = safe_fopen (buf, "a")))
-  {
+  if ((rc = safe_fopen (buf, "a"))) {
     if (mutt_check_alias_name (new->name, NULL))
       mutt_quote_filename (buf, sizeof (buf), new->name);
     else
@@ -357,22 +334,20 @@ retry_name:
 static int check_alias_name_char (char c)
 {
   return (c == '-' || c == '_' || c == '+' || c == '=' || c == '.' ||
-         isalnum ((unsigned char) c));
+          isalnum ((unsigned char) c));
 }
 
 int mutt_check_alias_name (const char *s, char *d)
 {
   int rv = 0;
-  for (; *s; s++) 
-  {
-    if (!check_alias_name_char (*s))
-    {
+
+  for (; *s; s++) {
+    if (!check_alias_name_char (*s)) {
       if (!d)
-       return -1;
-      else
-      {
-       *d++ = '_';
-       rv = -1;
+        return -1;
+      else {
+        *d++ = '_';
+        rv = -1;
       }
     }
     else if (d)
@@ -387,7 +362,7 @@ int mutt_check_alias_name (const char *s, char *d)
  * This routine looks to see if the user has an alias defined for the given
  * address.
  */
-ADDRESS *alias_reverse_lookup (ADDRESS *a)
+ADDRESS *alias_reverse_lookup (ADDRESS * a)
 {
   ALIAS *t = Aliases;
   ADDRESS *ap;
@@ -395,14 +370,12 @@ ADDRESS *alias_reverse_lookup (ADDRESS *a)
   if (!a || !a->mailbox)
     return NULL;
 
-  for (; t; t = t->next)
-  {
+  for (; t; t = t->next) {
     /* cycle through all addresses if this is a group alias */
-    for (ap = t->addr; ap; ap = ap->next)
-    {
+    for (ap = t->addr; ap; ap = ap->next) {
       if (!ap->group && ap->mailbox &&
-         ascii_strcasecmp (ap->mailbox, a->mailbox) == 0)
-       return ap;
+          ascii_strcasecmp (ap->mailbox, a->mailbox) == 0)
+        return ap;
     }
   }
   return 0;
@@ -423,66 +396,55 @@ int mutt_alias_complete (char *s, size_t buflen)
 
 #define min(a,b)        ((a<b)?a:b)
 
-  if (s[0] != 0) /* avoid empty string as strstr argument */
-  {
+  if (s[0] != 0) {              /* avoid empty string as strstr argument */
     memset (bestname, 0, sizeof (bestname));
 
-    while (a)
-    {
-      if (a->name && strstr (a->name, s) == a->name)
-      {
-       if (!bestname[0]) /* init */
-         strfcpy (bestname, a->name,
-                  min (mutt_strlen (a->name) + 1, sizeof (bestname)));
-       else
-       {
-         for (i = 0 ; a->name[i] && a->name[i] == bestname[i] ; i++)
-           ;
-         bestname[i] = 0;
-       }
+    while (a) {
+      if (a->name && strstr (a->name, s) == a->name) {
+        if (!bestname[0])       /* init */
+          strfcpy (bestname, a->name,
+                   min (mutt_strlen (a->name) + 1, sizeof (bestname)));
+        else {
+          for (i = 0; a->name[i] && a->name[i] == bestname[i]; i++);
+          bestname[i] = 0;
+        }
       }
       a = a->next;
     }
 
-    if (bestname[0] != 0)
-    {
-      if (mutt_strcmp (bestname, s) != 0)
-      {
-       /* we are adding something to the completion */
-       strfcpy (s, bestname, mutt_strlen (bestname) + 1);
-       return 1;
+    if (bestname[0] != 0) {
+      if (mutt_strcmp (bestname, s) != 0) {
+        /* we are adding something to the completion */
+        strfcpy (s, bestname, mutt_strlen (bestname) + 1);
+        return 1;
       }
 
       /* build alias list and show it */
 
       a = Aliases;
-      while (a)
-      {
-       if (a->name && (strstr (a->name, s) == a->name))
-       {
-         if (!a_list)  /* init */
-           a_cur = a_list = (ALIAS *) safe_malloc (sizeof (ALIAS));
-         else
-         {
-           a_cur->next = (ALIAS *) safe_malloc (sizeof (ALIAS));
-           a_cur = a_cur->next;
-         }
-         memcpy (a_cur, a, sizeof (ALIAS));
-         a_cur->next = NULL;
-       }
-       a = a->next;
+      while (a) {
+        if (a->name && (strstr (a->name, s) == a->name)) {
+          if (!a_list)          /* init */
+            a_cur = a_list = (ALIAS *) safe_malloc (sizeof (ALIAS));
+          else {
+            a_cur->next = (ALIAS *) safe_malloc (sizeof (ALIAS));
+            a_cur = a_cur->next;
+          }
+          memcpy (a_cur, a, sizeof (ALIAS));
+          a_cur->next = NULL;
+        }
+        a = a->next;
       }
     }
   }
 
   bestname[0] = 0;
-  mutt_alias_menu (bestname, sizeof(bestname), a_list ? a_list : Aliases);
+  mutt_alias_menu (bestname, sizeof (bestname), a_list ? a_list : Aliases);
   if (bestname[0] != 0)
     strfcpy (s, bestname, buflen);
 
   /* free the alias list */
-  while (a_list)
-  {
+  while (a_list) {
     a_cur = a_list;
     a_list = a_list->next;
     FREE (&a_cur);
@@ -490,95 +452,99 @@ int mutt_alias_complete (char *s, size_t buflen)
 
   /* remove any aliases marked for deletion */
   a_list = NULL;
-  for (a_cur = Aliases; a_cur;)
-  {
-    if (a_cur->del)
-    {
+  for (a_cur = Aliases; a_cur;) {
+    if (a_cur->del) {
       if (a_list)
-       a_list->next = a_cur->next;
+        a_list->next = a_cur->next;
       else
-       Aliases = a_cur->next;
-      
+        Aliases = a_cur->next;
+
       a_cur->next = NULL;
       mutt_free_alias (&a_cur);
-      
+
       if (a_list)
-       a_cur = a_list;
+        a_cur = a_list;
       else
-       a_cur = Aliases;
+        a_cur = Aliases;
     }
-    else
-    {
+    else {
       a_list = a_cur;
-      a_cur  = a_cur->next;
+      a_cur = a_cur->next;
     }
   }
-  
+
   return 0;
 }
 
-static int string_is_address(const char *str, const char *u, const char *d)
+static int string_is_address (const char *str, const char *u, const char *d)
 {
   char buf[LONG_STRING];
-  
-  snprintf(buf, sizeof(buf), "%s@%s", NONULL(u), NONULL(d));
-  if (ascii_strcasecmp(str, buf) == 0)
+
+  snprintf (buf, sizeof (buf), "%s@%s", NONULL (u), NONULL (d));
+  if (ascii_strcasecmp (str, buf) == 0)
     return 1;
-  
+
   return 0;
 }
 
 /* returns TRUE if the given address belongs to the user. */
-int mutt_addr_is_user (ADDRESS *addr)
+int mutt_addr_is_user (ADDRESS * addr)
 {
   /* NULL address is assumed to be the user. */
-  if (!addr)
-  {
+  if (!addr) {
     dprint (5, (debugfile, "mail_addr_is_user: yes, NULL address\n"));
     return 1;
   }
-  if (!addr->mailbox)
-  {
+  if (!addr->mailbox) {
     dprint (5, (debugfile, "mail_addr_is_user: no, no mailbox\n"));
     return 0;
   }
 
-  if (ascii_strcasecmp (addr->mailbox, Username) == 0)
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox, Username));
+  if (ascii_strcasecmp (addr->mailbox, Username) == 0) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox,
+             Username));
     return 1;
   }
-  if (string_is_address(addr->mailbox, Username, Hostname))
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n", addr->mailbox, Username, Hostname));
+  if (string_is_address (addr->mailbox, Username, Hostname)) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
+             addr->mailbox, Username, Hostname));
     return 1;
   }
-  if (string_is_address(addr->mailbox, Username, mutt_fqdn(0)))
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (0)));
+  if (string_is_address (addr->mailbox, Username, mutt_fqdn (0))) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
+             addr->mailbox, Username, mutt_fqdn (0)));
     return 1;
   }
-  if (string_is_address(addr->mailbox, Username, mutt_fqdn(1)))
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (1)));
+  if (string_is_address (addr->mailbox, Username, mutt_fqdn (1))) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
+             addr->mailbox, Username, mutt_fqdn (1)));
     return 1;
   }
 
-  if (From && !ascii_strcasecmp (From->mailbox, addr->mailbox))
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox, From->mailbox));
+  if (From && !ascii_strcasecmp (From->mailbox, addr->mailbox)) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox,
+             From->mailbox));
     return 1;
   }
 
-  if (mutt_match_rx_list (addr->mailbox, Alternates))
-  {
-    dprint (5, (debugfile, "mail_addr_is_user: yes, %s matched by alternates.\n", addr->mailbox));
+  if (mutt_match_rx_list (addr->mailbox, Alternates)) {
+    dprint (5,
+            (debugfile, "mail_addr_is_user: yes, %s matched by alternates.\n",
+             addr->mailbox));
     if (mutt_match_rx_list (addr->mailbox, UnAlternates))
-      dprint (5, (debugfile, "mail_addr_is_user: but, %s matched by unalternates.\n", addr->mailbox));
+      dprint (5,
+              (debugfile,
+               "mail_addr_is_user: but, %s matched by unalternates.\n",
+               addr->mailbox));
     else
       return 1;
   }
-  
+
   dprint (5, (debugfile, "mail_addr_is_user: no, all failed.\n"));
   return 0;
 }
diff --git a/ascii.c b/ascii.c
index 27f3a86..e588f61 100644 (file)
--- a/ascii.c
+++ b/ascii.c
@@ -48,7 +48,7 @@ int ascii_toupper (int c)
 {
   if (ascii_islower (c))
     return c & ~32;
-  
+
   return c;
 }
 
@@ -56,46 +56,44 @@ int ascii_tolower (int c)
 {
   if (ascii_isupper (c))
     return c | 32;
-  
+
   return c;
 }
 
 int ascii_strcasecmp (const char *a, const char *b)
 {
   int i;
-  
+
   if (a == b)
     return 0;
   if (a == NULL && b)
     return -1;
   if (b == NULL && a)
     return 1;
-  
-  for (; *a || *b; a++, b++)
-  {
+
+  for (; *a || *b; a++, b++) {
     if ((i = ascii_tolower (*a) - ascii_tolower (*b)))
       return i;
   }
-  
+
   return 0;
 }
 
 int ascii_strncasecmp (const char *a, const char *b, int n)
 {
   int i, j;
-  
+
   if (a == b)
     return 0;
   if (a == NULL && b)
     return -1;
   if (b == NULL && a)
     return 1;
-  
-  for (j = 0; (*a || *b) && j < n; a++, b++, j++)
-  {
+
+  for (j = 0; (*a || *b) && j < n; a++, b++, j++) {
     if ((i = ascii_tolower (*a) - ascii_tolower (*b)))
       return i;
   }
-  
+
   return 0;
 }
index 102329d..ca06827 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <string.h>
 #include <errno.h>
 
-int mutt_get_tmp_attachment (BODY *a)
+int mutt_get_tmp_attachment (BODY * a)
 {
   char type[STRING];
   char tempfile[_POSIX_PATH_MAX];
-  rfc1524_entry *entry = rfc1524_new_entry();
+  rfc1524_entry *entry = rfc1524_new_entry ();
   FILE *fpin = NULL, *fpout = NULL;
   struct stat st;
-  
-  if(a->unlink)
+
+  if (a->unlink)
     return 0;
 
-  snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype);
-  rfc1524_mailcap_lookup(a, type, entry, 0);
-  rfc1524_expand_filename(entry->nametemplate, a->filename, 
-                         tempfile, sizeof(tempfile));
-  
-  rfc1524_free_entry(&entry);
+  snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
+  rfc1524_mailcap_lookup (a, type, entry, 0);
+  rfc1524_expand_filename (entry->nametemplate, a->filename,
+                           tempfile, sizeof (tempfile));
+
+  rfc1524_free_entry (&entry);
 
-  if(stat(a->filename, &st) == -1)
+  if (stat (a->filename, &st) == -1)
     return -1;
 
-  if((fpin = fopen(a->filename, "r")) && (fpout = safe_fopen(tempfile, "w")))  /* __FOPEN_CHECKED__ */
-  {
+  if ((fpin = fopen (a->filename, "r")) && (fpout = safe_fopen (tempfile, "w"))) {      /* __FOPEN_CHECKED__ */
     mutt_copy_stream (fpin, fpout);
     mutt_str_replace (&a->filename, tempfile);
     a->unlink = 1;
 
-    if(a->stamp >= st.st_mtime)
-      mutt_stamp_attachment(a);
+    if (a->stamp >= st.st_mtime)
+      mutt_stamp_attachment (a);
   }
   else
-    mutt_perror(fpin ? tempfile : a->filename);
-  
-  if(fpin)  fclose(fpin);
-  if(fpout) fclose(fpout);
-  
+    mutt_perror (fpin ? tempfile : a->filename);
+
+  if (fpin)
+    fclose (fpin);
+  if (fpout)
+    fclose (fpout);
+
   return a->unlink ? 0 : -1;
 }
 
 
 /* return 1 if require full screen redraw, 0 otherwise */
-int mutt_compose_attachment (BODY *a)
+int mutt_compose_attachment (BODY * a)
 {
   char type[STRING];
   char command[STRING];
@@ -91,119 +92,109 @@ int mutt_compose_attachment (BODY *a)
   rfc1524_entry *entry = rfc1524_new_entry ();
   short unlink_newfile = 0;
   int rc = 0;
-  
+
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
-  if (rfc1524_mailcap_lookup (a, type, entry, M_COMPOSE))
-  {
-    if (entry->composecommand || entry->composetypecommand)
-    {
+  if (rfc1524_mailcap_lookup (a, type, entry, M_COMPOSE)) {
+    if (entry->composecommand || entry->composetypecommand) {
 
       if (entry->composetypecommand)
-       strfcpy (command, entry->composetypecommand, sizeof (command));
-      else 
-       strfcpy (command, entry->composecommand, sizeof (command));
+        strfcpy (command, entry->composetypecommand, sizeof (command));
+      else
+        strfcpy (command, entry->composecommand, sizeof (command));
       if (rfc1524_expand_filename (entry->nametemplate,
-                                     a->filename, newfile, sizeof (newfile)))
-      {
-       dprint(1, (debugfile, "oldfile: %s\t newfile: %s\n",
-                                 a->filename, newfile));
-       if (safe_symlink (a->filename, newfile) == -1)
-       {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != M_YES)
-           goto bailout;
-       }
-       else
-         unlink_newfile = 1;
+                                   a->filename, newfile, sizeof (newfile))) {
+        dprint (1, (debugfile, "oldfile: %s\t newfile: %s\n",
+                    a->filename, newfile));
+        if (safe_symlink (a->filename, newfile) == -1) {
+          if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
+              != M_YES)
+            goto bailout;
+        }
+        else
+          unlink_newfile = 1;
       }
       else
-       strfcpy(newfile, a->filename, sizeof(newfile));
-      
+        strfcpy (newfile, a->filename, sizeof (newfile));
+
       if (rfc1524_expand_command (a, newfile, type,
-                                     command, sizeof (command)))
-      {
-       /* For now, editing requires a file, no piping */
-       mutt_error _("Mailcap compose entry requires %%s");
+                                  command, sizeof (command))) {
+        /* For now, editing requires a file, no piping */
+        mutt_error _("Mailcap compose entry requires %%s");
       }
-      else
-      {
-       int r;
-
-       mutt_endwin (NULL);
-       if ((r = mutt_system (command)) == -1)
-         mutt_error (_("Error running \"%s\"!"), command);
-       
-       if (r != -1 && entry->composetypecommand)
-       {
-         BODY *b;
-         FILE *fp, *tfp;
-         char tempfile[_POSIX_PATH_MAX];
-
-         if ((fp = safe_fopen (a->filename, "r")) == NULL)
-         {
-           mutt_perror _("Failure to open file to parse headers.");
-           goto bailout;
-         }
-
-         b = mutt_read_mime_header (fp, 0);
-         if (b)
-         {
-           if (b->parameter)
-           {
-             mutt_free_parameter (&a->parameter);
-             a->parameter = b->parameter;
-             b->parameter = NULL;
-           }
-           if (b->description) {
-             FREE (&a->description);
-             a->description = b->description;
-             b->description = NULL;
-           }
-           if (b->form_name)
-           {
-             FREE (&a->form_name);
-             a->form_name = b->form_name;
-             b->form_name = NULL;
-           }
-
-           /* Remove headers by copying out data to another file, then 
-            * copying the file back */
-           fseek (fp, b->offset, 0);
-           mutt_mktemp (tempfile);
-           if ((tfp = safe_fopen (tempfile, "w")) == NULL)
-           {
-             mutt_perror _("Failure to open file to strip headers.");
-             goto bailout;
-           }
-           mutt_copy_stream (fp, tfp);
-           fclose (fp);
-           fclose (tfp);
-           mutt_unlink (a->filename);  
-           if (mutt_rename_file (tempfile, a->filename) != 0) 
-           {
-             mutt_perror _("Failure to rename file.");
-             goto bailout;
-           }
-
-           mutt_free_body (&b);
-         }
-       }
+      else {
+        int r;
+
+        mutt_endwin (NULL);
+        if ((r = mutt_system (command)) == -1)
+          mutt_error (_("Error running \"%s\"!"), command);
+
+        if (r != -1 && entry->composetypecommand) {
+          BODY *b;
+          FILE *fp, *tfp;
+          char tempfile[_POSIX_PATH_MAX];
+
+          if ((fp = safe_fopen (a->filename, "r")) == NULL) {
+            mutt_perror _("Failure to open file to parse headers.");
+
+            goto bailout;
+          }
+
+          b = mutt_read_mime_header (fp, 0);
+          if (b) {
+            if (b->parameter) {
+              mutt_free_parameter (&a->parameter);
+              a->parameter = b->parameter;
+              b->parameter = NULL;
+            }
+            if (b->description) {
+              FREE (&a->description);
+              a->description = b->description;
+              b->description = NULL;
+            }
+            if (b->form_name) {
+              FREE (&a->form_name);
+              a->form_name = b->form_name;
+              b->form_name = NULL;
+            }
+
+            /* Remove headers by copying out data to another file, then 
+             * copying the file back */
+            fseek (fp, b->offset, 0);
+            mutt_mktemp (tempfile);
+            if ((tfp = safe_fopen (tempfile, "w")) == NULL) {
+              mutt_perror _("Failure to open file to strip headers.");
+
+              goto bailout;
+            }
+            mutt_copy_stream (fp, tfp);
+            fclose (fp);
+            fclose (tfp);
+            mutt_unlink (a->filename);
+            if (mutt_rename_file (tempfile, a->filename) != 0) {
+              mutt_perror _("Failure to rename file.");
+
+              goto bailout;
+            }
+
+            mutt_free_body (&b);
+          }
+        }
       }
     }
   }
-  else
-  {
+  else {
     rfc1524_free_entry (&entry);
     mutt_message (_("No mailcap compose entry for %s, creating empty file."),
-                  type);
+                  type);
     return 1;
   }
 
   rc = 1;
-  
-  bailout:
-  
-  if(unlink_newfile)
-    unlink(newfile);
+
+bailout:
+
+  if (unlink_newfile)
+    unlink (newfile);
 
   rfc1524_free_entry (&entry);
   return rc;
@@ -218,7 +209,7 @@ int mutt_compose_attachment (BODY *a)
  * Returns 1 if editor found, 0 if not (useful to tell calling menu to
  * redraw)
  */
-int mutt_edit_attachment (BODY *a)
+int mutt_edit_attachment (BODY * a)
 {
   char type[STRING];
   char command[STRING];
@@ -226,63 +217,56 @@ int mutt_edit_attachment (BODY *a)
   rfc1524_entry *entry = rfc1524_new_entry ();
   short unlink_newfile = 0;
   int rc = 0;
-  
+
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
-  if (rfc1524_mailcap_lookup (a, type, entry, M_EDIT))
-  {
-    if (entry->editcommand)
-    {
+  if (rfc1524_mailcap_lookup (a, type, entry, M_EDIT)) {
+    if (entry->editcommand) {
 
       strfcpy (command, entry->editcommand, sizeof (command));
       if (rfc1524_expand_filename (entry->nametemplate,
-                                     a->filename, newfile, sizeof (newfile)))
-      {
-       dprint(1, (debugfile, "oldfile: %s\t newfile: %s\n",
-                                 a->filename, newfile));
-       if (safe_symlink (a->filename, newfile) == -1)
-       {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != M_YES)
-           goto bailout;
-       }
-       else
-         unlink_newfile = 1;
+                                   a->filename, newfile, sizeof (newfile))) {
+        dprint (1, (debugfile, "oldfile: %s\t newfile: %s\n",
+                    a->filename, newfile));
+        if (safe_symlink (a->filename, newfile) == -1) {
+          if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
+              != M_YES)
+            goto bailout;
+        }
+        else
+          unlink_newfile = 1;
       }
       else
-       strfcpy(newfile, a->filename, sizeof(newfile));
+        strfcpy (newfile, a->filename, sizeof (newfile));
 
       if (rfc1524_expand_command (a, newfile, type,
-                                     command, sizeof (command)))
-      {
-       /* For now, editing requires a file, no piping */
-       mutt_error _("Mailcap Edit entry requires %%s");
+                                  command, sizeof (command))) {
+        /* For now, editing requires a file, no piping */
+        mutt_error _("Mailcap Edit entry requires %%s");
       }
-      else
-      {
-       mutt_endwin (NULL);
-       if (mutt_system (command) == -1)
-         mutt_error (_("Error running \"%s\"!"), command);
+      else {
+        mutt_endwin (NULL);
+        if (mutt_system (command) == -1)
+          mutt_error (_("Error running \"%s\"!"), command);
       }
     }
   }
-  else if (a->type == TYPETEXT)
-  {
+  else if (a->type == TYPETEXT) {
     /* On text, default to editor */
     mutt_edit_file (NONULL (Editor), newfile);
   }
-  else
-  {
+  else {
     rfc1524_free_entry (&entry);
-    mutt_error (_("No mailcap edit entry for %s"),type);
+    mutt_error (_("No mailcap edit entry for %s"), type);
     return 0;
   }
 
   rc = 1;
-  
-  bailout:
-  
-  if(unlink_newfile)
-    unlink(newfile);
-  
+
+bailout:
+
+  if (unlink_newfile)
+    unlink (newfile);
+
   rfc1524_free_entry (&entry);
   return rc;
 }
@@ -294,34 +278,28 @@ static int is_mmnoask (const char *buf)
   char tmp[LONG_STRING], *p, *q;
   int lng;
 
-  if ((p = getenv ("MM_NOASK")) != NULL && *p)
-  {
+  if ((p = getenv ("MM_NOASK")) != NULL && *p) {
     if (mutt_strcmp (p, "1") == 0)
       return (1);
 
     strfcpy (tmp, p, sizeof (tmp));
     p = tmp;
 
-    while ((p = strtok (p, ",")) != NULL)
-    {
-      if ((q = strrchr (p, '/')) != NULL)
-      {
-       if (*(q+1) == '*')
-       {
-         if (ascii_strncasecmp (buf, p, q-p) == 0)
-           return (1);
-       }
-       else
-       {
-         if (ascii_strcasecmp (buf, p) == 0)
-           return (1);
-       }
+    while ((p = strtok (p, ",")) != NULL) {
+      if ((q = strrchr (p, '/')) != NULL) {
+        if (*(q + 1) == '*') {
+          if (ascii_strncasecmp (buf, p, q - p) == 0)
+            return (1);
+        }
+        else {
+          if (ascii_strcasecmp (buf, p) == 0)
+            return (1);
+        }
       }
-      else
-      {
-       lng = mutt_strlen (p);
-       if (buf[lng] == '/' && mutt_strncasecmp (buf, p, lng) == 0)
-         return (1);
+      else {
+        lng = mutt_strlen (p);
+        if (buf[lng] == '/' && mutt_strncasecmp (buf, p, lng) == 0)
+          return (1);
       }
 
       p = NULL;
@@ -331,42 +309,42 @@ static int is_mmnoask (const char *buf)
   return (0);
 }
 
-void mutt_check_lookup_list (BODY *b, char *type, int len)
+void mutt_check_lookup_list (BODY * b, char *type, int len)
 {
   LIST *t = MimeLookupList;
   int i;
 
   for (; t; t = t->next) {
     i = mutt_strlen (t->data) - 1;
-    if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && 
-        ascii_strncasecmp (type, t->data, i) == 0) ||
-       ascii_strcasecmp (type, t->data) == 0) {
-
-    BODY tmp = {0};
-    int n;
-    if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) {
-      snprintf (type, len, "%s/%s",
-                n == TYPEAUDIO ? "audio" :
-                n == TYPEAPPLICATION ? "application" :
-                n == TYPEIMAGE ? "image" :
-                n == TYPEMESSAGE ? "message" :
-                n == TYPEMODEL ? "model" :
-                n == TYPEMULTIPART ? "multipart" :
-                n == TYPETEXT ? "text" :
-                n == TYPEVIDEO ? "video" : "other",
-                tmp.subtype);
-      dprint(1, (debugfile, "mutt_check_lookup_list: \"%s\" -> %s\n", 
-        b->filename, type));
-    }
-    if (tmp.subtype) 
-      FREE (&tmp.subtype);
-    if (tmp.xtype) 
-      FREE (&tmp.xtype);
+    if ((i > 0 && t->data[i - 1] == '/' && t->data[i] == '*' &&
+         ascii_strncasecmp (type, t->data, i) == 0) ||
+        ascii_strcasecmp (type, t->data) == 0) {
+
+      BODY tmp = { 0 };
+      int n;
+
+      if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) {
+        snprintf (type, len, "%s/%s",
+                  n == TYPEAUDIO ? "audio" :
+                  n == TYPEAPPLICATION ? "application" :
+                  n == TYPEIMAGE ? "image" :
+                  n == TYPEMESSAGE ? "message" :
+                  n == TYPEMODEL ? "model" :
+                  n == TYPEMULTIPART ? "multipart" :
+                  n == TYPETEXT ? "text" :
+                  n == TYPEVIDEO ? "video" : "other", tmp.subtype);
+        dprint (1, (debugfile, "mutt_check_lookup_list: \"%s\" -> %s\n",
+                    b->filename, type));
+      }
+      if (tmp.subtype)
+        FREE (&tmp.subtype);
+      if (tmp.xtype)
+        FREE (&tmp.xtype);
     }
   }
 }
 
-int mutt_is_autoview (BODY *b, const char *type)
+int mutt_is_autoview (BODY * b, const char *type)
 {
   LIST *t = AutoViewList;
   char _type[SHORT_STRING];
@@ -375,25 +353,24 @@ int mutt_is_autoview (BODY *b, const char *type)
   if (!type)
     snprintf (_type, sizeof (_type), "%s/%s", TYPE (b), b->subtype);
   else
-    strncpy (_type, type, sizeof(_type));
+    strncpy (_type, type, sizeof (_type));
 
-  mutt_check_lookup_list (b, _type, sizeof(_type));
+  mutt_check_lookup_list (b, _type, sizeof (_type));
   type = _type;
 
-  if (mutt_needs_mailcap (b))
-  {
+  if (mutt_needs_mailcap (b)) {
     if (option (OPTIMPLICITAUTOVIEW))
       return 1;
-    
+
     if (is_mmnoask (type))
       return 1;
   }
 
   for (; t; t = t->next) {
     i = mutt_strlen (t->data) - 1;
-    if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && 
-        ascii_strncasecmp (type, t->data, i) == 0) ||
-       ascii_strcasecmp (type, t->data) == 0)
+    if ((i > 0 && t->data[i - 1] == '/' && t->data[i] == '*' &&
+         ascii_strncasecmp (type, t->data, i) == 0) ||
+        ascii_strcasecmp (type, t->data) == 0)
       return 1;
   }
 
@@ -401,8 +378,8 @@ int mutt_is_autoview (BODY *b, const char *type)
 }
 
 /* returns -1 on error, 0 or the return code from mutt_do_pager() on success */
-int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
-                         ATTACHPTR **idx, short idxlen)
+int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr,
+                          ATTACHPTR ** idx, short idxlen)
 {
   char tempfile[_POSIX_PATH_MAX] = "";
   char pagerfile[_POSIX_PATH_MAX] = "";
@@ -417,44 +394,40 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
   rfc1524_entry *entry = NULL;
   int rc = -1;
   int unlink_tempfile = 0;
-  
-  is_message = mutt_is_message_type(a->type, a->subtype);
+
+  is_message = mutt_is_message_type (a->type, a->subtype);
   if (WithCrypto && is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
-      !crypt_valid_passphrase(a->hdr->security))
+      !crypt_valid_passphrase (a->hdr->security))
     return (rc);
   use_mailcap = (flag == M_MAILCAP ||
-               (flag == M_REGULAR && mutt_needs_mailcap (a)));
+                 (flag == M_REGULAR && mutt_needs_mailcap (a)));
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
-  
-  if (use_mailcap)
-  {
-    entry = rfc1524_new_entry (); 
-    if (!rfc1524_mailcap_lookup (a, type, entry, 0))
-    {
-      if (flag == M_REGULAR)
-      {
-       /* fallback to view as text */
-       rfc1524_free_entry (&entry);
-       mutt_error _("No matching mailcap entry found.  Viewing as text.");
-       flag = M_AS_TEXT;
-       use_mailcap = 0;
+
+  if (use_mailcap) {
+    entry = rfc1524_new_entry ();
+    if (!rfc1524_mailcap_lookup (a, type, entry, 0)) {
+      if (flag == M_REGULAR) {
+        /* fallback to view as text */
+        rfc1524_free_entry (&entry);
+        mutt_error _("No matching mailcap entry found.  Viewing as text.");
+
+        flag = M_AS_TEXT;
+        use_mailcap = 0;
       }
       else
-       goto return_error;
+        goto return_error;
     }
   }
-  
-  if (use_mailcap)
-  {
-    if (!entry->command)
-    {
+
+  if (use_mailcap) {
+    if (!entry->command) {
       mutt_error _("MIME type not defined.  Cannot view attachment.");
+
       goto return_error;
     }
     strfcpy (command, entry->command, sizeof (command));
-    
-    if (fp)
-    {
+
+    if (fp) {
       fname = safe_strdup (a->filename);
       mutt_sanitize_filename (fname, 1);
     }
@@ -462,151 +435,139 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
       fname = a->filename;
 
     if (rfc1524_expand_filename (entry->nametemplate, fname,
-                                tempfile, sizeof (tempfile)))
-    {
-      if (fp == NULL && mutt_strcmp(tempfile, a->filename))
-      {
-       /* 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)
-           strfcpy (tempfile, a->filename, sizeof (tempfile));
-         else
-           goto return_error;
-       }
-       else
-         unlink_tempfile = 1;
+                                 tempfile, sizeof (tempfile))) {
+      if (fp == NULL && mutt_strcmp (tempfile, a->filename)) {
+        /* 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)
+            strfcpy (tempfile, a->filename, sizeof (tempfile));
+          else
+            goto return_error;
+        }
+        else
+          unlink_tempfile = 1;
       }
     }
-    else if (fp == NULL) /* send case */
+    else if (fp == NULL)        /* send case */
       strfcpy (tempfile, a->filename, sizeof (tempfile));
-    
-    if (fp)
-    {
+
+    if (fp) {
       /* recv case: we need to save the attachment to a file */
       FREE (&fname);
       if (mutt_save_attachment (fp, a, tempfile, 0, NULL) == -1)
-       goto return_error;
+        goto return_error;
     }
 
     use_pipe = rfc1524_expand_command (a, tempfile, type,
-                                      command, sizeof (command));
+                                       command, sizeof (command));
     use_pager = entry->copiousoutput;
   }
-  
-  if (use_pager)
-  {
-    if (fp && !use_mailcap && a->filename)
-    {
+
+  if (use_pager) {
+    if (fp && !use_mailcap && a->filename) {
       /* recv case */
       strfcpy (pagerfile, a->filename, sizeof (pagerfile));
-      mutt_adv_mktemp (pagerfile, sizeof(pagerfile));
+      mutt_adv_mktemp (pagerfile, sizeof (pagerfile));
     }
     else
       mutt_mktemp (pagerfile);
   }
-    
-  if (use_mailcap)
-  {
+
+  if (use_mailcap) {
     pid_t thepid = 0;
     int tempfd = -1, pagerfd = -1;
-    
+
     if (!use_pager)
       mutt_endwin (NULL);
 
-    if (use_pager || use_pipe)
-    {
-      if (use_pager && ((pagerfd = safe_open (pagerfile, O_CREAT | O_EXCL | O_WRONLY)) == -1))
-      {
-       mutt_perror ("open");
-       goto return_error;
+    if (use_pager || use_pipe) {
+      if (use_pager
+          && ((pagerfd = safe_open (pagerfile, O_CREAT | O_EXCL | O_WRONLY))
+              == -1)) {
+        mutt_perror ("open");
+        goto return_error;
       }
-      if (use_pipe && ((tempfd = open (tempfile, 0)) == -1))
-      {
-       if(pagerfd != -1)
-         close(pagerfd);
-       mutt_perror ("open");
-       goto return_error;
+      if (use_pipe && ((tempfd = open (tempfile, 0)) == -1)) {
+        if (pagerfd != -1)
+          close (pagerfd);
+        mutt_perror ("open");
+        goto return_error;
       }
 
       if ((thepid = mutt_create_filter_fd (command, NULL, NULL, NULL,
-                                          use_pipe ? tempfd : -1, use_pager ? pagerfd : -1, -1)) == -1)
-      {
-       if(pagerfd != -1)
-         close(pagerfd);
-       
-       if(tempfd != -1)
-         close(tempfd);
-
-       mutt_error _("Cannot create filter");
-       goto return_error;
+                                           use_pipe ? tempfd : -1,
+                                           use_pager ? pagerfd : -1,
+                                           -1)) == -1) {
+        if (pagerfd != -1)
+          close (pagerfd);
+
+        if (tempfd != -1)
+          close (tempfd);
+
+        mutt_error _("Cannot create filter");
+
+        goto return_error;
       }
 
-      if (use_pager)
-      {
-       if (a->description)
-         snprintf (descrip, sizeof (descrip),
-                   "---Command: %-20.20s Description: %s",
-                   command, a->description);
-       else
-         snprintf (descrip, sizeof (descrip),
-                   "---Command: %-30.30s Attachment: %s", command, type);
+      if (use_pager) {
+        if (a->description)
+          snprintf (descrip, sizeof (descrip),
+                    "---Command: %-20.20s Description: %s",
+                    command, a->description);
+        else
+          snprintf (descrip, sizeof (descrip),
+                    "---Command: %-30.30s Attachment: %s", command, type);
       }
 
       if ((mutt_wait_filter (thepid) || (entry->needsterminal &&
-         option (OPTWAITKEY))) && !use_pager)
-       mutt_any_key_to_continue (NULL);
-      
-      close(tempfd);
-      close(pagerfd);
-      
+                                         option (OPTWAITKEY))) && !use_pager)
+        mutt_any_key_to_continue (NULL);
+
+      close (tempfd);
+      close (pagerfd);
+
     }
-    else
-    {
+    else {
       /* interactive command */
       if (mutt_system (command) ||
-         (entry->needsterminal && option (OPTWAITKEY)))
-       mutt_any_key_to_continue (NULL);
+          (entry->needsterminal && option (OPTWAITKEY)))
+        mutt_any_key_to_continue (NULL);
     }
   }
-  else
-  {
+  else {
     /* Don't use mailcap; the attachment is viewed in the pager */
 
-    if (flag == M_AS_TEXT)
-    {
+    if (flag == M_AS_TEXT) {
       /* just let me see the raw data */
       if (mutt_save_attachment (fp, a, pagerfile, 0, NULL))
-       goto return_error;
+        goto return_error;
     }
-    else
-    {
+    else {
       /* 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))
-      {
-       unset_option (OPTVIEWATTACH);
-       goto return_error;
+      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)) {
+        unset_option (OPTVIEWATTACH);
+        goto return_error;
       }
       unset_option (OPTVIEWATTACH);
     }
-    
+
     if (a->description)
       strfcpy (descrip, a->description, sizeof (descrip));
     else if (a->filename)
       snprintf (descrip, sizeof (descrip), "---Attachment: %s : %s",
-         a->filename, type);
+                a->filename, type);
     else
       snprintf (descrip, sizeof (descrip), "---Attachment: %s", type);
   }
-  
+
   /* We only reach this point if there have been no errors */
 
-  if (use_pager)
-  {
+  if (use_pager) {
     pager_t info;
-    
+
     memset (&info, 0, sizeof (info));
     info.fp = fp;
     info.bdy = a;
@@ -616,20 +577,21 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
     info.hdr = hdr;
 
     rc = mutt_do_pager (descrip, pagerfile,
-                       M_PAGER_ATTACHMENT | (is_message ? M_PAGER_MESSAGE : 0), &info);
+                        M_PAGER_ATTACHMENT | (is_message ? M_PAGER_MESSAGE :
+                                              0), &info);
     *pagerfile = '\0';
   }
   else
     rc = 0;
 
-  return_error:
-  
+return_error:
+
   if (entry)
     rfc1524_free_entry (&entry);
   if (fp && tempfile[0])
     mutt_unlink (tempfile);
   else if (unlink_tempfile)
-    unlink(tempfile);
+    unlink (tempfile);
 
   if (pagerfile[0])
     mutt_unlink (pagerfile);
@@ -638,23 +600,22 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
 }
 
 /* returns 1 on success, 0 on error */
-int mutt_pipe_attachment (FILE *fp, BODY *b, const char *path, char *outfile)
+int mutt_pipe_attachment (FILE * fp, BODY * b, const char *path,
+                          char *outfile)
 {
   pid_t thepid;
   int out = -1;
   int rv = 0;
-  
+
   if (outfile && *outfile)
-    if ((out = safe_open (outfile, O_CREAT | O_EXCL | O_WRONLY)) < 0)
-    {
+    if ((out = safe_open (outfile, O_CREAT | O_EXCL | O_WRONLY)) < 0) {
       mutt_perror ("open");
       return 0;
     }
 
   mutt_endwin (NULL);
 
-  if (fp)
-  {
+  if (fp) {
     /* recv case */
 
     STATE s;
@@ -662,33 +623,31 @@ int mutt_pipe_attachment (FILE *fp, BODY *b, const char *path, char *outfile)
     memset (&s, 0, sizeof (STATE));
 
     if (outfile && *outfile)
-      thepid = mutt_create_filter_fd (path, &s.fpout, NULL, NULL, -1, out, -1);
+      thepid =
+        mutt_create_filter_fd (path, &s.fpout, NULL, NULL, -1, out, -1);
     else
       thepid = mutt_create_filter (path, &s.fpout, NULL, NULL);
 
-    if (thepid < 0)
-    {
+    if (thepid < 0) {
       mutt_perror _("Can't create filter");
+
       goto bail;
     }
-    
+
     s.fpin = fp;
     mutt_decode_attachment (b, &s);
     safe_fclose (&s.fpout);
   }
-  else
-  {
+  else {
     /* send case */
 
     FILE *ifp, *ofp;
 
-    if ((ifp = fopen (b->filename, "r")) == NULL)
-    {
+    if ((ifp = fopen (b->filename, "r")) == NULL) {
       mutt_perror ("fopen");
-      if (outfile && *outfile)
-      {
-       close (out);
-       unlink (outfile);
+      if (outfile && *outfile) {
+        close (out);
+        unlink (outfile);
       }
       return 0;
     }
@@ -698,22 +657,22 @@ int mutt_pipe_attachment (FILE *fp, BODY *b, const char *path, char *outfile)
     else
       thepid = mutt_create_filter (path, &ofp, NULL, NULL);
 
-    if (thepid < 0)
-    {
+    if (thepid < 0) {
       mutt_perror _("Can't create filter");
+
       safe_fclose (&ifp);
       goto bail;
     }
-    
+
     mutt_copy_stream (ifp, ofp);
     safe_fclose (&ofp);
     safe_fclose (&ifp);
   }
 
   rv = 1;
-  
+
 bail:
-  
+
   if (outfile && *outfile)
     close (out);
 
@@ -728,34 +687,32 @@ bail:
   return rv;
 }
 
-static FILE *
-mutt_save_attachment_open (char *path, int flags)
+static FILE *mutt_save_attachment_open (char *path, int flags)
 {
   if (flags == M_SAVE_APPEND)
     return fopen (path, "a");
-    /* be sure not to change the following fopen to safe_fopen
-     * as safe_fopen returns w/ an error if path exists
-     */
+  /* be sure not to change the following fopen to safe_fopen
+   * as safe_fopen returns w/ an error if path exists
+   */
   if (flags == M_SAVE_OVERWRITE)
-    return fopen (path, "w");          /* __FOPEN_CHECKED__ */
-  
+    return fopen (path, "w");   /* __FOPEN_CHECKED__ */
+
   return safe_fopen (path, "w");
 }
 
 /* returns 0 on success, -1 on error */
-int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
+int mutt_save_attachment (FILE * fp, BODY * m, char *path, int flags,
+                          HEADER * hdr)
 {
-  if (fp)
-  {
-    
+  if (fp) {
+
     /* recv mode */
 
-    if(hdr &&
-       m->hdr &&
-       m->encoding != ENCBASE64 &&
-       m->encoding != ENCQUOTEDPRINTABLE &&
-       mutt_is_message_type(m->type, m->subtype))
-    {
+    if (hdr &&
+        m->hdr &&
+        m->encoding != ENCBASE64 &&
+        m->encoding != ENCQUOTEDPRINTABLE &&
+        mutt_is_message_type (m->type, m->subtype)) {
       /* message type attachments are written to mail folders. */
 
       char buf[HUGE_STRING];
@@ -764,78 +721,74 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
       MESSAGE *msg;
       int chflags = 0;
       int r = -1;
-      
+
       hn = m->hdr;
-      hn->msgno = hdr->msgno; /* required for MH/maildir */
+      hn->msgno = hdr->msgno;   /* required for MH/maildir */
       hn->read = 1;
 
       fseek (fp, m->offset, 0);
       if (fgets (buf, sizeof (buf), fp) == NULL)
-       return -1;
-      if (mx_open_mailbox(path, M_APPEND | M_QUIET, &ctx) == NULL)
-       return -1;
-      if ((msg = mx_open_new_message (&ctx, hn, is_from (buf, NULL, 0, NULL) ? 0 : M_ADD_FROM)) == NULL)
-      {
-       mx_close_mailbox(&ctx, NULL);
-       return -1;
+        return -1;
+      if (mx_open_mailbox (path, M_APPEND | M_QUIET, &ctx) == NULL)
+        return -1;
+      if ((msg =
+           mx_open_new_message (&ctx, hn,
+                                is_from (buf, NULL, 0,
+                                         NULL) ? 0 : M_ADD_FROM)) == NULL) {
+        mx_close_mailbox (&ctx, NULL);
+        return -1;
       }
       if (ctx.magic == M_MBOX || ctx.magic == M_MMDF)
-       chflags = CH_FROM;
+        chflags = CH_FROM;
       chflags |= (ctx.magic == M_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;
+      if (_mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags) == 0
+          && mx_commit_message (msg, &ctx) == 0)
+        r = 0;
       else
-       r = -1;
+        r = -1;
 
       mx_close_message (&msg);
       mx_close_mailbox (&ctx, NULL);
       return r;
     }
-    else
-    {
+    else {
       /* In recv mode, extract from folder and decode */
-      
+
       STATE s;
-      
+
       memset (&s, 0, sizeof (s));
-      if ((s.fpout = mutt_save_attachment_open (path, flags)) == NULL)
-      {
-       mutt_perror ("fopen");
-       return (-1);
+      if ((s.fpout = mutt_save_attachment_open (path, flags)) == NULL) {
+        mutt_perror ("fopen");
+        return (-1);
       }
       fseek ((s.fpin = fp), m->offset, 0);
       mutt_decode_attachment (m, &s);
-      
-      if (fclose (s.fpout) != 0)
-      {
-       mutt_perror ("fclose");
-       return (-1);
+
+      if (fclose (s.fpout) != 0) {
+        mutt_perror ("fclose");
+        return (-1);
       }
     }
   }
-  else
-  {
+  else {
     /* In send mode, just copy file */
 
     FILE *ofp, *nfp;
 
-    if ((ofp = fopen (m->filename, "r")) == NULL)
-    {
+    if ((ofp = fopen (m->filename, "r")) == NULL) {
       mutt_perror ("fopen");
       return (-1);
     }
-    
-    if ((nfp = mutt_save_attachment_open (path, flags)) == NULL)
-    {
+
+    if ((nfp = mutt_save_attachment_open (path, flags)) == NULL) {
       mutt_perror ("fopen");
       safe_fclose (&ofp);
       return (-1);
     }
 
-    if (mutt_copy_stream (ofp, nfp) == -1)
-    {
+    if (mutt_copy_stream (ofp, nfp) == -1) {
       mutt_error _("Write fault!");
+
       safe_fclose (&ofp);
       safe_fclose (&nfp);
       return (-1);
@@ -848,8 +801,8 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
 }
 
 /* returns 0 on success, -1 on error */
-int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
-                                int displaying, int flags)
+int mutt_decode_save_attachment (FILE * fp, BODY * m, char *path,
+                                 int displaying, int flags)
 {
   STATE s;
   unsigned int saved_encoding = 0;
@@ -862,31 +815,27 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
   if (flags == M_SAVE_APPEND)
     s.fpout = fopen (path, "a");
   else if (flags == M_SAVE_OVERWRITE)
-    s.fpout = safe_fopen (path, "w");  /* __FOPEN_CHECKED__ */
+    s.fpout = safe_fopen (path, "w");   /* __FOPEN_CHECKED__ */
   else
     s.fpout = safe_fopen (path, "w");
 
-  if (s.fpout == NULL)
-  {
+  if (s.fpout == NULL) {
     mutt_perror ("fopen");
     return (-1);
   }
 
-  if (fp == NULL)
-  {
+  if (fp == NULL) {
     /* When called from the compose menu, the attachment isn't parsed,
      * so we need to do it here. */
     struct stat st;
 
-    if (stat (m->filename, &st) == -1)
-    {
+    if (stat (m->filename, &st) == -1) {
       mutt_perror ("stat");
       fclose (s.fpout);
       return (-1);
     }
 
-    if ((s.fpin = fopen (m->filename, "r")) == NULL)
-    {
+    if ((s.fpin = fopen (m->filename, "r")) == NULL) {
       mutt_perror ("fopen");
       return (-1);
     }
@@ -894,7 +843,7 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
     saved_encoding = m->encoding;
     if (!is_multipart (m))
       m->encoding = ENC8BIT;
-    
+
     m->length = st.st_size;
     m->offset = 0;
     saved_parts = m->parts;
@@ -904,8 +853,7 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
     if (m->noconv || is_multipart (m))
       s.flags |= M_CHARCONV;
   }
-  else
-  {
+  else {
     s.fpin = fp;
     s.flags |= M_CHARCONV;
   }
@@ -913,12 +861,10 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
   mutt_body_handler (m, &s);
 
   fclose (s.fpout);
-  if (fp == NULL)
-  {
+  if (fp == NULL) {
     m->length = 0;
     m->encoding = saved_encoding;
-    if (saved_parts)
-    {
+    if (saved_parts) {
       mutt_free_header (&m->hdr);
       m->parts = saved_parts;
       m->hdr = saved_hdr;
@@ -936,42 +882,38 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
  *       attachment
  */
 
-int mutt_print_attachment (FILE *fp, BODY *a)
+int mutt_print_attachment (FILE * fp, BODY * a)
 {
   char newfile[_POSIX_PATH_MAX] = "";
   char type[STRING];
   pid_t thepid;
   FILE *ifp, *fpout;
   short unlink_newfile = 0;
-  
+
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
 
-  if (rfc1524_mailcap_lookup (a, type, NULL, M_PRINT)) 
-  {
-    char command[_POSIX_PATH_MAX+STRING];
+  if (rfc1524_mailcap_lookup (a, type, NULL, M_PRINT)) {
+    char command[_POSIX_PATH_MAX + STRING];
     rfc1524_entry *entry;
     int piped = FALSE;
 
     dprint (2, (debugfile, "Using mailcap...\n"));
-    
+
     entry = rfc1524_new_entry ();
     rfc1524_mailcap_lookup (a, type, entry, M_PRINT);
     if (rfc1524_expand_filename (entry->nametemplate, a->filename,
-                                                 newfile, sizeof (newfile)))
-    {
-      if (!fp)
-      {
-       if (safe_symlink(a->filename, newfile) == -1)
-       {
-         if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != M_YES)
-         {
-           rfc1524_free_entry (&entry);
-           return 0;
-         }
-         strfcpy (newfile, a->filename, sizeof (newfile));
-       }
-       else
-         unlink_newfile = 1;
+                                 newfile, sizeof (newfile))) {
+      if (!fp) {
+        if (safe_symlink (a->filename, newfile) == -1) {
+          if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
+              != M_YES) {
+            rfc1524_free_entry (&entry);
+            return 0;
+          }
+          strfcpy (newfile, a->filename, sizeof (newfile));
+        }
+        else
+          unlink_newfile = 1;
       }
     }
 
@@ -980,93 +922,89 @@ int mutt_print_attachment (FILE *fp, BODY *a)
       mutt_save_attachment (fp, a, newfile, 0, NULL);
 
     strfcpy (command, entry->printcommand, sizeof (command));
-    piped = rfc1524_expand_command (a, newfile, type, command, sizeof (command));
+    piped =
+      rfc1524_expand_command (a, newfile, type, command, sizeof (command));
 
     mutt_endwin (NULL);
 
     /* interactive program */
-    if (piped)
-    {
-      if ((ifp = fopen (newfile, "r")) == NULL)
-      {
-       mutt_perror ("fopen");
-       rfc1524_free_entry (&entry);
-       return (0);
+    if (piped) {
+      if ((ifp = fopen (newfile, "r")) == NULL) {
+        mutt_perror ("fopen");
+        rfc1524_free_entry (&entry);
+        return (0);
       }
 
-      if ((thepid = mutt_create_filter (command, &fpout, NULL, NULL)) < 0)
-      {
-       mutt_perror _("Can't create filter");
-       rfc1524_free_entry (&entry);
-       safe_fclose (&ifp);
-       return 0;
+      if ((thepid = mutt_create_filter (command, &fpout, NULL, NULL)) < 0) {
+        mutt_perror _("Can't create filter");
+
+        rfc1524_free_entry (&entry);
+        safe_fclose (&ifp);
+        return 0;
       }
       mutt_copy_stream (ifp, fpout);
       safe_fclose (&fpout);
       safe_fclose (&ifp);
       if (mutt_wait_filter (thepid) || option (OPTWAITKEY))
-       mutt_any_key_to_continue (NULL);
+        mutt_any_key_to_continue (NULL);
     }
-    else
-    {
+    else {
       if (mutt_system (command) || option (OPTWAITKEY))
-       mutt_any_key_to_continue (NULL);
+        mutt_any_key_to_continue (NULL);
     }
 
     if (fp)
       mutt_unlink (newfile);
     else if (unlink_newfile)
-      unlink(newfile);
+      unlink (newfile);
 
     rfc1524_free_entry (&entry);
     return (1);
   }
 
   if (!ascii_strcasecmp ("text/plain", type) ||
-      !ascii_strcasecmp ("application/postscript", type))
-  {
-    return (mutt_pipe_attachment (fp, a, NONULL(PrintCmd), NULL));
+      !ascii_strcasecmp ("application/postscript", type)) {
+    return (mutt_pipe_attachment (fp, a, NONULL (PrintCmd), NULL));
   }
-  else if (mutt_can_decode (a))
-  {
+  else if (mutt_can_decode (a)) {
     /* decode and print */
 
     int rc = 0;
-    
+
     ifp = NULL;
     fpout = NULL;
-    
+
     mutt_mktemp (newfile);
-    if (mutt_decode_save_attachment (fp, a, newfile, M_PRINTING, 0) == 0)
-    {
-      
-      dprint (2, (debugfile, "successfully decoded %s type attachment to %s\n",
-                 type, newfile));
-      
-      if ((ifp = fopen (newfile, "r")) == NULL)
-      {
-       mutt_perror ("fopen");
-       goto bail0;
+    if (mutt_decode_save_attachment (fp, a, newfile, M_PRINTING, 0) == 0) {
+
+      dprint (2,
+              (debugfile, "successfully decoded %s type attachment to %s\n",
+               type, newfile));
+
+      if ((ifp = fopen (newfile, "r")) == NULL) {
+        mutt_perror ("fopen");
+        goto bail0;
       }
 
       dprint (2, (debugfile, "successfully opened %s read-only\n", newfile));
-      
+
       mutt_endwin (NULL);
-      if ((thepid = mutt_create_filter (NONULL(PrintCmd), &fpout, NULL, NULL)) < 0)
-      {
-       mutt_perror _("Can't create filter");
-       goto bail0;
+      if ((thepid =
+           mutt_create_filter (NONULL (PrintCmd), &fpout, NULL, NULL)) < 0) {
+        mutt_perror _("Can't create filter");
+
+        goto bail0;
       }
 
       dprint (2, (debugfile, "Filter created.\n"));
-      
+
       mutt_copy_stream (ifp, fpout);
 
       safe_fclose (&fpout);
       safe_fclose (&ifp);
 
       if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
-       mutt_any_key_to_continue (NULL);
+        mutt_any_key_to_continue (NULL);
       rc = 1;
     }
   bail0:
@@ -1075,9 +1013,9 @@ int mutt_print_attachment (FILE *fp, BODY *a)
     mutt_unlink (newfile);
     return rc;
   }
-  else
-  {
+  else {
     mutt_error _("I don't know how to print that!");
+
     return 0;
   }
 }
index b751a95..e7b5513 100644 (file)
--- a/attach.h
+++ b/attach.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* common protos for compose / attach menus */
 
-int mutt_tag_attach (MUTTMENU *menu, int n, int m);
-int mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
-                             BODY *cur, ATTACHPTR ***idxp, short *idxlen, short *idxmax,
-                             int recv);
+int mutt_tag_attach (MUTTMENU * menu, int n, int m);
+int mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp,
+                              HEADER * hdr, BODY * cur, ATTACHPTR *** idxp,
+                              short *idxlen, short *idxmax, int recv);
 
 
-void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTMENU *menu);
-void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter);
-void mutt_print_attachment_list (FILE *fp, int tag, BODY *top);
+void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
+                                MUTTMENU * menu);
+void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter);
+void mutt_print_attachment_list (FILE * fp, int tag, BODY * top);
 
 void mutt_attach_bounce (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
 void mutt_attach_resend (FILE *, HEADER *, ATTACHPTR **, short, BODY *);
index 4e63292..ad6c6c4 100644 (file)
--- a/base64.c
+++ b/base64.c
 
 /* raw bytes to null-terminated base 64 string */
 void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len,
-                    size_t olen)
+                     size_t olen)
 {
-  while (len >= 3 && olen > 10)
-  {
+  while (len >= 3 && olen > 10) {
     *out++ = B64Chars[in[0] >> 2];
     *out++ = B64Chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
     *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
     *out++ = B64Chars[in[2] & 0x3f];
-    olen  -= 4;
-    len   -= 3;
-    in    += 3;
+    olen -= 4;
+    len -= 3;
+    in += 3;
   }
 
   /* clean up remainder */
-  if (len > 0 && olen > 4)
-  {
+  if (len > 0 && olen > 4) {
     unsigned char fragment;
 
     *out++ = B64Chars[in[0] >> 2];
@@ -86,8 +84,7 @@ int mutt_from_base64 (char *out, const char *in)
   int len = 0;
   register unsigned char digit1, digit2, digit3, digit4;
 
-  do
-  {
+  do {
     digit1 = in[0];
     if (digit1 > 127 || base64val (digit1) == BAD)
       return -1;
@@ -103,16 +100,14 @@ int mutt_from_base64 (char *out, const char *in)
     in += 4;
 
     /* digits are already sanity-checked */
-    *out++ = (base64val(digit1) << 2) | (base64val(digit2) >> 4);
+    *out++ = (base64val (digit1) << 2) | (base64val (digit2) >> 4);
     len++;
-    if (digit3 != '=')
-    {
-      *out++ = ((base64val(digit2) << 4) & 0xf0) | (base64val(digit3) >> 2);
+    if (digit3 != '=') {
+      *out++ = ((base64val (digit2) << 4) & 0xf0) | (base64val (digit3) >> 2);
       len++;
-      if (digit4 != '=')
-      {
-       *out++ = ((base64val(digit3) << 6) & 0xc0) | base64val(digit4);
-       len++;
+      if (digit4 != '=') {
+        *out++ = ((base64val (digit3) << 6) & 0xc0) | base64val (digit4);
+        len++;
       }
     }
   }
index 21bb588..f47b8fb 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <errno.h>
 
 static struct mapping_t FolderHelp[] = {
-  { N_("Exit"),  OP_EXIT },
-  { N_("Chdir"), OP_CHANGE_DIRECTORY },
-  { N_("Mask"),  OP_ENTER_MASK },
-  { N_("Help"),  OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("Chdir"), OP_CHANGE_DIRECTORY},
+  {N_("Mask"), OP_ENTER_MASK},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
 #ifdef USE_NNTP
 static struct mapping_t FolderNewsHelp[] = {
-  { N_("Exit"),        OP_EXIT },
-  { N_("List"),        OP_TOGGLE_MAILBOXES },
-  { N_("Subscribe"),   OP_BROWSER_SUBSCRIBE },
-  { N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
-  { N_("Catchup"),     OP_CATCHUP },
-  { N_("Mask"),        OP_ENTER_MASK },
-  { N_("Help"),        OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("List"), OP_TOGGLE_MAILBOXES},
+  {N_("Subscribe"), OP_BROWSER_SUBSCRIBE},
+  {N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE},
+  {N_("Catchup"), OP_CATCHUP},
+  {N_("Mask"), OP_ENTER_MASK},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 #endif
 
-typedef struct folder_t
-{
+typedef struct folder_t {
   struct folder_file *ff;
   int num;
 } FOLDER;
@@ -79,8 +78,7 @@ static void destroy_state (struct browser_state *state)
 {
   int c;
 
-  for (c = 0; c < state->entrylen; c++)
-  {
+  for (c = 0; c < state->entrylen; c++) {
     FREE (&((state->entry)[c].name));
     FREE (&((state->entry)[c].desc));
     FREE (&((state->entry)[c].st));
@@ -125,28 +123,27 @@ static void browser_sort (struct browser_state *state)
 {
   int (*f) (const void *, const void *);
 
-  switch (BrowserSort & SORT_MASK)
-  {
-    case SORT_ORDER:
-      return;
-    case SORT_DATE:
+  switch (BrowserSort & SORT_MASK) {
+  case SORT_ORDER:
+    return;
+  case SORT_DATE:
 #ifdef USE_NNTP
-      if (option (OPTNEWS))
-       return;
+    if (option (OPTNEWS))
+      return;
 #endif
-      f = browser_compare_date;
-      break;
-    case SORT_SIZE:
+    f = browser_compare_date;
+    break;
+  case SORT_SIZE:
 #ifdef USE_NNTP
-      if (option (OPTNEWS))
-       return;
+    if (option (OPTNEWS))
+      return;
 #endif
-      f = browser_compare_size;
-      break;
-    case SORT_SUBJECT:
-    default:
-      f = browser_compare_subject;
-      break;
+    f = browser_compare_size;
+    break;
+  case SORT_SUBJECT:
+  default:
+    f = browser_compare_subject;
+    break;
   }
   qsort (state->entry, state->entrylen, sizeof (struct folder_file), f);
 }
@@ -155,19 +152,20 @@ static int link_is_dir (const char *folder, const char *path)
 {
   struct stat st;
   char fullpath[_POSIX_PATH_MAX];
-  
+
   mutt_concat_path (fullpath, folder, path, sizeof (fullpath));
-  
+
   if (stat (fullpath, &st) == 0)
     return (S_ISDIR (st.st_mode));
   else
     return 0;
 }
 
-static const char *
-folder_format_str (char *dest, size_t destlen, char op, const char *src,
-                  const char *fmt, const char *ifstring, const char *elsestring,
-                  unsigned long data, format_flag flags)
+static const char *folder_format_str (char *dest, size_t destlen, char op,
+                                      const char *src, const char *fmt,
+                                      const char *ifstring,
+                                      const char *elsestring,
+                                      unsigned long data, format_flag flags)
 {
   char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11];
   char date[16], *t_fmt;
@@ -177,149 +175,151 @@ folder_format_str (char *dest, size_t destlen, char op, const char *src,
   struct group *gr;
   int optional = (flags & M_FORMAT_OPTIONAL);
 
-  switch (op)
-  {
-    case 'C':
-      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-      snprintf (dest, destlen, tmp, folder->num + 1);
-      break;
-      
-    case 'd':
-      if (folder->ff->st != NULL)
-      {
-       tnow = time (NULL);
-       t_fmt = tnow - folder->ff->st->st_mtime < 31536000 ? "%b %d %H:%M" : "%b %d  %Y";
-       strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->st->st_mtime));
-       mutt_format_s (dest, destlen, fmt, date);
-      }
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    case 'f':
+  switch (op) {
+  case 'C':
+    snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+    snprintf (dest, destlen, tmp, folder->num + 1);
+    break;
+
+  case 'd':
+    if (folder->ff->st != NULL) {
+      tnow = time (NULL);
+      t_fmt =
+        tnow - folder->ff->st->st_mtime <
+        31536000 ? "%b %d %H:%M" : "%b %d  %Y";
+      strftime (date, sizeof (date), t_fmt,
+                localtime (&folder->ff->st->st_mtime));
+      mutt_format_s (dest, destlen, fmt, date);
+    }
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  case 'f':
     {
       char *s;
+
 #ifdef USE_IMAP
       if (folder->ff->imap)
-       s = NONULL (folder->ff->desc);
+        s = NONULL (folder->ff->desc);
       else
 #endif
-       s = NONULL (folder->ff->name);
+        s = NONULL (folder->ff->name);
 
       snprintf (fn, sizeof (fn), "%s%s", s,
-               folder->ff->st ? (S_ISLNK (folder->ff->st->st_mode) ? "@" :             
-                                 (S_ISDIR (folder->ff->st->st_mode) ? "/" : 
-                                  ((folder->ff->st->st_mode & S_IXUSR) != 0 ? "*" : ""))) : "");
-      
+                folder->ff->st ? (S_ISLNK (folder->ff->st->st_mode) ? "@" :
+                                  (S_ISDIR (folder->ff->st->st_mode) ? "/" :
+                                   ((folder->ff->st->st_mode & S_IXUSR) !=
+                                    0 ? "*" : ""))) : "");
+
       mutt_format_s (dest, destlen, fmt, fn);
       break;
     }
-    case 'F':
-      if (folder->ff->st != NULL)
-      {
-       snprintf (permission, sizeof (permission), "%c%c%c%c%c%c%c%c%c%c",
-                 S_ISDIR(folder->ff->st->st_mode) ? 'd' : (S_ISLNK(folder->ff->st->st_mode) ? 'l' : '-'),
-                 (folder->ff->st->st_mode & S_IRUSR) != 0 ? 'r': '-',
-                 (folder->ff->st->st_mode & S_IWUSR) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISUID) != 0 ? 's' : (folder->ff->st->st_mode & S_IXUSR) != 0 ? 'x': '-',
-                 (folder->ff->st->st_mode & S_IRGRP) != 0 ? 'r' : '-',
-                 (folder->ff->st->st_mode & S_IWGRP) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISGID) != 0 ? 's' : (folder->ff->st->st_mode & S_IXGRP) != 0 ? 'x': '-',
-                 (folder->ff->st->st_mode & S_IROTH) != 0 ? 'r' : '-',
-                 (folder->ff->st->st_mode & S_IWOTH) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISVTX) != 0 ? 't' : (folder->ff->st->st_mode & S_IXOTH) != 0 ? 'x': '-');
-       mutt_format_s (dest, destlen, fmt, permission);
-      }
+  case 'F':
+    if (folder->ff->st != NULL) {
+      snprintf (permission, sizeof (permission), "%c%c%c%c%c%c%c%c%c%c",
+                S_ISDIR (folder->ff->st->
+                         st_mode) ? 'd' : (S_ISLNK (folder->ff->st->
+                                                    st_mode) ? 'l' : '-'),
+                (folder->ff->st->st_mode & S_IRUSR) != 0 ? 'r' : '-',
+                (folder->ff->st->st_mode & S_IWUSR) != 0 ? 'w' : '-',
+                (folder->ff->st->st_mode & S_ISUID) !=
+                0 ? 's' : (folder->ff->st->st_mode & S_IXUSR) !=
+                0 ? 'x' : '-',
+                (folder->ff->st->st_mode & S_IRGRP) != 0 ? 'r' : '-',
+                (folder->ff->st->st_mode & S_IWGRP) != 0 ? 'w' : '-',
+                (folder->ff->st->st_mode & S_ISGID) !=
+                0 ? 's' : (folder->ff->st->st_mode & S_IXGRP) !=
+                0 ? 'x' : '-',
+                (folder->ff->st->st_mode & S_IROTH) != 0 ? 'r' : '-',
+                (folder->ff->st->st_mode & S_IWOTH) != 0 ? 'w' : '-',
+                (folder->ff->st->st_mode & S_ISVTX) !=
+                0 ? 't' : (folder->ff->st->st_mode & S_IXOTH) !=
+                0 ? 'x' : '-');
+      mutt_format_s (dest, destlen, fmt, permission);
+    }
 #ifdef USE_IMAP
-      else if (folder->ff->imap)
-      {
-       /* mark folders with subfolders AND mail */
-       snprintf (permission, sizeof (permission), "IMAP %c",
-                 (folder->ff->inferiors && folder->ff->selectable) ? '+' : ' ');
-       mutt_format_s (dest, destlen, fmt, permission);
-      }                                        
+    else if (folder->ff->imap) {
+      /* mark folders with subfolders AND mail */
+      snprintf (permission, sizeof (permission), "IMAP %c",
+                (folder->ff->inferiors
+                 && folder->ff->selectable) ? '+' : ' ');
+      mutt_format_s (dest, destlen, fmt, permission);
+    }
 #endif
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    case 'g':
-      if (folder->ff->st != NULL)
-      {
-       if ((gr = getgrgid (folder->ff->st->st_gid)))
-         mutt_format_s (dest, destlen, fmt, gr->gr_name);
-       else
-       {
-         snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
-         snprintf (dest, destlen, tmp, folder->ff->st->st_gid);
-       }
-      }
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    case 'l':
-      if (folder->ff->st != NULL)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->st->st_nlink);
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  case 'g':
+    if (folder->ff->st != NULL) {
+      if ((gr = getgrgid (folder->ff->st->st_gid)))
+        mutt_format_s (dest, destlen, fmt, gr->gr_name);
+      else {
+        snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
+        snprintf (dest, destlen, tmp, folder->ff->st->st_gid);
       }
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    case 'N':
+    }
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  case 'l':
+    if (folder->ff->st != NULL) {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp, folder->ff->st->st_nlink);
+    }
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  case 'N':
 #ifdef USE_IMAP
-      if (mx_is_imap (folder->ff->desc))
-      {
-       if (!optional)
-       {
-         snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-         snprintf (dest, destlen, tmp, folder->ff->new);
-       }
-       else if (!folder->ff->new)
-         optional = 0;
-       break;
-      }
-#endif
-      snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
-      snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
-      break;
-      
-    case 's':
-      if (folder->ff->st != NULL)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
-       snprintf (dest, destlen, tmp, (long) folder->ff->st->st_size);
+    if (mx_is_imap (folder->ff->desc)) {
+      if (!optional) {
+        snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+        snprintf (dest, destlen, tmp, folder->ff->new);
       }
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    case 't':
-      snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
-      snprintf (dest, destlen, tmp, folder->ff->tagged ? '*' : ' ');
+      else if (!folder->ff->new)
+        optional = 0;
       break;
-      
-    case 'u':
-      if (folder->ff->st != NULL)
-      {
-       if ((pw = getpwuid (folder->ff->st->st_uid)))
-         mutt_format_s (dest, destlen, fmt, pw->pw_name);
-       else
-       {
-         snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
-         snprintf (dest, destlen, tmp, folder->ff->st->st_uid);
-       }
+    }
+#endif
+    snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+    snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
+    break;
+
+  case 's':
+    if (folder->ff->st != NULL) {
+      snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
+      snprintf (dest, destlen, tmp, (long) folder->ff->st->st_size);
+    }
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  case 't':
+    snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+    snprintf (dest, destlen, tmp, folder->ff->tagged ? '*' : ' ');
+    break;
+
+  case 'u':
+    if (folder->ff->st != NULL) {
+      if ((pw = getpwuid (folder->ff->st->st_uid)))
+        mutt_format_s (dest, destlen, fmt, pw->pw_name);
+      else {
+        snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
+        snprintf (dest, destlen, tmp, folder->ff->st->st_uid);
       }
-      else
-       mutt_format_s (dest, destlen, fmt, "");
-      break;
-      
-    default:
-      snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
-      snprintf (dest, destlen, tmp, op);
-      break;
+    }
+    else
+      mutt_format_s (dest, destlen, fmt, "");
+    break;
+
+  default:
+    snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+    snprintf (dest, destlen, tmp, op);
+    break;
   }
 
   if (optional)
@@ -331,123 +331,115 @@ folder_format_str (char *dest, size_t destlen, char op, const char *src,
 }
 
 #ifdef USE_NNTP
-static const char *
-newsgroup_format_str (char *dest, size_t destlen, char op, const char *src,
-                      const char *fmt, const char *ifstring, const char *elsestring,
-                      unsigned long data, format_flag flags)
+static const char *newsgroup_format_str (char *dest, size_t destlen, char op,
+                                         const char *src, const char *fmt,
+                                         const char *ifstring,
+                                         const char *elsestring,
+                                         unsigned long data,
+                                         format_flag flags)
 {
   char fn[SHORT_STRING], tmp[SHORT_STRING];
   FOLDER *folder = (FOLDER *) data;
 
-  switch (op)
-  {
-    case 'C':
-      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-      snprintf (dest, destlen, tmp, folder->num + 1);
-      break;
-      
-    case 'f':
-      strncpy (fn, folder->ff->name, sizeof(fn) - 1);
-      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-      snprintf (dest, destlen, tmp, fn);
-      break;
-
-    case 'N':
-      snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
-      if (folder->ff->nd->subscribed)
-       snprintf (dest, destlen, tmp, ' ');
-      else
-       snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
-      break;
-
-    case 'M':
-      snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
-      if (folder->ff->nd->deleted)
-       snprintf (dest, destlen, tmp, 'D');
-      else
-       snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
-      break;
+  switch (op) {
+  case 'C':
+    snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+    snprintf (dest, destlen, tmp, folder->num + 1);
+    break;
+
+  case 'f':
+    strncpy (fn, folder->ff->name, sizeof (fn) - 1);
+    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+    snprintf (dest, destlen, tmp, fn);
+    break;
+
+  case 'N':
+    snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+    if (folder->ff->nd->subscribed)
+      snprintf (dest, destlen, tmp, ' ');
+    else
+      snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u');
+    break;
 
-    case 's':
-      if (flags & M_FORMAT_OPTIONAL)
-      {
-       if (folder->ff->nd->unread != 0)
-         mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
-               data, flags);
-       else
-         mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
-               data, flags);
-      }
-      else if (Context && Context->data == folder->ff->nd)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, Context->unread);
-      }
+  case 'M':
+    snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
+    if (folder->ff->nd->deleted)
+      snprintf (dest, destlen, tmp, 'D');
+    else
+      snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-');
+    break;
+
+  case 's':
+    if (flags & M_FORMAT_OPTIONAL) {
+      if (folder->ff->nd->unread != 0)
+        mutt_FormatString (dest, destlen, ifstring, newsgroup_format_str,
+                           data, flags);
       else
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->nd->unread);
-      }
-      break;
+        mutt_FormatString (dest, destlen, elsestring, newsgroup_format_str,
+                           data, flags);
+    }
+    else if (Context && Context->data == folder->ff->nd) {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp, Context->unread);
+    }
+    else {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp, folder->ff->nd->unread);
+    }
+    break;
 
-    case 'n':
-      if (Context && Context->data == folder->ff->nd)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, Context->new);
-      }
-      else if (option (OPTMARKOLD) &&
-               folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
-               folder->ff->nd->lastCached <= folder->ff->nd->lastMessage)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
-      }
-      else
-      {
-       snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->nd->unread);
-      }
-      break;
+  case 'n':
+    if (Context && Context->data == folder->ff->nd) {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp, Context->new);
+    }
+    else if (option (OPTMARKOLD) &&
+             folder->ff->nd->lastCached >= folder->ff->nd->firstMessage &&
+             folder->ff->nd->lastCached <= folder->ff->nd->lastMessage) {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp,
+                folder->ff->nd->lastMessage - folder->ff->nd->lastCached);
+    }
+    else {
+      snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+      snprintf (dest, destlen, tmp, folder->ff->nd->unread);
+    }
+    break;
 
-    case 'd':
-      if (folder->ff->nd->desc != NULL)
-      {
-       snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->nd->desc);
-      }
-      else
-      {
-       snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-       snprintf (dest, destlen, tmp, "");
-      }
-      break;
+  case 'd':
+    if (folder->ff->nd->desc != NULL) {
+      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+      snprintf (dest, destlen, tmp, folder->ff->nd->desc);
+    }
+    else {
+      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+      snprintf (dest, destlen, tmp, "");
+    }
+    break;
   }
   return (src);
 }
 #endif /* USE_NNTP */
 
-static void add_folder (MUTTMENU *m, struct browser_state *state,
-                       const char *name, const struct stat *s,
-                       void *data, int new)
+static void add_folder (MUTTMENU * m, struct browser_state *state,
+                        const char *name, const struct stat *s,
+                        void *data, int new)
 {
-  if (state->entrylen == state->entrymax)
-  {
+  if (state->entrylen == state->entrymax) {
     /* need to allocate more space */
     safe_realloc (&state->entry,
-                 sizeof (struct folder_file) * (state->entrymax += 256));
+                  sizeof (struct folder_file) * (state->entrymax += 256));
     memset (&state->entry[state->entrylen], 0,
-           sizeof (struct folder_file) * 256);
+            sizeof (struct folder_file) * 256);
     if (m)
       m->data = state->entry;
   }
 
-  if (s != NULL)
-  {
+  if (s != NULL) {
     (state->entry)[state->entrylen].mode = s->st_mode;
     (state->entry)[state->entrylen].mtime = s->st_mtime;
     (state->entry)[state->entrylen].size = s->st_size;
-    
+
     (state->entry)[state->entrylen].st = safe_malloc (sizeof (struct stat));
     memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
   }
@@ -465,11 +457,13 @@ static void add_folder (MUTTMENU *m, struct browser_state *state,
   (state->entrylen)++;
 }
 
-static void init_state (struct browser_state *state, MUTTMENU *menu)
+static void init_state (struct browser_state *state, MUTTMENU * menu)
 {
   state->entrylen = 0;
   state->entrymax = 256;
-  state->entry = (struct folder_file *) safe_calloc (state->entrymax, sizeof (struct folder_file));
+  state->entry =
+    (struct folder_file *) safe_calloc (state->entrymax,
+                                        sizeof (struct folder_file));
 #ifdef USE_IMAP
   state->imap_browse = 0;
 #endif
@@ -478,12 +472,11 @@ static void init_state (struct browser_state *state, MUTTMENU *menu)
 }
 
 /* get list of all files/newsgroups with mask */
-static int examine_directory (MUTTMENU *menu, struct browser_state *state,
-                             char *d, const char *prefix)
+static int examine_directory (MUTTMENU * menu, struct browser_state *state,
+                              char *d, const char *prefix)
 {
 #ifdef USE_NNTP
-  if (option (OPTNEWS))
-  {
+  if (option (OPTNEWS)) {
     LIST *tmp;
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
@@ -491,84 +484,78 @@ static int examine_directory (MUTTMENU *menu, struct browser_state *state,
 /*  mutt_buffy_check (0); */
     init_state (state, menu);
 
-    for (tmp = news->list; tmp; tmp = tmp->next)
-    {
-      if (!(data = (NNTP_DATA *)tmp->data))
-       continue;
+    for (tmp = news->list; tmp; tmp = tmp->next) {
+      if (!(data = (NNTP_DATA *) tmp->data))
+        continue;
       if (prefix && *prefix && strncmp (prefix, data->group,
-           strlen (prefix)) != 0)
-       continue;
+                                        strlen (prefix)) != 0)
+        continue;
       if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
-       continue;
+        continue;
       add_folder (menu, state, data->group, NULL, data, data->new);
     }
   }
   else
 #endif /* USE_NNTP */
   {
-  struct stat s;
-  DIR *dp;
-  struct dirent *de;
-  char buffer[_POSIX_PATH_MAX + SHORT_STRING];
-  BUFFY *tmp;
+    struct stat s;
+    DIR *dp;
+    struct dirent *de;
+    char buffer[_POSIX_PATH_MAX + SHORT_STRING];
+    BUFFY *tmp;
+
+    while (stat (d, &s) == -1) {
+      if (errno == ENOENT) {
+        /* The last used directory is deleted, try to use the parent dir. */
+        char *c = strrchr (d, '/');
+
+        if (c && (c > d)) {
+          *c = 0;
+          continue;
+        }
+      }
+      mutt_perror (d);
+      return (-1);
+    }
 
-  while (stat (d, &s) == -1)
-  {
-    if (errno == ENOENT)
-    {
-      /* The last used directory is deleted, try to use the parent dir. */
-      char *c = strrchr (d, '/');
+    if (!S_ISDIR (s.st_mode)) {
+      mutt_error (_("%s is not a directory."), d);
+      return (-1);
+    }
 
-      if (c && (c > d))
-      {
-       *c = 0;
-       continue;
-      }
+    mutt_buffy_check (0);
+
+    if ((dp = opendir (d)) == NULL) {
+      mutt_perror (d);
+      return (-1);
     }
-    mutt_perror (d);
-    return (-1);
-  }
 
-  if (!S_ISDIR (s.st_mode))
-  {
-    mutt_error (_("%s is not a directory."), d);
-    return (-1);
-  }
+    init_state (state, menu);
 
-  mutt_buffy_check (0);
+    while ((de = readdir (dp)) != NULL) {
+      if (mutt_strcmp (de->d_name, ".") == 0)
+        continue;               /* we don't need . */
 
-  if ((dp = opendir (d)) == NULL)
-  {
-    mutt_perror (d);
-    return (-1);
-  }
+      if (prefix && *prefix
+          && mutt_strncmp (prefix, de->d_name, mutt_strlen (prefix)) != 0)
+        continue;
+      if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
+        continue;
 
-  init_state (state, menu);
+      mutt_concat_path (buffer, d, de->d_name, sizeof (buffer));
+      if (lstat (buffer, &s) == -1)
+        continue;
 
-  while ((de = readdir (dp)) != NULL)
-  {
-    if (mutt_strcmp (de->d_name, ".") == 0)
-      continue;    /* we don't need . */
-    
-    if (prefix && *prefix && mutt_strncmp (prefix, de->d_name, mutt_strlen (prefix)) != 0)
-      continue;
-    if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
-      continue;
-
-    mutt_concat_path (buffer, d, de->d_name, sizeof (buffer));
-    if (lstat (buffer, &s) == -1)
-      continue;
-    
-    if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) &&
-       (! S_ISLNK (s.st_mode)))
-      continue;
-    
-    tmp = Incoming;
-    while (tmp && mutt_strcmp (buffer, tmp->path))
-      tmp = tmp->next;
-    add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
-  }
-  closedir (dp);
+      if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) &&
+          (!S_ISLNK (s.st_mode)))
+        continue;
+
+      tmp = Incoming;
+      while (tmp && mutt_strcmp (buffer, tmp->path))
+        tmp = tmp->next;
+      add_folder (menu, state, de->d_name, &s, NULL, (tmp) ? tmp->new : 0);
+    }
+    closedir (dp);
   }
   draw_sidebar (CurrentMenu);
   browser_sort (state);
@@ -576,14 +563,13 @@ static int examine_directory (MUTTMENU *menu, struct browser_state *state,
 }
 
 /* get list of mailboxes/subscribed newsgroups */
-static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
+static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state)
 {
   struct stat s;
   char buffer[LONG_STRING];
 
 #ifdef USE_NNTP
-  if (option (OPTNEWS))
-  {
+  if (option (OPTNEWS)) {
     LIST *tmp;
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
@@ -591,11 +577,14 @@ static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
 /*  mutt_buffy_check (0); */
     init_state (state, menu);
 
-    for (tmp = news->list; tmp; tmp = tmp->next)
-    {
+    for (tmp = news->list; tmp; tmp = tmp->next) {
       if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new ||
-         (data->subscribed && (!option (OPTSHOWONLYUNREAD) || data->unread))))
-      add_folder (menu, state, data->group, NULL, data, data->new);
+                                                       (data->subscribed
+                                                        &&
+                                                        (!option
+                                                         (OPTSHOWONLYUNREAD)
+                                                         || data->unread))))
+        add_folder (menu, state, data->group, NULL, data, data->new);
     }
   }
   else
@@ -609,37 +598,33 @@ static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
 
     init_state (state, menu);
 
-    do
-    {
+    do {
 #ifdef USE_IMAP
-      if (mx_is_imap (tmp->path))
-      {
-       add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
-       continue;
+      if (mx_is_imap (tmp->path)) {
+        add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
+        continue;
       }
 #endif
 #ifdef USE_POP
-      if (mx_is_pop (tmp->path))
-      {
-       add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
-       continue;
+      if (mx_is_pop (tmp->path)) {
+        add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
+        continue;
       }
 #endif
 #ifdef USE_NNTP
-      if (mx_is_nntp (tmp->path))
-      {
-       add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
-       continue;
+      if (mx_is_nntp (tmp->path)) {
+        add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
+        continue;
       }
 #endif
       if (lstat (tmp->path, &s) == -1)
-       continue;
+        continue;
 
-      if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) &&
-         (! S_ISLNK (s.st_mode)))
-       continue;
-    
-      strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
+      if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) &&
+          (!S_ISLNK (s.st_mode)))
+        continue;
+
+      strfcpy (buffer, NONULL (tmp->path), sizeof (buffer));
       mutt_pretty_mailbox (buffer);
 
       add_folder (menu, state, buffer, &s, NULL, tmp->new);
@@ -650,40 +635,42 @@ static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
   return 0;
 }
 
-static int select_file_search (MUTTMENU *menu, regex_t *re, int n)
+static int select_file_search (MUTTMENU * menu, regex_t * re, int n)
 {
 #ifdef USE_NNTP
   if (option (OPTNEWS))
-    return (regexec (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
+    return (regexec
+            (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0));
 #endif
-  return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
+  return (regexec
+          (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0));
 }
 
-static void folder_entry (char *s, size_t slen, MUTTMENU *menu, int num)
+static void folder_entry (char *s, size_t slen, MUTTMENU * menu, int num)
 {
   FOLDER folder;
 
   folder.ff = &((struct folder_file *) menu->data)[num];
   folder.num = num;
-  
+
 #ifdef USE_NNTP
   if (option (OPTNEWS))
-    mutt_FormatString (s, slen, NONULL(GroupFormat), newsgroup_format_str, 
-      (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
+    mutt_FormatString (s, slen, NONULL (GroupFormat), newsgroup_format_str,
+                       (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
   else
 #endif
-    mutt_FormatString (s, slen, NONULL(FolderFormat), folder_format_str, 
-      (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
+    mutt_FormatString (s, slen, NONULL (FolderFormat), folder_format_str,
+                       (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
 }
 
-static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
-                      size_t titlelen, int buffy)
+static void init_menu (struct browser_state *state, MUTTMENU * menu,
+                       char *title, size_t titlelen, int buffy)
 {
   char path[_POSIX_PATH_MAX];
 
   menu->max = state->entrylen;
 
-  if(menu->current >= menu->max)
+  if (menu->current >= menu->max)
     menu->current = menu->max - 1;
   if (menu->current < 0)
     menu->current = 0;
@@ -693,51 +680,52 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
   menu->tagged = 0;
 
 #ifdef USE_NNTP
-  if (option (OPTNEWS))
-  {
+  if (option (OPTNEWS)) {
     if (buffy)
       snprintf (title, titlelen, "%s", _("Subscribed newsgroups"));
     else
       snprintf (title, titlelen, _("Newsgroups on server [%s]"),
-               CurrentNewsSrv->conn->account.host);
+                CurrentNewsSrv->conn->account.host);
   }
   else
 #endif
   if (buffy)
     snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
-  else
-  {
+  else {
     strfcpy (path, LastDir, sizeof (path));
     mutt_pretty_mailbox (path);
 #ifdef USE_IMAP
-  if (state->imap_browse && option (OPTIMAPLSUB))
-    snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
-             path, NONULL (Mask.pattern));
-  else
+    if (state->imap_browse && option (OPTIMAPLSUB))
+      snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
+                path, NONULL (Mask.pattern));
+    else
 #endif
-    snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
-             path, NONULL(Mask.pattern));
+      snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
+                path, NONULL (Mask.pattern));
   }
   menu->redraw = REDRAW_FULL;
 }
 
-static int file_tag (MUTTMENU *menu, int n, int m)
+static int file_tag (MUTTMENU * menu, int n, int m)
 {
-  struct folder_file *ff = &(((struct folder_file *)menu->data)[n]);
+  struct folder_file *ff = &(((struct folder_file *) menu->data)[n]);
   int ot;
-  if (S_ISDIR (ff->mode) || (S_ISLNK (ff->mode) && link_is_dir (LastDir, ff->name)))
-  {
+
+  if (S_ISDIR (ff->mode)
+      || (S_ISLNK (ff->mode) && link_is_dir (LastDir, ff->name))) {
     mutt_error _("Can't attach a directory!");
+
     return 0;
   }
-  
+
   ot = ff->tagged;
   ff->tagged = (m >= 0 ? m : !ff->tagged);
-  
+
   return ff->tagged - ot;
 }
 
-void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *numfiles)
+void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
+                        int *numfiles)
 {
   char buf[_POSIX_PATH_MAX];
   char prefix[_POSIX_PATH_MAX] = "";
@@ -747,99 +735,87 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
   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 & M_SEL_MULTI) ? 1 : 0;
+  int folder = (flags & M_SEL_FOLDER) ? 1 : 0;
+  int buffy = (flags & M_SEL_BUFFY) ? 1 : 0;
 
   buffy = buffy && folder;
-  
+
   memset (&state, 0, sizeof (struct browser_state));
 
   if (!folder)
     strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
 
 #ifdef USE_NNTP
-  if (option (OPTNEWS))
-  {
+  if (option (OPTNEWS)) {
     if (*f)
       strfcpy (prefix, f, sizeof (prefix));
-    else
-    {
+    else {
       LIST *list;
 
       /* default state for news reader mode is browse subscribed newsgroups */
       buffy = 0;
-      for (list = CurrentNewsSrv->list; list; list = list->next)
-      {
-       NNTP_DATA *data = (NNTP_DATA *) list->data;
+      for (list = CurrentNewsSrv->list; list; list = list->next) {
+        NNTP_DATA *data = (NNTP_DATA *) list->data;
 
-       if (data && data->subscribed)
-       {
-         buffy = 1;
-         break;
-       }
+        if (data && data->subscribed) {
+          buffy = 1;
+          break;
+        }
       }
     }
   }
   else
 #endif
-  if (*f)
-  {
+  if (*f) {
     mutt_expand_path (f, flen);
 #ifdef USE_IMAP
-    if (mx_is_imap (f))
-    {
+    if (mx_is_imap (f)) {
       init_state (&state, NULL);
       state.imap_browse = 1;
       imap_browse (f, &state);
       strfcpy (LastDir, state.folder, sizeof (LastDir));
     }
-    else
-    {
+    else {
 #endif
-    for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--);
-    if (i > 0)
-    {
-      if (f[0] == '/')
-      {
-       if (i > sizeof (LastDir) - 1) i = sizeof (LastDir) - 1;
-       strncpy (LastDir, f, i);
-       LastDir[i] = 0;
+      for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/'; i--);
+      if (i > 0) {
+        if (f[0] == '/') {
+          if (i > sizeof (LastDir) - 1)
+            i = sizeof (LastDir) - 1;
+          strncpy (LastDir, f, i);
+          LastDir[i] = 0;
+        }
+        else {
+          getcwd (LastDir, sizeof (LastDir));
+          safe_strcat (LastDir, sizeof (LastDir), "/");
+          safe_strncat (LastDir, sizeof (LastDir), f, i);
+        }
       }
-      else
-      {
-       getcwd (LastDir, sizeof (LastDir));
-       safe_strcat (LastDir, sizeof (LastDir), "/");
-       safe_strncat (LastDir, sizeof (LastDir), f, i);
+      else {
+        if (f[0] == '/')
+          strcpy (LastDir, "/");        /* __STRCPY_CHECKED__ */
+        else
+          getcwd (LastDir, sizeof (LastDir));
       }
-    }
-    else
-    {
-      if (f[0] == '/')
-       strcpy (LastDir, "/");          /* __STRCPY_CHECKED__ */
-      else
-       getcwd (LastDir, sizeof (LastDir));
-    }
 
-    if (i <= 0 && f[0] != '/')
-      strfcpy (prefix, f, sizeof (prefix));
-    else
-      strfcpy (prefix, f + i + 1, sizeof (prefix));
-    killPrefix = 1;
+      if (i <= 0 && f[0] != '/')
+        strfcpy (prefix, f, sizeof (prefix));
+      else
+        strfcpy (prefix, f + i + 1, sizeof (prefix));
+      killPrefix = 1;
 #ifdef USE_IMAP
     }
 #endif
   }
-  else 
-  {
+  else {
     if (!folder)
       getcwd (LastDir, sizeof (LastDir));
     else if (!LastDir[0])
-      strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
-    
+      strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir));
+
 #ifdef USE_IMAP
-    if (!buffy && mx_is_imap (LastDir))
-    {
+    if (!buffy && mx_is_imap (LastDir)) {
       init_state (&state, NULL);
       state.imap_browse = 1;
       imap_browse (LastDir, &state);
@@ -849,8 +825,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
 
   *f = 0;
 
-  if (buffy)
-  {
+  if (buffy) {
     if (examine_mailboxes (NULL, &state) == -1)
       goto bail;
   }
@@ -858,8 +833,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
 #ifdef USE_IMAP
   if (!state.imap_browse)
 #endif
-  if (examine_directory (NULL, &state, LastDir, prefix) == -1)
-    goto bail;
+    if (examine_directory (NULL, &state, LastDir, prefix) == -1)
+      goto bail;
 
   menu = mutt_new_menu ();
   menu->menu = MENU_FOLDER;
@@ -872,573 +847,537 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
 
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
 #ifdef USE_NNTP
-    (option (OPTNEWS)) ? FolderNewsHelp :
+                                  (option (OPTNEWS)) ? FolderNewsHelp :
 #endif
-    FolderHelp);
+                                  FolderHelp);
 
   init_menu (&state, menu, title, sizeof (title), buffy);
 
-  FOREVER
-  {
-    switch (i = mutt_menuLoop (menu))
-    {
-      case OP_GENERIC_SELECT_ENTRY:
+  FOREVER {
+    switch (i = mutt_menuLoop (menu)) {
+    case OP_GENERIC_SELECT_ENTRY:
 
-       if (!state.entrylen)
-       {
-         mutt_error _("No files match the file mask");
-         break;
-       }
+      if (!state.entrylen) {
+        mutt_error _("No files match the file mask");
+
+        break;
+      }
 
-        if (S_ISDIR (state.entry[menu->current].mode) ||
-           (S_ISLNK (state.entry[menu->current].mode) &&
-           link_is_dir (LastDir, state.entry[menu->current].name)) 
+      if (S_ISDIR (state.entry[menu->current].mode) ||
+          (S_ISLNK (state.entry[menu->current].mode) &&
+           link_is_dir (LastDir, state.entry[menu->current].name))
 #ifdef USE_IMAP
-           || state.entry[menu->current].inferiors
+          || state.entry[menu->current].inferiors
 #endif
-           )
-       {
-         /* make sure this isn't a MH or maildir mailbox */
-         if (buffy)
-         {
-           strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
-           mutt_expand_path (buf, sizeof (buf));
-         }
+        ) {
+        /* make sure this isn't a MH or maildir mailbox */
+        if (buffy) {
+          strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+          mutt_expand_path (buf, sizeof (buf));
+        }
 #ifdef USE_IMAP
-         else if (state.imap_browse)
-         {
-            strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
-         }
+        else if (state.imap_browse) {
+          strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+        }
 #endif
-         else
-           mutt_concat_path (buf, LastDir, state.entry[menu->current].name, sizeof (buf));
+        else
+          mutt_concat_path (buf, LastDir, state.entry[menu->current].name,
+                            sizeof (buf));
 
-         if ((mx_get_magic (buf) <= 0)
+        if ((mx_get_magic (buf) <= 0)
 #ifdef USE_IMAP
-           || state.entry[menu->current].inferiors
+            || state.entry[menu->current].inferiors
 #endif
-           )
-         {
-           char OldLastDir[_POSIX_PATH_MAX];
-
-           /* save the old directory */
-           strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
-
-           if (mutt_strcmp (state.entry[menu->current].name, "..") == 0)
-           {
-             if (mutt_strcmp ("..", LastDir + mutt_strlen (LastDir) - 2) == 0)
-               strcat (LastDir, "/..");        /* __STRCAT_CHECKED__ */
-             else
-             {
-               char *p = strrchr (LastDir + 1, '/');
-
-               if (p)
-                 *p = 0;
-               else
-               {
-                 if (LastDir[0] == '/')
-                   LastDir[1] = 0;
-                 else
-                   strcat (LastDir, "/..");    /* __STRCAT_CHECKED__ */
-               }
-             }
-           }
-           else if (buffy)
-           {
-             strfcpy (LastDir, state.entry[menu->current].name, sizeof (LastDir));
-             mutt_expand_path (LastDir, sizeof (LastDir));
-           }
+          ) {
+          char OldLastDir[_POSIX_PATH_MAX];
+
+          /* save the old directory */
+          strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
+
+          if (mutt_strcmp (state.entry[menu->current].name, "..") == 0) {
+            if (mutt_strcmp ("..", LastDir + mutt_strlen (LastDir) - 2) == 0)
+              strcat (LastDir, "/..");  /* __STRCAT_CHECKED__ */
+            else {
+              char *p = strrchr (LastDir + 1, '/');
+
+              if (p)
+                *p = 0;
+              else {
+                if (LastDir[0] == '/')
+                  LastDir[1] = 0;
+                else
+                  strcat (LastDir, "/..");      /* __STRCAT_CHECKED__ */
+              }
+            }
+          }
+          else if (buffy) {
+            strfcpy (LastDir, state.entry[menu->current].name,
+                     sizeof (LastDir));
+            mutt_expand_path (LastDir, sizeof (LastDir));
+          }
 #ifdef USE_IMAP
-           else if (state.imap_browse)
-           {
-             int n;
-             ciss_url_t url;
-             
-              strfcpy (LastDir, state.entry[menu->current].name,
-                sizeof (LastDir));
-             /* tack on delimiter here */
-             n = strlen (LastDir)+1;
-             
-             /* special case "" needs no delimiter */
-             url_parse_ciss (&url, state.entry[menu->current].name);
-             if (url.path &&
-                 (state.entry[menu->current].delim != '\0') &&
-                 (n < sizeof (LastDir)))
-             {
-               LastDir[n] = '\0';
-               LastDir[n-1] = state.entry[menu->current].delim;
-             }
-           }
+          else if (state.imap_browse) {
+            int n;
+            ciss_url_t url;
+
+            strfcpy (LastDir, state.entry[menu->current].name,
+                     sizeof (LastDir));
+            /* tack on delimiter here */
+            n = strlen (LastDir) + 1;
+
+            /* special case "" needs no delimiter */
+            url_parse_ciss (&url, state.entry[menu->current].name);
+            if (url.path &&
+                (state.entry[menu->current].delim != '\0') &&
+                (n < sizeof (LastDir))) {
+              LastDir[n] = '\0';
+              LastDir[n - 1] = state.entry[menu->current].delim;
+            }
+          }
 #endif
-           else
-           {
-             char tmp[_POSIX_PATH_MAX];
-             mutt_concat_path (tmp, LastDir, state.entry[menu->current].name, sizeof (tmp));
-             strfcpy (LastDir, tmp, sizeof (LastDir));
-           }
-
-           destroy_state (&state);
-           if (killPrefix)
-           {
-             prefix[0] = 0;
-             killPrefix = 0;
-           }
-           buffy = 0;
+          else {
+            char tmp[_POSIX_PATH_MAX];
+
+            mutt_concat_path (tmp, LastDir, state.entry[menu->current].name,
+                              sizeof (tmp));
+            strfcpy (LastDir, tmp, sizeof (LastDir));
+          }
+
+          destroy_state (&state);
+          if (killPrefix) {
+            prefix[0] = 0;
+            killPrefix = 0;
+          }
+          buffy = 0;
 #ifdef USE_IMAP
-           if (state.imap_browse)
-           {
-             init_state (&state, NULL);
-             state.imap_browse = 1;
-             imap_browse (LastDir, &state);
-             menu->data = state.entry;
-           }
-           else
+          if (state.imap_browse) {
+            init_state (&state, NULL);
+            state.imap_browse = 1;
+            imap_browse (LastDir, &state);
+            menu->data = state.entry;
+          }
+          else
 #endif
-           if (examine_directory (menu, &state, LastDir, prefix) == -1)
-           {
-             /* try to restore the old values */
-             strfcpy (LastDir, OldLastDir, sizeof (LastDir));
-             if (examine_directory (menu, &state, LastDir, prefix) == -1)
-             {
-               strfcpy (LastDir, NONULL(Homedir), sizeof (LastDir));
-               goto bail;
-             }
-           }
-           menu->current = 0; 
-           menu->top = 0; 
-           init_menu (&state, menu, title, sizeof (title), buffy);
-           break;
-         }
-       }
+          if (examine_directory (menu, &state, LastDir, prefix) == -1) {
+            /* try to restore the old values */
+            strfcpy (LastDir, OldLastDir, sizeof (LastDir));
+            if (examine_directory (menu, &state, LastDir, prefix) == -1) {
+              strfcpy (LastDir, NONULL (Homedir), sizeof (LastDir));
+              goto bail;
+            }
+          }
+          menu->current = 0;
+          menu->top = 0;
+          init_menu (&state, menu, title, sizeof (title), buffy);
+          break;
+        }
+      }
 
 #ifdef USE_NNTP
-       if (buffy || option (OPTNEWS)) /* news have not path */
+      if (buffy || option (OPTNEWS))    /* news have not path */
 #else
-       if (buffy)
+      if (buffy)
 #endif
-       {
-         strfcpy (f, state.entry[menu->current].name, flen);
-         mutt_expand_path (f, flen);
-       }
+      {
+        strfcpy (f, state.entry[menu->current].name, flen);
+        mutt_expand_path (f, flen);
+      }
 #ifdef USE_IMAP
-       else if (state.imap_browse)
-          strfcpy (f, state.entry[menu->current].name, flen);
+      else if (state.imap_browse)
+        strfcpy (f, state.entry[menu->current].name, flen);
 #endif
-       else
-         mutt_concat_path (f, LastDir, state.entry[menu->current].name, flen);
-
-       /* Fall through to OP_EXIT */
-
-      case OP_EXIT:
-
-       if (multiple)
-       {
-         char **tfiles;
-         int i, j;
-
-         if (menu->tagged)
-         {
-           *numfiles = menu->tagged;
-           tfiles = safe_calloc (*numfiles, sizeof (char *));
-           for (i = 0, j = 0; i < state.entrylen; i++)
-           {
-             struct folder_file ff = state.entry[i];
-             char full[_POSIX_PATH_MAX];
-             if (ff.tagged)
-             {
-               mutt_concat_path (full, LastDir, ff.name, sizeof (full));
-               mutt_expand_path (full, sizeof (full));
-               tfiles[j++] = safe_strdup (full);
-             }
-           }
-           *files = tfiles;
-         }
-         else if (f[0]) /* no tagged entries. return selected entry */
-         {
-           *numfiles = 1;
-           tfiles = safe_calloc (*numfiles, sizeof (char *));
-           mutt_expand_path (f, flen);
-           tfiles[0] = safe_strdup (f);
-           *files = tfiles;
-         }
-       }
-
-       destroy_state (&state);
-       mutt_menuDestroy (&menu);
-       goto bail;
-
-      case OP_BROWSER_TELL:
-        if(state.entrylen)
-         mutt_message("%s", state.entry[menu->current].name);
-        break;
+      else
+        mutt_concat_path (f, LastDir, state.entry[menu->current].name, flen);
+
+      /* Fall through to OP_EXIT */
+
+    case OP_EXIT:
+
+      if (multiple) {
+        char **tfiles;
+        int i, j;
+
+        if (menu->tagged) {
+          *numfiles = menu->tagged;
+          tfiles = safe_calloc (*numfiles, sizeof (char *));
+          for (i = 0, j = 0; i < state.entrylen; i++) {
+            struct folder_file ff = state.entry[i];
+            char full[_POSIX_PATH_MAX];
+
+            if (ff.tagged) {
+              mutt_concat_path (full, LastDir, ff.name, sizeof (full));
+              mutt_expand_path (full, sizeof (full));
+              tfiles[j++] = safe_strdup (full);
+            }
+          }
+          *files = tfiles;
+        }
+        else if (f[0]) {        /* no tagged entries. return selected entry */
+          *numfiles = 1;
+          tfiles = safe_calloc (*numfiles, sizeof (char *));
+          mutt_expand_path (f, flen);
+          tfiles[0] = safe_strdup (f);
+          *files = tfiles;
+        }
+      }
+
+      destroy_state (&state);
+      mutt_menuDestroy (&menu);
+      goto bail;
+
+    case OP_BROWSER_TELL:
+      if (state.entrylen)
+        mutt_message ("%s", state.entry[menu->current].name);
+      break;
 
 #ifdef USE_IMAP
-      case OP_BROWSER_TOGGLE_LSUB:
-       if (option (OPTIMAPLSUB))
-       {
-         unset_option (OPTIMAPLSUB);
-       }
-       else
-       {
-         set_option (OPTIMAPLSUB);
-       }
-       mutt_ungetch (0, OP_CHECK_NEW);
-       break;
-
-      case OP_CREATE_MAILBOX:
-       if (!state.imap_browse)
-         mutt_error (_("Create is only supported for IMAP mailboxes"));
-       else
-       {
-         imap_mailbox_create (LastDir);
-         /* TODO: find a way to detect if the new folder would appear in
-          *   this window, and insert it without starting over. */
-         destroy_state (&state);
-         init_state (&state, NULL);
-         state.imap_browse = 1;
-         imap_browse (LastDir, &state);
-         menu->data = state.entry;
-         menu->current = 0; 
-         menu->top = 0; 
-         init_menu (&state, menu, title, sizeof (title), buffy);
-         MAYBE_REDRAW (menu->redraw);
-       }
-       break;
-
-      case OP_RENAME_MAILBOX:
-       if (!state.entry[menu->current].imap)
-         mutt_error (_("Rename is only supported for IMAP mailboxes"));
-       else
-       {
-         int nentry = menu->current;
-
-         if (imap_mailbox_rename (state.entry[nentry].name) >= 0) {
-           destroy_state (&state);
-           init_state (&state, NULL);
-           state.imap_browse = 1;
-           imap_browse (LastDir, &state);
-           menu->data = state.entry;
-           menu->current = 0;
-           menu->top = 0;
-           init_menu (&state, menu, title, sizeof (title), buffy);
-           MAYBE_REDRAW (menu->redraw);
-         }
-       }
-       break;
+    case OP_BROWSER_TOGGLE_LSUB:
+      if (option (OPTIMAPLSUB)) {
+        unset_option (OPTIMAPLSUB);
+      }
+      else {
+        set_option (OPTIMAPLSUB);
+      }
+      mutt_ungetch (0, OP_CHECK_NEW);
+      break;
+
+    case OP_CREATE_MAILBOX:
+      if (!state.imap_browse)
+        mutt_error (_("Create is only supported for IMAP mailboxes"));
+      else {
+        imap_mailbox_create (LastDir);
+        /* TODO: find a way to detect if the new folder would appear in
+         *   this window, and insert it without starting over. */
+        destroy_state (&state);
+        init_state (&state, NULL);
+        state.imap_browse = 1;
+        imap_browse (LastDir, &state);
+        menu->data = state.entry;
+        menu->current = 0;
+        menu->top = 0;
+        init_menu (&state, menu, title, sizeof (title), buffy);
+        MAYBE_REDRAW (menu->redraw);
+      }
+      break;
+
+    case OP_RENAME_MAILBOX:
+      if (!state.entry[menu->current].imap)
+        mutt_error (_("Rename is only supported for IMAP mailboxes"));
+      else {
+        int nentry = menu->current;
+
+        if (imap_mailbox_rename (state.entry[nentry].name) >= 0) {
+          destroy_state (&state);
+          init_state (&state, NULL);
+          state.imap_browse = 1;
+          imap_browse (LastDir, &state);
+          menu->data = state.entry;
+          menu->current = 0;
+          menu->top = 0;
+          init_menu (&state, menu, title, sizeof (title), buffy);
+          MAYBE_REDRAW (menu->redraw);
+        }
+      }
+      break;
 
     case OP_DELETE_MAILBOX:
-       if (!state.entry[menu->current].imap)
-         mutt_error (_("Delete is only supported for IMAP mailboxes"));
-       else
-        {
-         char msg[SHORT_STRING];
-         IMAP_MBOX mx;
-         int nentry = menu->current;
-         
-         imap_parse_path (state.entry[nentry].name, &mx);
-         snprintf (msg, sizeof (msg), _("Really delete mailbox \"%s\"?"),
-            mx.mbox);
-         if (mutt_yesorno (msg, M_NO) == M_YES)
-          {
-           if (!imap_delete_mailbox (Context, mx))
-            {
-             /* free the mailbox from the browser */
-             FREE (&((state.entry)[nentry].name));
-             FREE (&((state.entry)[nentry].desc));
-             /* and move all other entries up */
-             if (nentry+1 < state.entrylen)
-               memmove (state.entry + nentry, state.entry + nentry + 1,
-                  sizeof (struct folder_file) * (state.entrylen - (nentry+1)));
-             state.entrylen--;
-             mutt_message _("Mailbox deleted.");
-             init_menu (&state, menu, title, sizeof (title), buffy);
-             MAYBE_REDRAW (menu->redraw);
-           }
-         }
-         else
-           mutt_message _("Mailbox not deleted.");
-         FREE (&mx.mbox);
+      if (!state.entry[menu->current].imap)
+        mutt_error (_("Delete is only supported for IMAP mailboxes"));
+      else {
+        char msg[SHORT_STRING];
+        IMAP_MBOX mx;
+        int nentry = menu->current;
+
+        imap_parse_path (state.entry[nentry].name, &mx);
+        snprintf (msg, sizeof (msg), _("Really delete mailbox \"%s\"?"),
+                  mx.mbox);
+        if (mutt_yesorno (msg, M_NO) == M_YES) {
+          if (!imap_delete_mailbox (Context, mx)) {
+            /* free the mailbox from the browser */
+            FREE (&((state.entry)[nentry].name));
+            FREE (&((state.entry)[nentry].desc));
+            /* and move all other entries up */
+            if (nentry + 1 < state.entrylen)
+              memmove (state.entry + nentry, state.entry + nentry + 1,
+                       sizeof (struct folder_file) * (state.entrylen -
+                                                      (nentry + 1)));
+            state.entrylen--;
+            mutt_message _("Mailbox deleted.");
+
+            init_menu (&state, menu, title, sizeof (title), buffy);
+            MAYBE_REDRAW (menu->redraw);
+          }
         }
-        break;
+        else
+          mutt_message _("Mailbox not deleted.");
+        FREE (&mx.mbox);
+      }
+      break;
 #endif
-      
-      case OP_CHANGE_DIRECTORY:
+
+    case OP_CHANGE_DIRECTORY:
 
 #ifdef USE_NNTP
-       if (option (OPTNEWS))
-         break;
+      if (option (OPTNEWS))
+        break;
 #endif
 
-       strfcpy (buf, LastDir, sizeof (buf));
+      strfcpy (buf, LastDir, sizeof (buf));
 #ifdef USE_IMAP
-       if (!state.imap_browse)
+      if (!state.imap_browse)
 #endif
-       {
-         /* add '/' at the end of the directory name if not already there */
-         int len=mutt_strlen(LastDir);
-         if (len && LastDir[len-1] != '/' && sizeof (buf) > len)
-           buf[len]='/';
-       }
-
-       if (mutt_get_field (_("Chdir to: "), buf, sizeof (buf), M_FILE) == 0 &&
-           buf[0])
-       {
-         buffy = 0;      
-         mutt_expand_path (buf, sizeof (buf));
+      {
+        /* add '/' at the end of the directory name if not already there */
+        int len = mutt_strlen (LastDir);
+
+        if (len && LastDir[len - 1] != '/' && sizeof (buf) > len)
+          buf[len] = '/';
+      }
+
+      if (mutt_get_field (_("Chdir to: "), buf, sizeof (buf), M_FILE) == 0 &&
+          buf[0]) {
+        buffy = 0;
+        mutt_expand_path (buf, sizeof (buf));
 #ifdef USE_IMAP
-         if (mx_is_imap (buf))
-         {
-           strfcpy (LastDir, buf, sizeof (LastDir));
-           destroy_state (&state);
-           init_state (&state, NULL);
-           state.imap_browse = 1;
-           imap_browse (LastDir, &state);
-           menu->data = state.entry;
-           menu->current = 0; 
-           menu->top = 0; 
-           init_menu (&state, menu, title, sizeof (title), buffy);
-         }
-         else
+        if (mx_is_imap (buf)) {
+          strfcpy (LastDir, buf, sizeof (LastDir));
+          destroy_state (&state);
+          init_state (&state, NULL);
+          state.imap_browse = 1;
+          imap_browse (LastDir, &state);
+          menu->data = state.entry;
+          menu->current = 0;
+          menu->top = 0;
+          init_menu (&state, menu, title, sizeof (title), buffy);
+        }
+        else
 #endif
-         if (stat (buf, &st) == 0)
-         {
-           if (S_ISDIR (st.st_mode))
-           {
-             destroy_state (&state);
-             if (examine_directory (menu, &state, buf, prefix) == 0)
-               strfcpy (LastDir, buf, sizeof (LastDir));
-             else
-             {
-               mutt_error _("Error scanning directory.");
-               if (examine_directory (menu, &state, LastDir, prefix) == -1)
-               {
-                 mutt_menuDestroy (&menu);
-                 goto bail;
-               }
-             }
-             menu->current = 0; 
-             menu->top = 0; 
-             init_menu (&state, menu, title, sizeof (title), buffy);
-           }
-           else
-             mutt_error (_("%s is not a directory."), buf);
-         }
-         else
-           mutt_perror (buf);
-       }
-       MAYBE_REDRAW (menu->redraw);
-       break;
-       
-      case OP_ENTER_MASK:
-
-       strfcpy (buf, NONULL(Mask.pattern), sizeof (buf));
-       if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0)
-       {
-         regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
-         char *s = buf;
-         int not = 0, err;
-
-         buffy = 0;
-         /* assume that the user wants to see everything */
-         if (!buf[0])
-           strfcpy (buf, ".", sizeof (buf));
-         SKIPWS (s);
-         if (*s == '!')
-         {
-           s++;
-           SKIPWS (s);
-           not = 1;
-         }
-
-         if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
-         {
-           regerror (err, rx, buf, sizeof (buf));
-           regfree (rx);
-           FREE (&rx);
-           mutt_error ("%s", buf);
-         }
-         else
-         {
-           mutt_str_replace (&Mask.pattern, buf);
-           regfree (Mask.rx);
-           FREE (&Mask.rx);
-           Mask.rx = rx;
-           Mask.not = not;
-
-           destroy_state (&state);
+        if (stat (buf, &st) == 0) {
+          if (S_ISDIR (st.st_mode)) {
+            destroy_state (&state);
+            if (examine_directory (menu, &state, buf, prefix) == 0)
+              strfcpy (LastDir, buf, sizeof (LastDir));
+            else {
+              mutt_error _("Error scanning directory.");
+
+              if (examine_directory (menu, &state, LastDir, prefix) == -1) {
+                mutt_menuDestroy (&menu);
+                goto bail;
+              }
+            }
+            menu->current = 0;
+            menu->top = 0;
+            init_menu (&state, menu, title, sizeof (title), buffy);
+          }
+          else
+            mutt_error (_("%s is not a directory."), buf);
+        }
+        else
+          mutt_perror (buf);
+      }
+      MAYBE_REDRAW (menu->redraw);
+      break;
+
+    case OP_ENTER_MASK:
+
+      strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
+      if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
+        regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+        char *s = buf;
+        int not = 0, err;
+
+        buffy = 0;
+        /* assume that the user wants to see everything */
+        if (!buf[0])
+          strfcpy (buf, ".", sizeof (buf));
+        SKIPWS (s);
+        if (*s == '!') {
+          s++;
+          SKIPWS (s);
+          not = 1;
+        }
+
+        if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
+          regerror (err, rx, buf, sizeof (buf));
+          regfree (rx);
+          FREE (&rx);
+          mutt_error ("%s", buf);
+        }
+        else {
+          mutt_str_replace (&Mask.pattern, buf);
+          regfree (Mask.rx);
+          FREE (&Mask.rx);
+          Mask.rx = rx;
+          Mask.not = not;
+
+          destroy_state (&state);
 #ifdef USE_IMAP
-           if (state.imap_browse)
-           {
-             init_state (&state, NULL);
-             state.imap_browse = 1;
-             imap_browse (LastDir, &state);
-             menu->data = state.entry;
-             init_menu (&state, menu, title, sizeof (title), buffy);
-           }
-           else
+          if (state.imap_browse) {
+            init_state (&state, NULL);
+            state.imap_browse = 1;
+            imap_browse (LastDir, &state);
+            menu->data = state.entry;
+            init_menu (&state, menu, title, sizeof (title), buffy);
+          }
+          else
 #endif
-           if (examine_directory (menu, &state, LastDir, NULL) == 0)
-             init_menu (&state, menu, title, sizeof (title), buffy);
-           else
-           {
-             mutt_error _("Error scanning directory.");
-             mutt_menuDestroy (&menu);
-             goto bail;
-           }
-           killPrefix = 0;
-           if (!state.entrylen)
-           {
-             mutt_error _("No files match the file mask");
-             break;
-           }
-         }
-       }
-       MAYBE_REDRAW (menu->redraw);
-       break;
-
-      case OP_SORT:
-      case OP_SORT_REVERSE:
-
-        {
-         int resort = 1;
-         int reverse = (i == OP_SORT_REVERSE);
-         
-         switch (mutt_multi_choice ((reverse) ?
-             _("Reverse sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? ") :
-             _("Sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "),
-             _("dazn")))
-         {
-           case -1: /* abort */
-             resort = 0;
-             break;
-
-            case 1: /* (d)ate */
-             BrowserSort = SORT_DATE;
-             break;
-
-            case 2: /* (a)lpha */
-             BrowserSort = SORT_SUBJECT;
-             break;
-
-            case 3: /* si(z)e */
-             BrowserSort = SORT_SIZE;
-             break;
-
-            case 4: /* do(n)'t sort */
-             BrowserSort = SORT_ORDER;
-             resort = 0;
-             break;
-         }
-         if (resort)
-         {
-           BrowserSort |= reverse ? SORT_REVERSE : 0;
-           browser_sort (&state);
-           menu->redraw = REDRAW_FULL;
-         }
-         break;
-       }
-
-      case OP_TOGGLE_MAILBOXES:
-       buffy = 1 - buffy;
-
-      case OP_CHECK_NEW:
-       destroy_state (&state);
-       prefix[0] = 0;
-       killPrefix = 0;
-
-       if (buffy)
-       {
-         if (examine_mailboxes (menu, &state) == -1)
-           goto bail;
-       }
+          if (examine_directory (menu, &state, LastDir, NULL) == 0)
+            init_menu (&state, menu, title, sizeof (title), buffy);
+          else {
+            mutt_error _("Error scanning directory.");
+
+            mutt_menuDestroy (&menu);
+            goto bail;
+          }
+          killPrefix = 0;
+          if (!state.entrylen) {
+            mutt_error _("No files match the file mask");
+
+            break;
+          }
+        }
+      }
+      MAYBE_REDRAW (menu->redraw);
+      break;
+
+    case OP_SORT:
+    case OP_SORT_REVERSE:
+
+      {
+        int resort = 1;
+        int reverse = (i == OP_SORT_REVERSE);
+
+        switch (mutt_multi_choice ((reverse) ?
+                                   _
+                                   ("Reverse sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? ")
+                                   :
+                                   _
+                                   ("Sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "),
+                                   _("dazn"))) {
+        case -1:               /* abort */
+          resort = 0;
+          break;
+
+        case 1:                /* (d)ate */
+          BrowserSort = SORT_DATE;
+          break;
+
+        case 2:                /* (a)lpha */
+          BrowserSort = SORT_SUBJECT;
+          break;
+
+        case 3:                /* si(z)e */
+          BrowserSort = SORT_SIZE;
+          break;
+
+        case 4:                /* do(n)'t sort */
+          BrowserSort = SORT_ORDER;
+          resort = 0;
+          break;
+        }
+        if (resort) {
+          BrowserSort |= reverse ? SORT_REVERSE : 0;
+          browser_sort (&state);
+          menu->redraw = REDRAW_FULL;
+        }
+        break;
+      }
+
+    case OP_TOGGLE_MAILBOXES:
+      buffy = 1 - buffy;
+
+    case OP_CHECK_NEW:
+      destroy_state (&state);
+      prefix[0] = 0;
+      killPrefix = 0;
+
+      if (buffy) {
+        if (examine_mailboxes (menu, &state) == -1)
+          goto bail;
+      }
 #ifdef USE_IMAP
-       else if (mx_is_imap (LastDir))
-       {
-         init_state (&state, NULL);
-         state.imap_browse = 1;
-         imap_browse (LastDir, &state);
-         menu->data = state.entry;
-       }
+      else if (mx_is_imap (LastDir)) {
+        init_state (&state, NULL);
+        state.imap_browse = 1;
+        imap_browse (LastDir, &state);
+        menu->data = state.entry;
+      }
 #endif
-       else if (examine_directory (menu, &state, LastDir, prefix) == -1)
-         goto bail;
-       init_menu (&state, menu, title, sizeof (title), buffy);
-       break;
-
-      case OP_BUFFY_LIST:
-       mutt_buffy_list ();
-       break;
-
-      case OP_BROWSER_NEW_FILE:
-
-       snprintf (buf, sizeof (buf), "%s/", LastDir);
-       if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) == 0)
-       {
-         strfcpy (f, buf, flen);
-         destroy_state (&state);
-         mutt_menuDestroy (&menu);
-         goto bail;
-       }
-       MAYBE_REDRAW (menu->redraw);
-       break;
-
-      case OP_BROWSER_VIEW_FILE:
-       if (!state.entrylen)
-       {
-         mutt_error _("No files match the file mask");
-         break;
-       }
+      else if (examine_directory (menu, &state, LastDir, prefix) == -1)
+        goto bail;
+      init_menu (&state, menu, title, sizeof (title), buffy);
+      break;
+
+    case OP_BUFFY_LIST:
+      mutt_buffy_list ();
+      break;
+
+    case OP_BROWSER_NEW_FILE:
+
+      snprintf (buf, sizeof (buf), "%s/", LastDir);
+      if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) ==
+          0) {
+        strfcpy (f, buf, flen);
+        destroy_state (&state);
+        mutt_menuDestroy (&menu);
+        goto bail;
+      }
+      MAYBE_REDRAW (menu->redraw);
+      break;
+
+    case OP_BROWSER_VIEW_FILE:
+      if (!state.entrylen) {
+        mutt_error _("No files match the file mask");
+
+        break;
+      }
 
 #ifdef USE_IMAP
-       if (state.entry[menu->current].selectable)
-       {
-         strfcpy (f, state.entry[menu->current].name, flen);
-         destroy_state (&state);
-         mutt_menuDestroy (&menu);
-         goto bail;
-       }
-       else
+      if (state.entry[menu->current].selectable) {
+        strfcpy (f, state.entry[menu->current].name, flen);
+        destroy_state (&state);
+        mutt_menuDestroy (&menu);
+        goto bail;
+      }
+      else
 #endif
-        if (S_ISDIR (state.entry[menu->current].mode) ||
-           (S_ISLNK (state.entry[menu->current].mode) &&
-           link_is_dir (LastDir, state.entry[menu->current].name)))
-       {
-         mutt_error _("Can't view a directory");
-         break;
-       } 
-       else
-       {
-         BODY *b;
-         char buf[_POSIX_PATH_MAX];
-         
-         mutt_concat_path (buf, LastDir, state.entry[menu->current].name, sizeof (buf));
-         b = mutt_make_file_attach (buf);
-         if (b != NULL)
-         {
-           mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
-           mutt_free_body (&b);
-           menu->redraw = REDRAW_FULL;
-         }
-         else
-           mutt_error _("Error trying to view file");
-       }
-       break;
+      if (S_ISDIR (state.entry[menu->current].mode) ||
+            (S_ISLNK (state.entry[menu->current].mode) &&
+               link_is_dir (LastDir, state.entry[menu->current].name))) {
+        mutt_error _("Can't view a directory");
+
+        break;
+      }
+      else {
+        BODY *b;
+        char buf[_POSIX_PATH_MAX];
+
+        mutt_concat_path (buf, LastDir, state.entry[menu->current].name,
+                          sizeof (buf));
+        b = mutt_make_file_attach (buf);
+        if (b != NULL) {
+          mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
+          mutt_free_body (&b);
+          menu->redraw = REDRAW_FULL;
+        }
+        else
+          mutt_error _("Error trying to view file");
+      }
+      break;
 
 #ifdef USE_NNTP
-      case OP_CATCHUP:
-      case OP_UNCATCHUP:
-       if (option (OPTNEWS))
-       {
-         struct folder_file *f = &state.entry[menu->current];
-         NNTP_DATA *nd;
-
-         if (i == OP_CATCHUP)
-           nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
-         else
-           nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
-
-         if (nd)
-         {
+    case OP_CATCHUP:
+    case OP_UNCATCHUP:
+      if (option (OPTNEWS)) {
+        struct folder_file *f = &state.entry[menu->current];
+        NNTP_DATA *nd;
+
+        if (i == OP_CATCHUP)
+          nd = mutt_newsgroup_catchup (CurrentNewsSrv, f->name);
+        else
+          nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, f->name);
+
+        if (nd) {
 /*         FOLDER folder;
            struct folder_file ff;
            char buffer[_POSIX_PATH_MAX + SHORT_STRING];
@@ -1453,97 +1392,90 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
                  newsgroup_format_str, (unsigned long) &folder,
                  M_FORMAT_ARROWCURSOR);
            f->desc = safe_strdup (buffer); */
-           if (menu->current + 1 < menu->max)
-             menu->current++;
-           menu->redraw = REDRAW_MOTION_RESYNCH;
-         }
-       }
-       break;
-
-      case OP_LOAD_ACTIVE:
-       if (!option (OPTNEWS))
-         break;
-
-       {
-         LIST *tmp;
-         NNTP_DATA *data;
-
-         for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next)
-         {
-           if ((data = (NNTP_DATA *)tmp->data))
-             data->deleted = 1;
-         }
-       }
-       nntp_get_active (CurrentNewsSrv);
-
-       destroy_state (&state);
-       if (buffy)
-         examine_mailboxes (menu, &state);
-       else
-         examine_directory (menu, &state, NULL, NULL);
-       init_menu (&state, menu, title, sizeof (title), buffy);
-       break;
+          if (menu->current + 1 < menu->max)
+            menu->current++;
+          menu->redraw = REDRAW_MOTION_RESYNCH;
+        }
+      }
+      break;
+
+    case OP_LOAD_ACTIVE:
+      if (!option (OPTNEWS))
+        break;
+
+      {
+        LIST *tmp;
+        NNTP_DATA *data;
+
+        for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next) {
+          if ((data = (NNTP_DATA *) tmp->data))
+            data->deleted = 1;
+        }
+      }
+      nntp_get_active (CurrentNewsSrv);
+
+      destroy_state (&state);
+      if (buffy)
+        examine_mailboxes (menu, &state);
+      else
+        examine_directory (menu, &state, NULL, NULL);
+      init_menu (&state, menu, title, sizeof (title), buffy);
+      break;
 #endif /* USE_NNTP */
 
 #if defined USE_IMAP || defined USE_NNTP
-      case OP_BROWSER_SUBSCRIBE:
-      case OP_BROWSER_UNSUBSCRIBE:
+    case OP_BROWSER_SUBSCRIBE:
+    case OP_BROWSER_UNSUBSCRIBE:
 #endif
 #ifdef USE_NNTP
-      case OP_SUBSCRIBE_PATTERN:
-      case OP_UNSUBSCRIBE_PATTERN:
-        if (option (OPTNEWS))
-       {
-         regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
-         char *s = buf;
-         int j = menu->current;
-         NNTP_DATA *nd;
-         NNTP_SERVER *news = CurrentNewsSrv;
-
-         if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN)
-         {
-           char tmp[STRING];
-           int err;
-
-           buf[0] = 0;
-           if (i == OP_SUBSCRIBE_PATTERN)
-             snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
-           else
-             snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
-           if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0])
-           {
-             FREE (&rx);
-             break;
-           }
-
-           if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0)
-           {
-             regerror (err, rx, buf, sizeof (buf));
-             regfree (rx);
-             FREE (&rx);
-             mutt_error ("%s", buf);
-             break;
-           }
-           menu->redraw = REDRAW_FULL;
-           j = 0;
-         }
-         else if (!state.entrylen)
-         {
-           mutt_error _("No newsgroups match the mask");
-           break;
-         }
-
-         for ( ; j < state.entrylen; j++)
-         {
-           struct folder_file *f = &state.entry[j];
-
-           if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
-                 regexec (rx, f->name, 0, NULL, 0) == 0)
-           {
-             if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
-               nd = mutt_newsgroup_subscribe (news, f->name);
-             else
-               nd = mutt_newsgroup_unsubscribe (news, f->name);
+    case OP_SUBSCRIBE_PATTERN:
+    case OP_UNSUBSCRIBE_PATTERN:
+      if (option (OPTNEWS)) {
+        regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+        char *s = buf;
+        int j = menu->current;
+        NNTP_DATA *nd;
+        NNTP_SERVER *news = CurrentNewsSrv;
+
+        if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) {
+          char tmp[STRING];
+          int err;
+
+          buf[0] = 0;
+          if (i == OP_SUBSCRIBE_PATTERN)
+            snprintf (tmp, sizeof (tmp), _("Subscribe pattern: "));
+          else
+            snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
+          if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) {
+            FREE (&rx);
+            break;
+          }
+
+          if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
+            regerror (err, rx, buf, sizeof (buf));
+            regfree (rx);
+            FREE (&rx);
+            mutt_error ("%s", buf);
+            break;
+          }
+          menu->redraw = REDRAW_FULL;
+          j = 0;
+        }
+        else if (!state.entrylen) {
+          mutt_error _("No newsgroups match the mask");
+
+          break;
+        }
+
+        for (; j < state.entrylen; j++) {
+          struct folder_file *f = &state.entry[j];
+
+          if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE ||
+              regexec (rx, f->name, 0, NULL, 0) == 0) {
+            if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN)
+              nd = mutt_newsgroup_subscribe (news, f->name);
+            else
+              nd = mutt_newsgroup_unsubscribe (news, f->name);
 /*           if (nd)
              {
                FOLDER folder;
@@ -1559,59 +1491,54 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
                        M_FORMAT_ARROWCURSOR);
                f->desc = safe_strdup (buffer);
              } */
-           }
-           if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE)
-           {
-             if (menu->current + 1 < menu->max)
-               menu->current++;
-             menu->redraw = REDRAW_MOTION_RESYNCH;
-             break;
-           }
-         }
-         if (i == OP_SUBSCRIBE_PATTERN)
-         {
-           LIST *grouplist = NULL;
-
-           if (news)
-             grouplist = news->list;
-           for (; grouplist; grouplist = grouplist->next)
-           {
-             nd = (NNTP_DATA *) grouplist->data;
-             if (nd && nd->group && !nd->subscribed)
-             {
-               if (regexec (rx, nd->group, 0, NULL, 0) == 0)
-               {
-                 mutt_newsgroup_subscribe (news, nd->group);
-                 add_folder (menu, &state, nd->group, NULL, nd, nd->new);
-               }
-             }
-           }
-           init_menu (&state, menu, title, sizeof (title), buffy);
-         }
-         mutt_newsrc_update (news);
-         nntp_clear_cacheindex (news);
-         if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
-           regfree (rx);
-         FREE (&rx);
-       }
+          }
+          if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) {
+            if (menu->current + 1 < menu->max)
+              menu->current++;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
+            break;
+          }
+        }
+        if (i == OP_SUBSCRIBE_PATTERN) {
+          LIST *grouplist = NULL;
+
+          if (news)
+            grouplist = news->list;
+          for (; grouplist; grouplist = grouplist->next) {
+            nd = (NNTP_DATA *) grouplist->data;
+            if (nd && nd->group && !nd->subscribed) {
+              if (regexec (rx, nd->group, 0, NULL, 0) == 0) {
+                mutt_newsgroup_subscribe (news, nd->group);
+                add_folder (menu, &state, nd->group, NULL, nd, nd->new);
+              }
+            }
+          }
+          init_menu (&state, menu, title, sizeof (title), buffy);
+        }
+        mutt_newsrc_update (news);
+        nntp_clear_cacheindex (news);
+        if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
+          regfree (rx);
+        FREE (&rx);
+      }
 #ifdef USE_IMAP
-       else
+      else
 #endif /* USE_IMAP && USE_NNTP */
 #endif /* USE_NNTP */
 #ifdef USE_IMAP
-       {
-         if (i == OP_BROWSER_SUBSCRIBE)
-           imap_subscribe (state.entry[menu->current].name, 1);
-         else
-           imap_subscribe (state.entry[menu->current].name, 0);
-       }
+      {
+        if (i == OP_BROWSER_SUBSCRIBE)
+          imap_subscribe (state.entry[menu->current].name, 1);
+        else
+          imap_subscribe (state.entry[menu->current].name, 0);
+      }
 #endif /* USE_IMAP */
     }
   }
-  
-  bail:
-  
+
+bail:
+
   if (!folder)
     strfcpy (LastDir, LastDirBackup, sizeof (LastDir));
-  
+
 }
index dbc5726..cbfe9a3 100644 (file)
--- a/browser.h
+++ b/browser.h
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _BROWSER_H
 #define _BROWSER_H 1
@@ -24,8 +24,7 @@
 #include "nntp.h"
 #endif
 
-struct folder_file
-{
+struct folder_file {
   mode_t mode;
   off_t size;
   time_t mtime;
@@ -37,28 +36,27 @@ struct folder_file
   unsigned short new;
 #ifdef USE_IMAP
   char delim;
-  
-  unsigned imap : 1;
-  unsigned selectable : 1;
-  unsigned inferiors : 1;
+
+  unsigned imap:1;
+  unsigned selectable:1;
+  unsigned inferiors:1;
 #endif
 #ifdef USE_NNTP
   NNTP_DATA *nd;
 #endif
-  unsigned tagged : 1;
+  unsigned tagged:1;
 };
 
-struct browser_state
-{
+struct browser_state {
   struct folder_file *entry;
-  unsigned int entrylen; /* number of real entries */
-  unsigned int entrymax; /* max entry */
+  unsigned int entrylen;        /* number of real entries */
+  unsigned int entrymax;        /* max entry */
 #ifdef USE_IMAP
   short imap_browse;
   char *folder;
-  unsigned noselect : 1;
-  unsigned marked : 1;
-  unsigned unmarked : 1;
+  unsigned noselect:1;
+  unsigned marked:1;
+  unsigned unmarked:1;
 #endif
 };
 
diff --git a/buffy.c b/buffy.c
index c955ab9..48927d1 100644 (file)
--- a/buffy.c
+++ b/buffy.c
 
 #include <stdio.h>
 
-static time_t BuffyTime = 0;            /* last time we started checking for mail */
+static time_t BuffyTime = 0;    /* last time we started checking for mail */
+
 #ifdef USE_IMAP
 static time_t ImapBuffyTime = 0;        /* last time we started checking for mail */
 #endif
-static short BuffyCount = 0;            /* how many boxes with new mail */
-static short BuffyNotify = 0;           /* # of unnotified new boxes */
+static short BuffyCount = 0;    /* how many boxes with new mail */
+static short BuffyNotify = 0;   /* # of unnotified new boxes */
 
 #ifdef BUFFY_SIZE
 
@@ -56,11 +57,11 @@ static short BuffyNotify = 0;           /* # of unnotified new boxes */
 int fseek_last_message (FILE * f)
 {
   long int pos;
-  char buffer[BUFSIZ + 9];     /* 7 for "\n\nFrom " */
+  char buffer[BUFSIZ + 9];      /* 7 for "\n\nFrom " */
   int bytes_read;
-  int i;                       /* Index into `buffer' for scanning.  */
+  int i;                        /* Index into `buffer' for scanning.  */
 
-  memset (buffer, 0, sizeof(buffer));
+  memset (buffer, 0, sizeof (buffer));
   fseek (f, 0, SEEK_END);
   pos = ftell (f);
 
@@ -71,26 +72,23 @@ int fseek_last_message (FILE * f)
     bytes_read = BUFSIZ;
   /* Make `pos' a multiple of `BUFSIZ' (0 if the file is short), so that all
    * reads will be on block boundaries, which might increase efficiency.  */
-  while ((pos -= bytes_read) >= 0)
-  {
+  while ((pos -= bytes_read) >= 0) {
     /* we save in the buffer at the end the first 7 chars from the last read */
-    strncpy (buffer + BUFSIZ, buffer, 5+2); /* 2 == 2 * mutt_strlen(CRLF) */
+    strncpy (buffer + BUFSIZ, buffer, 5 + 2);   /* 2 == 2 * mutt_strlen(CRLF) */
     fseek (f, pos, SEEK_SET);
     bytes_read = fread (buffer, sizeof (char), bytes_read, f);
     if (bytes_read == -1)
       return -1;
     for (i = bytes_read; --i >= 0;)
-      if (!mutt_strncmp (buffer + i, "\n\nFrom ", mutt_strlen ("\n\nFrom ")))
-      {                                /* found it - go to the beginning of the From */
-       fseek (f, pos + i + 2, SEEK_SET);
-       return 0;
+      if (!mutt_strncmp (buffer + i, "\n\nFrom ", mutt_strlen ("\n\nFrom "))) { /* found it - go to the beginning of the From */
+        fseek (f, pos + i + 2, SEEK_SET);
+        return 0;
       }
     bytes_read = BUFSIZ;
   }
 
   /* here we are at the beginning of the file */
-  if (!mutt_strncmp ("From ", buffer, 5))
-  {
+  if (!mutt_strncmp ("From ", buffer, 5)) {
     fseek (f, 0, 0);
     return (0);
   }
@@ -102,7 +100,7 @@ int fseek_last_message (FILE * f)
 int test_last_status_new (FILE * f)
 {
   HEADER *hdr;
-  ENVELOPEtmp_envelope;
+  ENVELOPE *tmp_envelope;
   int result = 0;
 
   if (fseek_last_message (f) == -1)
@@ -113,7 +111,7 @@ int test_last_status_new (FILE * f)
   if (!(hdr->read || hdr->old))
     result = 1;
 
-  mutt_free_envelope(&tmp_envelope);
+  mutt_free_envelope (&tmp_envelope);
   mutt_free_header (&hdr);
 
   return result;
@@ -130,8 +128,7 @@ int test_new_folder (const char *path)
   if (typ != M_MBOX && typ != M_MMDF)
     return 0;
 
-  if ((f = fopen (path, "rb")))
-  {
+  if ((f = fopen (path, "rb"))) {
     rc = test_last_status_new (f);
     fclose (f);
   }
@@ -144,14 +141,13 @@ BUFFY *mutt_find_mailbox (const char *path)
   BUFFY *tmp = NULL;
   struct stat sb;
   struct stat tmp_sb;
-  
-  if (stat (path,&sb) != 0)
+
+  if (stat (path, &sb) != 0)
     return NULL;
 
-  for (tmp = Incoming; tmp; tmp = tmp->next)
-  {
-    if (stat (tmp->path,&tmp_sb) ==0 && 
-       sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
+  for (tmp = Incoming; tmp; tmp = tmp->next) {
+    if (stat (tmp->path, &tmp_sb) == 0 &&
+        sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
       break;
   }
   return tmp;
@@ -172,27 +168,26 @@ void mutt_update_mailbox (BUFFY * b)
 }
 #endif
 
-int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data,
+                          BUFFER * err)
 {
-  BUFFY **tmp,*tmp1;
+  BUFFY **tmp, *tmp1;
   char buf[_POSIX_PATH_MAX];
+
 #ifdef BUFFY_SIZE
   struct stat sb;
 #endif /* BUFFY_SIZE */
 
-  while (MoreArgs (s))
-  {
+  while (MoreArgs (s)) {
     mutt_extract_token (path, s, 0);
     strfcpy (buf, path->data, sizeof (buf));
 
-    if(data == M_UNMAILBOXES && mutt_strcmp(buf,"*") == 0)
-    {
-      for (tmp = &Incoming; *tmp;)
-      {
+    if (data == M_UNMAILBOXES && mutt_strcmp (buf, "*") == 0) {
+      for (tmp = &Incoming; *tmp;) {
         FREE (&((*tmp)->path));
-        tmp1=(*tmp)->next;
+        tmp1 = (*tmp)->next;
         FREE (tmp);
-        *tmp=tmp1;
+        *tmp = tmp1;
       }
       return 0;
     }
@@ -200,35 +195,32 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
     mutt_expand_path (buf, sizeof (buf));
 
     /* Skip empty tokens. */
-    if(!*buf) continue;
+    if (!*buf)
+      continue;
 
     /* simple check to avoid duplicates */
-    for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
-    {
+    for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) {
       if (mutt_strcmp (buf, (*tmp)->path) == 0)
-       break;
+        break;
     }
 
-    if(data == M_UNMAILBOXES)
-    {
-      if(*tmp)
-      {
+    if (data == M_UNMAILBOXES) {
+      if (*tmp) {
         FREE (&((*tmp)->path));
-        tmp1=(*tmp)->next;
+        tmp1 = (*tmp)->next;
         FREE (tmp);
-        *tmp=tmp1;
+        *tmp = tmp1;
       }
       continue;
     }
 
-    if (!*tmp)
-    {
+    if (!*tmp) {
       *tmp = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
       (*tmp)->path = safe_strdup (buf);
       (*tmp)->next = NULL;
       /* it is tempting to set magic right here */
       (*tmp)->magic = 0;
-      
+
     }
 
     (*tmp)->new = 0;
@@ -240,8 +232,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
      * reading it), the size is set to 0 so that later when we check we see
      * that it increased .  without buffy_size we probably don't care.
      */
-    if (stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path))
-    {
+    if (stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path)) {
       /* some systems out there don't have an off_t type */
       (*tmp)->size = (long) sb.st_size;
     }
@@ -276,8 +267,10 @@ int mutt_buffy_check (int force)
   struct stat contex_sb;
   time_t now, last1;
   CONTEXT *ctx;
+
 #ifdef USE_IMAP
   time_t last2;
+
   /* update postponed count as well, on force */
   if (force != 0)
     mutt_update_num_postponed ();
@@ -291,7 +284,7 @@ int mutt_buffy_check (int force)
 #ifdef USE_IMAP
       && (now - ImapBuffyTime < ImapBuffyTimeout))
 #else
-      )
+    )
 #endif
     return BuffyCount;
 
@@ -310,20 +303,19 @@ int mutt_buffy_check (int force)
   if (!Context || Context->magic != M_IMAP)
 #endif
 #ifdef USE_POP
-  if (!Context || Context->magic != M_POP)
+    if (!Context || Context->magic != M_POP)
 #endif
 #ifdef USE_NNTP
-  if (!Context || Context->magic != M_NNTP)
+      if (!Context || Context->magic != M_NNTP)
 #endif
-  /* check device ID and serial number instead of comparing paths */
-  if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0)
-  {
-    contex_sb.st_dev=0;
-    contex_sb.st_ino=0;
-  }
-  
-  for (tmp = Incoming; tmp; tmp = tmp->next)
-  {
+        /* check device ID and serial number instead of comparing paths */
+        if (!Context || !Context->path
+            || stat (Context->path, &contex_sb) != 0) {
+          contex_sb.st_dev = 0;
+          contex_sb.st_ino = 0;
+        }
+
+  for (tmp = Incoming; tmp; tmp = tmp->next) {
 #ifdef USE_IMAP
     if (mx_is_imap (tmp->path))
       tmp->magic = M_IMAP;
@@ -340,8 +332,7 @@ int mutt_buffy_check (int force)
     else
 #endif
     if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
-       (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
-    {
+          (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) {
       /* if the mailbox still doesn't exist, set the newly created flag to
        * be ready for when it does. */
       tmp->newly_created = 1;
@@ -354,25 +345,31 @@ int mutt_buffy_check (int force)
 
     /* check to see if the folder is the currently selected folder
      * before polling */
-    if (!Context || !Context->path ||
-         (
-           (0
+    if (!Context || !Context->path || ((0
 #ifdef USE_IMAP
-            || tmp->magic == M_IMAP
+                                        || tmp->magic == M_IMAP
 #endif
 #ifdef USE_POP
-            || tmp->magic == M_POP
+                                        || tmp->magic == M_POP
 #endif
 #ifdef USE_NNTP
-            || tmp->magic == M_NNTP
+                                        || tmp->magic == M_NNTP
 #endif
-           ) ? mutt_strcmp (tmp->path, Context->path) :
-               (sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)
-         )
-       )
-    {
-      switch (tmp->magic)
-      {
+                                       )? 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:
         /* only check on force or $mail_check reached */
@@ -383,17 +380,19 @@ int mutt_buffy_check (int force)
               tmp->new = 1;
             }
 #ifdef BUFFY_SIZE
-            else
-            {
+            else {
               /* some other program has deleted mail from the folder */
               tmp->size = (long) sb.st_size;
             }
 #endif
-          } else if (SidebarWidth > 0 && option (OPTMBOXPANE) && 
-                    (STAT_CHECK || tmp->msgcount == 0)) {
+          }
+          else if (SidebarWidth > 0 && option (OPTMBOXPANE) &&
+                   (STAT_CHECK || tmp->msgcount == 0)) {
             /* sidebar visible */
             BuffyCount++;
-            if ((ctx = mx_open_mailbox (tmp->path, M_READONLY | M_QUIET | M_NOSORT, NULL)) != NULL) {
+            if ((ctx =
+                 mx_open_mailbox (tmp->path, M_READONLY | M_QUIET | M_NOSORT,
+                                  NULL)) != NULL) {
               tmp->msgcount = ctx->msgcount;
               tmp->new = ctx->new;
               tmp->msg_unread = ctx->new;       /* for sidebar, wtf? */
@@ -404,7 +403,8 @@ int mutt_buffy_check (int force)
           if (tmp->newly_created &&
               (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
             tmp->newly_created = 0;
-        } else if (tmp->new > 0)
+        }
+        else if (tmp->new > 0)
           BuffyCount++;
         break;
 
@@ -412,23 +412,20 @@ int mutt_buffy_check (int force)
         /* only check on force or $mail_check reached */
         if (force != 0 || (now - last1 >= BuffyTimeout)) {
           snprintf (path, sizeof (path), "%s/new", tmp->path);
-          if ((dirp = opendir (path)) == NULL)
-          {
+          if ((dirp = opendir (path)) == NULL) {
             tmp->magic = 0;
             break;
           }
           tmp->new = 0;
           tmp->msg_unread = 0;
           tmp->msgcount = 0;
-          while ((de = readdir (dirp)) != NULL)
-          {
+          while ((de = readdir (dirp)) != NULL) {
             char *p;
-            if (*de->d_name != '.' && 
-                (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
-            {
+
+            if (*de->d_name != '.' &&
+                (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T'))) {
               /* one new and undeleted message is enough */
-              if (tmp->new == 0)
-              {
+              if (tmp->new == 0) {
                 BuffyCount++;
                 tmp->new = 1;
                 if (SidebarWidth == 0 || !option (OPTMBOXPANE))
@@ -442,20 +439,19 @@ int mutt_buffy_check (int force)
           }
           closedir (dirp);
 
-          if (SidebarWidth > 0 && option (OPTMBOXPANE))
-          {
+          if (SidebarWidth > 0 && option (OPTMBOXPANE)) {
             /* only count total mail if sidebar visible */
             snprintf (path, sizeof (path), "%s/cur", tmp->path);
-            if ((dirp = opendir (path)) == NULL)
-            {
+            if ((dirp = opendir (path)) == NULL) {
               tmp->magic = 0;
               break;
             }
             tmp->msg_flagged = 0;
-            while ((de = readdir (dirp)) != NULL)
-            {
+            while ((de = readdir (dirp)) != NULL) {
               char *p;
-              if (*de->d_name != '.' && (p = strstr (de->d_name, ":2,")) != NULL) {
+
+              if (*de->d_name != '.'
+                  && (p = strstr (de->d_name, ":2,")) != NULL) {
                 if (!strchr (p + 3, 'T'))
                   tmp->msgcount++;
                 if (strchr (p + 3, 'F'))
@@ -464,7 +460,8 @@ int mutt_buffy_check (int force)
             }
             closedir (dirp);
           }
-        } else if (tmp->new > 0)
+        }
+        else if (tmp->new > 0)
           /* keep current stats if !force and !$mail_check reached */
           BuffyCount++;
         break;
@@ -474,19 +471,17 @@ int mutt_buffy_check (int force)
         if (force != 0 || (now - last1 >= BuffyTimeout)) {
           if ((tmp->new = mh_buffy (tmp->path)) > 0)
             BuffyCount++;
-          if (SidebarWidth > 0 && option (OPTMBOXPANE))
-          {
+          if (SidebarWidth > 0 && option (OPTMBOXPANE)) {
             DIR *dp;
             struct dirent *de;
+
             if ((dp = opendir (path)) == NULL)
               break;
             tmp->new = 0;
             tmp->msgcount = 0;
             tmp->msg_unread = 0;
-            while ((de = readdir (dp)))
-            {
-              if (mh_valid_message (de->d_name))
-              {
+            while ((de = readdir (dp))) {
+              if (mh_valid_message (de->d_name)) {
                 tmp->msgcount++;
                 tmp->msg_unread++;
                 tmp->new++;
@@ -494,7 +489,8 @@ int mutt_buffy_check (int force)
             }
             closedir (dp);
           }
-        } else if (tmp->new > 0)
+        }
+        else if (tmp->new > 0)
           /* keep current stats if !force and !$mail_check reached */
           BuffyCount++;
         break;
@@ -512,7 +508,8 @@ int mutt_buffy_check (int force)
             tmp->new = 0;
             tmp->msg_unread = 0;
           }
-        } else if (tmp->new > 0)
+        }
+        else if (tmp->new > 0)
           /* keep current stats if !force and !$imap_mail_check reached */
           BuffyCount++;
         break;
@@ -531,7 +528,7 @@ int mutt_buffy_check (int force)
     }
 #ifdef BUFFY_SIZE
     else if (Context && Context->path)
-      tmp->size = (long) sb.st_size;   /* update the size */
+      tmp->size = (long) sb.st_size;    /* update the size */
 #endif
 
     if (tmp->new <= 0)
@@ -561,37 +558,33 @@ int mutt_buffy_list (void)
   first = 1;
   buffylist[0] = 0;
   pos += strlen (strncat (buffylist, _("New mail in "), sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
-  for (tmp = Incoming; tmp; tmp = tmp->next)
-  {
+  for (tmp = Incoming; tmp; tmp = tmp->next) {
     /* Is there new mail in this mailbox? */
     if (tmp->new <= 0 || (have_unnotified && tmp->notified))
       continue;
 
     strfcpy (path, tmp->path, sizeof (path));
     mutt_pretty_mailbox (path);
-    
+
     if (!first && pos + strlen (path) >= COLS - 7)
       break;
-    
+
     if (!first)
-      pos += strlen (strncat(buffylist + pos, ", ", sizeof(buffylist)-1-pos)); /* __STRNCAT_CHECKED__ */
+      pos += strlen (strncat (buffylist + pos, ", ", sizeof (buffylist) - 1 - pos));    /* __STRNCAT_CHECKED__ */
 
     /* Prepend an asterisk to mailboxes not already notified */
-    if (!tmp->notified)
-    {
+    if (!tmp->notified) {
       /* pos += strlen (strncat(buffylist + pos, "*", sizeof(buffylist)-1-pos));  __STRNCAT_CHECKED__ */
       tmp->notified = 1;
       BuffyNotify--;
     }
-    pos += strlen (strncat(buffylist + pos, path, sizeof(buffylist)-1-pos)); /* __STRNCAT_CHECKED__ */
+    pos += strlen (strncat (buffylist + pos, path, sizeof (buffylist) - 1 - pos));      /* __STRNCAT_CHECKED__ */
     first = 0;
   }
-  if (!first && tmp)
-  {
-    strncat (buffylist + pos, ", ...", sizeof (buffylist) - 1 - pos); /* __STRNCAT_CHECKED__ */
+  if (!first && tmp) {
+    strncat (buffylist + pos, ", ...", sizeof (buffylist) - 1 - pos);   /* __STRNCAT_CHECKED__ */
   }
-  if (!first)
-  {
+  if (!first) {
     /* on new mail: redraw sidebar */
     draw_sidebar (CurrentMenu);
     mutt_message ("%s", buffylist);
@@ -606,8 +599,7 @@ int mutt_buffy_list (void)
 
 int mutt_buffy_notify (void)
 {
-  if (mutt_buffy_check (0) && BuffyNotify)
-  {
+  if (mutt_buffy_check (0) && BuffyNotify) {
     return (mutt_buffy_list ());
   }
   return (0);
@@ -625,8 +617,7 @@ void mutt_buffy (char *s, size_t slen)
   BUFFY *tmp = Incoming;
 
   mutt_expand_path (s, _POSIX_PATH_MAX);
-  switch (mutt_buffy_check (0))
-  {
+  switch (mutt_buffy_check (0)) {
   case 0:
 
     *s = '\0';
@@ -636,10 +627,9 @@ void mutt_buffy (char *s, size_t slen)
 
     while (tmp && tmp->new <= 0)
       tmp = tmp->next;
-    if (!tmp)
-    {
+    if (!tmp) {
       *s = '\0';
-      mutt_buffy_check (1); /* buffy was wrong - resync things */
+      mutt_buffy_check (1);     /* buffy was wrong - resync things */
       break;
     }
     strfcpy (s, tmp->path, slen);
@@ -647,25 +637,22 @@ void mutt_buffy (char *s, size_t slen)
     break;
 
   default:
-    
+
     count = 0;
-    while (count < 3)
-    {
+    while (count < 3) {
       if (mutt_strcmp (s, tmp->path) == 0)
-       count++;
+        count++;
       else if (count && tmp->new > 0)
-       break;
+        break;
       tmp = tmp->next;
-      if (!tmp)
-      {
-       tmp = Incoming;
-       count++;
+      if (!tmp) {
+        tmp = Incoming;
+        count++;
       }
     }
-    if (count >= 3)
-    {
+    if (count >= 3) {
       *s = '\0';
-      mutt_buffy_check (1); /* buffy was wrong - resync things */
+      mutt_buffy_check (1);     /* buffy was wrong - resync things */
       break;
     }
     strfcpy (s, tmp->path, slen);
diff --git a/buffy.h b/buffy.h
index 94a325c..a8dd0d9 100644 (file)
--- a/buffy.h
+++ b/buffy.h
 
 /*parameter to mutt_parse_mailboxes*/
 #define M_MAILBOXES   1
-#define M_UNMAILBOXES 2 
+#define M_UNMAILBOXES 2
 
-typedef struct buffy_t
-{
+typedef struct buffy_t {
   char *path;
 #ifdef BUFFY_SIZE
   long size;
-#endif                         /* BUFFY_SIZE */
+#endif                          /* BUFFY_SIZE */
   struct buffy_t *next;
   struct buffy_t *prev;
-  short new;                   /* mailbox has new mail */
-  short has_new;               /* set it new if new and not read */
-  int msgcount;                        /* total number of messages */
-  int msg_unread;              /* number of unread messages */
-  int msg_flagged;             /* number of flagged messages */
-  short notified;              /* user has been notified */
-  short magic;                 /* mailbox type */
-  short newly_created;         /* mbox or mmdf just popped into existence */
-}
-BUFFY;
+  short new;                    /* mailbox has new mail */
+  short has_new;                /* set it new if new and not read */
+  int msgcount;                 /* total number of messages */
+  int msg_unread;               /* number of unread messages */
+  int msg_flagged;              /* number of flagged messages */
+  short notified;               /* user has been notified */
+  short magic;                  /* mailbox type */
+  short newly_created;          /* mbox or mmdf just popped into existence */
+} BUFFY;
 
 WHERE BUFFY *Incoming INITVAL (0);
 WHERE short BuffyTimeout INITVAL (3);
 
-extern time_t BuffyDoneTime;   /* last time we knew for sure how much mail there was */
+extern time_t BuffyDoneTime;    /* last time we knew for sure how much mail there was */
 
 #ifdef BUFFY_SIZE
 BUFFY *mutt_find_mailbox (const char *path);
index c211563..3fd4628 100644 (file)
--- a/charset.c
+++ b/charset.c
  * a preferred MIME name is given.
  */
 
-static struct 
-{
+static struct {
   char *key;
   char *pref;
-}
-PreferredMIMENames[] = 
-{
-  { "ansi_x3.4-1968",  "us-ascii"      },
-  { "iso-ir-6",                "us-ascii"      },
-  { "iso_646.irv:1991",        "us-ascii"      },
-  { "ascii",           "us-ascii"      },
-  { "iso646-us",       "us-ascii"      },
-  { "us",              "us-ascii"      },
-  { "ibm367",          "us-ascii"      },
-  { "cp367",           "us-ascii"      },
-  { "csASCII",         "us-ascii"      },
-  
-  { "csISO2022KR",     "iso-2022-kr"   },
-  { "csEUCKR",         "euc-kr"        },
-  { "csISO2022JP",     "iso-2022-jp"   },
-  { "csISO2022JP2",    "iso-2022-jp-2" },
-
-  { "ISO_8859-1:1987", "iso-8859-1"    },
-  { "iso-ir-100",      "iso-8859-1"    },
-  { "iso_8859-1",      "iso-8859-1"    },
-  { "latin1",          "iso-8859-1"    },
-  { "l1",              "iso-8859-1"    },
-  { "IBM819",          "iso-8859-1"    },
-  { "CP819",           "iso-8859-1"    },
-  { "csISOLatin1",     "iso-8859-1"    },
-  
-  { "ISO_8859-2:1987", "iso-8859-2"    },
-  { "iso-ir-101",      "iso-8859-2"    },
-  { "iso_8859-2",      "iso-8859-2"    },
-  { "latin2",          "iso-8859-2"    },
-  { "l2",              "iso-8859-2"    },
-  { "csISOLatin2",     "iso-8859-2"    },
-  
-  { "ISO_8859-3:1988", "iso-8859-3"    },
-  { "iso-ir-109",      "iso-8859-3"    },
-  { "ISO_8859-3",      "iso-8859-3"    },
-  { "latin3",          "iso-8859-3"    },
-  { "l3",              "iso-8859-3"    },
-  { "csISOLatin3",     "iso-8859-3"    },
-
-  { "ISO_8859-4:1988", "iso-8859-4"    },
-  { "iso-ir-110",      "iso-8859-4"    },
-  { "ISO_8859-4",      "iso-8859-4"    },
-  { "latin4",          "iso-8859-4"    },
-  { "l4",              "iso-8859-4"    },
-  { "csISOLatin4",     "iso-8859-4"    },
-
-  { "ISO_8859-6:1987", "iso-8859-6"    },
-  { "iso-ir-127",      "iso-8859-6"    },
-  { "iso_8859-6",      "iso-8859-6"    },
-  { "ECMA-114",                "iso-8859-6"    },
-  { "ASMO-708",                "iso-8859-6"    },
-  { "arabic",          "iso-8859-6"    },
-  { "csISOLatinArabic",        "iso-8859-6"    },
-  
-  { "ISO_8859-7:1987", "iso-8859-7"    },
-  { "iso-ir-126",      "iso-8859-7"    },
-  { "ISO_8859-7",      "iso-8859-7"    },
-  { "ELOT_928",                "iso-8859-7"    },
-  { "ECMA-118",                "iso-8859-7"    },
-  { "greek",           "iso-8859-7"    },
-  { "greek8",          "iso-8859-7"    },
-  { "csISOLatinGreek", "iso-8859-7"    },
-  
-  { "ISO_8859-8:1988", "iso-8859-8"    },
-  { "iso-ir-138",      "iso-8859-8"    },
-  { "ISO_8859-8",      "iso-8859-8"    },
-  { "hebrew",          "iso-8859-8"    },
-  { "csISOLatinHebrew",        "iso-8859-8"    },
-
-  { "ISO_8859-5:1988", "iso-8859-5"    },
-  { "iso-ir-144",      "iso-8859-5"    },
-  { "ISO_8859-5",      "iso-8859-5"    },
-  { "cyrillic",                "iso-8859-5"    },
-  { "csISOLatinCyrillic", "iso8859-5"  },
-
-  { "ISO_8859-9:1989", "iso-8859-9"    },
-  { "iso-ir-148",      "iso-8859-9"    },
-  { "ISO_8859-9",      "iso-8859-9"    },
-  { "latin5",          "iso-8859-9"    }, /* this is not a bug */
-  { "l5",              "iso-8859-9"    },
-  { "csISOLatin5",     "iso-8859-9"    },
-  
-  { "ISO_8859-10:1992",        "iso-8859-10"   },
-  { "iso-ir-157",      "iso-8859-10"   },
-  { "latin6",          "iso-8859-10"   }, /* this is not a bug */
-  { "l6",              "iso-8859-10"   },
-  { "csISOLatin6"      "iso-8859-10"   }, 
-  
-  { "csKOI8r",         "koi8-r"        },
-  
-  { "MS_Kanji",                "Shift_JIS"     }, /* Note the underscore! */
-  { "csShiftJis",      "Shift_JIS"     },
-  
-  { "Extended_UNIX_Code_Packed_Format_for_Japanese",
-                       "EUC-JP"        },
-  { "csEUCPkdFmtJapanese", 
-                       "EUC-JP"        },
-  
-  { "csGB2312",                "gb2312"        },
-  { "csbig5",          "big5"          },
-
-  /* 
-   * End of official brain damage.  What follows has been taken
-   * from glibc's localedata files. 
-   */
-
-  { "iso_8859-13",     "iso-8859-13"   },
-  { "iso-ir-179",      "iso-8859-13"   },
-  { "latin7",          "iso-8859-13"   }, /* this is not a bug */
-  { "l7",              "iso-8859-13"   },
-  
-  { "iso_8859-14",     "iso-8859-14"   },
-  { "latin8",          "iso-8859-14"   }, /* this is not a bug */
-  { "l8",              "iso-8859-14"   },
-
-  { "iso_8859-15",     "iso-8859-15"   },
-  { "latin9",          "iso-8859-15"   }, /* this is not a bug */
-
-  /* Suggested by Ionel Mugurel Ciobica <tgakic@sg10.chem.tue.nl> */
-  { "latin0",           "iso-8859-15"   }, /* this is not a bug */
-  
-  { "iso_8859-16",      "iso-8859-16"   },
-  { "latin10",          "iso-8859-16"   }, /* this is not a bug */
-  
-  /* 
-   * David Champion <dgc@uchicago.edu> has observed this with
-   * nl_langinfo under SunOS 5.8. 
-   */
-  
-  { "646",             "us-ascii"      },
-  
-  /* 
-   * http://www.sun.com/software/white-papers/wp-unicode/
-   */
-
-  { "eucJP",           "euc-jp"        },
-  { "PCK",             "Shift_JIS"     },
-  { "ko_KR-euc",       "euc-kr"        },
-  { "zh_TW-big5",      "big5"          },
-
-  /* seems to be common on some systems */
-
-  { "sjis",            "Shift_JIS"     },
-  { "euc-jp-ms",       "eucJP-ms"      },
-
-
-  /*
-   * If you happen to encounter system-specific brain-damage with
-   * respect to character set naming, please add it above this
-   * comment, and submit a patch to <mutt-dev@mutt.org>. 
-   */
-  
-  /* End of aliases.  Please keep this line last. */
-  
-  { NULL,              NULL            }
+} PreferredMIMENames[] = {
+  {
+  "ansi_x3.4-1968", "us-ascii"}, {
+  "iso-ir-6", "us-ascii"}, {
+  "iso_646.irv:1991", "us-ascii"}, {
+  "ascii", "us-ascii"}, {
+  "iso646-us", "us-ascii"}, {
+  "us", "us-ascii"}, {
+  "ibm367", "us-ascii"}, {
+  "cp367", "us-ascii"}, {
+  "csASCII", "us-ascii"}, {
+  "csISO2022KR", "iso-2022-kr"}, {
+  "csEUCKR", "euc-kr"}, {
+  "csISO2022JP", "iso-2022-jp"}, {
+  "csISO2022JP2", "iso-2022-jp-2"}, {
+  "ISO_8859-1:1987", "iso-8859-1"}, {
+  "iso-ir-100", "iso-8859-1"}, {
+  "iso_8859-1", "iso-8859-1"}, {
+  "latin1", "iso-8859-1"}, {
+  "l1", "iso-8859-1"}, {
+  "IBM819", "iso-8859-1"}, {
+  "CP819", "iso-8859-1"}, {
+  "csISOLatin1", "iso-8859-1"}, {
+  "ISO_8859-2:1987", "iso-8859-2"}, {
+  "iso-ir-101", "iso-8859-2"}, {
+  "iso_8859-2", "iso-8859-2"}, {
+  "latin2", "iso-8859-2"}, {
+  "l2", "iso-8859-2"}, {
+  "csISOLatin2", "iso-8859-2"}, {
+  "ISO_8859-3:1988", "iso-8859-3"}, {
+  "iso-ir-109", "iso-8859-3"}, {
+  "ISO_8859-3", "iso-8859-3"}, {
+  "latin3", "iso-8859-3"}, {
+  "l3", "iso-8859-3"}, {
+  "csISOLatin3", "iso-8859-3"}, {
+  "ISO_8859-4:1988", "iso-8859-4"}, {
+  "iso-ir-110", "iso-8859-4"}, {
+  "ISO_8859-4", "iso-8859-4"}, {
+  "latin4", "iso-8859-4"}, {
+  "l4", "iso-8859-4"}, {
+  "csISOLatin4", "iso-8859-4"}, {
+  "ISO_8859-6:1987", "iso-8859-6"}, {
+  "iso-ir-127", "iso-8859-6"}, {
+  "iso_8859-6", "iso-8859-6"}, {
+  "ECMA-114", "iso-8859-6"}, {
+  "ASMO-708", "iso-8859-6"}, {
+  "arabic", "iso-8859-6"}, {
+  "csISOLatinArabic", "iso-8859-6"}, {
+  "ISO_8859-7:1987", "iso-8859-7"}, {
+  "iso-ir-126", "iso-8859-7"}, {
+  "ISO_8859-7", "iso-8859-7"}, {
+  "ELOT_928", "iso-8859-7"}, {
+  "ECMA-118", "iso-8859-7"}, {
+  "greek", "iso-8859-7"}, {
+  "greek8", "iso-8859-7"}, {
+  "csISOLatinGreek", "iso-8859-7"}, {
+  "ISO_8859-8:1988", "iso-8859-8"}, {
+  "iso-ir-138", "iso-8859-8"}, {
+  "ISO_8859-8", "iso-8859-8"}, {
+  "hebrew", "iso-8859-8"}, {
+  "csISOLatinHebrew", "iso-8859-8"}, {
+  "ISO_8859-5:1988", "iso-8859-5"}, {
+  "iso-ir-144", "iso-8859-5"}, {
+  "ISO_8859-5", "iso-8859-5"}, {
+  "cyrillic", "iso-8859-5"}, {
+  "csISOLatinCyrillic", "iso8859-5"}, {
+  "ISO_8859-9:1989", "iso-8859-9"}, {
+  "iso-ir-148", "iso-8859-9"}, {
+  "ISO_8859-9", "iso-8859-9"}, {
+  "latin5", "iso-8859-9"},      /* this is not a bug */
+  {
+  "l5", "iso-8859-9"}, {
+  "csISOLatin5", "iso-8859-9"}, {
+  "ISO_8859-10:1992", "iso-8859-10"}, {
+  "iso-ir-157", "iso-8859-10"}, {
+  "latin6", "iso-8859-10"},     /* this is not a bug */
+  {
+  "l6", "iso-8859-10"}, {
+  "csISOLatin6" "iso-8859-10"}, {
+  "csKOI8r", "koi8-r"}, {
+  "MS_Kanji", "Shift_JIS"},     /* Note the underscore! */
+  {
+  "csShiftJis", "Shift_JIS"}, {
+  "Extended_UNIX_Code_Packed_Format_for_Japanese", "EUC-JP"}, {
+  "csEUCPkdFmtJapanese", "EUC-JP"}, {
+  "csGB2312", "gb2312"}, {
+  "csbig5", "big5"},
+    /* 
+     * End of official brain damage.  What follows has been taken
+     * from glibc's localedata files. 
+     */
+  {
+  "iso_8859-13", "iso-8859-13"}, {
+  "iso-ir-179", "iso-8859-13"}, {
+  "latin7", "iso-8859-13"},     /* this is not a bug */
+  {
+  "l7", "iso-8859-13"}, {
+  "iso_8859-14", "iso-8859-14"}, {
+  "latin8", "iso-8859-14"},     /* this is not a bug */
+  {
+  "l8", "iso-8859-14"}, {
+  "iso_8859-15", "iso-8859-15"}, {
+  "latin9", "iso-8859-15"},     /* this is not a bug */
+    /* Suggested by Ionel Mugurel Ciobica <tgakic@sg10.chem.tue.nl> */
+  {
+  "latin0", "iso-8859-15"},     /* this is not a bug */
+  {
+  "iso_8859-16", "iso-8859-16"}, {
+  "latin10", "iso-8859-16"},    /* this is not a bug */
+    /* 
+     * David Champion <dgc@uchicago.edu> has observed this with
+     * nl_langinfo under SunOS 5.8. 
+     */
+  {
+  "646", "us-ascii"},
+    /* 
+     * http://www.sun.com/software/white-papers/wp-unicode/
+     */
+  {
+  "eucJP", "euc-jp"}, {
+  "PCK", "Shift_JIS"}, {
+  "ko_KR-euc", "euc-kr"}, {
+  "zh_TW-big5", "big5"},
+    /* seems to be common on some systems */
+  {
+  "sjis", "Shift_JIS"}, {
+  "euc-jp-ms", "eucJP-ms"},
+    /*
+     * If you happen to encounter system-specific brain-damage with
+     * respect to character set naming, please add it above this
+     * comment, and submit a patch to <mutt-dev@mutt.org>. 
+     */
+    /* End of aliases.  Please keep this line last. */
+  {
+  NULL, NULL}
 };
 
 #ifdef HAVE_LANGINFO_CODESET
@@ -221,10 +198,10 @@ void mutt_set_langinfo_charset (void)
 {
   char buff[LONG_STRING];
   char buff2[LONG_STRING];
-  
+
   strfcpy (buff, nl_langinfo (CODESET), sizeof (buff));
   mutt_canonical_charset (buff2, sizeof (buff2), buff);
-  
+
   /* finally, set $charset */
   if (!(Charset = safe_strdup (buff2)))
     Charset = safe_strdup ("iso-8859-1");
@@ -247,7 +224,7 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name)
 
   /* catch some common iso-8859-something misspellings */
   if (!ascii_strncasecmp (name, "8859", 4) && name[4] != '-')
-    snprintf (scratch, sizeof (scratch), "iso-8859-%s", name +4);
+    snprintf (scratch, sizeof (scratch), "iso-8859-%s", name + 4);
   else if (!ascii_strncasecmp (name, "8859-", 5))
     snprintf (scratch, sizeof (scratch), "iso-8859-%s", name + 5);
   else if (!ascii_strncasecmp (name, "iso8859", 7) && name[7] != '-')
@@ -255,12 +232,11 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name)
   else if (!ascii_strncasecmp (name, "iso8859-", 8))
     snprintf (scratch, sizeof (scratch), "iso_8859-%s", name + 8);
   else
-    strfcpy (scratch, NONULL(name), sizeof (scratch));
+    strfcpy (scratch, NONULL (name), sizeof (scratch));
 
   for (i = 0; PreferredMIMENames[i].key; i++)
     if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) ||
-       !mutt_strcasecmp (scratch, PreferredMIMENames[i].key))
-    {
+        !mutt_strcasecmp (scratch, PreferredMIMENames[i].key)) {
       strfcpy (dest, PreferredMIMENames[i].pref, dlen);
       return;
     }
@@ -276,7 +252,8 @@ int mutt_chscmp (const char *s, const char *chs)
 {
   char buffer[STRING];
 
-  if (!s) return 0;
+  if (!s)
+    return 0;
 
   mutt_canonical_charset (buffer, sizeof (buffer), s);
   return !ascii_strcasecmp (buffer, chs);
@@ -287,11 +264,11 @@ int mutt_chscmp (const char *s, const char *chs)
 
 iconv_t iconv_open (const char *tocode, const char *fromcode)
 {
-  return (iconv_t)(-1);
+  return (iconv_t) (-1);
 }
 
-size_t iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
-             char **outbuf, size_t *outbytesleft)
+size_t iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t * inbytesleft,
+              char **outbuf, size_t * outbytesleft)
 {
   return 0;
 }
@@ -316,7 +293,7 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags)
   char *tmp;
 
   iconv_t cd;
-  
+
   mutt_canonical_charset (tocode1, sizeof (tocode1), tocode);
 
 #ifdef M_ICONV_HOOK_TO
@@ -329,12 +306,13 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags)
   if ((flags & M_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook (fromcode1)))
     mutt_canonical_charset (fromcode1, sizeof (fromcode1), tmp);
 
-  if ((cd = iconv_open (tocode1, fromcode1)) != (iconv_t) -1)
+  if ((cd = iconv_open (tocode1, fromcode1)) != (iconv_t) - 1)
     return cd;
-  if ((tocode2 = mutt_iconv_hook (tocode1)) && (fromcode2 = mutt_iconv_hook (fromcode1)))
+  if ((tocode2 = mutt_iconv_hook (tocode1))
+      && (fromcode2 = mutt_iconv_hook (fromcode1)))
     return iconv_open (tocode2, fromcode2);
-  
-  return (iconv_t) -1;
+
+  return (iconv_t) - 1;
 }
 
 
@@ -344,9 +322,9 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags)
  * if you're supplying an outrepl, the target charset should be.
  */
 
-size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
-                  char **outbuf, size_t *outbytesleft,
-                  ICONV_CONST char **inrepls, const char *outrepl)
+size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t * inbytesleft,
+                   char **outbuf, size_t * outbytesleft,
+                   ICONV_CONST char **inrepls, const char *outrepl)
 {
   size_t ret = 0, ret1;
   ICONV_CONST char *ib = *inbuf;
@@ -354,53 +332,49 @@ size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
   char *ob = *outbuf;
   size_t obl = *outbytesleft;
 
-  for (;;)
-  {
+  for (;;) {
     ret1 = iconv (cd, &ib, &ibl, &ob, &obl);
-    if (ret1 != (size_t)-1)
+    if (ret1 != (size_t) - 1)
       ret += ret1;
-    if (ibl && obl && errno == EILSEQ)
-    {
-      if (inrepls)
-      {
-       /* Try replacing the input */
-       ICONV_CONST char **t;
-       for (t = inrepls; *t; t++)
-       {
-         ICONV_CONST char *ib1 = *t;
-         size_t ibl1 = strlen (*t);
-         char *ob1 = ob;
-         size_t obl1 = obl;
-         iconv (cd, &ib1, &ibl1, &ob1, &obl1);
-         if (!ibl1)
-         {
-           ++ib, --ibl;
-           ob = ob1, obl = obl1;
-           ++ret;
-           break;
-         }
-       }
-       if (*t)
-         continue;
+    if (ibl && obl && errno == EILSEQ) {
+      if (inrepls) {
+        /* Try replacing the input */
+        ICONV_CONST char **t;
+
+        for (t = inrepls; *t; t++) {
+          ICONV_CONST char *ib1 = *t;
+          size_t ibl1 = strlen (*t);
+          char *ob1 = ob;
+          size_t obl1 = obl;
+
+          iconv (cd, &ib1, &ibl1, &ob1, &obl1);
+          if (!ibl1) {
+            ++ib, --ibl;
+            ob = ob1, obl = obl1;
+            ++ret;
+            break;
+          }
+        }
+        if (*t)
+          continue;
       }
       /* Replace the output */
       if (!outrepl)
-       outrepl = "?";
+        outrepl = "?";
       iconv (cd, 0, 0, &ob, &obl);
-      if (obl)
-      {
-       int n = strlen (outrepl);
-       if (n > obl)
-       {
-         outrepl = "?";
-         n = 1;
-       }
-       memcpy (ob, outrepl, n);
-       ++ib, --ibl;
-       ob += n, obl -= n;
-       ++ret;
-       iconv (cd, 0, 0, 0, 0); /* for good measure */
-       continue;
+      if (obl) {
+        int n = strlen (outrepl);
+
+        if (n > obl) {
+          outrepl = "?";
+          n = 1;
+        }
+        memcpy (ob, outrepl, n);
+        ++ib, --ibl;
+        ob += n, obl -= n;
+        ++ret;
+        iconv (cd, 0, 0, 0, 0); /* for good measure */
+        continue;
       }
     }
     *inbuf = ib, *inbytesleft = ibl;
@@ -415,7 +389,8 @@ size_t mutt_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
  * Used in rfc2047.c and rfc2231.c
  */
 
-int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
+int mutt_convert_string (char **ps, const char *from, const char *to,
+                         int flags)
 {
   iconv_t cd;
   ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
@@ -424,8 +399,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
   if (!s || !*s)
     return 0;
 
-  if (to && from && (cd = mutt_iconv_open (to, from, flags)) != (iconv_t)-1)
-  {
+  if (to && from && (cd = mutt_iconv_open (to, from, flags)) != (iconv_t) - 1) {
     int len;
     ICONV_CONST char *ib;
     char *buf, *ob;
@@ -439,12 +413,12 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
       inrepls = repls;
     else
       outrepl = "?";
-      
+
     len = strlen (s);
     ib = s, ibl = len + 1;
     obl = MB_LEN_MAX * ibl;
     ob = buf = safe_malloc (obl + 1);
-    
+
     mutt_iconv (cd, &ib, &ibl, &ob, &obl, inrepls, outrepl);
     iconv_close (cd);
 
@@ -452,7 +426,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
 
     FREE (ps);
     *ps = buf;
-    
+
     mutt_str_adjust (ps);
     return 0;
   }
@@ -466,8 +440,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int flags)
  * Used in sendlib.c for converting from mutt's Charset
  */
 
-struct fgetconv_s
-{
+struct fgetconv_s {
   FILE *file;
   iconv_t cd;
   char bufi[512];
@@ -479,23 +452,22 @@ struct fgetconv_s
   ICONV_CONST char **inrepls;
 };
 
-struct fgetconv_not
-{
+struct fgetconv_not {
   FILE *file;
   iconv_t cd;
 };
 
-FGETCONV *fgetconv_open (FILE *file, const char *from, const char *to, int flags)
+FGETCONV *fgetconv_open (FILE * file, const char *from, const char *to,
+                         int flags)
 {
   struct fgetconv_s *fc;
-  iconv_t cd = (iconv_t)-1;
+  iconv_t cd = (iconv_t) - 1;
   static ICONV_CONST char *repls[] = { "\357\277\275", "?", 0 };
 
   if (from && to)
     cd = mutt_iconv_open (to, from, flags);
 
-  if (cd != (iconv_t)-1)
-  {
+  if (cd != (iconv_t) - 1) {
     fc = safe_malloc (sizeof (struct fgetconv_s));
     fc->p = fc->ob = fc->bufo;
     fc->ib = fc->bufi;
@@ -506,51 +478,50 @@ FGETCONV *fgetconv_open (FILE *file, const char *from, const char *to, int flags
     fc = safe_malloc (sizeof (struct fgetconv_not));
   fc->file = file;
   fc->cd = cd;
-  return (FGETCONV *)fc;
+  return (FGETCONV *) fc;
 }
 
-char *fgetconvs (char *buf, size_t l, FGETCONV *_fc)
+char *fgetconvs (char *buf, size_t l, FGETCONV * _fc)
 {
   int c;
   size_t r;
-  
-  for (r = 0; r + 1 < l;)
-  {
+
+  for (r = 0; r + 1 < l;) {
     if ((c = fgetconv (_fc)) == EOF)
       break;
     buf[r++] = (char) c;
-    if (c == '\n') 
+    if (c == '\n')
       break;
   }
   buf[r] = '\0';
-  
-  if (r) 
+
+  if (r)
     return buf;
-  else 
+  else
     return NULL;
 }
 
-int fgetconv (FGETCONV *_fc)
+int fgetconv (FGETCONV * _fc)
 {
-  struct fgetconv_s *fc = (struct fgetconv_s *)_fc;
+  struct fgetconv_s *fc = (struct fgetconv_s *) _fc;
 
   if (!fc)
     return EOF;
-  if (fc->cd == (iconv_t)-1)
+  if (fc->cd == (iconv_t) - 1)
     return fgetc (fc->file);
   if (!fc->p)
     return EOF;
   if (fc->p < fc->ob)
-    return (unsigned char)*(fc->p)++;
+    return (unsigned char) *(fc->p)++;
 
   /* Try to convert some more */
   fc->p = fc->ob = fc->bufo;
-  if (fc->ibl)
-  {
+  if (fc->ibl) {
     size_t obl = sizeof (fc->bufo);
-    iconv (fc->cd, (ICONV_CONST char **)&fc->ib, &fc->ibl, &fc->ob, &obl);
+
+    iconv (fc->cd, (ICONV_CONST char **) &fc->ib, &fc->ibl, &fc->ob, &obl);
     if (fc->p < fc->ob)
-      return (unsigned char)*(fc->p)++;
+      return (unsigned char) *(fc->p)++;
   }
 
   /* If we trusted iconv a bit more, we would at this point
@@ -558,24 +529,24 @@ int fgetconv (FGETCONV *_fc)
 
   /* Try to read some more */
   if (fc->ibl == sizeof (fc->bufi) ||
-      (fc->ibl && fc->ib + fc->ibl < fc->bufi + sizeof (fc->bufi)))
-  {
+      (fc->ibl && fc->ib + fc->ibl < fc->bufi + sizeof (fc->bufi))) {
     fc->p = 0;
     return EOF;
   }
   if (fc->ibl)
     memcpy (fc->bufi, fc->ib, fc->ibl);
   fc->ib = fc->bufi;
-  fc->ibl += fread (fc->ib + fc->ibl, 1, sizeof (fc->bufi) - fc->ibl, fc->file);
+  fc->ibl +=
+    fread (fc->ib + fc->ibl, 1, sizeof (fc->bufi) - fc->ibl, fc->file);
 
   /* Try harder this time to convert some */
-  if (fc->ibl)
-  {
+  if (fc->ibl) {
     size_t obl = sizeof (fc->bufo);
-    mutt_iconv (fc->cd, (ICONV_CONST char **)&fc->ib, &fc->ibl, &fc->ob, &obl,
-               fc->inrepls, 0);
+
+    mutt_iconv (fc->cd, (ICONV_CONST char **) &fc->ib, &fc->ibl, &fc->ob,
+                &obl, fc->inrepls, 0);
     if (fc->p < fc->ob)
-      return (unsigned char)*(fc->p)++;
+      return (unsigned char) *(fc->p)++;
   }
 
   /* Either the file has finished or one of the buffers is too small */
@@ -583,11 +554,11 @@ int fgetconv (FGETCONV *_fc)
   return EOF;
 }
 
-void fgetconv_close (FGETCONV **_fc)
+void fgetconv_close (FGETCONV ** _fc)
 {
   struct fgetconv_s *fc = (struct fgetconv_s *) *_fc;
 
-  if (fc->cd != (iconv_t)-1)
+  if (fc->cd != (iconv_t) - 1)
     iconv_close (fc->cd);
   FREE (_fc);
 }
@@ -598,7 +569,7 @@ char *mutt_get_first_charset (const char *charset)
   const char *c, *c1;
 
   c = charset;
-  if (!mutt_strlen(c))
+  if (!mutt_strlen (c))
     return "us-ascii";
   if (!(c1 = strchr (c, ':')))
     return charset;
@@ -607,8 +578,8 @@ char *mutt_get_first_charset (const char *charset)
 }
 
 static size_t convert_string (ICONV_CONST char *f, size_t flen,
-                             const char *from, const char *to,
-                             char **t, size_t *tlen)
+                              const char *from, const char *to,
+                              char **t, size_t * tlen)
 {
   iconv_t cd;
   char *buf, *ob;
@@ -616,18 +587,17 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen,
   int e;
 
   cd = mutt_iconv_open (to, from, 0);
-  if (cd == (iconv_t)(-1))
-    return (size_t)(-1);
+  if (cd == (iconv_t) (-1))
+    return (size_t) (-1);
   obl = 4 * flen + 1;
   ob = buf = safe_malloc (obl);
   n = iconv (cd, &f, &flen, &ob, &obl);
-  if (n == (size_t)(-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t)(-1))
-  {
+  if (n == (size_t) (-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) {
     e = errno;
     FREE (&buf);
     iconv_close (cd);
     errno = e;
-    return (size_t)(-1);
+    return (size_t) (-1);
   }
   *ob = '\0';
 
@@ -644,8 +614,7 @@ int mutt_convert_nonmime_string (char **ps)
 {
   const char *c, *c1;
 
-  for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
-  {
+  for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0) {
     char *u = *ps;
     char *s;
     char *fromcode;
@@ -664,8 +633,7 @@ int mutt_convert_nonmime_string (char **ps)
     strfcpy (fromcode, c, n + 1);
     m = convert_string (u, ulen, fromcode, Charset, &s, &slen);
     FREE (&fromcode);
-    if (m != (size_t)(-1))
-    {
+    if (m != (size_t) (-1)) {
       FREE (ps);
       *ps = s;
       return 0;
@@ -673,4 +641,3 @@ int mutt_convert_nonmime_string (char **ps)
   }
   return -1;
 }
-
index 6397493..2721b01 100644 (file)
--- a/charset.h
+++ b/charset.h
@@ -29,7 +29,7 @@ typedef void *iconv_t;
 
 #ifndef HAVE_ICONV
 #define ICONV_CONST /**/
-iconv_t iconv_open (const char *, const char *);
+  iconv_t iconv_open (const char *, const char *);
 size_t iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *);
 int iconv_close (iconv_t);
 #endif
@@ -39,13 +39,14 @@ char *mutt_get_first_charset (const char *);
 int mutt_convert_nonmime_string (char **);
 
 iconv_t mutt_iconv_open (const char *, const char *, int);
-size_t mutt_iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *, ICONV_CONST char **, const char *);
+size_t mutt_iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *,
+                   ICONV_CONST char **, const char *);
 
-typedef void * FGETCONV;
+typedef void *FGETCONV;
 
 FGETCONV *fgetconv_open (FILE *, const char *, const char *, int);
 int fgetconv (FGETCONV *);
-char * fgetconvs (char *, size_t, FGETCONV *);
+char *fgetconvs (char *, size_t, FGETCONV *);
 void fgetconv_close (FGETCONV **);
 
 void mutt_set_langinfo_charset (void);
diff --git a/color.c b/color.c
index 8dda6cf..34a3d70 100644 (file)
--- a/color.c
+++ b/color.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -43,8 +43,7 @@ static int ColorQuoteSize;
 
 #define COLOR_DEFAULT (-2)
 
-typedef struct color_list
-{
+typedef struct color_list {
   short fg;
   short bg;
   short index;
@@ -55,48 +54,46 @@ typedef struct color_list
 static COLOR_LIST *ColorList = NULL;
 static int UserColors = 0;
 
-static struct mapping_t Colors[] =
-{
-  { "black",   COLOR_BLACK },
-  { "blue",    COLOR_BLUE },
-  { "cyan",    COLOR_CYAN },
-  { "green",   COLOR_GREEN },
-  { "magenta", COLOR_MAGENTA },
-  { "red",     COLOR_RED },
-  { "white",   COLOR_WHITE },
-  { "yellow",  COLOR_YELLOW },
+static struct mapping_t Colors[] = {
+  {"black", COLOR_BLACK},
+  {"blue", COLOR_BLUE},
+  {"cyan", COLOR_CYAN},
+  {"green", COLOR_GREEN},
+  {"magenta", COLOR_MAGENTA},
+  {"red", COLOR_RED},
+  {"white", COLOR_WHITE},
+  {"yellow", COLOR_YELLOW},
 #if defined (USE_SLANG_CURSES) || defined (HAVE_USE_DEFAULT_COLORS)
-  { "default", COLOR_DEFAULT },
+  {"default", COLOR_DEFAULT},
 #endif
-  { 0, 0 }
+  {0, 0}
 };
 
 #endif /* HAVE_COLOR */
 
-static struct mapping_t Fields[] =
-{
-  { "hdrdefault",      MT_COLOR_HDEFAULT },
-  { "quoted",          MT_COLOR_QUOTED },
-  { "signature",       MT_COLOR_SIGNATURE },
-  { "indicator",       MT_COLOR_INDICATOR },
-  { "status",          MT_COLOR_STATUS },
-  { "tree",            MT_COLOR_TREE },
-  { "error",           MT_COLOR_ERROR },
-  { "normal",          MT_COLOR_NORMAL },
-  { "tilde",           MT_COLOR_TILDE },
-  { "markers",         MT_COLOR_MARKERS },
-  { "header",          MT_COLOR_HEADER },
-  { "body",            MT_COLOR_BODY },
-  { "message",         MT_COLOR_MESSAGE },
-  { "attachment",      MT_COLOR_ATTACHMENT },
-  { "search",          MT_COLOR_SEARCH },
-  { "bold",            MT_COLOR_BOLD },
-  { "underline",       MT_COLOR_UNDERLINE },
-  { "index",           MT_COLOR_INDEX },
-  { "sidebar_new",     MT_COLOR_NEW },
-  { "sidebar",      MT_COLOR_SIDEBAR },
-  { "sidebar_flagged", MT_COLOR_FLAGGED },
-  { NULL,              0 }
+static struct mapping_t Fields[] = {
+  {"hdrdefault", MT_COLOR_HDEFAULT},
+  {"quoted", MT_COLOR_QUOTED},
+  {"signature", MT_COLOR_SIGNATURE},
+  {"indicator", MT_COLOR_INDICATOR},
+  {"status", MT_COLOR_STATUS},
+  {"tree", MT_COLOR_TREE},
+  {"error", MT_COLOR_ERROR},
+  {"normal", MT_COLOR_NORMAL},
+  {"tilde", MT_COLOR_TILDE},
+  {"markers", MT_COLOR_MARKERS},
+  {"header", MT_COLOR_HEADER},
+  {"body", MT_COLOR_BODY},
+  {"message", MT_COLOR_MESSAGE},
+  {"attachment", MT_COLOR_ATTACHMENT},
+  {"search", MT_COLOR_SEARCH},
+  {"bold", MT_COLOR_BOLD},
+  {"underline", MT_COLOR_UNDERLINE},
+  {"index", MT_COLOR_INDEX},
+  {"sidebar_new", MT_COLOR_NEW},
+  {"sidebar", MT_COLOR_SIDEBAR},
+  {"sidebar_flagged", MT_COLOR_FLAGGED},
+  {NULL, 0}
 };
 
 #define COLOR_QUOTE_INIT       8
@@ -106,31 +103,30 @@ static COLOR_LINE *mutt_new_color_line (void)
   COLOR_LINE *p = safe_calloc (1, sizeof (COLOR_LINE));
 
   p->fg = p->bg = -1;
-  
+
   return (p);
 }
 
-static void mutt_free_color_line(COLOR_LINE **l, 
-                                int free_colors)
+static void mutt_free_color_line (COLOR_LINE ** l, int free_colors)
 {
   COLOR_LINE *tmp;
-  if(!l || !*l)
+
+  if (!l || !*l)
     return;
 
   tmp = *l;
 
 #ifdef HAVE_COLOR
-  if(free_colors && tmp->fg != -1 && tmp->bg != -1)
-    mutt_free_color(tmp->fg, tmp->bg);
+  if (free_colors && tmp->fg != -1 && tmp->bg != -1)
+    mutt_free_color (tmp->fg, tmp->bg);
 #endif
 
   /* we should really introduce a container
    * type for regular expressions.
    */
-  
-  regfree(&tmp->rx);
-  mutt_pattern_free(&tmp->color_pattern);
+
+  regfree (&tmp->rx);
+  mutt_pattern_free (&tmp->color_pattern);
   FREE (&tmp->pattern);
   FREE (l);
 }
@@ -162,28 +158,25 @@ void ci_start_color (void)
 #ifdef USE_SLANG_CURSES
 static char *get_color_name (char *dest, size_t destlen, int val)
 {
-  static char * missing[3] = {"brown", "lightgray", "default"};
+  static char *missing[3] = { "brown", "lightgray", "default" };
   int i;
 
-  switch (val)
-  {
-    case COLOR_YELLOW:
-      strfcpy (dest, missing[0], destlen);
-      return dest;
+  switch (val) {
+  case COLOR_YELLOW:
+    strfcpy (dest, missing[0], destlen);
+    return dest;
 
-    case COLOR_WHITE:
-      strfcpy (dest, missing[1], destlen);
-      return dest;
-      
-    case COLOR_DEFAULT:
-      strfcpy (dest, missing[2], destlen);
-      return dest;
+  case COLOR_WHITE:
+    strfcpy (dest, missing[1], destlen);
+    return dest;
+
+  case COLOR_DEFAULT:
+    strfcpy (dest, missing[2], destlen);
+    return dest;
   }
 
-  for (i = 0; Colors[i].name; i++)
-  {
-    if (Colors[i].value == val)
-    {
+  for (i = 0; Colors[i].name; i++) {
+    if (Colors[i].value == val) {
       strfcpy (dest, Colors[i].name, destlen);
       return dest;
     }
@@ -202,16 +195,14 @@ int mutt_alloc_color (int fg, int bg)
 {
   COLOR_LIST *p = ColorList;
   int i;
-  
+
 #if defined (USE_SLANG_CURSES)
   char fgc[SHORT_STRING], bgc[SHORT_STRING];
 #endif
 
   /* check to see if this color is already allocated to save space */
-  while (p)
-  {
-    if (p->fg == fg && p->bg == bg)
-    {
+  while (p) {
+    if (p->fg == fg && p->bg == bg) {
       (p->count)++;
       return (COLOR_PAIR (p->index));
     }
@@ -219,19 +210,20 @@ int mutt_alloc_color (int fg, int bg)
   }
 
   /* check to see if there are colors left */
-  if (++UserColors > COLOR_PAIRS) return (A_NORMAL);
+  if (++UserColors > COLOR_PAIRS)
+    return (A_NORMAL);
 
   /* find the smallest available index (object) */
   i = 1;
-  FOREVER
-  {
+  FOREVER {
     p = ColorList;
-    while (p)
-    {
-      if (p->index == i) break;
+    while (p) {
+      if (p->index == i)
+        break;
       p = p->next;
     }
-    if (p == NULL) break;
+    if (p == NULL)
+      break;
     i++;
   }
 
@@ -246,7 +238,8 @@ int mutt_alloc_color (int fg, int bg)
 
 #if defined (USE_SLANG_CURSES)
   if (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
-    SLtt_set_color (i, NULL, get_color_name (fgc, sizeof (fgc), fg), get_color_name (bgc, sizeof (bgc), bg));
+    SLtt_set_color (i, NULL, get_color_name (fgc, sizeof (fgc), fg),
+                    get_color_name (bgc, sizeof (bgc), bg));
   else
 #elif defined (HAVE_USE_DEFAULT_COLORS)
   if (fg == COLOR_DEFAULT)
@@ -255,10 +248,10 @@ int mutt_alloc_color (int fg, int bg)
     bg = -1;
 #endif
 
-  init_pair(i, fg, bg);
+  init_pair (i, fg, bg);
 
-  dprint(1,(debugfile,"mutt_alloc_color(): Color pairs used so far: %d\n",
-                       UserColors));
+  dprint (1, (debugfile, "mutt_alloc_color(): Color pairs used so far: %d\n",
+              UserColors));
 
   return (COLOR_PAIR (p->index));
 }
@@ -268,33 +261,30 @@ void mutt_free_color (int fg, int bg)
   COLOR_LIST *p, *q;
 
   p = ColorList;
-  while (p)
-  {
-    if (p->fg == fg && p->bg == bg)
-    {
+  while (p) {
+    if (p->fg == fg && p->bg == bg) {
       (p->count)--;
-      if (p->count > 0) return;
+      if (p->count > 0)
+        return;
 
       UserColors--;
-      dprint(1,(debugfile,"mutt_free_color(): Color pairs used so far: %d\n",
-                           UserColors));
-
-      if (p == ColorList)
-      {
-       ColorList = ColorList->next;
-       FREE (&p);
-       return;
+      dprint (1,
+              (debugfile, "mutt_free_color(): Color pairs used so far: %d\n",
+               UserColors));
+
+      if (p == ColorList) {
+        ColorList = ColorList->next;
+        FREE (&p);
+        return;
       }
       q = ColorList;
-      while (q)
-      {
-       if (q->next == p)
-       {
-         q->next = p->next;
-         FREE (&p);
-         return;
-       }
-       q = q->next;
+      while (q) {
+        if (q->next == p) {
+          q->next = p->next;
+          FREE (&p);
+          return;
+        }
+        q = q->next;
       }
       /* can't get here */
     }
@@ -308,30 +298,27 @@ void mutt_free_color (int fg, int bg)
 #ifdef HAVE_COLOR
 
 static int
-parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER *err)
+parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err)
 {
   char *eptr;
 
-  if (mutt_strncasecmp (s, "bright", 6) == 0)
-  {
+  if (mutt_strncasecmp (s, "bright", 6) == 0) {
     *attr |= brite;
     s += 6;
   }
 
   /* allow aliases for xterm color resources */
-  if (mutt_strncasecmp (s, "color", 5) == 0)
-  {
+  if (mutt_strncasecmp (s, "color", 5) == 0) {
     s += 5;
     *col = strtol (s, &eptr, 10);
     if (!*s || *eptr || *col < 0 ||
-       (*col >= COLORS && !option(OPTNOCURSES) && has_colors()))
-    {
-      snprintf (err->data, err->dsize, _("%s: color not supported by term"), s);
+        (*col >= COLORS && !option (OPTNOCURSES) && has_colors ())) {
+      snprintf (err->data, err->dsize, _("%s: color not supported by term"),
+                s);
       return (-1);
     }
   }
-  else if ((*col = mutt_getvaluebyname (s, Colors)) == -1)
-  {
+  else if ((*col = mutt_getvaluebyname (s, Colors)) == -1) {
     snprintf (err->data, err->dsize, _("%s: no such color"), s);
     return (-1);
   }
@@ -346,71 +333,68 @@ parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER *err)
  *       unmono  index pattern [pattern...]
  */
 
-static int 
-_mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, 
-                        short parse_uncolor);
+static int
+_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err, short parse_uncolor);
 
 
 #ifdef HAVE_COLOR
 
-int mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
-                       BUFFER *err)
+int mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
+                        BUFFER * err)
 {
-  return _mutt_parse_uncolor(buf, s, data, err, 1);
+  return _mutt_parse_uncolor (buf, s, data, err, 1);
 }
 
 #endif
 
-int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data,
-                      BUFFER *err)
+int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data,
+                       BUFFER * err)
 {
-  return _mutt_parse_uncolor(buf, s, data, err, 0);
+  return _mutt_parse_uncolor (buf, s, data, err, 0);
 }
 
-static int 
-_mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, 
-                        short parse_uncolor)
+static int
+_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err, short parse_uncolor)
 {
   int object = 0, do_cache = 0;
   COLOR_LINE *tmp, *last = NULL;
 
   mutt_extract_token (buf, s, 0);
 
-  if ((object = mutt_getvaluebyname (buf->data, Fields)) == -1)
-  {
+  if ((object = mutt_getvaluebyname (buf->data, Fields)) == -1) {
     snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
     return (-1);
   }
 
-  if (mutt_strncmp (buf->data, "index", 5) != 0)
-  {
+  if (mutt_strncmp (buf->data, "index", 5) != 0) {
     snprintf (err->data, err->dsize,
-             _("%s: command valid only for index object"), 
-             parse_uncolor ? "uncolor" : "unmono");
+              _("%s: command valid only for index object"),
+              parse_uncolor ? "uncolor" : "unmono");
     return (-1);
   }
-  
-  if (!MoreArgs (s))
-  {
+
+  if (!MoreArgs (s)) {
     snprintf (err->data, err->dsize,
-             _("%s: too few arguments"), parse_uncolor ? "uncolor" : "unmono");
+              _("%s: too few arguments"),
+              parse_uncolor ? "uncolor" : "unmono");
     return (-1);
   }
 
-  if(
+  if (
 #ifdef HAVE_COLOR
-     /* we're running without curses */
-     option (OPTNOCURSES) 
-     || /* we're parsing an uncolor command, and have no colors */
-     (parse_uncolor && !has_colors())
-     /* we're parsing an unmono command, and have colors */
-     || (!parse_uncolor && has_colors())
+       /* we're running without curses */
+       option (OPTNOCURSES)
+       ||                       /* we're parsing an uncolor command, and have no colors */
+       (parse_uncolor && !has_colors ())
+       /* we're parsing an unmono command, and have colors */
+       || (!parse_uncolor && has_colors ())
 #else
-     /* We don't even have colors compiled in */
-     parse_uncolor
+       /* We don't even have colors compiled in */
+       parse_uncolor
 #endif
-     )
-  {
+    ) {
     /* just eat the command, but don't do anything real about it */
     do
       mutt_extract_token (buf, s, 0);
@@ -418,49 +402,45 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err,
 
     return 0;
   }
-     
-  
-  do
-  {
+
+
+  do {
     mutt_extract_token (buf, s, 0);
-    if (!mutt_strcmp ("*", buf->data))
-    {
-      for (tmp = ColorIndexList; tmp; )
-      {
+    if (!mutt_strcmp ("*", buf->data)) {
+      for (tmp = ColorIndexList; tmp;) {
         if (!do_cache)
-         do_cache = 1;
-       last = tmp;
-       tmp = tmp->next;
-       mutt_free_color_line(&last, parse_uncolor);
+          do_cache = 1;
+        last = tmp;
+        tmp = tmp->next;
+        mutt_free_color_line (&last, parse_uncolor);
       }
       ColorIndexList = NULL;
     }
-    else
-    {
-      for (last = NULL, tmp = ColorIndexList; tmp; last = tmp, tmp = tmp->next)
-      {
-       if (!mutt_strcmp (buf->data, tmp->pattern))
-       {
+    else {
+      for (last = NULL, tmp = ColorIndexList; tmp;
+           last = tmp, tmp = tmp->next) {
+        if (!mutt_strcmp (buf->data, tmp->pattern)) {
           if (!do_cache)
-           do_cache = 1;
-         dprint(1,(debugfile,"Freeing pattern \"%s\" from ColorIndexList\n",
-                              tmp->pattern));
-         if (last)
-           last->next = tmp->next;
-         else
-           ColorIndexList = tmp->next;
-         mutt_free_color_line(&tmp, parse_uncolor);
-         break;
-       }
+            do_cache = 1;
+          dprint (1,
+                  (debugfile, "Freeing pattern \"%s\" from ColorIndexList\n",
+                   tmp->pattern));
+          if (last)
+            last->next = tmp->next;
+          else
+            ColorIndexList = tmp->next;
+          mutt_free_color_line (&tmp, parse_uncolor);
+          break;
+        }
       }
     }
   }
   while (MoreArgs (s));
 
 
-  if (do_cache && !option (OPTNOCURSES))
-  {
+  if (do_cache && !option (OPTNOCURSES)) {
     int i;
+
     set_option (OPTFORCEREDRAWINDEX);
     /* force re-caching of index colors */
     for (i = 0; Context && i < Context->msgcount; i++)
@@ -470,10 +450,9 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err,
 }
 
 
-static int 
-add_pattern (COLOR_LINE **top, const char *s, int sensitive,
-            int fg, int bg, int attr, BUFFER *err,
-            int is_index)
+static int
+add_pattern (COLOR_LINE ** top, const char *s, int sensitive,
+             int fg, int bg, int attr, BUFFER * err, int is_index)
 {
 
   /* is_index used to store compiled pattern
@@ -482,71 +461,64 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
 
   COLOR_LINE *tmp = *top;
 
-  while (tmp)
-  {
-    if (sensitive)
-    {
+  while (tmp) {
+    if (sensitive) {
       if (mutt_strcmp (s, tmp->pattern) == 0)
-       break;
+        break;
     }
-    else
-    {
+    else {
       if (mutt_strcasecmp (s, tmp->pattern) == 0)
-       break;
+        break;
     }
     tmp = tmp->next;
   }
 
-  if (tmp)
-  {
+  if (tmp) {
 #ifdef HAVE_COLOR
-    if (fg != -1 && bg != -1)
-    {
-      if (tmp->fg != fg || tmp->bg != bg)
-      {
-       mutt_free_color (tmp->fg, tmp->bg);
-       tmp->fg = fg;
-       tmp->bg = bg;
-       attr |= mutt_alloc_color (fg, bg);
+    if (fg != -1 && bg != -1) {
+      if (tmp->fg != fg || tmp->bg != bg) {
+        mutt_free_color (tmp->fg, tmp->bg);
+        tmp->fg = fg;
+        tmp->bg = bg;
+        attr |= mutt_alloc_color (fg, bg);
       }
       else
-       attr |= (tmp->pair & ~A_BOLD);
+        attr |= (tmp->pair & ~A_BOLD);
     }
 #endif /* HAVE_COLOR */
     tmp->pair = attr;
   }
-  else
-  {
+  else {
     int r;
     char buf[STRING];
 
     tmp = mutt_new_color_line ();
-    if (is_index) 
-    {
+    if (is_index) {
       int i;
 
-      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)
-      {
-       mutt_free_color_line(&tmp, 1);
-       return -1;
+      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) {
+        mutt_free_color_line (&tmp, 1);
+        return -1;
       }
       /* force re-caching of index colors */
       for (i = 0; Context && i < Context->msgcount; i++)
-       Context->hdrs[i]->pair = 0;
+        Context->hdrs[i]->pair = 0;
     }
-    else if ((r = REGCOMP (&tmp->rx, s, (sensitive ? mutt_which_case (s) : REG_ICASE))) != 0)
-    {
+    else
+      if ((r =
+           REGCOMP (&tmp->rx, s,
+                    (sensitive ? mutt_which_case (s) : REG_ICASE))) != 0) {
       regerror (r, &tmp->rx, err->data, err->dsize);
-      mutt_free_color_line(&tmp, 1);
+      mutt_free_color_line (&tmp, 1);
       return (-1);
     }
     tmp->next = *top;
     tmp->pattern = safe_strdup (s);
 #ifdef HAVE_COLOR
-    if(fg != -1 && bg != -1)
-    {
+    if (fg != -1 && bg != -1) {
       tmp->fg = fg;
       tmp->bg = bg;
       attr |= mutt_alloc_color (fg, bg);
@@ -560,36 +532,31 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
 }
 
 static int
-parse_object(BUFFER *buf, BUFFER *s, int *o, int *ql, BUFFER *err)
+parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err)
 {
   int q_level = 0;
   char *eptr;
-  
-  if(!MoreArgs(s))
-  {
-    strfcpy(err->data, _("Missing arguments."), err->dsize);
+
+  if (!MoreArgs (s)) {
+    strfcpy (err->data, _("Missing arguments."), err->dsize);
     return -1;
   }
-  
-  mutt_extract_token(buf, s, 0);
-  if(!mutt_strncmp(buf->data, "quoted", 6))
-  {
-    if(buf->data[6])
-    {
-      *ql = strtol(buf->data + 6, &eptr, 10);
-      if(*eptr || q_level < 0)
-      {
-       snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
-       return -1;
+
+  mutt_extract_token (buf, s, 0);
+  if (!mutt_strncmp (buf->data, "quoted", 6)) {
+    if (buf->data[6]) {
+      *ql = strtol (buf->data + 6, &eptr, 10);
+      if (*eptr || q_level < 0) {
+        snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
+        return -1;
       }
     }
     else
       *ql = 0;
-    
+
     *o = MT_COLOR_QUOTED;
   }
-  else if ((*o = mutt_getvaluebyname (buf->data, Fields)) == -1)
-  {
+  else if ((*o = mutt_getvaluebyname (buf->data, Fields)) == -1) {
     snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
     return (-1);
   }
@@ -597,15 +564,16 @@ parse_object(BUFFER *buf, BUFFER *s, int *o, int *ql, BUFFER *err)
   return 0;
 }
 
-typedef int (*parser_callback_t)(BUFFER *, BUFFER *, int *, int *, int *, BUFFER *);
+typedef int (*parser_callback_t) (BUFFER *, BUFFER *, int *, int *, int *,
+                                  BUFFER *);
 
 #ifdef HAVE_COLOR
 
 static int
-parse_color_pair(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *err)
+parse_color_pair (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
+                  BUFFER * err)
 {
-  if (! MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("color: too few arguments"), err->dsize);
     return (-1);
   }
@@ -615,31 +583,32 @@ parse_color_pair(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *er
   if (parse_color_name (buf->data, fg, attr, A_BOLD, err) != 0)
     return (-1);
 
-  if (! MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("color: too few arguments"), err->dsize);
     return (-1);
   }
-  
+
   mutt_extract_token (buf, s, 0);
 
   if (parse_color_name (buf->data, bg, attr, A_BLINK, err) != 0)
     return (-1);
-  
+
   return 0;
 }
 
 #endif
 
 static int
-parse_attr_spec(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *err)
+parse_attr_spec (BUFFER * buf, BUFFER * s, int *fg, int *bg, int *attr,
+                 BUFFER * err)
 {
-  
-  if(fg) *fg = -1; 
-  if(bg) *bg = -1;
 
-  if (! MoreArgs (s))
-  {
+  if (fg)
+    *fg = -1;
+  if (bg)
+    *bg = -1;
+
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("mono: too few arguments"), err->dsize);
     return (-1);
   }
@@ -657,21 +626,20 @@ parse_attr_spec(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *err
   else if (ascii_strcasecmp ("standout", buf->data) == 0)
     *attr |= A_STANDOUT;
   else if (ascii_strcasecmp ("normal", buf->data) == 0)
-    *attr = A_NORMAL; /* needs use = instead of |= to clear other bits */
-  else
-  {
+    *attr = A_NORMAL;           /* needs use = instead of |= to clear other bits */
+  else {
     snprintf (err->data, err->dsize, _("%s: no such attribute"), buf->data);
     return (-1);
   }
-  
+
   return 0;
 }
 
-static int fgbgattr_to_color(int fg, int bg, int attr)
+static int fgbgattr_to_color (int fg, int bg, int attr)
 {
 #ifdef HAVE_COLOR
-  if(fg != -1 && bg != -1)
-    return attr | mutt_alloc_color(fg, bg);
+  if (fg != -1 && bg != -1)
+    return attr | mutt_alloc_color (fg, bg);
   else
 #endif
     return attr;
@@ -681,95 +649,88 @@ static int fgbgattr_to_color(int fg, int bg, int attr)
  *       mono  <object> <attr> [ <regexp> ]
  */
 
-static int 
-_mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, 
-                  parser_callback_t callback, short dry_run)
+static int
+_mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err,
+                   parser_callback_t callback, short dry_run)
 {
   int object = 0, attr = 0, fg = 0, bg = 0, q_level = 0;
   int r = 0;
 
-  if(parse_object(buf, s, &object, &q_level, err) == -1)
+  if (parse_object (buf, s, &object, &q_level, err) == -1)
     return -1;
 
-  if(callback(buf, s, &fg, &bg, &attr, err) == -1)
+  if (callback (buf, s, &fg, &bg, &attr, err) == -1)
     return -1;
 
   /* extract a regular expression if needed */
-  
-  if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY || object == MT_COLOR_INDEX)
-  {
-    if (!MoreArgs (s))
-    {
+
+  if (object == MT_COLOR_HEADER || object == MT_COLOR_BODY
+      || object == MT_COLOR_INDEX) {
+    if (!MoreArgs (s)) {
       strfcpy (err->data, _("too few arguments"), err->dsize);
       return (-1);
     }
 
     mutt_extract_token (buf, s, 0);
   }
-   
-  if (MoreArgs (s))
-  {
+
+  if (MoreArgs (s)) {
     strfcpy (err->data, _("too many arguments"), err->dsize);
     return (-1);
   }
-  
+
   /* dry run? */
-  
-  if(dry_run) return 0;
 
-  
+  if (dry_run)
+    return 0;
+
+
 #ifdef HAVE_COLOR
 # ifdef HAVE_USE_DEFAULT_COLORS
-  if (!option (OPTNOCURSES) && has_colors()
-    /* delay use_default_colors() until needed, since it initializes things */
-    && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
-    && use_default_colors () != OK)
-  {
+  if (!option (OPTNOCURSES) && has_colors ()
+      /* delay use_default_colors() until needed, since it initializes things */
+      && (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
+      && use_default_colors () != OK) {
     strfcpy (err->data, _("default colors not supported"), err->dsize);
     return (-1);
   }
 # endif /* HAVE_USE_DEFAULT_COLORS */
 #endif
-  
+
   if (object == MT_COLOR_HEADER)
-    r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err,0);
+    r = add_pattern (&ColorHdrList, buf->data, 0, fg, bg, attr, err, 0);
   else if (object == MT_COLOR_BODY)
     r = add_pattern (&ColorBodyList, buf->data, 1, fg, bg, attr, err, 0);
-  else if (object == MT_COLOR_INDEX)
-  {
+  else if (object == MT_COLOR_INDEX) {
     r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1);
     set_option (OPTFORCEREDRAWINDEX);
   }
-  else if (object == MT_COLOR_QUOTED)
-  {
-    if (q_level >= ColorQuoteSize)
-    {
+  else if (object == MT_COLOR_QUOTED) {
+    if (q_level >= ColorQuoteSize) {
       safe_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int));
-      ColorQuote[ColorQuoteSize-2] = ColorDefs[MT_COLOR_QUOTED];
-      ColorQuote[ColorQuoteSize-1] = ColorDefs[MT_COLOR_QUOTED];
+      ColorQuote[ColorQuoteSize - 2] = ColorDefs[MT_COLOR_QUOTED];
+      ColorQuote[ColorQuoteSize - 1] = ColorDefs[MT_COLOR_QUOTED];
     }
     if (q_level >= ColorQuoteUsed)
       ColorQuoteUsed = q_level + 1;
-    if (q_level == 0)
-    {
-      ColorDefs[MT_COLOR_QUOTED] = fgbgattr_to_color(fg, bg, attr);
-      
+    if (q_level == 0) {
+      ColorDefs[MT_COLOR_QUOTED] = fgbgattr_to_color (fg, bg, attr);
+
       ColorQuote[0] = ColorDefs[MT_COLOR_QUOTED];
-      for (q_level = 1; q_level < ColorQuoteUsed; q_level++)
-      {
-       if (ColorQuote[q_level] == A_NORMAL)
-         ColorQuote[q_level] = ColorDefs[MT_COLOR_QUOTED];
+      for (q_level = 1; q_level < ColorQuoteUsed; q_level++) {
+        if (ColorQuote[q_level] == A_NORMAL)
+          ColorQuote[q_level] = ColorDefs[MT_COLOR_QUOTED];
       }
     }
     else
-      ColorQuote[q_level] = fgbgattr_to_color(fg, bg, attr);
+      ColorQuote[q_level] = fgbgattr_to_color (fg, bg, attr);
   }
   else
-    ColorDefs[object] = fgbgattr_to_color(fg, bg, attr);
+    ColorDefs[object] = fgbgattr_to_color (fg, bg, attr);
 
 #ifdef HAVE_COLOR
 # ifdef HAVE_BKGDSET
-  if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors())
+  if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ())
     BKGDSET (MT_COLOR_NORMAL);
 # endif
 #endif
@@ -779,30 +740,31 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err,
 
 #ifdef HAVE_COLOR
 
-int mutt_parse_color(BUFFER *buff, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data,
+                      BUFFER * err)
 {
   int dry_run = 0;
-  
-  if(option(OPTNOCURSES) || !has_colors())
+
+  if (option (OPTNOCURSES) || !has_colors ())
     dry_run = 1;
-  
-  return _mutt_parse_color(buff, s, err, parse_color_pair, dry_run);
+
+  return _mutt_parse_color (buff, s, err, parse_color_pair, dry_run);
 }
 
 #endif
 
-int mutt_parse_mono(BUFFER *buff, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_mono (BUFFER * buff, BUFFER * s, unsigned long data,
+                     BUFFER * err)
 {
   int dry_run = 0;
-  
+
 #ifdef HAVE_COLOR
-  if(option(OPTNOCURSES) || has_colors())
+  if (option (OPTNOCURSES) || has_colors ())
     dry_run = 1;
 #else
-  if(option(OPTNOCURSES))
+  if (option (OPTNOCURSES))
     dry_run = 1;
 #endif
 
-  return _mutt_parse_color(buff, s, err, parse_attr_spec, dry_run);
+  return _mutt_parse_color (buff, s, err, parse_attr_spec, dry_run);
 }
-
index 86a83ba..33051bb 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -59,7 +59,7 @@ extern char *ReleaseDate;
 /* The folder the user last saved to.  Used by ci_save_message() */
 static char LastSaveFolder[_POSIX_PATH_MAX] = "";
 
-int mutt_display_message (HEADER *cur)
+int mutt_display_message (HEADER * cur)
 {
   char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING];
   int rc = 0, builtin = 0;
@@ -70,40 +70,35 @@ int mutt_display_message (HEADER *cur)
   int res;
 
   snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content),
-           cur->content->subtype);
+            cur->content->subtype);
 
   mutt_parse_mime_message (Context, cur);
   mutt_message_hook (Context, cur, M_MESSAGEHOOK);
 
   /* see if crytpo is needed for this message.  if so, we should exit curses */
-  if (WithCrypto && cur->security)
-  {
-    if (cur->security & ENCRYPT)
-    {
+  if (WithCrypto && cur->security) {
+    if (cur->security & ENCRYPT) {
       if (cur->security & APPLICATION_SMIME)
-       crypt_smime_getkeys (cur->env);
-      if(!crypt_valid_passphrase(cur->security))
-       return 0;
+        crypt_smime_getkeys (cur->env);
+      if (!crypt_valid_passphrase (cur->security))
+        return 0;
 
       cmflags |= M_CM_VERIFY;
     }
-    else if (cur->security & SIGN)
-    {
+    else if (cur->security & SIGN) {
       /* find out whether or not the verify signature */
-      if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == M_YES)
-      {
-       cmflags |= M_CM_VERIFY;
+      if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) ==
+          M_YES) {
+        cmflags |= M_CM_VERIFY;
       }
     }
   }
-  
-  if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
-  {
-    if (cur->security & APPLICATION_PGP)
-    {
+
+  if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT) {
+    if (cur->security & APPLICATION_PGP) {
       if (cur->env->from)
         crypt_pgp_invoke_getkeys (cur->env->from);
-      
+
       crypt_invoke_message (APPLICATION_PGP);
     }
 
@@ -113,21 +108,19 @@ int mutt_display_message (HEADER *cur)
 
 
   mutt_mktemp (tempfile);
-  if ((fpout = safe_fopen (tempfile, "w")) == NULL)
-  {
+  if ((fpout = safe_fopen (tempfile, "w")) == NULL) {
     mutt_error _("Could not create temporary file!");
+
     return (0);
   }
 
-  if (DisplayFilter && *DisplayFilter) 
-  {
+  if (DisplayFilter && *DisplayFilter) {
     fpfilterout = fpout;
     fpout = NULL;
     /* mutt_endwin (NULL); */
     filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL,
-                                      -1, fileno(fpfilterout), -1);
-    if (filterpid < 0)
-    {
+                                       -1, fileno (fpfilterout), -1);
+    if (filterpid < 0) {
       mutt_error (_("Cannot create display filter"));
       safe_fclose (&fpfilterout);
       unlink (tempfile);
@@ -137,20 +130,18 @@ int mutt_display_message (HEADER *cur)
 
   if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
     builtin = 1;
-  else
-  {
-    mutt_make_string (buf, sizeof (buf), NONULL(PagerFmt), Context, cur);
+  else {
+    mutt_make_string (buf, sizeof (buf), NONULL (PagerFmt), Context, cur);
     fputs (buf, fpout);
     fputs ("\n\n", fpout);
   }
 
   res = mutt_copy_message (fpout, Context, cur, cmflags,
-               (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM);
-  if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1)
-  {
+                           (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                           CH_DECODE | CH_FROM);
+  if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res == -1) {
     mutt_error (_("Could not copy message"));
-    if (fpfilterout != NULL)
-    {
+    if (fpfilterout != NULL) {
       mutt_wait_filter (filterpid);
       safe_fclose (&fpfilterout);
     }
@@ -161,48 +152,45 @@ int mutt_display_message (HEADER *cur)
   if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
     mutt_any_key_to_continue (NULL);
 
-  safe_fclose (&fpfilterout);  /* XXX - check result? */
+  safe_fclose (&fpfilterout);   /* XXX - check result? */
+
 
-  
-  if (WithCrypto)
-  {
+  if (WithCrypto) {
     /* update crypto information for this message */
     cur->security |= crypt_query (cur->content);
-  
+
     /* Remove color cache for this message, in case there
        are color patterns for both ~g and ~V */
     cur->pair = 0;
   }
 
-  if (builtin)
-  {
+  if (builtin) {
     pager_t info;
 
-    if (WithCrypto 
-        && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
-    {
-      if (cur->security & GOODSIGN)
-      {
-       if (!crypt_smime_verify_sender(cur))
-         mutt_message ( _("S/MIME signature successfully verified."));
-       else
-         mutt_error ( _("S/MIME certificate owner does not match sender."));
+    if (WithCrypto
+        && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY)) {
+      if (cur->security & GOODSIGN) {
+        if (!crypt_smime_verify_sender (cur))
+          mutt_message (_("S/MIME signature successfully verified."));
+        else
+          mutt_error (_("S/MIME certificate owner does not match sender."));
       }
       else if (cur->security & PARTSIGN)
-       mutt_message (_("Warning: Part of this message has not been signed."));
+        mutt_message (_
+                      ("Warning: Part of this message has not been signed."));
       else if (cur->security & SIGN || cur->security & BADSIGN)
-       mutt_error ( _("S/MIME signature could NOT be verified."));
+        mutt_error (_("S/MIME signature could NOT be verified."));
     }
 
-    if (WithCrypto 
-        && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
-    {
+    if (WithCrypto
+        && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) {
       if (cur->security & GOODSIGN)
-       mutt_message (_("PGP signature successfully verified."));
+        mutt_message (_("PGP signature successfully verified."));
       else if (cur->security & PARTSIGN)
-       mutt_message (_("Warning: Part of this message has not been signed."));
+        mutt_message (_
+                      ("Warning: Part of this message has not been signed."));
       else
-       mutt_message (_("PGP signature could NOT be verified."));
+        mutt_message (_("PGP signature could NOT be verified."));
     }
 
     /* Invoke the builtin pager */
@@ -211,20 +199,18 @@ int mutt_display_message (HEADER *cur)
     info.ctx = Context;
     rc = mutt_pager (NULL, tempfile, M_PAGER_MESSAGE, &info);
   }
-  else
-  {
+  else {
     int r;
 
     mutt_endwin (NULL);
-    snprintf (buf, sizeof (buf), "%s %s", NONULL(Pager), tempfile);
+    snprintf (buf, sizeof (buf), "%s %s", NONULL (Pager), tempfile);
     if ((r = mutt_system (buf)) == -1)
       mutt_error (_("Error running \"%s\"!"), buf);
     unlink (tempfile);
     keypad (stdscr, TRUE);
     if (r != -1)
       mutt_set_flag (Context, cur, M_READ, 1);
-    if (r != -1 && option (OPTPROMPTAFTER))
-    {
+    if (r != -1 && option (OPTPROMPTAFTER)) {
       mutt_ungetch (mutt_any_key_to_continue _("Command: "), 0);
       rc = km_dokey (MENU_PAGER);
     }
@@ -235,7 +221,7 @@ int mutt_display_message (HEADER *cur)
   return rc;
 }
 
-void ci_bounce_message (HEADER *h, int *redraw)
+void ci_bounce_message (HEADER * h, int *redraw)
 {
   char prompt[SHORT_STRING];
   char buf[HUGE_STRING] = { 0 };
@@ -243,15 +229,14 @@ void ci_bounce_message (HEADER *h, int *redraw)
   char *err = NULL;
   int rc;
 
-  if(h)
-    strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
+  if (h)
+    strfcpy (prompt, _("Bounce message to: "), sizeof (prompt));
   else
-    strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
-  
+    strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
+
   rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS);
 
-  if (option (OPTNEEDREDRAW))
-  {
+  if (option (OPTNEEDREDRAW)) {
     unset_option (OPTNEEDREDRAW);
     *redraw = REDRAW_FULL;
   }
@@ -259,16 +244,15 @@ void ci_bounce_message (HEADER *h, int *redraw)
   if (rc || !buf[0])
     return;
 
-  if (!(adr = rfc822_parse_adrlist (adr, buf)))
-  {
+  if (!(adr = rfc822_parse_adrlist (adr, buf))) {
     mutt_error _("Error parsing address!");
+
     return;
   }
 
   adr = mutt_expand_aliases (adr);
 
-  if (mutt_addrlist_to_idna (adr, &err) < 0)
-  {
+  if (mutt_addrlist_to_idna (adr, &err) < 0) {
     mutt_error (_("Bad IDN: '%s'"), err);
     FREE (&err);
     rfc822_free_address (&adr);
@@ -280,20 +264,19 @@ void ci_bounce_message (HEADER *h, int *redraw)
 
 #define extra_space (15 + 7 + 2)
   snprintf (prompt, sizeof (prompt),
-           (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
+            (h ? _("Bounce message to %s") : _("Bounce messages to %s")),
+            buf);
 
-  if (mutt_strwidth (prompt) > COLS - extra_space)
-  {
+  if (mutt_strwidth (prompt) > COLS - extra_space) {
     mutt_format_string (prompt, sizeof (prompt),
-                       0, COLS-extra_space, 0, 0,
-                       prompt, sizeof (prompt), 0);
+                        0, COLS - extra_space, 0, 0,
+                        prompt, sizeof (prompt), 0);
     safe_strcat (prompt, sizeof (prompt), "...?");
   }
   else
     safe_strcat (prompt, sizeof (prompt), "?");
 
-  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
-  {
+  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
     rfc822_free_address (&adr);
     CLEARLINE (LINES - 1);
     mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
@@ -301,7 +284,7 @@ void ci_bounce_message (HEADER *h, int *redraw)
   }
 
   CLEARLINE (LINES - 1);
-  
+
   rc = mutt_bounce_message (NULL, h, adr);
   rfc822_free_address (&adr);
   /* If no error, or background, display message. */
@@ -311,33 +294,30 @@ void ci_bounce_message (HEADER *h, int *redraw)
 
 static void pipe_set_flags (int decode, int print, int *cmflags, int *chflags)
 {
-  if (decode)
-  {
+  if (decode) {
     *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
     *chflags |= CH_DECODE | CH_REORDER;
-    
-    if (option (OPTWEED))
-    {
+
+    if (option (OPTWEED)) {
       *chflags |= CH_WEED;
       *cmflags |= M_CM_WEED;
     }
   }
-  
+
   if (print)
     *cmflags |= M_CM_PRINTING;
-  
+
 }
 
-static void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
+static void pipe_msg (HEADER * h, FILE * fp, int decode, int print)
 {
   int cmflags = 0;
   int chflags = CH_FROM;
-  
+
   pipe_set_flags (decode, print, &cmflags, &chflags);
 
-  if (WithCrypto && decode && h->security & ENCRYPT)
-  {
-    if(!crypt_valid_passphrase(h->security))
+  if (WithCrypto && decode && h->security & ENCRYPT) {
+    if (!crypt_valid_passphrase (h->security))
       return;
     endwin ();
   }
@@ -351,105 +331,97 @@ static void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
 
 /* the following code is shared between printing and piping */
 
-static int _mutt_pipe_message (HEADER *h, char *cmd,
-                              int decode,
-                              int print,
-                              int split,
-                              char *sep)
+static int _mutt_pipe_message (HEADER * h, char *cmd,
+                               int decode, int print, int split, char *sep)
 {
-  
+
   int i, rc = 0;
   pid_t thepid;
   FILE *fpout;
-  
+
 /*   mutt_endwin (NULL); 
 
      is this really needed here ? 
      it makes the screen flicker on pgp and s/mime messages,
      before asking for a passphrase...
                                      Oliver Ehli */
-  if (h)
-  {
+  if (h) {
 
     mutt_message_hook (Context, h, M_MESSAGEHOOK);
 
-    if (WithCrypto && decode)
-    {
+    if (WithCrypto && decode) {
       mutt_parse_mime_message (Context, h);
-      if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
-       return 1;
+      if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
+        return 1;
     }
     mutt_endwin (NULL);
 
-    if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
-    {
+    if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
       mutt_perror _("Can't create filter process");
+
       return 1;
     }
-      
+
     pipe_msg (h, fpout, decode, print);
     fclose (fpout);
     rc = mutt_wait_filter (thepid);
   }
-  else
-  { /* handle tagged messages */
+  else {                        /* handle tagged messages */
 
-    if (WithCrypto && decode)
-    {
+    if (WithCrypto && decode) {
       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_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]);
-         if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
-             !crypt_valid_passphrase(Context->hdrs[Context->v2r[i]]->security))
-           return 1;
-       }
+        if (Context->hdrs[Context->v2r[i]]->tagged) {
+          mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
+                             M_MESSAGEHOOK);
+          mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
+          if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
+              !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
+                                       security))
+            return 1;
+        }
     }
-    
-    if (split)
-    {
-      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_endwin (NULL);
-         if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
-         {
-           mutt_perror _("Can't create filter process");
-           return 1;
-         }
+
+    if (split) {
+      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_endwin (NULL);
+          if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
+            mutt_perror _("Can't create filter process");
+
+            return 1;
+          }
           pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
           /* add the message separator */
-          if (sep)  fputs (sep, fpout);
-         safe_fclose (&fpout);
-         if (mutt_wait_filter (thepid) != 0)
-           rc = 1;
+          if (sep)
+            fputs (sep, fpout);
+          safe_fclose (&fpout);
+          if (mutt_wait_filter (thepid) != 0)
+            rc = 1;
         }
       }
     }
-    else
-    {
+    else {
       mutt_endwin (NULL);
-      if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
-      {
-       mutt_perror _("Can't create filter process");
-       return 1;
+      if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0) {
+        mutt_perror _("Can't create filter process");
+
+        return 1;
       }
-      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);
+      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);
           pipe_msg (Context->hdrs[Context->v2r[i]], fpout, decode, print);
           /* add the message separator */
-          if (sep) fputs (sep, fpout);
+          if (sep)
+            fputs (sep, fpout);
         }
       }
       safe_fclose (&fpout);
       if (mutt_wait_filter (thepid) != 0)
-       rc = 1;
+        rc = 1;
     }
   }
 
@@ -458,7 +430,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
   return rc;
 }
 
-void mutt_pipe_message (HEADER *h)
+void mutt_pipe_message (HEADER * h)
 {
   char buffer[LONG_STRING];
 
@@ -469,94 +441,91 @@ void mutt_pipe_message (HEADER *h)
 
   mutt_expand_path (buffer, sizeof (buffer));
   _mutt_pipe_message (h, buffer,
-                     option (OPTPIPEDECODE),
-                     0, 
-                     option (OPTPIPESPLIT),
-                     PipeSep);
+                      option (OPTPIPEDECODE),
+                      0, option (OPTPIPESPLIT), PipeSep);
 }
 
-void mutt_print_message (HEADER *h)
+void mutt_print_message (HEADER * h)
 {
 
-  if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd))
-  {
+  if (quadoption (OPT_PRINT) && (!PrintCmd || !*PrintCmd)) {
     mutt_message (_("No printing command has been defined."));
     return;
   }
-  
+
   if (query_quadoption (OPT_PRINT,
-                       h ? _("Print message?") : _("Print tagged messages?"))
-                       != M_YES)
+                        h ? _("Print message?") : _("Print tagged messages?"))
+      != M_YES)
     return;
 
   if (_mutt_pipe_message (h, PrintCmd,
-                         option (OPTPRINTDECODE),
-                         1,
-                         option (OPTPRINTSPLIT),
-                         "\f") == 0)
+                          option (OPTPRINTDECODE),
+                          1, option (OPTPRINTSPLIT), "\f") == 0)
     mutt_message (h ? _("Message printed") : _("Messages printed"));
   else
     mutt_message (h ? _("Message could not be printed") :
-                 _("Messages could not be printed"));
+                  _("Messages could not be printed"));
 }
 
 
 int mutt_select_sort (int reverse)
 {
-  int method = Sort; /* save the current method in case of abort */
+  int method = Sort;            /* save the current method in case of abort */
 
   switch (mutt_multi_choice (reverse ?
-                            _("Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: ") :
-                            _("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
-                            _("dfrsotuzcp")))
-  {
-  case -1: /* abort - don't resort */
+                             _
+                             ("Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: ")
+                             :
+                             _
+                             ("Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore/s(p)am?: "),
+                             _("dfrsotuzcp"))) {
+  case -1:                     /* abort - don't resort */
     return -1;
 
-  case 1: /* (d)ate */
+  case 1:                      /* (d)ate */
     Sort = SORT_DATE;
     break;
 
-  case 2: /* (f)rm */
+  case 2:                      /* (f)rm */
     Sort = SORT_FROM;
     break;
-  
-  case 3: /* (r)ecv */
+
+  case 3:                      /* (r)ecv */
     Sort = SORT_RECEIVED;
     break;
-  
-  case 4: /* (s)ubj */
+
+  case 4:                      /* (s)ubj */
     Sort = SORT_SUBJECT;
     break;
-  
-  case 5: /* t(o) */
+
+  case 5:                      /* t(o) */
     Sort = SORT_TO;
     break;
-  
-  case 6: /* (t)hread */
+
+  case 6:                      /* (t)hread */
     Sort = SORT_THREADS;
     break;
-  
-  case 7: /* (u)nsort */
+
+  case 7:                      /* (u)nsort */
     Sort = SORT_ORDER;
     break;
-  
-  case 8: /* si(z)e */
+
+  case 8:                      /* si(z)e */
     Sort = SORT_SIZE;
     break;
-  
-  case 9: /* s(c)ore */ 
+
+  case 9:                      /* s(c)ore */
     Sort = SORT_SCORE;
     break;
 
-  case 10: /* s(p)am */
+  case 10:                     /* s(p)am */
     Sort = SORT_SPAM;
     break;
   }
   if (reverse)
     Sort |= SORT_REVERSE;
 
-  return (Sort != method ? 0 : -1); /* no need to resort if it's the same */
+  return (Sort != method ? 0 : -1);     /* no need to resort if it's the same */
 }
 
 /* invoke a command in a subshell */
@@ -565,17 +534,15 @@ void mutt_shell_escape (void)
   char buf[LONG_STRING];
 
   buf[0] = 0;
-  if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0)
-  {
+  if (mutt_get_field (_("Shell command: "), buf, sizeof (buf), M_CMD) == 0) {
     if (!buf[0] && Shell)
       strfcpy (buf, Shell, sizeof (buf));
-    if(buf[0])
-    {
-      CLEARLINE (LINES-1);
+    if (buf[0]) {
+      CLEARLINE (LINES - 1);
       mutt_endwin (NULL);
       fflush (stdout);
       if (mutt_system (buf) != 0 || option (OPTWAITKEY))
-       mutt_any_key_to_continue (NULL);
+        mutt_any_key_to_continue (NULL);
     }
   }
 }
@@ -588,15 +555,15 @@ void mutt_enter_command (void)
   int r;
 
   buffer[0] = 0;
-  if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0 || !buffer[0])
+  if (mutt_get_field (":", buffer, sizeof (buffer), M_COMMAND) != 0
+      || !buffer[0])
     return;
   err.data = errbuf;
   err.dsize = sizeof (errbuf);
   memset (&token, 0, sizeof (token));
   r = mutt_parse_rc_line (buffer, &token, &err);
   FREE (&token.data);
-  if (errbuf[0])
-  {
+  if (errbuf[0]) {
     /* since errbuf could potentially contain printf() sequences in it,
        we must call mutt_error() in this fashion so that vsprintf()
        doesn't expect more arguments that we passed */
@@ -607,7 +574,7 @@ void mutt_enter_command (void)
   }
 }
 
-void mutt_display_address (ENVELOPE *env)
+void mutt_display_address (ENVELOPE * env)
 {
   char *pfx = NULL;
   char buf[SHORT_STRING];
@@ -615,92 +582,88 @@ void mutt_display_address (ENVELOPE *env)
 
   adr = mutt_get_address (env, &pfx);
 
-  if (!adr) return;
-  
+  if (!adr)
+    return;
+
   /* 
    * Note: We don't convert IDNA to local representation this time.
    * That is intentional, so the user has an opportunity to copy &
    * paste the on-the-wire form of the address to other, IDN-unable
    * software. 
    */
-  
+
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), adr, 0);
   mutt_message ("%s: %s", pfx, buf);
 }
 
-static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags, int *chflags)
+static void set_copy_flags (HEADER * hdr, int decode, int decrypt,
+                            int *cmflags, int *chflags)
 {
   *cmflags = 0;
   *chflags = CH_UPDATE_LEN;
-  
-  if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT))
-  {
+
+  if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT)) {
     if ((WithCrypto & APPLICATION_PGP)
-        && mutt_is_multipart_encrypted(hdr->content))
-    {
+        && mutt_is_multipart_encrypted (hdr->content)) {
       *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
       *cmflags = M_CM_DECODE_PGP;
     }
     else if ((WithCrypto & APPLICATION_PGP)
-              && mutt_is_application_pgp (hdr->content) & ENCRYPT)
+             && mutt_is_application_pgp (hdr->content) & ENCRYPT)
       decode = 1;
     else if ((WithCrypto & APPLICATION_SMIME)
-             && mutt_is_application_smime(hdr->content) & ENCRYPT)
-    {
+             && mutt_is_application_smime (hdr->content) & ENCRYPT) {
       *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
       *cmflags = M_CM_DECODE_SMIME;
     }
   }
 
-  if (decode)
-  {
+  if (decode) {
     *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
     *cmflags = M_CM_DECODE | M_CM_CHARCONV;
 
-    if (!decrypt)      /* If decode doesn't kick in for decrypt, */
-    {
-      *chflags |= CH_DECODE;   /* then decode RFC 2047 headers, */
+    if (!decrypt) {             /* If decode doesn't kick in for decrypt, */
+      *chflags |= CH_DECODE;    /* then decode RFC 2047 headers, */
 
-      if (option (OPTWEED))
-      {
-       *chflags |= CH_WEED;    /* and respect $weed. */
-       *cmflags |= M_CM_WEED;
+      if (option (OPTWEED)) {
+        *chflags |= CH_WEED;    /* and respect $weed. */
+        *cmflags |= M_CM_WEED;
       }
     }
   }
 }
 
-void _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt)
+void _mutt_save_message (HEADER * h, CONTEXT * ctx, int delete, int decode,
+                         int decrypt)
 {
   int cmflags, chflags;
-  
+
   set_copy_flags (h, decode, decrypt, &cmflags, &chflags);
 
   if (decode || decrypt)
     mutt_parse_mime_message (Context, h);
 
-  if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0)
-  {
-    if (delete)
-    {
+  if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0) {
+    if (delete) {
       mutt_set_flag (Context, h, M_DELETE, 1);
       if (option (OPTDELETEUNTAG))
-       mutt_set_flag (Context, h, M_TAG, 0);
+        mutt_set_flag (Context, h, M_TAG, 0);
     }
     mutt_set_flag (Context, h, M_APPENDED, 1);
   }
 }
 
 /* returns 0 if the copy/save was successful, or -1 on error/abort */
-int mutt_save_message (HEADER *h, int delete, 
-                      int decode, int decrypt, int *redraw)
+int mutt_save_message (HEADER * h, int delete,
+                       int decode, int decrypt, int *redraw)
 {
   int i, need_buffy_cleanup;
-  int need_passphrase = 0, app=0;
+  int need_passphrase = 0, app = 0;
   char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
   CONTEXT ctx;
   struct stat st;
+
 #ifdef BUFFY_SIZE
   BUFFY *tmp = NULL;
 #else
@@ -709,46 +672,39 @@ int mutt_save_message (HEADER *h, int delete,
 
   *redraw = 0;
 
-  
+
   snprintf (prompt, sizeof (prompt),
-           decode  ? (delete ? _("Decode-save%s to mailbox") :
-                      _("Decode-copy%s to mailbox")) :
-           (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
-                       _("Decrypt-copy%s to mailbox")) :
-            (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
-           h ? "" : _(" tagged"));
-  
+            decode ? (delete ? _("Decode-save%s to mailbox") :
+                      _("Decode-copy%s to mailbox")) :
+            (decrypt ? (delete ? _("Decrypt-save%s to mailbox") :
+                        _("Decrypt-copy%s to mailbox")) :
+             (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
+            h ? "" : _(" tagged"));
 
-  if (h)
-  {
-    if (WithCrypto)
-    {
+
+  if (h) {
+    if (WithCrypto) {
       need_passphrase = h->security & ENCRYPT;
       app = h->security;
     }
     mutt_message_hook (Context, h, M_MESSAGEHOOK);
     mutt_default_save (buf, sizeof (buf), h);
   }
-  else
-  {
+  else {
     /* look for the first tagged message */
 
-    for (i = 0; i < Context->vcount; i++)
-    {
-      if (Context->hdrs[Context->v2r[i]]->tagged)
-      {
-       h = Context->hdrs[Context->v2r[i]];
-       break;
+    for (i = 0; i < Context->vcount; i++) {
+      if (Context->hdrs[Context->v2r[i]]->tagged) {
+        h = Context->hdrs[Context->v2r[i]];
+        break;
       }
     }
 
 
-    if (h)
-    {
+    if (h) {
       mutt_message_hook (Context, h, M_MESSAGEHOOK);
       mutt_default_save (buf, sizeof (buf), h);
-      if (WithCrypto)
-      {
+      if (WithCrypto) {
         need_passphrase = h->security & ENCRYPT;
         app = h->security;
       }
@@ -760,8 +716,7 @@ int mutt_save_message (HEADER *h, int delete,
   if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
     return (-1);
 
-  if (*redraw != REDRAW_FULL)
-  {
+  if (*redraw != REDRAW_FULL) {
     if (!h)
       *redraw = REDRAW_INDEX | REDRAW_STATUS;
     else
@@ -770,7 +725,7 @@ int mutt_save_message (HEADER *h, int delete,
 
   if (!buf[0])
     return (-1);
+
   /* This is an undocumented feature of ELM pointed out to me by Felix von
    * Leitner <leitner@prz.fu-berlin.de>
    */
@@ -786,41 +741,39 @@ int mutt_save_message (HEADER *h, int delete,
     return -1;
 
   if (WithCrypto && need_passphrase && (decode || decrypt)
-      && !crypt_valid_passphrase(app))
+      && !crypt_valid_passphrase (app))
     return -1;
-  
+
   mutt_message (_("Copying to %s..."), buf);
-  
+
 #ifdef USE_IMAP
-  if (Context->magic == M_IMAP && 
-      !(decode || decrypt) && mx_is_imap (buf))
-  {
-    switch (imap_copy_messages (Context, h, buf, delete))
-    {
+  if (Context->magic == M_IMAP && !(decode || decrypt) && mx_is_imap (buf)) {
+    switch (imap_copy_messages (Context, h, buf, delete)) {
       /* success */
-      case 0: mutt_clear_error (); return 0;
+    case 0:
+      mutt_clear_error ();
+      return 0;
       /* non-fatal error: fall through to fetch/append */
-      case 1: break;
+    case 1:
+      break;
       /* fatal error, abort */
-      case -1: return -1;
+    case -1:
+      return -1;
     }
   }
 #endif
 
-  if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL)
-  {
+  if (mx_open_mailbox (buf, M_APPEND, &ctx) != NULL) {
     if (h)
-      _mutt_save_message(h, &ctx, delete, decode, decrypt);
-    else
-    {
-      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_save_message(Context->hdrs[Context->v2r[i]],
-                            &ctx, delete, decode, decrypt);
-       }
+      _mutt_save_message (h, &ctx, delete, decode, decrypt);
+    else {
+      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_save_message (Context->hdrs[Context->v2r[i]], &ctx, delete,
+                              decode, decrypt);
+        }
       }
     }
 
@@ -828,33 +781,32 @@ int mutt_save_message (HEADER *h, int delete,
 
     mx_close_mailbox (&ctx, NULL);
 
-    if (need_buffy_cleanup)
-    {
+    if (need_buffy_cleanup) {
 #ifdef BUFFY_SIZE
       tmp = mutt_find_mailbox (buf);
       if (tmp && tmp->new <= 0)
-       mutt_update_mailbox (tmp);
+        mutt_update_mailbox (tmp);
 #else
       /* fix up the times so buffy won't get confused */
-      if (st.st_mtime > st.st_atime)
-      {
-       ut.actime = st.st_atime;
-       ut.modtime = time (NULL);
-       utime (buf, &ut); 
+      if (st.st_mtime > st.st_atime) {
+        ut.actime = st.st_atime;
+        ut.modtime = time (NULL);
+        utime (buf, &ut);
       }
       else
-       utime (buf, NULL);
+        utime (buf, NULL);
 #endif
     }
 
     mutt_clear_error ();
     return (0);
   }
-  
+
   return -1;
 }
 
-int mutt_update_list_file (char *filename, char *section, char *key, char *line)
+int mutt_update_list_file (char *filename, char *section, char *key,
+                           char *line)
 {
   FILE *ifp;
   FILE *ofp;
@@ -863,95 +815,90 @@ int mutt_update_list_file (char *filename, char *section, char *key, char *line)
   char *c;
   int ext = 0, done = 0, r = 0;
 
-  snprintf (oldfile, sizeof(oldfile), "%s.bak", filename);
+  snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
   dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
 
   /* if file not exist, create it */
   if ((ifp = safe_fopen (filename, "a")))
     fclose (ifp);
-  if (_mutt_rename_file (filename, oldfile, 1))
-  {
+  if (_mutt_rename_file (filename, oldfile, 1)) {
     mutt_perror _("Unable to create backup file");
+
     return (-1);
   }
   dprint (1, (debugfile, "Opening %s\n", oldfile));
-  if (!(ifp = safe_fopen (oldfile, "r")))
-  {
+  if (!(ifp = safe_fopen (oldfile, "r"))) {
     mutt_perror _("Unable to open backup file for reading");
+
     return (-1);
   }
   dprint (1, (debugfile, "Opening %s\n", filename));
-  if (!(ofp = safe_fopen (filename, "w")))
-  {
+  if (!(ofp = safe_fopen (filename, "w"))) {
     fclose (ifp);
     mutt_perror _("Unable to open new file for writing");
+
     return (-1);
   }
-  if (mx_lock_file (filename, fileno (ofp), 1, 0, 1))
-  {
+  if (mx_lock_file (filename, fileno (ofp), 1, 0, 1)) {
     fclose (ofp);
     fclose (ifp);
-    mutt_error (_("Unable to lock %s, old file saved as %s"), filename, oldfile);
+    mutt_error (_("Unable to lock %s, old file saved as %s"), filename,
+                oldfile);
     return (-1);
   }
 
-  if (section)
-  {
-    while (r != EOF && !done && fgets (buf, sizeof (buf), ifp))
-    {
+  if (section) {
+    while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) {
       r = fputs (buf, ofp);
       c = buf;
-      while (*c && *c != '\n') c++;
-      c[0] = 0;        /* strip EOL */
-      if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf+3, section))
-       done++;
+      while (*c && *c != '\n')
+        c++;
+      c[0] = 0;                 /* strip EOL */
+      if (!strncmp (buf, "#: ", 3) && !mutt_strcasecmp (buf + 3, section))
+        done++;
     }
-    if (r != EOF && !done)
-    {
-      snprintf (buf, sizeof(buf), "#: %s\n", section);
+    if (r != EOF && !done) {
+      snprintf (buf, sizeof (buf), "#: %s\n", section);
       r = fputs (buf, ofp);
     }
     done = 0;
   }
 
-  while (r != EOF && fgets (buf, sizeof (buf), ifp))
-  {
-    if (ext)
-    {
+  while (r != EOF && fgets (buf, sizeof (buf), ifp)) {
+    if (ext) {
       c = buf;
-      while (*c && (*c != '\r') && (*c != '\n')) c++;
+      while (*c && (*c != '\r') && (*c != '\n'))
+        c++;
       c--;
-      if (*c != '\\') ext = 0;
+      if (*c != '\\')
+        ext = 0;
     }
-    else if ((section && !strncmp (buf, "#: ", 3)))
-    {
-      if (!done && line)
-      {
-       fputs (line, ofp);
-       fputc ('\n', ofp);
+    else if ((section && !strncmp (buf, "#: ", 3))) {
+      if (!done && line) {
+        fputs (line, ofp);
+        fputc ('\n', ofp);
       }
       r = fputs (buf, ofp);
       done++;
       break;
     }
-    else if (key && !strncmp (buf, key, strlen(key)) &&
-           (!*key || buf[strlen(key)] == ' '))
-    {
+    else if (key && !strncmp (buf, key, strlen (key)) &&
+             (!*key || buf[strlen (key)] == ' ')) {
       c = buf;
       ext = 0;
-      while (*c && (*c != '\r') && (*c != '\n')) c++;
+      while (*c && (*c != '\r') && (*c != '\n'))
+        c++;
       c--;
-      if (*c == '\\') ext = 1;
-      if (!done && line)
-      {
-       r = fputs (line, ofp);
-       if (*key)
-         r = fputc ('\n', ofp);
-       done++;
+      if (*c == '\\')
+        ext = 1;
+      if (!done && line) {
+        r = fputs (line, ofp);
+        if (*key)
+          r = fputc ('\n', ofp);
+        done++;
       }
     }
-    else
-    {
+    else {
       r = fputs (buf, ofp);
     }
   }
@@ -960,22 +907,20 @@ int mutt_update_list_file (char *filename, char *section, char *key, char *line)
     r = fputs (buf, ofp);
 
   /* If there wasn't a line to replace, put it on the end of the file */
-  if (r != EOF && !done && line)
-  {
+  if (r != EOF && !done && line) {
     fputs (line, ofp);
     r = fputc ('\n', ofp);
   }
   mx_unlock_file (filename, fileno (ofp), 0);
   fclose (ofp);
   fclose (ifp);
-  if (r != EOF)
-  {
+  if (r != EOF) {
     unlink (oldfile);
     return 0;
   }
   unlink (filename);
   mutt_error (_("Cannot write new %s, old file saved as %s"), filename,
-       oldfile);
+              oldfile);
   return (-1);
 }
 
@@ -985,7 +930,7 @@ void mutt_version (void)
   mutt_message ("Mutt-ng %s (%s)", MUTT_VERSION, ReleaseDate);
 }
 
-void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
+void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
 {
   char buf[LONG_STRING];
   char obuf[LONG_STRING];
@@ -997,125 +942,120 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
 
   short charset_changed = 0;
   short type_changed = 0;
-  
+
   cp = mutt_get_parameter ("charset", b->parameter);
   strfcpy (charset, NONULL (cp), sizeof (charset));
 
   snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
   strfcpy (obuf, buf, sizeof (obuf));
-  if (b->parameter)
-  {
+  if (b->parameter) {
     size_t l;
-    
-    for (p = b->parameter; p; p = p->next)
-    {
+
+    for (p = b->parameter; p; p = p->next) {
       l = strlen (buf);
 
       rfc822_cat (tmp, sizeof (tmp), p->value, MimeSpecials);
       snprintf (buf + l, sizeof (buf) - l, "; %s=%s", p->attribute, tmp);
     }
   }
-  
+
   if (mutt_get_field ("Content-Type: ", buf, sizeof (buf), 0) != 0 ||
       buf[0] == 0)
     return;
-  
+
   /* clean up previous junk */
   mutt_free_parameter (&b->parameter);
   FREE (&b->subtype);
-  
+
   mutt_parse_content_type (buf, b);
 
-  
+
   snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
   type_changed = ascii_strcasecmp (tmp, obuf);
-  charset_changed = ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
+  charset_changed =
+    ascii_strcasecmp (charset, mutt_get_parameter ("charset", b->parameter));
 
   /* if in send mode, check for conversion - current setting is default. */
 
-  if (!h && b->type == TYPETEXT && charset_changed)
-  {
+  if (!h && b->type == TYPETEXT && charset_changed) {
     int r;
+
     snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"),
-             mutt_get_parameter ("charset", b->parameter));
+              mutt_get_parameter ("charset", b->parameter));
     if ((r = mutt_yesorno (tmp, !b->noconv)) != -1)
       b->noconv = (r == M_NO);
   }
 
   /* inform the user */
-  
+
   snprintf (tmp, sizeof (tmp), "%s/%s", TYPE (b), NONULL (b->subtype));
   if (type_changed)
     mutt_message (_("Content-Type changed to %s."), tmp);
-  if (b->type == TYPETEXT && charset_changed)
-  {
+  if (b->type == TYPETEXT && charset_changed) {
     if (type_changed)
       mutt_sleep (1);
     mutt_message (_("Character set changed to %s; %s."),
-                 mutt_get_parameter ("charset", b->parameter),
-                 b->noconv ? _("not converting") : _("converting"));
+                  mutt_get_parameter ("charset", b->parameter),
+                  b->noconv ? _("not converting") : _("converting"));
   }
 
   b->force_charset |= charset_changed ? 1 : 0;
 
   if (!is_multipart (b) && b->parts)
     mutt_free_body (&b->parts);
-  if (!mutt_is_message_type (b->type, b->subtype) && b->hdr)
-  {
+  if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
     b->hdr->content = NULL;
     mutt_free_header (&b->hdr);
   }
 
   if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
     mutt_parse_part (fp, b);
-  
-  if (WithCrypto && h)
-  {
+
+  if (WithCrypto && h) {
     if (h->content == b)
-      h->security  = 0;
+      h->security = 0;
 
     h->security |= crypt_query (b);
   }
 }
 
 
-static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
+static int _mutt_check_traditional_pgp (HEADER * h, int *redraw)
 {
   MESSAGE *msg;
   int rv = 0;
-  
+
   h->security |= PGP_TRADITIONAL_CHECKED;
-  
+
   mutt_parse_mime_message (Context, h);
   if ((msg = mx_open_message (Context, h->msgno)) == NULL)
     return 0;
-  if (crypt_pgp_check_traditional (msg->fp, h->content, 0))
-  {
+  if (crypt_pgp_check_traditional (msg->fp, h->content, 0)) {
     h->security = crypt_query (h->content);
     *redraw |= REDRAW_FULL;
     rv = 1;
   }
-  
+
   h->security |= PGP_TRADITIONAL_CHECKED;
   mx_close_message (&msg);
   return rv;
 }
 
-int mutt_check_traditional_pgp (HEADER *h, int *redraw)
+int mutt_check_traditional_pgp (HEADER * h, int *redraw)
 {
   int i;
   int rv = 0;
+
   if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
     rv = _mutt_check_traditional_pgp (h, redraw);
-  else
-  {
+  else {
     for (i = 0; i < Context->vcount; i++)
-      if (Context->hdrs[Context->v2r[i]]->tagged && 
-         !(Context->hdrs[Context->v2r[i]]->security & PGP_TRADITIONAL_CHECKED))
-       rv = _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)
-         || rv;
+      if (Context->hdrs[Context->v2r[i]]->tagged &&
+          !(Context->hdrs[Context->v2r[i]]->
+            security & PGP_TRADITIONAL_CHECKED))
+        rv =
+          _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], redraw)
+          || rv;
   }
   return rv;
 }
-
-
index d8355a7..fcb9269 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -45,10 +45,11 @@ int mutt_complete (char *s, size_t slen)
   char *p;
   DIR *dirp = NULL;
   struct dirent *de;
-  int i ,init=0;
+  int i, init = 0;
   size_t len;
   char dirpart[_POSIX_PATH_MAX], exp_dirpart[_POSIX_PATH_MAX];
   char filepart[_POSIX_PATH_MAX];
+
 #ifdef USE_IMAP
   char imap_path[LONG_STRING];
 #endif
@@ -56,8 +57,7 @@ int mutt_complete (char *s, size_t slen)
   dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
 
 #ifdef USE_NNTP
-  if (option (OPTNEWS))
-  {
+  if (option (OPTNEWS)) {
     LIST *l = CurrentNewsSrv->list;
 
     strfcpy (filepart, s, sizeof (filepart));
@@ -66,46 +66,37 @@ int mutt_complete (char *s, size_t slen)
      * special case to handle when there is no filepart yet.
      * find the first subscribed newsgroup
      */
-    if ((len = mutt_strlen (filepart)) == 0)
-    {
-      for (; l; l = l->next)
-      {
-       NNTP_DATA *data = (NNTP_DATA *)l->data;
-
-       if (data && data->subscribed)
-       {
-         strfcpy (filepart, data->group, sizeof (filepart));
-         init++;
-         l = l->next;
-         break;
-       }
+    if ((len = mutt_strlen (filepart)) == 0) {
+      for (; l; l = l->next) {
+        NNTP_DATA *data = (NNTP_DATA *) l->data;
+
+        if (data && data->subscribed) {
+          strfcpy (filepart, data->group, sizeof (filepart));
+          init++;
+          l = l->next;
+          break;
+        }
       }
     }
 
-    for (; l; l = l->next)
-    {
-      NNTP_DATA *data = (NNTP_DATA *)l->data;
+    for (; l; l = l->next) {
+      NNTP_DATA *data = (NNTP_DATA *) l->data;
 
       if (data && data->subscribed &&
-         mutt_strncmp (data->group, filepart, len) == 0)
-      {
-       if (init)
-       {
-         for (i = 0; filepart[i] && data->group[i]; i++)
-         {
-           if (filepart[i] != data->group[i])
-           {
-             filepart[i] = 0;
-             break;
-           }
-         }
-         filepart[i] = 0;
-       }
-       else
-       {
-         strfcpy (filepart, data->group, sizeof (filepart));
-         init = 1;
-       }
+          mutt_strncmp (data->group, filepart, len) == 0) {
+        if (init) {
+          for (i = 0; filepart[i] && data->group[i]; i++) {
+            if (filepart[i] != data->group[i]) {
+              filepart[i] = 0;
+              break;
+            }
+          }
+          filepart[i] = 0;
+        }
+        else {
+          strfcpy (filepart, data->group, sizeof (filepart));
+          init = 1;
+        }
       }
     }
 
@@ -117,37 +108,35 @@ int mutt_complete (char *s, size_t slen)
 
 #ifdef USE_IMAP
   /* we can use '/' as a delimiter, imap_complete rewrites it */
-  if (*s == '=' || *s == '+' || *s == '!')
-  {
+  if (*s == '=' || *s == '+' || *s == '!') {
     if (*s == '!')
       p = NONULL (Spoolfile);
     else
       p = NONULL (Maildir);
 
-    mutt_concat_path (imap_path, p, s+1, sizeof (imap_path));
+    mutt_concat_path (imap_path, p, s + 1, sizeof (imap_path));
   }
   else
-    strfcpy (imap_path, s, sizeof(imap_path));
+    strfcpy (imap_path, s, sizeof (imap_path));
 
   if (mx_is_imap (imap_path))
     return imap_complete (s, slen, imap_path);
 #endif
-  
-  if (*s == '=' || *s == '+' || *s == '!')
-  {
+
+  if (*s == '=' || *s == '+' || *s == '!') {
     dirpart[0] = *s;
     dirpart[1] = 0;
     if (*s == '!')
       strfcpy (exp_dirpart, NONULL (Spoolfile), sizeof (exp_dirpart));
     else
       strfcpy (exp_dirpart, NONULL (Maildir), sizeof (exp_dirpart));
-    if ((p = strrchr (s, '/')))
-    {
+    if ((p = strrchr (s, '/'))) {
       char buf[_POSIX_PATH_MAX];
+
       *p++ = 0;
       mutt_concat_path (buf, exp_dirpart, s + 1, sizeof (buf));
       strfcpy (exp_dirpart, buf, sizeof (exp_dirpart));
-      snprintf (buf, sizeof (buf), "%s%s/", dirpart, s+1);
+      snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1);
       strfcpy (dirpart, buf, sizeof (dirpart));
       strfcpy (filepart, p, sizeof (filepart));
     }
@@ -155,33 +144,28 @@ int mutt_complete (char *s, size_t slen)
       strfcpy (filepart, s + 1, sizeof (filepart));
     dirp = opendir (exp_dirpart);
   }
-  else
-  {
-    if ((p = strrchr (s, '/')))
-    {
-      if (p == s) /* absolute path */
-      {
-       p = s + 1;
-       strfcpy (dirpart, "/", sizeof (dirpart));
-       exp_dirpart[0] = 0;
-       strfcpy (filepart, p, sizeof (filepart));
-       dirp = opendir (dirpart);
+  else {
+    if ((p = strrchr (s, '/'))) {
+      if (p == s) {             /* absolute path */
+        p = s + 1;
+        strfcpy (dirpart, "/", sizeof (dirpart));
+        exp_dirpart[0] = 0;
+        strfcpy (filepart, p, sizeof (filepart));
+        dirp = opendir (dirpart);
       }
-      else
-      {
-       *p = 0;
-       len = (size_t)(p - s);
-       strncpy (dirpart, s, len);
-       dirpart[len]=0;
-       p++;
-       strfcpy (filepart, p, sizeof (filepart));
-       strfcpy (exp_dirpart, dirpart, sizeof (exp_dirpart));
-       mutt_expand_path (exp_dirpart, sizeof (exp_dirpart));
-       dirp = opendir (exp_dirpart);
+      else {
+        *p = 0;
+        len = (size_t) (p - s);
+        strncpy (dirpart, s, len);
+        dirpart[len] = 0;
+        p++;
+        strfcpy (filepart, p, sizeof (filepart));
+        strfcpy (exp_dirpart, dirpart, sizeof (exp_dirpart));
+        mutt_expand_path (exp_dirpart, sizeof (exp_dirpart));
+        dirp = opendir (exp_dirpart);
       }
     }
-    else
-    {
+    else {
       /* no directory name, so assume current directory. */
       dirpart[0] = 0;
       strfcpy (filepart, s, sizeof (filepart));
@@ -189,9 +173,10 @@ int mutt_complete (char *s, size_t slen)
     }
   }
 
-  if (dirp == NULL)
-  {
-    dprint (1, (debugfile, "mutt_complete(): %s: %s (errno %d).\n", exp_dirpart, strerror (errno), errno));
+  if (dirp == NULL) {
+    dprint (1,
+            (debugfile, "mutt_complete(): %s: %s (errno %d).\n", exp_dirpart,
+             strerror (errno), errno));
     return (-1);
   }
 
@@ -199,64 +184,55 @@ int mutt_complete (char *s, size_t slen)
    * special case to handle when there is no filepart yet.  find the first
    * file/directory which is not ``.'' or ``..''
    */
-  if ((len = mutt_strlen (filepart)) == 0)
-  {
-    while ((de = readdir (dirp)) != NULL)
-    {
-      if (mutt_strcmp (".", de->d_name) != 0 && mutt_strcmp ("..", de->d_name) != 0)
-      {
-       strfcpy (filepart, de->d_name, sizeof (filepart));
-       init++;
-       break;
+  if ((len = mutt_strlen (filepart)) == 0) {
+    while ((de = readdir (dirp)) != NULL) {
+      if (mutt_strcmp (".", de->d_name) != 0
+          && mutt_strcmp ("..", de->d_name) != 0) {
+        strfcpy (filepart, de->d_name, sizeof (filepart));
+        init++;
+        break;
       }
     }
   }
 
-  while ((de = readdir (dirp)) != NULL)
-  {
-    if (mutt_strncmp (de->d_name, filepart, len) == 0)
-    {
-      if (init)
-      {
-       for (i=0; filepart[i] && de->d_name[i]; i++)
-       {
-         if (filepart[i] != de->d_name[i])
-         {
-           filepart[i] = 0;
-           break;
-         }
-       }
-       filepart[i] = 0;
+  while ((de = readdir (dirp)) != NULL) {
+    if (mutt_strncmp (de->d_name, filepart, len) == 0) {
+      if (init) {
+        for (i = 0; filepart[i] && de->d_name[i]; i++) {
+          if (filepart[i] != de->d_name[i]) {
+            filepart[i] = 0;
+            break;
+          }
+        }
+        filepart[i] = 0;
       }
-      else
-      {
-       char buf[_POSIX_PATH_MAX];
-       struct stat st;
-
-       strfcpy (filepart, de->d_name, sizeof(filepart));
-
-       /* check to see if it is a directory */
-       if (dirpart[0])
-       {
-         strfcpy (buf, exp_dirpart, sizeof (buf));
-         strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf));
-       }
-       else
-         buf[0] = 0;
-       strfcpy (buf + strlen (buf), filepart, sizeof (buf) - strlen (buf));
-       if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
-         strfcpy (filepart + strlen (filepart), "/",
-                  sizeof (filepart) - strlen (filepart));
-       init = 1;
+      else {
+        char buf[_POSIX_PATH_MAX];
+        struct stat st;
+
+        strfcpy (filepart, de->d_name, sizeof (filepart));
+
+        /* check to see if it is a directory */
+        if (dirpart[0]) {
+          strfcpy (buf, exp_dirpart, sizeof (buf));
+          strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf));
+        }
+        else
+          buf[0] = 0;
+        strfcpy (buf + strlen (buf), filepart, sizeof (buf) - strlen (buf));
+        if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR))
+          strfcpy (filepart + strlen (filepart), "/",
+                   sizeof (filepart) - strlen (filepart));
+        init = 1;
       }
     }
   }
   closedir (dirp);
 
-  if (dirpart[0])
-  {
+  if (dirpart[0]) {
     strfcpy (s, dirpart, slen);
-    if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+')
+    if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '='
+        && dirpart[0] != '+')
       strfcpy (s + strlen (s), "/", slen - strlen (s));
     strfcpy (s + strlen (s), filepart, slen - strlen (s));
   }
index ddf10cc..7ea1952 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -37,7 +37,7 @@
 #ifdef MIXMASTER
 #include "remailer.h"
 #endif
-  
+
 #ifdef USE_NNTP
 #include "nntp.h"
 #endif
 #include <unistd.h>
 #include <stdlib.h>
 
-static const charThere_are_no_attachments = N_("There are no attachments.");
+static const char *There_are_no_attachments = N_("There are no attachments.");
 
 #define CHECK_COUNT if (idxlen == 0) { mutt_error _(There_are_no_attachments); break; }
 
 
 
-enum
-{
-  HDR_FROM  = 1,
+enum {
+  HDR_FROM = 1,
   HDR_TO,
   HDR_CC,
   HDR_BCC,
@@ -65,7 +64,7 @@ enum
   HDR_REPLYTO,
   HDR_FCC,
 
-#ifdef MIXMASTER  
+#ifdef MIXMASTER
   HDR_MIX,
 #endif
 
@@ -79,18 +78,17 @@ enum
 #endif
 
 #ifndef USE_NNTP
-  HDR_ATTACH  = (HDR_FCC + 5) /* where to start printing the attachments */
+  HDR_ATTACH = (HDR_FCC + 5)    /* where to start printing the attachments */
 #else
-  HDR_ATTACH  = (HDR_FCC + 7) 
+  HDR_ATTACH = (HDR_FCC + 7)
 #endif
 };
 
 #define HDR_XOFFSET 14
-#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
+#define TITLE_FMT "%14s"        /* Used for Prompts, which are ASCII */
 #define W (COLS - HDR_XOFFSET - SidebarWidth)
 
-static char *Prompts[] =
-{
+static char *Prompts[] = {
   "From: ",
   "To: ",
   "Cc: ",
@@ -100,69 +98,64 @@ static char *Prompts[] =
   "Fcc: "
 #ifdef USE_NNTP
 #ifdef MIXMASTER
-  ,""
+    , ""
 #endif
-  ,""
-  ,""
-  ,"Newsgroups: "
-  ,"Followup-To: "
-  ,"X-Comment-To: "
+    , "", "", "Newsgroups: ", "Followup-To: ", "X-Comment-To: "
 #endif
 };
 
 static struct mapping_t ComposeHelp[] = {
-  { N_("Send"),    OP_COMPOSE_SEND_MESSAGE },
-  { N_("Abort"),   OP_EXIT },
-  { "To",      OP_COMPOSE_EDIT_TO },
-  { "CC",      OP_COMPOSE_EDIT_CC },
-  { "Subj",    OP_COMPOSE_EDIT_SUBJECT },
-  { N_("Attach file"),  OP_COMPOSE_ATTACH_FILE },
-  { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
-  { N_("Help"),    OP_HELP },
-  { NULL }
+  {N_("Send"), OP_COMPOSE_SEND_MESSAGE},
+  {N_("Abort"), OP_EXIT},
+  {"To", OP_COMPOSE_EDIT_TO},
+  {"CC", OP_COMPOSE_EDIT_CC},
+  {"Subj", OP_COMPOSE_EDIT_SUBJECT},
+  {N_("Attach file"), OP_COMPOSE_ATTACH_FILE},
+  {N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
 #ifdef USE_NNTP
 static struct mapping_t ComposeNewsHelp[] = {
-  { N_("Send"),    OP_COMPOSE_SEND_MESSAGE },
-  { N_("Abort"),   OP_EXIT },
-  { "Newsgroups",  OP_COMPOSE_EDIT_NEWSGROUPS },
-  { "Subj",        OP_COMPOSE_EDIT_SUBJECT },
-  { N_("Attach file"),  OP_COMPOSE_ATTACH_FILE },
-  { N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION },
-  { N_("Help"),    OP_HELP },
-  { NULL }
+  {N_("Send"), OP_COMPOSE_SEND_MESSAGE},
+  {N_("Abort"), OP_EXIT},
+  {"Newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS},
+  {"Subj", OP_COMPOSE_EDIT_SUBJECT},
+  {N_("Attach file"), OP_COMPOSE_ATTACH_FILE},
+  {N_("Descrip"), OP_COMPOSE_EDIT_DESCRIPTION},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 #endif
 
-static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
+static void snd_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-    mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
-           (unsigned long)(((ATTACHPTR **) menu->data)[num]),
-           M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+                     (unsigned long) (((ATTACHPTR **) menu->data)[num]),
+                     M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
 }
 
 
 
 #include "mutt_crypt.h"
 
-static void redraw_crypt_lines (HEADER *msg)
+static void redraw_crypt_lines (HEADER * msg)
 {
   int off = 0;
 
-  if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
-  {     
+  if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME)) {
     if (!msg->security)
-      mvaddstr (HDR_CRYPT, SidebarWidth,     "    Security: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth, "    Security: ");
     else if (msg->security & APPLICATION_SMIME)
-      mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth, "      S/MIME: ");
     else if (msg->security & APPLICATION_PGP)
-      mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
+      mvaddstr (HDR_CRYPT, SidebarWidth, "         PGP: ");
   }
   else if ((WithCrypto & APPLICATION_SMIME))
-    mvaddstr (HDR_CRYPT, SidebarWidth,     "      S/MIME: ");
+    mvaddstr (HDR_CRYPT, SidebarWidth, "      S/MIME: ");
   else if ((WithCrypto & APPLICATION_PGP))
-    mvaddstr (HDR_CRYPT, SidebarWidth,     "         PGP: ");
+    mvaddstr (HDR_CRYPT, SidebarWidth, "         PGP: ");
   else
     return;
 
@@ -176,65 +169,63 @@ static void redraw_crypt_lines (HEADER *msg)
     addstr (_("Clear"));
 
   if ((WithCrypto & APPLICATION_PGP))
-    if ((msg->security & APPLICATION_PGP) 
-       && (msg->security & (ENCRYPT | SIGN)))
-    {
+    if ((msg->security & APPLICATION_PGP)
+        && (msg->security & (ENCRYPT | SIGN))) {
       if ((msg->security & INLINE))
-       addstr (_(" (inline)"));
+        addstr (_(" (inline)"));
       else
-       addstr (_(" (PGP/MIME)"));
+        addstr (_(" (PGP/MIME)"));
     }
   clrtoeol ();
 
   move (HDR_CRYPTINFO, SidebarWidth);
   clrtoeol ();
   if ((WithCrypto & APPLICATION_PGP)
-      && msg->security & APPLICATION_PGP  && msg->security & SIGN)
-    printw ("%s%s", _("     sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
+      && msg->security & APPLICATION_PGP && msg->security & SIGN)
+    printw ("%s%s", _("     sign as: "),
+            PgpSignAs ? PgpSignAs : _("<default>"));
 
   if ((WithCrypto & APPLICATION_SMIME)
-     && msg->security & APPLICATION_SMIME  && msg->security & SIGN) {
-      printw ("%s%s", _("     sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
+      && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
+    printw ("%s%s", _("     sign as: "),
+            SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
   }
 
   if ((WithCrypto & APPLICATION_SMIME)
-       && (msg->security & APPLICATION_SMIME)
-       && (msg->security & ENCRYPT)
-       && SmimeCryptAlg
-       && *SmimeCryptAlg) {
-      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
-               NONULL(SmimeCryptAlg));
-      off = 20;
+      && (msg->security & APPLICATION_SMIME)
+      && (msg->security & ENCRYPT)
+      && SmimeCryptAlg && *SmimeCryptAlg) {
+    mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
+              NONULL (SmimeCryptAlg));
+    off = 20;
   }
 }
 
 
 #ifdef MIXMASTER
 
-static void redraw_mix_line (LIST *chain)
+static void redraw_mix_line (LIST * chain)
 {
   int c;
   char *t;
 
-  mvaddstr (HDR_MIX, SidebarWidth,     "         Mix: ");
+  mvaddstr (HDR_MIX, SidebarWidth, "         Mix: ");
 
-  if (!chain)
-  {
+  if (!chain) {
     addstr ("<no chain defined>");
     clrtoeol ();
     return;
   }
-  
-  for (c = 12; chain; chain = chain->next)
-  {
+
+  for (c = 12; chain; chain = chain->next) {
     t = chain->data;
     if (t && t[0] == '0' && t[1] == '\0')
       t = "<random>";
-    
+
     if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
       break;
 
-    addstr (NONULL(t));
+    addstr (NONULL (t));
     if (chain->next)
       addstr (", ");
 
@@ -243,41 +234,36 @@ static void redraw_mix_line (LIST *chain)
 }
 #endif /* MIXMASTER */
 
-static int
-check_attachments(ATTACHPTR **idx, short idxlen)
+static int check_attachments (ATTACHPTR ** idx, short idxlen)
 {
   int i, r;
   struct stat st;
   char pretty[_POSIX_PATH_MAX], msg[_POSIX_PATH_MAX + SHORT_STRING];
 
-  for (i = 0; i < idxlen; i++)
-  {
-    strfcpy(pretty, idx[i]->content->filename, sizeof(pretty));
-    if(stat(idx[i]->content->filename, &st) != 0)
-    {
-      mutt_pretty_mailbox(pretty);
-      mutt_error(_("%s [#%d] no longer exists!"),
-                pretty, i+1);
+  for (i = 0; i < idxlen; i++) {
+    strfcpy (pretty, idx[i]->content->filename, sizeof (pretty));
+    if (stat (idx[i]->content->filename, &st) != 0) {
+      mutt_pretty_mailbox (pretty);
+      mutt_error (_("%s [#%d] no longer exists!"), pretty, i + 1);
       return -1;
     }
-    
-    if(idx[i]->content->stamp < st.st_mtime)
-    {
-      mutt_pretty_mailbox(pretty);
-      snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"),
-              pretty, i+1);
-      
-      if((r = mutt_yesorno(msg, M_YES)) == M_YES)
-       mutt_update_encoding(idx[i]->content);
-      else if(r == -1)
-       return -1;
+
+    if (idx[i]->content->stamp < st.st_mtime) {
+      mutt_pretty_mailbox (pretty);
+      snprintf (msg, sizeof (msg), _("%s [#%d] modified. Update encoding?"),
+                pretty, i + 1);
+
+      if ((r = mutt_yesorno (msg, M_YES)) == M_YES)
+        mutt_update_encoding (idx[i]->content);
+      else if (r == -1)
+        return -1;
     }
   }
 
   return 0;
 }
 
-static void draw_envelope_addr (int line, ADDRESS *addr)
+static void draw_envelope_addr (int line, ADDRESS * addr)
 {
   char buf[STRING];
 
@@ -287,27 +273,24 @@ static void draw_envelope_addr (int line, ADDRESS *addr)
   mutt_paddstr (W, buf);
 }
 
-static void draw_envelope (HEADER *msg, char *fcc)
+static void draw_envelope (HEADER * msg, char *fcc)
 {
   draw_envelope_addr (HDR_FROM, msg->env->from);
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
-  {
+  if (!option (OPTNEWSSEND)) {
 #endif
-  draw_envelope_addr (HDR_TO, msg->env->to);
-  draw_envelope_addr (HDR_CC, msg->env->cc);
-  draw_envelope_addr (HDR_BCC, msg->env->bcc);
+    draw_envelope_addr (HDR_TO, msg->env->to);
+    draw_envelope_addr (HDR_CC, msg->env->cc);
+    draw_envelope_addr (HDR_BCC, msg->env->bcc);
 #ifdef USE_NNTP
   }
-  else
-  {
-    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT , Prompts[HDR_NEWSGROUPS - 1]);
+  else {
+    mvprintw (HDR_TO, SidebarWidth, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]);
     mutt_paddstr (W, NONULL (msg->env->newsgroups));
-    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT , Prompts[HDR_FOLLOWUPTO - 1]);
+    mvprintw (HDR_CC, SidebarWidth, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]);
     mutt_paddstr (W, NONULL (msg->env->followup_to));
-    if (option (OPTXCOMMENTTO))
-    {
-      mvprintw (HDR_BCC, 0, TITLE_FMT , Prompts[HDR_XCOMMENTTO - 1]);
+    if (option (OPTXCOMMENTTO)) {
+      mvprintw (HDR_BCC, 0, TITLE_FMT, Prompts[HDR_XCOMMENTTO - 1]);
       mutt_paddstr (W, NONULL (msg->env->x_comment_to));
     }
   }
@@ -334,60 +317,55 @@ static void draw_envelope (HEADER *msg, char *fcc)
   SETCOLOR (MT_COLOR_NORMAL);
 }
 
-static int edit_address_list (int line, ADDRESS **addr)
+static int edit_address_list (int line, ADDRESS ** addr)
 {
-  char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */
+  char buf[HUGE_STRING] = "";   /* needs to be large for alias expansion */
   char *err = NULL;
-  
+
   mutt_addrlist_to_local (*addr);
   rfc822_write_address (buf, sizeof (buf), *addr, 0);
-  if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0)
-  {
+  if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) {
     rfc822_free_address (addr);
     *addr = mutt_parse_adrlist (*addr, buf);
     *addr = mutt_expand_aliases (*addr);
   }
 
-  if (option (OPTNEEDREDRAW))
-  {
+  if (option (OPTNEEDREDRAW)) {
     unset_option (OPTNEEDREDRAW);
     return (REDRAW_FULL);
   }
 
-  if (mutt_addrlist_to_idna (*addr, &err) != 0)
-  {
+  if (mutt_addrlist_to_idna (*addr, &err) != 0) {
     mutt_error (_("Warning: '%s' is a bad IDN."), err);
-    mutt_refresh();
+    mutt_refresh ();
     FREE (&err);
   }
 
   /* 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);
+  move (line, HDR_XOFFSET + SidebarWidth);
   mutt_paddstr (W, buf);
-  
+
   return 0;
 }
 
-static int delete_attachment (MUTTMENU *menu, short *idxlen, int x)
+static int delete_attachment (MUTTMENU * menu, short *idxlen, int x)
 {
   ATTACHPTR **idx = (ATTACHPTR **) menu->data;
   int y;
 
   menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
 
-  if (x == 0 && menu->max == 1)
-  {
+  if (x == 0 && menu->max == 1) {
     mutt_error _("You may not delete the only attachment.");
+
     idx[x]->content->tagged = 0;
     return (-1);
   }
 
-  for (y = 0; y < *idxlen; y++)
-  {
-    if (idx[y]->content->next == idx[x]->content)
-    {
+  for (y = 0; y < *idxlen; y++) {
+    if (idx[y]->content->next == idx[x]->content) {
       idx[y]->content->next = idx[x]->content->next;
       break;
     }
@@ -399,15 +377,15 @@ static int delete_attachment (MUTTMENU *menu, short *idxlen, int x)
   FREE (&idx[x]->tree);
   FREE (&idx[x]);
   for (; x < *idxlen - 1; x++)
-    idx[x] = idx[x+1];
+    idx[x] = idx[x + 1];
   menu->max = --(*idxlen);
-  
+
   return (0);
 }
 
-static void update_idx (MUTTMENU *menu, ATTACHPTR **idx, short idxlen)
+static void update_idx (MUTTMENU * menu, ATTACHPTR ** idx, short idxlen)
 {
-  idx[idxlen]->level = (idxlen > 0) ? idx[idxlen-1]->level : 0;
+  idx[idxlen]->level = (idxlen > 0) ? idx[idxlen - 1]->level : 0;
   if (idxlen)
     idx[idxlen - 1]->content->next = idx[idxlen]->content;
   idx[idxlen]->content->aptr = idx[idxlen];
@@ -427,34 +405,31 @@ static void update_idx (MUTTMENU *menu, ATTACHPTR **idx, short idxlen)
  * 
  */
 
-static unsigned long cum_attachs_size (MUTTMENU *menu)
+static unsigned long cum_attachs_size (MUTTMENU * menu)
 {
   size_t s;
   unsigned short i;
   ATTACHPTR **idx = menu->data;
   CONTENT *info;
   BODY *b;
-  
-  for (i = 0, s = 0; i < menu->max; i++)
-  {
+
+  for (i = 0, s = 0; i < menu->max; i++) {
     b = idx[i]->content;
 
     if (!b->content)
       b->content = mutt_get_content_info (b->filename, b);
 
-    if ((info = b->content))
-    {
-      switch (b->encoding)
-      {
-       case ENCQUOTEDPRINTABLE:
-         s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
-         break;
-       case ENCBASE64:
-         s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
-         break;
-       default:
-         s += info->lobin + info->hibin + info->ascii + info->crlf;
-         break;
+    if ((info = b->content)) {
+      switch (b->encoding) {
+      case ENCQUOTEDPRINTABLE:
+        s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
+        break;
+      case ENCBASE64:
+        s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
+        break;
+      default:
+        s += info->lobin + info->hibin + info->ascii + info->crlf;
+        break;
       }
     }
   }
@@ -463,8 +438,8 @@ static unsigned long cum_attachs_size (MUTTMENU *menu)
 }
 
 /* prototype for use below */
-static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
-      const char *p);
+static void compose_status_line (char *buf, size_t buflen, MUTTMENU * menu,
+                                 const char *p);
 
 /*
  * compose_format_str()
@@ -478,47 +453,46 @@ static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu,
  * help when modifying this function.
  */
 
-static const char *
-compose_format_str (char *buf, size_t buflen, char op, const char *src,
-                  const char *prefix, const char *ifstring,
-                  const char *elsestring,
-                  unsigned long data, format_flag flags)
+static const char *compose_format_str (char *buf, size_t buflen, char op,
+                                       const char *src, const char *prefix,
+                                       const char *ifstring,
+                                       const char *elsestring,
+                                       unsigned long data, format_flag flags)
 {
   char fmt[SHORT_STRING], tmp[SHORT_STRING];
   int optional = (flags & M_FORMAT_OPTIONAL);
   MUTTMENU *menu = (MUTTMENU *) data;
 
   *buf = 0;
-  switch (op)
-  {
-    case 'a': /* total number of attachments */
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, menu->max);
-      break;
-
-    case 'h':  /* hostname */
-      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (buf, buflen, fmt, NONULL(Hostname));
-      break;
-
-    case 'l': /* approx length of current message in bytes */
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       mutt_pretty_size (tmp, sizeof (tmp), menu ? cum_attachs_size(menu) : 0);
-       snprintf (buf, buflen, fmt, tmp);
-      break;
-
-    case 'v':
-      snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
-      snprintf (buf, buflen, fmt, MUTT_VERSION);
-      break;
-
-    case 0:
-      *buf = 0;
-      return (src);
-
-    default:
-      snprintf (buf, buflen, "%%%s%c", prefix, op);
-      break;
+  switch (op) {
+  case 'a':                    /* total number of attachments */
+    snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+    snprintf (buf, buflen, fmt, menu->max);
+    break;
+
+  case 'h':                    /* hostname */
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (buf, buflen, fmt, NONULL (Hostname));
+    break;
+
+  case 'l':                    /* approx length of current message in bytes */
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    mutt_pretty_size (tmp, sizeof (tmp), menu ? cum_attachs_size (menu) : 0);
+    snprintf (buf, buflen, fmt, tmp);
+    break;
+
+  case 'v':
+    snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
+    snprintf (buf, buflen, fmt, MUTT_VERSION);
+    break;
+
+  case 0:
+    *buf = 0;
+    return (src);
+
+  default:
+    snprintf (buf, buflen, "%%%s%c", prefix, op);
+    break;
   }
 
   if (optional)
@@ -529,11 +503,11 @@ compose_format_str (char *buf, size_t buflen, char op, const char *src,
   return (src);
 }
 
-static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu, 
-      const char *p)
+static void compose_status_line (char *buf, size_t buflen, MUTTMENU * menu,
+                                 const char *p)
 {
-  mutt_FormatString (buf, buflen, p, compose_format_str, 
-        (unsigned long) menu, 0);
+  mutt_FormatString (buf, buflen, p, compose_format_str,
+                     (unsigned long) menu, 0);
 }
 
 
@@ -543,11 +517,10 @@ static void compose_status_line (char *buf, size_t buflen, MUTTMENU *menu,
  * 0   normal exit
  * -1  abort message
  */
-int mutt_compose_menu (HEADER *msg,   /* structure for new message */
-                   char *fcc,     /* where to save a copy of the message */
-                   size_t fcclen,
-                   HEADER *cur)   /* current message */
-{
+int mutt_compose_menu (HEADER * msg,    /* structure for new message */
+                       char *fcc,       /* where to save a copy of the message */
+                       size_t fcclen, HEADER * cur)
+{                               /* current message */
   char helpstr[SHORT_STRING];
   char buf[LONG_STRING];
   char fname[_POSIX_PATH_MAX];
@@ -556,16 +529,18 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
   short idxlen = 0;
   short idxmax = 0;
   int i, close = 0;
-  int r = -1;          /* return value */
+  int r = -1;                   /* return value */
   int op = 0;
   int loop = 1;
-  int fccSet = 0;      /* has the user edited the Fcc: field ? */
+  int fccSet = 0;               /* has the user edited the Fcc: field ? */
   CONTEXT *ctx = NULL, *this = NULL;
+
   /* Sort, SortAux could be changed in mutt_index_menu() */
   int oldSort, oldSortAux;
   struct stat st;
+
 #ifdef USE_NNTP
-  int news = 0;               /* is it a news article ? */
+  int news = 0;                 /* is it a news article ? */
 
   if (option (OPTNEWSSEND))
     news++;
@@ -583,884 +558,865 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
   menu->data = idx;
 #ifdef USE_NNTP
   if (news)
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeNewsHelp);
+    menu->help =
+      mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE,
+                         ComposeNewsHelp);
   else
 #endif
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
-  
-  if (option(OPTMBOXPANE))
-    mutt_buffy_check(1);
-  while (loop)
-  {
+    menu->help =
+      mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE,
+                         ComposeHelp);
+
+  if (option (OPTMBOXPANE))
+    mutt_buffy_check (1);
+  while (loop) {
 #ifdef USE_NNTP
-    unset_option (OPTNEWS);    /* for any case */
+    unset_option (OPTNEWS);     /* for any case */
 #endif
-    switch (op = mutt_menuLoop (menu))
-    {
-      case OP_REDRAW:
-       draw_envelope (msg, fcc);
-       menu->offset = HDR_ATTACH;
-       menu->pagelen = LINES - HDR_ATTACH - 2;
-       break;
-      case OP_COMPOSE_EDIT_FROM:
-       menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-       break;
-      case OP_COMPOSE_EDIT_TO:
+    switch (op = mutt_menuLoop (menu)) {
+    case OP_REDRAW:
+      draw_envelope (msg, fcc);
+      menu->offset = HDR_ATTACH;
+      menu->pagelen = LINES - HDR_ATTACH - 2;
+      break;
+    case OP_COMPOSE_EDIT_FROM:
+      menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+    case OP_COMPOSE_EDIT_TO:
 #ifdef USE_NNTP
-       if (!news) {
+      if (!news) {
 #endif
-         menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
-          mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
 #ifdef USE_NNTP
-       }
+      }
 #endif
-       break;
-      case OP_COMPOSE_EDIT_BCC:
+      break;
+    case OP_COMPOSE_EDIT_BCC:
 #ifdef USE_NNTP
-       if (!news) {
+      if (!news) {
 #endif
-         menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
-          mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
 #ifdef USE_NNTP
-       }
+      }
 #endif
-       break;
-      case OP_COMPOSE_EDIT_CC:
+      break;
+    case OP_COMPOSE_EDIT_CC:
 #ifdef USE_NNTP
-       if (!news) {
+      if (!news) {
 #endif
-         menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
-          mutt_message_hook (NULL, msg, M_SEND2HOOK);  
+        menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
+        mutt_message_hook (NULL, msg, M_SEND2HOOK);
 #ifdef USE_NNTP
-       }
+      }
 #endif
-       break;
+      break;
 #ifdef USE_NNTP
-      case OP_COMPOSE_EDIT_NEWSGROUPS:
-       if (news)
-       {
-         if (msg->env->newsgroups)
-           strfcpy (buf, msg->env->newsgroups, sizeof (buf));
-         else
-           buf[0] = 0;
-         if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 && buf[0])
-         {
-           FREE (&msg->env->newsgroups);
-           mutt_remove_trailing_ws (buf);
-           msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
-           move (HDR_TO, HDR_XOFFSET);
-           clrtoeol ();
-           if (msg->env->newsgroups)
-             printw ("%-*.*s", W, W, msg->env->newsgroups);
-         }
-       }
-       break;
-
-      case OP_COMPOSE_EDIT_FOLLOWUP_TO:
-       if (news)
-       {
-         buf[0] = 0;
-         if (msg->env->followup_to)
-           strfcpy (buf, msg->env->followup_to, sizeof (buf));
-         if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
-         {
-           FREE (&msg->env->followup_to);
-           mutt_remove_trailing_ws (buf);
-           msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
-           move (HDR_CC, HDR_XOFFSET);
-           clrtoeol();
-           if (msg->env->followup_to)
-             printw ("%-*.*s", W, W, msg->env->followup_to);
-         }
-       }
-       break;
-
-      case OP_COMPOSE_EDIT_X_COMMENT_TO:
-       if (news && option (OPTXCOMMENTTO))
-       {
-         buf[0] = 0;
-         if (msg->env->x_comment_to)
-           strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
-         if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0 && buf[0])
-         {
-           FREE (&msg->env->x_comment_to);
-           msg->env->x_comment_to = safe_strdup (buf);
-           move (HDR_BCC, HDR_XOFFSET);
-           clrtoeol();
-           if (msg->env->x_comment_to)
-             printw ("%-*.*s", W, W, msg->env->x_comment_to);
-         }
-       }
-       break;
+    case OP_COMPOSE_EDIT_NEWSGROUPS:
+      if (news) {
+        if (msg->env->newsgroups)
+          strfcpy (buf, msg->env->newsgroups, sizeof (buf));
+        else
+          buf[0] = 0;
+        if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0
+            && buf[0]) {
+          FREE (&msg->env->newsgroups);
+          mutt_remove_trailing_ws (buf);
+          msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
+          move (HDR_TO, HDR_XOFFSET);
+          clrtoeol ();
+          if (msg->env->newsgroups)
+            printw ("%-*.*s", W, W, msg->env->newsgroups);
+        }
+      }
+      break;
+
+    case OP_COMPOSE_EDIT_FOLLOWUP_TO:
+      if (news) {
+        buf[0] = 0;
+        if (msg->env->followup_to)
+          strfcpy (buf, msg->env->followup_to, sizeof (buf));
+        if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0
+            && buf[0]) {
+          FREE (&msg->env->followup_to);
+          mutt_remove_trailing_ws (buf);
+          msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
+          move (HDR_CC, HDR_XOFFSET);
+          clrtoeol ();
+          if (msg->env->followup_to)
+            printw ("%-*.*s", W, W, msg->env->followup_to);
+        }
+      }
+      break;
+
+    case OP_COMPOSE_EDIT_X_COMMENT_TO:
+      if (news && option (OPTXCOMMENTTO)) {
+        buf[0] = 0;
+        if (msg->env->x_comment_to)
+          strfcpy (buf, msg->env->x_comment_to, sizeof (buf));
+        if (mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) == 0
+            && buf[0]) {
+          FREE (&msg->env->x_comment_to);
+          msg->env->x_comment_to = safe_strdup (buf);
+          move (HDR_BCC, HDR_XOFFSET);
+          clrtoeol ();
+          if (msg->env->x_comment_to)
+            printw ("%-*.*s", W, W, msg->env->x_comment_to);
+        }
+      }
+      break;
 #endif
-      case OP_COMPOSE_EDIT_SUBJECT:
-       if (msg->env->subject)
-         strfcpy (buf, msg->env->subject, sizeof (buf));
-       else
-         buf[0] = 0;
-       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);
-       }
+    case OP_COMPOSE_EDIT_SUBJECT:
+      if (msg->env->subject)
+        strfcpy (buf, msg->env->subject, sizeof (buf));
+      else
+        buf[0] = 0;
+      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);
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+    case OP_COMPOSE_EDIT_REPLY_TO:
+      menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+    case OP_COMPOSE_EDIT_FCC:
+      strfcpy (buf, fcc, sizeof (buf));
+      if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) {
+        strfcpy (fcc, buf, _POSIX_PATH_MAX);
+        mutt_pretty_mailbox (fcc);
+        move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
+        mutt_paddstr (W, fcc);
+        fccSet = 1;
+      }
+      MAYBE_REDRAW (menu->redraw);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+    case OP_COMPOSE_EDIT_MESSAGE:
+      if (Editor && (mutt_strcmp ("builtin", Editor) != 0)
+          && !option (OPTEDITHDRS)) {
+        mutt_edit_file (Editor, msg->content->filename);
+        mutt_update_encoding (msg->content);
+        menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
         mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
-      case OP_COMPOSE_EDIT_REPLY_TO:
-       menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-       break;
-      case OP_COMPOSE_EDIT_FCC:
-       strfcpy (buf, fcc, sizeof (buf));
-       if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0)
-       {
-         strfcpy (fcc, buf, _POSIX_PATH_MAX);
-         mutt_pretty_mailbox (fcc);
-         move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
-         mutt_paddstr (W, fcc);
-         fccSet = 1;
-       }
-       MAYBE_REDRAW (menu->redraw);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      }
+      /* fall through */
+    case OP_COMPOSE_EDIT_HEADERS:
+      if (mutt_strcmp ("builtin", Editor) != 0 &&
+          (op == OP_COMPOSE_EDIT_HEADERS ||
+           (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))) {
+        char *tag = NULL, *err = NULL;
+
+        mutt_env_to_local (msg->env);
+        mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
+                           fcc, fcclen);
+        if (mutt_env_to_idna (msg->env, &tag, &err)) {
+          mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
+          FREE (&err);
+        }
+      }
+      else {
+        /* this is grouped with OP_COMPOSE_EDIT_HEADERS because the
+           attachment list could change if the user invokes ~v to edit
+           the message with headers, in which we need to execute the
+           code below to regenerate the index array */
+        mutt_builtin_editor (msg->content->filename, msg, cur);
+      }
+      mutt_update_encoding (msg->content);
+
+      /* attachments may have been added */
+      if (idxlen && idx[idxlen - 1]->content->next) {
+        for (i = 0; i < idxlen; i++)
+          FREE (&idx[i]);
+        idxlen = 0;
+        idx =
+          mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0,
+                                1);
+        menu->data = idx;
+        menu->max = idxlen;
+      }
+
+      menu->redraw = REDRAW_FULL;
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+
+
+    case OP_COMPOSE_ATTACH_KEY:
+      if (!(WithCrypto & APPLICATION_PGP))
         break;
-      case OP_COMPOSE_EDIT_MESSAGE:
-       if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS))
-       {
-         mutt_edit_file (Editor, msg->content->filename);
-         mutt_update_encoding (msg->content);
-         menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
-         mutt_message_hook (NULL, msg, M_SEND2HOOK);
-         break;
-       }
-       /* fall through */
-      case OP_COMPOSE_EDIT_HEADERS:
-       if (mutt_strcmp ("builtin", Editor) != 0 &&
-           (op == OP_COMPOSE_EDIT_HEADERS ||
-           (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS))))
-       {
-         char *tag = NULL, *err = NULL;
-         mutt_env_to_local (msg->env);
-         mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
-                            fcc, fcclen);
-         if (mutt_env_to_idna (msg->env, &tag, &err))
-         {
-           mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
-           FREE (&err);
-         }
-       }
-       else
-       {
-         /* this is grouped with OP_COMPOSE_EDIT_HEADERS because the
-            attachment list could change if the user invokes ~v to edit
-            the message with headers, in which we need to execute the
-            code below to regenerate the index array */
-         mutt_builtin_editor (msg->content->filename, msg, cur);
-       }
-       mutt_update_encoding (msg->content);
-
-       /* attachments may have been added */
-       if (idxlen && idx[idxlen - 1]->content->next)
-       {
-         for (i = 0; i < idxlen; i++)
-           FREE (&idx[i]);
-         idxlen = 0;
-         idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
-         menu->data = idx;
-         menu->max = idxlen;
-       }
+      if (idxlen == idxmax) {
+        safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+        menu->data = idx;
+      }
 
+      idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+      if ((idx[idxlen]->content =
+           crypt_pgp_make_key_attachment (NULL)) != NULL) {
+        update_idx (menu, idx, idxlen++);
+        menu->redraw |= REDRAW_INDEX;
+      }
+      else
+        FREE (&idx[idxlen]);
+
+      menu->redraw |= REDRAW_STATUS;
+
+      if (option (OPTNEEDREDRAW)) {
         menu->redraw = REDRAW_FULL;
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-       break;
-
-
-
-      case OP_COMPOSE_ATTACH_KEY:
-        if (!(WithCrypto & APPLICATION_PGP))
-          break;       
-       if (idxlen == idxmax)
-        {
-         safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
-         menu->data = idx;
-       }
-       
-       idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
-       if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL)
-       {
-         update_idx (menu, idx, idxlen++);
-         menu->redraw |= REDRAW_INDEX;
-       }
-       else
-         FREE (&idx[idxlen]);
-
-       menu->redraw |= REDRAW_STATUS;
-
-       if (option(OPTNEEDREDRAW))
-       {
-         menu->redraw = REDRAW_FULL;
-         unset_option(OPTNEEDREDRAW);
-       }
-       
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+        unset_option (OPTNEEDREDRAW);
+      }
 
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 
-      case OP_COMPOSE_ATTACH_FILE:
-       {
-         char *prompt, **files;
-         int error, numfiles;
-
-         fname[0] = 0;
-         prompt = _("Attach file");
-         numfiles = 0;
-         files = NULL;
-
-         if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files, &numfiles) == -1 ||
-             *fname == '\0')
-           break;
-
-         if (idxlen + numfiles >= idxmax)
-         {
-           safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles));
-           menu->data = idx;
-         }
-
-         error = 0;
-         if (numfiles > 1)
-           mutt_message _("Attaching selected files...");
-         for (i = 0; i < numfiles; i++)
-         {
-           char *att = files[i];
-           idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
-           idx[idxlen]->content = mutt_make_file_attach (att);
-           if (idx[idxlen]->content != NULL)
-             update_idx (menu, idx, idxlen++);
-           else
-           {
-             error = 1;
-             mutt_error (_("Unable to attach %s!"), att);
-             FREE (&idx[idxlen]);
-           }
-         }
-         
-         FREE (&files);
-         if (!error) mutt_clear_error ();
-
-         menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
 
-      case OP_COMPOSE_ATTACH_MESSAGE:
+    case OP_COMPOSE_ATTACH_FILE:
+      {
+        char *prompt, **files;
+        int error, numfiles;
+
+        fname[0] = 0;
+        prompt = _("Attach file");
+        numfiles = 0;
+        files = NULL;
+
+        if (_mutt_enter_fname
+            (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files,
+             &numfiles) == -1 || *fname == '\0')
+          break;
+
+        if (idxlen + numfiles >= idxmax) {
+          safe_realloc (&idx,
+                        sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles));
+          menu->data = idx;
+        }
+
+        error = 0;
+        if (numfiles > 1)
+          mutt_message _("Attaching selected files...");
+
+        for (i = 0; i < numfiles; i++) {
+          char *att = files[i];
+
+          idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+          idx[idxlen]->content = mutt_make_file_attach (att);
+          if (idx[idxlen]->content != NULL)
+            update_idx (menu, idx, idxlen++);
+          else {
+            error = 1;
+            mutt_error (_("Unable to attach %s!"), att);
+            FREE (&idx[idxlen]);
+          }
+        }
+
+        FREE (&files);
+        if (!error)
+          mutt_clear_error ();
+
+        menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_ATTACH_MESSAGE:
 #ifdef USE_NNTP
-      case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
+    case OP_COMPOSE_ATTACH_NEWS_MESSAGE:
 #endif
-       {
-         char *prompt;
-         HEADER *h;
+      {
+        char *prompt;
+        HEADER *h;
 
-         fname[0] = 0;
-         prompt = _("Open mailbox to attach message from");
+        fname[0] = 0;
+        prompt = _("Open mailbox to attach message from");
 
 #ifdef USE_NNTP
-         unset_option (OPTNEWS);
-         if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
-         {
-           if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
-             break;
-
-           prompt = _("Open newsgroup to attach message from");
-           set_option (OPTNEWS);
-         }
+        unset_option (OPTNEWS);
+        if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) {
+          if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
+            break;
+
+          prompt = _("Open newsgroup to attach message from");
+          set_option (OPTNEWS);
+        }
 #endif
 
-         if (Context)
+        if (Context)
 #ifdef USE_NNTP
-         if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
+          if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP))
 #endif
-         {
-           strfcpy (fname, NONULL (Context->path), sizeof (fname));
-           mutt_pretty_mailbox (fname);
-         }
+          {
+            strfcpy (fname, NONULL (Context->path), sizeof (fname));
+            mutt_pretty_mailbox (fname);
+          }
 
-         if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
-           break;
+        if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1)
+            == -1 || !fname[0])
+          break;
 
 #ifdef USE_NNTP
-         if (option (OPTNEWS))
-           nntp_expand_path (fname, sizeof (fname), &CurrentNewsSrv->conn->account);
-         else
+        if (option (OPTNEWS))
+          nntp_expand_path (fname, sizeof (fname),
+                            &CurrentNewsSrv->conn->account);
+        else
 #endif
-         mutt_expand_path (fname, sizeof (fname));
+          mutt_expand_path (fname, sizeof (fname));
 #ifdef USE_IMAP
-          if (!mx_is_imap (fname))
+        if (!mx_is_imap (fname))
 #endif
 #ifdef USE_POP
           if (!mx_is_pop (fname))
 #endif
 #ifdef USE_NNTP
-          if (!mx_is_nntp (fname) && !option (OPTNEWS))
+            if (!mx_is_nntp (fname) && !option (OPTNEWS))
 #endif
-         /* check to make sure the file exists and is readable */
-         if (access (fname, R_OK) == -1)
-         {
-           mutt_perror (fname);
-           break;
-         }
-
-         menu->redraw = REDRAW_FULL;
-
-         ctx = mx_open_mailbox (fname, M_READONLY, NULL);
-         if (ctx == NULL)
-         {
-           mutt_perror (fname);
-           break;
-         }
-
-         if (!ctx->msgcount)
-         {
-           mx_close_mailbox (ctx, NULL);
-           FREE (&ctx);
-           mutt_error _("No messages in that folder.");
-           break;
-         }
-
-         this = Context; /* remember current folder and sort methods*/
-         oldSort = Sort; oldSortAux = SortAux;
-         
-         Context = ctx;
-         set_option(OPTATTACHMSG);
-         mutt_message _("Tag the messages you want to attach!");
-         close = mutt_index_menu ();
-         unset_option(OPTATTACHMSG);
-
-         if (!Context)
-         {
-           /* go back to the folder we started from */
-           Context = this;
-           /* Restore old $sort and $sort_aux */
-           Sort = oldSort;
-           SortAux = oldSortAux;
-           menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
-           break;
-         }
-
-         if (idxlen + Context->tagged >= idxmax)
-         {
-           safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + Context->tagged));
-           menu->data = idx;
-         }
-
-         for (i = 0; i < Context->msgcount; i++)
-         {
-           h = Context->hdrs[i];
-           if (h->tagged)
-           {
-             idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
-             idx[idxlen]->content = mutt_make_message_attach (Context, h, 1);
-             if (idx[idxlen]->content != NULL)
-               update_idx (menu, idx, idxlen++);
-             else
-             {
-               mutt_error _("Unable to attach!");
-               FREE (&idx[idxlen]);
-             }
-           }
-         }
-         menu->redraw |= REDRAW_FULL;
-
-         if (close == OP_QUIT) 
-           mx_close_mailbox (Context, NULL);
-         else
-           mx_fastclose_mailbox (Context);
-         FREE (&Context);
-
-         /* go back to the folder we started from */
-         Context = this;
-         /* Restore old $sort and $sort_aux */
-         Sort = oldSort;
-         SortAux = oldSortAux;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+              /* check to make sure the file exists and is readable */
+              if (access (fname, R_OK) == -1) {
+                mutt_perror (fname);
+                break;
+              }
 
-      case OP_DELETE:
-       CHECK_COUNT;
-       if (delete_attachment (menu, &idxlen, menu->current) == -1)
-         break;
-       mutt_update_tree (idx, idxlen);
-       if (idxlen)
-       {
-         if (menu->current > idxlen - 1)
-           menu->current = idxlen - 1;
-       }
-       else
-         menu->current = 0;
-
-       if (menu->current == 0)
-         msg->content = idx[0]->content;
+        menu->redraw = REDRAW_FULL;
 
-        menu->redraw |= REDRAW_STATUS;
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+        ctx = mx_open_mailbox (fname, M_READONLY, NULL);
+        if (ctx == NULL) {
+          mutt_perror (fname);
+          break;
+        }
+
+        if (!ctx->msgcount) {
+          mx_close_mailbox (ctx, NULL);
+          FREE (&ctx);
+          mutt_error _("No messages in that folder.");
+
+          break;
+        }
+
+        this = Context;         /* remember current folder and sort methods */
+        oldSort = Sort;
+        oldSortAux = SortAux;
+
+        Context = ctx;
+        set_option (OPTATTACHMSG);
+        mutt_message _("Tag the messages you want to attach!");
+
+        close = mutt_index_menu ();
+        unset_option (OPTATTACHMSG);
+
+        if (!Context) {
+          /* go back to the folder we started from */
+          Context = this;
+          /* Restore old $sort and $sort_aux */
+          Sort = oldSort;
+          SortAux = oldSortAux;
+          menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
+          break;
+        }
+
+        if (idxlen + Context->tagged >= idxmax) {
+          safe_realloc (&idx,
+                        sizeof (ATTACHPTR *) * (idxmax +=
+                                                5 + Context->tagged));
+          menu->data = idx;
+        }
+
+        for (i = 0; i < Context->msgcount; i++) {
+          h = Context->hdrs[i];
+          if (h->tagged) {
+            idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+            idx[idxlen]->content = mutt_make_message_attach (Context, h, 1);
+            if (idx[idxlen]->content != NULL)
+              update_idx (menu, idx, idxlen++);
+            else {
+              mutt_error _("Unable to attach!");
+
+              FREE (&idx[idxlen]);
+            }
+          }
+        }
+        menu->redraw |= REDRAW_FULL;
+
+        if (close == OP_QUIT)
+          mx_close_mailbox (Context, NULL);
+        else
+          mx_fastclose_mailbox (Context);
+        FREE (&Context);
+
+        /* go back to the folder we started from */
+        Context = this;
+        /* Restore old $sort and $sort_aux */
+        Sort = oldSort;
+        SortAux = oldSortAux;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_DELETE:
+      CHECK_COUNT;
+      if (delete_attachment (menu, &idxlen, menu->current) == -1)
         break;
+      mutt_update_tree (idx, idxlen);
+      if (idxlen) {
+        if (menu->current > idxlen - 1)
+          menu->current = idxlen - 1;
+      }
+      else
+        menu->current = 0;
+
+      if (menu->current == 0)
+        msg->content = idx[0]->content;
+
+      menu->redraw |= REDRAW_STATUS;
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 
 #define CURRENT idx[menu->current]->content
-      
-      case OP_COMPOSE_TOGGLE_RECODE:
-      {      
+
+    case OP_COMPOSE_TOGGLE_RECODE:
+      {
         CHECK_COUNT;
-        if (!mutt_is_text_part (CURRENT))
-        {
-         mutt_error (_("Recoding only affects text attachments."));
-         break;
-       }
+        if (!mutt_is_text_part (CURRENT)) {
+          mutt_error (_("Recoding only affects text attachments."));
+          break;
+        }
         CURRENT->noconv = !CURRENT->noconv;
         if (CURRENT->noconv)
-         mutt_message (_("The current attachment won't be converted."));
+          mutt_message (_("The current attachment won't be converted."));
         else
-         mutt_message (_("The current attachment will be converted."));
-       menu->redraw = REDRAW_CURRENT;
+          mutt_message (_("The current attachment will be converted."));
+        menu->redraw = REDRAW_CURRENT;
         mutt_message_hook (NULL, msg, M_SEND2HOOK);
         break;
       }
 #undef CURRENT
 
-      case OP_COMPOSE_EDIT_DESCRIPTION:
-       CHECK_COUNT;
-       strfcpy (buf,
-                idx[menu->current]->content->description ?
-                idx[menu->current]->content->description : "",
-                sizeof (buf));
-       /* header names should not be translated */
-       if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0)
-       {
-         mutt_str_replace (&idx[menu->current]->content->description, buf);
-         menu->redraw = REDRAW_CURRENT;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+    case OP_COMPOSE_EDIT_DESCRIPTION:
+      CHECK_COUNT;
+      strfcpy (buf,
+               idx[menu->current]->content->description ?
+               idx[menu->current]->content->description : "", sizeof (buf));
+      /* header names should not be translated */
+      if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0) {
+        mutt_str_replace (&idx[menu->current]->content->description, buf);
+        menu->redraw = REDRAW_CURRENT;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 
-      case OP_COMPOSE_UPDATE_ENCODING:
-        CHECK_COUNT;
-        if (menu->tagprefix)
-        {
-         BODY *top;
-         for (top = msg->content; top; top = top->next)
-         {
-           if (top->tagged)
-             mutt_update_encoding (top);
-         }
-         menu->redraw = REDRAW_FULL;
-       }
+    case OP_COMPOSE_UPDATE_ENCODING:
+      CHECK_COUNT;
+      if (menu->tagprefix) {
+        BODY *top;
+
+        for (top = msg->content; top; top = top->next) {
+          if (top->tagged)
+            mutt_update_encoding (top);
+        }
+        menu->redraw = REDRAW_FULL;
+      }
+      else {
+        mutt_update_encoding (idx[menu->current]->content);
+        menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_TOGGLE_DISPOSITION:
+      /* toggle the content-disposition between inline/attachment */
+      idx[menu->current]->content->disposition =
+        (idx[menu->current]->content->disposition ==
+         DISPINLINE) ? DISPATTACH : DISPINLINE;
+      menu->redraw = REDRAW_CURRENT;
+      break;
+
+    case OP_EDIT_TYPE:
+      CHECK_COUNT;
+      {
+        mutt_edit_content_type (NULL, idx[menu->current]->content, NULL);
+
+        /* this may have been a change to text/something */
+        mutt_update_encoding (idx[menu->current]->content);
+
+        menu->redraw = REDRAW_CURRENT;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_EDIT_ENCODING:
+      CHECK_COUNT;
+      strfcpy (buf, ENCODING (idx[menu->current]->content->encoding),
+               sizeof (buf));
+      if (mutt_get_field ("Content-Transfer-Encoding: ", buf,
+                          sizeof (buf), 0) == 0 && buf[0]) {
+        if ((i = mutt_check_encoding (buf)) != ENCOTHER && i != ENCUUENCODED) {
+          idx[menu->current]->content->encoding = i;
+          menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
+          mutt_clear_error ();
+        }
         else
-        {
-          mutt_update_encoding(idx[menu->current]->content);
-         menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
-      
-      case OP_COMPOSE_TOGGLE_DISPOSITION:
-       /* toggle the content-disposition between inline/attachment */
-       idx[menu->current]->content->disposition = (idx[menu->current]->content->disposition == DISPINLINE) ? DISPATTACH : DISPINLINE;
-       menu->redraw = REDRAW_CURRENT;
-       break;
-
-      case OP_EDIT_TYPE:
-       CHECK_COUNT;
-        {
-         mutt_edit_content_type (NULL, idx[menu->current]->content, NULL);
-
-         /* this may have been a change to text/something */
-         mutt_update_encoding (idx[menu->current]->content);
-
-         menu->redraw = REDRAW_CURRENT;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+          mutt_error _("Invalid encoding.");
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 
-      case OP_COMPOSE_EDIT_ENCODING:
-       CHECK_COUNT;
-       strfcpy (buf, ENCODING (idx[menu->current]->content->encoding),
-                                                             sizeof (buf));
-       if (mutt_get_field ("Content-Transfer-Encoding: ", buf,
-                                           sizeof (buf), 0) == 0 && buf[0])
-       {
-         if ((i = mutt_check_encoding (buf)) != ENCOTHER && i != ENCUUENCODED)
-         {
-           idx[menu->current]->content->encoding = i;
-           menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
-           mutt_clear_error();
-         }
-         else
-           mutt_error _("Invalid encoding.");
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+    case OP_COMPOSE_SEND_MESSAGE:
 
-      case OP_COMPOSE_SEND_MESSAGE:
+      /* Note: We don't invoke send2-hook here, since we want to leave
+       * users an opportunity to change settings from the ":" prompt.
+       */
+
+      if (check_attachments (idx, idxlen) != 0) {
+        menu->redraw = REDRAW_FULL;
+        break;
+      }
 
-        /* Note: We don't invoke send2-hook here, since we want to leave
-        * users an opportunity to change settings from the ":" prompt.
-        */
-      
-        if(check_attachments(idx, idxlen) != 0)
-        {
-         menu->redraw = REDRAW_FULL;
-         break;
-       }
 
-      
 #ifdef MIXMASTER
-        if (msg->chain && mix_check_message (msg) != 0)
-         break;
+      if (msg->chain && mix_check_message (msg) != 0)
+        break;
 #endif
-      
-       if (!fccSet && *fcc)
-       {
-         if ((i = query_quadoption (OPT_COPY,
-                               _("Save a copy of this message?"))) == -1)
-           break;
-         else if (i == M_NO)
-           *fcc = 0;
-       }
-
-       loop = 0;
-       r = 0;
-       break;
-
-      case OP_COMPOSE_EDIT_FILE:
-       CHECK_COUNT;
-       mutt_edit_file (NONULL(Editor), idx[menu->current]->content->filename);
-       mutt_update_encoding (idx[menu->current]->content);
-       menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-       break;
 
-      case OP_COMPOSE_TOGGLE_UNLINK:
-       CHECK_COUNT;
-       idx[menu->current]->content->unlink = !idx[menu->current]->content->unlink;
+      if (!fccSet && *fcc) {
+        if ((i = query_quadoption (OPT_COPY,
+                                   _("Save a copy of this message?"))) == -1)
+          break;
+        else if (i == M_NO)
+          *fcc = 0;
+      }
+
+      loop = 0;
+      r = 0;
+      break;
+
+    case OP_COMPOSE_EDIT_FILE:
+      CHECK_COUNT;
+      mutt_edit_file (NONULL (Editor), idx[menu->current]->content->filename);
+      mutt_update_encoding (idx[menu->current]->content);
+      menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_TOGGLE_UNLINK:
+      CHECK_COUNT;
+      idx[menu->current]->content->unlink =
+        !idx[menu->current]->content->unlink;
 
 #if 0
-        /* OPTRESOLVE is otherwise ignored on this menu.
-        * Where's the bug?
-        */
+      /* OPTRESOLVE is otherwise ignored on this menu.
+       * Where's the bug?
+       */
 
-        if (option (OPTRESOLVE) && menu->current + 1 < menu->max)
-         menu->current++;
+      if (option (OPTRESOLVE) && menu->current + 1 < menu->max)
+        menu->current++;
 # endif
-       menu->redraw = REDRAW_INDEX;
-        /* No send2hook since this doesn't change the message. */
-       break;
+      menu->redraw = REDRAW_INDEX;
+      /* No send2hook since this doesn't change the message. */
+      break;
 
-      case OP_COMPOSE_GET_ATTACHMENT:
-        CHECK_COUNT;
-        if(menu->tagprefix)
-        {
-         BODY *top;
-         for(top = msg->content; top; top = top->next)
-         {
-           if(top->tagged)
-             mutt_get_tmp_attachment(top);
-         }
-         menu->redraw = REDRAW_FULL;
-       }
-        else if (mutt_get_tmp_attachment(idx[menu->current]->content) == 0)
-         menu->redraw = REDRAW_CURRENT;
-
-        /* No send2hook since this doesn't change the message. */
-        break;
-      
-      case OP_COMPOSE_RENAME_FILE:
-       CHECK_COUNT;
-       strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname));
-       mutt_pretty_mailbox (fname);
-       if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE)
-                                                       == 0 && fname[0])
-       {
-         if (stat(idx[menu->current]->content->filename, &st) == -1)
-         {
-           mutt_error (_("Can't stat %s: %s"), fname, strerror (errno));
-           break;
-         }
-
-         mutt_expand_path (fname, sizeof (fname));
-         if(mutt_rename_file (idx[menu->current]->content->filename, fname))
-           break;
-         
-         mutt_str_replace (&idx[menu->current]->content->filename, fname);
-         menu->redraw = REDRAW_CURRENT;
-
-         if(idx[menu->current]->content->stamp >= st.st_mtime)
-           mutt_stamp_attachment(idx[menu->current]->content);
-         
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+    case OP_COMPOSE_GET_ATTACHMENT:
+      CHECK_COUNT;
+      if (menu->tagprefix) {
+        BODY *top;
+
+        for (top = msg->content; top; top = top->next) {
+          if (top->tagged)
+            mutt_get_tmp_attachment (top);
+        }
+        menu->redraw = REDRAW_FULL;
+      }
+      else if (mutt_get_tmp_attachment (idx[menu->current]->content) == 0)
+        menu->redraw = REDRAW_CURRENT;
+
+      /* No send2hook since this doesn't change the message. */
+      break;
+
+    case OP_COMPOSE_RENAME_FILE:
+      CHECK_COUNT;
+      strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname));
+      mutt_pretty_mailbox (fname);
+      if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE)
+          == 0 && fname[0]) {
+        if (stat (idx[menu->current]->content->filename, &st) == -1) {
+          mutt_error (_("Can't stat %s: %s"), fname, strerror (errno));
+          break;
+        }
+
+        mutt_expand_path (fname, sizeof (fname));
+        if (mutt_rename_file (idx[menu->current]->content->filename, fname))
+          break;
+
+        mutt_str_replace (&idx[menu->current]->content->filename, fname);
+        menu->redraw = REDRAW_CURRENT;
+
+        if (idx[menu->current]->content->stamp >= st.st_mtime)
+          mutt_stamp_attachment (idx[menu->current]->content);
 
-      case OP_COMPOSE_NEW_MIME:
-       {
-         char type[STRING];
-         char *p;
-         int itype;
-         FILE *fp;
-
-         CLEARLINE (LINES-1);
-         fname[0] = 0;
-         if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
-             != 0 || !fname[0])
-           continue;
-         mutt_expand_path (fname, sizeof (fname));
-
-         /* Call to lookup_mime_type () ?  maybe later */
-         type[0] = 0;
-         if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 
-             || !type[0])
-           continue;
-
-         if (!(p = strchr (type, '/')))
-         {
-           mutt_error _("Content-Type is of the form base/sub");
-           continue;
-         }
-         *p++ = 0;
-         if ((itype = mutt_check_mime_type (type)) == TYPEOTHER)
-         {
-           mutt_error (_("Unknown Content-Type %s"), type);
-           continue;
-         }
-         if (idxlen == idxmax)
-         {
-           safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
-           menu->data = idx;
-         }
-
-         idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
-         /* Touch the file */
-         if (!(fp = safe_fopen (fname, "w")))
-         {
-           mutt_error (_("Can't create file %s"), fname);
-           FREE (&idx[idxlen]);
-           continue;
-         }
-         fclose (fp);
-
-         if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL)
-         {
-           mutt_error _("What we have here is a failure to make an attachment");
-           continue;
-         }
-         update_idx (menu, idx, idxlen++);
-
-         idx[menu->current]->content->type = itype;
-         mutt_str_replace (&idx[menu->current]->content->subtype, p);
-         idx[menu->current]->content->unlink = 1;
-         menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
-
-         if (mutt_compose_attachment (idx[menu->current]->content))
-         {
-           mutt_update_encoding (idx[menu->current]->content);
-           menu->redraw = REDRAW_FULL;
-         }
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);    
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_NEW_MIME:
+      {
+        char type[STRING];
+        char *p;
+        int itype;
+        FILE *fp;
+
+        CLEARLINE (LINES - 1);
+        fname[0] = 0;
+        if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
+            != 0 || !fname[0])
+          continue;
+        mutt_expand_path (fname, sizeof (fname));
+
+        /* Call to lookup_mime_type () ?  maybe later */
+        type[0] = 0;
+        if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0
+            || !type[0])
+          continue;
+
+        if (!(p = strchr (type, '/'))) {
+          mutt_error _("Content-Type is of the form base/sub");
+
+          continue;
+        }
+        *p++ = 0;
+        if ((itype = mutt_check_mime_type (type)) == TYPEOTHER) {
+          mutt_error (_("Unknown Content-Type %s"), type);
+          continue;
+        }
+        if (idxlen == idxmax) {
+          safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+          menu->data = idx;
+        }
+
+        idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+        /* Touch the file */
+        if (!(fp = safe_fopen (fname, "w"))) {
+          mutt_error (_("Can't create file %s"), fname);
+          FREE (&idx[idxlen]);
+          continue;
+        }
+        fclose (fp);
+
+        if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL) {
+          mutt_error
+            _("What we have here is a failure to make an attachment");
+          continue;
+        }
+        update_idx (menu, idx, idxlen++);
+
+        idx[menu->current]->content->type = itype;
+        mutt_str_replace (&idx[menu->current]->content->subtype, p);
+        idx[menu->current]->content->unlink = 1;
+        menu->redraw |= REDRAW_INDEX | REDRAW_STATUS;
+
+        if (mutt_compose_attachment (idx[menu->current]->content)) {
+          mutt_update_encoding (idx[menu->current]->content);
+          menu->redraw = REDRAW_FULL;
+        }
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_COMPOSE_EDIT_MIME:
+      CHECK_COUNT;
+      if (mutt_edit_attachment (idx[menu->current]->content)) {
+        mutt_update_encoding (idx[menu->current]->content);
+        menu->redraw = REDRAW_FULL;
+      }
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_VIEW_ATTACH:
+    case OP_DISPLAY_HEADERS:
+      CHECK_COUNT;
+      mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen,
+                                NULL, 0);
+      menu->redraw = REDRAW_FULL;
+      /* no send2hook, since this doesn't modify the message */
+      break;
+
+    case OP_SAVE:
+      CHECK_COUNT;
+      mutt_save_attachment_list (NULL, menu->tagprefix,
+                                 menu->tagprefix ? msg->content : idx[menu->
+                                                                      current]->
+                                 content, NULL, menu);
+      MAYBE_REDRAW (menu->redraw);
+      /* no send2hook, since this doesn't modify the message */
+      break;
+
+    case OP_PRINT:
+      CHECK_COUNT;
+      mutt_print_attachment_list (NULL, menu->tagprefix,
+                                  menu->tagprefix ? msg->content : idx[menu->
+                                                                       current]->
+                                  content);
+      /* no send2hook, since this doesn't modify the message */
+      break;
+
+    case OP_PIPE:
+    case OP_FILTER:
+      CHECK_COUNT;
+      mutt_pipe_attachment_list (NULL, menu->tagprefix,
+                                 menu->tagprefix ? msg->content : idx[menu->
+                                                                      current]->
+                                 content, op == OP_FILTER);
+      if (op == OP_FILTER)      /* cte might have changed */
+        menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT;
+      menu->redraw |= REDRAW_STATUS;
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
+    case OP_EXIT:
+      if ((i =
+           query_quadoption (OPT_POSTPONE,
+                             _("Postpone this message?"))) == M_NO) {
+        while (idxlen-- > 0) {
+          /* avoid freeing other attachments */
+          idx[idxlen]->content->next = NULL;
+          idx[idxlen]->content->parts = NULL;
+          mutt_free_body (&idx[idxlen]->content);
+          FREE (&idx[idxlen]->tree);
+          FREE (&idx[idxlen]);
+        }
+        FREE (&idx);
+        idxlen = 0;
+        idxmax = 0;
+        r = -1;
+        loop = 0;
         break;
+      }
+      else if (i == -1)
+        break;                  /* abort */
 
-      case OP_COMPOSE_EDIT_MIME:
-       CHECK_COUNT;
-       if (mutt_edit_attachment (idx[menu->current]->content))
-       {
-         mutt_update_encoding (idx[menu->current]->content);
-         menu->redraw = REDRAW_FULL;
-       }
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      /* fall through to postpone! */
+
+    case OP_COMPOSE_POSTPONE_MESSAGE:
+
+      if (check_attachments (idx, idxlen) != 0) {
+        menu->redraw = REDRAW_FULL;
         break;
+      }
 
-      case OP_VIEW_ATTACH:
-      case OP_DISPLAY_HEADERS:
-       CHECK_COUNT;
-       mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen, NULL, 0);
-       menu->redraw = REDRAW_FULL;
-        /* no send2hook, since this doesn't modify the message */
-       break;
-
-      case OP_SAVE:
-       CHECK_COUNT;
-       mutt_save_attachment_list (NULL, menu->tagprefix, menu->tagprefix ?  msg->content : idx[menu->current]->content, NULL, menu);
-       MAYBE_REDRAW (menu->redraw);
-        /* no send2hook, since this doesn't modify the message */
-       break;
-
-      case OP_PRINT:
-       CHECK_COUNT;
-       mutt_print_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content);
-        /* no send2hook, since this doesn't modify the message */
-       break;
-
-      case OP_PIPE:
-      case OP_FILTER:
-        CHECK_COUNT;
-       mutt_pipe_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, op == OP_FILTER);
-       if (op == OP_FILTER) /* cte might have changed */
-         menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT;
+      loop = 0;
+      r = 1;
+      break;
+
+    case OP_COMPOSE_ISPELL:
+      endwin ();
+      snprintf (buf, sizeof (buf), "%s -x %s", NONULL (Ispell),
+                msg->content->filename);
+      if (mutt_system (buf) == -1)
+        mutt_error (_("Error running \"%s\"!"), buf);
+      else {
+        mutt_update_encoding (msg->content);
         menu->redraw |= REDRAW_STATUS;
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-       break;
-
-      case OP_EXIT:
-       if ((i = query_quadoption (OPT_POSTPONE, _("Postpone this message?"))) == M_NO)
-       {
-         while (idxlen-- > 0)
-         {
-           /* avoid freeing other attachments */
-           idx[idxlen]->content->next = NULL;
-           idx[idxlen]->content->parts = NULL;
-           mutt_free_body (&idx[idxlen]->content);
-           FREE (&idx[idxlen]->tree);
-           FREE (&idx[idxlen]);
-         }
-         FREE (&idx);
-         idxlen = 0;
-         idxmax = 0;
-         r = -1;
-         loop = 0;
-         break;
-       }
-       else if (i == -1)
-         break; /* abort */
-
-       /* fall through to postpone! */
-
-      case OP_COMPOSE_POSTPONE_MESSAGE:
-
-        if(check_attachments(idx, idxlen) != 0)
-        {
-         menu->redraw = REDRAW_FULL;
-         break;
-       }
-      
-       loop = 0;
-       r = 1;
-       break;
-
-      case OP_COMPOSE_ISPELL:
-       endwin ();
-       snprintf (buf, sizeof (buf), "%s -x %s", NONULL(Ispell), msg->content->filename);
-       if (mutt_system (buf) == -1)
-         mutt_error (_("Error running \"%s\"!"), buf);
-       else
-        {
-         mutt_update_encoding (msg->content);
-         menu->redraw |= REDRAW_STATUS;
-       }
-       break;
-
-      case OP_COMPOSE_WRITE_MESSAGE:
-
-       fname[0] = '\0';
-       if (Context)
-       {
-        strfcpy (fname, NONULL (Context->path), sizeof (fname));
-        mutt_pretty_mailbox (fname);
-       }
-       if (idxlen)
-         msg->content = idx[0]->content;
-       if (mutt_enter_fname (_("Write message to mailbox"), fname, sizeof (fname),
-                             &menu->redraw, 1) != -1 && fname[0])
-       {
-         mutt_message (_("Writing message to %s ..."), fname);
-         mutt_expand_path (fname, sizeof (fname));
-
-         if (msg->content->next)
-           msg->content = mutt_make_multipart (msg->content);
-
-         if (mutt_write_fcc (NONULL (fname), msg, NULL, 1, NULL) < 0)
-           msg->content = mutt_remove_multipart (msg->content);
-         else
-           mutt_message _("Message written.");
-       }
-       break;
-
-
-
-      case OP_COMPOSE_PGP_MENU:
-        if (!(WithCrypto & APPLICATION_PGP))
-          break;
-       if ((WithCrypto & APPLICATION_SMIME)
-            && msg->security & APPLICATION_SMIME)
-       {
-         if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "),
-                            M_YES) != M_YES)
-         {
-           mutt_clear_error ();
-           break;
-         }
-         msg->security = 0;
-       }
-       msg->security = crypt_pgp_send_menu (msg, &menu->redraw);
-       redraw_crypt_lines (msg);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+      }
+      break;
+
+    case OP_COMPOSE_WRITE_MESSAGE:
 
+      fname[0] = '\0';
+      if (Context) {
+        strfcpy (fname, NONULL (Context->path), sizeof (fname));
+        mutt_pretty_mailbox (fname);
+      }
+      if (idxlen)
+        msg->content = idx[0]->content;
+      if (mutt_enter_fname
+          (_("Write message to mailbox"), fname, sizeof (fname),
+           &menu->redraw, 1) != -1 && fname[0]) {
+        mutt_message (_("Writing message to %s ..."), fname);
+        mutt_expand_path (fname, sizeof (fname));
+
+        if (msg->content->next)
+          msg->content = mutt_make_multipart (msg->content);
+
+        if (mutt_write_fcc (NONULL (fname), msg, NULL, 1, NULL) < 0)
+          msg->content = mutt_remove_multipart (msg->content);
+        else
+          mutt_message _("Message written.");
+      }
+      break;
 
-      case OP_FORGET_PASSPHRASE:
-       crypt_forget_passphrase ();
-       break;
 
 
-      case OP_COMPOSE_SMIME_MENU:
-        if (!(WithCrypto & APPLICATION_SMIME))
+    case OP_COMPOSE_PGP_MENU:
+      if (!(WithCrypto & APPLICATION_PGP))
+        break;
+      if ((WithCrypto & APPLICATION_SMIME)
+          && msg->security & APPLICATION_SMIME) {
+        if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "),
+                          M_YES) != M_YES) {
+          mutt_clear_error ();
           break;
+        }
+        msg->security = 0;
+      }
+      msg->security = crypt_pgp_send_menu (msg, &menu->redraw);
+      redraw_crypt_lines (msg);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 
-       if ((WithCrypto & APPLICATION_PGP)
-            && msg->security & APPLICATION_PGP)
-       {
-         if (mutt_yesorno (_("PGP already selected. Clear & continue ? "),
-                             M_YES) != M_YES)
-         {
-            mutt_clear_error ();
-            break;
-         }
-         msg->security = 0;
-       }
-       msg->security = crypt_smime_send_menu(msg, &menu->redraw);
-       redraw_crypt_lines (msg);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
+
+    case OP_FORGET_PASSPHRASE:
+      crypt_forget_passphrase ();
+      break;
+
+
+    case OP_COMPOSE_SMIME_MENU:
+      if (!(WithCrypto & APPLICATION_SMIME))
         break;
 
+      if ((WithCrypto & APPLICATION_PGP)
+          && msg->security & APPLICATION_PGP) {
+        if (mutt_yesorno (_("PGP already selected. Clear & continue ? "),
+                          M_YES) != M_YES) {
+          mutt_clear_error ();
+          break;
+        }
+        msg->security = 0;
+      }
+      msg->security = crypt_smime_send_menu (msg, &menu->redraw);
+      redraw_crypt_lines (msg);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
+
 
 #ifdef MIXMASTER
-      case OP_COMPOSE_MIX:
-      
-       mix_make_chain (&msg->chain, &menu->redraw);
-        mutt_message_hook (NULL, msg, M_SEND2HOOK);
-        break;
+    case OP_COMPOSE_MIX:
+
+      mix_make_chain (&msg->chain, &menu->redraw);
+      mutt_message_hook (NULL, msg, M_SEND2HOOK);
+      break;
 #endif
 
     }
 
     /* Draw formated compose status line */
-    if (menu->redraw & REDRAW_STATUS) 
-    {
-               compose_status_line (buf, sizeof (buf), menu, NONULL(ComposeFormat));
-       CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
-       SETCOLOR (MT_COLOR_STATUS);
-       printw ("%-*.*s", COLS, COLS, buf);
-       SETCOLOR (MT_COLOR_NORMAL);
-       menu->redraw &= ~REDRAW_STATUS;
+    if (menu->redraw & REDRAW_STATUS) {
+      compose_status_line (buf, sizeof (buf), menu, NONULL (ComposeFormat));
+      CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
+      SETCOLOR (MT_COLOR_STATUS);
+      printw ("%-*.*s", COLS, COLS, buf);
+      SETCOLOR (MT_COLOR_NORMAL);
+      menu->redraw &= ~REDRAW_STATUS;
     }
   }
 
   mutt_menuDestroy (&menu);
 
-  if (idxlen)
-  {
+  if (idxlen) {
     msg->content = idx[0]->content;
-    for (i = 0; i < idxlen; i++)
-    {
+    for (i = 0; i < idxlen; i++) {
       idx[i]->content->aptr = NULL;
       FREE (&idx[i]);
     }
@@ -1472,4 +1428,3 @@ int mutt_compose_menu (HEADER *msg,   /* structure for new message */
 
   return (r);
 }
-
index 11d4fa4..1ac8355 100644 (file)
 #include <unistd.h>
 #include <sys/stat.h>
 
-typedef struct
-{
-  const char *close;   /* close-hook  command */
-  const char *open;    /* open-hook   command */
-  const char *append;  /* append-hook command */
-  off_t size;          /* size of real folder */
+typedef struct {
+  const char *close;            /* close-hook  command */
+  const char *open;             /* open-hook   command */
+  const char *append;           /* append-hook command */
+  off_t size;                   /* size of real folder */
 } COMPRESS_INFO;
 
 char echo_cmd[HUGE_STRING];
@@ -44,14 +43,13 @@ char echo_cmd[HUGE_STRING];
  * excl - exclusive lock?
  * retry - should retry if unable to lock?
  */
-int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
+int mbox_lock_compressed (CONTEXT * ctx, FILE * fp, int excl, int retry)
 {
   int r;
 
   if ((r = mx_lock_file (ctx->realpath, fileno (fp), excl, 1, retry)) == 0)
     ctx->locked = 1;
-  else if (retry && !excl)
-  {
+  else if (retry && !excl) {
     ctx->readonly = 1;
     return 0;
   }
@@ -59,10 +57,9 @@ int mbox_lock_compressed (CONTEXT *ctx, FILE *fp, int excl, int retry)
   return (r);
 }
 
-void mbox_unlock_compressed (CONTEXT *ctx, FILE *fp)
+void mbox_unlock_compressed (CONTEXT * ctx, FILE * fp)
 {
-  if (ctx->locked)
-  {
+  if (ctx->locked) {
     fflush (fp);
 
     mx_unlock_file (ctx->realpath, fileno (fp), 1);
@@ -75,9 +72,10 @@ static int is_new (const char *path)
   return (access (path, W_OK) != 0 && errno == ENOENT) ? 1 : 0;
 }
 
-static const charfind_compress_hook (int type, const char *path)
+static const char *find_compress_hook (int type, const char *path)
 {
-  const char* c = mutt_find_hook (type, path);
+  const char *c = mutt_find_hook (type, path);
+
   return (!c || !*c) ? NULL : c;
 }
 
@@ -89,12 +87,13 @@ int mutt_can_read_compressed (const char *path)
 /* if the file is new, we really do not append, but create, and so use
  * close-hook, and not append-hook 
  */
-static const char* get_append_command (const char *path, const CONTEXT* ctx)
+static const char *get_append_command (const char *path, const CONTEXT * ctx)
 {
   COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+
   return (is_new (path)) ? ci->close : ci->append;
 }
-    
+
 int mutt_can_append_compressed (const char *path)
 {
   int magic;
@@ -103,30 +102,30 @@ int mutt_can_append_compressed (const char *path)
     return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);
 
   magic = mx_get_magic (path);
-  
+
   if (magic != 0 && magic != M_COMPRESSED)
     return 0;
 
   return (find_compress_hook (M_APPENDHOOK, path)
-         || (find_compress_hook (M_OPENHOOK, path) 
-             && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
+          || (find_compress_hook (M_OPENHOOK, path)
+              && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
 }
 
 /* open a compressed mailbox */
-static COMPRESS_INFO *set_compress_info (CONTEXT *ctx)
+static COMPRESS_INFO *set_compress_info (CONTEXT * ctx)
 {
   COMPRESS_INFO *ci;
 
   /* Now lets uncompress this thing */
   ci = safe_malloc (sizeof (COMPRESS_INFO));
-  ctx->compressinfo = (void*) ci;
+  ctx->compressinfo = (void *) ci;
   ci->append = find_compress_hook (M_APPENDHOOK, ctx->path);
   ci->open = find_compress_hook (M_OPENHOOK, ctx->path);
   ci->close = find_compress_hook (M_CLOSEHOOK, ctx->path);
   return ci;
 }
-  
-static void set_path (CONTEXT* ctx)
+
+static void set_path (CONTEXT * ctx)
 {
   char tmppath[_POSIX_PATH_MAX];
 
@@ -139,31 +138,35 @@ static void set_path (CONTEXT* ctx)
   strcpy (ctx->path, tmppath);
 }
 
-static int get_size (const char* path) 
+static int get_size (const char *path)
 {
   struct stat sb;
+
   if (stat (path, &sb) != 0)
     return 0;
   return (sb.st_size);
 }
 
-static void store_size (CONTEXT* ctx) 
+static void store_size (CONTEXT * ctx)
 {
   COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
+
   ci->size = get_size (ctx->realpath);
 }
 
-static const char *
-compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
-                        const char *fmt, const char *ifstring, 
-                        const char *elsestring, unsigned long data, 
-                        format_flag flags)
+static const char *compresshook_format_str (char *dest, size_t destlen,
+                                            char op, const char *src,
+                                            const char *fmt,
+                                            const char *ifstring,
+                                            const char *elsestring,
+                                            unsigned long data,
+                                            format_flag flags)
 {
   char tmp[SHORT_STRING];
-  
+
   CONTEXT *ctx = (CONTEXT *) data;
-  switch (op)
-  {
+
+  switch (op) {
   case 'f':
     snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
     snprintf (dest, destlen, tmp, ctx->realpath);
@@ -179,39 +182,42 @@ compresshook_format_str (char *dest, size_t destlen, char op, const char *src,
 /* check that the command has both %f and %t
  * 0 means OK, -1 means error
  */
-int mutt_test_compress_command (const charcmd)
+int mutt_test_compress_command (const char *cmd)
 {
   return (strstr (cmd, "%f") && strstr (cmd, "%t")) ? 0 : -1;
 }
 
-static char *get_compression_cmd (const char* cmd, const CONTEXT* ctx)
+static char *get_compression_cmd (const char *cmd, const CONTEXT * ctx)
 {
   char expanded[_POSIX_PATH_MAX];
-  mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str,
-                    (unsigned long) ctx, 0);
+
+  mutt_FormatString (expanded, sizeof (expanded), cmd,
+                     compresshook_format_str, (unsigned long) ctx, 0);
   return safe_strdup (expanded);
 }
 
-int mutt_check_mailbox_compressed (CONTEXT* ctx)
+int mutt_check_mailbox_compressed (CONTEXT * ctx)
 {
   COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
-  if (ci->size != get_size (ctx->realpath))
-  {
+
+  if (ci->size != get_size (ctx->realpath)) {
     FREE (&ctx->compressinfo);
     FREE (&ctx->realpath);
     mutt_error _("Mailbox was corrupted!");
+
     return (-1);
   }
   return (0);
 }
 
-int mutt_open_read_compressed (CONTEXT *ctx)
+int mutt_open_read_compressed (CONTEXT * ctx)
 {
   char *cmd;
   FILE *fp;
   int rc;
 
   COMPRESS_INFO *ci = set_compress_info (ctx);
+
   if (!ci->open) {
     ctx->magic = 0;
     FREE (ctx->compressinfo);
@@ -227,44 +233,43 @@ int mutt_open_read_compressed (CONTEXT *ctx)
     mutt_message (_("Decompressing %s..."), ctx->realpath);
 
   cmd = get_compression_cmd (ci->open, ctx);
-  if (cmd == NULL) 
+  if (cmd == NULL)
     return (-1);
   dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
 
-  if ((fp = fopen (ctx->realpath, "r")) == NULL)
-  {
+  if ((fp = fopen (ctx->realpath, "r")) == NULL) {
     mutt_perror (ctx->realpath);
     FREE (&cmd);
     return (-1);
   }
   mutt_block_signals ();
-  if (mbox_lock_compressed (ctx, fp, 0, 1) == -1)
-  {
+  if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) {
     fclose (fp);
     mutt_unblock_signals ();
     mutt_error _("Unable to lock mailbox!");
+
     FREE (&cmd);
     return (-1);
   }
 
   endwin ();
   fflush (stdout);
-  sprintf(echo_cmd,_("echo Decompressing %s..."),ctx->realpath); 
-  mutt_system(echo_cmd);
+  sprintf (echo_cmd, _("echo Decompressing %s..."), ctx->realpath);
+  mutt_system (echo_cmd);
   rc = mutt_system (cmd);
   mbox_unlock_compressed (ctx, fp);
   mutt_unblock_signals ();
   fclose (fp);
 
-  if (rc)
-  {
+  if (rc) {
     mutt_any_key_to_continue (NULL);
     ctx->magic = 0;
     FREE (ctx->compressinfo);
-    mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd);
+    mutt_error (_("Error executing: %s : unable to open the mailbox!\n"),
+                cmd);
   }
   FREE (&cmd);
-  if (rc) 
+  if (rc)
     return (-1);
 
   if (mutt_check_mailbox_compressed (ctx))
@@ -275,26 +280,25 @@ int mutt_open_read_compressed (CONTEXT *ctx)
   return (0);
 }
 
-void restore_path (CONTEXT* ctx)
+void restore_path (CONTEXT * ctx)
 {
   FREE (&ctx->path);
   ctx->path = ctx->realpath;
 }
 
 /* remove the temporary mailbox */
-void remove_file (CONTEXT* ctx) 
+void remove_file (CONTEXT * ctx)
 {
   if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
     remove (ctx->path);
 }
 
-int mutt_open_append_compressed (CONTEXT *ctx)
+int mutt_open_append_compressed (CONTEXT * ctx)
 {
   FILE *fh;
   COMPRESS_INFO *ci = set_compress_info (ctx);
 
-  if (!get_append_command (ctx->path, ctx))
-  {
+  if (!get_append_command (ctx->path, ctx)) {
     if (ci->open && ci->close)
       return (mutt_open_read_compressed (ctx));
 
@@ -310,25 +314,24 @@ int mutt_open_append_compressed (CONTEXT *ctx)
   if (!is_new (ctx->realpath))
     if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
       if ((fh = safe_fopen (ctx->path, "w")))
-       fclose (fh);
+        fclose (fh);
   /* No error checking - the parent function will catch it */
 
   return (0);
 }
 
 /* close a compressed mailbox */
-void mutt_fast_close_compressed (CONTEXT *ctx)
+void mutt_fast_close_compressed (CONTEXT * ctx)
 {
   dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
-             ctx->path));
+              ctx->path));
 
-  if (ctx->compressinfo)
-  {
+  if (ctx->compressinfo) {
     if (ctx->fp)
       fclose (ctx->fp);
     ctx->fp = NULL;
     /* if the folder was removed, remove the gzipped folder too */
-    if (access (ctx->path, F_OK) != 0 && ! option (OPTSAVEEMPTY))
+    if (access (ctx->path, F_OK) != 0 && !option (OPTSAVEEMPTY))
       remove (ctx->realpath);
     else
       remove_file (ctx);
@@ -339,7 +342,7 @@ void mutt_fast_close_compressed (CONTEXT *ctx)
 }
 
 /* return 0 on success, -1 on failure */
-int mutt_sync_compressed (CONTEXT* ctx)
+int mutt_sync_compressed (CONTEXT * ctx)
 {
   char *cmd;
   int rc = 0;
@@ -350,23 +353,21 @@ int mutt_sync_compressed (CONTEXT* ctx)
     mutt_message (_("Compressing %s..."), ctx->realpath);
 
   cmd = get_compression_cmd (ci->close, ctx);
-  if (cmd == NULL) 
+  if (cmd == NULL)
     return (-1);
 
-  if ((fp = fopen (ctx->realpath, "a")) == NULL)
-  {
+  if ((fp = fopen (ctx->realpath, "a")) == NULL) {
     mutt_perror (ctx->realpath);
     FREE (&cmd);
     return (-1);
   }
   mutt_block_signals ();
-  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
-  {
+  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
     fclose (fp);
     mutt_unblock_signals ();
     mutt_error _("Unable to lock mailbox!");
 
-  store_size (ctx);
+    store_size (ctx);
 
     FREE (&cmd);
     return (-1);
@@ -376,12 +377,13 @@ int mutt_sync_compressed (CONTEXT* ctx)
 
   endwin ();
   fflush (stdout);
-  sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); 
-  mutt_system(echo_cmd);
-  if (mutt_system (cmd))
-  {
+  sprintf (echo_cmd, _("echo Compressing %s..."), ctx->realpath);
+  mutt_system (echo_cmd);
+  if (mutt_system (cmd)) {
     mutt_any_key_to_continue (NULL);
-    mutt_error (_("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"), ctx->path);
+    mutt_error (_
+                ("%s: Error compressing mailbox! Original mailbox deleted, uncompressed one kept!\n"),
+                ctx->path);
     rc = -1;
   }
 
@@ -390,29 +392,27 @@ int mutt_sync_compressed (CONTEXT* ctx)
   fclose (fp);
 
   FREE (&cmd);
-  
+
   store_size (ctx);
 
   return (rc);
 }
 
-int mutt_slow_close_compressed (CONTEXT *ctx)
+int mutt_slow_close_compressed (CONTEXT * ctx)
 {
   FILE *fp;
   const char *append;
   char *cmd;
   COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
 
-  dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n", 
-             ctx->path));
+  dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
+              ctx->path));
 
-  if (! (ctx->append 
-        && ((append = get_append_command (ctx->realpath, ctx))
-            || (append = ci->close))))
-  { /* if we can not or should not append,
-     * we only have to remove the compressed info, because sync was already
-     * called 
-     */
+  if (!(ctx->append && ((append = get_append_command (ctx->realpath, ctx))
+                        || (append = ci->close)))) {    /* if we can not or should not append,
+                                                         * we only have to remove the compressed info, because sync was already
+                                                         * called 
+                                                         */
     mutt_fast_close_compressed (ctx);
     return (0);
   }
@@ -421,8 +421,7 @@ int mutt_slow_close_compressed (CONTEXT *ctx)
     fclose (ctx->fp);
   ctx->fp = NULL;
 
-  if (!ctx->quiet)
-  {
+  if (!ctx->quiet) {
     if (append == ci->close)
       mutt_message (_("Compressing %s..."), ctx->realpath);
     else
@@ -430,21 +429,20 @@ int mutt_slow_close_compressed (CONTEXT *ctx)
   }
 
   cmd = get_compression_cmd (append, ctx);
-  if (cmd == NULL) 
+  if (cmd == NULL)
     return (-1);
 
-  if ((fp = fopen (ctx->realpath, "a")) == NULL)
-  {
+  if ((fp = fopen (ctx->realpath, "a")) == NULL) {
     mutt_perror (ctx->realpath);
     FREE (&cmd);
     return (-1);
   }
   mutt_block_signals ();
-  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1)
-  {
+  if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
     fclose (fp);
     mutt_unblock_signals ();
     mutt_error _("Unable to lock mailbox!");
+
     FREE (&cmd);
     return (-1);
   }
@@ -455,16 +453,17 @@ int mutt_slow_close_compressed (CONTEXT *ctx)
   fflush (stdout);
 
   if (append == ci->close)
-    sprintf(echo_cmd,_("echo Compressing %s..."), ctx->realpath); 
+    sprintf (echo_cmd, _("echo Compressing %s..."), ctx->realpath);
   else
-    sprintf(echo_cmd,_("echo Compressed-appending to %s..."), ctx->realpath); 
-  mutt_system(echo_cmd);
+    sprintf (echo_cmd, _("echo Compressed-appending to %s..."),
+             ctx->realpath);
+  mutt_system (echo_cmd);
 
-  if (mutt_system (cmd))
-  {
+  if (mutt_system (cmd)) {
     mutt_any_key_to_continue (NULL);
-    mutt_error (_(" %s: Error compressing mailbox!  Uncompressed one kept!\n"),
-               ctx->path);
+    mutt_error (_
+                (" %s: Error compressing mailbox!  Uncompressed one kept!\n"),
+                ctx->path);
     FREE (&cmd);
     mbox_unlock_compressed (ctx, fp);
     mutt_unblock_signals ();
index 126df1e..dc0b806 100644 (file)
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at run-time.
-        STACK_DIRECTION > 0 => grows toward higher addresses
-        STACK_DIRECTION < 0 => grows toward lower addresses
-        STACK_DIRECTION = 0 => direction of growth unknown */
+       STACK_DIRECTION > 0 => grows toward higher addresses
+       STACK_DIRECTION < 0 => grows toward lower addresses
+       STACK_DIRECTION = 0 => direction of growth unknown */
 #undef STACK_DIRECTION
 
 /* Define to 1 if you have the ANSI C header files. */
@@ -596,9 +596,11 @@ typedef unsigned long long uint64_t;
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
-   if it is not supported. */
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
 #undef inline
+#endif
 
 /* Define to 'int' if system headers don't define. */
 #undef mbstate_t
diff --git a/copy.c b/copy.c
index 9afdc25..f68d45f 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include <unistd.h> /* needed for SEEK_SET under SunOS 4.1.4 */
+#include <unistd.h>             /* needed for SEEK_SET under SunOS 4.1.4 */
 
 static int address_header_decode (char **str);
-static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date);
+static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
+                               char *date);
 
 /* Ok, the only reason for not merging this with mutt_copy_header()
  * below is to avoid creating a HEADER structure in message_handler().
  */
 int
-mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
-              const char *prefix)
+mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags,
+               const char *prefix)
 {
   int from = 0;
   int this_is_from;
   int ignore = 0;
-  char buf[STRING]; /* should be long enough to get most fields in one pass */
+  char buf[STRING];             /* should be long enough to get most fields in one pass */
   char *nl;
   LIST *t;
   char **headers;
@@ -62,54 +63,52 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
   buf[0] = '\n';
   buf[1] = 0;
 
-  if ((flags & (CH_REORDER | CH_WEED | CH_MIME | CH_DECODE | CH_PREFIX | CH_WEED_DELIVERED)) == 0)
-  {
+  if ((flags &
+       (CH_REORDER | CH_WEED | CH_MIME | CH_DECODE | CH_PREFIX |
+        CH_WEED_DELIVERED)) == 0) {
     /* Without these flags to complicate things
      * we can do a more efficient line to line copying
      */
-    while (ftell (in) < off_end)
-    {
+    while (ftell (in) < off_end) {
       nl = strchr (buf, '\n');
 
       if ((fgets (buf, sizeof (buf), in)) == NULL)
-       break;
+        break;
 
       /* Is it the begining of a header? */
-      if (nl && buf[0] != ' ' && buf[0] != '\t')
-      {
-       ignore = 1;
-       if (!from && mutt_strncmp ("From ", buf, 5) == 0)
-       {
-         if ((flags & CH_FROM) == 0)
-           continue;
-         from = 1;
-       }
-       else if (flags & (CH_NOQFROM) &&
-                       ascii_strncasecmp (">From ", buf, 6) == 0)
-               continue;
-
-       else if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))
-         break; /* end of header */
-
-       if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) &&
-           (ascii_strncasecmp ("Status:", buf, 7) == 0 ||
-            ascii_strncasecmp ("X-Status:", buf, 9) == 0))
-         continue;
-       if ((flags & (CH_UPDATE_LEN | CH_XMIT | CH_NOLEN)) &&
-           (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
-            ascii_strncasecmp ("Lines:", buf, 6) == 0))
-         continue;
-       if ((flags & CH_UPDATE_REFS) &&
-           ascii_strncasecmp ("References:", buf, 11) == 0)
-         continue;
-       if ((flags & CH_UPDATE_IRT) &&
-           ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
-         continue;
-       ignore = 0;
+      if (nl && buf[0] != ' ' && buf[0] != '\t') {
+        ignore = 1;
+        if (!from && mutt_strncmp ("From ", buf, 5) == 0) {
+          if ((flags & CH_FROM) == 0)
+            continue;
+          from = 1;
+        }
+        else if (flags & (CH_NOQFROM) &&
+                 ascii_strncasecmp (">From ", buf, 6) == 0)
+          continue;
+
+        else if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))
+          break;                /* end of header */
+
+        if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) &&
+            (ascii_strncasecmp ("Status:", buf, 7) == 0 ||
+             ascii_strncasecmp ("X-Status:", buf, 9) == 0))
+          continue;
+        if ((flags & (CH_UPDATE_LEN | CH_XMIT | CH_NOLEN)) &&
+            (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
+             ascii_strncasecmp ("Lines:", buf, 6) == 0))
+          continue;
+        if ((flags & CH_UPDATE_REFS) &&
+            ascii_strncasecmp ("References:", buf, 11) == 0)
+          continue;
+        if ((flags & CH_UPDATE_IRT) &&
+            ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
+          continue;
+        ignore = 0;
       }
 
       if (!ignore && fputs (buf, out) == EOF)
-       return (-1);
+        return (-1);
     }
     return 0;
   }
@@ -122,11 +121,9 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
    * so we are able to do re-ordering.
    * First count the number of entries in the array
    */
-  if (flags & CH_REORDER)
-  {
-    for (t = HeaderOrderList; t; t = t->next)
-    {
-      dprint(1, (debugfile, "Reorder list: %s\n", t->data));
+  if (flags & CH_REORDER) {
+    for (t = HeaderOrderList; t; t = t->next) {
+      dprint (1, (debugfile, "Reorder list: %s\n", t->data));
       hdr_count++;
     }
   }
@@ -136,8 +133,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
   headers = safe_calloc (hdr_count, sizeof (char *));
 
   /* Read all the headers into the array */
-  while (ftell (in) < off_end)
-  {
+  while (ftell (in) < off_end) {
     nl = strchr (buf, '\n');
 
     /* Read a line */
@@ -145,172 +141,152 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
       break;
 
     /* Is it the begining of a header? */
-    if (nl && buf[0] != ' ' && buf[0] != '\t')
-    {
+    if (nl && buf[0] != ' ' && buf[0] != '\t') {
       /* Do we have anything pending? */
-      if (this_one)
-      {
-       if (flags & CH_DECODE) 
-       {
-         if (!address_header_decode (&this_one))
-           rfc2047_decode (&this_one);
-       }
-       
-       if (!headers[x])
-         headers[x] = this_one;
-       else 
-       {
-         safe_realloc (&headers[x], mutt_strlen (headers[x]) + 
-                       mutt_strlen (this_one) + sizeof (char));
-         strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
-         FREE (&this_one);
-       }
-       
-       this_one = NULL;
+      if (this_one) {
+        if (flags & CH_DECODE) {
+          if (!address_header_decode (&this_one))
+            rfc2047_decode (&this_one);
+        }
+
+        if (!headers[x])
+          headers[x] = this_one;
+        else {
+          safe_realloc (&headers[x], mutt_strlen (headers[x]) +
+                        mutt_strlen (this_one) + sizeof (char));
+          strcat (headers[x], this_one);        /* __STRCAT_CHECKED__ */
+          FREE (&this_one);
+        }
+
+        this_one = NULL;
       }
-      
+
       ignore = 1;
       this_is_from = 0;
-      if (!from && mutt_strncmp ("From ", buf, 5) == 0)
-      {
-       if ((flags & CH_FROM) == 0)
-         continue;
-       this_is_from = from = 1;
+      if (!from && mutt_strncmp ("From ", buf, 5) == 0) {
+        if ((flags & CH_FROM) == 0)
+          continue;
+        this_is_from = from = 1;
       }
       else if (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))
-       break; /* end of header */
+        break;                  /* end of header */
 
       /* note: CH_FROM takes precedence over header weeding. */
       if (!((flags & CH_FROM) && (flags & CH_FORCE_FROM) && this_is_from) &&
-         (flags & CH_WEED) &&
-         mutt_matches_ignore (buf, Ignore) &&
-         !mutt_matches_ignore (buf, UnIgnore))
-       continue;
+          (flags & CH_WEED) &&
+          mutt_matches_ignore (buf, Ignore) &&
+          !mutt_matches_ignore (buf, UnIgnore))
+        continue;
       if ((flags & CH_WEED_DELIVERED) &&
-         ascii_strncasecmp ("Delivered-To:", buf, 13) == 0)
-       continue;
+          ascii_strncasecmp ("Delivered-To:", buf, 13) == 0)
+        continue;
       if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) &&
-         (ascii_strncasecmp ("Status:", buf, 7) == 0 ||
-          ascii_strncasecmp ("X-Status:", buf, 9) == 0))
-       continue;
+          (ascii_strncasecmp ("Status:", buf, 7) == 0 ||
+           ascii_strncasecmp ("X-Status:", buf, 9) == 0))
+        continue;
       if ((flags & (CH_UPDATE_LEN | CH_XMIT | CH_NOLEN)) &&
-         (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
-          ascii_strncasecmp ("Lines:", buf, 6) == 0))
-       continue;
+          (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
+           ascii_strncasecmp ("Lines:", buf, 6) == 0))
+        continue;
       if ((flags & CH_MIME) &&
-         ((ascii_strncasecmp ("content-", buf, 8) == 0 &&
-           (ascii_strncasecmp ("transfer-encoding:", buf + 8, 18) == 0 ||
-            ascii_strncasecmp ("type:", buf + 8, 5) == 0)) ||
-          ascii_strncasecmp ("mime-version:", buf, 13) == 0))
-       continue;
+          ((ascii_strncasecmp ("content-", buf, 8) == 0 &&
+            (ascii_strncasecmp ("transfer-encoding:", buf + 8, 18) == 0 ||
+             ascii_strncasecmp ("type:", buf + 8, 5) == 0)) ||
+           ascii_strncasecmp ("mime-version:", buf, 13) == 0))
+        continue;
       if ((flags & CH_UPDATE_REFS) &&
-         ascii_strncasecmp ("References:", buf, 11) == 0)
-       continue;
+          ascii_strncasecmp ("References:", buf, 11) == 0)
+        continue;
       if ((flags & CH_UPDATE_IRT) &&
-         ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
-       continue;
+          ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
+        continue;
 
       /* Find x -- the array entry where this header is to be saved */
-      if (flags & CH_REORDER)
-      {
-       for (t = HeaderOrderList, x = 0 ; (t) ; t = t->next, x++)
-       {
-         if (!ascii_strncasecmp (buf, t->data, mutt_strlen (t->data)))
-         {
-           dprint(2, (debugfile, "Reorder: %s matches %s\n", t->data, buf));
-           break;
-         }
-       }
+      if (flags & CH_REORDER) {
+        for (t = HeaderOrderList, x = 0; (t); t = t->next, x++) {
+          if (!ascii_strncasecmp (buf, t->data, mutt_strlen (t->data))) {
+            dprint (2, (debugfile, "Reorder: %s matches %s\n", t->data, buf));
+            break;
+          }
+        }
       }
-      
+
       ignore = 0;
-    } /* If beginning of header */
+    }                           /* If beginning of header */
 
-    if (!ignore)
-    {
-      dprint (2, (debugfile, "Reorder: x = %d; hdr_count = %d\n", x, hdr_count));
+    if (!ignore) {
+      dprint (2,
+              (debugfile, "Reorder: x = %d; hdr_count = %d\n", x, hdr_count));
       if (!this_one)
-       this_one = safe_strdup (buf);
-      else
-      {
-       safe_realloc (&this_one,
-                     mutt_strlen (this_one) + mutt_strlen (buf) + sizeof (char));
-       strcat (this_one, buf); /* __STRCAT_CHECKED__ */
+        this_one = safe_strdup (buf);
+      else {
+        safe_realloc (&this_one,
+                      mutt_strlen (this_one) + mutt_strlen (buf) +
+                      sizeof (char));
+        strcat (this_one, buf); /* __STRCAT_CHECKED__ */
       }
     }
-  } /* while (ftell (in) < off_end) */
+  }                             /* while (ftell (in) < off_end) */
 
   /* Do we have anything pending?  -- XXX, same code as in above in the loop. */
-  if (this_one)
-  {
-    if (flags & CH_DECODE) 
-    {
+  if (this_one) {
+    if (flags & CH_DECODE) {
       if (!address_header_decode (&this_one))
-       rfc2047_decode (&this_one);
+        rfc2047_decode (&this_one);
     }
-    
+
     if (!headers[x])
       headers[x] = this_one;
-    else 
-    {
-      safe_realloc (&headers[x], mutt_strlen (headers[x]) + 
-                   mutt_strlen (this_one) + sizeof (char));
-      strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
+    else {
+      safe_realloc (&headers[x], mutt_strlen (headers[x]) +
+                    mutt_strlen (this_one) + sizeof (char));
+      strcat (headers[x], this_one);    /* __STRCAT_CHECKED__ */
       FREE (&this_one);
     }
-    
+
     this_one = NULL;
   }
 
   /* Now output the headers in order */
-  for (x = 0; x < hdr_count; x++)
-  {
-    if (headers[x])
-    {
+  for (x = 0; x < hdr_count; x++) {
+    if (headers[x]) {
 #if 0
       if (flags & CH_DECODE)
-       rfc2047_decode (&headers[x]);
+        rfc2047_decode (&headers[x]);
 #endif
 
       /* We couldn't do the prefixing when reading because RFC 2047
        * decoding may have concatenated lines.
        */
-      if (flags & CH_PREFIX)
-      {
-       char *ch = headers[x];
-       int print_prefix = 1;
-
-       while (*ch)
-       { 
-         if (print_prefix)
-         {
-           if (fputs (prefix, out) == EOF)
-           {
-             error = TRUE;
-             break;
-           }
-           print_prefix = 0;
-         }
-
-         if (*ch == '\n' && ch[1])
-           print_prefix = 1;
-
-         if (putc (*ch++, out) == EOF)
-         {
-           error = TRUE;
-           break;
-         }
-       }
-       if (error)
-         break;
+      if (flags & CH_PREFIX) {
+        char *ch = headers[x];
+        int print_prefix = 1;
+
+        while (*ch) {
+          if (print_prefix) {
+            if (fputs (prefix, out) == EOF) {
+              error = TRUE;
+              break;
+            }
+            print_prefix = 0;
+          }
+
+          if (*ch == '\n' && ch[1])
+            print_prefix = 1;
+
+          if (putc (*ch++, out) == EOF) {
+            error = TRUE;
+            break;
+          }
+        }
+        if (error)
+          break;
       }
-      else
-      {      
-       if (fputs (headers[x], out) == EOF)
-       {
-         error = TRUE;
-         break;
-       }
+      else {
+        if (fputs (headers[x], out) == EOF) {
+          error = TRUE;
+          break;
+        }
       }
     }
   }
@@ -350,171 +326,158 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
  */
 
 int
-mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
+mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags,
+                  const char *prefix)
 {
   char buffer[SHORT_STRING];
 
   flags |= (h->irt_changed ? CH_UPDATE_IRT : 0)
-         | (h->refs_changed ? CH_UPDATE_REFS : 0);
-  
-  if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
+    | (h->refs_changed ? CH_UPDATE_REFS : 0);
+
+  if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) ==
+      -1)
     return (-1);
 
-  if (flags & CH_TXTPLAIN)
-  {
+  if (flags & CH_TXTPLAIN) {
     char chsbuf[SHORT_STRING];
+
     fputs ("Mime-Version: 1.0\n", out);
     fputs ("Content-Transfer-Encoding: 8bit\n", out);
     fputs ("Content-Type: text/plain; charset=", out);
-    mutt_canonical_charset (chsbuf, sizeof (chsbuf), Charset ? Charset : "us-ascii");
-    rfc822_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials);
-    fputs(buffer, out);
-    fputc('\n', out);
-    
+    mutt_canonical_charset (chsbuf, sizeof (chsbuf),
+                            Charset ? Charset : "us-ascii");
+    rfc822_cat (buffer, sizeof (buffer), chsbuf, MimeSpecials);
+    fputs (buffer, out);
+    fputc ('\n', out);
+
     if (ferror (out) != 0 || feof (out) != 0)
       return -1;
-    
+
   }
 
-  if (flags & CH_UPDATE)
-  {
-    if ((flags & CH_NOSTATUS) == 0)
-    {
-      if (h->irt_changed && h->new_env->in_reply_to)
-      {
-       LIST *listp = h->new_env->in_reply_to;
+  if (flags & CH_UPDATE) {
+    if ((flags & CH_NOSTATUS) == 0) {
+      if (h->irt_changed && h->new_env->in_reply_to) {
+        LIST *listp = h->new_env->in_reply_to;
 
-       if (fputs ("In-Reply-To: ", out) == EOF)
-         return (-1);
+        if (fputs ("In-Reply-To: ", out) == EOF)
+          return (-1);
 
-       for (; listp; listp = listp->next)
-         if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
-           return (-1);
+        for (; listp; listp = listp->next)
+          if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
+            return (-1);
 
-       if (fputc ('\n', out) == EOF)
-         return (-1);
+        if (fputc ('\n', out) == EOF)
+          return (-1);
       }
 
-      if (h->refs_changed && h->new_env->references)
-      {
-       LIST *listp = h->new_env->references, *refs = NULL, *t;
-
-       if (fputs ("References: ", out) == EOF)
-         return (-1);
-
-       /* Mutt stores references in reverse order, thus we create
-        * a reordered refs list that we can put in the headers */
-       for (; listp; listp = listp->next, refs = t)
-       {
-         t = (LIST *)safe_malloc (sizeof (LIST));
-         t->data = listp->data;
-         t->next = refs;
-       }
-
-       for (; refs; refs = refs->next)
-         if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
-           return (-1);
-
-       /* clearing refs from memory */
-       for (t = refs; refs; refs = t->next, t = refs)
-         FREE(&refs);
-
-       if (fputc ('\n', out) == EOF)
-         return (-1);
+      if (h->refs_changed && h->new_env->references) {
+        LIST *listp = h->new_env->references, *refs = NULL, *t;
+
+        if (fputs ("References: ", out) == EOF)
+          return (-1);
+
+        /* Mutt stores references in reverse order, thus we create
+         * a reordered refs list that we can put in the headers */
+        for (; listp; listp = listp->next, refs = t) {
+          t = (LIST *) safe_malloc (sizeof (LIST));
+          t->data = listp->data;
+          t->next = refs;
+        }
+
+        for (; refs; refs = refs->next)
+          if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
+            return (-1);
+
+        /* clearing refs from memory */
+        for (t = refs; refs; refs = t->next, t = refs)
+          FREE (&refs);
+
+        if (fputc ('\n', out) == EOF)
+          return (-1);
       }
 
-      if (h->old || h->read)
-      {
-       if (fputs ("Status: ", out) == EOF)
-         return (-1);
-
-       if (h->read)
-       {
-         if (fputs ("RO", out) == EOF)
-           return (-1);
-       }
-       else if (h->old)
-       {
-         if (fputc ('O', out) == EOF)
-           return (-1);
-       }
-
-       if (fputc ('\n', out) == EOF)
-         return (-1);
+      if (h->old || h->read) {
+        if (fputs ("Status: ", out) == EOF)
+          return (-1);
+
+        if (h->read) {
+          if (fputs ("RO", out) == EOF)
+            return (-1);
+        }
+        else if (h->old) {
+          if (fputc ('O', out) == EOF)
+            return (-1);
+        }
+
+        if (fputc ('\n', out) == EOF)
+          return (-1);
       }
 
-      if (h->flagged || h->replied)
-      {
-       if (fputs ("X-Status: ", out) == EOF)
-         return (-1);
-
-       if (h->replied)
-       {
-         if (fputc ('A', out) == EOF)
-           return (-1);
-       }
-
-       if (h->flagged)
-       {
-         if (fputc ('F', out) == EOF)
-           return (-1);
-       }
-       
-       if (fputc ('\n', out) == EOF)
-         return (-1);
+      if (h->flagged || h->replied) {
+        if (fputs ("X-Status: ", out) == EOF)
+          return (-1);
+
+        if (h->replied) {
+          if (fputc ('A', out) == EOF)
+            return (-1);
+        }
+
+        if (h->flagged) {
+          if (fputc ('F', out) == EOF)
+            return (-1);
+        }
+
+        if (fputc ('\n', out) == EOF)
+          return (-1);
       }
     }
   }
 
-  if (flags & CH_UPDATE_LEN &&
-      (flags & CH_NOLEN) == 0)
-  {
+  if (flags & CH_UPDATE_LEN && (flags & CH_NOLEN) == 0) {
     fprintf (out, "Content-Length: %ld\n", h->content->length);
     if (h->lines != 0 || h->content->length == 0)
       fprintf (out, "Lines: %d\n", h->lines);
   }
 
-  if ((flags & CH_NONEWLINE) == 0)
-  {
+  if ((flags & CH_NONEWLINE) == 0) {
     if (flags & CH_PREFIX)
-      fputs(prefix, out);
-    if (fputc ('\n', out) == EOF) /* add header terminator */
+      fputs (prefix, out);
+    if (fputc ('\n', out) == EOF)       /* add header terminator */
       return (-1);
   }
 
   if (ferror (out) || feof (out))
     return -1;
-  
+
   return (0);
 }
 
 /* Count the number of lines and bytes to be deleted in this body*/
-static int count_delete_lines (FILE *fp, BODY *b, long *length, size_t datelen)
+static int count_delete_lines (FILE * fp, BODY * b, long *length,
+                               size_t datelen)
 {
   int dellines = 0;
   long l;
   int ch;
 
-  if (b->deleted)
-  {
+  if (b->deleted) {
     fseek (fp, b->offset, SEEK_SET);
-    for (l = b->length ; l ; l --)
-    {
+    for (l = b->length; l; l--) {
       ch = getc (fp);
       if (ch == EOF)
-       break;
+        break;
       if (ch == '\n')
-       dellines ++;
+        dellines++;
     }
     dellines -= 3;
     *length -= b->length - (84 + datelen);
     /* Count the number of digits exceeding the first one to write the size */
-    for (l = 10 ; b->length >= l ; l *= 10)
-      (*length) ++;
+    for (l = 10; b->length >= l; l *= 10)
+      (*length)++;
   }
-  else
-  {
-    for (b = b->parts ; b ; b = b->next)
+  else {
+    for (b = b->parts; b; b = b->next)
       dellines += count_delete_lines (fp, b, length, datelen);
   }
   return dellines;
@@ -539,28 +502,26 @@ static int count_delete_lines (FILE *fp, BODY *b, long *length, size_t datelen)
  */
 
 int
-_mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
-                   int flags, int chflags)
+_mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
+                    int flags, int chflags)
 {
   char prefix[SHORT_STRING];
   STATE s;
   long new_offset = -1;
 
-  if (flags & M_CM_PREFIX)
-  {
+  if (flags & M_CM_PREFIX) {
     if (option (OPTTEXTFLOWED))
       strfcpy (prefix, ">", sizeof (prefix));
     else
-      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, hdr, 0);
+      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context,
+                         hdr, 0);
   }
 
-  if ((flags & M_CM_NOHEADER) == 0)
-  {
+  if ((flags & M_CM_NOHEADER) == 0) {
     if (flags & M_CM_PREFIX)
       chflags |= CH_PREFIX;
 
-    else if (hdr->attach_del && (chflags & CH_UPDATE_LEN))
-    {
+    else if (hdr->attach_del && (chflags & CH_UPDATE_LEN)) {
       int new_lines;
       long new_length = body->length;
       char date[SHORT_STRING];
@@ -571,71 +532,68 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
       /* Count the number of lines and bytes to be deleted */
       fseek (fpin, body->offset, SEEK_SET);
       new_lines = hdr->lines -
-       count_delete_lines (fpin, body, &new_length, mutt_strlen (date));
+        count_delete_lines (fpin, body, &new_length, mutt_strlen (date));
 
       /* Copy the headers */
       if (mutt_copy_header (fpin, hdr, fpout,
-                           chflags | CH_NOLEN | CH_NONEWLINE, NULL))
-       return -1;
+                            chflags | CH_NOLEN | CH_NONEWLINE, NULL))
+        return -1;
       fprintf (fpout, "Content-Length: %ld\n", new_length);
       if (new_lines <= 0)
-       new_lines = 0;
+        new_lines = 0;
       else
-       fprintf (fpout, "Lines: %d\n\n", new_lines);
+        fprintf (fpout, "Lines: %d\n\n", new_lines);
       if (ferror (fpout) || feof (fpout))
-       return -1;
+        return -1;
       new_offset = ftell (fpout);
 
       /* Copy the body */
       fseek (fpin, body->offset, SEEK_SET);
       if (copy_delete_attach (body, fpin, fpout, date))
-       return -1;
+        return -1;
 
 #ifdef DEBUG
       {
-       long fail = ((ftell (fpout) - new_offset) - new_length);
-
-       if (fail)
-       {
-         mutt_error ("The length calculation was wrong by %ld bytes", fail);
-         new_length += fail;
-         mutt_sleep (1);
-       }
+        long fail = ((ftell (fpout) - new_offset) - new_length);
+
+        if (fail) {
+          mutt_error ("The length calculation was wrong by %ld bytes", fail);
+          new_length += fail;
+          mutt_sleep (1);
+        }
       }
 #endif
 
-      /* Update original message if we are sync'ing a mailfolder */ 
-      if (flags & M_CM_UPDATE)
-      {
-       hdr->attach_del = 0;
-       hdr->lines = new_lines;
-       body->offset = new_offset;
-
-       /* update the total size of the mailbox to reflect this deletion */
-       Context->size -= body->length - new_length;
-       /*
-        * if the message is visible, update the visible size of the mailbox
-        * as well.
-        */
-       if (Context->v2r[hdr->msgno] != -1)
-         Context->vsize -= body->length - new_length;
-
-       body->length = new_length;
-       mutt_free_body (&body->parts);
+      /* Update original message if we are sync'ing a mailfolder */
+      if (flags & M_CM_UPDATE) {
+        hdr->attach_del = 0;
+        hdr->lines = new_lines;
+        body->offset = new_offset;
+
+        /* update the total size of the mailbox to reflect this deletion */
+        Context->size -= body->length - new_length;
+        /*
+         * if the message is visible, update the visible size of the mailbox
+         * as well.
+         */
+        if (Context->v2r[hdr->msgno] != -1)
+          Context->vsize -= body->length - new_length;
+
+        body->length = new_length;
+        mutt_free_body (&body->parts);
       }
 
       return 0;
     }
 
     if (mutt_copy_header (fpin, hdr, fpout, chflags,
-                         (chflags & CH_PREFIX) ? prefix : NULL) == -1)
+                          (chflags & CH_PREFIX) ? prefix : NULL) == -1)
       return -1;
 
     new_offset = ftell (fpout);
   }
 
-  if (flags & M_CM_DECODE)
-  {
+  if (flags & M_CM_DECODE) {
     /* now make a text/plain version of the message */
     memset (&s, 0, sizeof (STATE));
     s.fpin = fpin;
@@ -652,41 +610,37 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
       s.flags |= M_CHARCONV;
     if (flags & M_CM_REPLYING)
       s.flags |= M_REPLYING;
-    
+
     if (WithCrypto && flags & M_CM_VERIFY)
       s.flags |= M_VERIFY;
 
     mutt_body_handler (body, &s);
   }
   else if (WithCrypto
-           && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
-  {
+           && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT)) {
     BODY *cur;
     FILE *fp;
 
     if ((WithCrypto & APPLICATION_PGP)
         && (flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) &&
-       hdr->content->type == TYPEMULTIPART)
-    {
+        hdr->content->type == TYPEMULTIPART) {
       if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
-       return (-1);
+        return (-1);
       fputs ("Mime-Version: 1.0\n", fpout);
     }
 
     if ((WithCrypto & APPLICATION_SMIME)
         && (flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME)
-            && hdr->content->type == TYPEAPPLICATION)
-    {
+        && hdr->content->type == TYPEAPPLICATION) {
       if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
-       return (-1);
+        return (-1);
     }
 
     mutt_write_mime_header (cur, fpout);
     fputc ('\n', fpout);
 
     fseek (fp, cur->offset, 0);
-    if (mutt_copy_bytes (fp, fpout, cur->length) == -1)
-    {
+    if (mutt_copy_bytes (fp, fpout, cur->length) == -1) {
       fclose (fp);
       mutt_free_body (&cur);
       return (-1);
@@ -694,32 +648,27 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
     mutt_free_body (&cur);
     fclose (fp);
   }
-  else
-  {
+  else {
     fseek (fpin, body->offset, 0);
-    if (flags & M_CM_PREFIX)
-    {
+    if (flags & M_CM_PREFIX) {
       int c;
       size_t bytes = body->length;
-      
-      fputs(prefix, fpout);
-      
-      while((c = fgetc(fpin)) != EOF && bytes--)
-      {
-       fputc(c, fpout);
-       if(c == '\n')
-       {
-         fputs(prefix, fpout);
-       }
-      } 
+
+      fputs (prefix, fpout);
+
+      while ((c = fgetc (fpin)) != EOF && bytes--) {
+        fputc (c, fpout);
+        if (c == '\n') {
+          fputs (prefix, fpout);
+        }
+      }
     }
     else if (mutt_copy_bytes (fpin, fpout, body->length) == -1)
       return -1;
   }
 
-  if ((flags & M_CM_UPDATE) && (flags & M_CM_NOHEADER) == 0 
-      && new_offset != -1)
-  {
+  if ((flags & M_CM_UPDATE) && (flags & M_CM_NOHEADER) == 0
+      && new_offset != -1) {
     body->offset = new_offset;
     mutt_free_body (&body->parts);
   }
@@ -728,17 +677,18 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
 }
 
 int
-mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags,
-                  int chflags)
+mutt_copy_message (FILE * fpout, CONTEXT * src, HEADER * hdr, int flags,
+                   int chflags)
 {
   MESSAGE *msg;
   int r;
-  
+
   if ((msg = mx_open_message (src, hdr->msgno)) == NULL)
     return -1;
-  if ((r = _mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0 
-      && (ferror (fpout) || feof (fpout)))
-  {
+  if ((r =
+       _mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags,
+                           chflags)) == 0 && (ferror (fpout)
+                                              || feof (fpout))) {
     dprint (1, (debugfile, "_mutt_copy_message failed to detect EOF!\n"));
     r = -1;
   }
@@ -758,13 +708,17 @@ mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags,
  */
 
 int
-_mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
-                     BODY *body, int flags, int chflags)
+_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src,
+                      HEADER * hdr, BODY * body, int flags, int chflags)
 {
   MESSAGE *msg;
   int r;
 
-  if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX || src->magic == M_MMDF) ? 0 : M_ADD_FROM)) == NULL)
+  if ((msg =
+       mx_open_new_message (dest, hdr,
+                            (src->magic == M_MBOX
+                             || src->magic == M_MMDF) ? 0 : M_ADD_FROM)) ==
+      NULL)
     return -1;
   if (dest->magic == M_MBOX || dest->magic == M_MMDF)
     chflags |= CH_FROM | CH_FORCE_FROM;
@@ -778,15 +732,17 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
 }
 
 int
-mutt_append_message (CONTEXT *dest, CONTEXT *src, HEADER *hdr, int cmflags,
-                    int chflags)
+mutt_append_message (CONTEXT * dest, CONTEXT * src, HEADER * hdr, int cmflags,
+                     int chflags)
 {
   MESSAGE *msg;
   int r;
 
   if ((msg = mx_open_message (src, hdr->msgno)) == NULL)
     return -1;
-  r = _mutt_append_message (dest, msg->fp, src, hdr, hdr->content, cmflags, chflags);
+  r =
+    _mutt_append_message (dest, msg->fp, src, hdr, hdr->content, cmflags,
+                          chflags);
   mx_close_message (&msg);
   return r;
 }
@@ -798,38 +754,35 @@ mutt_append_message (CONTEXT *dest, CONTEXT *src, HEADER *hdr, int cmflags,
  *
  * The function will return 0 on success and -1 on failure.
  */
-static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date)
+static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
+                               char *date)
 {
   BODY *part;
 
-  for (part = b->parts ; part ; part = part->next)
-  {
-    if (part->deleted || part->parts)
-    {
+  for (part = b->parts; part; part = part->next) {
+    if (part->deleted || part->parts) {
       /* Copy till start of this part */
       if (mutt_copy_bytes (fpin, fpout, part->hdr_offset - ftell (fpin)))
-       return -1;
-
-      if (part->deleted)
-      {
-       fprintf (fpout,
-                "Content-Type: message/external-body; access-type=x-mutt-deleted;\n"
-                "\texpiration=%s; length=%ld\n"
-                "\n", date + 5, part->length);
-       if (ferror (fpout))
-         return -1;
-
-       /* Copy the original mime headers */
-       if (mutt_copy_bytes (fpin, fpout, part->offset - ftell (fpin)))
-         return -1;
-
-       /* Skip the deleted body */
-       fseek (fpin, part->offset + part->length, SEEK_SET);
+        return -1;
+
+      if (part->deleted) {
+        fprintf (fpout,
+                 "Content-Type: message/external-body; access-type=x-mutt-deleted;\n"
+                 "\texpiration=%s; length=%ld\n"
+                 "\n", date + 5, part->length);
+        if (ferror (fpout))
+          return -1;
+
+        /* Copy the original mime headers */
+        if (mutt_copy_bytes (fpin, fpout, part->offset - ftell (fpin)))
+          return -1;
+
+        /* Skip the deleted body */
+        fseek (fpin, part->offset + part->length, SEEK_SET);
       }
-      else
-      {
-       if (copy_delete_attach (part, fpin, fpout, date))
-         return -1;
+      else {
+        if (copy_delete_attach (part, fpin, fpout, date))
+          return -1;
       }
     }
   }
@@ -850,57 +803,54 @@ static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date)
  * XXX - fix that. 
  */
 
-static void format_address_header (char **h, ADDRESS *a)
+static void format_address_header (char **h, ADDRESS * a)
 {
   char buf[HUGE_STRING];
   char cbuf[STRING];
   char c2buf[STRING];
-  
+
   int l, linelen, buflen, count;
+
   linelen = mutt_strlen (*h);
-  buflen  = linelen + 3;
-  
-  
+  buflen = linelen + 3;
+
+
   safe_realloc (h, buflen);
-  for (count = 0; a; a = a->next, count++)
-  {
+  for (count = 0; a; a = a->next, count++) {
     ADDRESS *tmp = a->next;
+
     a->next = NULL;
     *buf = *cbuf = *c2buf = '\0';
     rfc822_write_address (buf, sizeof (buf), a, 0);
     a->next = tmp;
-    
+
     l = mutt_strlen (buf);
-    if (count && linelen + l > 74) 
-    {
-      strcpy (cbuf, "\n\t");   /* __STRCPY_CHECKED__ */
+    if (count && linelen + l > 74) {
+      strcpy (cbuf, "\n\t");    /* __STRCPY_CHECKED__ */
       linelen = l + 8;
     }
-    else
-    {
-      if (a->mailbox)
-      {
-       strcpy (cbuf, " ");     /* __STRCPY_CHECKED__ */
-       linelen++;
+    else {
+      if (a->mailbox) {
+        strcpy (cbuf, " ");     /* __STRCPY_CHECKED__ */
+        linelen++;
       }
       linelen += l;
     }
-    if (!a->group && a->next && a->next->mailbox)
-    {
+    if (!a->group && a->next && a->next->mailbox) {
       linelen++;
       buflen++;
-      strcpy (c2buf, ",");     /* __STRCPY_CHECKED__ */
+      strcpy (c2buf, ",");      /* __STRCPY_CHECKED__ */
     }
-    
+
     buflen += l + mutt_strlen (cbuf) + mutt_strlen (c2buf);
     safe_realloc (h, buflen);
-    strcat (*h, cbuf);         /* __STRCAT_CHECKED__ */
-    strcat (*h, buf);          /* __STRCAT_CHECKED__ */
-    strcat (*h, c2buf);                /* __STRCAT_CHECKED__ */
+    strcat (*h, cbuf);          /* __STRCAT_CHECKED__ */
+    strcat (*h, buf);           /* __STRCAT_CHECKED__ */
+    strcat (*h, c2buf);         /* __STRCAT_CHECKED__ */
   }
-  
+
   /* Space for this was allocated in the beginning of this function. */
-  strcat (*h, "\n");           /* __STRCAT_CHECKED__ */
+  strcat (*h, "\n");            /* __STRCAT_CHECKED__ */
 }
 
 static int address_header_decode (char **h)
@@ -910,82 +860,80 @@ static int address_header_decode (char **h)
 
   ADDRESS *a = NULL;
 
-  switch (tolower ((unsigned char) *s))
-  {
-    case 'r': 
+  switch (tolower ((unsigned char) *s)) {
+  case 'r':
     {
-      if (ascii_strncasecmp (s, "return-path:", 12) == 0)
-      {
-       l = 12;
-       break;
+      if (ascii_strncasecmp (s, "return-path:", 12) == 0) {
+        l = 12;
+        break;
       }
-      else if (ascii_strncasecmp (s, "reply-to:", 9) == 0)
-      {
-       l = 9;
-       break;
+      else if (ascii_strncasecmp (s, "reply-to:", 9) == 0) {
+        l = 9;
+        break;
       }
       return 0;
     }
-    case 'f': 
+  case 'f':
     {
-      if (ascii_strncasecmp (s, "from:", 5)) 
-       return 0; 
+      if (ascii_strncasecmp (s, "from:", 5))
+        return 0;
       l = 5;
       break;
     }
-    case 'c':
+  case 'c':
     {
       if (ascii_strncasecmp (s, "cc:", 3))
-       return 0;
+        return 0;
       l = 3;
       break;
-      
+
     }
-    case 'b':
+  case 'b':
     {
       if (ascii_strncasecmp (s, "bcc:", 4))
-       return 0;
+        return 0;
       l = 4;
       break;
     }
-    case 's':
+  case 's':
     {
       if (ascii_strncasecmp (s, "sender:", 7))
-       return 0;
+        return 0;
       l = 7;
       break;
     }
-    case 't':
+  case 't':
     {
       if (ascii_strncasecmp (s, "to:", 3))
-       return 0;
+        return 0;
       l = 3;
       break;
     }
-    case 'm':
+  case 'm':
     {
       if (ascii_strncasecmp (s, "mail-followup-to:", 17))
-       return 0;
+        return 0;
       l = 17;
       break;
     }
-    default: return 0;    
+  default:
+    return 0;
   }
 
   if ((a = rfc822_parse_adrlist (a, s + l)) == NULL)
     return 0;
-  
+
   mutt_addrlist_to_local (a);
   rfc2047_decode_adrlist (a);
-  
+
   *h = safe_calloc (1, l + 2);
-  
+
   strfcpy (*h, s, l + 1);
-  
+
   format_address_header (h, a);
 
   rfc822_free_address (&a);
-  
+
   FREE (&s);
   return 1;
 }
diff --git a/copy.h b/copy.h
index f0a9b86..8963117 100644 (file)
--- a/copy.h
+++ b/copy.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* flags to _mutt_copy_message */
-#define M_CM_NOHEADER  1       /* don't copy the message header */
-#define M_CM_PREFIX    (1<<1)  /* quote the message */
-#define M_CM_DECODE    (1<<2)  /* decode the message body into text/plain */
-#define M_CM_DISPLAY   (1<<3)  /* output is displayed to the user */
+#define M_CM_NOHEADER  1       /* don't copy the message header */
+#define M_CM_PREFIX    (1<<1)  /* quote the message */
+#define M_CM_DECODE    (1<<2)  /* decode the message body into text/plain */
+#define M_CM_DISPLAY   (1<<3)  /* output is displayed to the user */
 #define M_CM_UPDATE    (1<<4)  /* update structs on sync */
 #define M_CM_WEED      (1<<5)  /* weed message/rfc822 attachment headers */
 #define M_CM_CHARCONV  (1<<6)  /* perform character set conversions */
-#define M_CM_PRINTING  (1<<7)  /* printing the message - display light */
-#define M_CM_REPLYING  (1<<8)  /* replying the message */
+#define M_CM_PRINTING  (1<<7)  /* printing the message - display light */
+#define M_CM_REPLYING  (1<<8)  /* replying the message */
 
 
-#define M_CM_DECODE_PGP          (1<<9) /* used for decoding PGP messages */
-#define M_CM_DECODE_SMIME (1<<10) /* used for decoding S/MIME messages */
+#define M_CM_DECODE_PGP          (1<<9)        /* used for decoding PGP messages */
+#define M_CM_DECODE_SMIME (1<<10)       /* used for decoding S/MIME messages */
 #define M_CM_DECODE_CRYPT  (M_CM_DECODE_PGP | M_CM_DECODE_SMIME)
 
 
-#define M_CM_VERIFY    (1<<11) /* do signature verification */
+#define M_CM_VERIFY    (1<<11) /* do signature verification */
 
 
 
@@ -41,29 +41,18 @@ int mutt_copy_hdr (FILE *, FILE *, long, long, int, const char *);
 
 int mutt_copy_header (FILE *, HEADER *, FILE *, int, const char *);
 
-int _mutt_copy_message (FILE *fpout,
-                       FILE *fpin,
-                       HEADER *hdr,
-                       BODY *body,
-                       int flags,
-                       int chflags);
+int _mutt_copy_message (FILE * fpout,
+                        FILE * fpin,
+                        HEADER * hdr, BODY * body, int flags, int chflags);
 
-int mutt_copy_message (FILE *fpout,
-                      CONTEXT *src,
-                      HEADER *hdr,
-                      int flags,
-                      int chflags);
+int mutt_copy_message (FILE * fpout,
+                       CONTEXT * src, HEADER * hdr, int flags, int chflags);
 
-int _mutt_append_message (CONTEXT *dest,
-                         FILE *fpin,
-                         CONTEXT *src,
-                         HEADER *hdr,
-                         BODY *body,
-                         int flags,
-                         int chflags);
+int _mutt_append_message (CONTEXT * dest,
+                          FILE * fpin,
+                          CONTEXT * src,
+                          HEADER * hdr, BODY * body, int flags, int chflags);
 
-int mutt_append_message (CONTEXT *dest,
-                        CONTEXT *src,
-                        HEADER *hdr,
-                        int cmflags,
-                        int chflags);
+int mutt_append_message (CONTEXT * dest,
+                         CONTEXT * src,
+                         HEADER * hdr, int cmflags, int chflags);
index 8843195..4b201e2 100644 (file)
  * Type definitions.
  */
 
-struct crypt_cache
-{
+struct crypt_cache {
   char *what;
   char *dflt;
   struct crypt_cache *next;
 };
 
-struct dn_array_s
-{
+struct dn_array_s {
   char *key;
   char *value;
 };
 
 /* We work based on user IDs, getting from a user ID to the key is
    check and does not need any memory (gpgme uses reference counting). */
-typedef struct crypt_keyinfo
-{
+typedef struct crypt_keyinfo {
   struct crypt_keyinfo *next;
   gpgme_key_t kobj;
-  int idx;             /* and the user ID at this index */
-  const char *uid;     /* and for convenience point to this user ID */
-  unsigned int flags;  /* global and per uid flags (for convenience)*/
+  int idx;                      /* and the user ID at this index */
+  const char *uid;              /* and for convenience point to this user ID */
+  unsigned int flags;           /* global and per uid flags (for convenience) */
 } crypt_key_t;
 
-typedef struct crypt_entry
-{
+typedef struct crypt_entry {
   size_t num;
   crypt_key_t *key;
 } crypt_entry_t;
@@ -121,23 +117,21 @@ static gpgme_key_t signature_key = NULL;
  */
 
 /* return true when S pints to a didgit or letter. */
-static int
-digit_or_letter (const unsigned char *s)
+static int digit_or_letter (const unsigned char *s)
 {
-  return ( (*s >= '0' && *s < '9')
-           || (*s >= 'A' && *s <= 'Z')
-           || (*s >= 'a' && *s <= 'z'));
+  return ((*s >= '0' && *s < '9')
+          || (*s >= 'A' && *s <= 'Z')
+          || (*s >= 'a' && *s <= 'z'));
 }
 
 
 /* Print the utf-8 encoded string BUF of length LEN bytes to stream
    FP. Convert the character set. */
-static void
-print_utf8 (FILE *fp, const char *buf, size_t len)
+static void print_utf8 (FILE * fp, const char *buf, size_t len)
 {
   char *tstr;
 
-  tstr = safe_malloc (len+1);
+  tstr = safe_malloc (len + 1);
   memcpy (tstr, buf, len);
   tstr[len] = 0;
   mutt_convert_string (&tstr, "utf-8", Charset, M_ICONV_HOOK_FROM);
@@ -152,23 +146,22 @@ print_utf8 (FILE *fp, const char *buf, size_t len)
 
 /* Return the keyID for the key K.  Note that this string is valid as
    long as K is valid */
-static const char *crypt_keyid (crypt_key_t *k)
+static const char *crypt_keyid (crypt_key_t * k)
 {
   const char *s = "????????";
 
-  if (k->kobj && k->kobj->subkeys)
-    {
-      s = k->kobj->subkeys->keyid;
-      if ((! option (OPTPGPLONGIDS)) && (strlen (s) == 16))
-       /* Return only the short keyID.  */
-       s += 8;
-    }
+  if (k->kobj && k->kobj->subkeys) {
+    s = k->kobj->subkeys->keyid;
+    if ((!option (OPTPGPLONGIDS)) && (strlen (s) == 16))
+      /* Return only the short keyID.  */
+      s += 8;
+  }
 
   return s;
 }
 
 /* Return the hexstring fingerprint from the key K. */
-static const char *crypt_fpr (crypt_key_t *k)
+static const char *crypt_fpr (crypt_key_t * k)
 {
   const char *s = "";
 
@@ -213,12 +206,12 @@ static char crypt_flags (int flags)
     return 'd';
   else if (flags & KEYFLAG_CRITICAL)
     return 'c';
-  else 
+  else
     return ' ';
 }
 
 /* Return a copy of KEY. */
-static crypt_key_t *crypt_copy_key (crypt_key_t *key)
+static crypt_key_t *crypt_copy_key (crypt_key_t * key)
 {
   crypt_key_t *k;
 
@@ -234,18 +227,18 @@ static crypt_key_t *crypt_copy_key (crypt_key_t *key)
 
 /* Release all the keys at the address of KEYLIST and set the address
    to NULL. */
-static void crypt_free_key (crypt_key_t **keylist)
+static void crypt_free_key (crypt_key_t ** keylist)
 {
-  while (*keylist)
-    {
-      crypt_key_t *k = (*keylist)->next;
-      FREE (&k);
-      *keylist = k;
-    }
+  while (*keylist) {
+    crypt_key_t *k = (*keylist)->next;
+
+    FREE (&k);
+    *keylist = k;
+  }
 }
 
 /* Return trute when key K is valid. */
-static int crypt_key_is_valid (crypt_key_t *k)
+static int crypt_key_is_valid (crypt_key_t * k)
 {
   if (k->flags & KEYFLAG_CANTUSE)
     return 0;
@@ -253,7 +246,7 @@ static int crypt_key_is_valid (crypt_key_t *k)
 }
 
 /* Return true whe validity of KEY is sufficient. */
-static int crypt_id_is_strong (crypt_key_t *key)
+static int crypt_id_is_strong (crypt_key_t * key)
 {
   gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
   gpgme_user_id_t uid = NULL;
@@ -264,56 +257,54 @@ static int crypt_id_is_strong (crypt_key_t *key)
     return 1;
 
   for (i = 0, uid = key->kobj->uids; (i < key->idx) && uid;
-       i++, uid = uid->next)
-    ;
+       i++, uid = uid->next);
   if (uid)
     val = uid->validity;
 
-  switch (val)
-    {
-    case GPGME_VALIDITY_UNKNOWN:
-    case GPGME_VALIDITY_UNDEFINED:
-    case GPGME_VALIDITY_NEVER:
-    case GPGME_VALIDITY_MARGINAL:
-      is_strong = 0;
-      break;
+  switch (val) {
+  case GPGME_VALIDITY_UNKNOWN:
+  case GPGME_VALIDITY_UNDEFINED:
+  case GPGME_VALIDITY_NEVER:
+  case GPGME_VALIDITY_MARGINAL:
+    is_strong = 0;
+    break;
 
-    case GPGME_VALIDITY_FULL:
-    case GPGME_VALIDITY_ULTIMATE:
-      is_strong = 1;
-      break;
-    }
+  case GPGME_VALIDITY_FULL:
+  case GPGME_VALIDITY_ULTIMATE:
+    is_strong = 1;
+    break;
+  }
 
   return is_strong;
 }
 
 /* Return true when the KEY is valid, i.e. not marked as unusable. */
-static int crypt_id_is_valid (crypt_key_t *key)
+static int crypt_id_is_valid (crypt_key_t * key)
 {
-  return ! (key->flags & KEYFLAG_CANTUSE);
+  return !(key->flags & KEYFLAG_CANTUSE);
 }
 
 /* Return a bit vector describing how well the addresses ADDR and
    U_ADDR match and whether KEY is valid. */
-static int crypt_id_matches_addr (ADDRESS *addr, ADDRESS *u_addr,
-                                  crypt_key_t *key)
+static int crypt_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr,
+                                  crypt_key_t * key)
 {
   int rv = 0;
-  
+
   if (crypt_id_is_valid (key))
     rv |= CRYPT_KV_VALID;
 
   if (crypt_id_is_strong (key))
     rv |= CRYPT_KV_STRONGID;
-  
+
   if (addr->mailbox && u_addr->mailbox
       && mutt_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
     rv |= CRYPT_KV_ADDR;
-    
+
   if (addr->personal && u_addr->personal
       && mutt_strcasecmp (addr->personal, u_addr->personal) == 0)
     rv |= CRYPT_KV_STRING;
-  
+
   return rv;
 }
 
@@ -330,24 +321,20 @@ static gpgme_ctx_t create_gpgme_context (int for_smime)
   gpgme_ctx_t ctx;
 
   err = gpgme_new (&ctx);
-  if (err)
-    {
-      mutt_error ("error creating gpgme context: %s\n", gpgme_strerror (err));
+  if (err) {
+    mutt_error ("error creating gpgme context: %s\n", gpgme_strerror (err));
+    sleep (2);
+    mutt_exit (1);
+  }
+
+  if (for_smime) {
+    err = gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+    if (err) {
+      mutt_error ("error enabling CMS protocol: %s\n", gpgme_strerror (err));
       sleep (2);
       mutt_exit (1);
     }
-
-  if (for_smime)
-    {
-      err = gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
-      if (err)
-        {
-          mutt_error ("error enabling CMS protocol: %s\n",
-                      gpgme_strerror (err));
-          sleep (2);
-          mutt_exit (1);
-        }
-    }
+  }
 
   return ctx;
 }
@@ -360,77 +347,69 @@ static gpgme_data_t create_gpgme_data (void)
   gpgme_data_t data;
 
   err = gpgme_data_new (&data);
-  if (err) 
-    {
-      mutt_error ("error creating gpgme data object: %s\n",
-                  gpgme_strerror (err));
-      sleep (2);
-      mutt_exit (1);
-    }
+  if (err) {
+    mutt_error ("error creating gpgme data object: %s\n",
+                gpgme_strerror (err));
+    sleep (2);
+    mutt_exit (1);
+  }
   return data;
 }
 
 /* Create a new GPGME Data object from the mail body A.  With CONVERT
    passed as true, the lines are converted to CR,LF if required.
    Return NULL on error or the gpgme_data_t object on success. */
-static gpgme_data_t body_to_data_object (BODY *a, int convert)
+static gpgme_data_t body_to_data_object (BODY * a, int convert)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fptmp;
   int err = 0;
   gpgme_data_t data;
-  
+
   mutt_mktemp (tempfile);
   fptmp = safe_fopen (tempfile, "w+");
-  if (!fptmp)
-    {
-      mutt_perror (tempfile);
-      return NULL;
-    }
+  if (!fptmp) {
+    mutt_perror (tempfile);
+    return NULL;
+  }
 
   mutt_write_mime_header (a, fptmp);
   fputc ('\n', fptmp);
   mutt_write_mime_body (a, fptmp);
 
-  if (convert)
-    {
-      int c, hadcr = 0;
-      unsigned char buf[1];
-
-      data = create_gpgme_data ();
-      rewind (fptmp);
-      while ((c = fgetc (fptmp)) != EOF)
-        {
-          if  (c == '\r')
-            hadcr = 1;
-          else 
-            {
-              if (c == '\n' && !hadcr)
-                {
-                  buf[0] = '\r';
-                  gpgme_data_write (data, buf, 1);
-                }
-                  
-              hadcr = 0;
-            }
-          /* FIXME: This is quite suboptimal */
-          buf[0] = c;
+  if (convert) {
+    int c, hadcr = 0;
+    unsigned char buf[1];
+
+    data = create_gpgme_data ();
+    rewind (fptmp);
+    while ((c = fgetc (fptmp)) != EOF) {
+      if (c == '\r')
+        hadcr = 1;
+      else {
+        if (c == '\n' && !hadcr) {
+          buf[0] = '\r';
           gpgme_data_write (data, buf, 1);
         }
-      fclose(fptmp);
-      gpgme_data_seek (data, 0, SEEK_SET);
-    }
-  else
-    {
-      fclose(fptmp);
-      err = gpgme_data_new_from_file (&data, tempfile, 1);
+
+        hadcr = 0;
+      }
+      /* FIXME: This is quite suboptimal */
+      buf[0] = c;
+      gpgme_data_write (data, buf, 1);
     }
+    fclose (fptmp);
+    gpgme_data_seek (data, 0, SEEK_SET);
+  }
+  else {
+    fclose (fptmp);
+    err = gpgme_data_new_from_file (&data, tempfile, 1);
+  }
   unlink (tempfile);
-  if (err) 
-    {
-      mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
-      return NULL;
-    }
+  if (err) {
+    mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+    return NULL;
+  }
 
   return data;
 }
@@ -438,23 +417,22 @@ static gpgme_data_t body_to_data_object (BODY *a, int convert)
 /* Create a GPGME data object from the stream FP but limit the object
    to LENGTH bytes starting at OFFSET bytes from the beginning of the
    file. */
-static gpgme_data_t file_to_data_object (FILE *fp, long offset, long length)
+static gpgme_data_t file_to_data_object (FILE * fp, long offset, long length)
 {
   int err = 0;
   gpgme_data_t data;
-  
+
   err = gpgme_data_new_from_filepart (&data, NULL, fp, offset, length);
-  if (err) 
-    {
-      mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
-      return NULL;
-    }
+  if (err) {
+    mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+    return NULL;
+  }
 
   return data;
 }
 
 /* Write a GPGME data object to the stream FP. */
-static int data_object_to_stream (gpgme_data_t data, FILE *fp)
+static int data_object_to_stream (gpgme_data_t data, FILE * fp)
 {
   int err;
   char buf[4096], *p;
@@ -462,40 +440,35 @@ static int data_object_to_stream (gpgme_data_t data, FILE *fp)
 
   err = ((gpgme_data_seek (data, 0, SEEK_SET) == -1)
          ? gpgme_error_from_errno (errno) : 0);
-  if (err)
-    {
-      mutt_error ("error rewinding data object: %s\n", gpgme_strerror (err));
-      return -1;
-    }
-
-  while ((nread = gpgme_data_read (data, buf, sizeof (buf))))
-    {
-      /* fixme: we are not really converting CRLF to LF but just
-         skipping CR. Doing it correctly needs a more complex logic */
-      for (p=buf; nread; p++, nread--)
-        {
-          if (*p != '\r')
-            putc (*p, fp);
-        }
+  if (err) {
+    mutt_error ("error rewinding data object: %s\n", gpgme_strerror (err));
+    return -1;
+  }
 
-     if (ferror (fp))
-       {
-         mutt_perror ("[tempfile]");
-         return -1;
-       }
+  while ((nread = gpgme_data_read (data, buf, sizeof (buf)))) {
+    /* fixme: we are not really converting CRLF to LF but just
+       skipping CR. Doing it correctly needs a more complex logic */
+    for (p = buf; nread; p++, nread--) {
+      if (*p != '\r')
+        putc (*p, fp);
     }
-  if (nread == -1)
-    {
-      mutt_error ("error reading data object: %s\n", strerror (errno));
+
+    if (ferror (fp)) {
+      mutt_perror ("[tempfile]");
       return -1;
     }
+  }
+  if (nread == -1) {
+    mutt_error ("error reading data object: %s\n", strerror (errno));
+    return -1;
+  }
   return 0;
 }
 
 /* Copy a data object to a newly created temporay file and return that
    filename. Caller must free.  With RET_FP not NULL, don't close the
    stream but return it there. */
-static char *data_object_to_tempfile (gpgme_data_t data, FILE **ret_fp)
+static char *data_object_to_tempfile (gpgme_data_t data, FILE ** ret_fp)
 {
   int err;
   char tempfile[_POSIX_PATH_MAX];
@@ -504,40 +477,35 @@ static char *data_object_to_tempfile (gpgme_data_t data, FILE **ret_fp)
 
   mutt_mktemp (tempfile);
   fp = safe_fopen (tempfile, "w+");
-  if (!fp)
-    {
-      mutt_perror (tempfile);
-      return NULL;
-    }
+  if (!fp) {
+    mutt_perror (tempfile);
+    return NULL;
+  }
 
   err = ((gpgme_data_seek (data, 0, SEEK_SET) == -1)
          ? gpgme_error_from_errno (errno) : 0);
-  if (!err)
-    {
-      char buf[4096];
-
-      while ((nread = gpgme_data_read (data, buf, sizeof (buf))))
-        {
-          if (fwrite (buf, nread, 1, fp) != 1)
-            {
-              mutt_perror (tempfile);
-              fclose (fp);
-              unlink (tempfile);
-              return NULL;
-            }
-        }
+  if (!err) {
+    char buf[4096];
+
+    while ((nread = gpgme_data_read (data, buf, sizeof (buf)))) {
+      if (fwrite (buf, nread, 1, fp) != 1) {
+        mutt_perror (tempfile);
+        fclose (fp);
+        unlink (tempfile);
+        return NULL;
+      }
     }
+  }
   if (ret_fp)
     rewind (fp);
   else
     fclose (fp);
-  if (nread == -1)
-    {
-      mutt_error ("error reading data object: %s\n", gpgme_strerror (err));
-      unlink (tempfile);
-      fclose (fp);
-      return NULL;
-    }
+  if (nread == -1) {
+    mutt_error ("error reading data object: %s\n", gpgme_strerror (err));
+    unlink (tempfile);
+    fclose (fp);
+    return NULL;
+  }
   if (ret_fp)
     *ret_fp = fp;
   return safe_strdup (tempfile);
@@ -559,54 +527,49 @@ static gpgme_key_t *create_recipient_set (const char *keylist,
   gpgme_ctx_t context = NULL;
 
   err = gpgme_new (&context);
-  if (! err)
+  if (!err)
     err = gpgme_set_protocol (context, protocol);
 
-  if (! err)
-    {
-      s = keylist;
-      do {
-       while (*s == ' ')
-         s++;
-       for (i=0; *s && *s != ' ' && i < sizeof(buf)-1;)
-         buf[i++] = *s++;
-       buf[i] = 0;
-       if (*buf)
-         {
-           if (i>1 && buf[i-1] == '!') 
-             {
-               /* The user selected to override the valididy of that
-                  key. */
-               buf[i-1] = 0;
-           
-               err = gpgme_get_key (context, buf, &key, 0);
-               if (! err)
-                 key->uids->validity = GPGME_VALIDITY_FULL;
-               buf[i-1] = '!';
-             }
-           else
-             err = gpgme_get_key (context, buf, &key, 0);
-
-           if (! err)
-             {
-               safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
-               rset[rset_n++] = key;
-             }
-           else
-             {
-               mutt_error ("error adding recipient `%s': %s\n",
-                           buf, gpgme_strerror (err));
-               FREE (&rset);
-               return NULL;
-             }
-         }
-      } while (*s);
-    }
+  if (!err) {
+    s = keylist;
+    do {
+      while (*s == ' ')
+        s++;
+      for (i = 0; *s && *s != ' ' && i < sizeof (buf) - 1;)
+        buf[i++] = *s++;
+      buf[i] = 0;
+      if (*buf) {
+        if (i > 1 && buf[i - 1] == '!') {
+          /* The user selected to override the valididy of that
+             key. */
+          buf[i - 1] = 0;
+
+          err = gpgme_get_key (context, buf, &key, 0);
+          if (!err)
+            key->uids->validity = GPGME_VALIDITY_FULL;
+          buf[i - 1] = '!';
+        }
+        else
+          err = gpgme_get_key (context, buf, &key, 0);
+
+        if (!err) {
+          safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+          rset[rset_n++] = key;
+        }
+        else {
+          mutt_error ("error adding recipient `%s': %s\n",
+                      buf, gpgme_strerror (err));
+          FREE (&rset);
+          return NULL;
+        }
+      }
+    } while (*s);
+  }
 
   /* NULL terminate.  */
   safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
   rset[rset_n++] = NULL;
-  
+
   if (context)
     gpgme_release (context);
 
@@ -617,7 +580,7 @@ static gpgme_key_t *create_recipient_set (const char *keylist,
 /* Make sure that the correct signer is set. Returns 0 on success. */
 static int set_signer (gpgme_ctx_t ctx, int for_smime)
 {
-  char *signid = for_smime ? SmimeDefaultKey: PgpSignAs;
+  char *signid = for_smime ? SmimeDefaultKey : PgpSignAs;
   gpgme_error_t err;
   gpgme_ctx_t listctx;
   gpgme_key_t key, key2;
@@ -629,35 +592,31 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime)
   err = gpgme_op_keylist_start (listctx, signid, 1);
   if (!err)
     err = gpgme_op_keylist_next (listctx, &key);
-  if (err)
-    {
-      gpgme_release (listctx);
-      mutt_error (_("secret key `%s' not found: %s\n"),
-                  signid, gpgme_strerror (err));
-      return -1;
-    }
+  if (err) {
+    gpgme_release (listctx);
+    mutt_error (_("secret key `%s' not found: %s\n"),
+                signid, gpgme_strerror (err));
+    return -1;
+  }
   err = gpgme_op_keylist_next (listctx, &key2);
-  if (!err)
-    {
-      gpgme_key_release (key);
-      gpgme_key_release (key2);
-      gpgme_release (listctx);
-      mutt_error (_("ambiguous specfication of secret key `%s'\n"),
-                  signid);
-      return -1;
-    }
+  if (!err) {
+    gpgme_key_release (key);
+    gpgme_key_release (key2);
+    gpgme_release (listctx);
+    mutt_error (_("ambiguous specfication of secret key `%s'\n"), signid);
+    return -1;
+  }
   gpgme_op_keylist_end (listctx);
   gpgme_release (listctx);
 
   gpgme_signers_clear (ctx);
   err = gpgme_signers_add (ctx, key);
   gpgme_key_release (key);
-  if (err)
-    {
-      mutt_error (_("error setting secret key `%s': %s\n"),
-                  signid, gpgme_strerror (err));
-      return -1;
-    }
+  if (err) {
+    mutt_error (_("error setting secret key `%s': %s\n"),
+                signid, gpgme_strerror (err));
+    return -1;
+  }
   return 0;
 }
 
@@ -667,7 +626,7 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime)
    enciphered text.  With USE_SMIME set to true, the smime backend is
    used.  With COMBINED_SIGNED a PGP message is signed and
    encrypted.  Returns NULL in case of error */
-static char *encrypt_gpgme_object (gpgme_data_t plaintext, gpgme_key_t *rset,
+static char *encrypt_gpgme_object (gpgme_data_t plaintext, gpgme_key_t * rset,
                                    int use_smime, int combined_signed)
 {
   int err;
@@ -676,33 +635,30 @@ static char *encrypt_gpgme_object (gpgme_data_t plaintext, gpgme_key_t *rset,
   char *outfile;
 
   ctx = create_gpgme_context (use_smime);
-  if (!use_smime) 
-      gpgme_set_armor (ctx, 1);
+  if (!use_smime)
+    gpgme_set_armor (ctx, 1);
 
   ciphertext = create_gpgme_data ();
 
-  if (combined_signed)
-    {
-      if (set_signer (ctx, use_smime))
-        {
-          gpgme_data_release (ciphertext);
-          gpgme_release (ctx);
-          return NULL;
-        }
-      err = gpgme_op_encrypt_sign (ctx, rset, GPGME_ENCRYPT_ALWAYS_TRUST,
-                                   plaintext, ciphertext);
+  if (combined_signed) {
+    if (set_signer (ctx, use_smime)) {
+      gpgme_data_release (ciphertext);
+      gpgme_release (ctx);
+      return NULL;
     }
+    err = gpgme_op_encrypt_sign (ctx, rset, GPGME_ENCRYPT_ALWAYS_TRUST,
+                                 plaintext, ciphertext);
+  }
   else
     err = gpgme_op_encrypt (ctx, rset, GPGME_ENCRYPT_ALWAYS_TRUST,
                             plaintext, ciphertext);
   mutt_need_hard_redraw ();
-  if (err)
-    {
-      mutt_error ("error encrypting data: %s\n", gpgme_strerror (err));
-      gpgme_data_release (ciphertext);
-      gpgme_release (ctx);
-      return NULL;
-    }
+  if (err) {
+    mutt_error ("error encrypting data: %s\n", gpgme_strerror (err));
+    gpgme_data_release (ciphertext);
+    gpgme_release (ctx);
+    return NULL;
+  }
 
   gpgme_release (ctx);
 
@@ -727,20 +683,18 @@ static int get_micalg (gpgme_ctx_t ctx, char *buf, size_t buflen)
 
   *buf = 0;
   result = gpgme_op_sign_result (ctx);
-  if (result)
-    {
-      algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo);
-      if (algorithm_name)
-       {
-         strncpy (buf, algorithm_name, buflen - 1);
-         buf[buflen - 1] = 0;
-       }
+  if (result) {
+    algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo);
+    if (algorithm_name) {
+      strncpy (buf, algorithm_name, buflen - 1);
+      buf[buflen - 1] = 0;
     }
+  }
 
-  return *buf? 0:-1;
+  return *buf ? 0 : -1;
 }
 
-static void print_time(time_t t, STATE *s)
+static void print_time (time_t t, STATE * s)
 {
   char p[STRING];
 
@@ -761,7 +715,7 @@ static void print_time(time_t t, STATE *s)
 /* Sign the MESSAGE in body A either using OpenPGP or S/MIME when
    USE_SMIME is passed as true.  Returns the new body or NULL on
    error. */
-static BODY *sign_message (BODY *a, int use_smime)
+static BODY *sign_message (BODY * a, int use_smime)
 {
   BODY *t;
   char *sigfile;
@@ -770,42 +724,39 @@ static BODY *sign_message (BODY *a, int use_smime)
   gpgme_ctx_t ctx;
   gpgme_data_t message, signature;
 
-  convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
+  convert_to_7bit (a);          /* Signed data _must_ be in 7-bit format. */
 
   message = body_to_data_object (a, 1);
   if (!message)
-     return NULL;
+    return NULL;
   signature = create_gpgme_data ();
 
   ctx = create_gpgme_context (use_smime);
   if (!use_smime)
     gpgme_set_armor (ctx, 1);
 
-  if (set_signer (ctx, use_smime))
-    {
-      gpgme_data_release (signature);
-      gpgme_release (ctx);
-      return NULL;
-    }
+  if (set_signer (ctx, use_smime)) {
+    gpgme_data_release (signature);
+    gpgme_release (ctx);
+    return NULL;
+  }
 
-  err = gpgme_op_sign (ctx, message, signature, GPGME_SIG_MODE_DETACH );
+  err = gpgme_op_sign (ctx, message, signature, GPGME_SIG_MODE_DETACH);
   mutt_need_hard_redraw ();
   gpgme_data_release (message);
-  if (err)
-    {
-      gpgme_data_release (signature);
-      gpgme_release (ctx);
-      mutt_error ("error signing data: %s\n", gpgme_strerror (err));
-      return NULL;
-    }
+  if (err) {
+    gpgme_data_release (signature);
+    gpgme_release (ctx);
+    mutt_error ("error signing data: %s\n", gpgme_strerror (err));
+    return NULL;
+  }
 
   sigfile = data_object_to_tempfile (signature, NULL);
   gpgme_data_release (signature);
-  if (!sigfile)
-    {
-      gpgme_release (ctx);
-      return NULL;
-    }
+  if (!sigfile) {
+    gpgme_release (ctx);
+    return NULL;
+  }
 
   t = mutt_new_body ();
   t->type = TYPEMULTIPART;
@@ -816,9 +767,8 @@ static BODY *sign_message (BODY *a, int use_smime)
 
   mutt_generate_boundary (&t->parameter);
   mutt_set_parameter ("protocol",
-                      use_smime? "application/pkcs7-signature"
-                               : "application/pgp-signature",
-                      &t->parameter);
+                      use_smime ? "application/pkcs7-signature"
+                      : "application/pgp-signature", &t->parameter);
   /* Get the micalg from gpgme.  Old gpgme versions don't support this
      for S/MIME so we assume sha-1 in this case. */
   if (!get_micalg (ctx, buf, sizeof buf))
@@ -833,35 +783,33 @@ static BODY *sign_message (BODY *a, int use_smime)
   t->parts->next = mutt_new_body ();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
-  if (use_smime)
-    {
-      t->subtype = safe_strdup ("pkcs7-signature");
-      mutt_set_parameter ("name", "smime.p7s", &t->parameter);
-      t->encoding = ENCBASE64; 
-      t->use_disp = 1;
-      t->disposition = DISPATTACH;
-      t->d_filename = safe_strdup ("smime.p7s");
-    }
-  else
-    {
-      t->subtype = safe_strdup ("pgp-signature");
-      t->use_disp = 0;
-      t->disposition = DISPINLINE;
-      t->encoding = ENC7BIT;
-    }
+  if (use_smime) {
+    t->subtype = safe_strdup ("pkcs7-signature");
+    mutt_set_parameter ("name", "smime.p7s", &t->parameter);
+    t->encoding = ENCBASE64;
+    t->use_disp = 1;
+    t->disposition = DISPATTACH;
+    t->d_filename = safe_strdup ("smime.p7s");
+  }
+  else {
+    t->subtype = safe_strdup ("pgp-signature");
+    t->use_disp = 0;
+    t->disposition = DISPINLINE;
+    t->encoding = ENC7BIT;
+  }
   t->filename = sigfile;
-  t->unlink = 1; /* ok to remove this file after sending. */
+  t->unlink = 1;                /* ok to remove this file after sending. */
 
   return a;
 }
 
 
-BODY *pgp_gpgme_sign_message (BODY *a)
+BODY *pgp_gpgme_sign_message (BODY * a)
 {
   return sign_message (a, 0);
 }
 
-BODY *smime_gpgme_sign_message (BODY *a)
+BODY *smime_gpgme_sign_message (BODY * a)
 {
   return sign_message (a, 1);
 }
@@ -872,31 +820,30 @@ BODY *smime_gpgme_sign_message (BODY *a)
 
 /* Encrypt the mail body A to all keys given as space separated keyids
    or fingerprints in KEYLIST and return the encrypted body.  */
-BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign)
+BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign)
 {
   char *outfile = NULL;
   BODY *t;
   gpgme_key_t *rset = NULL;
   gpgme_data_t plaintext;
-  
+
   rset = create_recipient_set (keylist, GPGME_PROTOCOL_OpenPGP);
   if (!rset)
     return NULL;
-  
+
   if (sign)
     convert_to_7bit (a);
   plaintext = body_to_data_object (a, 0);
-  if (!plaintext)
-    {
-      FREE (&rset);
-      return NULL;
-    }
-  
+  if (!plaintext) {
+    FREE (&rset);
+    return NULL;
+  }
+
   outfile = encrypt_gpgme_object (plaintext, rset, 0, sign);
   gpgme_data_release (plaintext);
   FREE (&rset);
   if (!outfile)
-      return NULL;
+    return NULL;
 
   t = mutt_new_body ();
   t->type = TYPEMULTIPART;
@@ -905,9 +852,9 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign)
   t->use_disp = 0;
   t->disposition = DISPINLINE;
 
-  mutt_generate_boundary(&t->parameter);
-  mutt_set_parameter("protocol", "application/pgp-encrypted", &t->parameter);
-  
+  mutt_generate_boundary (&t->parameter);
+  mutt_set_parameter ("protocol", "application/pgp-encrypted", &t->parameter);
+
   t->parts = mutt_new_body ();
   t->parts->type = TYPEAPPLICATION;
   t->parts->subtype = safe_strdup ("pgp-encrypted");
@@ -920,7 +867,7 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign)
   t->parts->next->filename = outfile;
   t->parts->next->use_disp = 1;
   t->parts->next->disposition = DISPINLINE;
-  t->parts->next->unlink = 1; /* delete after sending the message */
+  t->parts->next->unlink = 1;   /* delete after sending the message */
   t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime
                                                            can save */
 
@@ -933,7 +880,7 @@ BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign)
 
 /* Encrypt the mail body A to all keys given as space separated
    fingerprints in KEYLIST and return the S/MIME encrypted body.  */
-BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist)
+BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist)
 {
   char *outfile = NULL;
   BODY *t;
@@ -945,32 +892,31 @@ BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist)
     return NULL;
 
   plaintext = body_to_data_object (a, 0);
-  if (!plaintext)
-    {
-      FREE (&rset);
-      return NULL;
-    }
+  if (!plaintext) {
+    FREE (&rset);
+    return NULL;
+  }
 
   outfile = encrypt_gpgme_object (plaintext, rset, 1, 0);
   gpgme_data_release (plaintext);
   FREE (&rset);
-  if (!outfile) 
-      return NULL;
+  if (!outfile)
+    return NULL;
 
   t = mutt_new_body ();
   t->type = TYPEAPPLICATION;
   t->subtype = safe_strdup ("pkcs7-mime");
   mutt_set_parameter ("name", "smime.p7m", &t->parameter);
   mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
-  t->encoding = ENCBASE64;  /* The output of OpenSSL SHOULD be binary */
+  t->encoding = ENCBASE64;      /* The output of OpenSSL SHOULD be binary */
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   t->d_filename = safe_strdup ("smime.p7m");
   t->filename = outfile;
-  t->unlink = 1; /*delete after sending the message */
-  t->parts=0;
-  t->next=0;
-  
+  t->unlink = 1;                /*delete after sending the message */
+  t->parts = 0;
+  t->next = 0;
+
   return t;
 }
 
@@ -983,108 +929,97 @@ BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist)
    Return 1 if there is is a severe warning.
  */
 static int show_sig_summary (unsigned long sum,
-                              gpgme_ctx_t ctx, gpgme_key_t key, int idx,
-                              STATE *s)
+                             gpgme_ctx_t ctx, gpgme_key_t key, int idx,
+                             STATE * s)
 {
   int severe = 0;
 
-  if ((sum & GPGME_SIGSUM_KEY_REVOKED))
-    {
-      state_attach_puts (_("Warning: One of the keys has been revoked\n"),s);
-      severe = 1;
-    }
+  if ((sum & GPGME_SIGSUM_KEY_REVOKED)) {
+    state_attach_puts (_("Warning: One of the keys has been revoked\n"), s);
+    severe = 1;
+  }
 
-  if ((sum & GPGME_SIGSUM_KEY_EXPIRED))
-    {
-      time_t at = key->subkeys->expires ? key->subkeys->expires : 0;
-      if (at)
-        {
-          state_attach_puts (_("Warning: The key used to create the "
-                               "signature expired at: "), s);
-          print_time (at , s);
-          state_attach_puts ("\n", s);
-        }
-      else
-        state_attach_puts (_("Warning: At least one certification key "
-                             "has expired\n"), s);
-    }
+  if ((sum & GPGME_SIGSUM_KEY_EXPIRED)) {
+    time_t at = key->subkeys->expires ? key->subkeys->expires : 0;
 
-  if ((sum & GPGME_SIGSUM_SIG_EXPIRED))
-    {
-      gpgme_verify_result_t result;
-      gpgme_signature_t sig;
-      unsigned int i;
-      
-      result = gpgme_op_verify_result (ctx);
-
-      for (sig = result->signatures, i = 0; sig && (i < idx);
-           sig = sig->next, i++)
-        ;
-      
-      state_attach_puts (_("Warning: The signature expired at: "), s);
-      print_time (sig ? sig->exp_timestamp : 0, s);
+    if (at) {
+      state_attach_puts (_("Warning: The key used to create the "
+                           "signature expired at: "), s);
+      print_time (at, s);
       state_attach_puts ("\n", s);
     }
+    else
+      state_attach_puts (_("Warning: At least one certification key "
+                           "has expired\n"), s);
+  }
+
+  if ((sum & GPGME_SIGSUM_SIG_EXPIRED)) {
+    gpgme_verify_result_t result;
+    gpgme_signature_t sig;
+    unsigned int i;
+
+    result = gpgme_op_verify_result (ctx);
+
+    for (sig = result->signatures, i = 0; sig && (i < idx);
+         sig = sig->next, i++);
+
+    state_attach_puts (_("Warning: The signature expired at: "), s);
+    print_time (sig ? sig->exp_timestamp : 0, s);
+    state_attach_puts ("\n", s);
+  }
 
   if ((sum & GPGME_SIGSUM_KEY_MISSING))
     state_attach_puts (_("Can't verify due to a missing "
                          "key or certificate\n"), s);
 
-  if ((sum & GPGME_SIGSUM_CRL_MISSING))
-    {
-      state_attach_puts (_("The CRL is not available\n"), s);
-      severe = 1;
-    }
+  if ((sum & GPGME_SIGSUM_CRL_MISSING)) {
+    state_attach_puts (_("The CRL is not available\n"), s);
+    severe = 1;
+  }
 
-  if ((sum & GPGME_SIGSUM_CRL_TOO_OLD))
-    {
-      state_attach_puts (_("Available CRL is too old\n"), s);
-      severe = 1;
-    }
+  if ((sum & GPGME_SIGSUM_CRL_TOO_OLD)) {
+    state_attach_puts (_("Available CRL is too old\n"), s);
+    severe = 1;
+  }
 
   if ((sum & GPGME_SIGSUM_BAD_POLICY))
     state_attach_puts (_("A policy requirement was not met\n"), s);
 
-  if ((sum & GPGME_SIGSUM_SYS_ERROR))
-    {
-      const char *t0 = NULL, *t1 = NULL;
-      gpgme_verify_result_t result;
-      gpgme_signature_t sig;
-      unsigned int i;
-
-      state_attach_puts (_("A system error occured"), s );
-
-      /* Try to figure out some more detailed system error information. */
-      result = gpgme_op_verify_result (ctx);
-      for (sig = result->signatures, i = 0; sig && (i < idx);
-           sig = sig->next, i++)
-        ;
-      if (sig)
-       {
-         t0 = "";
-         t1 = sig->wrong_key_usage ? "Wrong_Key_Usage" : "";
-       }
-
-      if (t0 || t1)
-        {
-          state_attach_puts (": ", s);
-          if (t0)
-              state_attach_puts (t0, s);
-          if (t1 && !(t0 && !strcmp (t0, t1)))
-            {
-              if (t0)
-                state_attach_puts (",", s);
-              state_attach_puts (t1, s);
-            }
-        }
-      state_attach_puts ("\n", s);
+  if ((sum & GPGME_SIGSUM_SYS_ERROR)) {
+    const char *t0 = NULL, *t1 = NULL;
+    gpgme_verify_result_t result;
+    gpgme_signature_t sig;
+    unsigned int i;
+
+    state_attach_puts (_("A system error occured"), s);
+
+    /* Try to figure out some more detailed system error information. */
+    result = gpgme_op_verify_result (ctx);
+    for (sig = result->signatures, i = 0; sig && (i < idx);
+         sig = sig->next, i++);
+    if (sig) {
+      t0 = "";
+      t1 = sig->wrong_key_usage ? "Wrong_Key_Usage" : "";
+    }
+
+    if (t0 || t1) {
+      state_attach_puts (": ", s);
+      if (t0)
+        state_attach_puts (t0, s);
+      if (t1 && !(t0 && !strcmp (t0, t1))) {
+        if (t0)
+          state_attach_puts (",", s);
+        state_attach_puts (t1, s);
+      }
     }
+    state_attach_puts ("\n", s);
+  }
 
   return severe;
 }
 
 
-static void show_fingerprint (gpgme_key_t key, STATE *state)
+static void show_fingerprint (gpgme_key_t key, STATE * state)
 {
   const char *s;
   int i, is_pgp;
@@ -1098,33 +1033,29 @@ static void show_fingerprint (gpgme_key_t key, STATE *state)
     return;
   is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
 
-  buf = safe_malloc ( strlen (prefix) + strlen(s) * 4 + 2 );
-  strcpy (buf, prefix); /* __STRCPY_CHECKED__ */
+  buf = safe_malloc (strlen (prefix) + strlen (s) * 4 + 2);
+  strcpy (buf, prefix);         /* __STRCPY_CHECKED__ */
   p = buf + strlen (buf);
-  if (is_pgp && strlen (s) == 40)
-    {  /* PGP v4 style formatted. */
-      for (i=0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
-        {
-          *p++ = s[0];
-          *p++ = s[1];
-          *p++ = s[2];
-          *p++ = s[3];
-          *p++ = ' ';
-          if (i == 4)
-            *p++ = ' ';
-        }
+  if (is_pgp && strlen (s) == 40) {     /* PGP v4 style formatted. */
+    for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
+      *p++ = s[0];
+      *p++ = s[1];
+      *p++ = s[2];
+      *p++ = s[3];
+      *p++ = ' ';
+      if (i == 4)
+        *p++ = ' ';
     }
-  else
-    {
-      for (i=0; *s && s[1] && s[2]; s += 2, i++)
-        {
-          *p++ = s[0];
-          *p++ = s[1];
-          *p++ = is_pgp? ' ':':';
-          if (is_pgp && i == 7)
-            *p++ = ' ';
-        }
+  }
+  else {
+    for (i = 0; *s && s[1] && s[2]; s += 2, i++) {
+      *p++ = s[0];
+      *p++ = s[1];
+      *p++ = is_pgp ? ' ' : ':';
+      if (is_pgp && i == 7)
+        *p++ = ' ';
     }
+  }
 
   /* just in case print remaining odd digits */
   for (; *s; s++)
@@ -1136,7 +1067,7 @@ static void show_fingerprint (gpgme_key_t key, STATE *state)
 }
 
 /* Show the valididy of a key used for one signature. */
-static void show_one_sig_validity (gpgme_ctx_t ctx, int idx, STATE *s)
+static void show_one_sig_validity (gpgme_ctx_t ctx, int idx, STATE * s)
 {
   gpgme_verify_result_t result = NULL;
   gpgme_signature_t sig = NULL;
@@ -1146,28 +1077,26 @@ static void show_one_sig_validity (gpgme_ctx_t ctx, int idx, STATE *s)
   if (result)
     for (sig = result->signatures; sig && (idx > 0); sig = sig->next, idx--);
 
-  switch (sig ? sig->validity : 0)
-      {
-      case GPGME_VALIDITY_UNKNOWN:
-       txt = _("WARNING: We have NO indication whether "
-               "the key belongs to the person named "
-               "as shown above\n");
-       break;
-      case GPGME_VALIDITY_UNDEFINED:
-       break;
-      case GPGME_VALIDITY_NEVER:
-       txt = _("WARNING: The key does NOT BELONG to "
-               "the person named as shown above\n");
-       break;
-      case GPGME_VALIDITY_MARGINAL:
-       txt = _("WARNING: It is NOT certain that the key "
-               "belongs to the person named as shown above\n");
-       break;
-      case GPGME_VALIDITY_FULL:
-      case GPGME_VALIDITY_ULTIMATE:
-       txt = NULL;
-       break;
-      }
+  switch (sig ? sig->validity : 0) {
+  case GPGME_VALIDITY_UNKNOWN:
+    txt = _("WARNING: We have NO indication whether "
+            "the key belongs to the person named " "as shown above\n");
+    break;
+  case GPGME_VALIDITY_UNDEFINED:
+    break;
+  case GPGME_VALIDITY_NEVER:
+    txt = _("WARNING: The key does NOT BELONG to "
+            "the person named as shown above\n");
+    break;
+  case GPGME_VALIDITY_MARGINAL:
+    txt = _("WARNING: It is NOT certain that the key "
+            "belongs to the person named as shown above\n");
+    break;
+  case GPGME_VALIDITY_FULL:
+  case GPGME_VALIDITY_ULTIMATE:
+    txt = NULL;
+    break;
+  }
   if (txt)
     state_attach_puts (txt, s);
 }
@@ -1179,7 +1108,7 @@ static void show_one_sig_validity (gpgme_ctx_t ctx, int idx, STATE *s)
 
    Return values are: 0 for normal procession, 1 for a bad signature,
    2 for a signature with a warning or -1 for no more signature.  */
-static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE *s)
+static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE * s)
 {
   time_t created;
   const char *fpr, *uid;
@@ -1192,117 +1121,106 @@ static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE *s)
   gpgme_error_t err = GPG_ERR_NO_ERROR;
 
   result = gpgme_op_verify_result (ctx);
-  if (result)
-    {
-      /* FIXME: this code should use a static variable and remember
-        the current position in the list of signatures, IMHO.
-        -moritz.  */
-
-      for (i = 0, sig = result->signatures; sig && (i < idx);
-           i++, sig = sig->next)
-        ;
-      if (! sig)
-       return -1;              /* Signature not found.  */
-
-      if (signature_key)
-       {
-         gpgme_key_release (signature_key);
-         signature_key = NULL;
-       }
-      
-      created = sig->timestamp;
-      fpr = sig->fpr;
-      sum = sig->summary;
-
-      if (gpg_err_code (sig->status) != GPG_ERR_NO_ERROR)
-       anybad = 1;
-
-      err = gpgme_get_key (ctx, fpr, &key, 0); /* secret key?  */
-      if (! err)
-       {
-         uid = (key->uids && key->uids->uid) ? key->uids->uid : "[?]";
-         if (! signature_key)
-           signature_key = key;
-       }
-      else
-       {
-          key = NULL; /* Old gpgme versions did not set KEY to NULL on
-                         error.   Do it here to avoid a double free. */
-          uid = "[?]";
-       }
-
-      if (!s || !s->fpout || !(s->flags & M_DISPLAY))
-       ; /* No state information so no way to print anything. */
-      else if (err)
-       {
-         state_attach_puts (_("Error getting key information: "), s);
-         state_attach_puts ( gpg_strerror (err), s );
-         state_attach_puts ("\n", s);
-         anybad = 1;
-       }
-      else if ((sum & GPGME_SIGSUM_GREEN))
-       {
-         state_attach_puts (_("Good signature from: "), s);
-         state_attach_puts (uid, s);
-         state_attach_puts ("\n", s);
-         for (i = 1, uids = key->uids; uids; i++, uids = uids->next)
-           {
-             if (i == 1)
-               /* Skip primary UID.  */
-               continue;
-             if (uids->revoked)
-               continue;
-             state_attach_puts (_("                aka: "), s);
-             state_attach_puts (uids->uid, s);
-             state_attach_puts ("\n", s);
-           }
-         state_attach_puts (_("            created: "), s);
-         print_time (created, s);
-         state_attach_puts ("\n", s);
-         if (show_sig_summary (sum, ctx, key, idx, s))
-           anywarn = 1;
-         show_one_sig_validity (ctx, idx, s);
-       }
-      else if ((sum & GPGME_SIGSUM_RED))
-       {
-         state_attach_puts (_("*BAD* signature claimed to be from: "), s);
-         state_attach_puts (uid, s);
-         state_attach_puts ("\n", s);
-         show_sig_summary (sum, ctx, key, idx, s);
-       }
-      else if (!anybad && key && (key->protocol == GPGME_PROTOCOL_OpenPGP))
-       { /* We can't decide (yellow) but this is a PGP key with a good
-            signature, so we display what a PGP user expects: The name,
-            fingerprint and the key validity (which is neither fully or
-            ultimate). */
-         state_attach_puts (_("Good signature from: "), s);
-         state_attach_puts (uid, s);
-         state_attach_puts ("\n", s);
-         state_attach_puts (_("            created: "), s);
-         print_time (created, s);
-         state_attach_puts ("\n", s);
-         show_one_sig_validity (ctx, idx, s);
-         show_fingerprint (key,s);
-         if (show_sig_summary (sum, ctx, key, idx, s))
-           anywarn = 1;
-       }
-      else /* can't decide (yellow) */
-       {
-         state_attach_puts (_("Error checking signature"), s);
-         state_attach_puts ("\n", s);
-         show_sig_summary (sum, ctx, key, idx, s);
-       }
-
-      if (key != signature_key)
-       gpgme_key_release (key);
-    }
+  if (result) {
+    /* FIXME: this code should use a static variable and remember
+       the current position in the list of signatures, IMHO.
+       -moritz.  */
 
-  return anybad ? 1 : anywarn ? 2 : 0;
-}
+    for (i = 0, sig = result->signatures; sig && (i < idx);
+         i++, sig = sig->next);
+    if (!sig)
+      return -1;                /* Signature not found.  */
 
-/* Do the actual verification step. With IS_SMIME set to true we
-   assume S/MIME (surprise!) */
-static int verify_one (BODY *sigbdy, STATE *s,
+    if (signature_key) {
+      gpgme_key_release (signature_key);
+      signature_key = NULL;
+    }
+
+    created = sig->timestamp;
+    fpr = sig->fpr;
+    sum = sig->summary;
+
+    if (gpg_err_code (sig->status) != GPG_ERR_NO_ERROR)
+      anybad = 1;
+
+    err = gpgme_get_key (ctx, fpr, &key, 0);    /* secret key?  */
+    if (!err) {
+      uid = (key->uids && key->uids->uid) ? key->uids->uid : "[?]";
+      if (!signature_key)
+        signature_key = key;
+    }
+    else {
+      key = NULL;               /* Old gpgme versions did not set KEY to NULL on
+                                   error.   Do it here to avoid a double free. */
+      uid = "[?]";
+    }
+
+    if (!s || !s->fpout || !(s->flags & M_DISPLAY));    /* No state information so no way to print anything. */
+    else if (err) {
+      state_attach_puts (_("Error getting key information: "), s);
+      state_attach_puts (gpg_strerror (err), s);
+      state_attach_puts ("\n", s);
+      anybad = 1;
+    }
+    else if ((sum & GPGME_SIGSUM_GREEN)) {
+      state_attach_puts (_("Good signature from: "), s);
+      state_attach_puts (uid, s);
+      state_attach_puts ("\n", s);
+      for (i = 1, uids = key->uids; uids; i++, uids = uids->next) {
+        if (i == 1)
+          /* Skip primary UID.  */
+          continue;
+        if (uids->revoked)
+          continue;
+        state_attach_puts (_("                aka: "), s);
+        state_attach_puts (uids->uid, s);
+        state_attach_puts ("\n", s);
+      }
+      state_attach_puts (_("            created: "), s);
+      print_time (created, s);
+      state_attach_puts ("\n", s);
+      if (show_sig_summary (sum, ctx, key, idx, s))
+        anywarn = 1;
+      show_one_sig_validity (ctx, idx, s);
+    }
+    else if ((sum & GPGME_SIGSUM_RED)) {
+      state_attach_puts (_("*BAD* signature claimed to be from: "), s);
+      state_attach_puts (uid, s);
+      state_attach_puts ("\n", s);
+      show_sig_summary (sum, ctx, key, idx, s);
+    }
+    else if (!anybad && key && (key->protocol == GPGME_PROTOCOL_OpenPGP)) {     /* We can't decide (yellow) but this is a PGP key with a good
+                                                                                   signature, so we display what a PGP user expects: The name,
+                                                                                   fingerprint and the key validity (which is neither fully or
+                                                                                   ultimate). */
+      state_attach_puts (_("Good signature from: "), s);
+      state_attach_puts (uid, s);
+      state_attach_puts ("\n", s);
+      state_attach_puts (_("            created: "), s);
+      print_time (created, s);
+      state_attach_puts ("\n", s);
+      show_one_sig_validity (ctx, idx, s);
+      show_fingerprint (key, s);
+      if (show_sig_summary (sum, ctx, key, idx, s))
+        anywarn = 1;
+    }
+    else {                      /* can't decide (yellow) */
+
+      state_attach_puts (_("Error checking signature"), s);
+      state_attach_puts ("\n", s);
+      show_sig_summary (sum, ctx, key, idx, s);
+    }
+
+    if (key != signature_key)
+      gpgme_key_release (key);
+  }
+
+  return anybad ? 1 : anywarn ? 2 : 0;
+}
+
+/* Do the actual verification step. With IS_SMIME set to true we
+   assume S/MIME (surprise!) */
+static int verify_one (BODY * sigbdy, STATE * s,
                        const char *tempfile, int is_smime)
 {
   int badsig = -1;
@@ -1321,12 +1239,11 @@ static int verify_one (BODY *sigbdy, STATE *s,
     gpgme_data_set_encoding (signature, GPGME_DATA_ENCODING_BASE64);
 
   err = gpgme_data_new_from_file (&message, tempfile, 1);
-  if (err) 
-    {
-      gpgme_data_release (signature);
-      mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
-      return -1;
-    }
+  if (err) {
+    gpgme_data_release (signature);
+    mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+    return -1;
+  }
   ctx = create_gpgme_context (is_smime);
 
   /* Note: We don't need a current time output because GPGME avoids
@@ -1336,90 +1253,79 @@ static int verify_one (BODY *sigbdy, STATE *s,
 
   err = gpgme_op_verify (ctx, signature, message, NULL);
   mutt_need_hard_redraw ();
-  if (err)
-    {
-      char buf[200];
-      
-      snprintf (buf, sizeof(buf)-1, 
-                _("Error: verification failed: %s\n"),
-                gpgme_strerror (err));
-      state_attach_puts (buf, s);
-    }
-  else
-    { /* Verification succeeded, see what the result is. */
-      int res, idx;
-      int anybad = 0;
-
-      if (signature_key)
-       {
-         gpgme_key_release (signature_key);
-         signature_key = NULL;
-       }
-
-      for(idx=0; (res = show_one_sig_status (ctx, idx, s)) != -1; idx++)
-        {
-          if (res == 1)
-            anybad = 1;
-          else if (res == 2)
-            anywarn = 2;
-        }
-      if (!anybad)
-        badsig = 0;
+  if (err) {
+    char buf[200];
+
+    snprintf (buf, sizeof (buf) - 1,
+              _("Error: verification failed: %s\n"), gpgme_strerror (err));
+    state_attach_puts (buf, s);
+  }
+  else {                        /* Verification succeeded, see what the result is. */
+    int res, idx;
+    int anybad = 0;
+
+    if (signature_key) {
+      gpgme_key_release (signature_key);
+      signature_key = NULL;
     }
 
-  if (!badsig)
-    {
-      gpgme_verify_result_t result;
-      gpgme_sig_notation_t notation;
-      gpgme_signature_t signature;
+    for (idx = 0; (res = show_one_sig_status (ctx, idx, s)) != -1; idx++) {
+      if (res == 1)
+        anybad = 1;
+      else if (res == 2)
+        anywarn = 2;
+    }
+    if (!anybad)
+      badsig = 0;
+  }
 
-      result = gpgme_op_verify_result (ctx);
-      if (result)
-      {
-       for (signature = result->signatures; signature;
-             signature = signature->next)
-       {
-         if (signature->notations)
-         {
-           state_attach_puts ("*** Begin Notation (signature by: ", s);
-           state_attach_puts (signature->fpr, s);
-           state_attach_puts (") ***\n", s);
-           for (notation = signature->notations; notation;
-                 notation = notation->next)
-           {
-             if (notation->name)
-             {
-               state_attach_puts (notation->name, s);
-               state_attach_puts ("=", s);
-             }
-             if (notation->value)
-             {
-               state_attach_puts (notation->value, s);
-               if (!(*notation->value
-                      && (notation->value[strlen (notation->value)-1]=='\n')))
-                 state_attach_puts ("\n", s);
-             }
-           }
-           state_attach_puts ("*** End Notation ***\n", s);
-         }
-       }
+  if (!badsig) {
+    gpgme_verify_result_t result;
+    gpgme_sig_notation_t notation;
+    gpgme_signature_t signature;
+
+    result = gpgme_op_verify_result (ctx);
+    if (result) {
+      for (signature = result->signatures; signature;
+           signature = signature->next) {
+        if (signature->notations) {
+          state_attach_puts ("*** Begin Notation (signature by: ", s);
+          state_attach_puts (signature->fpr, s);
+          state_attach_puts (") ***\n", s);
+          for (notation = signature->notations; notation;
+               notation = notation->next) {
+            if (notation->name) {
+              state_attach_puts (notation->name, s);
+              state_attach_puts ("=", s);
+            }
+            if (notation->value) {
+              state_attach_puts (notation->value, s);
+              if (!(*notation->value
+                    && (notation->value[strlen (notation->value) - 1] ==
+                        '\n')))
+                state_attach_puts ("\n", s);
+            }
+          }
+          state_attach_puts ("*** End Notation ***\n", s);
+        }
       }
     }
+  }
 
   gpgme_release (ctx);
-  
+
   state_attach_puts (_("[-- End signature information --]\n\n"), s);
   dprint (1, (debugfile, "verify_one: returning %d.\n", badsig));
-  
-  return badsig? 1: anywarn? 2 : 0;
+
+  return badsig ? 1 : anywarn ? 2 : 0;
 }
 
-int pgp_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
+int pgp_gpgme_verify_one (BODY * sigbdy, STATE * s, const char *tempfile)
 {
   return verify_one (sigbdy, s, tempfile, 0);
 }
 
-int smime_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
+int smime_gpgme_verify_one (BODY * sigbdy, STATE * s, const char *tempfile)
 {
   return verify_one (sigbdy, s, tempfile, 1);
 }
@@ -1434,7 +1340,7 @@ int smime_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
    a flag in R_IS_SIGNED to indicate whether this is a combined
    encrypted and signed message, for S/MIME it returns true when it is
    not a encrypted but a signed message.  */
-static BODY *decrypt_part (BODY *a, STATE *s, FILE *fpout, int is_smime,
+static BODY *decrypt_part (BODY * a, STATE * s, FILE * fpout, int is_smime,
                            int *r_is_signed)
 {
   struct stat info;
@@ -1451,7 +1357,7 @@ static BODY *decrypt_part (BODY *a, STATE *s, FILE *fpout, int is_smime,
 
   ctx = create_gpgme_context (is_smime);
 
- restart:
+restart:
   /* Make a data object from the body, create context etc. */
   ciphertext = file_to_data_object (s->fpin, a->offset, a->length);
   if (!ciphertext)
@@ -1459,144 +1365,133 @@ static BODY *decrypt_part (BODY *a, STATE *s, FILE *fpout, int is_smime,
   plaintext = create_gpgme_data ();
 
   /* Do the decryption or the verification in case of the S/MIME hack. */
-  if ((! is_smime) || maybe_signed)
+  if ((!is_smime) || maybe_signed) {
+    if (!is_smime)
+      err = gpgme_op_decrypt_verify (ctx, ciphertext, plaintext);
+    else if (maybe_signed)
+      err = gpgme_op_verify (ctx, ciphertext, NULL, plaintext);
+
     {
-      if (! is_smime)
-       err = gpgme_op_decrypt_verify (ctx, ciphertext, plaintext);
-      else if (maybe_signed)
-       err = gpgme_op_verify (ctx, ciphertext, NULL, plaintext);
+      /* Check wether signatures have been verified.  */
+      gpgme_verify_result_t verify_result = gpgme_op_verify_result (ctx);
 
-      {
-       /* Check wether signatures have been verified.  */
-       gpgme_verify_result_t verify_result = gpgme_op_verify_result (ctx);
-       if (verify_result->signatures)
-         sig_stat = 1;
-      }
+      if (verify_result->signatures)
+        sig_stat = 1;
     }
+  }
   else
     err = gpgme_op_decrypt (ctx, ciphertext, plaintext);
   gpgme_data_release (ciphertext);
-  if (err)
-    {
-      if (is_smime && !maybe_signed
-          && gpg_err_code (err) == GPG_ERR_NO_DATA)
-        {
-         /* Check whether this might be a signed message despite what
-             the mime header told us.  Retry then.  gpgsm returns the
-             error information "unsupported Algorithm '?'" but gpgme
-             will not store this unknown algorithm, thus we test that
-             it has not been set. */
-         gpgme_decrypt_result_t result;
-
-         result = gpgme_op_decrypt_result (ctx);
-         if (!result->unsupported_algorithm)
-            {
-              maybe_signed = 1;
-              gpgme_data_release (plaintext);
-              goto restart;
-            }
-        }
-      mutt_need_hard_redraw ();
-      if ((s->flags & M_DISPLAY))
-        {
-          char buf[200];
-          
-          snprintf (buf, sizeof(buf)-1, 
-                    _("[-- Error: decryption failed: %s --]\n\n"),
-                    gpgme_strerror (err));
-          state_attach_puts (buf, s);
-        }
-      gpgme_data_release (plaintext);
-      gpgme_release (ctx);
-      return NULL;
+  if (err) {
+    if (is_smime && !maybe_signed && gpg_err_code (err) == GPG_ERR_NO_DATA) {
+      /* Check whether this might be a signed message despite what
+         the mime header told us.  Retry then.  gpgsm returns the
+         error information "unsupported Algorithm '?'" but gpgme
+         will not store this unknown algorithm, thus we test that
+         it has not been set. */
+      gpgme_decrypt_result_t result;
+
+      result = gpgme_op_decrypt_result (ctx);
+      if (!result->unsupported_algorithm) {
+        maybe_signed = 1;
+        gpgme_data_release (plaintext);
+        goto restart;
+      }
+    }
+    mutt_need_hard_redraw ();
+    if ((s->flags & M_DISPLAY)) {
+      char buf[200];
+
+      snprintf (buf, sizeof (buf) - 1,
+                _("[-- Error: decryption failed: %s --]\n\n"),
+                gpgme_strerror (err));
+      state_attach_puts (buf, s);
+    }
+    gpgme_data_release (plaintext);
+    gpgme_release (ctx);
+    return NULL;
   }
   mutt_need_hard_redraw ();
 
   /* Read the output from GPGME, and make sure to change CRLF to LF,
      otherwise read_mime_header has a hard time parsing the message.  */
-  if (data_object_to_stream (plaintext, fpout))
-    {
-      gpgme_data_release (plaintext);
-      gpgme_release (ctx);
-      return NULL;
-    }
+  if (data_object_to_stream (plaintext, fpout)) {
+    gpgme_data_release (plaintext);
+    gpgme_release (ctx);
+    return NULL;
+  }
   gpgme_data_release (plaintext);
 
   a->is_signed_data = 0;
-  if (sig_stat)
-    {
-      int res, idx;
-      int anybad = 0;
-      
-      if (maybe_signed)
-        a->is_signed_data = 1;
-      if(r_is_signed)
-        *r_is_signed = -1; /* A signature exists. */
-
-      if ((s->flags & M_DISPLAY))
-        state_attach_puts (_("[-- Begin signature "
-                             "information --]\n"), s);
-      for(idx = 0; (res = show_one_sig_status (ctx, idx, s)) != -1; idx++)
-        {
-          if (res == 1)
-            anybad = 1;
-          else if (res == 2)
-            anywarn = 1;
-        }
-      if (!anybad && idx && r_is_signed && *r_is_signed)
-        *r_is_signed = anywarn? 2:1; /* Good signature. */
-      
-      if ((s->flags & M_DISPLAY))
-        state_attach_puts (_("[-- End signature "
-                             "information --]\n\n"), s);
-    }
-  gpgme_release (ctx); ctx = NULL;
+  if (sig_stat) {
+    int res, idx;
+    int anybad = 0;
+
+    if (maybe_signed)
+      a->is_signed_data = 1;
+    if (r_is_signed)
+      *r_is_signed = -1;        /* A signature exists. */
+
+    if ((s->flags & M_DISPLAY))
+      state_attach_puts (_("[-- Begin signature " "information --]\n"), s);
+    for (idx = 0; (res = show_one_sig_status (ctx, idx, s)) != -1; idx++) {
+      if (res == 1)
+        anybad = 1;
+      else if (res == 2)
+        anywarn = 1;
+    }
+    if (!anybad && idx && r_is_signed && *r_is_signed)
+      *r_is_signed = anywarn ? 2 : 1;   /* Good signature. */
+
+    if ((s->flags & M_DISPLAY))
+      state_attach_puts (_("[-- End signature " "information --]\n\n"), s);
+  }
+  gpgme_release (ctx);
+  ctx = NULL;
 
   fflush (fpout);
   rewind (fpout);
   tattach = mutt_read_mime_header (fpout, 0);
-  if (tattach)
-    {
-      /*
-       * Need to set the length of this body part.
-       */
-      fstat (fileno (fpout), &info);
-      tattach->length = info.st_size - tattach->offset;
-      
-      tattach->warnsig = anywarn;
+  if (tattach) {
+    /*
+     * Need to set the length of this body part.
+     */
+    fstat (fileno (fpout), &info);
+    tattach->length = info.st_size - tattach->offset;
 
-      /* See if we need to recurse on this MIME part.  */
-      mutt_parse_part (fpout, tattach);
-    }
+    tattach->warnsig = anywarn;
+
+    /* See if we need to recurse on this MIME part.  */
+    mutt_parse_part (fpout, tattach);
+  }
 
   return tattach;
 }
 
 /* Decrypt a PGP/MIME message in FPIN and B and return a new body and
    the stream in CUR and FPOUT.  Returns 0 on success. */
-int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
+int pgp_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
 {
   char tempfile[_POSIX_PATH_MAX];
   STATE s;
   BODY *first_part = b;
   int is_signed;
-  
+
   first_part->goodsig = 0;
   first_part->warnsig = 0;
 
-  if(!mutt_is_multipart_encrypted(b))
+  if (!mutt_is_multipart_encrypted (b))
     return -1;
 
-  if(!b->parts || !b->parts->next)
+  if (!b->parts || !b->parts->next)
     return -1;
-  
+
   b = b->parts->next;
-  
+
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
   mutt_mktemp (tempfile);
-  if (!(*fpout = safe_fopen (tempfile, "w+")))
-  {
+  if (!(*fpout = safe_fopen (tempfile, "w+"))) {
     mutt_perror (tempfile);
     return -1;
   }
@@ -1606,18 +1501,19 @@ int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   rewind (*fpout);
   if (is_signed > 0)
     first_part->goodsig = 1;
-  
-  return *cur? 0:-1;
+
+  return *cur ? 0 : -1;
 }
 
 
 /* Decrypt a S/MIME message in FPIN and B and return a new body and
    the stream in CUR and FPOUT.  Returns 0 on success. */
-int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
+int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
+                              BODY ** cur)
 {
   char tempfile[_POSIX_PATH_MAX];
   STATE s;
-  FILE *tmpfp=NULL;
+  FILE *tmpfp = NULL;
   int is_signed;
   long saved_b_offset;
   size_t saved_b_length;
@@ -1628,7 +1524,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
 
   if (b->parts)
     return -1;
-  
+
   /* Decode the body - we need to pass binary CMS to the
      backend.  The backend allows for Base64 encoded data but it does
      not allow for QP which I have seen in some messages.  So better
@@ -1638,13 +1534,12 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   saved_b_length = b->length;
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
-  fseek (s.fpin, b->offset, 0); 
+  fseek (s.fpin, b->offset, 0);
   mutt_mktemp (tempfile);
-  if (!(tmpfp = safe_fopen (tempfile, "w+")))
-    {
-      mutt_perror (tempfile);
-      return -1;
-    }
+  if (!(tmpfp = safe_fopen (tempfile, "w+"))) {
+    mutt_perror (tempfile);
+    return -1;
+  }
   mutt_unlink (tempfile);
 
   s.fpout = tmpfp;
@@ -1658,11 +1553,10 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   s.fpin = tmpfp;
   s.fpout = 0;
   mutt_mktemp (tempfile);
-  if (!(*fpout = safe_fopen (tempfile, "w+")))
-    {
-      mutt_perror (tempfile);
-      return -1;
-    }
+  if (!(*fpout = safe_fopen (tempfile, "w+"))) {
+    mutt_perror (tempfile);
+    return -1;
+  }
   mutt_unlink (tempfile);
 
   *cur = decrypt_part (b, &s, *fpout, 1, &is_signed);
@@ -1673,65 +1567,63 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   b->offset = saved_b_offset;
   fclose (tmpfp);
   rewind (*fpout);
-  if (*cur && !is_signed && !(*cur)->parts && mutt_is_application_smime (*cur))
-    {
-      /* Assume that this is a opaque signed s/mime message.  This is
-         an ugly way of doing it but we have anyway a problem with
-         arbitrary encoded S/MIME messages: Only the outer part may be
-         encrypted.  The entire mime parsing should be revamped,
-         probably by keeping the temportary files so that we don't
-         need to decrypt them all the time.  Inner parts of an
-         encrypted part can then pint into this file and tehre won't
-         never be a need to decrypt again.  This needs a partial
-         rewrite of the MIME engine. */
-      BODY *bb = *cur;
-      BODY *tmp_b;
-
-      saved_b_type = bb->type;
-      saved_b_offset = bb->offset;
-      saved_b_length = bb->length;
-      memset (&s, 0, sizeof (s));
-      s.fpin = *fpout;
-      fseek (s.fpin, bb->offset, 0); 
-      mutt_mktemp (tempfile);
-      if (!(tmpfp = safe_fopen (tempfile, "w+")))
-        {
-          mutt_perror (tempfile);
-          return -1;
-        }
-      mutt_unlink (tempfile);
-
-      s.fpout = tmpfp;
-      mutt_decode_attachment (bb, &s);
-      fflush (tmpfp);
-      bb->length = ftell (s.fpout);
-      bb->offset = 0;
-      rewind (tmpfp);
-      fclose (*fpout); 
-
-      memset (&s, 0, sizeof (s));
-      s.fpin = tmpfp;
-      s.fpout = 0;
-      mutt_mktemp (tempfile);
-      if (!(*fpout = safe_fopen (tempfile, "w+")))
-        {
-          mutt_perror (tempfile);
-          return -1;
-        }
-      mutt_unlink (tempfile);
-
-      tmp_b = decrypt_part (bb, &s, *fpout, 1, &is_signed);
-      if (tmp_b)
-        tmp_b->goodsig = is_signed > 0;
-      bb->type = saved_b_type;
-      bb->length = saved_b_length;
-      bb->offset = saved_b_offset;
-      fclose (tmpfp);
-      rewind (*fpout);
-      mutt_free_body (cur);
-      *cur = tmp_b;
+  if (*cur && !is_signed && !(*cur)->parts
+      && mutt_is_application_smime (*cur)) {
+    /* Assume that this is a opaque signed s/mime message.  This is
+       an ugly way of doing it but we have anyway a problem with
+       arbitrary encoded S/MIME messages: Only the outer part may be
+       encrypted.  The entire mime parsing should be revamped,
+       probably by keeping the temportary files so that we don't
+       need to decrypt them all the time.  Inner parts of an
+       encrypted part can then pint into this file and tehre won't
+       never be a need to decrypt again.  This needs a partial
+       rewrite of the MIME engine. */
+    BODY *bb = *cur;
+    BODY *tmp_b;
+
+    saved_b_type = bb->type;
+    saved_b_offset = bb->offset;
+    saved_b_length = bb->length;
+    memset (&s, 0, sizeof (s));
+    s.fpin = *fpout;
+    fseek (s.fpin, bb->offset, 0);
+    mutt_mktemp (tempfile);
+    if (!(tmpfp = safe_fopen (tempfile, "w+"))) {
+      mutt_perror (tempfile);
+      return -1;
+    }
+    mutt_unlink (tempfile);
+
+    s.fpout = tmpfp;
+    mutt_decode_attachment (bb, &s);
+    fflush (tmpfp);
+    bb->length = ftell (s.fpout);
+    bb->offset = 0;
+    rewind (tmpfp);
+    fclose (*fpout);
+
+    memset (&s, 0, sizeof (s));
+    s.fpin = tmpfp;
+    s.fpout = 0;
+    mutt_mktemp (tempfile);
+    if (!(*fpout = safe_fopen (tempfile, "w+"))) {
+      mutt_perror (tempfile);
+      return -1;
     }
-  return *cur? 0:-1;
+    mutt_unlink (tempfile);
+
+    tmp_b = decrypt_part (bb, &s, *fpout, 1, &is_signed);
+    if (tmp_b)
+      tmp_b->goodsig = is_signed > 0;
+    bb->type = saved_b_type;
+    bb->length = saved_b_length;
+    bb->offset = saved_b_offset;
+    fclose (tmpfp);
+    rewind (*fpout);
+    mutt_free_body (cur);
+    *cur = tmp_b;
+  }
+  return *cur ? 0 : -1;
 }
 
 
@@ -1739,15 +1631,16 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
  * Implementation of `pgp_check_traditional'.
  */
 
-static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
+static int pgp_check_traditional_one_body (FILE * fp, BODY * b,
+                                           int tagged_only)
 {
   char tempfile[_POSIX_PATH_MAX];
   char buf[HUGE_STRING];
   FILE *tfp;
-  
+
   short sgn = 0;
   short enc = 0;
-  
+
   if (b->type != TYPETEXT)
     return 0;
 
@@ -1755,26 +1648,22 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     return 0;
 
   mutt_mktemp (tempfile);
-  if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0)
-  {
+  if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0) {
     unlink (tempfile);
     return 0;
   }
-  
-  if ((tfp = fopen (tempfile, "r")) == NULL)
-  {
+
+  if ((tfp = fopen (tempfile, "r")) == NULL) {
     unlink (tempfile);
     return 0;
   }
-  
-  while (fgets (buf, sizeof (buf), tfp))
-  {
-    if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15))
-    {
+
+  while (fgets (buf, sizeof (buf), tfp)) {
+    if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) {
       if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
-       enc = 1;
+        enc = 1;
       else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
-       sgn = 1;
+        sgn = 1;
     }
   }
   safe_fclose (&tfp);
@@ -1784,28 +1673,27 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     return 0;
 
   /* fix the content type */
-  
+
   mutt_set_parameter ("format", "fixed", &b->parameter);
   mutt_set_parameter ("x-action", enc ? "pgp-encrypted" : "pgp-signed",
                       &b->parameter);
-  
+
   return 1;
 }
 
-int pgp_gpgme_check_traditional (FILE *fp, BODY *b, int tagged_only)
+int pgp_gpgme_check_traditional (FILE * fp, BODY * b, int tagged_only)
 {
   int rv = 0;
   int r;
-  for (; b; b = b->next)
-  {
+
+  for (; b; b = b->next) {
     if (is_multipart (b))
       rv = (pgp_gpgme_check_traditional (fp, b->parts, tagged_only) || rv);
-    else if (b->type == TYPETEXT)
-    {
+    else if (b->type == TYPETEXT) {
       if ((r = mutt_is_application_pgp (b)))
-       rv = (rv || r);
+        rv = (rv || r);
       else
-       rv = (pgp_check_traditional_one_body (fp, b, tagged_only) || rv);
+        rv = (pgp_check_traditional_one_body (fp, b, tagged_only) || rv);
     }
   }
   return rv;
@@ -1828,7 +1716,7 @@ int pgp_gpgme_check_traditional (FILE *fp, BODY *b, int tagged_only)
   note that we can successfully handle anything produced by any
   existing versions of mutt.)  */
 
-static void copy_clearsigned (gpgme_data_t data, STATE *s, char *charset)
+static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset)
 {
   char buf[HUGE_STRING];
   short complete, armor_header;
@@ -1841,46 +1729,43 @@ static void copy_clearsigned (gpgme_data_t data, STATE *s, char *charset)
     return;
   unlink (fname);
   FREE (&fname);
-  
+
   fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM);
-  
+
   for (complete = 1, armor_header = 1;
        fgetconvs (buf, sizeof (buf), fc) != NULL;
-       complete = strchr (buf, '\n') != NULL)
-  {
-    if (!complete)
-    {
+       complete = strchr (buf, '\n') != NULL) {
+    if (!complete) {
       if (!armor_header)
-       state_puts (buf, s);
+        state_puts (buf, s);
       continue;
     }
 
     if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
       break;
-    
-    if (armor_header)
-    {
-      if (buf[0] == '\n') 
-       armor_header = 0;
+
+    if (armor_header) {
+      if (buf[0] == '\n')
+        armor_header = 0;
       continue;
     }
-    
-    if (s->prefix) 
+
+    if (s->prefix)
       state_puts (s->prefix, s);
-    
+
     if (buf[0] == '-' && buf[1] == ' ')
       state_puts (buf + 2, s);
     else
       state_puts (buf, s);
   }
-  
+
   fgetconv_close (&fc);
   fclose (fp);
 }
 
 
 /* Support for classic_application/pgp */
-void pgp_gpgme_application_handler (BODY *m, STATE *s)
+void pgp_gpgme_application_handler (BODY * m, STATE * s)
 {
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0;
@@ -1895,7 +1780,7 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
   short maybe_goodsig = 1;
   short have_any_sigs = 0;
 
-  char body_charset[STRING];  /* Only used for clearsigned messages. */
+  char body_charset[STRING];    /* Only used for clearsigned messages. */
 
   dprint (2, (debugfile, "Entering pgp_application_pgp handler\n"));
 
@@ -1907,229 +1792,201 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
 
   fseek (s->fpin, m->offset, 0);
   last_pos = m->offset;
-  
-  for (bytes = m->length; bytes > 0;)
-    {
-      if (fgets (buf, sizeof (buf), s->fpin) == NULL)
-        break;
-      
-      offset = ftell (s->fpin);
-      bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
-      last_pos = offset;
-      
-      if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15))
-        {
-          clearsign = 0;
-          start_pos = last_pos;
-          
-          if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
-            needpass = 1;
-          else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
-            {
-              clearsign = 1;
-              needpass = 0;
-            }
-          else if (!option (OPTDONTHANDLEPGPKEYS) &&
-                   !mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15))
-            {
-              needpass = 0;
-              pgp_keyblock =1;
-            } 
-          else
-            {
-              /* XXX - we may wish to recode here */
-              if (s->prefix)
-                state_puts (s->prefix, s);
-              state_puts (buf, s);
-              continue;
-            }
-          
-          have_any_sigs = (have_any_sigs
-                           || (clearsign && (s->flags & M_VERIFY)));
-          
-          /* Copy PGP material to an data container */
-          armored_data = create_gpgme_data ();
-          gpgme_data_write (armored_data, buf, strlen (buf));
-          while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL)
-            {
-              offset = ftell (s->fpin);
-              bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf)*/
-              last_pos = offset;
-              
-              gpgme_data_write (armored_data, buf, strlen (buf));
-              
-              if ((needpass
-                   && !mutt_strcmp ("-----END PGP MESSAGE-----\n", buf)) 
-                  || (!needpass 
-                      && (!mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf)
-                          || !mutt_strcmp (
-                                "-----END PGP PUBLIC KEY BLOCK-----\n",buf))))
-                break;
-            }
-          
-          /* Invoke PGP if needed */
-          if (!clearsign || (s->flags & M_VERIFY))
-            {
-              unsigned int sig_stat = 0;
-              gpgme_data_t plaintext;
-              gpgme_ctx_t ctx;
-
-              plaintext = create_gpgme_data ();
-              ctx = create_gpgme_context (0);
-
-              if (clearsign)
-                err = gpgme_op_verify (ctx, armored_data, NULL, plaintext);
-              else
-                {
-                  err = gpgme_op_decrypt_verify (ctx, armored_data, plaintext);
-                  if (gpg_err_code (err) == GPG_ERR_NO_DATA)
-                    {
-                      /* Decrypt verify can't handle signed only messages. */
-                     err = (gpgme_data_seek (armored_data, 0, SEEK_SET) == -1)
-                       ? gpgme_error_from_errno (errno) : 0;
-                      /* Must release plaintext so that we supply an
-                         uninitialized object. */
-                      gpgme_data_release (plaintext);
-                      plaintext = create_gpgme_data ();
-                      err = gpgme_op_verify (ctx, armored_data,
-                                             NULL, plaintext);
-                    }
-                }
-
-              if (err)
-                {
-                  char errbuf[200];
-                  
-                  snprintf (errbuf, sizeof(errbuf)-1, 
-                            _("Error: decryption/verification failed: %s\n"),
-                            gpgme_strerror (err));
-                  state_attach_puts (errbuf, s);
-                }
-              else
-                { /* Decryption/Verification succeeded */
-                  char *tmpfname;
-
-                 {
-                   /* Check wether signatures have been verified.  */
-                   gpgme_verify_result_t verify_result;
-
-                    verify_result = gpgme_op_verify_result (ctx);
-                   if (verify_result->signatures)
-                     sig_stat = 1;
-                 }
-
-                  have_any_sigs = 0;
-                  maybe_goodsig = 0;
-                  if ((s->flags & M_DISPLAY) && sig_stat)
-                    {
-                      int res, idx;
-                      int anybad = 0;
-                      int anywarn = 0;
-
-                      state_attach_puts (_("[-- Begin signature "
-                                           "information --]\n"), s);
-                      have_any_sigs = 1;
-                      for(idx=0;
-                          (res = show_one_sig_status (ctx, idx, s)) != -1;
-                          idx++)
-                        {
-                          if (res == 1)
-                            anybad = 1;
-                          else if (res == 2)
-                            anywarn = 1;
-                        }
-                      if (!anybad && idx)
-                        maybe_goodsig = 1;
-                      
-                      state_attach_puts (_("[-- End signature "
-                                           "information --]\n\n"), s);
-                    }
-
-                  tmpfname = data_object_to_tempfile (plaintext, &pgpout);
-                  if (!tmpfname)
-                    {
-                      pgpout = NULL;
-                      state_attach_puts (_("Error: copy data failed\n"), s);
-                    }
-                  else
-                    {
-                      unlink (tmpfname);
-                      FREE (&tmpfname);
-                    }
-                }
-              gpgme_release (ctx);
-            }
-      
-          /*
-           * Now, copy cleartext to the screen.  NOTE - we expect that PGP
-           * outputs utf-8 cleartext.  This may not always be true, but it 
-           * seems to be a reasonable guess.
-           */
-          
-          if(s->flags & M_DISPLAY)
-            {
-              if (needpass)
-            state_attach_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
-              else if (pgp_keyblock)
-                state_attach_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"),
-                                   s);
-              else
-                state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"),
-                                   s);
-            }
-          
-          if (clearsign)
-            {
-              copy_clearsigned (armored_data, s, body_charset);
-            }
-          else if (pgpout)
-            {
-              FGETCONV *fc;
-              int c;
-              rewind (pgpout);
-              fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
-              while ((c = fgetconv (fc)) != EOF)
-                {
-                  state_putc (c, s);
-                  if (c == '\n' && s->prefix)
-                    state_puts (s->prefix, s);
-                }
-              fgetconv_close (&fc);
-            }
-          
-          if (s->flags & M_DISPLAY)
-            {
-              state_putc ('\n', s);
-              if (needpass)
-                state_attach_puts (_("[-- END PGP MESSAGE --]\n"), s);
-              else if (pgp_keyblock)
-                state_attach_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
-              else
-                state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
-            }
-          
-          if (pgpout)
-            {
-              safe_fclose (&pgpout);
+
+  for (bytes = m->length; bytes > 0;) {
+    if (fgets (buf, sizeof (buf), s->fpin) == NULL)
+      break;
+
+    offset = ftell (s->fpin);
+    bytes -= (offset - last_pos);       /* don't rely on mutt_strlen(buf) */
+    last_pos = offset;
+
+    if (!mutt_strncmp ("-----BEGIN PGP ", buf, 15)) {
+      clearsign = 0;
+      start_pos = last_pos;
+
+      if (!mutt_strcmp ("MESSAGE-----\n", buf + 15))
+        needpass = 1;
+      else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15)) {
+        clearsign = 1;
+        needpass = 0;
+      }
+      else if (!option (OPTDONTHANDLEPGPKEYS) &&
+               !mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) {
+        needpass = 0;
+        pgp_keyblock = 1;
+      }
+      else {
+        /* XXX - we may wish to recode here */
+        if (s->prefix)
+          state_puts (s->prefix, s);
+        state_puts (buf, s);
+        continue;
+      }
+
+      have_any_sigs = (have_any_sigs || (clearsign && (s->flags & M_VERIFY)));
+
+      /* Copy PGP material to an data container */
+      armored_data = create_gpgme_data ();
+      gpgme_data_write (armored_data, buf, strlen (buf));
+      while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) {
+        offset = ftell (s->fpin);
+        bytes -= (offset - last_pos);   /* don't rely on mutt_strlen(buf) */
+        last_pos = offset;
+
+        gpgme_data_write (armored_data, buf, strlen (buf));
+
+        if ((needpass && !mutt_strcmp ("-----END PGP MESSAGE-----\n", buf))
+            || (!needpass
+                && (!mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf)
+                    || !mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
+                                     buf))))
+          break;
+      }
+
+      /* Invoke PGP if needed */
+      if (!clearsign || (s->flags & M_VERIFY)) {
+        unsigned int sig_stat = 0;
+        gpgme_data_t plaintext;
+        gpgme_ctx_t ctx;
+
+        plaintext = create_gpgme_data ();
+        ctx = create_gpgme_context (0);
+
+        if (clearsign)
+          err = gpgme_op_verify (ctx, armored_data, NULL, plaintext);
+        else {
+          err = gpgme_op_decrypt_verify (ctx, armored_data, plaintext);
+          if (gpg_err_code (err) == GPG_ERR_NO_DATA) {
+            /* Decrypt verify can't handle signed only messages. */
+            err = (gpgme_data_seek (armored_data, 0, SEEK_SET) == -1)
+              ? gpgme_error_from_errno (errno) : 0;
+            /* Must release plaintext so that we supply an
+               uninitialized object. */
+            gpgme_data_release (plaintext);
+            plaintext = create_gpgme_data ();
+            err = gpgme_op_verify (ctx, armored_data, NULL, plaintext);
+          }
+        }
+
+        if (err) {
+          char errbuf[200];
+
+          snprintf (errbuf, sizeof (errbuf) - 1,
+                    _("Error: decryption/verification failed: %s\n"),
+                    gpgme_strerror (err));
+          state_attach_puts (errbuf, s);
+        }
+        else {                  /* Decryption/Verification succeeded */
+          char *tmpfname;
+
+          {
+            /* Check wether signatures have been verified.  */
+            gpgme_verify_result_t verify_result;
+
+            verify_result = gpgme_op_verify_result (ctx);
+            if (verify_result->signatures)
+              sig_stat = 1;
+          }
+
+          have_any_sigs = 0;
+          maybe_goodsig = 0;
+          if ((s->flags & M_DISPLAY) && sig_stat) {
+            int res, idx;
+            int anybad = 0;
+            int anywarn = 0;
+
+            state_attach_puts (_("[-- Begin signature "
+                                 "information --]\n"), s);
+            have_any_sigs = 1;
+            for (idx = 0;
+                 (res = show_one_sig_status (ctx, idx, s)) != -1; idx++) {
+              if (res == 1)
+                anybad = 1;
+              else if (res == 2)
+                anywarn = 1;
             }
+            if (!anybad && idx)
+              maybe_goodsig = 1;
+
+            state_attach_puts (_("[-- End signature "
+                                 "information --]\n\n"), s);
+          }
+
+          tmpfname = data_object_to_tempfile (plaintext, &pgpout);
+          if (!tmpfname) {
+            pgpout = NULL;
+            state_attach_puts (_("Error: copy data failed\n"), s);
+          }
+          else {
+            unlink (tmpfname);
+            FREE (&tmpfname);
+          }
         }
-      else
-        {
-          /* XXX - we may wish to recode here */
-          if (s->prefix)
+        gpgme_release (ctx);
+      }
+
+      /*
+       * Now, copy cleartext to the screen.  NOTE - we expect that PGP
+       * outputs utf-8 cleartext.  This may not always be true, but it 
+       * seems to be a reasonable guess.
+       */
+
+      if (s->flags & M_DISPLAY) {
+        if (needpass)
+          state_attach_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
+        else if (pgp_keyblock)
+          state_attach_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"), s);
+        else
+          state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
+      }
+
+      if (clearsign) {
+        copy_clearsigned (armored_data, s, body_charset);
+      }
+      else if (pgpout) {
+        FGETCONV *fc;
+        int c;
+
+        rewind (pgpout);
+        fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
+        while ((c = fgetconv (fc)) != EOF) {
+          state_putc (c, s);
+          if (c == '\n' && s->prefix)
             state_puts (s->prefix, s);
-          state_puts (buf, s);
         }
+        fgetconv_close (&fc);
+      }
+
+      if (s->flags & M_DISPLAY) {
+        state_putc ('\n', s);
+        if (needpass)
+          state_attach_puts (_("[-- END PGP MESSAGE --]\n"), s);
+        else if (pgp_keyblock)
+          state_attach_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
+        else
+          state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
+      }
+
+      if (pgpout) {
+        safe_fclose (&pgpout);
+      }
+    }
+    else {
+      /* XXX - we may wish to recode here */
+      if (s->prefix)
+        state_puts (s->prefix, s);
+      state_puts (buf, s);
     }
+  }
 
   m->goodsig = (maybe_goodsig && have_any_sigs);
-  
-  if (needpass == -1)
-    {
-      state_attach_puts (_("[-- Error: could not find beginning"
-                           " of PGP message! --]\n\n"), s);
-      return;
-    }
+
+  if (needpass == -1) {
+    state_attach_puts (_("[-- Error: could not find beginning"
+                         " of PGP message! --]\n\n"), s);
+    return;
+  }
   dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n"));
 }
 
@@ -2138,84 +1995,84 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
  */
 
 /* MIME handler for pgp/mime encrypted messages. */
-void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
+void pgp_gpgme_encrypted_handler (BODY * a, STATE * s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout;
   BODY *tattach;
   BODY *orig_body = a;
   int is_signed;
-  
+
   dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
   a = a->parts;
   if (!a || a->type != TYPEAPPLICATION || !a->subtype
-      || ascii_strcasecmp ("pgp-encrypted", a->subtype) 
+      || ascii_strcasecmp ("pgp-encrypted", a->subtype)
       || !a->next || a->next->type != TYPEAPPLICATION || !a->next->subtype
-      || ascii_strcasecmp ("octet-stream", a->next->subtype) )
-    {
-      if (s->flags & M_DISPLAY)
-        state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"),
-                           s);
-      return;
-    }
+      || ascii_strcasecmp ("octet-stream", a->next->subtype)) {
+    if (s->flags & M_DISPLAY)
+      state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"),
+                         s);
+    return;
+  }
 
   /* Move forward to the application/pgp-encrypted body. */
   a = a->next;
 
   mutt_mktemp (tempfile);
-  if (!(fpout = safe_fopen (tempfile, "w+")))
-    {
-      if (s->flags & M_DISPLAY)
-        state_attach_puts (_("[-- Error: could not create temporary file! "
-                             "--]\n"), s);
-      return;
-    }
+  if (!(fpout = safe_fopen (tempfile, "w+"))) {
+    if (s->flags & M_DISPLAY)
+      state_attach_puts (_("[-- Error: could not create temporary file! "
+                           "--]\n"), s);
+    return;
+  }
 
   tattach = decrypt_part (a, s, fpout, 0, &is_signed);
-  if (tattach)
+  if (tattach) {
+    tattach->goodsig = is_signed > 0;
+
+    if (s->flags & M_DISPLAY)
+      state_attach_puts (is_signed ?
+                         _
+                         ("[-- The following data is PGP/MIME signed and encrypted --]\n\n")
+                         :
+                         _
+                         ("[-- The following data is PGP/MIME encrypted --]\n\n"),
+                         s);
+
     {
-      tattach->goodsig = is_signed > 0;
-
-      if (s->flags & M_DISPLAY)
-        state_attach_puts (is_signed?
-          _("[-- The following data is PGP/MIME signed and encrypted --]\n\n"):
-          _("[-- The following data is PGP/MIME encrypted --]\n\n"),
-                           s);
-      
-      {
-        FILE *savefp = s->fpin;
-        s->fpin = fpout;
-        mutt_body_handler (tattach, s);
-        s->fpin = savefp;
-      }
+      FILE *savefp = s->fpin;
 
-      /* 
-       * if a multipart/signed is the _only_ sub-part of a
-       * multipart/encrypted, cache signature verification
-       * status.
-       */
-      if (mutt_is_multipart_signed (tattach) && !tattach->next)
-        orig_body->goodsig |= tattach->goodsig;
-    
-      if (s->flags & M_DISPLAY)
-        {
-          state_puts ("\n", s);
-          state_attach_puts (is_signed?
-             _("[-- End of PGP/MIME signed and encrypted data --]\n"):
-             _("[-- End of PGP/MIME encrypted data --]\n"),
-                             s);
-        }
+      s->fpin = fpout;
+      mutt_body_handler (tattach, s);
+      s->fpin = savefp;
+    }
 
-      mutt_free_body (&tattach);
+    /* 
+     * if a multipart/signed is the _only_ sub-part of a
+     * multipart/encrypted, cache signature verification
+     * status.
+     */
+    if (mutt_is_multipart_signed (tattach) && !tattach->next)
+      orig_body->goodsig |= tattach->goodsig;
+
+    if (s->flags & M_DISPLAY) {
+      state_puts ("\n", s);
+      state_attach_puts (is_signed ?
+                         _
+                         ("[-- End of PGP/MIME signed and encrypted data --]\n")
+                         : _("[-- End of PGP/MIME encrypted data --]\n"), s);
     }
-  
+
+    mutt_free_body (&tattach);
+  }
+
   fclose (fpout);
-  mutt_unlink(tempfile);
+  mutt_unlink (tempfile);
   dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
 }
 
 /* Support for application/smime */
-void smime_gpgme_application_handler (BODY *a, STATE *s)
+void smime_gpgme_application_handler (BODY * a, STATE * s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout;
@@ -2224,65 +2081,62 @@ void smime_gpgme_application_handler (BODY *a, STATE *s)
 
 
   dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
-  
+
   a->warnsig = 0;
   mutt_mktemp (tempfile);
-  if (!(fpout = safe_fopen (tempfile, "w+")))
-    {
-      if (s->flags & M_DISPLAY)
-        state_attach_puts (_("[-- Error: could not create temporary file! "
-                             "--]\n"), s);
-      return;
-    }
+  if (!(fpout = safe_fopen (tempfile, "w+"))) {
+    if (s->flags & M_DISPLAY)
+      state_attach_puts (_("[-- Error: could not create temporary file! "
+                           "--]\n"), s);
+    return;
+  }
 
   tattach = decrypt_part (a, s, fpout, 1, &is_signed);
-  if (tattach)
+  if (tattach) {
+    tattach->goodsig = is_signed > 0;
+
+    if (s->flags & M_DISPLAY)
+      state_attach_puts (is_signed ?
+                         _("[-- The following data is S/MIME signed --]\n\n")
+                         :
+                         _
+                         ("[-- The following data is S/MIME encrypted --]\n\n"),
+                         s);
+
     {
-      tattach->goodsig = is_signed > 0;
-
-      if (s->flags & M_DISPLAY)
-        state_attach_puts (is_signed?
-          _("[-- The following data is S/MIME signed --]\n\n"):
-          _("[-- The following data is S/MIME encrypted --]\n\n"),
-                           s);
-      
-      {
-        FILE *savefp = s->fpin;
-        s->fpin = fpout;
-        mutt_body_handler (tattach, s);
-        s->fpin = savefp;
-      }
+      FILE *savefp = s->fpin;
 
-      /* 
-       * if a multipart/signed is the _only_ sub-part of a
-       * multipart/encrypted, cache signature verification
-       * status.
-       */
-      if (mutt_is_multipart_signed (tattach) && !tattach->next)
-        {
-          if (!(a->goodsig = tattach->goodsig))
-            a->warnsig = tattach->warnsig;
-        }
-      else if (tattach->goodsig)
-        {
-          a->goodsig = 1;
-          a->warnsig = tattach->warnsig;
-        }
+      s->fpin = fpout;
+      mutt_body_handler (tattach, s);
+      s->fpin = savefp;
+    }
 
-      if (s->flags & M_DISPLAY)
-        {
-          state_puts ("\n", s);
-          state_attach_puts (is_signed?
-             _("[-- End of S/MIME signed data --]\n"):
-             _("[-- End of S/MIME encrypted data --]\n"),
-                             s);
-        }
+    /* 
+     * if a multipart/signed is the _only_ sub-part of a
+     * multipart/encrypted, cache signature verification
+     * status.
+     */
+    if (mutt_is_multipart_signed (tattach) && !tattach->next) {
+      if (!(a->goodsig = tattach->goodsig))
+        a->warnsig = tattach->warnsig;
+    }
+    else if (tattach->goodsig) {
+      a->goodsig = 1;
+      a->warnsig = tattach->warnsig;
+    }
 
-      mutt_free_body (&tattach);
+    if (s->flags & M_DISPLAY) {
+      state_puts ("\n", s);
+      state_attach_puts (is_signed ?
+                         _("[-- End of S/MIME signed data --]\n") :
+                         _("[-- End of S/MIME encrypted data --]\n"), s);
     }
-  
+
+    mutt_free_body (&tattach);
+  }
+
   fclose (fpout);
-  mutt_unlink(tempfile);
+  mutt_unlink (tempfile);
   dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
 }
 
@@ -2309,8 +2163,7 @@ static const char *crypt_entry_fmt (char *dest,
                                     const char *prefix,
                                     const char *ifstring,
                                     const char *elsestring,
-                                    unsigned long data,
-                                    format_flag flags)
+                                    unsigned long data, format_flag flags)
 {
   char fmt[16];
   crypt_entry_t *entry;
@@ -2321,190 +2174,174 @@ static const char *crypt_entry_fmt (char *dest,
   unsigned long val;
 
   entry = (crypt_entry_t *) data;
-  key   = entry->key;
+  key = entry->key;
 
 /*    if (isupper ((unsigned char) op)) */
 /*      key = pkey; */
 
-  kflags = (key->flags /*| (pkey->flags & KEYFLAG_RESTRICTIONS)
-                         | uid->flags*/);
-  
-  switch (ascii_tolower (op))
+  kflags = (key->flags          /*| (pkey->flags & KEYFLAG_RESTRICTIONS)
+                                   | uid->flags */ );
+
+  switch (ascii_tolower (op)) {
+  case '[':
     {
-    case '[':
-      {
-       const char *cp;
-       char buf2[SHORT_STRING], *p;
-       int do_locales;
-       struct tm *tm;
-       size_t len;
-
-       p = dest;
-
-       cp = src;
-       if (*cp == '!')
-       {
-         do_locales = 0;
-         cp++;
-       }
-       else
-         do_locales = 1;
-
-       len = destlen - 1;
-       while (len > 0 && *cp != ']')
-       {
-         if (*cp == '%')
-         {
-           cp++;
-           if (len >= 2)
-           {
-             *p++ = '%';
-             *p++ = *cp;
-             len -= 2;
-           }
-           else
-             break; /* not enough space */
-           cp++;
-         }
-         else
-         {
-           *p++ = *cp++;
-           len--;
-         }
-       }
-       *p = 0;
-
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
-        
-        {
-         time_t tt = 0;
-
-         if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
-           tt = key->kobj->subkeys->timestamp;
-
-          tm = localtime (&tt);
-        }
-       strftime (buf2, sizeof (buf2), dest, tm);
-
-       if (do_locales)
-         setlocale (LC_TIME, "C");
-        
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, buf2);
-       if (len > 0)
-         src = cp + 1;
-      }
-      break;
-    case 'n':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, entry->num);
-      }
-      break;
-    case 'k':
-      if (!optional)
-      {
-        /* fixme: we need a way to distinguish between main and subkeys.
-           Store the idx in entry? */
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, crypt_keyid (key));
-      }
-      break;
-    case 'u':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, key->uid);
-      }
-      break;
-    case 'a':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%s.3s", prefix);
-       if (key->kobj->subkeys)
-         s = gpgme_pubkey_algo_name (key->kobj->subkeys->pubkey_algo);
-       else
-          s = "?";
-       snprintf (dest, destlen, fmt, s);
-      }
-      break;
-    case 'l':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%slu", prefix);
-       if (key->kobj->subkeys)
-         val = key->kobj->subkeys->length;
-       else
-         val = 0;
-       snprintf (dest, destlen, fmt, val);
+      const char *cp;
+      char buf2[SHORT_STRING], *p;
+      int do_locales;
+      struct tm *tm;
+      size_t len;
+
+      p = dest;
+
+      cp = src;
+      if (*cp == '!') {
+        do_locales = 0;
+        cp++;
       }
-      break;
-    case 'f':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-       snprintf (dest, destlen, fmt, crypt_flags (kflags));
+      else
+        do_locales = 1;
+
+      len = destlen - 1;
+      while (len > 0 && *cp != ']') {
+        if (*cp == '%') {
+          cp++;
+          if (len >= 2) {
+            *p++ = '%';
+            *p++ = *cp;
+            len -= 2;
+          }
+          else
+            break;              /* not enough space */
+          cp++;
+        }
+        else {
+          *p++ = *cp++;
+          len--;
+        }
       }
-      else if (!(kflags & (KEYFLAG_RESTRICTIONS)))
-        optional = 0;
-      break;
-    case 'c':
-      if (!optional)
+      *p = 0;
+
+      if (do_locales && Locale)
+        setlocale (LC_TIME, Locale);
+
       {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, crypt_key_abilities (kflags));
+        time_t tt = 0;
+
+        if (key->kobj->subkeys && (key->kobj->subkeys->timestamp > 0))
+          tt = key->kobj->subkeys->timestamp;
+
+        tm = localtime (&tt);
       }
-      else if (!(kflags & (KEYFLAG_ABILITIES)))
-        optional = 0;
-      break;
-    case 't':
-      if ((kflags & KEYFLAG_ISX509))
-        s = "x";
+      strftime (buf2, sizeof (buf2), dest, tm);
+
+      if (do_locales)
+        setlocale (LC_TIME, "C");
+
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, buf2);
+      if (len > 0)
+        src = cp + 1;
+    }
+    break;
+  case 'n':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, entry->num);
+    }
+    break;
+  case 'k':
+    if (!optional) {
+      /* fixme: we need a way to distinguish between main and subkeys.
+         Store the idx in entry? */
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, crypt_keyid (key));
+    }
+    break;
+  case 'u':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, key->uid);
+    }
+    break;
+  case 'a':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%s.3s", prefix);
+      if (key->kobj->subkeys)
+        s = gpgme_pubkey_algo_name (key->kobj->subkeys->pubkey_algo);
       else
-       {
-         gpgme_user_id_t uid = NULL;
-         unsigned int i = 0;
-
-         for (i = 0, uid = key->kobj->uids; uid && (i < key->idx);
-               i++, uid = uid->next)
-            ;
-         if (uid)
-           switch (uid->validity)
-             {
-             case GPGME_VALIDITY_UNDEFINED:
-               s = "q";
-               break;
-             case GPGME_VALIDITY_NEVER:
-               s = "n";
-               break;
-             case GPGME_VALIDITY_MARGINAL:
-               s = "m";
-               break;
-             case GPGME_VALIDITY_FULL:
-               s = "f";
-               break;
-             case GPGME_VALIDITY_ULTIMATE:
-               s = "u";
-               break;
-             case GPGME_VALIDITY_UNKNOWN:
-             default:
-               s = "?";
-               break;
-             }
-       }
+        s = "?";
+      snprintf (dest, destlen, fmt, s);
+    }
+    break;
+  case 'l':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%slu", prefix);
+      if (key->kobj->subkeys)
+        val = key->kobj->subkeys->length;
+      else
+        val = 0;
+      snprintf (dest, destlen, fmt, val);
+    }
+    break;
+  case 'f':
+    if (!optional) {
       snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-      snprintf (dest, destlen, fmt, s? *s: 'B');
-      break;
-    case 'p':
+      snprintf (dest, destlen, fmt, crypt_flags (kflags));
+    }
+    else if (!(kflags & (KEYFLAG_RESTRICTIONS)))
+      optional = 0;
+    break;
+  case 'c':
+    if (!optional) {
       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (dest, destlen, fmt,
-                gpgme_get_protocol_name (key->kobj->protocol));
-      break;
+      snprintf (dest, destlen, fmt, crypt_key_abilities (kflags));
+    }
+    else if (!(kflags & (KEYFLAG_ABILITIES)))
+      optional = 0;
+    break;
+  case 't':
+    if ((kflags & KEYFLAG_ISX509))
+      s = "x";
+    else {
+      gpgme_user_id_t uid = NULL;
+      unsigned int i = 0;
+
+      for (i = 0, uid = key->kobj->uids; uid && (i < key->idx);
+           i++, uid = uid->next);
+      if (uid)
+        switch (uid->validity) {
+        case GPGME_VALIDITY_UNDEFINED:
+          s = "q";
+          break;
+        case GPGME_VALIDITY_NEVER:
+          s = "n";
+          break;
+        case GPGME_VALIDITY_MARGINAL:
+          s = "m";
+          break;
+        case GPGME_VALIDITY_FULL:
+          s = "f";
+          break;
+        case GPGME_VALIDITY_ULTIMATE:
+          s = "u";
+          break;
+        case GPGME_VALIDITY_UNKNOWN:
+        default:
+          s = "?";
+          break;
+        }
+    }
+    snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+    snprintf (dest, destlen, fmt, s ? *s : 'B');
+    break;
+  case 'p':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (dest, destlen, fmt,
+              gpgme_get_protocol_name (key->kobj->protocol));
+    break;
 
-    default:
-      *dest = '\0';
+  default:
+    *dest = '\0';
   }
 
   if (optional)
@@ -2513,18 +2350,18 @@ static const char *crypt_entry_fmt (char *dest,
     mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
   return (src);
 }
-      
+
 /* Used by the display fucntion to format a line. */
 static void crypt_entry (char *s, size_t l, MUTTMENU * menu, int num)
 {
   crypt_key_t **key_table = (crypt_key_t **) menu->data;
   crypt_entry_t entry;
-  
+
   entry.key = key_table[num];
   entry.num = num + 1;
 
-  mutt_FormatString (s, l, NONULL (PgpEntryFormat), crypt_entry_fmt, 
-                    (unsigned long) &entry, M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, l, NONULL (PgpEntryFormat), crypt_entry_fmt,
+                     (unsigned long) &entry, M_FORMAT_ARROWCURSOR);
 }
 
 /* Compare two addresses and the keyid to be used for sorting. */
@@ -2543,7 +2380,7 @@ static int _crypt_compare_address (const void *a, const void *b)
 static int crypt_compare_address (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_crypt_compare_address (a, b)
-                                         :  _crypt_compare_address (a, b));
+          : _crypt_compare_address (a, b));
 }
 
 
@@ -2563,7 +2400,7 @@ static int _crypt_compare_keyid (const void *a, const void *b)
 static int crypt_compare_keyid (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_crypt_compare_keyid (a, b)
-                                        :  _crypt_compare_keyid (a, b));
+          : _crypt_compare_keyid (a, b));
 }
 
 /* Compare 2 creation dates and the addresses.  For sorting. */
@@ -2589,7 +2426,7 @@ static int _crypt_compare_date (const void *a, const void *b)
 static int crypt_compare_date (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_crypt_compare_date (a, b)
-                                         :  _crypt_compare_date (a, b));
+          : _crypt_compare_date (a, b));
 }
 
 /* Compare two trust values, the key length, the creation dates. the
@@ -2602,7 +2439,7 @@ static int _crypt_compare_trust (const void *a, const void *b)
   int r;
 
   if ((r = (((*s)->flags & (KEYFLAG_RESTRICTIONS))
-           - ((*t)->flags & (KEYFLAG_RESTRICTIONS)))))
+            - ((*t)->flags & (KEYFLAG_RESTRICTIONS)))))
     return r > 0;
 
   if ((*s)->kobj->uids)
@@ -2636,152 +2473,135 @@ static int _crypt_compare_trust (const void *a, const void *b)
 static int crypt_compare_trust (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_crypt_compare_trust (a, b)
-                                      : _crypt_compare_trust (a, b));
+          : _crypt_compare_trust (a, b));
 }
 
 /* Print the X.500 Distinguished Name part KEY from the array of parts
    DN to FP. */
-static int
-print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key)
+static int print_dn_part (FILE * fp, struct dn_array_s *dn, const char *key)
 {
   int any = 0;
 
-  for (; dn->key; dn++)
-    {
-      if (!strcmp (dn->key, key))
-        {
-          if (any)
-            fputs (" + ", fp);
-          print_utf8 (fp, dn->value, strlen (dn->value));
-          any = 1;
-        }
+  for (; dn->key; dn++) {
+    if (!strcmp (dn->key, key)) {
+      if (any)
+        fputs (" + ", fp);
+      print_utf8 (fp, dn->value, strlen (dn->value));
+      any = 1;
     }
+  }
   return any;
 }
 
 /* Print all parts of a DN in a standard sequence. */
-static void
-print_dn_parts (FILE *fp, struct dn_array_s *dn)
+static void print_dn_parts (FILE * fp, struct dn_array_s *dn)
 {
   const char *stdpart[] = {
-    "CN", "OU", "O", "STREET", "L", "ST", "C", NULL 
+    "CN", "OU", "O", "STREET", "L", "ST", "C", NULL
   };
-  int any=0, any2=0, i;
-  
-  for (i=0; stdpart[i]; i++)
-    {
+  int any = 0, any2 = 0, i;
+
+  for (i = 0; stdpart[i]; i++) {
+    if (any)
+      fputs (", ", fp);
+    any = print_dn_part (fp, dn, stdpart[i]);
+  }
+  /* now print the rest without any specific ordering */
+  for (; dn->key; dn++) {
+    for (i = 0; stdpart[i]; i++) {
+      if (!strcmp (dn->key, stdpart[i]))
+        break;
+    }
+    if (!stdpart[i]) {
       if (any)
         fputs (", ", fp);
-      any = print_dn_part (fp, dn, stdpart[i]);
-    }
-  /* now print the rest without any specific ordering */
-  for (; dn->key; dn++)
-    {
-      for (i=0; stdpart[i]; i++)
-        {
-          if (!strcmp (dn->key, stdpart[i]))
-            break;
-        }
-      if (!stdpart[i])
-        {
-          if (any)
-            fputs (", ", fp);
-          if (!any2)
-            fputs ("(", fp);
-          any = print_dn_part (fp, dn, dn->key);
-          any2 = 1;
-        }
+      if (!any2)
+        fputs ("(", fp);
+      any = print_dn_part (fp, dn, dn->key);
+      any2 = 1;
     }
+  }
   if (any2)
     fputs (")", fp);
 }
 
 
 /* Parse an RDN; this is a helper to parse_dn(). */
-static const unsigned char *
-parse_dn_part (struct dn_array_s *array, const unsigned char *string)
+static const unsigned char *parse_dn_part (struct dn_array_s *array,
+                                           const unsigned char *string)
 {
   const unsigned char *s, *s1;
   size_t n;
   unsigned char *p;
 
   /* parse attributeType */
-  for (s = string+1; *s && *s != '='; s++)
-    ;
+  for (s = string + 1; *s && *s != '='; s++);
   if (!*s)
-    return NULL; /* error */
+    return NULL;                /* error */
   n = s - string;
   if (!n)
-    return NULL; /* empty key */
-  array->key = safe_malloc (n+1);
-  p = (unsigned char *)array->key;
-  memcpy (p, string, n); /* fixme: trim trailing spaces */
+    return NULL;                /* empty key */
+  array->key = safe_malloc (n + 1);
+  p = (unsigned char *) array->key;
+  memcpy (p, string, n);        /* fixme: trim trailing spaces */
   p[n] = 0;
   string = s + 1;
 
-  if (*string == '#')
-    { /* hexstring */
-      string++;
-      for (s=string; hexdigitp (s); s++)
+  if (*string == '#') {         /* hexstring */
+    string++;
+    for (s = string; hexdigitp (s); s++)
+      s++;
+    n = s - string;
+    if (!n || (n & 1))
+      return NULL;              /* empty or odd number of digits */
+    n /= 2;
+    p = safe_malloc (n + 1);
+    array->value = (char *) p;
+    for (s1 = string; n; s1 += 2, n--)
+      *p++ = xtoi_2 (s1);
+    *p = 0;
+  }
+  else {                        /* regular v3 quoted string */
+    for (n = 0, s = string; *s; s++) {
+      if (*s == '\\') {         /* pair */
         s++;
-      n = s - string;
-      if (!n || (n & 1))
-        return NULL; /* empty or odd number of digits */
-      n /= 2;
-      p = safe_malloc (n+1);
-      array->value = (char*)p;
-      for (s1=string; n; s1 += 2, n--)
-        *p++ = xtoi_2 (s1);
-      *p = 0;
-   }
-  else
-    { /* regular v3 quoted string */
-      for (n=0, s=string; *s; s++)
-        {
-          if (*s == '\\')
-            { /* pair */
-              s++;
-              if (*s == ',' || *s == '=' || *s == '+'
-                  || *s == '<' || *s == '>' || *s == '#' || *s == ';' 
-                  || *s == '\\' || *s == '\"' || *s == ' ')
-                n++;
-              else if (hexdigitp (s) && hexdigitp (s+1))
-                {
-                  s++;
-                  n++;
-                }
-              else
-                return NULL; /* invalid escape sequence */
-            }
-          else if (*s == '\"')
-            return NULL; /* invalid encoding */
-          else if (*s == ',' || *s == '=' || *s == '+'
-                   || *s == '<' || *s == '>' || *s == '#' || *s == ';' )
-            break; 
-          else
-            n++;
+        if (*s == ',' || *s == '=' || *s == '+'
+            || *s == '<' || *s == '>' || *s == '#' || *s == ';'
+            || *s == '\\' || *s == '\"' || *s == ' ')
+          n++;
+        else if (hexdigitp (s) && hexdigitp (s + 1)) {
+          s++;
+          n++;
         }
+        else
+          return NULL;          /* invalid escape sequence */
+      }
+      else if (*s == '\"')
+        return NULL;            /* invalid encoding */
+      else if (*s == ',' || *s == '=' || *s == '+'
+               || *s == '<' || *s == '>' || *s == '#' || *s == ';')
+        break;
+      else
+        n++;
+    }
 
-      p = safe_malloc (n+1);
-      array->value = (char*)p;
-      for (s=string; n; s++, n--)
-        {
-          if (*s == '\\')
-            { 
-              s++;
-              if (hexdigitp (s))
-                {
-                  *p++ = xtoi_2 (s);
-                  s++;
-                }
-              else
-                *p++ = *s;
-            }
-          else
-            *p++ = *s;
+    p = safe_malloc (n + 1);
+    array->value = (char *) p;
+    for (s = string; n; s++, n--) {
+      if (*s == '\\') {
+        s++;
+        if (hexdigitp (s)) {
+          *p++ = xtoi_2 (s);
+          s++;
         }
-      *p = 0;
+        else
+          *p++ = *s;
+      }
+      else
+        *p++ = *s;
     }
+    *p = 0;
+  }
   return s;
 }
 
@@ -2789,59 +2609,54 @@ parse_dn_part (struct dn_array_s *array, const unsigned char *string)
 /* Parse a DN and return an array-ized one.  This is not a validating
    parser and it does not support any old-stylish syntax; gpgme is
    expected to return only rfc2253 compatible strings. */
-static struct dn_array_s *
-parse_dn (const unsigned char *string)
+static struct dn_array_s *parse_dn (const unsigned char *string)
 {
   struct dn_array_s *array;
   size_t arrayidx, arraysize;
   int i;
 
-  arraysize = 7; /* C,ST,L,O,OU,CN,email */
-  array = safe_malloc ((arraysize+1) * sizeof *array);
+  arraysize = 7;                /* C,ST,L,O,OU,CN,email */
+  array = safe_malloc ((arraysize + 1) * sizeof *array);
   arrayidx = 0;
-  while (*string)
-    {
-      while (*string == ' ')
-        string++;
-      if (!*string)
-        break; /* ready */
-      if (arrayidx >= arraysize)
-        { /* mutt lacks a real safe_realoc - so we need to copy */
-          struct dn_array_s *a2;
-
-          arraysize += 5;
-          a2 = safe_malloc ((arraysize+1) * sizeof *array);
-          for (i=0; i < arrayidx; i++)
-            {
-              a2[i].key = array[i].key;
-              a2[i].value = array[i].value;
-            }
-          FREE (&array);
-          array = a2;
-        }
-      array[arrayidx].key = NULL;
-      array[arrayidx].value = NULL;
-      string = parse_dn_part (array+arrayidx, string);
-      arrayidx++;
-      if (!string)
-        goto failure;
-      while (*string == ' ')
-        string++;
-      if (*string && *string != ',' && *string != ';' && *string != '+')
-        goto failure; /* invalid delimiter */
-      if (*string)
-        string++;
-    }
+  while (*string) {
+    while (*string == ' ')
+      string++;
+    if (!*string)
+      break;                    /* ready */
+    if (arrayidx >= arraysize) {        /* mutt lacks a real safe_realoc - so we need to copy */
+      struct dn_array_s *a2;
+
+      arraysize += 5;
+      a2 = safe_malloc ((arraysize + 1) * sizeof *array);
+      for (i = 0; i < arrayidx; i++) {
+        a2[i].key = array[i].key;
+        a2[i].value = array[i].value;
+      }
+      FREE (&array);
+      array = a2;
+    }
+    array[arrayidx].key = NULL;
+    array[arrayidx].value = NULL;
+    string = parse_dn_part (array + arrayidx, string);
+    arrayidx++;
+    if (!string)
+      goto failure;
+    while (*string == ' ')
+      string++;
+    if (*string && *string != ',' && *string != ';' && *string != '+')
+      goto failure;             /* invalid delimiter */
+    if (*string)
+      string++;
+  }
   array[arrayidx].key = NULL;
   array[arrayidx].value = NULL;
   return array;
 
- failure:
-  for (i=0; i < arrayidx; i++)
-    {
-      FREE (&array[i].key);
-      FREE (&array[i].value);
-    }
+failure:
+  for (i = 0; i < arrayidx; i++) {
+    FREE (&array[i].key);
+    FREE (&array[i].value);
+  }
   FREE (&array);
   return NULL;
 }
@@ -2851,82 +2666,74 @@ parse_dn (const unsigned char *string)
    displayed in a proper way, which does mean to reorder some parts
    for S/MIME's DNs.  USERID is a string as returned by the gpgme key
    functions.  It is utf-8 encoded. */
-static void
-parse_and_print_user_id (FILE *fp, const char *userid)
+static void parse_and_print_user_id (FILE * fp, const char *userid)
 {
   const char *s;
   int i;
 
-  if (*userid == '<')
-    {
-      s = strchr (userid+1, '>');
-      if (s)
-        print_utf8 (fp, userid+1, s-userid-1);
-    }
+  if (*userid == '<') {
+    s = strchr (userid + 1, '>');
+    if (s)
+      print_utf8 (fp, userid + 1, s - userid - 1);
+  }
   else if (*userid == '(')
     fputs (_("[Can't display this user ID (unknown encoding)]"), fp);
-  else if (!digit_or_letter ((const unsigned char *)userid))
+  else if (!digit_or_letter ((const unsigned char *) userid))
     fputs (_("[Can't display this user ID (invalid encoding)]"), fp);
-  else
-    {
-      struct dn_array_s *dn = parse_dn ((const unsigned char *)userid);
-      if (!dn)
-        fputs (_("[Can't display this user ID (invalid DN)]"), fp);
-      else 
-        {
-          print_dn_parts (fp, dn);          
-          for (i=0; dn[i].key; i++)
-            {
-              FREE (&dn[i].key);
-              FREE (&dn[i].value);
-            }
-          FREE (&dn);
-        }
+  else {
+    struct dn_array_s *dn = parse_dn ((const unsigned char *) userid);
+
+    if (!dn)
+      fputs (_("[Can't display this user ID (invalid DN)]"), fp);
+    else {
+      print_dn_parts (fp, dn);
+      for (i = 0; dn[i].key; i++) {
+        FREE (&dn[i].key);
+        FREE (&dn[i].value);
+      }
+      FREE (&dn);
     }
+  }
 }
 
-typedef enum
-  {
-    KEY_CAP_CAN_ENCRYPT,
-    KEY_CAP_CAN_SIGN,
-    KEY_CAP_CAN_CERTIFY
-  }
-key_cap_t;
+typedef enum {
+  KEY_CAP_CAN_ENCRYPT,
+  KEY_CAP_CAN_SIGN,
+  KEY_CAP_CAN_CERTIFY
+} key_cap_t;
 
-static unsigned int
-key_check_cap (gpgme_key_t key, key_cap_t cap)
+static unsigned int key_check_cap (gpgme_key_t key, key_cap_t cap)
 {
   gpgme_subkey_t subkey = NULL;
   unsigned int ret = 0;
 
-  switch (cap)
-    {
-    case KEY_CAP_CAN_ENCRYPT:
-      if (! (ret = key->can_encrypt))
-       for (subkey = key->subkeys; subkey; subkey = subkey->next)
-         if ((ret = subkey->can_encrypt))
-           break;
-      break;
-    case KEY_CAP_CAN_SIGN:
-      if (! (ret = key->can_sign))
-       for (subkey = key->subkeys; subkey; subkey = subkey->next)
-         if ((ret = subkey->can_sign))
-           break;
-      break;
-    case KEY_CAP_CAN_CERTIFY:
-      if (! (ret = key->can_certify))
-       for (subkey = key->subkeys; subkey; subkey = subkey->next)
-         if ((ret = subkey->can_certify))
-           break;
-      break;
-    }
+  switch (cap) {
+  case KEY_CAP_CAN_ENCRYPT:
+    if (!(ret = key->can_encrypt))
+      for (subkey = key->subkeys; subkey; subkey = subkey->next)
+        if ((ret = subkey->can_encrypt))
+          break;
+    break;
+  case KEY_CAP_CAN_SIGN:
+    if (!(ret = key->can_sign))
+      for (subkey = key->subkeys; subkey; subkey = subkey->next)
+        if ((ret = subkey->can_sign))
+          break;
+    break;
+  case KEY_CAP_CAN_CERTIFY:
+    if (!(ret = key->can_certify))
+      for (subkey = key->subkeys; subkey; subkey = subkey->next)
+        if ((ret = subkey->can_certify))
+          break;
+    break;
+  }
 
   return ret;
 }
 
 
 /* Print verbose information about a key or certificate to FP. */
-static void print_key_info (gpgme_key_t key, FILE *fp)
+static void print_key_info (gpgme_key_t key, FILE * fp)
 {
   int idx;
   const char *s = NULL, *s2 = NULL;
@@ -2944,50 +2751,46 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
   is_pgp = key->protocol == GPGME_PROTOCOL_OpenPGP;
 
-  for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
-    {
-      if (uid->revoked)
-        continue;
+  for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) {
+    if (uid->revoked)
+      continue;
 
-      s = uid->uid;
-      fprintf (fp, "%s ......: ", idx ? _(" aka") :_("Name"));
-      if (uid->invalid)
-        {
-          fputs (_("[Invalid]"), fp);
-          putc (' ', fp);
-        }
-      if (is_pgp)
-        print_utf8 (fp, s, strlen(s));
-      else
-        parse_and_print_user_id (fp, s);
-      putc ('\n', fp);
+    s = uid->uid;
+    fprintf (fp, "%s ......: ", idx ? _(" aka") : _("Name"));
+    if (uid->invalid) {
+      fputs (_("[Invalid]"), fp);
+      putc (' ', fp);
     }
+    if (is_pgp)
+      print_utf8 (fp, s, strlen (s));
+    else
+      parse_and_print_user_id (fp, s);
+    putc ('\n', fp);
+  }
 
-  if (key->subkeys && (key->subkeys->timestamp > 0))
-    {
-      tt = key->subkeys->timestamp;
+  if (key->subkeys && (key->subkeys->timestamp > 0)) {
+    tt = key->subkeys->timestamp;
 
-      tm = localtime (&tt);
+    tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-      strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+    strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
 #else
-      strftime (shortbuf, sizeof shortbuf, "%c", tm);
+    strftime (shortbuf, sizeof shortbuf, "%c", tm);
 #endif
-      fprintf (fp, "Valid From : %s\n", shortbuf);
-    }
-  
-  if (key->subkeys && (key->subkeys->expires > 0))
-    {
-      tt = key->subkeys->expires;
-      
-      tm = localtime (&tt);
+    fprintf (fp, "Valid From : %s\n", shortbuf);
+  }
+
+  if (key->subkeys && (key->subkeys->expires > 0)) {
+    tt = key->subkeys->expires;
+
+    tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-      strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+    strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
 #else
-      strftime (shortbuf, sizeof shortbuf, "%c", tm);
+    strftime (shortbuf, sizeof shortbuf, "%c", tm);
 #endif
-      fprintf (fp, "Valid To ..: %s\n", shortbuf);
-    }
+    fprintf (fp, "Valid To ..: %s\n", shortbuf);
+  }
 
   if (key->subkeys)
     s = gpgme_pubkey_algo_name (key->subkeys->pubkey_algo);
@@ -3004,167 +2807,144 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
   fprintf (fp, "Key Usage .: ");
   delim = "";
 
-  if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
-    {
-      fprintf (fp, "%s%s", delim, _("encryption"));
-      delim = ", ";
-    }
-  if (key_check_cap (key, KEY_CAP_CAN_SIGN))
-    {
-      fprintf (fp, "%s%s", delim, _("signing"));
-      delim = ", ";
-    }
-  if (key_check_cap (key, KEY_CAP_CAN_CERTIFY))
-    {
-      fprintf (fp, "%s%s", delim, _("certification"));
-      delim = ", ";
-    }
+  if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT)) {
+    fprintf (fp, "%s%s", delim, _("encryption"));
+    delim = ", ";
+  }
+  if (key_check_cap (key, KEY_CAP_CAN_SIGN)) {
+    fprintf (fp, "%s%s", delim, _("signing"));
+    delim = ", ";
+  }
+  if (key_check_cap (key, KEY_CAP_CAN_CERTIFY)) {
+    fprintf (fp, "%s%s", delim, _("certification"));
+    delim = ", ";
+  }
   putc ('\n', fp);
 
-  if (key->subkeys)
-    {
-      s = key->subkeys->fpr;
-      fputs (_("Fingerprint: "), fp);
-      if (is_pgp && strlen (s) == 40)
-        {
-          for (i=0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
-            {
-              putc (*s, fp);
-              putc (s[1], fp);
-              putc (s[2], fp);
-              putc (s[3], fp);
-              putc (is_pgp? ' ':':', fp);
-              if (is_pgp && i == 4)
-                putc (' ', fp);
-            }
-        }
-      else
-        {
-          for (i=0; *s && s[1] && s[2]; s += 2, i++)
-            {
-              putc (*s, fp);
-              putc (s[1], fp);
-              putc (is_pgp? ' ':':', fp);
-              if (is_pgp && i == 7)
-                putc (' ', fp);
-            }
-        }
-      fprintf (fp, "%s\n", s);
+  if (key->subkeys) {
+    s = key->subkeys->fpr;
+    fputs (_("Fingerprint: "), fp);
+    if (is_pgp && strlen (s) == 40) {
+      for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
+        putc (*s, fp);
+        putc (s[1], fp);
+        putc (s[2], fp);
+        putc (s[3], fp);
+        putc (is_pgp ? ' ' : ':', fp);
+        if (is_pgp && i == 4)
+          putc (' ', fp);
+      }
     }
-
-  if (key->issuer_serial)
-    {
-      s = key->issuer_serial;
-      if (s)
-       fprintf (fp, "Serial-No .: 0x%s\n", s);
+    else {
+      for (i = 0; *s && s[1] && s[2]; s += 2, i++) {
+        putc (*s, fp);
+        putc (s[1], fp);
+        putc (is_pgp ? ' ' : ':', fp);
+        if (is_pgp && i == 7)
+          putc (' ', fp);
+      }
     }
+    fprintf (fp, "%s\n", s);
+  }
 
-  if (key->issuer_name)
-    {
-      s = key->issuer_name;
-      if (s)
-       {
-         fprintf (fp, "Issued By .: ");
-         parse_and_print_user_id (fp, s);
-         putc ('\n', fp);
-       }
+  if (key->issuer_serial) {
+    s = key->issuer_serial;
+    if (s)
+      fprintf (fp, "Serial-No .: 0x%s\n", s);
+  }
+
+  if (key->issuer_name) {
+    s = key->issuer_name;
+    if (s) {
+      fprintf (fp, "Issued By .: ");
+      parse_and_print_user_id (fp, s);
+      putc ('\n', fp);
     }
+  }
 
   /* For PGP we list all subkeys. */
-  if (is_pgp)
-    {
-      gpgme_subkey_t subkey = NULL;
-
-      for (idx = 1, subkey = key->subkeys; subkey;
-           idx++, subkey = subkey->next)
-        {
-         s = subkey->keyid;
-         
-          putc ('\n', fp);
-          if ( strlen (s) == 16)
-            s += 8; /* display only the short keyID */
-          fprintf (fp, "Subkey ....: 0x%s", s);
-         if (subkey->revoked)
-            {
-              putc (' ', fp);
-              fputs (_("[Revoked]"), fp);
-            }
-         if (subkey->invalid)
-            {
-              putc (' ', fp);
-              fputs (_("[Invalid]"), fp);
-            }
-         if (subkey->expired)
-            {
-              putc (' ', fp);
-              fputs (_("[Expired]"), fp);
-            }
-         if (subkey->disabled)
-            {
-              putc (' ', fp);
-              fputs (_("[Disabled]"), fp);
-            }
-          putc ('\n', fp);
+  if (is_pgp) {
+    gpgme_subkey_t subkey = NULL;
+
+    for (idx = 1, subkey = key->subkeys; subkey; idx++, subkey = subkey->next) {
+      s = subkey->keyid;
+
+      putc ('\n', fp);
+      if (strlen (s) == 16)
+        s += 8;                 /* display only the short keyID */
+      fprintf (fp, "Subkey ....: 0x%s", s);
+      if (subkey->revoked) {
+        putc (' ', fp);
+        fputs (_("[Revoked]"), fp);
+      }
+      if (subkey->invalid) {
+        putc (' ', fp);
+        fputs (_("[Invalid]"), fp);
+      }
+      if (subkey->expired) {
+        putc (' ', fp);
+        fputs (_("[Expired]"), fp);
+      }
+      if (subkey->disabled) {
+        putc (' ', fp);
+        fputs (_("[Disabled]"), fp);
+      }
+      putc ('\n', fp);
 
-         if (subkey->timestamp > 0)
-           {
-             tt = subkey->timestamp;
+      if (subkey->timestamp > 0) {
+        tt = subkey->timestamp;
 
-              tm = localtime (&tt);
+        tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-              strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+        strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
 #else
-              strftime (shortbuf, sizeof shortbuf, "%c", tm);
+        strftime (shortbuf, sizeof shortbuf, "%c", tm);
 #endif
-              fprintf (fp, "Valid From : %s\n", shortbuf);
-            }
+        fprintf (fp, "Valid From : %s\n", shortbuf);
+      }
 
-         if (subkey->expires > 0)
-           {
-             tt = subkey->expires;
+      if (subkey->expires > 0) {
+        tt = subkey->expires;
 
-              tm = localtime (&tt);
+        tm = localtime (&tt);
 #ifdef HAVE_LANGINFO_D_T_FMT
-              strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
+        strftime (shortbuf, sizeof shortbuf, nl_langinfo (D_T_FMT), tm);
 #else
-              strftime (shortbuf, sizeof shortbuf, "%c", tm);
+        strftime (shortbuf, sizeof shortbuf, "%c", tm);
 #endif
-              fprintf (fp, "Valid To ..: %s\n", shortbuf);
-            }
+        fprintf (fp, "Valid To ..: %s\n", shortbuf);
+      }
 
-         if (subkey)
-           s = gpgme_pubkey_algo_name (subkey->pubkey_algo);
-         else
-            s = "?";
+      if (subkey)
+        s = gpgme_pubkey_algo_name (subkey->pubkey_algo);
+      else
+        s = "?";
 
-         if (subkey)
-           aval = subkey->length;
-         else
-           aval = 0;
+      if (subkey)
+        aval = subkey->length;
+      else
+        aval = 0;
 
-          fprintf (fp, "Key Type ..: %s, %lu bit %s\n", "PGP", aval, s);
+      fprintf (fp, "Key Type ..: %s, %lu bit %s\n", "PGP", aval, s);
 
-          fprintf (fp, "Key Usage .: ");
-          delim = "";
+      fprintf (fp, "Key Usage .: ");
+      delim = "";
 
-         if (subkey->can_encrypt)
-            {
-              fprintf (fp, "%s%s", delim, _("encryption"));
-              delim = ", ";
-            }
-          if (subkey->can_sign)
-            {
-              fprintf (fp, "%s%s", delim, _("signing"));
-              delim = ", ";
-            }
-          if (subkey->can_certify)
-            {
-              fprintf (fp, "%s%s", delim, _("certification"));
-              delim = ", ";
-            }
-          putc ('\n', fp);
-        }
+      if (subkey->can_encrypt) {
+        fprintf (fp, "%s%s", delim, _("encryption"));
+        delim = ", ";
+      }
+      if (subkey->can_sign) {
+        fprintf (fp, "%s%s", delim, _("signing"));
+        delim = ", ";
+      }
+      if (subkey->can_certify) {
+        fprintf (fp, "%s%s", delim, _("certification"));
+        delim = ", ";
+      }
+      putc ('\n', fp);
     }
+  }
 
   if (Locale)
     setlocale (LC_TIME, "C");
@@ -3172,8 +2952,7 @@ static void print_key_info (gpgme_key_t key, FILE *fp)
 
 
 /* Show detailed information about the selected key */
-static void 
-verify_key (crypt_key_t *key)
+static void verify_key (crypt_key_t * key)
 {
   FILE *fp;
   char cmd[LONG_STRING], tempfile[_POSIX_PATH_MAX];
@@ -3184,59 +2963,53 @@ verify_key (crypt_key_t *key)
   int maxdepth = 100;
 
   mutt_mktemp (tempfile);
-  if (!(fp = safe_fopen (tempfile, "w")))
-    {
-      mutt_perror _("Can't create temporary file");
-      return;
-    }
+  if (!(fp = safe_fopen (tempfile, "w"))) {
+    mutt_perror _("Can't create temporary file");
+
+    return;
+  }
   mutt_message _("Collecting data...");
 
   print_key_info (key->kobj, fp);
 
   err = gpgme_new (&listctx);
-  if (err)
-    {
-      fprintf (fp, "Internal error: can't create gpgme context: %s\n",
-               gpgme_strerror (err));
-      goto leave;
-    }
+  if (err) {
+    fprintf (fp, "Internal error: can't create gpgme context: %s\n",
+             gpgme_strerror (err));
+    goto leave;
+  }
   if ((key->flags & KEYFLAG_ISX509))
-      gpgme_set_protocol (listctx, GPGME_PROTOCOL_CMS);
+    gpgme_set_protocol (listctx, GPGME_PROTOCOL_CMS);
 
   k = key->kobj;
   gpgme_key_ref (k);
-  while ((s = k->chain_id) && k->subkeys && strcmp (s, k->subkeys->fpr) )
-    {
-      putc ('\n', fp);
-      err = gpgme_op_keylist_start (listctx, s, 0);
-      gpgme_key_release (k);
-      k = NULL;
-      if (!err)
-       err = gpgme_op_keylist_next (listctx, &k);
-      if (err)
-        {
-          fprintf (fp, _("Error finding issuer key: %s\n"),
-                   gpgme_strerror (err));
-          goto leave;
-        }
-      gpgme_op_keylist_end (listctx);
-      
-      print_key_info (k, fp);
-      if (!--maxdepth)
-        {
-          putc ('\n', fp);
-          fputs (_("Error: certification chain to long - stopping here\n"),
-                 fp);
-          break;
-        }
+  while ((s = k->chain_id) && k->subkeys && strcmp (s, k->subkeys->fpr)) {
+    putc ('\n', fp);
+    err = gpgme_op_keylist_start (listctx, s, 0);
+    gpgme_key_release (k);
+    k = NULL;
+    if (!err)
+      err = gpgme_op_keylist_next (listctx, &k);
+    if (err) {
+      fprintf (fp, _("Error finding issuer key: %s\n"), gpgme_strerror (err));
+      goto leave;
+    }
+    gpgme_op_keylist_end (listctx);
+
+    print_key_info (k, fp);
+    if (!--maxdepth) {
+      putc ('\n', fp);
+      fputs (_("Error: certification chain to long - stopping here\n"), fp);
+      break;
     }
+  }
 
- leave:
+leave:
   gpgme_key_release (k);
   gpgme_release (listctx);
   fclose (fp);
   mutt_clear_error ();
-  snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"),  crypt_keyid (key));
+  snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), crypt_keyid (key));
   mutt_do_pager (cmd, tempfile, 0, NULL);
 }
 
@@ -3248,7 +3021,7 @@ verify_key (crypt_key_t *key)
 /* Convert LIST into a pattern string suitable to be passed to GPGME.
    We need to convert spaces in an item into a '+' and '%' into
    "%25". */
-static char *list_to_pattern (LIST *list)
+static char *list_to_pattern (LIST * list)
 {
   LIST *l;
   char *pattern, *p;
@@ -3256,53 +3029,47 @@ static char *list_to_pattern (LIST *list)
   size_t n;
 
   n = 0;
-  for(l=list; l; l = l->next)
-    {
-      for(s = l->data; *s; s++)
-        {
-          if (*s == '%')
-            n += 2;
-          n++;
-        }
-      n++; /* delimiter or end of string */
+  for (l = list; l; l = l->next) {
+    for (s = l->data; *s; s++) {
+      if (*s == '%')
+        n += 2;
+      n++;
     }
-  n++; /* make sure to allocate at least one byte */
-  pattern = p = safe_calloc (1,n);
-  for(l=list; l; l = l->next)
-    {
-      s = l->data;
-      if (*s)
-        {
-          if (l != list)
-            *p++ = ' ';
-          for(s = l->data; *s; s++)
-            {
-              if (*s == '%')
-                {
-                  *p++ = '%';
-                  *p++ = '2';
-                  *p++ = '5';
-                }
-              else if (*s == '+')
-                {
-                  *p++ = '%';
-                  *p++ = '2';
-                  *p++ = 'B';
-                }
-              else if (*s == ' ')
-                *p++ = '+';
-              else
-                *p++ = *s;
-            }
+    n++;                        /* delimiter or end of string */
+  }
+  n++;                          /* make sure to allocate at least one byte */
+  pattern = p = safe_calloc (1, n);
+  for (l = list; l; l = l->next) {
+    s = l->data;
+    if (*s) {
+      if (l != list)
+        *p++ = ' ';
+      for (s = l->data; *s; s++) {
+        if (*s == '%') {
+          *p++ = '%';
+          *p++ = '2';
+          *p++ = '5';
+        }
+        else if (*s == '+') {
+          *p++ = '%';
+          *p++ = '2';
+          *p++ = 'B';
         }
+        else if (*s == ' ')
+          *p++ = '+';
+        else
+          *p++ = *s;
+      }
     }
+  }
   *p = 0;
   return pattern;
 }
 
 /* Return a list of keys which are candidates for the selection.
    Select by looking at the HINTS list. */
-static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
+static crypt_key_t *get_candidates (LIST * hints, unsigned int app,
+                                    int secret)
 {
   crypt_key_t *db, *k, **kend;
   char *pattern;
@@ -3315,143 +3082,128 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
   pattern = list_to_pattern (hints);
   if (!pattern)
     return NULL;
-  
+
   err = gpgme_new (&ctx);
-  if (err) 
-    {
-      mutt_error ("gpgme_new failed: %s", gpgme_strerror (err));
+  if (err) {
+    mutt_error ("gpgme_new failed: %s", gpgme_strerror (err));
+    FREE (&pattern);
+    return NULL;
+  }
+
+  db = NULL;
+  kend = &db;
+
+  if ((app & APPLICATION_PGP)) {
+    /* Its all a mess.  That old GPGME expects different things
+       depending on the protocol.  For gpg we don' t need percent
+       escaped pappert but simple strings passed in an array to the
+       keylist_ext_start function. */
+    LIST *l;
+    size_t n;
+    char **patarr;
+
+    for (l = hints, n = 0; l; l = l->next) {
+      if (l->data && *l->data)
+        n++;
+    }
+    if (!n)
+      goto no_pgphints;
+
+    patarr = safe_calloc (n + 1, sizeof *patarr);
+    for (l = hints, n = 0; l; l = l->next) {
+      if (l->data && *l->data)
+        patarr[n++] = safe_strdup (l->data);
+    }
+    patarr[n] = NULL;
+    err = gpgme_op_keylist_ext_start (ctx, (const char **) patarr, secret, 0);
+    for (n = 0; patarr[n]; n++)
+      FREE (&patarr[n]);
+    FREE (&patarr);
+    if (err) {
+      mutt_error ("gpgme_op_keylist_start failed: %s", gpgme_strerror (err));
+      gpgme_release (ctx);
       FREE (&pattern);
       return NULL;
     }
 
-  db = NULL;
-  kend = &db;
-  
-  if ((app & APPLICATION_PGP))
-    {
-      /* Its all a mess.  That old GPGME expects different things
-         depending on the protocol.  For gpg we don' t need percent
-         escaped pappert but simple strings passed in an array to the
-         keylist_ext_start function. */
-      LIST *l;
-      size_t n;
-      char **patarr;
-
-      for(l=hints, n=0; l; l = l->next)
-        {
-          if (l->data && *l->data)
-            n++;
-        }
-      if (!n)
-        goto no_pgphints;
-
-      patarr = safe_calloc (n+1, sizeof *patarr);
-      for(l=hints, n=0; l; l = l->next)
-        {
-          if (l->data && *l->data)
-            patarr[n++] = safe_strdup (l->data);
-        }
-      patarr[n] = NULL;
-      err = gpgme_op_keylist_ext_start (ctx, (const char**)patarr, secret, 0);
-      for (n=0; patarr[n]; n++)
-        FREE (&patarr[n]);
-      FREE (&patarr);
-      if (err) 
-        {
-          mutt_error ("gpgme_op_keylist_start failed: %s",
-                      gpgme_strerror (err));
-          gpgme_release (ctx);
-          FREE (&pattern);
-          return NULL;
-        }
+    while (!(err = gpgme_op_keylist_next (ctx, &key))) {
+      unsigned int flags = 0;
 
-      while (!(err = gpgme_op_keylist_next (ctx, &key)) )
-        {
-          unsigned int flags = 0;
-         
-         if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
-            flags |= KEYFLAG_CANENCRYPT;
-         if (key_check_cap (key, KEY_CAP_CAN_SIGN))
-            flags |= KEYFLAG_CANSIGN;
-
-#if 0 /* DISABLED code */
-          if (!flags)
-            {
-             /* Bug in gpg.  Capabilities are not listed for secret
-                keys.  Try to deduce them from the algorithm. */
-
-             switch (key->subkeys[0].pubkey_algo)
-                {
-                case GPGME_PK_RSA:
-                  flags |= KEYFLAG_CANENCRYPT;
-                  flags |= KEYFLAG_CANSIGN;
-                  break;
-                case GPGME_PK_ELG_E:
-                  flags |= KEYFLAG_CANENCRYPT;
-                  break;
-                case GPGME_PK_DSA:
-                  flags |= KEYFLAG_CANSIGN;
-                  break;
-                }
-            }
-#endif /* DISABLED code */
+      if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
+        flags |= KEYFLAG_CANENCRYPT;
+      if (key_check_cap (key, KEY_CAP_CAN_SIGN))
+        flags |= KEYFLAG_CANSIGN;
 
-         for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
-            {
-              k = safe_calloc (1, sizeof *k);
-              k->kobj = key;
-              k->idx = idx;
-              k->uid = uid->uid;
-              k->flags = flags;
-              *kend = k;
-              kend = &k->next;
-            }
+#if 0                           /* DISABLED code */
+      if (!flags) {
+        /* Bug in gpg.  Capabilities are not listed for secret
+           keys.  Try to deduce them from the algorithm. */
+
+        switch (key->subkeys[0].pubkey_algo) {
+        case GPGME_PK_RSA:
+          flags |= KEYFLAG_CANENCRYPT;
+          flags |= KEYFLAG_CANSIGN;
+          break;
+        case GPGME_PK_ELG_E:
+          flags |= KEYFLAG_CANENCRYPT;
+          break;
+        case GPGME_PK_DSA:
+          flags |= KEYFLAG_CANSIGN;
+          break;
         }
-      if (gpg_err_code (err) != GPG_ERR_EOF)
-        mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
-      gpgme_op_keylist_end (ctx);
-    no_pgphints:
-      ;
+      }
+#endif /* DISABLED code */
+
+      for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) {
+        k = safe_calloc (1, sizeof *k);
+        k->kobj = key;
+        k->idx = idx;
+        k->uid = uid->uid;
+        k->flags = flags;
+        *kend = k;
+        kend = &k->next;
+      }
     }
+    if (gpg_err_code (err) != GPG_ERR_EOF)
+      mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
+    gpgme_op_keylist_end (ctx);
+  no_pgphints:
+    ;
+  }
 
-  if ((app & APPLICATION_SMIME))
-    {
-      /* and now look for x509 certificates */
-      gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
-      err = gpgme_op_keylist_start (ctx, pattern, 0);
-      if (err) 
-        {
-          mutt_error ("gpgme_op_keylist_start failed: %s",
-                      gpgme_strerror (err));
-          gpgme_release (ctx);
-          FREE (&pattern);
-          return NULL;
-        }
+  if ((app & APPLICATION_SMIME)) {
+    /* and now look for x509 certificates */
+    gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+    err = gpgme_op_keylist_start (ctx, pattern, 0);
+    if (err) {
+      mutt_error ("gpgme_op_keylist_start failed: %s", gpgme_strerror (err));
+      gpgme_release (ctx);
+      FREE (&pattern);
+      return NULL;
+    }
 
-      while (!(err = gpgme_op_keylist_next (ctx, &key)) )
-        {
-          unsigned int flags = KEYFLAG_ISX509;
-
-         if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
-            flags |= KEYFLAG_CANENCRYPT;
-         if (key_check_cap (key, KEY_CAP_CAN_SIGN))
-            flags |= KEYFLAG_CANSIGN;
-          
-         for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
-            {
-              k = safe_calloc (1, sizeof *k);
-              k->kobj = key;
-              k->idx = idx;
-              k->uid = uid->uid;
-              k->flags = flags;
-              *kend = k;
-              kend = &k->next;
-            }
-        }
-      if (gpg_err_code (err) != GPG_ERR_EOF)
-        mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
-      gpgme_op_keylist_end (ctx);
+    while (!(err = gpgme_op_keylist_next (ctx, &key))) {
+      unsigned int flags = KEYFLAG_ISX509;
+
+      if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT))
+        flags |= KEYFLAG_CANENCRYPT;
+      if (key_check_cap (key, KEY_CAP_CAN_SIGN))
+        flags |= KEYFLAG_CANSIGN;
+
+      for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) {
+        k = safe_calloc (1, sizeof *k);
+        k->kobj = key;
+        k->idx = idx;
+        k->uid = uid->uid;
+        k->flags = flags;
+        *kend = k;
+        kend = &k->next;
+      }
     }
+    if (gpg_err_code (err) != GPG_ERR_EOF)
+      mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
+    gpgme_op_keylist_end (ctx);
+  }
 
   gpgme_release (ctx);
   FREE (&pattern);
@@ -3460,7 +3212,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, int secret)
 
 /* Add the string STR to the list HINTS.  This list is later used to
    match addresses. */
-static LIST *crypt_add_string_to_hints (LIST *hints, const char *str)
+static LIST *crypt_add_string_to_hints (LIST * hints, const char *str)
 {
   char *scratch;
   char *t;
@@ -3469,12 +3221,11 @@ static LIST *crypt_add_string_to_hints (LIST *hints, const char *str)
     return hints;
 
   for (t = strtok (scratch, " ,.:\"()<>\n"); t;
-       t = strtok (NULL, " ,.:\"()<>\n"))
-    {
-      if (strlen (t) > 3)
-        hints = mutt_add_list (hints, t);
-    }
-  
+       t = strtok (NULL, " ,.:\"()<>\n")) {
+    if (strlen (t) > 3)
+      hints = mutt_add_list (hints, t);
+  }
+
   FREE (&scratch);
   return hints;
 }
@@ -3482,8 +3233,8 @@ static LIST *crypt_add_string_to_hints (LIST *hints, const char *str)
 /* Display a menu to select a key from the array KEYS. FORCED_VALID
    will be set to true on return if the user did override the the
    key's validity. */
-static crypt_key_t *crypt_select_key (crypt_key_t *keys,
-                                      ADDRESS * p, const char *s, 
+static crypt_key_t *crypt_select_key (crypt_key_t * keys,
+                                      ADDRESS * p, const char *s,
                                       unsigned int app, int *forced_valid)
 {
   int keymax;
@@ -3501,47 +3252,43 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
   /* build the key table */
   keymax = i = 0;
   key_table = NULL;
-  for (k = keys; k; k = k->next)
-    {
-      if (!option (OPTPGPSHOWUNUSABLE) && (k->flags & KEYFLAG_CANTUSE))
-        {
-          unusable = 1;
-          continue;
-        }
-      
-      if (i == keymax)
-        {
-          keymax += 20;
-          safe_realloc (&key_table, sizeof (crypt_key_t*)*keymax);
-        }
-      
-      key_table[i++] = k;
+  for (k = keys; k; k = k->next) {
+    if (!option (OPTPGPSHOWUNUSABLE) && (k->flags & KEYFLAG_CANTUSE)) {
+      unusable = 1;
+      continue;
     }
 
-  if (!i && unusable)
-    {
-      mutt_error _("All matching keys are marked expired/revoked.");
-      mutt_sleep (1);
-      return NULL;
+    if (i == keymax) {
+      keymax += 20;
+      safe_realloc (&key_table, sizeof (crypt_key_t *) * keymax);
     }
 
-  switch (PgpSortKeys & SORT_MASK)
-  {
-    case SORT_DATE:
-      f = crypt_compare_date;
-      break;
-    case SORT_KEYID:
-      f = crypt_compare_keyid;
-      break;
-    case SORT_ADDRESS:
-      f = crypt_compare_address;
-      break;
-    case SORT_TRUST:
-    default:
-      f = crypt_compare_trust;
-      break;
+    key_table[i++] = k;
   }
-  qsort (key_table, i, sizeof (crypt_key_t*), f);
+
+  if (!i && unusable) {
+    mutt_error _("All matching keys are marked expired/revoked.");
+
+    mutt_sleep (1);
+    return NULL;
+  }
+
+  switch (PgpSortKeys & SORT_MASK) {
+  case SORT_DATE:
+    f = crypt_compare_date;
+    break;
+  case SORT_KEYID:
+    f = crypt_compare_keyid;
+    break;
+  case SORT_ADDRESS:
+    f = crypt_compare_address;
+    break;
+  case SORT_TRUST:
+  default:
+    f = crypt_compare_trust;
+    break;
+  }
+  qsort (key_table, i, sizeof (crypt_key_t *), f);
 
   if (app & APPLICATION_PGP)
     menu_to_use = MENU_KEY_SELECT_PGP;
@@ -3550,15 +3297,15 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
 
   helpstr[0] = 0;
   mutt_make_help (buf, sizeof (buf), _("Exit  "), menu_to_use, OP_EXIT);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
   mutt_make_help (buf, sizeof (buf), _("Select  "), menu_to_use,
-                 OP_GENERIC_SELECT_ENTRY);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+                  OP_GENERIC_SELECT_ENTRY);
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
   mutt_make_help (buf, sizeof (buf), _("Check key  "),
                   menu_to_use, OP_VERIFY_KEY);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
   mutt_make_help (buf, sizeof (buf), _("Help"), menu_to_use, OP_HELP);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
 
   menu = mutt_new_menu ();
   menu->max = i;
@@ -3570,7 +3317,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
   {
     const char *ts;
 
-    if ((app & APPLICATION_PGP) && (app &  APPLICATION_SMIME))
+    if ((app & APPLICATION_PGP) && (app & APPLICATION_SMIME))
       ts = _("PGP and S/MIME keys matching");
     else if ((app & APPLICATION_PGP))
       ts = _("PGP keys matching");
@@ -3583,120 +3330,110 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
       snprintf (buf, sizeof (buf), _("%s <%s>."), ts, p->mailbox);
     else
       snprintf (buf, sizeof (buf), _("%s \"%s\"."), ts, s);
-    menu->title = buf; 
+    menu->title = buf;
   }
 
   mutt_clear_error ();
   k = NULL;
-  while (!done)
-    {
-      *forced_valid = 0;
-      switch (mutt_menuLoop (menu))
-        {
-        case OP_VERIFY_KEY:
-          verify_key (key_table[menu->current]);
-          menu->redraw = REDRAW_FULL;
-          break;
-          
-        case OP_VIEW_ID:
-          mutt_message ("%s", key_table[menu->current]->uid);
-          break;
-          
-        case OP_GENERIC_SELECT_ENTRY:
-          /* FIXME make error reporting more verbose - this should be
-             easy because gpgme provides more information */
-          if (option (OPTPGPCHECKTRUST))
-            {
-            if (!crypt_key_is_valid (key_table[menu->current]))
-              {
-                mutt_error _("This key can't be used: "
-                             "expired/disabled/revoked.");
-                break;
-              }
-            }
-          
-          if (option (OPTPGPCHECKTRUST) &&
-              (!crypt_id_is_valid (key_table[menu->current])
-               || !crypt_id_is_strong (key_table[menu->current])))
-            {
-              const char *warn_s;
-              char buff[LONG_STRING];
-              
-              if (key_table[menu->current]->flags & KEYFLAG_CANTUSE)
-                s = N_("ID is expired/disabled/revoked.");
-              else 
-                {
-                 gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
-                 gpgme_user_id_t uid = NULL;
-                 unsigned int j = 0;
-
-                  warn_s = "??";
-
-                 uid = key_table[menu->current]->kobj->uids;
-                 for (j = 0; (j < key_table[menu->current]->idx) && uid;
-                       j++, uid = uid->next)
-                    ;
-                 if (uid)
-                   val = uid->validity;
-
-                  switch (val)
-                    {
-                    case GPGME_VALIDITY_UNKNOWN:   
-                    case GPGME_VALIDITY_UNDEFINED: 
-                      warn_s = N_("ID has undefined validity.");
-                      break;
-                    case GPGME_VALIDITY_NEVER:     
-                      warn_s = N_("ID is not valid.");
-                      break;
-                    case GPGME_VALIDITY_MARGINAL:  
-                      warn_s = N_("ID is only marginally valid.");
-                      break;
-                    case GPGME_VALIDITY_FULL:      
-                    case GPGME_VALIDITY_ULTIMATE:  
-                      break;
-                    }
-
-                  snprintf (buff, sizeof (buff),
-                            _("%s Do you really want to use the key?"),
-                            _(warn_s));
-                 
-                  if (mutt_yesorno (buff, 0) != 1)
-                    {
-                      mutt_clear_error ();
-                      break;
-                    }
-                  *forced_valid = 1;
-                }
-            }  
-
-          k = crypt_copy_key (key_table[menu->current]);
-          done = 1;
-          break;
-          
-        case OP_EXIT:
-          k = NULL;
-          done = 1;
+  while (!done) {
+    *forced_valid = 0;
+    switch (mutt_menuLoop (menu)) {
+    case OP_VERIFY_KEY:
+      verify_key (key_table[menu->current]);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_VIEW_ID:
+      mutt_message ("%s", key_table[menu->current]->uid);
+      break;
+
+    case OP_GENERIC_SELECT_ENTRY:
+      /* FIXME make error reporting more verbose - this should be
+         easy because gpgme provides more information */
+      if (option (OPTPGPCHECKTRUST)) {
+        if (!crypt_key_is_valid (key_table[menu->current])) {
+          mutt_error _("This key can't be used: "
+                       "expired/disabled/revoked.");
           break;
         }
+      }
+
+      if (option (OPTPGPCHECKTRUST) &&
+          (!crypt_id_is_valid (key_table[menu->current])
+           || !crypt_id_is_strong (key_table[menu->current]))) {
+        const char *warn_s;
+        char buff[LONG_STRING];
+
+        if (key_table[menu->current]->flags & KEYFLAG_CANTUSE)
+          s = N_("ID is expired/disabled/revoked.");
+        else {
+          gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
+          gpgme_user_id_t uid = NULL;
+          unsigned int j = 0;
+
+          warn_s = "??";
+
+          uid = key_table[menu->current]->kobj->uids;
+          for (j = 0; (j < key_table[menu->current]->idx) && uid;
+               j++, uid = uid->next);
+          if (uid)
+            val = uid->validity;
+
+          switch (val) {
+          case GPGME_VALIDITY_UNKNOWN:
+          case GPGME_VALIDITY_UNDEFINED:
+            warn_s = N_("ID has undefined validity.");
+            break;
+          case GPGME_VALIDITY_NEVER:
+            warn_s = N_("ID is not valid.");
+            break;
+          case GPGME_VALIDITY_MARGINAL:
+            warn_s = N_("ID is only marginally valid.");
+            break;
+          case GPGME_VALIDITY_FULL:
+          case GPGME_VALIDITY_ULTIMATE:
+            break;
+          }
+
+          snprintf (buff, sizeof (buff),
+                    _("%s Do you really want to use the key?"), _(warn_s));
+
+          if (mutt_yesorno (buff, 0) != 1) {
+            mutt_clear_error ();
+            break;
+          }
+          *forced_valid = 1;
+        }
+      }
+
+      k = crypt_copy_key (key_table[menu->current]);
+      done = 1;
+      break;
+
+    case OP_EXIT:
+      k = NULL;
+      done = 1;
+      break;
     }
-  
+  }
+
   mutt_menuDestroy (&menu);
   FREE (&key_table);
 
   set_option (OPTNEEDREDRAW);
-  
+
   return k;
 }
 
 static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities,
-                                       unsigned int app, int *forced_valid)
+                                        unsigned int app, int *forced_valid)
 {
   ADDRESS *r, *p;
   LIST *hints = NULL;
 
-  int weak    = 0;
+  int weak = 0;
   int invalid = 0;
-  int multi   = 0;
+  int multi = 0;
   int this_key_has_strong;
   int this_key_has_weak;
   int this_key_has_invalid;
@@ -3706,7 +3443,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities,
   crypt_key_t *the_valid_key = NULL;
   crypt_key_t *matches = NULL;
   crypt_key_t **matches_endp = &matches;
-  
+
   *forced_valid = 0;
 
   if (a && a->mailbox)
@@ -3715,110 +3452,102 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities,
     hints = crypt_add_string_to_hints (hints, a->personal);
 
   mutt_message (_("Looking for keys matching \"%s\"..."), a->mailbox);
-  keys = get_candidates (hints, app, (abilities & KEYFLAG_CANSIGN) );
+  keys = get_candidates (hints, app, (abilities & KEYFLAG_CANSIGN));
 
   mutt_free_list (&hints);
-  
+
   if (!keys)
     return NULL;
-  
+
   dprint (5, (debugfile, "crypt_getkeybyaddr: looking for %s <%s>.",
-             a->personal, a->mailbox));
+              a->personal, a->mailbox));
 
-  for (k = keys; k; k = k->next)
-    {
-      dprint (5, (debugfile, "  looking at key: %s `%.15s'\n",
-                  crypt_keyid (k), k->uid));
-      
-      if (abilities && !(k->flags & abilities))
-        {
-          dprint (5, (debugfile, "  insufficient abilities: Has %x, want %x\n",
-                      k->flags, abilities));
-          continue;
-        }
+  for (k = keys; k; k = k->next) {
+    dprint (5, (debugfile, "  looking at key: %s `%.15s'\n",
+                crypt_keyid (k), k->uid));
 
-      this_key_has_weak    = 0;        /* weak but valid match   */
-      this_key_has_invalid = 0;   /* invalid match          */
-      this_key_has_strong  = 0;        /* strong and valid match */
-      match                = 0;   /* any match                   */
-
-      r = rfc822_parse_adrlist (NULL, k->uid);
-      for (p = r; p; p = p->next)
-        {
-          int validity = crypt_id_matches_addr (a, p, k);
-              
-          if (validity & CRYPT_KV_MATCH)       /* something matches */
-            match = 1;
-
-          /* is this key a strong candidate? */
-          if ((validity & CRYPT_KV_VALID)
-              && (validity & CRYPT_KV_STRONGID) 
-              && (validity & CRYPT_KV_ADDR))
-            {
-              if (the_valid_key && the_valid_key != k)
-                multi             = 1;
-              the_valid_key       = k;
-              this_key_has_strong = 1;
-            }
-          else if ((validity & CRYPT_KV_MATCH)
-                   && !(validity & CRYPT_KV_VALID))
-            this_key_has_invalid = 1;
-          else if ((validity & CRYPT_KV_MATCH) 
-                   && (!(validity & CRYPT_KV_STRONGID)
-                       || !(validity & CRYPT_KV_ADDR)))
-            this_key_has_weak    = 1;
-        }
-      rfc822_free_address (&r);
-      
-      if (match)
-        {
-          crypt_key_t *tmp;
-
-          if (!this_key_has_strong && this_key_has_invalid)
-            invalid = 1;
-          if (!this_key_has_strong && this_key_has_weak)
-            weak = 1;
-
-          *matches_endp = tmp = crypt_copy_key (k);
-          matches_endp = &tmp->next;
-         the_valid_key = tmp;
-        }
+    if (abilities && !(k->flags & abilities)) {
+      dprint (5, (debugfile, "  insufficient abilities: Has %x, want %x\n",
+                  k->flags, abilities));
+      continue;
     }
-  
+
+    this_key_has_weak = 0;      /* weak but valid match   */
+    this_key_has_invalid = 0;   /* invalid match          */
+    this_key_has_strong = 0;    /* strong and valid match */
+    match = 0;                  /* any match            */
+
+    r = rfc822_parse_adrlist (NULL, k->uid);
+    for (p = r; p; p = p->next) {
+      int validity = crypt_id_matches_addr (a, p, k);
+
+      if (validity & CRYPT_KV_MATCH)    /* something matches */
+        match = 1;
+
+      /* is this key a strong candidate? */
+      if ((validity & CRYPT_KV_VALID)
+          && (validity & CRYPT_KV_STRONGID)
+          && (validity & CRYPT_KV_ADDR)) {
+        if (the_valid_key && the_valid_key != k)
+          multi = 1;
+        the_valid_key = k;
+        this_key_has_strong = 1;
+      }
+      else if ((validity & CRYPT_KV_MATCH)
+               && !(validity & CRYPT_KV_VALID))
+        this_key_has_invalid = 1;
+      else if ((validity & CRYPT_KV_MATCH)
+               && (!(validity & CRYPT_KV_STRONGID)
+                   || !(validity & CRYPT_KV_ADDR)))
+        this_key_has_weak = 1;
+    }
+    rfc822_free_address (&r);
+
+    if (match) {
+      crypt_key_t *tmp;
+
+      if (!this_key_has_strong && this_key_has_invalid)
+        invalid = 1;
+      if (!this_key_has_strong && this_key_has_weak)
+        weak = 1;
+
+      *matches_endp = tmp = crypt_copy_key (k);
+      matches_endp = &tmp->next;
+      the_valid_key = tmp;
+    }
+  }
+
   crypt_free_key (&keys);
-  
-  if (matches)
-    {
-      if (the_valid_key && !multi && !weak 
-          && !(invalid && option (OPTPGPSHOWUNUSABLE)))
-        {      
-          /* 
-           * There was precisely one strong match on a valid ID, there
-           * were no valid keys with weak matches, and we aren't
-           * interested in seeing invalid keys.
-           * 
-           * Proceed without asking the user.
-           */
-          k = crypt_copy_key (the_valid_key);
-        }
-      else 
-        {
-          /* 
-           * Else: Ask the user.
-           */
-          k = crypt_select_key (matches, a, NULL, app, forced_valid);
-        }
-      crypt_free_key (&matches);
+
+  if (matches) {
+    if (the_valid_key && !multi && !weak
+        && !(invalid && option (OPTPGPSHOWUNUSABLE))) {
+      /* 
+       * There was precisely one strong match on a valid ID, there
+       * were no valid keys with weak matches, and we aren't
+       * interested in seeing invalid keys.
+       * 
+       * Proceed without asking the user.
+       */
+      k = crypt_copy_key (the_valid_key);
     }
-  else 
+    else {
+      /* 
+       * Else: Ask the user.
+       */
+      k = crypt_select_key (matches, a, NULL, app, forced_valid);
+    }
+    crypt_free_key (&matches);
+  }
+  else
     k = NULL;
-  
+
   return k;
 }
 
 
 static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
-                                      unsigned int app, int *forced_valid)
+                                       unsigned int app, int *forced_valid)
 {
   LIST *hints = NULL;
   crypt_key_t *keys;
@@ -3837,43 +3566,39 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
 
   if (!keys)
     return NULL;
-  
-  for (k = keys; k; k = k->next)
-    {
-      if (abilities && !(k->flags & abilities))
-        continue;
 
-      match = 0;
-      dprint (5, (debugfile, "crypt_getkeybystr: matching \"%s\" against "
-                  "key %s, \"%s\": ",  p, crypt_keyid (k), k->uid));
-
-      if (!*p
-          || !mutt_strcasecmp (p, crypt_keyid (k))
-          || (!mutt_strncasecmp (p, "0x", 2)
-              && !mutt_strcasecmp (p + 2, crypt_keyid (k)))
-          || (option (OPTPGPLONGIDS)
-              && !mutt_strncasecmp (p, "0x", 2) 
-              && !mutt_strcasecmp (p + 2, crypt_keyid (k) + 8))
-          || mutt_stristr (k->uid, p))
-        {
-          crypt_key_t *tmp;
-
-          dprint (5, (debugfile, "match.\n"));
-
-          *matches_endp = tmp = crypt_copy_key (k);
-          matches_endp = &tmp->next;
-        }
+  for (k = keys; k; k = k->next) {
+    if (abilities && !(k->flags & abilities))
+      continue;
+
+    match = 0;
+    dprint (5, (debugfile, "crypt_getkeybystr: matching \"%s\" against "
+                "key %s, \"%s\": ", p, crypt_keyid (k), k->uid));
+
+    if (!*p || !mutt_strcasecmp (p, crypt_keyid (k))
+        || (!mutt_strncasecmp (p, "0x", 2)
+            && !mutt_strcasecmp (p + 2, crypt_keyid (k)))
+        || (option (OPTPGPLONGIDS)
+            && !mutt_strncasecmp (p, "0x", 2)
+            && !mutt_strcasecmp (p + 2, crypt_keyid (k) + 8))
+        || mutt_stristr (k->uid, p)) {
+      crypt_key_t *tmp;
+
+      dprint (5, (debugfile, "match.\n"));
+
+      *matches_endp = tmp = crypt_copy_key (k);
+      matches_endp = &tmp->next;
     }
-  
+  }
+
   crypt_free_key (&keys);
-  
-  if (matches)
-    {
-      k = crypt_select_key (matches, NULL, p, app, forced_valid);
-      crypt_free_key (&matches);
-      return k;
-    }
-  
+
+  if (matches) {
+    k = crypt_select_key (matches, NULL, p, app, forced_valid);
+    crypt_free_key (&matches);
+    return k;
+  }
+
   return NULL;
 }
 
@@ -3882,11 +3607,10 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
    default.  ABILITIES describe the required key abilities (sign,
    encrypt) and APP the type of the requested key; ether S/MIME or
    PGP.  Return a copy of the key or NULL if not found. */
-static crypt_key_t *crypt_ask_for_key (char *tag, 
-                                       char *whatfor, 
+static crypt_key_t *crypt_ask_for_key (char *tag,
+                                       char *whatfor,
                                        short abilities,
-                                      unsigned int app,
-                                       int *forced_valid)
+                                       unsigned int app, int *forced_valid)
 {
   crypt_key_t *key;
   char resp[SHORT_STRING];
@@ -3900,49 +3624,44 @@ static crypt_key_t *crypt_ask_for_key (char *tag,
 
   *forced_valid = 0;
   resp[0] = 0;
-  if (whatfor)
-    {
-      
-      for (l = id_defaults; l; l = l->next)
-        if (!mutt_strcasecmp (whatfor, l->what))
-          {
-            strfcpy (resp, NONULL (l->dflt), sizeof (resp));
-            break;
-          }
-    }
+  if (whatfor) {
 
+    for (l = id_defaults; l; l = l->next)
+      if (!mutt_strcasecmp (whatfor, l->what)) {
+        strfcpy (resp, NONULL (l->dflt), sizeof (resp));
+        break;
+      }
+  }
 
-  for (;;)
-    {
-      resp[0] = 0;
-      if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
-        return NULL;
-      
-      if (whatfor)
-        {
-          if (l)
-            mutt_str_replace (&l->dflt, resp);
-          else
-            {
-              l = safe_malloc (sizeof (struct crypt_cache));
-              l->next = id_defaults;
-              id_defaults = l;
-              l->what = safe_strdup (whatfor);
-              l->dflt = safe_strdup (resp);
-            }
-        }
-      
-      if ((key = crypt_getkeybystr (resp, abilities, app, forced_valid)))
-        return key;
-      
-      BEEP ();
+
+  for (;;) {
+    resp[0] = 0;
+    if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
+      return NULL;
+
+    if (whatfor) {
+      if (l)
+        mutt_str_replace (&l->dflt, resp);
+      else {
+        l = safe_malloc (sizeof (struct crypt_cache));
+        l->next = id_defaults;
+        id_defaults = l;
+        l->what = safe_strdup (whatfor);
+        l->dflt = safe_strdup (resp);
+      }
     }
+
+    if ((key = crypt_getkeybystr (resp, abilities, app, forced_valid)))
+      return key;
+
+    BEEP ();
+  }
   /* not reached */
 }
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-static char *find_keys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc,
+static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
                         unsigned int app)
 {
   char *keyID, *keylist = NULL, *t;
@@ -3956,127 +3675,123 @@ static char *find_keys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc,
   const char *fqdn = mutt_fqdn (1);
 
 #if 0
-  *r_application = APPLICATION_PGP|APPLICATION_SMIME;
+  *r_application = APPLICATION_PGP | APPLICATION_SMIME;
 #endif
-  
-  for (i = 0; i < 3; i++) 
-    {
-      switch (i)
-        {
-        case 0: p = to; break;
-        case 1: p = cc; break;
-        case 2: p = bcc; break;
-        default: abort ();
-        }
-      
-      *last = rfc822_cpy_adr (p);
-      while (*last)
-        last = &((*last)->next);
+
+  for (i = 0; i < 3; i++) {
+    switch (i) {
+    case 0:
+      p = to;
+      break;
+    case 1:
+      p = cc;
+      break;
+    case 2:
+      p = bcc;
+      break;
+    default:
+      abort ();
     }
-  
+
+    *last = rfc822_cpy_adr (p);
+    while (*last)
+      last = &((*last)->next);
+  }
+
   if (fqdn)
     rfc822_qualify (tmp, fqdn);
-  
+
   tmp = mutt_remove_duplicates (tmp);
-  
-  for (p = tmp; p ; p = p->next)
-    {
-      char buf[LONG_STRING];
-      int forced_valid = 0;
-      
-      q = p;
-      k_info = NULL;
-      
-      if ((keyID = mutt_crypt_hook (p)) != NULL)
-        {
-          int r;
-          snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"),
-                    keyID, p->mailbox);
-          if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
-            {
-              /* check for e-mail address */
-              if ((t = strchr (keyID, '@')) && 
-                  (addr = rfc822_parse_adrlist (NULL, keyID)))
-                {
-                  if (fqdn)
-                    rfc822_qualify (addr, fqdn);
-                  q = addr;
-                }
-              else
-               {
-#if 0            
-                 k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT, 
-                                             *r_application, &forced_valid);
+
+  for (p = tmp; p; p = p->next) {
+    char buf[LONG_STRING];
+    int forced_valid = 0;
+
+    q = p;
+    k_info = NULL;
+
+    if ((keyID = mutt_crypt_hook (p)) != NULL) {
+      int r;
+
+      snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"),
+                keyID, p->mailbox);
+      if ((r = mutt_yesorno (buf, M_YES)) == M_YES) {
+        /* check for e-mail address */
+        if ((t = strchr (keyID, '@')) &&
+            (addr = rfc822_parse_adrlist (NULL, keyID))) {
+          if (fqdn)
+            rfc822_qualify (addr, fqdn);
+          q = addr;
+        }
+        else {
+#if 0
+          k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT,
+                                      *r_application, &forced_valid);
 #else
-                 k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT, 
-                                             app, &forced_valid);
+          k_info = crypt_getkeybystr (keyID, KEYFLAG_CANENCRYPT,
+                                      app, &forced_valid);
 #endif
-               }
-            }
-          else if (r == -1)
-            {
-              FREE (&keylist);
-              rfc822_free_address (&tmp);
-              rfc822_free_address (&addr);
-              return NULL;
-            }
         }
+      }
+      else if (r == -1) {
+        FREE (&keylist);
+        rfc822_free_address (&tmp);
+        rfc822_free_address (&addr);
+        return NULL;
+      }
+    }
+
+    if (k_info == NULL
+        && (k_info = crypt_getkeybyaddr (q, KEYFLAG_CANENCRYPT,
+                                         app, &forced_valid)) == NULL) {
+      snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
 
-      if (k_info == NULL
-          && (k_info = crypt_getkeybyaddr (q, KEYFLAG_CANENCRYPT,
-                                           app, &forced_valid)) == NULL)
-        {
-          snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
-          
-          if ((key = crypt_ask_for_key (buf, q->mailbox,
-                                        KEYFLAG_CANENCRYPT,
+      if ((key = crypt_ask_for_key (buf, q->mailbox, KEYFLAG_CANENCRYPT,
 #if 0
-                                        *r_application,
+                                    *r_application,
 #else
-                                       app,
+                                    app,
 #endif
-                                       &forced_valid)) == NULL)
-            {
-              FREE (&keylist);
-              rfc822_free_address (&tmp);
-              rfc822_free_address (&addr);
-              return NULL;
-            }
-        }
-      else
-        key = k_info;
+                                    &forced_valid)) == NULL) {
+        FREE (&keylist);
+        rfc822_free_address (&tmp);
+        rfc822_free_address (&addr);
+        return NULL;
+      }
+    }
+    else
+      key = k_info;
 
-      {
-        const char *s = crypt_fpr (key);
+    {
+      const char *s = crypt_fpr (key);
 
 #if 0
-        if (key->flags & KEYFLAG_ISX509)
-          *r_application &= ~APPLICATION_PGP;
-        if (!(key->flags & KEYFLAG_ISX509))
-          *r_application &= ~APPLICATION_SMIME;
+      if (key->flags & KEYFLAG_ISX509)
+        *r_application &= ~APPLICATION_PGP;
+      if (!(key->flags & KEYFLAG_ISX509))
+        *r_application &= ~APPLICATION_SMIME;
 #endif
-      
-        keylist_size += mutt_strlen (s) + 4 + 1;
-        safe_realloc (&keylist, keylist_size);
-        sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */
-                 keylist_used ? " " : "",  s,
-                 forced_valid? "!":"");
-      }
-      keylist_used = mutt_strlen (keylist);
-        
-      crypt_free_key (&key);
-      rfc822_free_address (&addr);
+
+      keylist_size += mutt_strlen (s) + 4 + 1;
+      safe_realloc (&keylist, keylist_size);
+      sprintf (keylist + keylist_used, "%s0x%s%s",      /* __SPRINTF_CHECKED__ */
+               keylist_used ? " " : "", s, forced_valid ? "!" : "");
     }
+    keylist_used = mutt_strlen (keylist);
+
+    crypt_free_key (&key);
+    rfc822_free_address (&addr);
+  }
   rfc822_free_address (&tmp);
   return (keylist);
 }
 
-char *pgp_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *pgp_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   return find_keys (to, cc, bcc, APPLICATION_PGP);
 }
 
-char *smime_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *smime_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   return find_keys (to, cc, bcc, APPLICATION_SMIME);
 }
@@ -4089,12 +3804,11 @@ char *smime_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 static void init_gpgme (void)
 {
   /* Make sure that gpg-agent is running.  */
-  if (! getenv ("GPG_AGENT_INFO"))
-    {
-      mutt_error ("\nUsing GPGME backend, although no gpg-agent is running");
-      if (mutt_any_key_to_continue (NULL) == -1)
-       mutt_exit(1);
-    }
+  if (!getenv ("GPG_AGENT_INFO")) {
+    mutt_error ("\nUsing GPGME backend, although no gpg-agent is running");
+    if (mutt_any_key_to_continue (NULL) == -1)
+      mutt_exit (1);
+  }
 }
 
 void pgp_gpgme_init (void)
@@ -4106,7 +3820,7 @@ void smime_gpgme_init (void)
 {
 }
 
-static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime)
+static int gpgme_send_menu (HEADER * msg, int *redraw, int is_smime)
 {
   crypt_key_t *p;
   char input_signas[SHORT_STRING];
@@ -4118,135 +3832,126 @@ static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime)
     is_smime = 1;
 
   if (is_smime)
-    choice = mutt_multi_choice (
-    _("S/MIME (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
-             _("esabtf"));
-  else 
-    choice = mutt_multi_choice (
-    _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
-                _("esabtf"));
-
-  switch (choice)
-  {
-  case 1: /* (e)ncrypt */
+    choice =
+      mutt_multi_choice (_
+                         ("S/MIME (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
+                         _("esabtf"));
+  else
+    choice =
+      mutt_multi_choice (_
+                         ("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
+                         _("esabtf"));
+
+  switch (choice) {
+  case 1:                      /* (e)ncrypt */
     msg->security |= (is_smime ? SMIMEENCRYPT : PGPENCRYPT);
     break;
 
-  case 2: /* (s)ign */
-    msg->security |= (is_smime? SMIMESIGN :PGPSIGN);
+  case 2:                      /* (s)ign */
+    msg->security |= (is_smime ? SMIMESIGN : PGPSIGN);
     break;
 
-  case 3: /* sign (a)s */
+  case 3:                      /* sign (a)s */
 /*      unset_option(OPTCRYPTCHECKTRUST); */
     if ((p = crypt_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN,
-                                is_smime? APPLICATION_SMIME:APPLICATION_PGP,
-                                NULL)))
-    {
+                                is_smime ? APPLICATION_SMIME :
+                                APPLICATION_PGP, NULL))) {
       snprintf (input_signas, sizeof (input_signas), "0x%s", crypt_keyid (p));
-      mutt_str_replace (is_smime? &SmimeDefaultKey : &PgpSignAs, input_signas);
-      crypt_free_key (&p); 
-      
-      msg->security |= (is_smime? SMIMESIGN:PGPSIGN);
+      mutt_str_replace (is_smime ? &SmimeDefaultKey : &PgpSignAs,
+                        input_signas);
+      crypt_free_key (&p);
+
+      msg->security |= (is_smime ? SMIMESIGN : PGPSIGN);
     }
-    else
-    {
-      msg->security &= (is_smime? ~SMIMESIGN : ~PGPSIGN);
+    else {
+      msg->security &= (is_smime ? ~SMIMESIGN : ~PGPSIGN);
     }
     *redraw = REDRAW_FULL;
     break;
 
-  case 4: /* (b)oth */
-    msg->security = (is_smime? (SMIMEENCRYPT|SMIMESIGN):(PGPENCRYPT|PGPSIGN));
+  case 4:                      /* (b)oth */
+    msg->security =
+      (is_smime ? (SMIMEENCRYPT | SMIMESIGN) : (PGPENCRYPT | PGPSIGN));
     break;
 
-  case 5: /* (t)oggle */
+  case 5:                      /* (t)oggle */
     is_smime = !is_smime;
     break;
 
-  case 6: /* (f)orget it */
+  case 6:                      /* (f)orget it */
     msg->security = 0;
     break;
   }
 
-  if (choice == 6)
-    ;
-  else if (is_smime)
-    {
-      msg->security &= ~APPLICATION_PGP;
-      msg->security |= APPLICATION_SMIME;
-    }
-  else
-    {
-      msg->security &= ~APPLICATION_SMIME;
-      msg->security |= APPLICATION_PGP;
-    }
-  
+  if (choice == 6);
+  else if (is_smime) {
+    msg->security &= ~APPLICATION_PGP;
+    msg->security |= APPLICATION_SMIME;
+  }
+  else {
+    msg->security &= ~APPLICATION_SMIME;
+    msg->security |= APPLICATION_PGP;
+  }
+
   return (msg->security);
 }
 
-int pgp_gpgme_send_menu (HEADER *msg, int *redraw)
+int pgp_gpgme_send_menu (HEADER * msg, int *redraw)
 {
   return gpgme_send_menu (msg, redraw, 0);
 }
 
-int smime_gpgme_send_menu (HEADER *msg, int *redraw)
+int smime_gpgme_send_menu (HEADER * msg, int *redraw)
 {
   return gpgme_send_menu (msg, redraw, 1);
 }
 
-static int verify_sender (HEADER *h, gpgme_protocol_t protocol)
+static int verify_sender (HEADER * h, gpgme_protocol_t protocol)
 {
   ADDRESS *sender = NULL;
   unsigned int ret = 1;
 
-  if (h->env->from)
-    {
-      h->env->from = mutt_expand_aliases (h->env->from);
-      sender = h->env->from;
-    }
-  else if (h->env->sender)
-    {
-      h->env->sender = mutt_expand_aliases (h->env->sender);
-      sender = h->env->sender;
-    }
+  if (h->env->from) {
+    h->env->from = mutt_expand_aliases (h->env->from);
+    sender = h->env->from;
+  }
+  else if (h->env->sender) {
+    h->env->sender = mutt_expand_aliases (h->env->sender);
+    sender = h->env->sender;
+  }
 
-  if (sender)
-    {
-      if (signature_key)
-       {
-         gpgme_key_t key = signature_key;
-         gpgme_user_id_t uid = NULL;
-         int sender_length = 0;
-         int uid_length = 0;
-
-         sender_length = strlen (sender->mailbox);
-         for (uid = key->uids; uid && ret; uid = uid->next)
-           {
-             uid_length = strlen (uid->email);
-             if (1
-                 && (uid->email[0] == '<')
-                 && (uid->email[uid_length - 1] == '>')
-                 && (uid_length == sender_length + 2)
-                 && (! strncmp (uid->email + 1, sender->mailbox, sender_length)))
-               ret = 0;
-           }
-       }
-      else
-       mutt_any_key_to_continue ("Failed to verify sender");
+  if (sender) {
+    if (signature_key) {
+      gpgme_key_t key = signature_key;
+      gpgme_user_id_t uid = NULL;
+      int sender_length = 0;
+      int uid_length = 0;
+
+      sender_length = strlen (sender->mailbox);
+      for (uid = key->uids; uid && ret; uid = uid->next) {
+        uid_length = strlen (uid->email);
+        if (1 && (uid->email[0] == '<')
+            && (uid->email[uid_length - 1] == '>')
+            && (uid_length == sender_length + 2)
+            && (!strncmp (uid->email + 1, sender->mailbox, sender_length)))
+          ret = 0;
+      }
     }
+    else
+      mutt_any_key_to_continue ("Failed to verify sender");
+  }
   else
     mutt_any_key_to_continue ("Failed to figure out sender");
 
-  if (signature_key)
-    {
-      gpgme_key_release (signature_key);
-      signature_key = NULL;
-    }
+  if (signature_key) {
+    gpgme_key_release (signature_key);
+    signature_key = NULL;
+  }
 
   return ret;
 }
 
-int smime_gpgme_verify_sender (HEADER *h)
+int smime_gpgme_verify_sender (HEADER * h)
 {
   return verify_sender (h, GPGME_PROTOCOL_CMS);
 }
index 4901351..224367a 100644 (file)
 void pgp_gpgme_init (void);
 void smime_gpgme_init (void);
 
-char *pgp_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
-char *smime_gpgme_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+char *pgp_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
+char *smime_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
 
-BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign);
-BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist);
+BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign);
+BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist);
 
-int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur);
-int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur);
+int pgp_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
+                            BODY ** cur);
+int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
+                              BODY ** cur);
 
-int pgp_gpgme_check_traditional (FILE *fp, BODY *b, int tagged_only);
+int pgp_gpgme_check_traditional (FILE * fp, BODY * b, int tagged_only);
 
-void pgp_gpgme_application_handler (BODY *m, STATE *s);
-void smime_gpgme_application_handler (BODY *a, STATE *s);
-void pgp_gpgme_encrypted_handler (BODY *a, STATE *s);
+void pgp_gpgme_application_handler (BODY * m, STATE * s);
+void smime_gpgme_application_handler (BODY * a, STATE * s);
+void pgp_gpgme_encrypted_handler (BODY * a, STATE * s);
 
 BODY *pgp_gpgme_make_key_attachment (char *tempf);
 
-BODY *pgp_gpgme_sign_message (BODY *a);
-BODY *smime_gpgme_sign_message (BODY *a);
+BODY *pgp_gpgme_sign_message (BODY * a);
+BODY *smime_gpgme_sign_message (BODY * a);
 
-int pgp_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile);
-int smime_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile);
+int pgp_gpgme_verify_one (BODY * sigbdy, STATE * s, const char *tempfile);
+int smime_gpgme_verify_one (BODY * sigbdy, STATE * s, const char *tempfile);
 
-int pgp_gpgme_send_menu (HEADER *msg, int *redraw);
-int smime_gpgme_send_menu (HEADER *msg, int *redraw);
+int pgp_gpgme_send_menu (HEADER * msg, int *redraw);
+int smime_gpgme_send_menu (HEADER * msg, int *redraw);
 
 #endif
index e6e3bc8..f5613ee 100644 (file)
@@ -37,36 +37,39 @@ static int crypt_mod_pgp_valid_passphrase (void)
   return pgp_valid_passphrase ();
 }
 
-static int crypt_mod_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+static int crypt_mod_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c,
+                                       BODY ** d)
 {
   return pgp_decrypt_mime (a, b, c, d);
 }
-static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
+static void crypt_mod_pgp_application_handler (BODY * m, STATE * s)
 {
   pgp_application_pgp_handler (m, s);
 }
 
-static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+static char *crypt_mod_pgp_findkeys (ADDRESS * to, ADDRESS * cc,
+                                     ADDRESS * bcc)
 {
   return pgp_findKeys (to, cc, bcc);
 }
 
-static BODY *crypt_mod_pgp_sign_message (BODY *a)
+static BODY *crypt_mod_pgp_sign_message (BODY * a)
 {
   return pgp_sign_message (a);
 }
 
-static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+static int crypt_mod_pgp_verify_one (BODY * sigbdy, STATE * s,
+                                     const char *tempf)
 {
   return pgp_verify_one (sigbdy, s, tempf);
 }
 
-static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw)
+static int crypt_mod_pgp_send_menu (HEADER * msg, int *redraw)
 {
   return pgp_send_menu (msg, redraw);
 }
 
-static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign)
+static BODY *crypt_mod_pgp_encrypt_message (BODY * a, char *keylist, int sign)
 {
   return pgp_encrypt_message (a, keylist, sign);
 }
@@ -76,22 +79,24 @@ static BODY *crypt_mod_pgp_make_key_attachment (char *tempf)
   return pgp_make_key_attachment (tempf);
 }
 
-static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+static int crypt_mod_pgp_check_traditional (FILE * fp, BODY * b,
+                                            int tagged_only)
 {
   return pgp_check_traditional (fp, b, tagged_only);
 }
 
-static BODY *crypt_mod_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
+static BODY *crypt_mod_pgp_traditional_encryptsign (BODY * a, int flags,
+                                                    char *keylist)
 {
   return pgp_traditional_encryptsign (a, flags, keylist);
 }
 
-static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
+static void crypt_mod_pgp_encrypted_handler (BODY * m, STATE * s)
 {
   pgp_encrypted_handler (m, s);
 }
 
-static void crypt_mod_pgp_invoke_getkeys (ADDRESS *addr)
+static void crypt_mod_pgp_invoke_getkeys (ADDRESS * addr)
 {
   pgp_invoke_getkeys (addr);
 }
@@ -101,36 +106,37 @@ static void crypt_mod_pgp_invoke_import (const char *fname)
   pgp_invoke_import (fname);
 }
 
-static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
+static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE * fp,
+                                                             int tag,
+                                                             BODY * top)
 {
   pgp_extract_keys_from_attachment_list (fp, tag, top);
 }
 
-struct crypt_module_specs crypt_mod_pgp_classic =
-  { APPLICATION_PGP,
-    {
-      NULL,                    /* init */
-      crypt_mod_pgp_void_passphrase,
-      crypt_mod_pgp_valid_passphrase,
-      crypt_mod_pgp_decrypt_mime,
-      crypt_mod_pgp_application_handler,
-      crypt_mod_pgp_encrypted_handler,
-      crypt_mod_pgp_findkeys,
-      crypt_mod_pgp_sign_message,
-      crypt_mod_pgp_verify_one,
-      crypt_mod_pgp_send_menu,
-
-      crypt_mod_pgp_encrypt_message,
-      crypt_mod_pgp_make_key_attachment,
-      crypt_mod_pgp_check_traditional,
-      crypt_mod_pgp_traditional_encryptsign,
-      crypt_mod_pgp_invoke_getkeys,
-      crypt_mod_pgp_invoke_import,
-      crypt_mod_pgp_extract_keys_from_attachment_list,
-
-      NULL,                    /* smime_getkeys */
-      NULL,                    /* smime_verify_sender */
-      NULL,                    /* smime_build_smime_entity */
-      NULL,                    /* smime_invoke_import */
-    }
-  };
+struct crypt_module_specs crypt_mod_pgp_classic = { APPLICATION_PGP,
+  {
+   NULL,                        /* init */
+   crypt_mod_pgp_void_passphrase,
+   crypt_mod_pgp_valid_passphrase,
+   crypt_mod_pgp_decrypt_mime,
+   crypt_mod_pgp_application_handler,
+   crypt_mod_pgp_encrypted_handler,
+   crypt_mod_pgp_findkeys,
+   crypt_mod_pgp_sign_message,
+   crypt_mod_pgp_verify_one,
+   crypt_mod_pgp_send_menu,
+
+   crypt_mod_pgp_encrypt_message,
+   crypt_mod_pgp_make_key_attachment,
+   crypt_mod_pgp_check_traditional,
+   crypt_mod_pgp_traditional_encryptsign,
+   crypt_mod_pgp_invoke_getkeys,
+   crypt_mod_pgp_invoke_import,
+   crypt_mod_pgp_extract_keys_from_attachment_list,
+
+   NULL,                        /* smime_getkeys */
+   NULL,                        /* smime_verify_sender */
+   NULL,                        /* smime_build_smime_entity */
+   NULL,                        /* smime_invoke_import */
+   }
+};
index bab9663..54b2af0 100644 (file)
@@ -45,80 +45,83 @@ static int crypt_mod_pgp_valid_passphrase (void)
   return 1;
 }
 
-static int crypt_mod_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+static int crypt_mod_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c,
+                                       BODY ** d)
 {
   return pgp_gpgme_decrypt_mime (a, b, c, d);
 }
 
-static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
+static void crypt_mod_pgp_application_handler (BODY * m, STATE * s)
 {
   pgp_gpgme_application_handler (m, s);
 }
 
-static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
+static void crypt_mod_pgp_encrypted_handler (BODY * m, STATE * s)
 {
   pgp_gpgme_encrypted_handler (m, s);
 }
 
-static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+static int crypt_mod_pgp_check_traditional (FILE * fp, BODY * b,
+                                            int tagged_only)
 {
   return pgp_gpgme_check_traditional (fp, b, tagged_only);
 }
 
-static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+static char *crypt_mod_pgp_findkeys (ADDRESS * to, ADDRESS * cc,
+                                     ADDRESS * bcc)
 {
   return pgp_gpgme_findkeys (to, cc, bcc);
 }
 
-static BODY *crypt_mod_pgp_sign_message (BODY *a)
+static BODY *crypt_mod_pgp_sign_message (BODY * a)
 {
   return pgp_gpgme_sign_message (a);
 }
 
-static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+static int crypt_mod_pgp_verify_one (BODY * sigbdy, STATE * s,
+                                     const char *tempf)
 {
   return pgp_gpgme_verify_one (sigbdy, s, tempf);
 }
 
-static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw)
+static int crypt_mod_pgp_send_menu (HEADER * msg, int *redraw)
 {
   return pgp_gpgme_send_menu (msg, redraw);
 }
 
-static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign)
+static BODY *crypt_mod_pgp_encrypt_message (BODY * a, char *keylist, int sign)
 {
   return pgp_gpgme_encrypt_message (a, keylist, sign);
 }
 
-struct crypt_module_specs crypt_mod_pgp_gpgme =
-  { APPLICATION_PGP,
-    {
-      /* Common.  */
-      crypt_mod_pgp_init,
-      crypt_mod_pgp_void_passphrase,
-      crypt_mod_pgp_valid_passphrase,
-      crypt_mod_pgp_decrypt_mime,
-      crypt_mod_pgp_application_handler,
-      crypt_mod_pgp_encrypted_handler,
-      crypt_mod_pgp_findkeys,
-      crypt_mod_pgp_sign_message,
-      crypt_mod_pgp_verify_one,
-      crypt_mod_pgp_send_menu,
-
-      /* PGP specific.  */
-      crypt_mod_pgp_encrypt_message,
-      NULL,                    /* pgp_make_key_attachment, */
-      crypt_mod_pgp_check_traditional,
-      NULL,                    /* pgp_traditional_encryptsign  */
-      NULL, /* pgp_invoke_getkeys  */
-      NULL, /* pgp_invoke_import  */
-      NULL, /* pgp_extract_keys_from_attachment_list  */
-
-      NULL,                    /* smime_getkeys */
-      NULL,                    /* smime_verify_sender */
-      NULL,                    /* smime_build_smime_entity */
-      NULL,                    /* smime_invoke_import */
-    }
-  };
+struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP,
+  {
+   /* Common.  */
+   crypt_mod_pgp_init,
+   crypt_mod_pgp_void_passphrase,
+   crypt_mod_pgp_valid_passphrase,
+   crypt_mod_pgp_decrypt_mime,
+   crypt_mod_pgp_application_handler,
+   crypt_mod_pgp_encrypted_handler,
+   crypt_mod_pgp_findkeys,
+   crypt_mod_pgp_sign_message,
+   crypt_mod_pgp_verify_one,
+   crypt_mod_pgp_send_menu,
+
+   /* PGP specific.  */
+   crypt_mod_pgp_encrypt_message,
+   NULL,                        /* pgp_make_key_attachment, */
+   crypt_mod_pgp_check_traditional,
+   NULL,                        /* pgp_traditional_encryptsign  */
+   NULL,                        /* pgp_invoke_getkeys  */
+   NULL,                        /* pgp_invoke_import  */
+   NULL,                        /* pgp_extract_keys_from_attachment_list  */
+
+   NULL,                        /* smime_getkeys */
+   NULL,                        /* smime_verify_sender */
+   NULL,                        /* smime_build_smime_entity */
+   NULL,                        /* smime_invoke_import */
+   }
+};
 
 #endif
index cff63b2..a790036 100644 (file)
@@ -37,46 +37,49 @@ static int crypt_mod_smime_valid_passphrase (void)
   return smime_valid_passphrase ();
 }
 
-static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
+                                         BODY ** d)
 {
   return smime_decrypt_mime (a, b, c, d);
 }
-static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
+static void crypt_mod_smime_application_handler (BODY * m, STATE * s)
 {
   smime_application_smime_handler (m, s);
 }
 
-static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+static char *crypt_mod_smime_findkeys (ADDRESS * to, ADDRESS * cc,
+                                       ADDRESS * bcc)
 {
   return smime_findKeys (to, cc, bcc);
 }
 
-static BODY *crypt_mod_smime_sign_message (BODY *a)
+static BODY *crypt_mod_smime_sign_message (BODY * a)
 {
   return smime_sign_message (a);
 }
 
-static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+static int crypt_mod_smime_verify_one (BODY * sigbdy, STATE * s,
+                                       const char *tempf)
 {
   return smime_verify_one (sigbdy, s, tempf);
 }
 
-static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw)
+static int crypt_mod_smime_send_menu (HEADER * msg, int *redraw)
 {
   return smime_send_menu (msg, redraw);
 }
 
-static void crypt_mod_smime_getkeys (ENVELOPE *env)
+static void crypt_mod_smime_getkeys (ENVELOPE * env)
 {
   smime_getkeys (env);
 }
 
-static int crypt_mod_smime_verify_sender (HEADER *h)
+static int crypt_mod_smime_verify_sender (HEADER * h)
 {
   return smime_verify_sender (h);
 }
 
-static BODY *crypt_mod_smime_build_smime_entity (BODY *a, char *certlist)
+static BODY *crypt_mod_smime_build_smime_entity (BODY * a, char *certlist)
 {
   return smime_build_smime_entity (a, certlist);
 }
@@ -87,31 +90,30 @@ static void crypt_mod_smime_invoke_import (char *infile, char *mailbox)
 }
 
 
-struct crypt_module_specs crypt_mod_smime_classic =
-  { APPLICATION_SMIME,
-    {
-      NULL,                    /* init */
-      crypt_mod_smime_void_passphrase,
-      crypt_mod_smime_valid_passphrase,
-      crypt_mod_smime_decrypt_mime,
-      crypt_mod_smime_application_handler,
-      NULL,                    /* encrypted_handler */
-      crypt_mod_smime_findkeys,
-      crypt_mod_smime_sign_message,
-      crypt_mod_smime_verify_one,
-      crypt_mod_smime_send_menu,
-
-      NULL,                    /* pgp_encrypt_message */
-      NULL,                    /* pgp_make_key_attachment */
-      NULL,                    /* pgp_check_traditional */
-      NULL,                    /* pgp_traditional_encryptsign */
-      NULL,                    /* pgp_invoke_getkeys */
-      NULL,                    /* pgp_invoke_import */
-      NULL,                    /* pgp_extract_keys_from_attachment_list */
-      
-      crypt_mod_smime_getkeys,
-      crypt_mod_smime_verify_sender,
-      crypt_mod_smime_build_smime_entity,
-      crypt_mod_smime_invoke_import,
-    }
-  };
+struct crypt_module_specs crypt_mod_smime_classic = { APPLICATION_SMIME,
+  {
+   NULL,                        /* init */
+   crypt_mod_smime_void_passphrase,
+   crypt_mod_smime_valid_passphrase,
+   crypt_mod_smime_decrypt_mime,
+   crypt_mod_smime_application_handler,
+   NULL,                        /* encrypted_handler */
+   crypt_mod_smime_findkeys,
+   crypt_mod_smime_sign_message,
+   crypt_mod_smime_verify_one,
+   crypt_mod_smime_send_menu,
+
+   NULL,                        /* pgp_encrypt_message */
+   NULL,                        /* pgp_make_key_attachment */
+   NULL,                        /* pgp_check_traditional */
+   NULL,                        /* pgp_traditional_encryptsign */
+   NULL,                        /* pgp_invoke_getkeys */
+   NULL,                        /* pgp_invoke_import */
+   NULL,                        /* pgp_extract_keys_from_attachment_list */
+
+   crypt_mod_smime_getkeys,
+   crypt_mod_smime_verify_sender,
+   crypt_mod_smime_build_smime_entity,
+   crypt_mod_smime_invoke_import,
+   }
+};
index 761dec9..ca17ce9 100644 (file)
@@ -45,73 +45,75 @@ static int crypt_mod_smime_valid_passphrase (void)
   return 1;
 }
 
-static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
+                                         BODY ** d)
 {
   return smime_gpgme_decrypt_mime (a, b, c, d);
 }
 
-static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
+static void crypt_mod_smime_application_handler (BODY * m, STATE * s)
 {
   smime_gpgme_application_handler (m, s);
 }
 
-static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+static char *crypt_mod_smime_findkeys (ADDRESS * to, ADDRESS * cc,
+                                       ADDRESS * bcc)
 {
   return smime_gpgme_findkeys (to, cc, bcc);
 }
 
-static BODY *crypt_mod_smime_sign_message (BODY *a)
+static BODY *crypt_mod_smime_sign_message (BODY * a)
 {
   return smime_gpgme_sign_message (a);
 }
 
-static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+static int crypt_mod_smime_verify_one (BODY * sigbdy, STATE * s,
+                                       const char *tempf)
 {
   return smime_gpgme_verify_one (sigbdy, s, tempf);
 }
 
-static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw)
+static int crypt_mod_smime_send_menu (HEADER * msg, int *redraw)
 {
   return smime_gpgme_send_menu (msg, redraw);
 }
 
-static BODY *crypt_mod_smime_build_smime_entity (BODY *a, char *certlist)
+static BODY *crypt_mod_smime_build_smime_entity (BODY * a, char *certlist)
 {
   return smime_gpgme_build_smime_entity (a, certlist);
 }
 
-static int crypt_mod_smime_verify_sender (HEADER *h)
+static int crypt_mod_smime_verify_sender (HEADER * h)
 {
   return smime_gpgme_verify_sender (h);
 }
 
-struct crypt_module_specs crypt_mod_smime_gpgme =
-  { APPLICATION_SMIME,
-    {
-      crypt_mod_smime_init,
-      crypt_mod_smime_void_passphrase,
-      crypt_mod_smime_valid_passphrase,
-      crypt_mod_smime_decrypt_mime,
-      crypt_mod_smime_application_handler,
-      NULL,                    /* encrypted_handler */
-      crypt_mod_smime_findkeys,
-      crypt_mod_smime_sign_message,
-      crypt_mod_smime_verify_one,
-      crypt_mod_smime_send_menu,
-
-      NULL,                    /* pgp_encrypt_message */
-      NULL,                    /* pgp_make_key_attachment */
-      NULL,                    /* pgp_check_traditional */
-      NULL,                    /* pgp_traditional_encryptsign */
-      NULL,                    /* pgp_invoke_getkeys */
-      NULL,                    /* pgp_invoke_import */
-      NULL,                    /* pgp_extract_keys_from_attachment_list */
-      
-      NULL,                    /* smime_getkeys */
-      crypt_mod_smime_verify_sender,
-      crypt_mod_smime_build_smime_entity,
-      NULL,                    /* smime_invoke_import */
-    }
-  };
+struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
+  {
+   crypt_mod_smime_init,
+   crypt_mod_smime_void_passphrase,
+   crypt_mod_smime_valid_passphrase,
+   crypt_mod_smime_decrypt_mime,
+   crypt_mod_smime_application_handler,
+   NULL,                        /* encrypted_handler */
+   crypt_mod_smime_findkeys,
+   crypt_mod_smime_sign_message,
+   crypt_mod_smime_verify_one,
+   crypt_mod_smime_send_menu,
+
+   NULL,                        /* pgp_encrypt_message */
+   NULL,                        /* pgp_make_key_attachment */
+   NULL,                        /* pgp_check_traditional */
+   NULL,                        /* pgp_traditional_encryptsign */
+   NULL,                        /* pgp_invoke_getkeys */
+   NULL,                        /* pgp_invoke_import */
+   NULL,                        /* pgp_extract_keys_from_attachment_list */
+
+   NULL,                        /* smime_getkeys */
+   crypt_mod_smime_verify_sender,
+   crypt_mod_smime_build_smime_entity,
+   NULL,                        /* smime_invoke_import */
+   }
+};
 
 #endif
index 4be1e43..3c52671 100644 (file)
@@ -25,8 +25,7 @@
 /* A type an a variable to keep track of registered crypto modules. */
 typedef struct crypt_module *crypt_module_t;
 
-struct crypt_module
-{
+struct crypt_module {
   crypt_module_specs_t specs;
   crypt_module_t next, *prevp;
 };
index 4f69c3e..dabf9a2 100644 (file)
     Type defintions for crypto module functions.
  */
 typedef void (*crypt_func_void_passphrase_t) (void);
-typedef int (*crypt_func_valid_passphrase_t)  (void);
+typedef int (*crypt_func_valid_passphrase_t) (void);
 
-typedef int (*crypt_func_decrypt_mime_t) (FILE *a, FILE **b,
-                                          BODY *c, BODY **d);
+typedef int (*crypt_func_decrypt_mime_t) (FILE * a, FILE ** b,
+                                          BODY * c, BODY ** d);
 
-typedef void (*crypt_func_application_handler_t) (BODY *m, STATE *s);
-typedef void (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s);
+typedef void (*crypt_func_application_handler_t) (BODY * m, STATE * s);
+typedef void (*crypt_func_encrypted_handler_t) (BODY * m, STATE * s);
 
-typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS *addr);
-typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b,
+typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS * addr);
+typedef int (*crypt_func_pgp_check_traditional_t) (FILE * fp, BODY * b,
                                                    int tagged_only);
-typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags,
+typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY * a,
+                                                           int flags,
                                                            char *keylist);
 typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
-typedef char *(*crypt_func_findkeys_t) (ADDRESS *to,
-                                        ADDRESS *cc, ADDRESS *bcc);
-typedef BODY *(*crypt_func_sign_message_t) (BODY *a);
-typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist,
+typedef char *(*crypt_func_findkeys_t) (ADDRESS * to,
+                                        ADDRESS * cc, ADDRESS * bcc);
+typedef BODY *(*crypt_func_sign_message_t) (BODY * a);
+typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY * a, char *keylist,
                                                    int sign);
 typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname);
-typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s,
+typedef int (*crypt_func_verify_one_t) (BODY * sigbdy, STATE * s,
                                         const char *tempf);
-typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t) 
-                                           (FILE *fp, int tag, BODY *top);
+typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t)
+     (FILE * fp, int tag, BODY * top);
 
-typedef int (*crypt_func_send_menu_t) (HEADER *msg, int *redraw);
+typedef int (*crypt_func_send_menu_t) (HEADER * msg, int *redraw);
 
  /* (SMIME) */
-typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE *env);
-typedef int (*crypt_func_smime_verify_sender_t) (HEADER *h);
+typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE * env);
+typedef int (*crypt_func_smime_verify_sender_t) (HEADER * h);
 
-typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY *a,
+typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY * a,
                                                         char *certlist);
 
-typedef void (*crypt_func_smime_invoke_import_t) (char *infile, char *mailbox);
+typedef void (*crypt_func_smime_invoke_import_t) (char *infile,
+                                                  char *mailbox);
 
 typedef void (*crypt_func_init_t) (void);
 
@@ -71,8 +73,7 @@ typedef void (*crypt_func_init_t) (void);
 /*
    A structure to keep all crypto module fucntions together.
  */
-typedef struct crypt_module_functions
-{
+typedef struct crypt_module_functions {
   /* Common/General functions.  */
   crypt_func_init_t init;
   crypt_func_void_passphrase_t void_passphrase;
@@ -92,8 +93,22 @@ typedef struct crypt_module_functions
   crypt_func_pgp_traditional_encryptsign_t pgp_traditional_encryptsign;
   crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys;
   crypt_func_pgp_invoke_import_t pgp_invoke_import;
-  crypt_func_pgp_extract_keys_from_attachment_list_t
-                                 pgp_extract_keys_from_attachment_list;
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     crypt_func_pgp_extract_keys_from_attachment_list_t
+    pgp_extract_keys_from_attachment_list;
 
   /* S/MIME specific functions.  */
 
@@ -107,11 +122,10 @@ typedef struct crypt_module_functions
 /*
    A structure to decribe a crypto module. 
  */
-typedef struct crypt_module_specs
-{
-  int identifier;                      /* Identifying bit.  */
+typedef struct crypt_module_specs {
+  int identifier;               /* Identifying bit.  */
   crypt_module_functions_t functions;
-} *crypt_module_specs_t;
+}                 *crypt_module_specs_t;
 
 
 
diff --git a/crypt.c b/crypt.c
index 9c0fc4c..39fead1 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -54,7 +54,7 @@
 
 
 /* print the current time to avoid spoofing of the signature output */
-void crypt_current_time(STATE *s, char *app_name)
+void crypt_current_time (STATE * s, char *app_name)
 {
   time_t t;
   char p[STRING], tmp[STRING];
@@ -62,9 +62,8 @@ void crypt_current_time(STATE *s, char *app_name)
   if (!WithCrypto)
     return;
 
-  if (option (OPTCRYPTTIMESTAMP))
-  {
-    t = time(NULL);
+  if (option (OPTCRYPTTIMESTAMP)) {
+    t = time (NULL);
     setlocale (LC_TIME, "");
     strftime (p, sizeof (p), _(" (current time: %c)"), localtime (&t));
     setlocale (LC_TIME, "C");
@@ -72,7 +71,8 @@ void crypt_current_time(STATE *s, char *app_name)
   else
     *p = '\0';
 
-  snprintf (tmp, sizeof (tmp), _("[-- %s output follows%s --]\n"), NONULL(app_name), p);
+  snprintf (tmp, sizeof (tmp), _("[-- %s output follows%s --]\n"),
+            NONULL (app_name), p);
   state_attach_puts (tmp, s);
 }
 
@@ -95,11 +95,10 @@ void crypt_forget_passphrase (void)
 
 static void disable_coredumps (void)
 {
-  struct rlimit rl = {0, 0};
+  struct rlimit rl = { 0, 0 };
   static short done = 0;
 
-  if (!done)
-  {
+  if (!done) {
     setrlimit (RLIMIT_CORE, &rl);
     done = 1;
   }
@@ -108,7 +107,7 @@ static void disable_coredumps (void)
 #endif /* HAVE_SETRLIMIT */
 
 
-int crypt_valid_passphrase(int flags)
+int crypt_valid_passphrase (int flags)
 {
   int ret = 0;
 
@@ -127,12 +126,12 @@ int crypt_valid_passphrase(int flags)
 
 
 
-int mutt_protect (HEADER *msg, char *keylist)
+int mutt_protect (HEADER * msg, char *keylist)
 {
   BODY *pbody = NULL, *tmp_pbody = NULL;
   BODY *tmp_smime_pbody = NULL;
   BODY *tmp_pgp_pbody = NULL;
-  int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0;
+  int flags = (WithCrypto & APPLICATION_PGP) ? msg->security : 0;
   int i;
 
   if (!WithCrypto)
@@ -141,48 +140,51 @@ int mutt_protect (HEADER *msg, char *keylist)
   if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security))
     return (-1);
 
-  if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE))
-  {
+  if ((WithCrypto & APPLICATION_PGP)
+      && ((msg->security & PGPINLINE) == PGPINLINE)) {
     /* they really want to send it inline... go for it */
-    if (!isendwin ()) mutt_endwin _("Invoking PGP...");
+    if (!isendwin ())
+      mutt_endwin _("Invoking PGP...");
+
     pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist);
-    if (pbody)
-    {
+    if (pbody) {
       msg->content = pbody;
       return 0;
     }
 
     /* otherwise inline won't work...ask for revert */
-    if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline.  Revert to using PGP/MIME?"))) != M_YES)
-      {
-       mutt_error _("Mail not sent.");
-       return -1;
-      }
+    if ((i =
+         query_quadoption (OPT_PGPMIMEAUTO,
+                           _
+                           ("Message can't be sent inline.  Revert to using PGP/MIME?")))
+        != M_YES) {
+      mutt_error _("Mail not sent.");
+
+      return -1;
+    }
 
     /* go ahead with PGP/MIME */
   }
 
-  if (!isendwin ()) mutt_endwin (NULL);
+  if (!isendwin ())
+    mutt_endwin (NULL);
 
   if ((WithCrypto & APPLICATION_SMIME))
     tmp_smime_pbody = msg->content;
   if ((WithCrypto & APPLICATION_PGP))
-    tmp_pgp_pbody   = msg->content;
+    tmp_pgp_pbody = msg->content;
 
-  if (msg->security & SIGN)
-  {
+  if (msg->security & SIGN) {
     if ((WithCrypto & APPLICATION_SMIME)
-        && (msg->security & APPLICATION_SMIME))
-    {
+        && (msg->security & APPLICATION_SMIME)) {
       if (!(tmp_pbody = crypt_smime_sign_message (msg->content)))
-       return -1;
+        return -1;
       pbody = tmp_smime_pbody = tmp_pbody;
     }
 
     if ((WithCrypto & APPLICATION_PGP)
         && (msg->security & APPLICATION_PGP)
-        && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG)))
-    {
+        && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG))) {
       if (!(tmp_pbody = crypt_pgp_sign_message (msg->content)))
         return -1;
 
@@ -190,87 +192,77 @@ int mutt_protect (HEADER *msg, char *keylist)
       pbody = tmp_pgp_pbody = tmp_pbody;
     }
 
-    if (WithCrypto
-        && (msg->security & APPLICATION_SMIME)
-       && (msg->security & APPLICATION_PGP))
-    {
-       /* here comes the draft ;-) */
+    if (WithCrypto && (msg->security & APPLICATION_SMIME)
+        && (msg->security & APPLICATION_PGP)) {
+      /* here comes the draft ;-) */
     }
   }
 
 
-  if (msg->security & ENCRYPT)
-  {
+  if (msg->security & ENCRYPT) {
     if ((WithCrypto & APPLICATION_SMIME)
-        && (msg->security & APPLICATION_SMIME))
-    {
+        && (msg->security & APPLICATION_SMIME)) {
       if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
-                                                        keylist)))
-      {
-       /* signed ? free it! */
-       return (-1);
+                                                        keylist))) {
+        /* signed ? free it! */
+        return (-1);
       }
       /* free tmp_body if messages was signed AND encrypted ... */
-      if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody)
-      {
-       /* detatch and dont't delete msg->content,
-          which tmp_smime_pbody->parts after signing. */
-       tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
-       msg->content->next = NULL;
-       mutt_free_body (&tmp_smime_pbody);
+      if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody) {
+        /* detatch and dont't delete msg->content,
+           which tmp_smime_pbody->parts after signing. */
+        tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
+        msg->content->next = NULL;
+        mutt_free_body (&tmp_smime_pbody);
       }
       pbody = tmp_pbody;
     }
 
     if ((WithCrypto & APPLICATION_PGP)
-        && (msg->security & APPLICATION_PGP))
-    {
+        && (msg->security & APPLICATION_PGP)) {
       if (!(pbody = crypt_pgp_encrypt_message (tmp_pgp_pbody, keylist,
-                                               flags & SIGN)))
-      {
-
-       /* did we perform a retainable signature? */
-       if (flags != msg->security)
-       {
-         /* remove the outer multipart layer */
-         tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
-         /* get rid of the signature */
-         mutt_free_body (&tmp_pgp_pbody->next);
-       }
-
-       return (-1);
+                                               flags & SIGN))) {
+
+        /* did we perform a retainable signature? */
+        if (flags != msg->security) {
+          /* remove the outer multipart layer */
+          tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
+          /* get rid of the signature */
+          mutt_free_body (&tmp_pgp_pbody->next);
+        }
+
+        return (-1);
       }
 
       /* destroy temporary signature envelope when doing retainable 
        * signatures.
 
        */
-      if (flags != msg->security)
-      {
-       tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
-       mutt_free_body (&tmp_pgp_pbody->next);
+      if (flags != msg->security) {
+        tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
+        mutt_free_body (&tmp_pgp_pbody->next);
       }
     }
   }
 
-  if(pbody)
-      msg->content = pbody;
+  if (pbody)
+    msg->content = pbody;
 
   return 0;
 }
 
 
-   
-     
-int mutt_is_multipart_signed (BODY *b)
+
+
+int mutt_is_multipart_signed (BODY * b)
 {
   char *p;
 
   if (!b || !(b->type == TYPEMULTIPART) ||
-      !b->subtype || ascii_strcasecmp(b->subtype, "signed"))
+      !b->subtype || ascii_strcasecmp (b->subtype, "signed"))
     return 0;
 
-  if (!(p = mutt_get_parameter("protocol", b->parameter)))
+  if (!(p = mutt_get_parameter ("protocol", b->parameter)))
     return 0;
 
   if (!(ascii_strcasecmp (p, "multipart/mixed")))
@@ -279,7 +271,7 @@ int mutt_is_multipart_signed (BODY *b)
   if ((WithCrypto & APPLICATION_PGP)
       && !(ascii_strcasecmp (p, "application/pgp-signature")))
     return PGPSIGN;
-    
+
   if ((WithCrypto & APPLICATION_SMIME)
       && !(ascii_strcasecmp (p, "application/x-pkcs7-signature")))
     return SMIMESIGN;
@@ -289,45 +281,45 @@ int mutt_is_multipart_signed (BODY *b)
 
   return 0;
 }
-   
-     
-int mutt_is_multipart_encrypted (BODY *b)
+
+
+int mutt_is_multipart_encrypted (BODY * b)
 {
-  if ((WithCrypto & APPLICATION_PGP))
-  {
+  if ((WithCrypto & APPLICATION_PGP)) {
     char *p;
-  
+
     if (!b || b->type != TYPEMULTIPART ||
         !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") ||
         !(p = mutt_get_parameter ("protocol", b->parameter)) ||
         ascii_strcasecmp (p, "application/pgp-encrypted"))
       return 0;
-  
-     return PGPENCRYPT;
+
+    return PGPENCRYPT;
   }
 
   return 0;
 }
 
 
-int mutt_is_application_pgp (BODY *m)
+int mutt_is_application_pgp (BODY * m)
 {
   int t = 0;
   char *p;
-  
-  if (m->type == TYPEAPPLICATION)
-  {
-    if (!ascii_strcasecmp (m->subtype, "pgp") || !ascii_strcasecmp (m->subtype, "x-pgp-message"))
-    {
+
+  if (m->type == TYPEAPPLICATION) {
+    if (!ascii_strcasecmp (m->subtype, "pgp")
+        || !ascii_strcasecmp (m->subtype, "x-pgp-message")) {
       if ((p = mutt_get_parameter ("x-action", m->parameter))
-         && (!ascii_strcasecmp (p, "sign") || !ascii_strcasecmp (p, "signclear")))
-       t |= PGPSIGN;
+          && (!ascii_strcasecmp (p, "sign")
+              || !ascii_strcasecmp (p, "signclear")))
+        t |= PGPSIGN;
 
-      if ((p = mutt_get_parameter ("format", m->parameter)) && 
-         !ascii_strcasecmp (p, "keys-only"))
-       t |= PGPKEY;
+      if ((p = mutt_get_parameter ("format", m->parameter)) &&
+          !ascii_strcasecmp (p, "keys-only"))
+        t |= PGPKEY;
 
-      if(!t) t |= PGPENCRYPT;  /* not necessarily correct, but... */
+      if (!t)
+        t |= PGPENCRYPT;        /* not necessarily correct, but... */
     }
 
     if (!ascii_strcasecmp (m->subtype, "pgp-signed"))
@@ -336,12 +328,11 @@ int mutt_is_application_pgp (BODY *m)
     if (!ascii_strcasecmp (m->subtype, "pgp-keys"))
       t |= PGPKEY;
   }
-  else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0)
-  {
+  else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0) {
     if (((p = mutt_get_parameter ("x-mutt-action", m->parameter))
-        || (p = mutt_get_parameter ("x-action", m->parameter)) 
-        || (p = mutt_get_parameter ("action", m->parameter)))
-        && !ascii_strncasecmp ("pgp-sign", p, 8))
+         || (p = mutt_get_parameter ("x-action", m->parameter))
+         || (p = mutt_get_parameter ("action", m->parameter)))
+        && !ascii_strncasecmp ("pgp-sign", p, 8))
       t |= PGPSIGN;
     else if (p && !ascii_strncasecmp ("pgp-encrypt", p, 11))
       t |= PGPENCRYPT;
@@ -354,34 +345,32 @@ int mutt_is_application_pgp (BODY *m)
   return t;
 }
 
-int mutt_is_application_smime (BODY *m)
+int mutt_is_application_smime (BODY * m)
 {
-  char *t=NULL;
-  int len, complain=0;
+  char *t = NULL;
+  int len, complain = 0;
 
   if (!m)
     return 0;
 
-  if ((m->type & TYPEAPPLICATION) && m->subtype)
-  {
+  if ((m->type & TYPEAPPLICATION) && m->subtype) {
     /* S/MIME MIME types don't need x- anymore, see RFC2311 */
     if (!ascii_strcasecmp (m->subtype, "x-pkcs7-mime") ||
-       !ascii_strcasecmp (m->subtype, "pkcs7-mime"))
-    {
-      if ((t = mutt_get_parameter ("smime-type", m->parameter)))
-      {
-       if (!ascii_strcasecmp (t, "enveloped-data"))
-         return SMIMEENCRYPT;
-       else if (!ascii_strcasecmp (t, "signed-data"))
-         return (SMIMESIGN|SMIMEOPAQUE);
-       else return 0;
+        !ascii_strcasecmp (m->subtype, "pkcs7-mime")) {
+      if ((t = mutt_get_parameter ("smime-type", m->parameter))) {
+        if (!ascii_strcasecmp (t, "enveloped-data"))
+          return SMIMEENCRYPT;
+        else if (!ascii_strcasecmp (t, "signed-data"))
+          return (SMIMESIGN | SMIMEOPAQUE);
+        else
+          return 0;
       }
       /* Netscape 4.7 uses 
        * Content-Description: S/MIME Encrypted Message
        * instead of Content-Type parameter
        */
       if (!ascii_strcasecmp (m->description, "S/MIME Encrypted Message"))
-       return SMIMEENCRYPT;
+        return SMIMEENCRYPT;
       complain = 1;
     }
     else if (ascii_strcasecmp (m->subtype, "octet-stream"))
@@ -389,31 +378,32 @@ int mutt_is_application_smime (BODY *m)
 
     t = mutt_get_parameter ("name", m->parameter);
 
-    if (!t) t = m->d_filename;
-    if (!t) t = m->filename;
-    if (!t) 
-    {
+    if (!t)
+      t = m->d_filename;
+    if (!t)
+      t = m->filename;
+    if (!t) {
       if (complain)
-       mutt_message (_("S/MIME messages with no hints on content are unsupported."));
+        mutt_message (_
+                      ("S/MIME messages with no hints on content are unsupported."));
       return 0;
     }
 
     /* no .p7c, .p10 support yet. */
 
     len = mutt_strlen (t) - 4;
-    if (len > 0 && *(t+len) == '.')
-    {
+    if (len > 0 && *(t + len) == '.') {
       len++;
-      if (!ascii_strcasecmp ((t+len), "p7m"))
+      if (!ascii_strcasecmp ((t + len), "p7m"))
 #if 0
-       return SMIMEENCRYPT;
+        return SMIMEENCRYPT;
 #else
-      /* Not sure if this is the correct thing to do, but 
-         it's required for compatibility with Outlook */
-       return (SMIMESIGN|SMIMEOPAQUE);
+        /* Not sure if this is the correct thing to do, but 
+           it's required for compatibility with Outlook */
+        return (SMIMESIGN | SMIMEOPAQUE);
 #endif
-      else if (!ascii_strcasecmp ((t+len), "p7s"))
-       return (SMIMESIGN|SMIMEOPAQUE);
+      else if (!ascii_strcasecmp ((t + len), "p7s"))
+        return (SMIMESIGN | SMIMEOPAQUE);
     }
   }
 
@@ -425,59 +415,56 @@ int mutt_is_application_smime (BODY *m)
 
 
 
-int crypt_query (BODY *m)
+int crypt_query (BODY * m)
 {
   int t = 0;
 
   if (!WithCrypto)
     return 0;
-  
+
   if (!m)
     return 0;
 
-  if (m->type == TYPEAPPLICATION)
-  {
+  if (m->type == TYPEAPPLICATION) {
     if ((WithCrypto & APPLICATION_PGP))
-      t |= mutt_is_application_pgp(m);
-
-    if ((WithCrypto & APPLICATION_SMIME))
-    {
-      t |= mutt_is_application_smime(m);
-      if (t && m->goodsig) t |= GOODSIGN;
-      if (t && m->badsig) t |= BADSIGN;
+      t |= mutt_is_application_pgp (m);
+
+    if ((WithCrypto & APPLICATION_SMIME)) {
+      t |= mutt_is_application_smime (m);
+      if (t && m->goodsig)
+        t |= GOODSIGN;
+      if (t && m->badsig)
+        t |= BADSIGN;
     }
   }
-  else if ((WithCrypto & APPLICATION_PGP) && m->type == TYPETEXT)
-  {
+  else if ((WithCrypto & APPLICATION_PGP) && m->type == TYPETEXT) {
     t |= mutt_is_application_pgp (m);
     if (t && m->goodsig)
       t |= GOODSIGN;
   }
-  
-  if (m->type == TYPEMULTIPART)
-  {
-    t |= mutt_is_multipart_encrypted(m);
+
+  if (m->type == TYPEMULTIPART) {
+    t |= mutt_is_multipart_encrypted (m);
     t |= mutt_is_multipart_signed (m);
 
-    if (t && m->goodsig) 
+    if (t && m->goodsig)
       t |= GOODSIGN;
   }
 
-  if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE)
-  {
+  if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE) {
     BODY *p;
     int u, v, w;
-    
-    u = m->parts ? 0xffffffff : 0;     /* Bits set in all parts */
-    w = 0;                             /* Bits set in any part  */
-    for (p = m->parts; p; p = p->next)
-    {
-      v  = crypt_query (p);
-      u &= v; w |= v;
+
+    u = m->parts ? 0xffffffff : 0;      /* Bits set in all parts */
+    w = 0;                      /* Bits set in any part  */
+
+    for (p = m->parts; p; p = p->next) {
+      v = crypt_query (p);
+      u &= v;
+      w |= v;
     }
     t |= u | (w & ~GOODSIGN);
-    
+
     if ((w & GOODSIGN) && !(u & GOODSIGN))
       t |= PARTSIGN;
   }
@@ -488,7 +475,7 @@ int crypt_query (BODY *m)
 
 
 
-int crypt_write_signed(BODY *a, STATE *s, const char *tempfile)
+int crypt_write_signed (BODY * a, STATE * s, const char *tempfile)
 {
   FILE *fp;
   int c;
@@ -498,34 +485,31 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile)
   if (!WithCrypto)
     return -1;
 
-  if (!(fp = safe_fopen (tempfile, "w")))
-  {
+  if (!(fp = safe_fopen (tempfile, "w"))) {
     mutt_perror (tempfile);
     return -1;
   }
-      
+
   fseek (s->fpin, a->hdr_offset, 0);
   bytes = a->length + a->offset - a->hdr_offset;
   hadcr = 0;
-  while (bytes > 0)
-  {
+  while (bytes > 0) {
     if ((c = fgetc (s->fpin)) == EOF)
       break;
-    
+
     bytes--;
-    
-    if  (c == '\r')
+
+    if (c == '\r')
       hadcr = 1;
-    else 
-    {
+    else {
       if (c == '\n' && !hadcr)
-       fputc ('\r', fp);
-      
+        fputc ('\r', fp);
+
       hadcr = 0;
     }
-    
+
     fputc (c, fp);
-    
+
   }
   fclose (fp);
 
@@ -534,36 +518,32 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile)
 
 
 
-void convert_to_7bit (BODY *a)
+void convert_to_7bit (BODY * a)
 {
   if (!WithCrypto)
     return;
 
-  while (a)
-  {
-    if (a->type == TYPEMULTIPART)
-    {
-      if (a->encoding != ENC7BIT)
-      {
+  while (a) {
+    if (a->type == TYPEMULTIPART) {
+      if (a->encoding != ENC7BIT) {
         a->encoding = ENC7BIT;
-       convert_to_7bit(a->parts);
+        convert_to_7bit (a->parts);
       }
       else if ((WithCrypto & APPLICATION_PGP) && option (OPTPGPSTRICTENC))
-       convert_to_7bit (a->parts);
-    } 
+        convert_to_7bit (a->parts);
+    }
     else if (a->type == TYPEMESSAGE &&
-            mutt_strcasecmp(a->subtype, "delivery-status"))
-    {
-      if(a->encoding != ENC7BIT)
-       mutt_message_to_7bit (a, NULL);
+             mutt_strcasecmp (a->subtype, "delivery-status")) {
+      if (a->encoding != ENC7BIT)
+        mutt_message_to_7bit (a, NULL);
     }
     else if (a->encoding == ENC8BIT)
       a->encoding = ENCQUOTEDPRINTABLE;
     else if (a->encoding == ENCBINARY)
       a->encoding = ENCBASE64;
     else if (a->content && a->encoding != ENCBASE64 &&
-            (a->content->from || (a->content->space && 
-                                  option (OPTPGPSTRICTENC))))
+             (a->content->from || (a->content->space &&
+                                   option (OPTPGPSTRICTENC))))
       a->encoding = ENCQUOTEDPRINTABLE;
     a = a->next;
   }
@@ -583,8 +563,7 @@ void crypt_extract_keys_from_messages (HEADER * h)
     return;
 
   mutt_mktemp (tempfname);
-  if (!(fpout = safe_fopen (tempfname, "w")))
-  {
+  if (!(fpout = safe_fopen (tempfname, "w"))) {
     mutt_perror (tempfname);
     return;
   }
@@ -592,100 +571,90 @@ void crypt_extract_keys_from_messages (HEADER * h)
   if ((WithCrypto & APPLICATION_PGP))
     set_option (OPTDONTHANDLEPGPKEYS);
 
-  if (!h)
-  {
-    for (i = 0; i < Context->vcount; i++)
-    {
-      if (Context->hdrs[Context->v2r[i]]->tagged)
-      {
-       mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
-       if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
-           !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->security))
-       {
-         fclose (fpout);
-         break;
-       }
-
-       if ((WithCrypto & APPLICATION_PGP)
-            && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP))
-       {
-         mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], 
-                            M_CM_DECODE|M_CM_CHARCONV, 0);
-         fflush(fpout);
-         
-         mutt_endwin (_("Trying to extract PGP keys...\n"));
-         crypt_pgp_invoke_import (tempfname);
-       }
-
-       if ((WithCrypto & APPLICATION_SMIME)
-            && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME))
-       {
-         if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT)
-           mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
-                              M_CM_NOHEADER|M_CM_DECODE_CRYPT
-                               |M_CM_DECODE_SMIME, 0);
-         else
-           mutt_copy_message (fpout, Context,
-                              Context->hdrs[Context->v2r[i]], 0, 0);
-         fflush(fpout);
+  if (!h) {
+    for (i = 0; i < Context->vcount; i++) {
+      if (Context->hdrs[Context->v2r[i]]->tagged) {
+        mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
+        if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
+            !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
+                                     security)) {
+          fclose (fpout);
+          break;
+        }
+
+        if ((WithCrypto & APPLICATION_PGP)
+            && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP)) {
+          mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
+                             M_CM_DECODE | M_CM_CHARCONV, 0);
+          fflush (fpout);
+
+          mutt_endwin (_("Trying to extract PGP keys...\n"));
+          crypt_pgp_invoke_import (tempfname);
+        }
+
+        if ((WithCrypto & APPLICATION_SMIME)
+            && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME)) {
+          if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT)
+            mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
+                               M_CM_NOHEADER | M_CM_DECODE_CRYPT
+                               | M_CM_DECODE_SMIME, 0);
+          else
+            mutt_copy_message (fpout, Context,
+                               Context->hdrs[Context->v2r[i]], 0, 0);
+          fflush (fpout);
 
           if (Context->hdrs[Context->v2r[i]]->env->from)
-           tmp = mutt_expand_aliases (h->env->from);
-         else if (Context->hdrs[Context->v2r[i]]->env->sender)
-           tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]
-                                                    ->env->sender);
+            tmp = mutt_expand_aliases (h->env->from);
+          else if (Context->hdrs[Context->v2r[i]]->env->sender)
+            tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]
+                                       ->env->sender);
           mbox = tmp ? tmp->mailbox : NULL;
-         if (mbox)
-         {
-           mutt_endwin (_("Trying to extract S/MIME certificates...\n"));
-           crypt_smime_invoke_import (tempfname, mbox);
-           tmp = NULL;
-         }
-       }
-
-       rewind (fpout);
+          if (mbox) {
+            mutt_endwin (_("Trying to extract S/MIME certificates...\n"));
+            crypt_smime_invoke_import (tempfname, mbox);
+            tmp = NULL;
+          }
+        }
+
+        rewind (fpout);
       }
     }
   }
-  else
-  {
+  else {
     mutt_parse_mime_message (Context, h);
-    if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security)))
-    {
+    if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security))) {
       if ((WithCrypto & APPLICATION_PGP)
-          && (h->security & APPLICATION_PGP))
-      {
-       mutt_copy_message (fpout, Context, h, M_CM_DECODE|M_CM_CHARCONV, 0);
-       fflush(fpout);
-       mutt_endwin (_("Trying to extract PGP keys...\n"));
-       crypt_pgp_invoke_import (tempfname);
+          && (h->security & APPLICATION_PGP)) {
+        mutt_copy_message (fpout, Context, h, M_CM_DECODE | M_CM_CHARCONV, 0);
+        fflush (fpout);
+        mutt_endwin (_("Trying to extract PGP keys...\n"));
+        crypt_pgp_invoke_import (tempfname);
       }
 
       if ((WithCrypto & APPLICATION_SMIME)
-          && (h->security & APPLICATION_SMIME))
-      {
-       if (h->security & ENCRYPT)
-         mutt_copy_message (fpout, Context, h, M_CM_NOHEADER
-                                                |M_CM_DECODE_CRYPT
-                                                |M_CM_DECODE_SMIME, 0);
-       else
-         mutt_copy_message (fpout, Context, h, 0, 0);
-
-       fflush(fpout);
-       if (h->env->from) tmp = mutt_expand_aliases (h->env->from);
-       else if (h->env->sender)  tmp = mutt_expand_aliases (h->env->sender); 
-       mbox = tmp ? tmp->mailbox : NULL;
-       if (mbox) /* else ? */
-       {
-         mutt_message (_("Trying to extract S/MIME certificates...\n"));
-         crypt_smime_invoke_import (tempfname, mbox);
-       }
+          && (h->security & APPLICATION_SMIME)) {
+        if (h->security & ENCRYPT)
+          mutt_copy_message (fpout, Context, h, M_CM_NOHEADER
+                             | M_CM_DECODE_CRYPT | M_CM_DECODE_SMIME, 0);
+        else
+          mutt_copy_message (fpout, Context, h, 0, 0);
+
+        fflush (fpout);
+        if (h->env->from)
+          tmp = mutt_expand_aliases (h->env->from);
+        else if (h->env->sender)
+          tmp = mutt_expand_aliases (h->env->sender);
+        mbox = tmp ? tmp->mailbox : NULL;
+        if (mbox) {             /* else ? */
+          mutt_message (_("Trying to extract S/MIME certificates...\n"));
+          crypt_smime_invoke_import (tempfname, mbox);
+        }
       }
     }
   }
-      
+
   fclose (fpout);
-  if (isendwin())
+  if (isendwin ())
     mutt_any_key_to_continue (NULL);
 
   mutt_unlink (tempfname);
@@ -696,7 +665,7 @@ void crypt_extract_keys_from_messages (HEADER * h)
 
 
 
-int crypt_get_keys (HEADER *msg, char **keylist)
+int crypt_get_keys (HEADER * msg, char **keylist)
 {
   /* Do a quick check to make sure that we can find all of the encryption
    * keys if the user has requested this service.
@@ -710,43 +679,38 @@ int crypt_get_keys (HEADER *msg, char **keylist)
 
   *keylist = NULL;
 
-  if (msg->security & ENCRYPT)
-  {
-     if ((WithCrypto & APPLICATION_PGP)
-         && (msg->security & APPLICATION_PGP))
-     {
-       if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
-                              msg->env->bcc)) == NULL)
-           return (-1);
-       unset_option (OPTPGPCHECKTRUST);
-     }
-     if ((WithCrypto & APPLICATION_SMIME)
-         && (msg->security & APPLICATION_SMIME))
-     {
-       if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
-                                            msg->env->bcc)) == NULL)
-           return (-1);
-     }
+  if (msg->security & ENCRYPT) {
+    if ((WithCrypto & APPLICATION_PGP)
+        && (msg->security & APPLICATION_PGP)) {
+      if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
+                                          msg->env->bcc)) == NULL)
+        return (-1);
+      unset_option (OPTPGPCHECKTRUST);
+    }
+    if ((WithCrypto & APPLICATION_SMIME)
+        && (msg->security & APPLICATION_SMIME)) {
+      if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
+                                            msg->env->bcc)) == NULL)
+        return (-1);
+    }
   }
-    
+
   return (0);
 }
 
 
 
-static void crypt_fetch_signatures (BODY ***signatures, BODY *a, int *n)
+static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n)
 {
   if (!WithCrypto)
     return;
 
-  for (; a; a = a->next)
-  {
+  for (; a; a = a->next) {
     if (a->type == TYPEMULTIPART)
       crypt_fetch_signatures (signatures, a->parts, n);
-    else
-    {
-      if((*n % 5) == 0)
-       safe_realloc (signatures, (*n + 6) * sizeof (BODY **));
+    else {
+      if ((*n % 5) == 0)
+        safe_realloc (signatures, (*n + 6) * sizeof (BODY **));
 
       (*signatures)[(*n)++] = a;
     }
@@ -758,13 +722,13 @@ static void crypt_fetch_signatures (BODY ***signatures, BODY *a, int *n)
  * This routine verifies a  "multipart/signed"  body.
  */
 
-void mutt_signed_handler (BODY *a, STATE *s)
+void mutt_signed_handler (BODY * a, STATE * s)
 {
   char tempfile[_POSIX_PATH_MAX];
   char *protocol;
   int protocol_major = TYPEOTHER;
   char *protocol_minor = NULL;
-  
+
   BODY *b = a;
   BODY **signatures = NULL;
   int sigcnt = 0;
@@ -778,26 +742,25 @@ void mutt_signed_handler (BODY *a, STATE *s)
   a = a->parts;
 
   /* extract the protocol information */
-  
-  if (protocol)
-  {
+
+  if (protocol) {
     char major[STRING];
     char *t;
 
-    if ((protocol_minor = strchr (protocol, '/'))) protocol_minor++;
-    
-    strfcpy (major, protocol, sizeof(major));
-    if((t = strchr(major, '/')))
+    if ((protocol_minor = strchr (protocol, '/')))
+      protocol_minor++;
+
+    strfcpy (major, protocol, sizeof (major));
+    if ((t = strchr (major, '/')))
       *t = '\0';
-    
+
     protocol_major = mutt_check_mime_type (major);
   }
 
   /* consistency check */
 
-  if (!(a && a->next && a->next->type == protocol_major && 
-      !mutt_strcasecmp (a->next->subtype, protocol_minor)))
-  {
+  if (!(a && a->next && a->next->type == protocol_major &&
+        !mutt_strcasecmp (a->next->subtype, protocol_minor))) {
     state_attach_puts (_("[-- Error: "
                          "Inconsistent multipart/signed structure! --]\n\n"),
                        s);
@@ -805,72 +768,64 @@ void mutt_signed_handler (BODY *a, STATE *s)
     return;
   }
 
-  
+
   if ((WithCrypto & APPLICATION_PGP)
       && protocol_major == TYPEAPPLICATION
-      && !mutt_strcasecmp (protocol_minor, "pgp-signature"))
-    ;
+      && !mutt_strcasecmp (protocol_minor, "pgp-signature"));
   else if ((WithCrypto & APPLICATION_SMIME)
            && protocol_major == TYPEAPPLICATION
-          && !(mutt_strcasecmp (protocol_minor, "x-pkcs7-signature")
-              && mutt_strcasecmp (protocol_minor, "pkcs7-signature")))
-    ;
+           && !(mutt_strcasecmp (protocol_minor, "x-pkcs7-signature")
+                && mutt_strcasecmp (protocol_minor, "pkcs7-signature")));
   else if (protocol_major == TYPEMULTIPART
-          && !mutt_strcasecmp (protocol_minor, "mixed"))
-    ;
-  else
-  {
+           && !mutt_strcasecmp (protocol_minor, "mixed"));
+  else {
     state_printf (s, _("[-- Error: "
                        "Unknown multipart/signed protocol %s! --]\n\n"),
                   protocol);
     mutt_body_handler (a, s);
     return;
   }
-  
-  if (s->flags & M_DISPLAY)
-  {
-    
+
+  if (s->flags & M_DISPLAY) {
+
     crypt_fetch_signatures (&signatures, a->next, &sigcnt);
-    
-    if (sigcnt)
-    {
+
+    if (sigcnt) {
       mutt_mktemp (tempfile);
-      if (crypt_write_signed (a, s, tempfile) == 0)
-      {
-       for (i = 0; i < sigcnt; i++)
-       {
-         if ((WithCrypto & APPLICATION_PGP)
-              && signatures[i]->type == TYPEAPPLICATION 
-             && !mutt_strcasecmp (signatures[i]->subtype, "pgp-signature"))
-         {
-           if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0)
-             goodsig = 0;
-           
-           continue;
-         }
-
-         if ((WithCrypto & APPLICATION_SMIME)
-              && signatures[i]->type == TYPEAPPLICATION 
-             && (!mutt_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature")
-                 || !mutt_strcasecmp(signatures[i]->subtype, "pkcs7-signature")))
-         {
-           if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0)
-             goodsig = 0;
-           
-           continue;
-         }
-
-         state_printf (s, _("[-- Warning: "
+      if (crypt_write_signed (a, s, tempfile) == 0) {
+        for (i = 0; i < sigcnt; i++) {
+          if ((WithCrypto & APPLICATION_PGP)
+              && signatures[i]->type == TYPEAPPLICATION
+              && !mutt_strcasecmp (signatures[i]->subtype, "pgp-signature")) {
+            if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0)
+              goodsig = 0;
+
+            continue;
+          }
+
+          if ((WithCrypto & APPLICATION_SMIME)
+              && signatures[i]->type == TYPEAPPLICATION
+              &&
+              (!mutt_strcasecmp (signatures[i]->subtype, "x-pkcs7-signature")
+               || !mutt_strcasecmp (signatures[i]->subtype,
+                                    "pkcs7-signature"))) {
+            if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0)
+              goodsig = 0;
+
+            continue;
+          }
+
+          state_printf (s, _("[-- Warning: "
                              "We can't verify %s/%s signatures. --]\n\n"),
-                         TYPE(signatures[i]), signatures[i]->subtype);
-       }
+                        TYPE (signatures[i]), signatures[i]->subtype);
+        }
       }
-      
+
       mutt_unlink (tempfile);
 
       b->goodsig = goodsig;
-      b->badsig  = !goodsig;
-      
+      b->badsig = !goodsig;
+
       /* Now display the signed body */
       state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
 
@@ -878,13 +833,12 @@ void mutt_signed_handler (BODY *a, STATE *s)
       FREE (&signatures);
     }
     else
-      state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s);
+      state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"),
+                         s);
   }
-  
+
   mutt_body_handler (a, s);
-  
+
   if (s->flags & M_DISPLAY && sigcnt)
     state_attach_puts (_("\n[-- End of signed data --]\n"), s);
 }
-
-
index f6a1bab..28e8492 100644 (file)
@@ -61,37 +61,36 @@ void crypt_init (void)
 #ifdef CRYPT_BACKEND_CLASSIC_PGP
   if (
 #ifdef CRYPT_BACKEND_GPGME
-      (! option (OPTCRYPTUSEGPGME))
+       (!option (OPTCRYPTUSEGPGME))
 #else
        1
 #endif
-      )
+    )
     crypto_module_register (&crypt_mod_pgp_classic);
 #endif
 
 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
   if (
 #ifdef CRYPT_BACKEND_GPGME
-      (! option (OPTCRYPTUSEGPGME))
+       (!option (OPTCRYPTUSEGPGME))
 #else
        1
 #endif
-      )
+    )
     crypto_module_register (&crypt_mod_smime_classic);
 #endif
 
-  if (option (OPTCRYPTUSEGPGME))
-    {
+  if (option (OPTCRYPTUSEGPGME)) {
 #ifdef CRYPT_BACKEND_GPGME
-      crypto_module_register (&crypt_mod_pgp_gpgme);
-      crypto_module_register (&crypt_mod_smime_gpgme);
+    crypto_module_register (&crypt_mod_pgp_gpgme);
+    crypto_module_register (&crypt_mod_smime_gpgme);
 #else
-      mutt_message (_("\"crypt_use_gpgme\" set"
-                      " but not build with GPGME support."));
-      if (mutt_any_key_to_continue (NULL) == -1)
-       mutt_exit(1);
+    mutt_message (_("\"crypt_use_gpgme\" set"
+                    " but not build with GPGME support."));
+    if (mutt_any_key_to_continue (NULL) == -1)
+      mutt_exit (1);
 #endif
-    }
+  }
 
 #if defined CRYPT_BACKEND_CLASSIG_PGP || defined CRYPT_BACKEND_CLASSIG_SMIME || defined CRYPT_BACKEND_GPGME
   if (CRYPT_MOD_CALL_CHECK (PGP, init))
@@ -106,14 +105,16 @@ void crypt_init (void)
 /* Show a message that a backend will be invoked. */
 void crypt_invoke_message (int type)
 {
-  if ((WithCrypto & APPLICATION_PGP) && (type & APPLICATION_PGP))
+  if ((WithCrypto & APPLICATION_PGP) && (type & APPLICATION_PGP)) {
     mutt_message _("Invoking PGP...");
-  else if ((WithCrypto & APPLICATION_SMIME) && (type & APPLICATION_SMIME))
+  }
+  else if ((WithCrypto & APPLICATION_SMIME) && (type & APPLICATION_SMIME)) {
     mutt_message _("Invoking SMIME...");
+  }
 }
+\f
 
 
-\f
 /* 
 
     PGP
@@ -138,7 +139,7 @@ int crypt_pgp_valid_passphrase (void)
 
 
 /* Decrypt a PGP/MIME message. */
-int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, decrypt_mime))
     return (CRYPT_MOD_CALL (PGP, decrypt_mime)) (a, b, c, d);
@@ -147,28 +148,28 @@ int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 }
 
 /* MIME handler for the application/pgp content-type. */
-void crypt_pgp_application_pgp_handler (BODY *m, STATE *s)
+void crypt_pgp_application_pgp_handler (BODY * m, STATE * s)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, application_handler))
     (CRYPT_MOD_CALL (PGP, application_handler)) (m, s);
 }
 
 /* MIME handler for an PGP/MIME encrypted message. */
-void crypt_pgp_encrypted_handler (BODY *a, STATE *s)
+void crypt_pgp_encrypted_handler (BODY * a, STATE * s)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler))
     (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
 }
 
 /* fixme: needs documentation. */
-void crypt_pgp_invoke_getkeys (ADDRESS *addr)
+void crypt_pgp_invoke_getkeys (ADDRESS * addr)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_getkeys))
     (CRYPT_MOD_CALL (PGP, pgp_invoke_getkeys)) (addr);
 }
 
 /* Check for a traditional PGP message in body B. */
-int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, pgp_check_traditional))
     return (CRYPT_MOD_CALL (PGP, pgp_check_traditional)) (fp, b, tagged_only);
@@ -177,10 +178,11 @@ int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
 }
 
 /* fixme: needs documentation. */
-BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
+BODY *crypt_pgp_traditional_encryptsign (BODY * a, int flags, char *keylist)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, pgp_traditional_encryptsign))
-    return (CRYPT_MOD_CALL (PGP, pgp_traditional_encryptsign)) (a, flags, keylist);
+    return (CRYPT_MOD_CALL (PGP, pgp_traditional_encryptsign)) (a, flags,
+                                                                keylist);
 
   return NULL;
 }
@@ -196,7 +198,7 @@ BODY *crypt_pgp_make_key_attachment (char *tempf)
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *crypt_pgp_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, findkeys))
     return (CRYPT_MOD_CALL (PGP, findkeys)) (to, cc, bcc);
@@ -205,7 +207,7 @@ char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 }
 
 /* Create a new body with a PGP signed message from A. */
-BODY *crypt_pgp_sign_message (BODY *a)
+BODY *crypt_pgp_sign_message (BODY * a)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, sign_message))
     return (CRYPT_MOD_CALL (PGP, sign_message)) (a);
@@ -215,7 +217,7 @@ BODY *crypt_pgp_sign_message (BODY *a)
 
 /* Warning: A is no longer freed in this routine, you need to free it
    later.  This is necessary for $fcc_attach. */
-BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign)
+BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, pgp_encrypt_message))
     return (CRYPT_MOD_CALL (PGP, pgp_encrypt_message)) (a, keylist, sign);
@@ -231,7 +233,7 @@ void crypt_pgp_invoke_import (const char *fname)
 }
 
 /* fixme: needs documentation */
-int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+int crypt_pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempf)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, verify_one))
     return (CRYPT_MOD_CALL (PGP, verify_one)) (sigbdy, s, tempf);
@@ -240,7 +242,7 @@ int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
 }
 
 
-int crypt_pgp_send_menu (HEADER *msg, int *redraw)
+int crypt_pgp_send_menu (HEADER * msg, int *redraw)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, send_menu))
     return (CRYPT_MOD_CALL (PGP, send_menu)) (msg, redraw);
@@ -250,14 +252,16 @@ int crypt_pgp_send_menu (HEADER *msg, int *redraw)
 
 
 /* fixme: needs documentation */
-void crypt_pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
+void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag,
+                                                  BODY * top)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, pgp_extract_keys_from_attachment_list))
-    (CRYPT_MOD_CALL (PGP, pgp_extract_keys_from_attachment_list)) (fp, tag, top);
+    (CRYPT_MOD_CALL (PGP, pgp_extract_keys_from_attachment_list)) (fp, tag,
+                                                                   top);
 }
+\f
 
 
-\f
 /* 
 
    S/MIME 
@@ -281,7 +285,7 @@ int crypt_smime_valid_passphrase (void)
 }
 
 /* Decrypt am S/MIME message. */
-int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, decrypt_mime))
     return (CRYPT_MOD_CALL (SMIME, decrypt_mime)) (a, b, c, d);
@@ -290,28 +294,28 @@ int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 }
 
 /* MIME handler for the application/smime content-type. */
-void crypt_smime_application_smime_handler (BODY *m, STATE *s)
+void crypt_smime_application_smime_handler (BODY * m, STATE * s)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, application_handler))
     (CRYPT_MOD_CALL (SMIME, application_handler)) (m, s);
 }
 
 /* MIME handler for an PGP/MIME encrypted message. */
-void crypt_smime_encrypted_handler (BODY *a, STATE *s)
+void crypt_smime_encrypted_handler (BODY * a, STATE * s)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, encrypted_handler))
     (CRYPT_MOD_CALL (SMIME, encrypted_handler)) (a, s);
 }
 
 /* fixme: Needs documentation. */
-void crypt_smime_getkeys (ENVELOPE *env)
+void crypt_smime_getkeys (ENVELOPE * env)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, smime_getkeys))
     (CRYPT_MOD_CALL (SMIME, smime_getkeys)) (env);
 }
 
 /* Check that the sender matches. */
-int crypt_smime_verify_sender(HEADER *h)
+int crypt_smime_verify_sender (HEADER * h)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, smime_verify_sender))
     return (CRYPT_MOD_CALL (SMIME, smime_verify_sender)) (h);
@@ -321,7 +325,7 @@ int crypt_smime_verify_sender(HEADER *h)
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *crypt_smime_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, findkeys))
     return (CRYPT_MOD_CALL (SMIME, findkeys)) (to, cc, bcc);
@@ -330,7 +334,7 @@ char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 }
 
 /* fixme: Needs documentation. */
-BODY *crypt_smime_sign_message (BODY *a)
+BODY *crypt_smime_sign_message (BODY * a)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, sign_message))
     return (CRYPT_MOD_CALL (SMIME, sign_message)) (a);
@@ -339,7 +343,7 @@ BODY *crypt_smime_sign_message (BODY *a)
 }
 
 /* fixme: needs documentation. */
-BODY *crypt_smime_build_smime_entity (BODY *a, char *certlist)
+BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, smime_build_smime_entity))
     return (CRYPT_MOD_CALL (SMIME, smime_build_smime_entity)) (a, certlist);
@@ -355,7 +359,7 @@ void crypt_smime_invoke_import (char *infile, char *mailbox)
 }
 
 /* fixme: needs documentation */
-int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+int crypt_smime_verify_one (BODY * sigbdy, STATE * s, const char *tempf)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, verify_one))
     return (CRYPT_MOD_CALL (SMIME, verify_one)) (sigbdy, s, tempf);
@@ -363,7 +367,7 @@ int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
   return -1;
 }
 
-int crypt_smime_send_menu (HEADER *msg, int *redraw)
+int crypt_smime_send_menu (HEADER * msg, int *redraw)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, send_menu))
     return (CRYPT_MOD_CALL (SMIME, send_menu)) (msg, redraw);
index 6601ce8..0678d28 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -68,8 +68,7 @@ void mutt_refresh (void)
    customize this is of course the Mutt way.  */
 void mutt_need_hard_redraw (void)
 {
-  if (!getenv ("DISPLAY"))
-  {
+  if (!getenv ("DISPLAY")) {
     keypad (stdscr, TRUE);
     clearok (stdscr, TRUE);
     set_option (OPTNEEDREDRAW);
@@ -79,9 +78,9 @@ void mutt_need_hard_redraw (void)
 event_t mutt_getch (void)
 {
   int ch;
-  event_t err = {-1, OP_NULL }, ret;
+  event_t err = { -1, OP_NULL }, ret;
 
-  if (!option(OPTUNBUFFEREDINPUT) && UngetCount)
+  if (!option (OPTUNBUFFEREDINPUT) && UngetCount)
     return (KeyEvent[--UngetCount]);
 
   SigInt = 0;
@@ -98,11 +97,10 @@ event_t mutt_getch (void)
   if (SigInt)
     mutt_query_exit ();
 
-  if(ch == ERR)
+  if (ch == ERR)
     return err;
-  
-  if ((ch & 0x80) && option (OPTMETAKEY))
-  {
+
+  if ((ch & 0x80) && option (OPTMETAKEY)) {
     /* send ALT-x as ESC-x */
     ch &= ~0x80;
     mutt_ungetch (ch, 0);
@@ -116,57 +114,59 @@ event_t mutt_getch (void)
   return (ch == ctrl ('G') ? err : ret);
 }
 
-int _mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles)
+int _mutt_get_field ( /* const */ char *field, char *buf, size_t buflen,
+                     int complete, int multiple, char ***files, int *numfiles)
 {
   int ret;
   int x, y;
 
-  ENTER_STATE *es = mutt_new_enter_state();
-  
-  do
-  {
-    CLEARLINE (LINES-1);
+  ENTER_STATE *es = mutt_new_enter_state ();
+
+  do {
+    CLEARLINE (LINES - 1);
     addstr (field);
     mutt_refresh ();
     getyx (stdscr, y, x);
-    ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, numfiles, es);
+    ret =
+      _mutt_enter_string (buf, buflen, y, x, complete, multiple, files,
+                          numfiles, es);
   }
   while (ret == 1);
-  CLEARLINE (LINES-1);
+  CLEARLINE (LINES - 1);
   mutt_free_enter_state (&es);
-  
+
   return (ret);
 }
 
 int mutt_get_password (char *msg, char *buf, size_t buflen)
 {
   int rc;
-  
-  CLEARLINE (LINES-1);
+
+  CLEARLINE (LINES - 1);
   addstr (msg);
   set_option (OPTUNBUFFEREDINPUT);
   rc = mutt_enter_string (buf, buflen, LINES - 1, mutt_strlen (msg), M_PASS);
   unset_option (OPTUNBUFFEREDINPUT);
-  CLEARLINE (LINES-1);
+  CLEARLINE (LINES - 1);
   return (rc);
 }
 
 void mutt_clear_error (void)
 {
   Errorbuf[0] = 0;
-  if (!option(OPTNOCURSES))
-    CLEARLINE (LINES-1);
+  if (!option (OPTNOCURSES))
+    CLEARLINE (LINES - 1);
 }
 
 static void fix_end_of_file (const char *data)
 {
   FILE *fp;
   int c;
-  
+
   if ((fp = safe_fopen (data, "a+")) == NULL)
     return;
-  fseek (fp,-1,SEEK_END);
-  if ((c = fgetc(fp)) != '\n')
+  fseek (fp, -1, SEEK_END);
+  if ((c = fgetc (fp)) != '\n')
     fputc ('\n', fp);
   safe_fclose (&fp);
 }
@@ -174,7 +174,7 @@ static void fix_end_of_file (const char *data)
 void mutt_edit_file (const char *editor, const char *data)
 {
   char cmd[LONG_STRING];
-  
+
   mutt_endwin (NULL);
   mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
   if (mutt_system (cmd) == -1)
@@ -201,14 +201,14 @@ int mutt_yesorno (const char *msg, int def)
   char answer[2];
 
   answer[1] = 0;
-  
+
   reyes_ok = (expr = nl_langinfo (YESEXPR)) && expr[0] == '^' &&
-             !regcomp (&reyes, expr, REG_NOSUB|REG_EXTENDED);
+    !regcomp (&reyes, expr, REG_NOSUB | REG_EXTENDED);
   reno_ok = (expr = nl_langinfo (NOEXPR)) && expr[0] == '^' &&
-            !regcomp (&reno, expr, REG_NOSUB|REG_EXTENDED);
+    !regcomp (&reno, expr, REG_NOSUB | REG_EXTENDED);
 #endif
 
-  CLEARLINE(LINES-1);
+  CLEARLINE (LINES - 1);
 
   /*
    * In order to prevent the default answer to the question to wrapped
@@ -217,60 +217,53 @@ int mutt_yesorno (const char *msg, int def)
    * to fit.
    */
   answer_string = safe_malloc (COLS + 1);
-  snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no, def == M_YES ? no : yes);
+  snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
+            def == M_YES ? no : yes);
   answer_string_len = strlen (answer_string);
   printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
   FREE (&answer_string);
 
-  FOREVER
-  {
+  FOREVER {
     mutt_refresh ();
     ch = mutt_getch ();
     if (CI_is_return (ch.ch))
       break;
-    if (ch.ch == -1)
-    {
+    if (ch.ch == -1) {
       def = -1;
       break;
     }
 
 #ifdef HAVE_LANGINFO_YESEXPR
     answer[0] = ch.ch;
-    if (reyes_ok ? 
-        (regexec (& reyes, answer, 0, 0, 0) == 0) :
+    if (reyes_ok ? (regexec (&reyes, answer, 0, 0, 0) == 0) :
 #else
     if (
 #endif
-        (tolower (ch.ch) == 'y'))
-    {
+         (tolower (ch.ch) == 'y')) {
       def = M_YES;
       break;
     }
     else if (
 #ifdef HAVE_LANGINFO_YESEXPR
-             reno_ok ?
-             (regexec (& reno, answer, 0, 0, 0) == 0) :
+              reno_ok ? (regexec (&reno, answer, 0, 0, 0) == 0) :
 #endif
-             (tolower (ch.ch) == 'n'))
-    {
+              (tolower (ch.ch) == 'n')) {
       def = M_NO;
       break;
     }
-    else
-    {
-      BEEP();
+    else {
+      BEEP ();
     }
   }
 
-#ifdef HAVE_LANGINFO_YESEXPR    
+#ifdef HAVE_LANGINFO_YESEXPR
   if (reyes_ok)
-    regfree (& reyes);
+    regfree (&reyes);
   if (reno_ok)
-    regfree (& reno);
+    regfree (&reno);
 #endif
 
-  if (def != -1)
-  {
+  if (def != -1) {
     addstr ((char *) (def == M_YES ? yes : no));
     mutt_refresh ();
   }
@@ -283,13 +276,12 @@ void mutt_query_exit (void)
   mutt_flushinp ();
   curs_set (1);
   if (Timeout)
-    timeout (-1); /* restore blocking operation */
-  if (mutt_yesorno (_("Exit Mutt-ng?"), M_YES) == M_YES)
-  {
+    timeout (-1);               /* restore blocking operation */
+  if (mutt_yesorno (_("Exit Mutt-ng?"), M_YES) == M_YES) {
     endwin ();
     exit (1);
   }
-  mutt_clear_error();
+  mutt_clear_error ();
   mutt_curs_set (-1);
   SigInt = 0;
 }
@@ -302,17 +294,16 @@ void mutt_curses_error (const char *fmt, ...)
   va_start (ap, fmt);
   vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
   va_end (ap);
-  
+
   dprint (1, (debugfile, "%s\n", Errorbuf));
   mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
-                      0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
-  snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */
+                      0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+  snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf);    /* overkill */
 
-  if (!option (OPTKEEPQUIET))
-  {
+  if (!option (OPTKEEPQUIET)) {
     BEEP ();
     SETCOLOR (MT_COLOR_ERROR);
-    mvaddstr (LINES-1, 0, Errorbuf);
+    mvaddstr (LINES - 1, 0, Errorbuf);
     clrtoeol ();
     SETCOLOR (MT_COLOR_NORMAL);
     mutt_refresh ();
@@ -331,11 +322,10 @@ void mutt_curses_message (const char *fmt, ...)
   va_end (ap);
 
   mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
-                      0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
-  snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */
+                      0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+  snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf);    /* overkill */
 
-  if (!option (OPTKEEPQUIET))
-  {
+  if (!option (OPTKEEPQUIET)) {
     SETCOLOR (MT_COLOR_MESSAGE);
     mvaddstr (LINES - 1, 0, Errorbuf);
     clrtoeol ();
@@ -350,26 +340,24 @@ void mutt_show_error (void)
 {
   if (option (OPTKEEPQUIET))
     return;
-  
+
   SETCOLOR (option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
-  CLEARLINE (LINES-1);
+  CLEARLINE (LINES - 1);
   addstr (Errorbuf);
   SETCOLOR (MT_COLOR_NORMAL);
 }
 
 void mutt_endwin (const char *msg)
 {
-  if (!option (OPTNOCURSES))
-  {
+  if (!option (OPTNOCURSES)) {
     CLEARLINE (LINES - 1);
-    
+
     attrset (A_NORMAL);
     mutt_refresh ();
     endwin ();
   }
-  
-  if (msg && *msg)
-  {
+
+  if (msg && *msg) {
     puts (msg);
     fflush (stdout);
   }
@@ -379,8 +367,8 @@ void mutt_perror (const char *s)
 {
   char *p = strerror (errno);
 
-  dprint (1, (debugfile, "%s: %s (errno = %d)\n", s, 
-      p ? p : "unknown error", errno));
+  dprint (1, (debugfile, "%s: %s (errno = %d)\n", s,
+              p ? p : "unknown error", errno));
   mutt_error ("%s: %s (errno = %d)", s, p ? p : _("unknown error"), errno);
 }
 
@@ -392,7 +380,7 @@ int mutt_any_key_to_continue (const char *s)
 
   f = open ("/dev/tty", O_RDONLY);
   tcgetattr (f, &t);
-  memcpy ((void *)&old, (void *)&t, sizeof(struct termios)); /* save original state */
+  memcpy ((void *) &old, (void *) &t, sizeof (struct termios)); /* save original state */
   t.c_lflag &= ~(ICANON | ECHO);
   t.c_cc[VMIN] = 1;
   t.c_cc[VTIME] = 0;
@@ -413,22 +401,18 @@ int mutt_any_key_to_continue (const char *s)
 }
 
 int mutt_do_pager (const char *banner,
-                   const char *tempfile,
-                   int do_color,
-                   pager_t *info)
+                   const char *tempfile, int do_color, pager_t * info)
 {
   int rc;
-  
+
   if (!Pager || mutt_strcmp (Pager, "builtin") == 0)
     rc = mutt_pager (banner, tempfile, do_color, info);
-  else
-  {
+  else {
     char cmd[STRING];
-    
+
     mutt_endwin (NULL);
-    mutt_expand_file_fmt (cmd, sizeof(cmd), Pager, tempfile);
-    if (mutt_system (cmd) == -1)
-    {
+    mutt_expand_file_fmt (cmd, sizeof (cmd), Pager, tempfile);
+    if (mutt_system (cmd) == -1) {
       mutt_error (_("Error running \"%s\"!"), cmd);
       rc = -1;
     }
@@ -440,38 +424,39 @@ int mutt_do_pager (const char *banner,
   return rc;
 }
 
-int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, int buffy, int multiple, char ***files, int *numfiles)
+int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
+                       int *redraw, int buffy, int multiple, char ***files,
+                       int *numfiles)
 {
   event_t ch;
 
-  mvaddstr (LINES-1, 0, (char *) prompt);
+  mvaddstr (LINES - 1, 0, (char *) prompt);
   addstr (_(" ('?' for list): "));
   if (buf[0])
     addstr (buf);
   clrtoeol ();
   mutt_refresh ();
 
-  ch = mutt_getch();
-  if (ch.ch == -1)
-  {
-    CLEARLINE (LINES-1);
+  ch = mutt_getch ();
+  if (ch.ch == -1) {
+    CLEARLINE (LINES - 1);
     return (-1);
   }
-  else if (ch.ch == '?')
-  {
+  else if (ch.ch == '?') {
     mutt_refresh ();
     buf[0] = 0;
-    _mutt_select_file (buf, blen, M_SEL_FOLDER | (multiple ? M_SEL_MULTI : 0), 
+    _mutt_select_file (buf, blen, M_SEL_FOLDER | (multiple ? M_SEL_MULTI : 0),
                        files, numfiles);
     *redraw = REDRAW_FULL;
   }
-  else
-  {
+  else {
     char *pc = safe_malloc (mutt_strlen (prompt) + 3);
 
-    sprintf (pc, "%s: ", prompt);        /* __SPRINTF_CHECKED__ */
+    sprintf (pc, "%s: ", prompt);       /* __SPRINTF_CHECKED__ */
     mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
-    if (_mutt_get_field (pc, buf, blen, (buffy ? M_EFILE : M_FILE) | M_CLEAR, multiple, files, numfiles)
+    if (_mutt_get_field
+        (pc, buf, blen, (buffy ? M_EFILE : M_FILE) | M_CLEAR, multiple, files,
+         numfiles)
         != 0)
       buf[0] = 0;
     MAYBE_REDRAW (*redraw);
@@ -489,7 +474,7 @@ void mutt_ungetch (int ch, int op)
   tmp.op = op;
 
   if (UngetCount >= UngetBufLen)
-    safe_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof(event_t));
+    safe_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t));
 
   KeyEvent[UngetCount++] = tmp;
 }
@@ -509,15 +494,15 @@ void mutt_flushinp (void)
 void mutt_curs_set (int cursor)
 {
   static int SavedCursor = 1;
-  
+
   if (cursor < 0)
     cursor = SavedCursor;
   else
     SavedCursor = cursor;
-  
+
   if (curs_set (cursor) == ERR) {
-    if (cursor == 1)        /* cnorm */
-      curs_set (2);        /* cvvis */
+    if (cursor == 1)            /* cnorm */
+      curs_set (2);             /* cvvis */
   }
 }
 #endif
@@ -530,25 +515,20 @@ int mutt_multi_choice (char *prompt, char *letters)
 
   mvaddstr (LINES - 1, 0, prompt);
   clrtoeol ();
-  FOREVER
-  {
+  FOREVER {
     mutt_refresh ();
-    ch  = mutt_getch ();
-    if (ch.ch == -1 || CI_is_return (ch.ch))
-    {
+    ch = mutt_getch ();
+    if (ch.ch == -1 || CI_is_return (ch.ch)) {
       choice = -1;
       break;
     }
-    else
-    {
+    else {
       p = strchr (letters, ch.ch);
-      if (p)
-      {
+      if (p) {
         choice = p - letters + 1;
         break;
       }
-      else if (ch.ch <= '9' && ch.ch > '0')
-      {
+      else if (ch.ch <= '9' && ch.ch > '0') {
         choice = ch.ch - '0';
         if (choice <= mutt_strlen (letters))
           break;
@@ -567,14 +547,14 @@ int mutt_multi_choice (char *prompt, char *letters)
 
 int mutt_addwch (wchar_t wc)
 {
-  char buf[MB_LEN_MAX*2];
+  char buf[MB_LEN_MAX * 2];
   mbstate_t mbstate;
   size_t n1, n2;
 
   memset (&mbstate, 0, sizeof (mbstate));
-  if ((n1 = wcrtomb (buf, wc, &mbstate)) == (size_t)(-1) ||
-      (n2 = wcrtomb (buf + n1, 0, &mbstate)) == (size_t)(-1))
-    return -1; /* ERR */
+  if ((n1 = wcrtomb (buf, wc, &mbstate)) == (size_t) (-1) ||
+      (n2 = wcrtomb (buf + n1, 0, &mbstate)) == (size_t) (-1))
+    return -1;                  /* ERR */
   else
     return addstr (buf);
 }
@@ -590,8 +570,7 @@ int mutt_addwch (wchar_t wc)
 void mutt_format_string (char *dest, size_t destlen,
                          int min_width, int max_width,
                          int right_justify, char m_pad_char,
-                         const char *s, size_t n,
-                         int arboreal)
+                         const char *s, size_t n, int arboreal)
 {
   char *p;
   wchar_t wc;
@@ -600,49 +579,43 @@ void mutt_format_string (char *dest, size_t destlen,
   char scratch[MB_LEN_MAX];
   mbstate_t mbstate1, mbstate2;
 
-  memset(&mbstate1, 0, sizeof (mbstate1));
-  memset(&mbstate2, 0, sizeof (mbstate2));
+  memset (&mbstate1, 0, sizeof (mbstate1));
+  memset (&mbstate2, 0, sizeof (mbstate2));
   --destlen;
   p = dest;
-  for (; n && (k = mbrtowc (&wc, s, n, &mbstate1)); s += k, n -= k)
-  {
-    if (k == (size_t)(-1) || k == (size_t)(-2))
-    {
-      k = (k == (size_t)(-1)) ? 1 : n;
+  for (; n && (k = mbrtowc (&wc, s, n, &mbstate1)); s += k, n -= k) {
+    if (k == (size_t) (-1) || k == (size_t) (-2)) {
+      k = (k == (size_t) (-1)) ? 1 : n;
       wc = replacement_char ();
     }
     if (arboreal && wc < M_TREE_MAX)
-      w = 1; /* hack */
-    else
-    {
+      w = 1;                    /* hack */
+    else {
       if (!IsWPrint (wc))
-       wc = '?';
+        wc = '?';
       w = wcwidth (wc);
     }
-    if (w >= 0)
-    {
+    if (w >= 0) {
       if (w > max_width || (k2 = wcrtomb (scratch, wc, &mbstate2)) > destlen)
         break;
       min_width -= w;
       max_width -= w;
       strncpy (p, scratch, k2);
-      p += k2;            
+      p += k2;
       destlen -= k2;
     }
   }
-  w = (int)destlen < min_width ? destlen : min_width;
+  w = (int) destlen < min_width ? destlen : min_width;
   if (w <= 0)
     *p = '\0';
-  else if (right_justify)
-  {
+  else if (right_justify) {
     p[w] = '\0';
     while (--p >= dest)
       p[w] = *p;
     while (--w >= 0)
       dest[w] = m_pad_char;
   }
-  else
-  {
+  else {
     while (--w >= 0)
       *p++ = m_pad_char;
     *p = '\0';
@@ -659,9 +632,7 @@ void mutt_format_string (char *dest, size_t destlen,
 
 static void mutt_format_s_x (char *dest,
                              size_t destlen,
-                             const char *prefix,
-                             const char *s,
-                             int arboreal)
+                             const char *prefix, const char *s, int arboreal)
 {
   int right_justify = 1;
   char *p;
@@ -671,8 +642,7 @@ static void mutt_format_s_x (char *dest,
   if (*prefix == '-')
     ++prefix, right_justify = 0;
   min_width = strtol (prefix, &p, 10);
-  if (*p == '.')
-  {
+  if (*p == '.') {
     prefix = p + 1;
     max_width = strtol (prefix, &p, 10);
     if (p <= prefix)
@@ -684,17 +654,13 @@ static void mutt_format_s_x (char *dest,
 }
 
 void mutt_format_s (char *dest,
-                    size_t destlen,
-                    const char *prefix,
-                    const char *s)
+                    size_t destlen, const char *prefix, const char *s)
 {
   mutt_format_s_x (dest, destlen, prefix, s, 0);
 }
 
 void mutt_format_s_tree (char *dest,
-                         size_t destlen,
-                         const char *prefix,
-                         const char *s)
+                         size_t destlen, const char *prefix, const char *s)
 {
   mutt_format_s_x (dest, destlen, prefix, s, 1);
 }
@@ -713,21 +679,18 @@ void mutt_paddstr (int n, const char *s)
   mbstate_t mbstate;
 
   memset (&mbstate, 0, sizeof (mbstate));
-  for (; len && (k = mbrtowc (&wc, s, len, &mbstate)); s += k, len -= k)
-  {
-    if (k == (size_t)(-1) || k == (size_t)(-2))
-    {
-      k = (k == (size_t)(-1)) ? 1 : len;
+  for (; len && (k = mbrtowc (&wc, s, len, &mbstate)); s += k, len -= k) {
+    if (k == (size_t) (-1) || k == (size_t) (-2)) {
+      k = (k == (size_t) (-1)) ? 1 : len;
       wc = replacement_char ();
     }
     if (!IsWPrint (wc))
       wc = '?';
     w = wcwidth (wc);
-    if (w >= 0)
-    {
+    if (w >= 0) {
       if (w > n)
         break;
-      addnstr ((char *)s, k);
+      addnstr ((char *) s, k);
       n -= w;
     }
   }
@@ -747,16 +710,15 @@ int mutt_strwidth (const char *s)
   size_t k, n;
   mbstate_t mbstate;
 
-  if (!s) return 0;
+  if (!s)
+    return 0;
 
   n = mutt_strlen (s);
 
   memset (&mbstate, 0, sizeof (mbstate));
-  for (w=0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k)
-  {
-    if (k == (size_t)(-1) || k == (size_t)(-2))
-    {
-      k = (k == (size_t)(-1)) ? 1 : n;
+  for (w = 0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k) {
+    if (k == (size_t) (-1) || k == (size_t) (-2)) {
+      k = (k == (size_t) (-1)) ? 1 : n;
       wc = replacement_char ();
     }
     if (!IsWPrint (wc))
index 1e50716..7720241 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 static const char *No_mailbox_is_open = N_("No mailbox is open.");
 static const char *There_are_no_messages = N_("There are no messages.");
 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
-static const char *Function_not_permitted_in_attach_message_mode = N_("Function not permitted in attach-message mode.");
+static const char *Function_not_permitted_in_attach_message_mode =
+N_("Function not permitted in attach-message mode.");
 static const char *No_visible = N_("No visible messages.");
 
 #define CHECK_MSGCOUNT if (!Context) \
         { \
                   mutt_flushinp (); \
-                mutt_error _(No_mailbox_is_open); \
+                mutt_error(_(No_mailbox_is_open)); \
                 break; \
         } \
         else if (!Context->msgcount) \
         { \
                   mutt_flushinp (); \
-                mutt_error _(There_are_no_messages); \
+                mutt_error(_(There_are_no_messages)); \
                 break; \
         }
 
 #define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
           {\
                   mutt_flushinp (); \
-                  mutt_error _(No_visible); \
+                  mutt_error(_(No_visible)); \
                   break; \
         }
-    
+
 
 #define CHECK_READONLY if (Context->readonly) \
                         { \
                                   mutt_flushinp (); \
-                                mutt_error _(Mailbox_is_read_only); \
+                                mutt_error(_(Mailbox_is_read_only)); \
                                 break; \
                         }
 
-#ifdef USE_IMAP 
+#ifdef USE_IMAP
 /* the error message returned here could be better. */
 #define CHECK_IMAP_ACL(aclbit) if (Context->magic == M_IMAP) \
                 if (mutt_bit_isset (((IMAP_DATA *)Context->data)->capabilities, ACL) \
@@ -102,7 +103,7 @@ static const char *No_visible = N_("No visible messages.");
 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
                      {\
                         mutt_flushinp (); \
-                        mutt_error _(Function_not_permitted_in_attach_message_mode); \
+                        mutt_error(_(Function_not_permitted_in_attach_message_mode)); \
                         break; \
                      }
 
@@ -113,38 +114,36 @@ static const char *No_visible = N_("No visible messages.");
 extern const char *ReleaseDate;
 extern size_t UngetCount;
 
-static void set_xterm_title_bar(char *title)
+static void set_xterm_title_bar (char *title)
 {
-  fputs("\033]2;", stdout);
-  fputs(title, stdout);
-  fputs("\007", stdout);
-  fflush(stdout);
+  fputs ("\033]2;", stdout);
+  fputs (title, stdout);
+  fputs ("\007", stdout);
+  fflush (stdout);
 }
 
-static void set_xterm_icon_name(char *name)
+static void set_xterm_icon_name (char *name)
 {
-  fputs("\033]1;", stdout);
-  fputs(name, stdout);
-  fputs("\007", stdout);
-  fflush(stdout);
+  fputs ("\033]1;", stdout);
+  fputs (name, stdout);
+  fputs ("\007", stdout);
+  fflush (stdout);
 }
 
-void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
+void index_make_entry (char *s, size_t l, MUTTMENU * menu, int num)
 {
-  format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
+  format_flag flag =
+    M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
   int edgemsgno, reverse = Sort & SORT_REVERSE;
   HEADER *h = Context->hdrs[Context->v2r[num]];
   THREAD *tmp;
 
-  if ((Sort & SORT_MASK) == SORT_THREADS && h->tree)
-  {
-    flag |= M_FORMAT_TREE; /* display the thread tree */
+  if ((Sort & SORT_MASK) == SORT_THREADS && h->tree) {
+    flag |= M_FORMAT_TREE;      /* display the thread tree */
     if (h->display_subject)
       flag |= M_FORMAT_FORCESUBJ;
-    else
-    {
-      if (reverse)
-      {
+    else {
+      if (reverse) {
         if (menu->top + menu->pagelen > menu->max)
           edgemsgno = Context->v2r[menu->max - 1];
         else
@@ -153,33 +152,30 @@ void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
       else
         edgemsgno = Context->v2r[menu->top];
 
-      for (tmp = h->thread->parent; tmp; tmp = tmp->parent)
-      {
+      for (tmp = h->thread->parent; tmp; tmp = tmp->parent) {
         if (!tmp->message)
           continue;
 
         /* if no ancestor is visible on current screen, provisionally force
          * subject... */
-        if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
-        {
+        if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno <
+            edgemsgno) {
           flag |= M_FORMAT_FORCESUBJ;
           break;
         }
         else if (tmp->message->virtual >= 0)
           break;
       }
-      if (flag & M_FORMAT_FORCESUBJ)
-      {
-        for (tmp = h->thread->prev; tmp; tmp = tmp->prev)
-        {
+      if (flag & M_FORMAT_FORCESUBJ) {
+        for (tmp = h->thread->prev; tmp; tmp = tmp->prev) {
           if (!tmp->message)
             continue;
 
           /* ...but if a previous sibling is available, don't force it */
-          if (reverse ? tmp->message->msgno > edgemsgno : tmp->message->msgno < edgemsgno)
+          if (reverse ? tmp->message->msgno >
+              edgemsgno : tmp->message->msgno < edgemsgno)
             break;
-          else if (tmp->message->virtual >= 0)
-          {
+          else if (tmp->message->virtual >= 0) {
             flag &= ~M_FORMAT_FORCESUBJ;
             break;
           }
@@ -206,8 +202,8 @@ static int ci_next_undeleted (int msgno)
 {
   int i;
 
-  for (i=msgno+1; i < Context->vcount; i++)
-    if (! Context->hdrs[Context->v2r[i]]->deleted)
+  for (i = msgno + 1; i < Context->vcount; i++)
+    if (!Context->hdrs[Context->v2r[i]]->deleted)
       return (i);
   return (-1);
 }
@@ -216,8 +212,8 @@ static int ci_previous_undeleted (int msgno)
 {
   int i;
 
-  for (i=msgno-1; i>=0; i--)
-    if (! Context->hdrs[Context->v2r[i]]->deleted)
+  for (i = msgno - 1; i >= 0; i--)
+    if (!Context->hdrs[Context->v2r[i]]->deleted)
       return (i);
   return (-1);
 }
@@ -229,14 +225,11 @@ static int ci_first_message (void)
 {
   int old = -1, i;
 
-  if (Context && Context->msgcount)
-  {
-    for (i=0; i < Context->vcount; i++)
-    {
-      if (! Context->hdrs[Context->v2r[i]]->read &&
-          ! Context->hdrs[Context->v2r[i]]->deleted)
-      {
-        if (! Context->hdrs[Context->v2r[i]]->old)
+  if (Context && Context->msgcount) {
+    for (i = 0; i < Context->vcount; i++) {
+      if (!Context->hdrs[Context->v2r[i]]->read &&
+          !Context->hdrs[Context->v2r[i]]->deleted) {
+        if (!Context->hdrs[Context->v2r[i]]->old)
           return (i);
         else if (old == -1)
           old = i;
@@ -260,110 +253,99 @@ static int ci_first_message (void)
 }
 
 /* This should be in mx.c, but it only gets used here. */
-static int mx_toggle_write (CONTEXT *ctx)
+static int mx_toggle_write (CONTEXT * ctx)
 {
   if (!ctx)
     return -1;
 
-  if (ctx->readonly)
-  {
-    mutt_error _("Cannot toggle write on a readonly mailbox!");
+  if (ctx->readonly) {
+    mutt_error (_("Cannot toggle write on a readonly mailbox!"));
+
     return -1;
   }
 
-  if (ctx->dontwrite)
-  {
+  if (ctx->dontwrite) {
     ctx->dontwrite = 0;
-    mutt_message _("Changes to folder will be written on folder exit.");
+    mutt_message (_("Changes to folder will be written on folder exit."));
   }
-  else
-  {
+  else {
     ctx->dontwrite = 1;
-    mutt_message _("Changes to folder will not be written.");
+    mutt_message (_("Changes to folder will not be written."));
   }
 
   return 0;
 }
 
-static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
+static void update_index (MUTTMENU * menu, CONTEXT * ctx, int check,
                           int oldcount, int index_hint)
 {
   /* store pointers to the newly added messages */
-  HEADER  **save_new = NULL;
+  HEADER **save_new = NULL;
   int j;
-  
+
   /* take note of the current message */
-  if (oldcount)
-  {
+  if (oldcount) {
     if (menu->current < Context->vcount)
       menu->oldcurrent = index_hint;
     else
-      oldcount = 0; /* invalid message number! */
+      oldcount = 0;             /* invalid message number! */
   }
-  
+
   /* We are in a limited view. Check if the new message(s) satisfy
    * the limit criteria. If they do, set their virtual msgno so that
    * they will be visible in the limited view */
-  if (Context->pattern)
-  {
+  if (Context->pattern) {
 #define THIS_BODY Context->hdrs[j]->content
-    if (oldcount || check == M_REOPENED)
-    {
-      for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++)
-      {
-        if (mutt_pattern_exec (Context->limit_pattern,
-                               M_MATCH_FULL_ADDRESS, 
-                               Context, Context->hdrs[j]))
-        {
+    if (oldcount || check == M_REOPENED) {
+      for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount;
+           j++) {
+        if (mutt_pattern_exec
+            (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
+             Context->hdrs[j])) {
           Context->hdrs[j]->virtual = Context->vcount;
           Context->v2r[Context->vcount] = j;
           Context->hdrs[j]->limited = 1;
           Context->vcount++;
-          Context->vsize += THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
+          Context->vsize +=
+            THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
         }
       }
     }
 #undef THIS_BODY
   }
-    
+
   /* save the list of new messages */
-  if (oldcount && check != M_REOPENED
-      && ((Sort & SORT_MASK) == SORT_THREADS))
-  {
-    save_new = (HEADER **) safe_malloc (sizeof (HEADER *) * (Context->msgcount - oldcount));
+  if (oldcount && check != M_REOPENED && ((Sort & SORT_MASK) == SORT_THREADS)) {
+    save_new =
+      (HEADER **) safe_malloc (sizeof (HEADER *) *
+                               (Context->msgcount - oldcount));
     for (j = oldcount; j < Context->msgcount; j++)
-      save_new[j-oldcount] = Context->hdrs[j];
+      save_new[j - oldcount] = Context->hdrs[j];
   }
-  
+
   /* if the mailbox was reopened, need to rethread from scratch */
   mutt_sort_headers (Context, (check == M_REOPENED));
 
   /* uncollapse threads with new mail */
-  if ((Sort & SORT_MASK) == SORT_THREADS)
-  {
-    if (check == M_REOPENED)
-    {
+  if ((Sort & SORT_MASK) == SORT_THREADS) {
+    if (check == M_REOPENED) {
       THREAD *h, *j;
-      
+
       Context->collapsed = 0;
-      
-      for (h = Context->tree; h; h = h->next)
-      {
-        for (j = h; !j->message; j = j->child)
-          ;
+
+      for (h = Context->tree; h; h = h->next) {
+        for (j = h; !j->message; j = j->child);
         mutt_uncollapse_thread (Context, j->message);
       }
       mutt_set_virtual (Context);
     }
-    else if (oldcount)
-    {
-      for (j = 0; j < Context->msgcount - oldcount; j++)
-      {
+    else if (oldcount) {
+      for (j = 0; j < Context->msgcount - oldcount; j++) {
         int k;
-        
-        for (k = 0; k < Context->msgcount; k++)
-        {
+
+        for (k = 0; k < Context->msgcount; k++) {
           HEADER *h = Context->hdrs[k];
+
           if (h == save_new[j] && (!Context->pattern || h->limited))
             mutt_uncollapse_thread (Context, h);
         }
@@ -372,27 +354,24 @@ static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
       mutt_set_virtual (Context);
     }
   }
-  
+
   menu->current = -1;
-  if (oldcount)
-  {
+  if (oldcount) {
     /* restore the current message to the message it was pointing to */
-    for (j = 0; j < Context->vcount; j++)
-    {
-      if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent)
-      {
+    for (j = 0; j < Context->vcount; j++) {
+      if (Context->hdrs[Context->v2r[j]]->index == menu->oldcurrent) {
         menu->current = j;
         break;
       }
     }
   }
-  
+
   if (menu->current < 0)
     menu->current = ci_first_message ();
-  
+
 }
 
-static void resort_index (MUTTMENU *menu)
+static void resort_index (MUTTMENU * menu)
 {
   int i;
   HEADER *current = CURHDR;
@@ -401,47 +380,45 @@ static void resort_index (MUTTMENU *menu)
   mutt_sort_headers (Context, 0);
   /* Restore the current message */
 
-  for (i = 0; i < Context->vcount; i++)
-  {
-    if (Context->hdrs[Context->v2r[i]] == current)
-    {
+  for (i = 0; i < Context->vcount; i++) {
+    if (Context->hdrs[Context->v2r[i]] == current) {
       menu->current = i;
       break;
     }
   }
-  
+
   if ((Sort & SORT_MASK) == SORT_THREADS && menu->current < 0)
     menu->current = mutt_parent_message (Context, current);
-  
+
   if (menu->current < 0)
     menu->current = ci_first_message ();
-  
+
   menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
 }
 
 struct mapping_t IndexHelp[] = {
-  { N_("Quit"),  OP_QUIT },
-  { N_("Del"),   OP_DELETE },
-  { N_("Undel"), OP_UNDELETE },
-  { N_("Save"),  OP_SAVE },
-  { N_("Mail"),  OP_MAIL },
-  { N_("Reply"), OP_REPLY },
-  { N_("Group"), OP_GROUP_REPLY },
-  { N_("Help"),  OP_HELP },
-  { NULL }
+  {N_("Quit"), OP_QUIT},
+  {N_("Del"), OP_DELETE},
+  {N_("Undel"), OP_UNDELETE},
+  {N_("Save"), OP_SAVE},
+  {N_("Mail"), OP_MAIL},
+  {N_("Reply"), OP_REPLY},
+  {N_("Group"), OP_GROUP_REPLY},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
 #ifdef USE_NNTP
 struct mapping_t IndexNewsHelp[] = {
-  { N_("Quit"),     OP_QUIT },
-  { N_("Del"),      OP_DELETE },
-  { N_("Undel"),    OP_UNDELETE },
-  { N_("Save"),     OP_SAVE },
-  { N_("Post"),     OP_POST },
-  { N_("Followup"), OP_FOLLOWUP },
-  { N_("Catchup"),  OP_CATCHUP },
-  { N_("Help"),     OP_HELP },
-  { NULL }
+  {N_("Quit"), OP_QUIT},
+  {N_("Del"), OP_DELETE},
+  {N_("Undel"), OP_UNDELETE},
+  {N_("Save"), OP_SAVE},
+  {N_("Post"), OP_POST},
+  {N_("Followup"), OP_FOLLOWUP},
+  {N_("Catchup"), OP_CATCHUP},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 #endif
 
@@ -453,19 +430,19 @@ int mutt_index_menu (void)
   char buf[LONG_STRING], helpstr[SHORT_STRING];
   int flags;
   int op = OP_NULL;
-  int done = 0;                /* controls when to exit the "event" loop */
+  int done = 0;                 /* controls when to exit the "event" loop */
   int i = 0, j;
-  int tag = 0;                 /* has the tag-prefix command been pressed? */
+  int tag = 0;                  /* has the tag-prefix command been pressed? */
   int newcount = -1;
   int oldcount = -1;
   int rc = -1;
   MUTTMENU *menu;
-  char *cp;                    /* temporary variable. */
-  int index_hint;   /* used to restore cursor position */
+  char *cp;                     /* temporary variable. */
+  int index_hint;               /* used to restore cursor position */
   int do_buffy_notify = 1;
-  int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
-  int attach_msg = option(OPTATTACHMSG);
-  
+  int close = 0;                /* did we OP_QUIT or OP_EXIT out of this menu? */
+  int attach_msg = option (OPTATTACHMSG);
+
   menu = mutt_new_menu ();
   menu->menu = MENU_MAIN;
   menu->offset = 1;
@@ -475,20 +452,21 @@ int mutt_index_menu (void)
   menu->current = ci_first_message ();
   menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
 #ifdef USE_NNTP
-        (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp :
+                                  (Context
+                                   && (Context->magic ==
+                                       M_NNTP)) ? IndexNewsHelp :
 #endif
-        IndexHelp);
-  
+                                  IndexHelp);
+
   if (!attach_msg) {
-    mutt_buffy_check(1); /* force the buffy check after we enter the folder */
+    mutt_buffy_check (1);       /* force the buffy check after we enter the folder */
     /* record folder we open to place sidebar indicator properly */
     if (Context && Context->path)
-      set_curbuffy(Context->path);
+      set_curbuffy (Context->path);
   }
 
-  FOREVER
-  {
-    tag = 0; /* clear the tag-prefix */
+  FOREVER {
+    tag = 0;                    /* clear the tag-prefix */
 
     menu->max = Context ? Context->vcount : 0;
     oldcount = Context ? Context->msgcount : 0;
@@ -499,17 +477,17 @@ int mutt_index_menu (void)
      */
     if (option (OPTNEEDRESORT) && Context && Context->msgcount)
       resort_index (menu);
-    
-    if (option (OPTREDRAWTREE) && Context && Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
-    {
+
+    if (option (OPTREDRAWTREE) && Context && Context->msgcount
+        && (Sort & SORT_MASK) == SORT_THREADS) {
       mutt_draw_tree (Context);
       menu->redraw |= REDRAW_STATUS;
       unset_option (OPTREDRAWTREE);
     }
 
-    if (Context && !attach_msg)
-    {
+    if (Context && !attach_msg) {
       int check;
+
       /* check for new mail in the mailbox.  If nonzero, then something has
        * changed about the file (either we got new mail or the file was
        * modified underneath us.)
@@ -518,43 +496,42 @@ int mutt_index_menu (void)
 #ifdef USE_IMAP
       imap_allow_reopen (Context);
 #endif
-    
-      index_hint = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ? CURHDR->index : 0;
 
-      if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0)
-      {
-        if (!Context->path)
-        {
+      index_hint = (Context->vcount && menu->current >= 0
+                    && menu->current < Context->vcount) ? CURHDR->index : 0;
+
+      if ((check = mx_check_mailbox (Context, &index_hint, 0)) < 0) {
+        if (!Context->path) {
           /* fatal error occurred */
           FREE (&Context);
           menu->redraw = REDRAW_FULL;
         }
-
         set_option (OPTSEARCHINVALID);
       }
-      else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS)
-      {
+      else if (check == M_NEW_MAIL || check == M_REOPENED || check == M_FLAGS) {
         update_index (menu, Context, check, oldcount, index_hint);
-        
+
         /* notify the user of new mail */
         if (check == M_REOPENED)
-          mutt_error _("Mailbox was externally modified.  Flags may be wrong.");
-        else if (check == M_NEW_MAIL)
-        {
+          mutt_error (_
+                      ("Mailbox was externally modified.  Flags may be wrong."));
+        else if (check == M_NEW_MAIL) {
           /* on new mail: redraw sidebar */
           draw_sidebar (CurrentMenu);
-          mutt_message _("New mail in this mailbox.");
+          mutt_message (_("New mail in this mailbox."));
+
           if (option (OPTBEEPNEW))
             beep ();
-        } else if (check == M_FLAGS)
-          mutt_message _("Mailbox was externally modified.");
+        }
+        else if (check == M_FLAGS)
+          mutt_message (_("Mailbox was externally modified."));
 
         /* avoid the message being overwritten by buffy */
         do_buffy_notify = 0;
-        
+
         menu->redraw = REDRAW_FULL;
         menu->max = Context->vcount;
-        
+
         set_option (OPTSEARCHINVALID);
       }
     }
@@ -564,41 +541,36 @@ int mutt_index_menu (void)
     imap_disallow_reopen (Context);
 #endif
 
-    if (!attach_msg)
-    {
-     /* check for new mail in the incoming folders */
-     oldcount = newcount;
-     if ((newcount = mutt_buffy_check (0)) != oldcount){
-       menu->redraw |= REDRAW_STATUS;
-       menu->redraw |= REDRAW_SIDEBAR;
-     } 
-     if (do_buffy_notify)
-     {
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
-         beep ();
-     }
-     else
-       do_buffy_notify = 1;
+    if (!attach_msg) {
+      /* check for new mail in the incoming folders */
+      oldcount = newcount;
+      if ((newcount = mutt_buffy_check (0)) != oldcount) {
+        menu->redraw |= REDRAW_STATUS;
+        menu->redraw |= REDRAW_SIDEBAR;
+      }
+      if (do_buffy_notify) {
+        if (mutt_buffy_notify () && option (OPTBEEPNEW))
+          beep ();
+      }
+      else
+        do_buffy_notify = 1;
     }
 
     if (op != -1)
       mutt_curs_set (0);
-    if (menu->redraw & REDRAW_SIDEBAR) draw_sidebar(menu->menu);
-    if (menu->redraw & REDRAW_FULL)
-    {
+    if (menu->redraw & REDRAW_SIDEBAR)
+      draw_sidebar (menu->menu);
+    if (menu->redraw & REDRAW_FULL) {
       menu_redraw_full (menu);
-      draw_sidebar(menu->menu);
+      draw_sidebar (menu->menu);
       mutt_show_error ();
     }
 
-    if (menu->menu == MENU_MAIN)
-    {
-      if (Context && Context->hdrs && !(menu->current >= Context->vcount))
-      {
+    if (menu->menu == MENU_MAIN) {
+      if (Context && Context->hdrs && !(menu->current >= Context->vcount)) {
         menu_check_recenter (menu);
 
-        if (menu->redraw & REDRAW_INDEX)
-        {
+        if (menu->redraw & REDRAW_INDEX) {
           menu_redraw_index (menu);
           menu->redraw |= REDRAW_STATUS;
         }
@@ -608,23 +580,21 @@ int mutt_index_menu (void)
           menu_redraw_current (menu);
       }
 
-      if (menu->redraw & REDRAW_STATUS) 
-      {
+      if (menu->redraw & REDRAW_STATUS) {
         DrawFullLine = 1;
         menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
         DrawFullLine = 0;
-        CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
+        CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
         SETCOLOR (MT_COLOR_STATUS);
         mutt_paddstr (COLS, buf);
         SETCOLOR (MT_COLOR_NORMAL);
         set_buffystats (Context);
         menu->redraw &= ~REDRAW_STATUS;
-        if (option(OPTXTERMSETTITLES))
-        {
+        if (option (OPTXTERMSETTITLES)) {
           menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
-          set_xterm_title_bar(buf);
+          set_xterm_title_bar (buf);
           menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
-          set_xterm_icon_name(buf);
+          set_xterm_icon_name (buf);
         }
       }
 
@@ -642,43 +612,42 @@ int mutt_index_menu (void)
 
       op = km_dokey (MENU_MAIN);
 
-      dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
+      dprint (4,
+              (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
 
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-      if (SigWinch)
-      {
+      if (SigWinch) {
         mutt_flushinp ();
         mutt_resize_screen ();
         menu->redraw = REDRAW_FULL;
         menu->menu = MENU_MAIN;
         SigWinch = 0;
-        menu->top = 0; /* so we scroll the right amount */
+        menu->top = 0;          /* so we scroll the right amount */
         /*
          * force a real complete redraw.  clrtobot() doesn't seem to be able
          * to handle every case without this.
          */
-        clearok(stdscr,TRUE);
+        clearok (stdscr, TRUE);
         continue;
       }
 #endif
 
       if (op == -1)
-        continue; /* either user abort or timeout */
-      
+        continue;               /* either user abort or timeout */
+
       mutt_curs_set (1);
-      
+
       /* special handling for the tag-prefix function */
-      if (op == OP_TAG_PREFIX)
-      {
-        if (!Context)
-        {
-          mutt_error _("No mailbox is open.");
+      if (op == OP_TAG_PREFIX) {
+        if (!Context) {
+          mutt_error (_("No mailbox is open."));
+
           continue;
         }
 
-        if (!Context->tagged)
-        {
-          mutt_error _("No tagged messages.");
+        if (!Context->tagged) {
+          mutt_error (_("No tagged messages."));
+
           continue;
         }
         tag = 1;
@@ -688,33 +657,32 @@ int mutt_index_menu (void)
         clrtoeol ();
 
         /* get the real command */
-        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
-        {
+        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
           /* abort tag sequence */
-          CLEARLINE (LINES-1);
+          CLEARLINE (LINES - 1);
           continue;
         }
       }
       else if (option (OPTAUTOTAG) && Context && Context->tagged)
         tag = 1;
 
-      if (op == OP_TAG_PREFIX_COND)
-      {
-        if (!Context)
-        {
-          mutt_error _("No mailbox is open.");
+      if (op == OP_TAG_PREFIX_COND) {
+        if (!Context) {
+          mutt_error (_("No mailbox is open."));
+
           continue;
         }
 
-        if (!Context->tagged)
-        {
+        if (!Context->tagged) {
           event_t tmp;
-          while(UngetCount>0)
-          {
-            tmp=mutt_getch();
-            if(tmp.op==OP_END_COND)break;
+
+          while (UngetCount > 0) {
+            tmp = mutt_getch ();
+            if (tmp.op == OP_END_COND)
+              break;
           }
-          mutt_message  _("Nothing to do.");
+          mutt_message (_("Nothing to do."));
+
           continue;
         }
         tag = 1;
@@ -724,996 +692,955 @@ int mutt_index_menu (void)
         clrtoeol ();
 
         /* get the real command */
-        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
-        {
+        if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
           /* abort tag sequence */
-          CLEARLINE (LINES-1);
+          CLEARLINE (LINES - 1);
           continue;
         }
       }
 
       mutt_clear_error ();
     }
-    else
-    {
+    else {
       if (menu->current < menu->max)
         menu->oldcurrent = menu->current;
       else
         menu->oldcurrent = -1;
-      
+
       mutt_curs_set (1);        /* fallback from the pager */
     }
 
 #ifdef USE_NNTP
-    unset_option (OPTNEWS);        /* for any case */
+    unset_option (OPTNEWS);     /* for any case */
 #endif
 
-    switch (op)
-    {
+    switch (op) {
 
       /* ----------------------------------------------------------------------
        * movement commands
        */
 
-      case OP_BOTTOM_PAGE:
-        menu_bottom_page (menu);
-        break;
-      case OP_FIRST_ENTRY:
-        menu_first_entry (menu);
-        break;
-      case OP_MIDDLE_PAGE:
-        menu_middle_page (menu);
-        break;
-      case OP_HALF_UP:
-        menu_half_up (menu);
-        break;
-      case OP_HALF_DOWN:
-        menu_half_down (menu);
-        break;
-      case OP_NEXT_LINE:
-        menu_next_line (menu);
-        break;
-      case OP_PREV_LINE:
-        menu_prev_line (menu);
-        break;
-      case OP_NEXT_PAGE:
-        menu_next_page (menu);
-        break;
-      case OP_PREV_PAGE:
-        menu_prev_page (menu);
-        break;
-      case OP_LAST_ENTRY:
-        menu_last_entry (menu);
-        break;
-      case OP_TOP_PAGE:
-        menu_top_page (menu);
-        break;
-      case OP_CURRENT_TOP:
-        menu_current_top (menu);
-        break;
-      case OP_CURRENT_MIDDLE:
-        menu_current_middle (menu);
-        break;
-      case OP_CURRENT_BOTTOM:
-        menu_current_bottom (menu);
-        break;
+    case OP_BOTTOM_PAGE:
+      menu_bottom_page (menu);
+      break;
+    case OP_FIRST_ENTRY:
+      menu_first_entry (menu);
+      break;
+    case OP_MIDDLE_PAGE:
+      menu_middle_page (menu);
+      break;
+    case OP_HALF_UP:
+      menu_half_up (menu);
+      break;
+    case OP_HALF_DOWN:
+      menu_half_down (menu);
+      break;
+    case OP_NEXT_LINE:
+      menu_next_line (menu);
+      break;
+    case OP_PREV_LINE:
+      menu_prev_line (menu);
+      break;
+    case OP_NEXT_PAGE:
+      menu_next_page (menu);
+      break;
+    case OP_PREV_PAGE:
+      menu_prev_page (menu);
+      break;
+    case OP_LAST_ENTRY:
+      menu_last_entry (menu);
+      break;
+    case OP_TOP_PAGE:
+      menu_top_page (menu);
+      break;
+    case OP_CURRENT_TOP:
+      menu_current_top (menu);
+      break;
+    case OP_CURRENT_MIDDLE:
+      menu_current_middle (menu);
+      break;
+    case OP_CURRENT_BOTTOM:
+      menu_current_bottom (menu);
+      break;
 
 #ifdef USE_NNTP
-      case OP_GET_MESSAGE:
-      case OP_GET_PARENT:
-        CHECK_MSGCOUNT;
-        if (Context->magic == M_NNTP)
-        {
-          HEADER *h;
+    case OP_GET_MESSAGE:
+    case OP_GET_PARENT:
+      CHECK_MSGCOUNT;
+      if (Context->magic == M_NNTP) {
+        HEADER *h;
+
+        if (op == OP_GET_MESSAGE) {
+          buf[0] = 0;
+          if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0)
+              != 0 || !buf[0])
+            break;
+        }
+        else {
+          LIST *ref = CURHDR->env->references;
 
-          if (op == OP_GET_MESSAGE)
-          {
-            buf[0] = 0;
-            if (mutt_get_field (_("Enter Message-Id: "), buf, sizeof (buf), 0) != 0
-                  || !buf[0])
-              break;
+          if (!ref) {
+            mutt_error (_("Article has no parent reference!"));
+
+            break;
           }
-          else
-          {
-            LIST *ref = CURHDR->env->references;
-            if (!ref)
-            {
-              mutt_error _("Article has no parent reference!");
-              break;
-            }
-            strfcpy (buf, ref->data, sizeof (buf));
+          strfcpy (buf, ref->data, sizeof (buf));
+        }
+        if (!Context->id_hash)
+          Context->id_hash = mutt_make_id_hash (Context);
+        if ((h = hash_find (Context->id_hash, buf))) {
+          if (h->virtual != -1) {
+            menu->current = h->virtual;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
           }
-          if (!Context->id_hash)
-            Context->id_hash = mutt_make_id_hash (Context);
-          if ((h = hash_find (Context->id_hash, buf)))
-          {
-            if (h->virtual != -1)
-            {
-              menu->current = h->virtual;
-              menu->redraw = REDRAW_MOTION_RESYNCH;
-            }
-            else if (h->collapsed)
-            {
-              mutt_uncollapse_thread (Context, h);
-              mutt_set_virtual (Context);
-              menu->current = h->virtual;
-              menu->redraw = REDRAW_MOTION_RESYNCH;
-            }
-            else
-              mutt_error _("Message not visible in limited view.");
+          else if (h->collapsed) {
+            mutt_uncollapse_thread (Context, h);
+            mutt_set_virtual (Context);
+            menu->current = h->virtual;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
           }
           else
-          {
-            if (nntp_check_msgid (Context, buf) == 0)
-            {
-              h = Context->hdrs[Context->msgcount-1];
-              mutt_sort_headers (Context, 0);
-              menu->current = h->virtual;
-              menu->redraw = REDRAW_FULL;
-            }
-            else
-              mutt_error (_("Article %s not found on server"), buf); 
+            mutt_error (_("Message not visible in limited view."));
+        }
+        else {
+          if (nntp_check_msgid (Context, buf) == 0) {
+            h = Context->hdrs[Context->msgcount - 1];
+            mutt_sort_headers (Context, 0);
+            menu->current = h->virtual;
+            menu->redraw = REDRAW_FULL;
           }
+          else
+            mutt_error (_("Article %s not found on server"), buf);
         }
-        break;
+      }
+      break;
 
-      case OP_GET_CHILDREN:
-      case OP_RECONSTRUCT_THREAD:
-        CHECK_MSGCOUNT;
-        if (Context->magic == M_NNTP)
-        {
-          HEADER *h;
-          int old = CURHDR->index, i;
+    case OP_GET_CHILDREN:
+    case OP_RECONSTRUCT_THREAD:
+      CHECK_MSGCOUNT;
+      if (Context->magic == M_NNTP) {
+        HEADER *h;
+        int old = CURHDR->index, i;
 
-          if (!CURHDR->env->message_id)
-          {
-            mutt_error _("No Message-Id. Unable to perform operation");
-            break;
-          }
+        if (!CURHDR->env->message_id) {
+          mutt_error (_("No Message-Id. Unable to perform operation"));
 
-          if (!Context->id_hash)
-            Context->id_hash = mutt_make_id_hash (Context);
-          strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
-
-          if (op == OP_RECONSTRUCT_THREAD)
-          {
-            LIST *ref = CURHDR->env->references;
-            while (ref)
-            {
-              nntp_check_msgid (Context, ref->data);
-              /* the last msgid in References is the root message */
-              if (!ref->next)
-                strfcpy (buf, ref->data, sizeof (buf));
-              ref = ref->next;
-            }
-          }
-          mutt_message _("Check for children of message...");
-          if (nntp_check_children (Context, buf) == 0)
-          {
-            mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
-            h = hash_find (Context->id_hash, buf);
-            /* if the root message was retrieved, move to it */
-            if (h)
-              menu->current = h->virtual;
-            else /* try to restore old position */
-              for (i = 0; i < Context->msgcount; i++)
-                if (Context->hdrs[i]->index == old)
-                {
-                  menu->current = Context->hdrs[i]->virtual;
-                  /* As an added courtesy, recenter the menu
-                   * with the current entry at the middle of the screen */
-                  menu_check_recenter (menu);
-                  menu_current_middle (menu);
-                }
+          break;
+        }
+
+        if (!Context->id_hash)
+          Context->id_hash = mutt_make_id_hash (Context);
+        strfcpy (buf, CURHDR->env->message_id, sizeof (buf));
+
+        if (op == OP_RECONSTRUCT_THREAD) {
+          LIST *ref = CURHDR->env->references;
+
+          while (ref) {
+            nntp_check_msgid (Context, ref->data);
+            /* the last msgid in References is the root message */
+            if (!ref->next)
+              strfcpy (buf, ref->data, sizeof (buf));
+            ref = ref->next;
           }
-          menu->redraw = REDRAW_FULL;
-          mutt_clear_error ();
         }
-        break;
+        mutt_message (_("Check for children of message..."));
+
+        if (nntp_check_children (Context, buf) == 0) {
+          mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD));
+          h = hash_find (Context->id_hash, buf);
+          /* if the root message was retrieved, move to it */
+          if (h)
+            menu->current = h->virtual;
+          else                  /* try to restore old position */
+            for (i = 0; i < Context->msgcount; i++)
+              if (Context->hdrs[i]->index == old) {
+                menu->current = Context->hdrs[i]->virtual;
+                /* As an added courtesy, recenter the menu
+                 * with the current entry at the middle of the screen */
+                menu_check_recenter (menu);
+                menu_current_middle (menu);
+              }
+        }
+        menu->redraw = REDRAW_FULL;
+        mutt_clear_error ();
+      }
+      break;
 #endif
 
-      case OP_JUMP:
+    case OP_JUMP:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (isdigit (LastKey)) mutt_ungetch (LastKey, 0);
-        buf[0] = 0;
-        if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
-            || !buf[0])
-          break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (isdigit (LastKey))
+        mutt_ungetch (LastKey, 0);
+      buf[0] = 0;
+      if (mutt_get_field (_("Jump to message: "), buf, sizeof (buf), 0) != 0
+          || !buf[0])
+        break;
 
-        if (! isdigit ((unsigned char) buf[0]))
-        {
-          mutt_error _("Argument must be a message number.");
-          break;
-        }
+      if (!isdigit ((unsigned char) buf[0])) {
+        mutt_error (_("Argument must be a message number."));
 
-        i = atoi (buf);
-        if (i > 0 && i <= Context->msgcount)
-        {
-          for (j = i-1; j < Context->msgcount; j++)
-          {
+        break;
+      }
+
+      i = atoi (buf);
+      if (i > 0 && i <= Context->msgcount) {
+        for (j = i - 1; j < Context->msgcount; j++) {
+          if (Context->hdrs[j]->virtual != -1)
+            break;
+        }
+        if (j >= Context->msgcount) {
+          for (j = i - 2; j >= 0; j--) {
             if (Context->hdrs[j]->virtual != -1)
               break;
           }
-          if (j >= Context->msgcount)
-          {
-            for (j = i-2; j >= 0; j--)
-            {
-              if (Context->hdrs[j]->virtual != -1)
-                break;
-            }
-          }
+        }
 
-          if (j >= 0)
-          {
-            menu->current = Context->hdrs[j]->virtual;
-            if (menu->menu == MENU_PAGER)
-            {
-              op = OP_DISPLAY_MESSAGE;
-              continue;
-            }
-            else
-            menu->redraw = REDRAW_MOTION;
+        if (j >= 0) {
+          menu->current = Context->hdrs[j]->virtual;
+          if (menu->menu == MENU_PAGER) {
+            op = OP_DISPLAY_MESSAGE;
+            continue;
           }
           else
-            mutt_error _("That message is not visible.");
+            menu->redraw = REDRAW_MOTION;
         }
         else
-          mutt_error _("Invalid message number.");
+          mutt_error (_("That message is not visible."));
+      }
+      else
+        mutt_error (_("Invalid message number."));
 
-        break;
+      break;
 
-        /* --------------------------------------------------------------------
-         * `index' specific commands
-         */
+      /* --------------------------------------------------------------------
+       * `index' specific commands
+       */
 
-      case OP_MAIN_DELETE_PATTERN:
+    case OP_MAIN_DELETE_PATTERN:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-        CHECK_ATTACH;
-        mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
-        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        break;
+      CHECK_ATTACH;
+      mutt_pattern_func (M_DELETE, _("Delete messages matching: "));
+      menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      break;
 
 #ifdef USE_POP
-      case OP_MAIN_FETCH_MAIL:
+    case OP_MAIN_FETCH_MAIL:
 
-        CHECK_ATTACH;
-        pop_fetch_mail ();
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_ATTACH;
+      pop_fetch_mail ();
+      menu->redraw = REDRAW_FULL;
+      break;
 #endif /* USE_POP */
 
-      case OP_HELP:
+    case OP_HELP:
 
-        mutt_help (MENU_MAIN);
-        menu->redraw = REDRAW_FULL;
-        break;
+      mutt_help (MENU_MAIN);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_MAIN_SHOW_LIMIT:
-        CHECK_MSGCOUNT;
-        if (!Context->pattern)
-           mutt_message _("No limit pattern is in effect.");
-        else
-        {
-           char buf[STRING];
-           /* i18n: ask for a limit to apply */
-           snprintf (buf, sizeof(buf), _("Limit: %s"),Context->pattern);
-           mutt_message ("%s", buf);
-        }
-        break;
+    case OP_MAIN_SHOW_LIMIT:
+      CHECK_MSGCOUNT;
+      if (!Context->pattern)
+        mutt_message (_("No limit pattern is in effect."));
 
-      case OP_MAIN_LIMIT:
-      case OP_TOGGLE_READ:
+      else {
+        char buf[STRING];
 
-        CHECK_MSGCOUNT;
-        menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
-                CURHDR->index : -1;
-        if (op == OP_TOGGLE_READ)
-        {
-          char buf[LONG_STRING];
+        /* i18n: ask for a limit to apply */
+        snprintf (buf, sizeof (buf), _("Limit: %s"), Context->pattern);
+        mutt_message ("%s", buf);
+      }
+      break;
 
-          if (!Context->pattern || strncmp (Context->pattern, "!~R!~D~s", 8) != 0)
-          {
-            snprintf (buf, sizeof (buf), "!~R!~D~s%s",
-                      Context->pattern ? Context->pattern : ".*");
-            set_option (OPTHIDEREAD);
-          }
-          else
-          {
-            strfcpy (buf, Context->pattern + 8, sizeof(buf));
-            if (!*buf || strncmp (buf, ".*", 2) == 0)
-              snprintf (buf, sizeof(buf), "~A");
-            unset_option (OPTHIDEREAD);
-          }
-          FREE (&Context->pattern);
-          Context->pattern = safe_strdup (buf);
-        }
-        if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
-            mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
-        {
-          if (menu->oldcurrent >= 0)
-          {
-            /* try to find what used to be the current message */
-            menu->current = -1;
-            for (i = 0; i < Context->vcount; i++)
-              if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent)
-              {
-                menu->current = i;
-                break;
-              }
-            if (menu->current < 0) menu->current = 0;
-          }
-          else
+    case OP_MAIN_LIMIT:
+    case OP_TOGGLE_READ:
+
+      CHECK_MSGCOUNT;
+      menu->oldcurrent = (Context->vcount && menu->current >= 0
+                          && menu->current <
+                          Context->vcount) ? CURHDR->index : -1;
+      if (op == OP_TOGGLE_READ) {
+        char buf[LONG_STRING];
+
+        if (!Context->pattern
+            || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) {
+          snprintf (buf, sizeof (buf), "!~R!~D~s%s",
+                    Context->pattern ? Context->pattern : ".*");
+          set_option (OPTHIDEREAD);
+        }
+        else {
+          strfcpy (buf, Context->pattern + 8, sizeof (buf));
+          if (!*buf || strncmp (buf, ".*", 2) == 0)
+            snprintf (buf, sizeof (buf), "~A");
+          unset_option (OPTHIDEREAD);
+        }
+        FREE (&Context->pattern);
+        Context->pattern = safe_strdup (buf);
+      }
+      if ((op == OP_TOGGLE_READ && mutt_pattern_func (M_LIMIT, NULL) == 0) ||
+          mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
+      {
+        if (menu->oldcurrent >= 0) {
+          /* try to find what used to be the current message */
+          menu->current = -1;
+          for (i = 0; i < Context->vcount; i++)
+            if (Context->hdrs[Context->v2r[i]]->index == menu->oldcurrent) {
+              menu->current = i;
+              break;
+            }
+          if (menu->current < 0)
             menu->current = 0;
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-          if ((Sort & SORT_MASK) == SORT_THREADS)
-            mutt_draw_tree (Context);
-          menu->redraw = REDRAW_FULL;
         }
-        break;          
+        else
+          menu->current = 0;
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+        if ((Sort & SORT_MASK) == SORT_THREADS)
+          mutt_draw_tree (Context);
+        menu->redraw = REDRAW_FULL;
+      }
+      break;
 
-      case OP_QUIT:
+    case OP_QUIT:
 
-        close = op;
-        if (attach_msg)
-        {
-         done = 1;
-         break;
-        }
+      close = op;
+      if (attach_msg) {
+        done = 1;
+        break;
+      }
 
-        if (query_quadoption (OPT_QUIT, _("Quit Mutt-ng?")) == M_YES)
-        {
-          int check;
-          
-          oldcount = Context ? Context->msgcount : 0;
+      if (query_quadoption (OPT_QUIT, _("Quit Mutt-ng?")) == M_YES) {
+        int check;
 
-          if (!Context || (check = mx_close_mailbox (Context, &index_hint)) == 0)
-            done = 1;
-          else
-          {
-            if (check == M_NEW_MAIL || check == M_REOPENED)
-              update_index (menu, Context, check, oldcount, index_hint);
+        oldcount = Context ? Context->msgcount : 0;
 
-            menu->redraw = REDRAW_FULL; /* new mail arrived? */
-            set_option (OPTSEARCHINVALID);
-          }
+        if (!Context
+            || (check = mx_close_mailbox (Context, &index_hint)) == 0)
+          done = 1;
+        else {
+          if (check == M_NEW_MAIL || check == M_REOPENED)
+            update_index (menu, Context, check, oldcount, index_hint);
+
+          menu->redraw = REDRAW_FULL;   /* new mail arrived? */
+          set_option (OPTSEARCHINVALID);
         }
-        break;
+      }
+      break;
 
-      case OP_REDRAW:
+    case OP_REDRAW:
 
-        clearok (stdscr, TRUE);
-        menu->redraw = REDRAW_FULL;
-        break;
+      clearok (stdscr, TRUE);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_SEARCH:
-      case OP_SEARCH_REVERSE:
-      case OP_SEARCH_NEXT:
-      case OP_SEARCH_OPPOSITE:
+    case OP_SEARCH:
+    case OP_SEARCH_REVERSE:
+    case OP_SEARCH_NEXT:
+    case OP_SEARCH_OPPOSITE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if ((menu->current = mutt_search_command (menu->current, op)) == -1)
-          menu->current = menu->oldcurrent;
-        else
-          menu->redraw = REDRAW_MOTION;
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if ((menu->current = mutt_search_command (menu->current, op)) == -1)
+        menu->current = menu->oldcurrent;
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_SORT:
-      case OP_SORT_REVERSE:
+    case OP_SORT:
+    case OP_SORT_REVERSE:
 
-        if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0)
-        {
-          if (Context && Context->msgcount)
-          {
-            resort_index (menu);
-            set_option (OPTSEARCHINVALID);
-          }
+      if (mutt_select_sort ((op == OP_SORT_REVERSE)) == 0) {
+        if (Context && Context->msgcount) {
+          resort_index (menu);
+          set_option (OPTSEARCHINVALID);
         }
-        break;
+      }
+      break;
 
-      case OP_TAG:
+    case OP_TAG:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (tag && !option (OPTAUTOTAG))
-        {
-          for (j = 0; j < Context->vcount; j++)
-            mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
-          menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (tag && !option (OPTAUTOTAG)) {
+        for (j = 0; j < Context->vcount; j++)
+          mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_TAG, 0);
+        menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
+      }
+      else {
+        mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
+        Context->last_tag = CURHDR->tagged ? CURHDR :
+          ((Context->last_tag == CURHDR && !CURHDR->tagged)
+           ? NULL : Context->last_tag);
+        menu->redraw = REDRAW_STATUS;
+        if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
+          menu->current++;
+          menu->redraw |= REDRAW_MOTION_RESYNCH;
         }
         else
-        {
-          mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
-          Context->last_tag = CURHDR->tagged ? CURHDR :
-            ((Context->last_tag == CURHDR && !CURHDR->tagged)
-            ? NULL : Context->last_tag);
-          menu->redraw = REDRAW_STATUS;
-          if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
-          {
-            menu->current++;
-            menu->redraw |= REDRAW_MOTION_RESYNCH;
-          }
-          else
-            menu->redraw |= REDRAW_CURRENT;
-        }
-        break;
+          menu->redraw |= REDRAW_CURRENT;
+      }
+      break;
 
-      case OP_MAIN_TAG_PATTERN:
+    case OP_MAIN_TAG_PATTERN:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        mutt_pattern_func (M_TAG, _("Tag messages matching: "));
-        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      mutt_pattern_func (M_TAG, _("Tag messages matching: "));
+      menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      break;
 
-      case OP_MAIN_UNDELETE_PATTERN:
+    case OP_MAIN_UNDELETE_PATTERN:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-        if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) == 0)
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        break;
+      if (mutt_pattern_func (M_UNDELETE, _("Undelete messages matching: ")) ==
+          0)
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      break;
 
-      case OP_MAIN_UNTAG_PATTERN:
+    case OP_MAIN_UNTAG_PATTERN:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (mutt_pattern_func (M_UNTAG, _("Untag messages matching: ")) == 0)
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      break;
 
-        /* --------------------------------------------------------------------
-         * The following operations can be performed inside of the pager.
-         */
+      /* --------------------------------------------------------------------
+       * The following operations can be performed inside of the pager.
+       */
 
 #ifdef USE_IMAP
-      case OP_MAIN_IMAP_FETCH:
-        if (Context->magic == M_IMAP)
-          imap_check_mailbox (Context, &index_hint, 1);
-        break;
+    case OP_MAIN_IMAP_FETCH:
+      if (Context->magic == M_IMAP)
+        imap_check_mailbox (Context, &index_hint, 1);
+      break;
 #endif
-      
-      case OP_MAIN_SYNC_FOLDER:
 
-       if (Context && !Context->msgcount)
-         break;
+    case OP_MAIN_SYNC_FOLDER:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
-        {
-          int oldvcount = Context->vcount;
-          int oldcount  = Context->msgcount;
-          int dcount = 0;
-          int check;
-
-          /* calculate the number of messages _above_ the cursor,
-           * so we can keep the cursor on the current message
-           */ 
-          for (j = 0; j <= menu->current; j++)
-          {
-            if (Context->hdrs[Context->v2r[j]]->deleted)
-              dcount++;
-          }
+      if (Context && !Context->msgcount)
+        break;
 
-          if ((check = mx_sync_mailbox (Context, &index_hint)) == 0)
-          {
-            if (Context->vcount != oldvcount)
-              menu->current -= dcount;
-            set_option (OPTSEARCHINVALID);
-          }
-          else if (check == M_NEW_MAIL || check == M_REOPENED)
-            update_index (menu, Context, check, oldcount, index_hint);
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
+      {
+        int oldvcount = Context->vcount;
+        int oldcount = Context->msgcount;
+        int dcount = 0;
+        int check;
 
-          /* 
-           * do a sanity check even if mx_sync_mailbox failed.
-           */
+        /* calculate the number of messages _above_ the cursor,
+         * so we can keep the cursor on the current message
+         */
+        for (j = 0; j <= menu->current; j++) {
+          if (Context->hdrs[Context->v2r[j]]->deleted)
+            dcount++;
+        }
 
-          if (menu->current < 0 || menu->current >= Context->vcount)
-            menu->current = ci_first_message ();
+        if ((check = mx_sync_mailbox (Context, &index_hint)) == 0) {
+          if (Context->vcount != oldvcount)
+            menu->current -= dcount;
+          set_option (OPTSEARCHINVALID);
         }
+        else if (check == M_NEW_MAIL || check == M_REOPENED)
+          update_index (menu, Context, check, oldcount, index_hint);
 
-        /* check for a fatal error, or all messages deleted */
-        if (!Context->path)
-          FREE (&Context);
+        /* 
+         * do a sanity check even if mx_sync_mailbox failed.
+         */
 
-        /* if we were in the pager, redisplay the message */
-        if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_FULL;
-        break;
+        if (menu->current < 0 || menu->current >= Context->vcount)
+          menu->current = ci_first_message ();
+      }
+
+      /* check for a fatal error, or all messages deleted */
+      if (!Context->path)
+        FREE (&Context);
 
-      case OP_SIDEBAR_OPEN:
-      case OP_MAIN_CHANGE_FOLDER:
-      case OP_MAIN_CHANGE_FOLDER_READONLY:
+      /* if we were in the pager, redisplay the message */
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_SIDEBAR_OPEN:
+    case OP_MAIN_CHANGE_FOLDER:
+    case OP_MAIN_CHANGE_FOLDER_READONLY:
 #ifdef USE_NNTP
-      case OP_MAIN_CHANGE_GROUP:
-      case OP_MAIN_CHANGE_GROUP_READONLY:
+    case OP_MAIN_CHANGE_GROUP:
+    case OP_MAIN_CHANGE_GROUP_READONLY:
 #endif
-        if (attach_msg || option (OPTREADONLY) ||
+      if (attach_msg || option (OPTREADONLY) ||
 #ifdef USE_NNTP
-            op == OP_MAIN_CHANGE_GROUP_READONLY ||
+          op == OP_MAIN_CHANGE_GROUP_READONLY ||
 #endif
-            op == OP_MAIN_CHANGE_FOLDER_READONLY)
-          flags = M_READONLY;
-        else
-          flags = 0;
+          op == OP_MAIN_CHANGE_FOLDER_READONLY)
+        flags = M_READONLY;
+      else
+        flags = 0;
 
-        if (flags)
-          cp = _("Open mailbox in read-only mode");
-        else
-          cp = _("Open mailbox");
+      if (flags)
+        cp = _("Open mailbox in read-only mode");
+      else
+        cp = _("Open mailbox");
 
-        buf[0] = '\0';
+      buf[0] = '\0';
 #ifdef USE_NNTP
-        unset_option (OPTNEWS);
-        if (op == OP_MAIN_CHANGE_GROUP ||
-            op == OP_MAIN_CHANGE_GROUP_READONLY)
-        {
-          set_option (OPTNEWS);
-          if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
-            break;
-          if (flags)
-            cp = _("Open newsgroup in read-only mode");
-          else
-            cp = _("Open newsgroup");
-          nntp_buffy (buf);
-        }
+      unset_option (OPTNEWS);
+      if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY) {
+        set_option (OPTNEWS);
+        if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
+          break;
+        if (flags)
+          cp = _("Open newsgroup in read-only mode");
         else
+          cp = _("Open newsgroup");
+        nntp_buffy (buf);
+      }
+      else
 #endif
-        {
-          if (Context && Context->path)
-            strncpy (buf, Context->path, sizeof (buf));
-          mutt_buffy (buf, sizeof (buf));
-        }
+      {
+        if (Context && Context->path)
+          strncpy (buf, Context->path, sizeof (buf));
+        mutt_buffy (buf, sizeof (buf));
+      }
 
-        if ( op == OP_SIDEBAR_OPEN ) {
-          if(!CurBuffy)
-            break;
-          strncpy( buf, CurBuffy->path, sizeof(buf) );
-        } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
-          break;
-        if (!buf[0])
-        {
-          CLEARLINE (LINES-1);
+      if (op == OP_SIDEBAR_OPEN) {
+        if (!CurBuffy)
           break;
-        }
+        strncpy (buf, CurBuffy->path, sizeof (buf));
+      }
+      else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) ==
+               -1)
+        break;
+      if (!buf[0]) {
+        CLEARLINE (LINES - 1);
+        break;
+      }
 
 #ifdef USE_NNTP
-        if (option (OPTNEWS))
-        {
-          unset_option (OPTNEWS);
-          nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
-        }
-        else
+      if (option (OPTNEWS)) {
+        unset_option (OPTNEWS);
+        nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account);
+      }
+      else
 #endif
         mutt_expand_path (buf, sizeof (buf));
-        set_curbuffy(buf);
-        if (mx_get_magic (buf) <= 0)
-        {
-          mutt_error (_("%s is not a mailbox."), buf);
-          break;
-        }
-        mutt_str_replace (&CurrentFolder, buf);
+      set_curbuffy (buf);
+      if (mx_get_magic (buf) <= 0) {
+        mutt_error (_("%s is not a mailbox."), buf);
+        break;
+      }
+      mutt_str_replace (&CurrentFolder, buf);
 
-        if (Context)
-        {
-          int check;
+      if (Context) {
+        int check;
 
 #ifdef USE_COMPRESSED
-          if (Context->compressinfo && Context->realpath)
-            mutt_str_replace (&LastFolder, Context->realpath);
-          else
+        if (Context->compressinfo && Context->realpath)
+          mutt_str_replace (&LastFolder, Context->realpath);
+        else
 #endif
 
           mutt_str_replace (&LastFolder, Context->path);
-          oldcount = Context ? Context->msgcount : 0;
-
-          if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
-          {
-            if (check == M_NEW_MAIL || check == M_REOPENED)
-              update_index (menu, Context, check, oldcount, index_hint);
-                
-            set_option (OPTSEARCHINVALID);
-            menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-            break;
-          }
-          FREE (&Context);
+        oldcount = Context ? Context->msgcount : 0;
+
+        if ((check = mx_close_mailbox (Context, &index_hint)) != 0) {
+          if (check == M_NEW_MAIL || check == M_REOPENED)
+            update_index (menu, Context, check, oldcount, index_hint);
+
+          set_option (OPTSEARCHINVALID);
+          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+          break;
         }
+        FREE (&Context);
+      }
 
-        mutt_sleep (0);
-      
-        /* Set CurrentMenu to MENU_MAIN before executing any folder
-         * hooks so that all the index menu functions are available to
-         * the exec command.
-         */
+      mutt_sleep (0);
 
-        CurrentMenu = MENU_MAIN;
-        mutt_folder_hook (buf);
+      /* Set CurrentMenu to MENU_MAIN before executing any folder
+       * hooks so that all the index menu functions are available to
+       * the exec command.
+       */
 
-        if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL)
-        {
-          menu->current = ci_first_message ();
-        }
-        else
-          menu->current = 0;
+      CurrentMenu = MENU_MAIN;
+      mutt_folder_hook (buf);
+
+      if ((Context = mx_open_mailbox (buf, flags, NULL)) != NULL) {
+        menu->current = ci_first_message ();
+      }
+      else
+        menu->current = 0;
 
 #ifdef USE_NNTP
-        /* mutt_buffy_check() must be done with mail-reader mode! */
-        menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
-          (Context && (Context->magic == M_NNTP)) ? IndexNewsHelp : IndexHelp);
+      /* mutt_buffy_check() must be done with mail-reader mode! */
+      menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN,
+                                      (Context
+                                       && (Context->magic ==
+                                           M_NNTP)) ? IndexNewsHelp :
+                                      IndexHelp);
 #endif
-        mutt_clear_error ();
-        mutt_buffy_check(1); /* force the buffy check after we have changed
-                              the folder */
-        menu->redraw = REDRAW_FULL;
-        set_option (OPTSEARCHINVALID);
-        break;
+      mutt_clear_error ();
+      mutt_buffy_check (1);     /* force the buffy check after we have changed
+                                   the folder */
+      menu->redraw = REDRAW_FULL;
+      set_option (OPTSEARCHINVALID);
+      break;
 
-      case OP_DISPLAY_MESSAGE:
-      case OP_DISPLAY_HEADERS: /* don't weed the headers */
+    case OP_DISPLAY_MESSAGE:
+    case OP_DISPLAY_HEADERS:   /* don't weed the headers */
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        /*
-         * toggle the weeding of headers so that a user can press the key
-         * again while reading the message.
-         */
-        if (op == OP_DISPLAY_HEADERS)
-          toggle_option (OPTWEED);
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      /*
+       * toggle the weeding of headers so that a user can press the key
+       * again while reading the message.
+       */
+      if (op == OP_DISPLAY_HEADERS)
+        toggle_option (OPTWEED);
+
+      unset_option (OPTNEEDRESORT);
 
+      if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed) {
+        mutt_uncollapse_thread (Context, CURHDR);
+        mutt_set_virtual (Context);
+        if (option (OPTUNCOLLAPSEJUMP))
+          menu->current = mutt_thread_next_unread (Context, CURHDR);
+      }
+
+      if ((op = mutt_display_message (CURHDR)) == -1) {
         unset_option (OPTNEEDRESORT);
+        break;
+      }
 
-        if ((Sort & SORT_MASK) == SORT_THREADS && CURHDR->collapsed)
-        {
-          mutt_uncollapse_thread (Context, CURHDR);
-          mutt_set_virtual (Context);
-          if (option (OPTUNCOLLAPSEJUMP))
-            menu->current = mutt_thread_next_unread (Context, CURHDR);
-        }
-        if ((op = mutt_display_message (CURHDR)) == -1)
-        {
-          unset_option (OPTNEEDRESORT);
-          break;
+      menu->menu = MENU_PAGER;
+      menu->oldcurrent = menu->current;
+      continue;
+
+    case OP_EXIT:
+
+      close = op;
+      if (menu->menu == MENU_MAIN && attach_msg) {
+        done = 1;
+        break;
+      }
+
+      if ((menu->menu == MENU_MAIN)
+          && (query_quadoption (OPT_QUIT,
+                                _("Exit Mutt-ng without saving?")) == M_YES))
+      {
+        if (Context) {
+          mx_fastclose_mailbox (Context);
+          FREE (&Context);
         }
+        done = 1;
+      }
+      break;
 
-        menu->menu = MENU_PAGER;
-         menu->oldcurrent = menu->current;
+    case OP_EDIT_TYPE:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_ATTACH;
+      mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
+      /* if we were in the pager, redisplay the message */
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
         continue;
+      }
+      else
+        menu->redraw = REDRAW_CURRENT;
+      break;
 
-      case OP_EXIT:
+    case OP_MAIN_BREAK_THREAD:
 
-        close = op;
-        if (menu->menu == MENU_MAIN && attach_msg)
-        {
-         done = 1;
-         break;
-        }
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
+
+      if ((Sort & SORT_MASK) != SORT_THREADS)
+        mutt_error (_("Threading is not enabled."));
 
-        if ((menu->menu == MENU_MAIN)
-            && (query_quadoption (OPT_QUIT, 
-                                  _("Exit Mutt-ng without saving?")) == M_YES))
+      else {
         {
-          if (Context)
-          {
-            mx_fastclose_mailbox (Context);
-            FREE (&Context);
-          }
-          done = 1;
+          HEADER *oldcur = CURHDR;
+
+          mutt_break_thread (CURHDR);
+          mutt_sort_headers (Context, 1);
+          menu->current = oldcur->virtual;
         }
-        break;
 
-      case OP_EDIT_TYPE:
+        Context->changed = 1;
+        mutt_message _("Thread broken");
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_ATTACH;
-        mutt_edit_content_type (CURHDR, CURHDR->content, NULL);
-        /* if we were in the pager, redisplay the message */
-        if (menu->menu == MENU_PAGER)
-        {
+        if (menu->menu == MENU_PAGER) {
           op = OP_DISPLAY_MESSAGE;
           continue;
         }
         else
-          menu->redraw = REDRAW_CURRENT;
-        break;
-
-      case OP_MAIN_BREAK_THREAD:
-
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+          menu->redraw |= REDRAW_INDEX;
+      }
+      break;
 
-        if ((Sort & SORT_MASK) != SORT_THREADS)
-          mutt_error _("Threading is not enabled.");
-        else
-        {
-          {
-            HEADER *oldcur = CURHDR;
+    case OP_MAIN_LINK_THREADS:
 
-            mutt_break_thread (CURHDR);
-            mutt_sort_headers (Context, 1);
-            menu->current = oldcur->virtual;
-          }
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
-          Context->changed = 1;
-          mutt_message _("Thread broken");
+      if ((Sort & SORT_MASK) != SORT_THREADS)
+        mutt_error (_("Threading is not enabled."));
 
-          if (menu->menu == MENU_PAGER)
-          {
-            op = OP_DISPLAY_MESSAGE;
-            continue;
-          }
-          else
-            menu->redraw |= REDRAW_INDEX;
-        }
-        break;
+      else if (!CURHDR->env->message_id)
+        mutt_error (_("No Message-ID: header available to link thread"));
 
-      case OP_MAIN_LINK_THREADS:
+      else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
+        mutt_error (_("First, please tag a message to be linked here"));
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
-
-        if ((Sort & SORT_MASK) != SORT_THREADS)
-          mutt_error _("Threading is not enabled.");
-        else if (!CURHDR->env->message_id)
-          mutt_error _("No Message-ID: header available to link thread");
-        else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
-          mutt_error _("First, please tag a message to be linked here");
-        else 
-        {
-          HEADER *oldcur = CURHDR;
+      else {
+        HEADER *oldcur = CURHDR;
 
-          if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
-                                 Context))
-          {
-            mutt_sort_headers (Context, 1);
-            menu->current = oldcur->virtual;
-            
-            Context->changed = 1;
-            mutt_message _("Threads linked");
-          }
-          else
-            mutt_error _("No thread linked");
-        }
+        if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
+                               Context)) {
+          mutt_sort_headers (Context, 1);
+          menu->current = oldcur->virtual;
 
-        if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
+          Context->changed = 1;
+          mutt_message _("Threads linked");
         }
         else
-          menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
-        break;
+          mutt_error (_("No thread linked"));
+      }
 
-      case OP_MAIN_NEXT_UNDELETED:
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
+      break;
+
+    case OP_MAIN_NEXT_UNDELETED:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (menu->current >= Context->vcount - 1) {
+        if (menu->menu == MENU_MAIN)
+          mutt_error (_("You are on the last message."));
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (menu->current >= Context->vcount - 1)
-        {
-          if (menu->menu == MENU_MAIN)
-            mutt_error _("You are on the last message.");
-          break;
-        }
-        if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-        {
-          menu->current = menu->oldcurrent;
-          if (menu->menu == MENU_MAIN)
-            mutt_error _("No undeleted messages.");
-        }
-        else if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_MOTION;
         break;
+      }
+      if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+        menu->current = menu->oldcurrent;
+        if (menu->menu == MENU_MAIN)
+          mutt_error (_("No undeleted messages."));
+      }
+      else if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_NEXT_ENTRY:
+    case OP_NEXT_ENTRY:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (menu->current >= Context->vcount - 1) {
+        if (menu->menu == MENU_MAIN)
+          mutt_error (_("You are on the last message."));
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (menu->current >= Context->vcount - 1)
-        {
-          if (menu->menu == MENU_MAIN)
-            mutt_error _("You are on the last message.");
-          break;
-        }
-        menu->current++;
-        if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_MOTION;
         break;
+      }
+      menu->current++;
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_MAIN_PREV_UNDELETED:
+    case OP_MAIN_PREV_UNDELETED:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (menu->current < 1) {
+        mutt_error (_("You are on the first message."));
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (menu->current < 1)
-        {
-          mutt_error _("You are on the first message.");
-          break;
-        }
-        if ((menu->current = ci_previous_undeleted (menu->current)) == -1)
-        {
-          menu->current = menu->oldcurrent;
-          if (menu->menu == MENU_MAIN)
-            mutt_error _("No undeleted messages.");
-        }
-        else if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_MOTION;
         break;
+      }
+      if ((menu->current = ci_previous_undeleted (menu->current)) == -1) {
+        menu->current = menu->oldcurrent;
+        if (menu->menu == MENU_MAIN)
+          mutt_error (_("No undeleted messages."));
+      }
+      else if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_PREV_ENTRY:
+    case OP_PREV_ENTRY:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (menu->current < 1) {
+        if (menu->menu == MENU_MAIN)
+          mutt_error (_("You are on the first message."));
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (menu->current < 1)
-        {
-          if (menu->menu == MENU_MAIN) mutt_error _("You are on the first message.");
-          break;
-        }
-        menu->current--;
-        if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_MOTION;
         break;
+      }
+      menu->current--;
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_DECRYPT_COPY:
-      case OP_DECRYPT_SAVE:
-        if (!WithCrypto)
-          break;   
-        /* fall thru */
-      case OP_COPY_MESSAGE:
-      case OP_SAVE:
-      case OP_DECODE_COPY:
-      case OP_DECODE_SAVE:
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        if (mutt_save_message (tag ? NULL : CURHDR,
-                               (op == OP_DECRYPT_SAVE) ||
-                               (op == OP_SAVE) || (op == OP_DECODE_SAVE),
-                               (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
-                               (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
-                               0,
-                               &menu->redraw) == 0 &&
-             (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
-            )
-        {
-          if (tag)
-            menu->redraw |= REDRAW_INDEX;
-          else if (option (OPTRESOLVE))
-          {
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-            {
-              menu->current = menu->oldcurrent;
-              menu->redraw |= REDRAW_CURRENT;
-            }
-            else
-              menu->redraw |= REDRAW_MOTION_RESYNCH;
+    case OP_DECRYPT_COPY:
+    case OP_DECRYPT_SAVE:
+      if (!WithCrypto)
+        break;
+      /* fall thru */
+    case OP_COPY_MESSAGE:
+    case OP_SAVE:
+    case OP_DECODE_COPY:
+    case OP_DECODE_SAVE:
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (mutt_save_message (tag ? NULL : CURHDR,
+                             (op == OP_DECRYPT_SAVE) ||
+                             (op == OP_SAVE) || (op == OP_DECODE_SAVE),
+                             (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
+                             (op == OP_DECRYPT_SAVE)
+                             || (op == OP_DECRYPT_COPY)
+                             || 0, &menu->redraw) == 0 && (op == OP_SAVE
+                                                           || op ==
+                                                           OP_DECODE_SAVE
+                                                           || op ==
+                                                           OP_DECRYPT_SAVE)
+        ) {
+        if (tag)
+          menu->redraw |= REDRAW_INDEX;
+        else if (option (OPTRESOLVE)) {
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+            menu->current = menu->oldcurrent;
+            menu->redraw |= REDRAW_CURRENT;
           }
           else
-            menu->redraw |= REDRAW_CURRENT;
+            menu->redraw |= REDRAW_MOTION_RESYNCH;
         }
-        break;
+        else
+          menu->redraw |= REDRAW_CURRENT;
+      }
+      break;
 
-      case OP_MAIN_NEXT_NEW:
-      case OP_MAIN_NEXT_UNREAD:
-      case OP_MAIN_PREV_NEW:
-      case OP_MAIN_PREV_UNREAD:
-      case OP_MAIN_NEXT_NEW_THEN_UNREAD:
-      case OP_MAIN_PREV_NEW_THEN_UNREAD:
+    case OP_MAIN_NEXT_NEW:
+    case OP_MAIN_NEXT_UNREAD:
+    case OP_MAIN_PREV_NEW:
+    case OP_MAIN_PREV_UNREAD:
+    case OP_MAIN_NEXT_NEW_THEN_UNREAD:
+    case OP_MAIN_PREV_NEW_THEN_UNREAD:
 
       {
         int first_unread = -1;
-        int first_new    = -1;
-        
+        int first_new = -1;
+
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
 
         i = menu->current;
         menu->current = -1;
-        for (j = 0; j != Context->vcount; j++)
-        {
-#define CURHDRi Context->hdrs[Context->v2r[i]] 
-          if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
-          {
+        for (j = 0; j != Context->vcount; j++) {
+#define CURHDRi Context->hdrs[Context->v2r[i]]
+          if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD
+              || op == OP_MAIN_NEXT_NEW_THEN_UNREAD) {
             i++;
-            if (i > Context->vcount - 1)
-            {
+            if (i > Context->vcount - 1) {
               mutt_message _("Search wrapped to top.");
+
               i = 0;
             }
           }
-          else
-          {
+          else {
             i--;
-            if (i < 0)
-            {
+            if (i < 0) {
               mutt_message _("Search wrapped to bottom.");
+
               i = Context->vcount - 1;
             }
           }
 
-          if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS)
-          {
+          if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) {
             if (UNREAD (CURHDRi) && first_unread == -1)
               first_unread = i;
             if (UNREAD (CURHDRi) == 1 && first_new == -1)
               first_new = i;
           }
-          else if ((!CURHDRi->deleted && !CURHDRi->read))
-          {
+          else if ((!CURHDRi->deleted && !CURHDRi->read)) {
             if (first_unread == -1)
               first_unread = i;
             if ((!CURHDRi->old) && first_new == -1)
               first_new = i;
           }
-          
+
           if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) &&
               first_unread != -1)
             break;
           if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
-               op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
+               op == OP_MAIN_NEXT_NEW_THEN_UNREAD
+               || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
               && first_new != -1)
             break;
         }
 #undef CURHDRi
         if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW ||
-             op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD) 
+             op == OP_MAIN_NEXT_NEW_THEN_UNREAD
+             || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
             && first_new != -1)
           menu->current = first_new;
         else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD ||
-                  op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
+                  op == OP_MAIN_NEXT_NEW_THEN_UNREAD
+                  || op == OP_MAIN_PREV_NEW_THEN_UNREAD)
                  && first_unread != -1)
           menu->current = first_unread;
 
-        if (menu->current == -1)
-        {
+        if (menu->current == -1) {
           menu->current = menu->oldcurrent;
-          mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"),
+          mutt_error ("%s%s.",
+                      (op == OP_MAIN_NEXT_NEW
+                       || op ==
+                       OP_MAIN_PREV_NEW) ? _("No new messages") :
+                      _("No unread messages"),
                       Context->pattern ? _(" in this limited view") : "");
         }
-        else if (menu->menu == MENU_PAGER)
-        {
+        else if (menu->menu == MENU_PAGER) {
           op = OP_DISPLAY_MESSAGE;
           continue;
         }
@@ -1721,785 +1648,755 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
           menu->redraw = REDRAW_MOTION;
         break;
       }
-      case OP_FLAG_MESSAGE:
+    case OP_FLAG_MESSAGE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_POP
-        if (Context->magic == M_POP)
-        {
-          mutt_flushinp ();
-          mutt_error _("Can't change 'important' flag on POP server.");
-          break;
-        }
+      if (Context->magic == M_POP) {
+        mutt_flushinp ();
+        mutt_error (_("Can't change 'important' flag on POP server."));
+
+        break;
+      }
 #endif
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_WRITE);
+      CHECK_IMAP_ACL (IMAP_ACL_WRITE);
 #endif
 
 #ifdef USE_NNTP
-        if (Context->magic == M_NNTP)
-        {
-          mutt_flushinp ();
-          mutt_error _("Can't change 'important' flag on NNTP server.");
-          break;
-        }
-#endif
+      if (Context->magic == M_NNTP) {
+        mutt_flushinp ();
+        mutt_error (_("Can't change 'important' flag on NNTP server."));
 
-        if (tag)
-        {
-          for (j = 0; j < Context->vcount; j++)
-          {
-            if (Context->hdrs[Context->v2r[j]]->tagged)
-              mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
-                             M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
-          }
+        break;
+      }
+#endif
 
-          menu->redraw |= REDRAW_INDEX;
+      if (tag) {
+        for (j = 0; j < Context->vcount; j++) {
+          if (Context->hdrs[Context->v2r[j]]->tagged)
+            mutt_set_flag (Context, Context->hdrs[Context->v2r[j]],
+                           M_FLAG, !Context->hdrs[Context->v2r[j]]->flagged);
         }
-        else
-        {
-          mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
-          if (option (OPTRESOLVE))
-          {
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-            {
-              menu->current = menu->oldcurrent;
-              menu->redraw = REDRAW_CURRENT;
-            }
-            else
-              menu->redraw = REDRAW_MOTION_RESYNCH;
+
+        menu->redraw |= REDRAW_INDEX;
+      }
+      else {
+        mutt_set_flag (Context, CURHDR, M_FLAG, !CURHDR->flagged);
+        if (option (OPTRESOLVE)) {
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+            menu->current = menu->oldcurrent;
+            menu->redraw = REDRAW_CURRENT;
           }
           else
-            menu->redraw = REDRAW_CURRENT;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
         }
-        menu->redraw |= REDRAW_STATUS;
-        break;
+        else
+          menu->redraw = REDRAW_CURRENT;
+      }
+      menu->redraw |= REDRAW_STATUS;
+      break;
 
-      case OP_TOGGLE_NEW:
+    case OP_TOGGLE_NEW:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
+      CHECK_IMAP_ACL (IMAP_ACL_SEEN);
 #endif
 
-        if (tag)
-        {
-          for (j = 0; j < Context->vcount; j++)
-          {
-            if (Context->hdrs[Context->v2r[j]]->tagged)
-            {
-              if (Context->hdrs[Context->v2r[j]]->read ||
-                  Context->hdrs[Context->v2r[j]]->old)
-                mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1);
-              else
-                mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1);
-            }
+      if (tag) {
+        for (j = 0; j < Context->vcount; j++) {
+          if (Context->hdrs[Context->v2r[j]]->tagged) {
+            if (Context->hdrs[Context->v2r[j]]->read ||
+                Context->hdrs[Context->v2r[j]]->old)
+              mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW,
+                             1);
+            else
+              mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ,
+                             1);
           }
-          menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
         }
+        menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
+      }
+      else {
+        if (CURHDR->read || CURHDR->old)
+          mutt_set_flag (Context, CURHDR, M_NEW, 1);
         else
-        {
-          if (CURHDR->read || CURHDR->old)
-            mutt_set_flag (Context, CURHDR, M_NEW, 1);
-          else
-            mutt_set_flag (Context, CURHDR, M_READ, 1);
-
-          if (option (OPTRESOLVE))
-          {
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-            {
-              menu->current = menu->oldcurrent;
-              menu->redraw = REDRAW_CURRENT;
-            }
-            else
-              menu->redraw = REDRAW_MOTION_RESYNCH;
+          mutt_set_flag (Context, CURHDR, M_READ, 1);
+
+        if (option (OPTRESOLVE)) {
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+            menu->current = menu->oldcurrent;
+            menu->redraw = REDRAW_CURRENT;
           }
           else
-            menu->redraw = REDRAW_CURRENT;
-          menu->redraw |= REDRAW_STATUS;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
         }
-        break;
+        else
+          menu->redraw = REDRAW_CURRENT;
+        menu->redraw |= REDRAW_STATUS;
+      }
+      break;
 
-      case OP_TOGGLE_WRITE:
+    case OP_TOGGLE_WRITE:
 
-        CHECK_MSGCOUNT;
-        if (mx_toggle_write (Context) == 0)
-          menu->redraw |= REDRAW_STATUS;
-        break;
+      CHECK_MSGCOUNT;
+      if (mx_toggle_write (Context) == 0)
+        menu->redraw |= REDRAW_STATUS;
+      break;
+
+    case OP_MAIN_NEXT_THREAD:
+    case OP_MAIN_NEXT_SUBTHREAD:
+    case OP_MAIN_PREV_THREAD:
+    case OP_MAIN_PREV_SUBTHREAD:
 
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      switch (op) {
       case OP_MAIN_NEXT_THREAD:
+        menu->current = mutt_next_thread (CURHDR);
+        break;
+
       case OP_MAIN_NEXT_SUBTHREAD:
-      case OP_MAIN_PREV_THREAD:
-      case OP_MAIN_PREV_SUBTHREAD:
+        menu->current = mutt_next_subthread (CURHDR);
+        break;
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        switch (op)
-        {
-          case OP_MAIN_NEXT_THREAD:
-            menu->current = mutt_next_thread (CURHDR);
-            break;
+      case OP_MAIN_PREV_THREAD:
+        menu->current = mutt_previous_thread (CURHDR);
+        break;
 
-          case OP_MAIN_NEXT_SUBTHREAD:
-            menu->current = mutt_next_subthread (CURHDR);
-            break;
-            
-          case OP_MAIN_PREV_THREAD:
-            menu->current = mutt_previous_thread (CURHDR);
-            break;
+      case OP_MAIN_PREV_SUBTHREAD:
+        menu->current = mutt_previous_subthread (CURHDR);
+        break;
+      }
 
-          case OP_MAIN_PREV_SUBTHREAD:
-            menu->current = mutt_previous_subthread (CURHDR);
-            break;
-        }
+      if (menu->current < 0) {
+        menu->current = menu->oldcurrent;
+        if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
+          mutt_error (_("No more threads."));
 
-        if (menu->current < 0)
-        {
-          menu->current = menu->oldcurrent;
-          if (op == OP_MAIN_NEXT_THREAD || op == OP_MAIN_NEXT_SUBTHREAD)
-            mutt_error _("No more threads.");
-          else
-            mutt_error _("You are on the first thread.");
-        }
-        else if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
         else
-          menu->redraw = REDRAW_MOTION;
-        break;
+          mutt_error (_("You are on the first thread."));
+      }
+      else if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_MAIN_PARENT_MESSAGE:
+    case OP_MAIN_PARENT_MESSAGE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
 
-        if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0)
-        {
-          menu->current = menu->oldcurrent;
-        }
-        else if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
-        else
-          menu->redraw = REDRAW_MOTION;
-        break;
+      if ((menu->current = mutt_parent_message (Context, CURHDR)) < 0) {
+        menu->current = menu->oldcurrent;
+      }
+      else if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      else
+        menu->redraw = REDRAW_MOTION;
+      break;
 
-      case OP_MAIN_SET_FLAG:
-      case OP_MAIN_CLEAR_FLAG:
+    case OP_MAIN_SET_FLAG:
+    case OP_MAIN_CLEAR_FLAG:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
-        
 /* #ifdef USE_IMAP
 CHECK_IMAP_ACL(IMAP_ACL_WRITE);
 #endif */
 
-        if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) == 0)
-        {
-          menu->redraw = REDRAW_STATUS;
-          if (tag)
-            menu->redraw |= REDRAW_INDEX;
-          else if (option (OPTRESOLVE))
-          {
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-            {
-              menu->current = menu->oldcurrent;
-              menu->redraw |= REDRAW_CURRENT;
-            }
-            else
-              menu->redraw |= REDRAW_MOTION_RESYNCH;
+      if (mutt_change_flag (tag ? NULL : CURHDR, (op == OP_MAIN_SET_FLAG)) ==
+          0) {
+        menu->redraw = REDRAW_STATUS;
+        if (tag)
+          menu->redraw |= REDRAW_INDEX;
+        else if (option (OPTRESOLVE)) {
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+            menu->current = menu->oldcurrent;
+            menu->redraw |= REDRAW_CURRENT;
           }
           else
-            menu->redraw |= REDRAW_CURRENT;
+            menu->redraw |= REDRAW_MOTION_RESYNCH;
         }
+        else
+          menu->redraw |= REDRAW_CURRENT;
+      }
+      break;
+
+    case OP_MAIN_COLLAPSE_THREAD:
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+
+      if ((Sort & SORT_MASK) != SORT_THREADS) {
+        mutt_error (_("Threading is not enabled."));
+
         break;
+      }
 
-      case OP_MAIN_COLLAPSE_THREAD:
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
+      if (CURHDR->collapsed) {
+        menu->current = mutt_uncollapse_thread (Context, CURHDR);
+        mutt_set_virtual (Context);
+        if (option (OPTUNCOLLAPSEJUMP))
+          menu->current = mutt_thread_next_unread (Context, CURHDR);
+      }
+      else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) {
+        menu->current = mutt_collapse_thread (Context, CURHDR);
+        mutt_set_virtual (Context);
+      }
+      else {
+        mutt_error (_("Thread contains unread messages."));
+
+        break;
+      }
+
+      menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+
+      break;
+
+    case OP_MAIN_COLLAPSE_ALL:
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+
+      if ((Sort & SORT_MASK) != SORT_THREADS) {
+        mutt_error (_("Threading is not enabled."));
+
+        break;
+      }
+
+      {
+        HEADER *h, *base;
+        THREAD *thread, *top;
+        int final;
 
-        if ((Sort & SORT_MASK) != SORT_THREADS)
-        {
-          mutt_error _("Threading is not enabled.");
-          break;
-        }
-      
         if (CURHDR->collapsed)
-        {
-          menu->current = mutt_uncollapse_thread (Context, CURHDR);
-          mutt_set_virtual (Context);
-          if (option (OPTUNCOLLAPSEJUMP))
-            menu->current = mutt_thread_next_unread (Context, CURHDR);
-        }
+          final = mutt_uncollapse_thread (Context, CURHDR);
         else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
-        {
-          menu->current = mutt_collapse_thread (Context, CURHDR);
-          mutt_set_virtual (Context);
-        }
+          final = mutt_collapse_thread (Context, CURHDR);
         else
-        {
-          mutt_error _("Thread contains unread messages.");
-          break;
-        }
+          final = CURHDR->virtual;
 
-        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-
-       break;
-
-      case OP_MAIN_COLLAPSE_ALL:
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
+        base = Context->hdrs[Context->v2r[final]];
 
-        if ((Sort & SORT_MASK) != SORT_THREADS)
-        {
-          mutt_error _("Threading is not enabled.");
-          break;
-        }
+        top = Context->tree;
+        Context->collapsed = !Context->collapsed;
+        while ((thread = top) != NULL) {
+          while (!thread->message)
+            thread = thread->child;
+          h = thread->message;
 
-        {
-          HEADER *h, *base;
-          THREAD *thread, *top;
-          int final;
-          
-          if (CURHDR->collapsed)
-            final = mutt_uncollapse_thread (Context, CURHDR);
-          else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR))
-            final = mutt_collapse_thread (Context, CURHDR);
-          else
-            final = CURHDR->virtual;
-          
-          base = Context->hdrs[Context->v2r[final]];
-          
-          top = Context->tree;
-          Context->collapsed = !Context->collapsed;
-          while ((thread = top) != NULL)
-          {
-            while (!thread->message)
-              thread = thread->child;
-            h = thread->message;
-
-            if (h->collapsed != Context->collapsed)
-            {
-              if (h->collapsed)
-                mutt_uncollapse_thread (Context, h);
-              else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
-                mutt_collapse_thread (Context, h);
-            }
-            top = top->next;
+          if (h->collapsed != Context->collapsed) {
+            if (h->collapsed)
+              mutt_uncollapse_thread (Context, h);
+            else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h))
+              mutt_collapse_thread (Context, h);
           }
-          
-          mutt_set_virtual (Context);
-          for (j = 0; j < Context->vcount; j++)
-          {
-            if (Context->hdrs[Context->v2r[j]]->index == base->index)
-            {
-              menu->current = j;
-              break;
-            }
+          top = top->next;
+        }
+
+        mutt_set_virtual (Context);
+        for (j = 0; j < Context->vcount; j++) {
+          if (Context->hdrs[Context->v2r[j]]->index == base->index) {
+            menu->current = j;
+            break;
           }
-          
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
         }
-        break;
-      
+
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
+
       /* --------------------------------------------------------------------
        * These functions are invoked directly from the internal-pager
        */
 
-      case OP_BOUNCE_MESSAGE:
+    case OP_BOUNCE_MESSAGE:
 
-        CHECK_ATTACH;
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
-        break;
+      CHECK_ATTACH;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw);
+      break;
 
-      case OP_CREATE_ALIAS:
+    case OP_CREATE_ALIAS:
 
-        mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL);
-        MAYBE_REDRAW (menu->redraw);
-        menu->redraw |= REDRAW_CURRENT;
-        break;
+      mutt_create_alias (Context
+                         && Context->vcount ? CURHDR->env : NULL, NULL);
+      MAYBE_REDRAW (menu->redraw);
+      menu->redraw |= REDRAW_CURRENT;
+      break;
 
-      case OP_QUERY:
-        CHECK_ATTACH;
-        mutt_query_menu (NULL, 0);
-        MAYBE_REDRAW (menu->redraw);
-        break;
+    case OP_QUERY:
+      CHECK_ATTACH;
+      mutt_query_menu (NULL, 0);
+      MAYBE_REDRAW (menu->redraw);
+      break;
 
-      case OP_PURGE_MESSAGE:
-      case OP_DELETE:
+    case OP_PURGE_MESSAGE:
+    case OP_DELETE:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
-        
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-        if (tag)
-        {
-          mutt_tag_set_flag (M_DELETE, 1);
-          mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
-          if (option (OPTDELETEUNTAG))
-            mutt_tag_set_flag (M_TAG, 0);
-          menu->redraw = REDRAW_INDEX;
-        }
-        else
-        {
-          mutt_set_flag (Context, CURHDR, M_DELETE, 1);
-          mutt_set_flag (Context, CURHDR, M_PURGED,
-                         (op != OP_PURGE_MESSAGE) ? 0 : 1);
-          if (option (OPTDELETEUNTAG))
-            mutt_set_flag (Context, CURHDR, M_TAG, 0);
-          if (option (OPTRESOLVE))
-          {
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-            {
-              menu->current = menu->oldcurrent;
-              menu->redraw = REDRAW_CURRENT;
-            }
-            else if (menu->menu == MENU_PAGER)
-            {
-              op = OP_DISPLAY_MESSAGE;
-              continue;
-            }
-            else
-              menu->redraw |= REDRAW_MOTION_RESYNCH;
+      if (tag) {
+        mutt_tag_set_flag (M_DELETE, 1);
+        mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
+        if (option (OPTDELETEUNTAG))
+          mutt_tag_set_flag (M_TAG, 0);
+        menu->redraw = REDRAW_INDEX;
+      }
+      else {
+        mutt_set_flag (Context, CURHDR, M_DELETE, 1);
+        mutt_set_flag (Context, CURHDR, M_PURGED,
+                       (op != OP_PURGE_MESSAGE) ? 0 : 1);
+        if (option (OPTDELETEUNTAG))
+          mutt_set_flag (Context, CURHDR, M_TAG, 0);
+        if (option (OPTRESOLVE)) {
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1) {
+            menu->current = menu->oldcurrent;
+            menu->redraw = REDRAW_CURRENT;
+          }
+          else if (menu->menu == MENU_PAGER) {
+            op = OP_DISPLAY_MESSAGE;
+            continue;
           }
           else
-            menu->redraw = REDRAW_CURRENT;
+            menu->redraw |= REDRAW_MOTION_RESYNCH;
         }
-        menu->redraw |= REDRAW_STATUS;
-        break;
+        else
+          menu->redraw = REDRAW_CURRENT;
+      }
+      menu->redraw |= REDRAW_STATUS;
+      break;
 
-      case OP_DELETE_THREAD:
-      case OP_DELETE_SUBTHREAD:
+    case OP_DELETE_THREAD:
+    case OP_DELETE_SUBTHREAD:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-        rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
-                                   op == OP_DELETE_THREAD ? 0 : 1);
+      rc = mutt_thread_set_flag (CURHDR, M_DELETE, 1,
+                                 op == OP_DELETE_THREAD ? 0 : 1);
 
-        if (rc != -1)
-        {
-          if (option (OPTDELETEUNTAG))
-            mutt_thread_set_flag (CURHDR, M_TAG, 0, 
-                                  op == OP_DELETE_THREAD ? 0 : 1);
-          if (option (OPTRESOLVE))
-            if ((menu->current = ci_next_undeleted (menu->current)) == -1)
-              menu->current = menu->oldcurrent;
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        }
-        break;
+      if (rc != -1) {
+        if (option (OPTDELETEUNTAG))
+          mutt_thread_set_flag (CURHDR, M_TAG, 0,
+                                op == OP_DELETE_THREAD ? 0 : 1);
+        if (option (OPTRESOLVE))
+          if ((menu->current = ci_next_undeleted (menu->current)) == -1)
+            menu->current = menu->oldcurrent;
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
 
 #ifdef USE_NNTP
-      case OP_CATCHUP:
-        if (Context && Context->magic == M_NNTP)
-        {
-          if (mutt_newsgroup_catchup (CurrentNewsSrv,
-                ((NNTP_DATA *)Context->data)->group))
-            menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        }
-        break;
+    case OP_CATCHUP:
+      if (Context && Context->magic == M_NNTP) {
+        if (mutt_newsgroup_catchup (CurrentNewsSrv,
+                                    ((NNTP_DATA *) Context->data)->group))
+          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
 #endif
 
-      case OP_DISPLAY_ADDRESS:
+    case OP_DISPLAY_ADDRESS:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        mutt_display_address (CURHDR->env);
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      mutt_display_address (CURHDR->env);
+      break;
 
-      case OP_ENTER_COMMAND:
+    case OP_ENTER_COMMAND:
 
-        CurrentMenu = MENU_MAIN;
-        mutt_enter_command ();
-        mutt_check_rescore (Context);
-        if (option (OPTFORCEREDRAWINDEX))
-          menu->redraw = REDRAW_FULL;
-        unset_option (OPTFORCEREDRAWINDEX);
-        unset_option (OPTFORCEREDRAWPAGER);
-        break;
+      CurrentMenu = MENU_MAIN;
+      mutt_enter_command ();
+      mutt_check_rescore (Context);
+      if (option (OPTFORCEREDRAWINDEX))
+        menu->redraw = REDRAW_FULL;
+      unset_option (OPTFORCEREDRAWINDEX);
+      unset_option (OPTFORCEREDRAWPAGER);
+      break;
 
-      case OP_EDIT_MESSAGE:
+    case OP_EDIT_MESSAGE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
-        CHECK_ATTACH;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
+      CHECK_ATTACH;
 
 #ifdef USE_POP
-        if (Context->magic == M_POP)
-        {
-          mutt_flushinp ();
-          mutt_error _("Can't edit message on POP server.");
-          break;
-        }
+      if (Context->magic == M_POP) {
+        mutt_flushinp ();
+        mutt_error (_("Can't edit message on POP server."));
+
+        break;
+      }
 #endif
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_INSERT);
+      CHECK_IMAP_ACL (IMAP_ACL_INSERT);
 #endif
 
 #ifdef USE_NNTP
-        if (Context->magic == M_NNTP)
-        {
-          mutt_flushinp ();
-          mutt_error _("Can't edit message on newsserver.");
-          break;
-        }
+      if (Context->magic == M_NNTP) {
+        mutt_flushinp ();
+        mutt_error (_("Can't edit message on newsserver."));
+
+        break;
+      }
 #endif
 
-       if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) 
-         mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
-        mutt_edit_message (Context, tag ? NULL : CURHDR);
-        menu->redraw = REDRAW_FULL;
+      if (option (OPTPGPAUTODEC)
+          && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
+        mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
+      mutt_edit_message (Context, tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
 
-        break;
+      break;
 
-      case OP_FORWARD_MESSAGE:
+    case OP_FORWARD_MESSAGE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_ATTACH;
-        ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_ATTACH;
+      ci_send_message (SENDFORWARD, NULL, NULL, Context, tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
+      break;
 
 
-      case OP_FORGET_PASSPHRASE:
-        crypt_forget_passphrase ();
-        break;
+    case OP_FORGET_PASSPHRASE:
+      crypt_forget_passphrase ();
+      break;
 
-      case OP_GROUP_REPLY:
+    case OP_GROUP_REPLY:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_ATTACH;
-        ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_ATTACH;
+      ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, Context,
+                       tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_LIST_REPLY:
+    case OP_LIST_REPLY:
 
-        CHECK_ATTACH;
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_ATTACH;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, Context,
+                       tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_MAIL:
+    case OP_MAIL:
 
-        CHECK_ATTACH;
-        ci_send_message (0, NULL, NULL, Context, NULL);
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_ATTACH;
+      ci_send_message (0, NULL, NULL, Context, NULL);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_MAIL_KEY:
-        if (!(WithCrypto & APPLICATION_PGP))
-          break;
-        CHECK_ATTACH;
-        ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
-        menu->redraw = REDRAW_FULL;
+    case OP_MAIL_KEY:
+      if (!(WithCrypto & APPLICATION_PGP))
         break;
+      CHECK_ATTACH;
+      ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      
-      case OP_EXTRACT_KEYS:
-        if (!WithCrypto)
-          break;
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
-        menu->redraw = REDRAW_FULL;
+
+    case OP_EXTRACT_KEYS:
+      if (!WithCrypto)
         break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      crypt_extract_keys_from_messages (tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
+      break;
 
 
-      case OP_CHECK_TRADITIONAL:
-        if (!(WithCrypto & APPLICATION_PGP))
-          break;
-        CHECK_MSGCOUNT; 
-        CHECK_VISIBLE;
-        if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) 
-         mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
-      
-        if (menu->menu == MENU_PAGER)
-        {
-          op = OP_DISPLAY_MESSAGE;
-          continue;
-        }
+    case OP_CHECK_TRADITIONAL:
+      if (!(WithCrypto & APPLICATION_PGP))
         break;
-      
-      case OP_PIPE:
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))
+        mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        mutt_pipe_message (tag ? NULL : CURHDR);
-        MAYBE_REDRAW (menu->redraw);
-        break;
+      if (menu->menu == MENU_PAGER) {
+        op = OP_DISPLAY_MESSAGE;
+        continue;
+      }
+      break;
 
-      case OP_PRINT:
+    case OP_PIPE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        mutt_print_message (tag ? NULL : CURHDR);
-        break;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      mutt_pipe_message (tag ? NULL : CURHDR);
+      MAYBE_REDRAW (menu->redraw);
+      break;
 
-      case OP_MAIN_READ_THREAD:
-      case OP_MAIN_READ_SUBTHREAD:
+    case OP_PRINT:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      mutt_print_message (tag ? NULL : CURHDR);
+      break;
+
+    case OP_MAIN_READ_THREAD:
+    case OP_MAIN_READ_SUBTHREAD:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
+      CHECK_IMAP_ACL (IMAP_ACL_SEEN);
 #endif
 
-        rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
-                                   op == OP_MAIN_READ_THREAD ? 0 : 1);
+      rc = mutt_thread_set_flag (CURHDR, M_READ, 1,
+                                 op == OP_MAIN_READ_THREAD ? 0 : 1);
 
-        if (rc != -1)
-        {
-          if (option (OPTRESOLVE))
-          {
-            if ((menu->current = (op == OP_MAIN_READ_THREAD ? 
-                                  mutt_next_thread (CURHDR) : mutt_next_subthread (CURHDR))) == -1)
-              menu->current = menu->oldcurrent;
-          }
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      if (rc != -1) {
+        if (option (OPTRESOLVE)) {
+          if ((menu->current = (op == OP_MAIN_READ_THREAD ?
+                                mutt_next_thread (CURHDR) :
+                                mutt_next_subthread (CURHDR))) == -1)
+            menu->current = menu->oldcurrent;
         }
-        break;
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
 
-      case OP_RECALL_MESSAGE:
+    case OP_RECALL_MESSAGE:
 
-        CHECK_ATTACH;
-        ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
-        menu->redraw = REDRAW_FULL;
-        break;
+      CHECK_ATTACH;
+      ci_send_message (SENDPOSTPONED, NULL, NULL, Context, NULL);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_RESEND:
-      
-        CHECK_ATTACH;
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-      
-        if (tag)
-        {
-          for (j = 0; j < Context->vcount; j++)
-          {
-            if (Context->hdrs[Context->v2r[j]]->tagged)
-              mutt_resend_message (NULL, Context, Context->hdrs[Context->v2r[j]]);
-          }
+    case OP_RESEND:
+
+      CHECK_ATTACH;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+
+      if (tag) {
+        for (j = 0; j < Context->vcount; j++) {
+          if (Context->hdrs[Context->v2r[j]]->tagged)
+            mutt_resend_message (NULL, Context,
+                                 Context->hdrs[Context->v2r[j]]);
         }
-        else
-          mutt_resend_message (NULL, Context, CURHDR);
-      
-        menu->redraw = REDRAW_FULL;
-        break;
+      }
+      else
+        mutt_resend_message (NULL, Context, CURHDR);
+
+      menu->redraw = REDRAW_FULL;
+      break;
 
 #ifdef USE_NNTP
-      case OP_POST:
-      case OP_FOLLOWUP:
-      case OP_FORWARD_TO_GROUP:
-
-        CHECK_ATTACH;
-        if ((op == OP_FOLLOWUP || op == OP_FORWARD_TO_GROUP) &&
-            Context && Context->msgcount == 0) {
-          mutt_error (_("There are no messages."));
-          sleep (2);
-        } else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
-            mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
-            query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
-        {
-          if (Context && Context->magic == M_NNTP &&
-              !((NNTP_DATA *)Context->data)->allowed &&
-              query_quadoption (OPT_TOMODERATED, _("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
-            break;
-          if (op == OP_POST)
-            ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
-          else
-          {
-            CHECK_MSGCOUNT;
-            if (op == OP_FOLLOWUP)
-              ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, Context,
-                               tag ? NULL : CURHDR);
-            else
-              ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, Context,
-                               tag ? NULL : CURHDR);
-          }
-          menu->redraw = REDRAW_FULL;
+    case OP_POST:
+    case OP_FOLLOWUP:
+    case OP_FORWARD_TO_GROUP:
+
+      CHECK_ATTACH;
+      if ((op == OP_FOLLOWUP || op == OP_FORWARD_TO_GROUP) &&
+          Context && Context->msgcount == 0) {
+        mutt_error (_("There are no messages."));
+        sleep (2);
+      }
+      else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to ||
+               mutt_strcasecmp (CURHDR->env->followup_to, "poster") ||
+               query_quadoption (OPT_FOLLOWUPTOPOSTER,
+                                 _("Reply by mail as poster prefers?")) !=
+               M_YES) {
+        if (Context && Context->magic == M_NNTP
+            && !((NNTP_DATA *) Context->data)->allowed
+            && query_quadoption (OPT_TOMODERATED,
+                                 _
+                                 ("Posting to this group not allowed, may be moderated. Continue?"))
+            != M_YES)
           break;
+        if (op == OP_POST)
+          ci_send_message (SENDNEWS, NULL, NULL, Context, NULL);
+        else {
+          CHECK_MSGCOUNT;
+          if (op == OP_FOLLOWUP)
+            ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL, Context,
+                             tag ? NULL : CURHDR);
+          else
+            ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, Context,
+                             tag ? NULL : CURHDR);
         }
-#endif
-      
-      case OP_REPLY:
-
-        CHECK_ATTACH;
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
         menu->redraw = REDRAW_FULL;
         break;
+      }
+#endif
 
-      case OP_SHELL_ESCAPE:
+    case OP_REPLY:
 
-        mutt_shell_escape ();
-        MAYBE_REDRAW (menu->redraw);
-        break;
+      CHECK_ATTACH;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_TAG_THREAD:
-      case OP_TAG_SUBTHREAD:
+    case OP_SHELL_ESCAPE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
-                                   op == OP_TAG_THREAD ? 0 : 1);
-        
-        if (rc != -1)
-        {
-          if (option (OPTRESOLVE))
-          {
-            menu->current = mutt_next_thread (CURHDR);
+      mutt_shell_escape ();
+      MAYBE_REDRAW (menu->redraw);
+      break;
 
-            if (menu->current == -1)
-              menu->current = menu->oldcurrent;
-          }
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+    case OP_TAG_THREAD:
+    case OP_TAG_SUBTHREAD:
+
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      rc = mutt_thread_set_flag (CURHDR, M_TAG, !CURHDR->tagged,
+                                 op == OP_TAG_THREAD ? 0 : 1);
+
+      if (rc != -1) {
+        if (option (OPTRESOLVE)) {
+          menu->current = mutt_next_thread (CURHDR);
+
+          if (menu->current == -1)
+            menu->current = menu->oldcurrent;
         }
-        break;
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
 
-      case OP_UNDELETE:
+    case OP_UNDELETE:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
-        
-        if (tag)
-        {
-          mutt_tag_set_flag (M_DELETE, 0);
-          mutt_tag_set_flag (M_PURGED, 0);
-          menu->redraw = REDRAW_INDEX;
+
+      if (tag) {
+        mutt_tag_set_flag (M_DELETE, 0);
+        mutt_tag_set_flag (M_PURGED, 0);
+        menu->redraw = REDRAW_INDEX;
+      }
+      else {
+        mutt_set_flag (Context, CURHDR, M_DELETE, 0);
+        mutt_set_flag (Context, CURHDR, M_PURGED, 0);
+        if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) {
+          menu->current++;
+          menu->redraw = REDRAW_MOTION_RESYNCH;
         }
         else
-        {
-          mutt_set_flag (Context, CURHDR, M_DELETE, 0);
-          mutt_set_flag (Context, CURHDR, M_PURGED, 0);
-          if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
-          {
-            menu->current++;
-            menu->redraw = REDRAW_MOTION_RESYNCH;
-          }
-          else
-            menu->redraw = REDRAW_CURRENT;
-        }
-        menu->redraw |= REDRAW_STATUS;
-        break;
+          menu->redraw = REDRAW_CURRENT;
+      }
+      menu->redraw |= REDRAW_STATUS;
+      break;
 
-      case OP_UNDELETE_THREAD:
-      case OP_UNDELETE_SUBTHREAD:
+    case OP_UNDELETE_THREAD:
+    case OP_UNDELETE_SUBTHREAD:
 
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        CHECK_READONLY;
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-        rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
-                                   op == OP_UNDELETE_THREAD ? 0 : 1)
-          + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
-                                  op == OP_UNDELETE_THREAD ? 0 : 1);
+      rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
+                                 op == OP_UNDELETE_THREAD ? 0 : 1)
+        + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
+                                op == OP_UNDELETE_THREAD ? 0 : 1);
 
-        if (rc > -1)
-        {
-          if (option (OPTRESOLVE))
-          {
-            if (op == OP_UNDELETE_THREAD)
-              menu->current = mutt_next_thread (CURHDR);
-            else
-              menu->current = mutt_next_subthread (CURHDR);
+      if (rc > -1) {
+        if (option (OPTRESOLVE)) {
+          if (op == OP_UNDELETE_THREAD)
+            menu->current = mutt_next_thread (CURHDR);
+          else
+            menu->current = mutt_next_subthread (CURHDR);
 
-            if (menu->current == -1)
-              menu->current = menu->oldcurrent;
-          }
-          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+          if (menu->current == -1)
+            menu->current = menu->oldcurrent;
         }
-        break;
+        menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+      }
+      break;
 
-      case OP_VERSION:
-        mutt_version ();
-        break;
+    case OP_VERSION:
+      mutt_version ();
+      break;
 
-      case OP_BUFFY_LIST:
-        mutt_buffy_list ();
-        menu->redraw = REDRAW_FULL;
-        break;
+    case OP_BUFFY_LIST:
+      mutt_buffy_list ();
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_VIEW_ATTACHMENTS:
-        CHECK_MSGCOUNT;
-        CHECK_VISIBLE;
-        mutt_view_attachments (CURHDR);
-        if (CURHDR->attach_del)
-          Context->changed = 1;
-        menu->redraw = REDRAW_FULL;
-        break;
+    case OP_VIEW_ATTACHMENTS:
+      CHECK_MSGCOUNT;
+      CHECK_VISIBLE;
+      mutt_view_attachments (CURHDR);
+      if (CURHDR->attach_del)
+        Context->changed = 1;
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_END_COND:
-        break;
+    case OP_END_COND:
+      break;
 
-      case OP_WHAT_KEY:
-        mutt_what_key();
-        break;
+    case OP_WHAT_KEY:
+      mutt_what_key ();
+      break;
 
-      case OP_SIDEBAR_SCROLL_UP:
-      case OP_SIDEBAR_SCROLL_DOWN:
-      case OP_SIDEBAR_NEXT:
-      case OP_SIDEBAR_PREV:
-      case OP_SIDEBAR_NEXT_NEW:
-      case OP_SIDEBAR_PREV_NEW:
-        scroll_sidebar(op, menu->menu);
-            break;
-      default:
-        if (menu->menu == MENU_MAIN)
-          km_error_key (MENU_MAIN);
+    case OP_SIDEBAR_SCROLL_UP:
+    case OP_SIDEBAR_SCROLL_DOWN:
+    case OP_SIDEBAR_NEXT:
+    case OP_SIDEBAR_PREV:
+    case OP_SIDEBAR_NEXT_NEW:
+    case OP_SIDEBAR_PREV_NEW:
+      scroll_sidebar (op, menu->menu);
+      break;
+    default:
+      if (menu->menu == MENU_MAIN)
+        km_error_key (MENU_MAIN);
     }
 
-    if (menu->menu == MENU_PAGER)
-    {
+    if (menu->menu == MENU_PAGER) {
       menu->menu = MENU_MAIN;
       menu->redraw = REDRAW_FULL;
 #if 0
-      set_option (OPTWEED); /* turn header weeding back on. */
+      set_option (OPTWEED);     /* turn header weeding back on. */
 #endif
     }
 
-    if (done) break;
+    if (done)
+      break;
   }
 
 #ifdef USE_IMAP
@@ -2517,18 +2414,18 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
   return (close);
 }
 
-void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
+void mutt_set_header_color (CONTEXT * ctx, HEADER * curhdr)
 {
   COLOR_LINE *color;
 
   if (!curhdr)
     return;
-  
+
   for (color = ColorIndexList; color; color = color->next)
-   if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr))
-   {
+    if (mutt_pattern_exec
+        (color->color_pattern, M_MATCH_FULL_ADDRESS, ctx, curhdr)) {
       curhdr->pair = color->pair;
       return;
-   }
+    }
   curhdr->pair = ColorDefs[MT_COLOR_NORMAL];
 }
diff --git a/date.c b/date.c
index b97b113..f9a2075 100644 (file)
--- a/date.c
+++ b/date.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -33,11 +33,10 @@ static time_t compute_tz (time_t g, struct tm *utc)
 
   t = (((lt->tm_hour - utc->tm_hour) * 60) + (lt->tm_min - utc->tm_min)) * 60;
 
-  if ((yday = (lt->tm_yday - utc->tm_yday)))
-  {
+  if ((yday = (lt->tm_yday - utc->tm_yday))) {
     /* This code is optimized to negative timezones (West of Greenwich) */
-    if (yday == -1 ||  /* UTC passed midnight before localtime */
-       yday > 1)       /* UTC passed new year before localtime */
+    if (yday == -1 ||           /* UTC passed midnight before localtime */
+        yday > 1)               /* UTC passed new year before localtime */
       t -= 24 * 60 * 60;
     else
       t += 24 * 60 * 60;
@@ -65,7 +64,7 @@ time_t mutt_local_tz (time_t t)
 
 /* converts struct tm to time_t, but does not take the local timezone into
    account unless ``local'' is nonzero */
-time_t mutt_mktime (struct tm *t, int local)
+time_t mutt_mktime (struct tm * t, int local)
 {
   time_t g;
 
@@ -74,7 +73,7 @@ time_t mutt_mktime (struct tm *t, int local)
   };
 
   /* Compute the number of days since January 1 in the same year */
-  g = AccumDaysPerMonth [t->tm_mon % 12];
+  g = AccumDaysPerMonth[t->tm_mon % 12];
 
   /* The leap years are 1972 and every 4. year until 2096,
    * but this algoritm will fail after year 2099 */
@@ -108,9 +107,9 @@ time_t mutt_mktime (struct tm *t, int local)
 /* Return 1 if month is February of leap year, else 0 */
 static int isLeapYearFeb (struct tm *tm)
 {
-  if (tm->tm_mon == 1)
-  {
+  if (tm->tm_mon == 1) {
     int y = tm->tm_year + 1900;
+
     return (((y & 3) == 0) && (((y % 100) != 0) || ((y % 400) == 0)));
   }
   return (0);
@@ -123,66 +122,54 @@ void mutt_normalize_time (struct tm *tm)
   };
   int nLeap;
 
-  while (tm->tm_sec < 0)
-  {
+  while (tm->tm_sec < 0) {
     tm->tm_sec += 60;
     tm->tm_min--;
   }
-  while (tm->tm_sec >= 60)
-  {
+  while (tm->tm_sec >= 60) {
     tm->tm_sec -= 60;
     tm->tm_min++;
   }
-  while (tm->tm_min < 0)
-  {
+  while (tm->tm_min < 0) {
     tm->tm_min += 60;
     tm->tm_hour--;
   }
-  while (tm->tm_min >= 60)
-  {
+  while (tm->tm_min >= 60) {
     tm->tm_min -= 60;
     tm->tm_hour++;
   }
-  while (tm->tm_hour < 0)
-  {
+  while (tm->tm_hour < 0) {
     tm->tm_hour += 24;
     tm->tm_mday--;
   }
-  while (tm->tm_hour >= 24)
-  {
+  while (tm->tm_hour >= 24) {
     tm->tm_hour -= 24;
     tm->tm_mday++;
   }
   /* use loops on NNNdwmy user input values? */
-  while (tm->tm_mon < 0)
-  {
+  while (tm->tm_mon < 0) {
     tm->tm_mon += 12;
     tm->tm_year--;
   }
-  while (tm->tm_mon >= 12)
-  {
+  while (tm->tm_mon >= 12) {
     tm->tm_mon -= 12;
     tm->tm_year++;
   }
-  while (tm->tm_mday <= 0)
-  {
+  while (tm->tm_mday <= 0) {
     if (tm->tm_mon)
       tm->tm_mon--;
-    else
-    {
+    else {
       tm->tm_mon = 11;
       tm->tm_year--;
     }
     tm->tm_mday += DaysPerMonth[tm->tm_mon] + isLeapYearFeb (tm);
   }
-  while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] + 
-       (nLeap = isLeapYearFeb (tm))))
-  {
+  while (tm->tm_mday > (DaysPerMonth[tm->tm_mon] +
+                        (nLeap = isLeapYearFeb (tm)))) {
     tm->tm_mday -= DaysPerMonth[tm->tm_mon] + nLeap;
     if (tm->tm_mon < 11)
       tm->tm_mon++;
-    else
-    {
+    else {
       tm->tm_mon = 0;
       tm->tm_year++;
     }
index 008c1c6..eb4ba30 100644 (file)
--- a/dotlock.c
+++ b/dotlock.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * This module either be compiled into Mutt, or it can be
@@ -57,7 +57,7 @@
 # include "reldate.h"
 #endif
 
-#define MAXLINKS 1024 /* maximum link depth */
+#define MAXLINKS 1024           /* maximum link depth */
 
 #ifdef DL_STANDALONE
 
@@ -83,7 +83,7 @@
 extern int snprintf (char *, size_t, const char *, ...);
 # endif
 
-#else  /* DL_STANDALONE */
+#else /* DL_STANDALONE */
 
 # ifdef USE_SETGID
 #   error Do not try to compile dotlock as a mutt module when requiring egid switching!
@@ -142,15 +142,15 @@ int main (int argc, char **argv)
   struct utsname utsname;
 
   /* first, drop privileges */
-  
+
   if (dotlock_init_privs () == -1)
     return DL_EX_ERROR;
 
 
   /* determine the system's host name */
-  
+
   uname (&utsname);
-  if (!(Hostname = strdup (utsname.nodename))) /* __MEM_CHECKED__ */
+  if (!(Hostname = strdup (utsname.nodename)))  /* __MEM_CHECKED__ */
     return DL_EX_ERROR;
   if ((p = strchr (Hostname, '.')))
     *p = '\0';
@@ -158,22 +158,37 @@ int main (int argc, char **argv)
 
   /* parse the command line options. */
   DotlockFlags = 0;
-  
-  while ((i = getopt (argc, argv, "dtfupr:")) != EOF)
-  {
-    switch (i)
-    {
+
+  while ((i = getopt (argc, argv, "dtfupr:")) != EOF) {
+    switch (i) {
       /* actions, mutually exclusive */
-      case 't': check_flags (DotlockFlags); DotlockFlags |= DL_FL_TRY; break;
-      case 'd': check_flags (DotlockFlags); DotlockFlags |= DL_FL_UNLINK; break;
-      case 'u': check_flags (DotlockFlags); DotlockFlags |= DL_FL_UNLOCK; break;
+    case 't':
+      check_flags (DotlockFlags);
+      DotlockFlags |= DL_FL_TRY;
+      break;
+    case 'd':
+      check_flags (DotlockFlags);
+      DotlockFlags |= DL_FL_UNLINK;
+      break;
+    case 'u':
+      check_flags (DotlockFlags);
+      DotlockFlags |= DL_FL_UNLOCK;
+      break;
 
       /* other flags */
-      case 'f': DotlockFlags |= DL_FL_FORCE; break;
-      case 'p': DotlockFlags |= DL_FL_USEPRIV; break;
-      case 'r': DotlockFlags |= DL_FL_RETRY; Retry = atoi (optarg); break;
-      
-      default: usage (argv[0]);
+    case 'f':
+      DotlockFlags |= DL_FL_FORCE;
+      break;
+    case 'p':
+      DotlockFlags |= DL_FL_USEPRIV;
+      break;
+    case 'r':
+      DotlockFlags |= DL_FL_RETRY;
+      Retry = atoi (optarg);
+      break;
+
+    default:
+      usage (argv[0]);
     }
   }
 
@@ -196,12 +211,11 @@ int main (int argc, char **argv)
  */
 
 
-static int
-dotlock_init_privs (void)
+static int dotlock_init_privs (void)
 {
 
 # ifdef USE_SETGID
-  
+
   UserGid = getgid ();
   MailGid = getegid ();
 
@@ -212,9 +226,9 @@ dotlock_init_privs (void)
 
   return 0;
 }
-  
 
-#else  /* DL_STANDALONE */
+
+#else /* DL_STANDALONE */
 
 /* 
  * This function is intended to be invoked from within
@@ -227,7 +241,7 @@ int dotlock_invoke (const char *path, int fd, int flags, int retry)
   int r;
 
   DotlockFlags = flags;
-  
+
   if ((currdir = open (".", O_RDONLY)) == -1)
     return DL_EX_ERROR;
 
@@ -235,16 +249,16 @@ int dotlock_invoke (const char *path, int fd, int flags, int retry)
     Retry = MAXLOCKATTEMPT;
   else
     Retry = 0;
-  
+
   r = dotlock_dispatch (path, fd);
-  
+
   fchdir (currdir);
   close (currdir);
-  
+
   return r;
 }
 
-#endif  /* DL_STANDALONE */
+#endif /* DL_STANDALONE */
 
 
 static int dotlock_dispatch (const char *f, int fd)
@@ -273,11 +287,11 @@ static int dotlock_dispatch (const char *f, int fd)
     return dotlock_unlock (realpath);
   else if (DotlockFlags & DL_FL_UNLINK)
     return dotlock_unlink (realpath);
-  else /* lock */
+  else                          /* lock */
     return dotlock_lock (realpath);
 }
 
-  
+
 /*
  * Get privileges 
  * 
@@ -289,14 +303,11 @@ static int dotlock_dispatch (const char *f, int fd)
  * 
  */
 
-static void
-BEGIN_PRIVILEGED (void)
+static void BEGIN_PRIVILEGED (void)
 {
 #ifdef USE_SETGID
-  if (DotlockFlags & DL_FL_USEPRIV)
-  {
-    if (SETEGID (MailGid) != 0)
-    {
+  if (DotlockFlags & DL_FL_USEPRIV) {
+    if (SETEGID (MailGid) != 0) {
       /* perror ("setegid"); */
       exit (DL_EX_ERROR);
     }
@@ -313,14 +324,11 @@ BEGIN_PRIVILEGED (void)
  *
  */
 
-static void
-END_PRIVILEGED (void)
+static void END_PRIVILEGED (void)
 {
 #ifdef USE_SETGID
-  if (DotlockFlags & DL_FL_USEPRIV)
-  {
-    if (SETEGID (UserGid) != 0)
-    {
+  if (DotlockFlags & DL_FL_USEPRIV) {
+    if (SETEGID (UserGid) != 0) {
       /* perror ("setegid"); */
       exit (DL_EX_ERROR);
     }
@@ -337,25 +345,20 @@ END_PRIVILEGED (void)
  * 
  */
 
-static void 
-usage (const char *av0)
+static void usage (const char *av0)
 {
   fprintf (stderr, "dotlock [Mutt-ng %s (%s)]\n", VERSION, ReleaseDate);
-  fprintf (stderr, "usage: %s [-t|-f|-u|-d] [-p] [-r <retries>] file\n",
-         av0);
+  fprintf (stderr, "usage: %s [-t|-f|-u|-d] [-p] [-r <retries>] file\n", av0);
 
   fputs ("\noptions:"
-       "\n  -t\t\ttry"
-       "\n  -f\t\tforce"
-       "\n  -u\t\tunlock"
-       "\n  -d\t\tunlink"
-       "\n  -p\t\tprivileged"
+         "\n  -t\t\ttry"
+         "\n  -f\t\tforce"
+         "\n  -u\t\tunlock" "\n  -d\t\tunlink" "\n  -p\t\tprivileged"
 #ifndef USE_SETGID
-       " (ignored)"
+         " (ignored)"
 #endif
-       "\n  -r <retries>\tRetry locking"
-       "\n", stderr);
-  
+         "\n  -r <retries>\tRetry locking" "\n", stderr);
+
   exit (DL_EX_ERROR);
 }
 
@@ -409,8 +412,7 @@ usage (const char *av0)
  * tlr, Jul 15 1998
  */
 
-static int
-dotlock_check_stats (struct stat *fsb, struct stat *lsb)
+static int dotlock_check_stats (struct stat *fsb, struct stat *lsb)
 {
   /* S_ISLNK (fsb->st_mode) should actually be impossible,
    * but we may have mixed up the parameters somewhere.
@@ -419,25 +421,22 @@ dotlock_check_stats (struct stat *fsb, struct stat *lsb)
 
   if (S_ISLNK (lsb->st_mode) || S_ISLNK (fsb->st_mode))
     return -1;
-  
+
   if ((lsb->st_dev != fsb->st_dev) ||
-     (lsb->st_ino != fsb->st_ino) ||
-     (lsb->st_mode != fsb->st_mode) ||
-     (lsb->st_nlink != fsb->st_nlink) ||
-     (lsb->st_uid != fsb->st_uid) ||
-     (lsb->st_gid != fsb->st_gid) ||
-     (lsb->st_rdev != fsb->st_rdev) ||
-     (lsb->st_size != fsb->st_size))
-  {
+      (lsb->st_ino != fsb->st_ino) ||
+      (lsb->st_mode != fsb->st_mode) ||
+      (lsb->st_nlink != fsb->st_nlink) ||
+      (lsb->st_uid != fsb->st_uid) ||
+      (lsb->st_gid != fsb->st_gid) ||
+      (lsb->st_rdev != fsb->st_rdev) || (lsb->st_size != fsb->st_size)) {
     /* something's fishy */
     return -1;
   }
-  
+
   return 0;
 }
 
-static int
-dotlock_prepare (char *bn, size_t l, const char *f, int _fd)
+static int dotlock_prepare (char *bn, size_t l, const char *f, int _fd)
 {
   struct stat fsb, lsb;
   char realpath[_POSIX_PATH_MAX];
@@ -445,27 +444,25 @@ dotlock_prepare (char *bn, size_t l, const char *f, int _fd)
   char *p;
   int fd;
   int r;
-  
+
   if (dotlock_deference_symlink (realpath, sizeof (realpath), f) == -1)
     return -1;
-  
-  if ((p = strrchr (realpath, '/')))
-  {
+
+  if ((p = strrchr (realpath, '/'))) {
     *p = '\0';
     basename = p + 1;
     dirname = realpath;
   }
-  else
-  {
+  else {
     basename = realpath;
     dirname = ".";
   }
 
   if (strlen (basename) + 1 > l)
     return -1;
-  
+
   strfcpy (bn, basename, l);
-  
+
   if (chdir (dirname) == -1)
     return -1;
 
@@ -473,15 +470,15 @@ dotlock_prepare (char *bn, size_t l, const char *f, int _fd)
     fd = _fd;
   else if ((fd = open (basename, O_RDONLY)) == -1)
     return -1;
-  
+
   r = fstat (fd, &fsb);
-  
+
   if (_fd == -1)
     close (fd);
-  
+
   if (r == -1)
     return -1;
-  
+
   if (lstat (basename, &lsb) == -1)
     return -1;
 
@@ -499,21 +496,19 @@ dotlock_prepare (char *bn, size_t l, const char *f, int _fd)
  *
  */
 
-static void 
+static void
 dotlock_expand_link (char *newpath, const char *path, const char *link)
 {
   const char *lb = NULL;
   size_t len;
 
   /* link is full path */
-  if (*link == '/')
-  {
+  if (*link == '/') {
     strfcpy (newpath, link, _POSIX_PATH_MAX);
     return;
   }
 
-  if ((lb = strrchr (path, '/')) == NULL)
-  {
+  if ((lb = strrchr (path, '/')) == NULL) {
     /* no path in link */
     strfcpy (newpath, link, _POSIX_PATH_MAX);
     return;
@@ -532,34 +527,29 @@ dotlock_expand_link (char *newpath, const char *path, const char *link)
  *
  */
 
-static int
-dotlock_deference_symlink (char *d, size_t l, const char *path)
+static int dotlock_deference_symlink (char *d, size_t l, const char *path)
 {
   struct stat sb;
   char realpath[_POSIX_PATH_MAX];
   const char *pathptr = path;
   int count = 0;
-  
-  while (count++ < MAXLINKS)
-  {
-    if (lstat (pathptr, &sb) == -1)
-    {
+
+  while (count++ < MAXLINKS) {
+    if (lstat (pathptr, &sb) == -1) {
       /* perror (pathptr); */
       return -1;
     }
-    
-    if (S_ISLNK (sb.st_mode))
-    {
+
+    if (S_ISLNK (sb.st_mode)) {
       char linkfile[_POSIX_PATH_MAX];
       char linkpath[_POSIX_PATH_MAX];
       int len;
 
-      if ((len = readlink (pathptr, linkfile, sizeof (linkfile))) == -1)
-      {
-       /* perror (pathptr); */
-       return -1;
+      if ((len = readlink (pathptr, linkfile, sizeof (linkfile))) == -1) {
+        /* perror (pathptr); */
+        return -1;
       }
-      
+
       linkfile[len] = '\0';
       dotlock_expand_link (linkpath, pathptr, linkfile);
       strfcpy (realpath, linkpath, sizeof (realpath));
@@ -584,8 +574,7 @@ dotlock_deference_symlink (char *d, size_t l, const char *path)
 
 #define HARDMAXATTEMPTS 10
 
-static int
-dotlock_lock (const char *realpath)
+static int dotlock_lock (const char *realpath)
 {
   char lockfile[_POSIX_PATH_MAX + LONG_STRING];
   char nfslockfile[_POSIX_PATH_MAX + LONG_STRING];
@@ -595,45 +584,41 @@ dotlock_lock (const char *realpath)
   int hard_count = 0;
   struct stat sb;
   time_t t;
-  
+
   snprintf (nfslockfile, sizeof (nfslockfile), "%s.%s.%d",
-          realpath, Hostname, (int) getpid ());
+            realpath, Hostname, (int) getpid ());
   snprintf (lockfile, sizeof (lockfile), "%s.lock", realpath);
 
-  
+
   BEGIN_PRIVILEGED ();
 
   unlink (nfslockfile);
 
-  while ((fd = open (nfslockfile, O_WRONLY | O_EXCL | O_CREAT, 0)) < 0)
-  {
+  while ((fd = open (nfslockfile, O_WRONLY | O_EXCL | O_CREAT, 0)) < 0) {
     END_PRIVILEGED ();
 
-  
-    if (errno != EAGAIN)
-    {
+
+    if (errno != EAGAIN) {
       /* perror ("cannot open NFS lock file"); */
       return DL_EX_ERROR;
     }
 
-    
+
     BEGIN_PRIVILEGED ();
   }
 
   END_PRIVILEGED ();
 
-  
+
   close (fd);
-  
-  while (hard_count++ < HARDMAXATTEMPTS)
-  {
+
+  while (hard_count++ < HARDMAXATTEMPTS) {
 
     BEGIN_PRIVILEGED ();
     link (nfslockfile, lockfile);
     END_PRIVILEGED ();
 
-    if (stat (nfslockfile, &sb) != 0)
-    {
+    if (stat (nfslockfile, &sb) != 0) {
       /* perror ("stat"); */
       return DL_EX_ERROR;
     }
@@ -644,32 +629,29 @@ dotlock_lock (const char *realpath)
     if (count == 0)
       prev_size = sb.st_size;
 
-    if (prev_size == sb.st_size && ++count > Retry)
-    {
-      if (DotlockFlags & DL_FL_FORCE)
-      {
-       BEGIN_PRIVILEGED ();
-       unlink (lockfile);
-       END_PRIVILEGED ();
+    if (prev_size == sb.st_size && ++count > Retry) {
+      if (DotlockFlags & DL_FL_FORCE) {
+        BEGIN_PRIVILEGED ();
+        unlink (lockfile);
+        END_PRIVILEGED ();
 
-       count = 0;
-       continue;
+        count = 0;
+        continue;
       }
-      else
-      {
-       BEGIN_PRIVILEGED ();
-       unlink (nfslockfile);
-       END_PRIVILEGED ();
-       return DL_EX_EXIST;
+      else {
+        BEGIN_PRIVILEGED ();
+        unlink (nfslockfile);
+        END_PRIVILEGED ();
+        return DL_EX_EXIST;
       }
     }
-    
+
     prev_size = sb.st_size;
-    
+
     /* don't trust sleep (3) as it may be interrupted
      * by users sending signals. 
      */
-    
+
     t = time (NULL);
     do {
       sleep (1);
@@ -691,29 +673,26 @@ dotlock_lock (const char *realpath)
  * 
  */
 
-static int
-dotlock_unlock (const char *realpath)
+static int dotlock_unlock (const char *realpath)
 {
   char lockfile[_POSIX_PATH_MAX + LONG_STRING];
   int i;
 
-  snprintf (lockfile, sizeof (lockfile), "%s.lock",
-          realpath);
-  
+  snprintf (lockfile, sizeof (lockfile), "%s.lock", realpath);
+
   BEGIN_PRIVILEGED ();
   i = unlink (lockfile);
   END_PRIVILEGED ();
-  
+
   if (i == -1)
     return DL_EX_ERROR;
-  
+
   return DL_EX_OK;
 }
 
 /* remove an empty file */
 
-static int
-dotlock_unlink (const char *realpath)
+static int dotlock_unlink (const char *realpath)
 {
   struct stat lsb;
   int i = -1;
@@ -726,7 +705,7 @@ dotlock_unlink (const char *realpath)
 
   dotlock_unlock (realpath);
 
-  return (i == 0) ?  DL_EX_OK : DL_EX_ERROR;
+  return (i == 0) ? DL_EX_OK : DL_EX_ERROR;
 }
 
 
@@ -737,8 +716,7 @@ dotlock_unlink (const char *realpath)
  * 
  */
 
-static int
-dotlock_try (void)
+static int dotlock_try (void)
 {
 #ifdef USE_SETGID
   struct stat sb;
@@ -748,8 +726,7 @@ dotlock_try (void)
     return DL_EX_OK;
 
 #ifdef USE_SETGID
-  if (stat (".", &sb) == 0)
-  {
+  if (stat (".", &sb) == 0) {
     if ((sb.st_mode & S_IWGRP) == S_IWGRP && sb.st_gid == MailGid)
       return DL_EX_NEED_PRIVS;
   }
index dff6f61..4ce4dd7 100644 (file)
--- a/dotlock.h
+++ b/dotlock.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _DOTLOCK_H
 #define _DOTLOCK_H
 
 /* exit values */
 
-#define DL_EX_OK       0       
-#define DL_EX_ERROR    1       
-#define DL_EX_EXIST    3       
+#define DL_EX_OK       0
+#define DL_EX_ERROR    1
+#define DL_EX_EXIST    3
 #define DL_EX_NEED_PRIVS 4
 #define DL_EX_IMPOSSIBLE 5
 
diff --git a/edit.c b/edit.c
index 1674248..fd1eeb2 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* Close approximation of the mailx(1) builtin editor for sending mail. */
 
@@ -38,7 +38,7 @@
  * SLcurses_waddnstr() can't take a "const char *", so this is only
  * declared "static" (sigh)
  */
-static charEditorHelp = N_("\
+static char *EditorHelp = N_("\
 ~~             insert a line begining with a single ~\n\
 ~b users       add users to the Bcc: field\n\
 ~c users       add users to the Cc: field\n\
@@ -58,61 +58,58 @@ static char* EditorHelp = N_("\
 ~?             this message\n\
 .              on a line by itself ends input\n");
 
-static char **
-be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset,
-              int bytes, int prefix)
+static char **be_snarf_data (FILE * f, char **buf, int *bufmax, int *buflen,
+                             int offset, int bytes, int prefix)
 {
   char tmp[HUGE_STRING];
   char *p = tmp;
   int tmplen = sizeof (tmp);
 
   tmp[sizeof (tmp) - 1] = 0;
-  if (prefix)
-  {
-    strfcpy (tmp, NONULL(Prefix), sizeof (tmp));
+  if (prefix) {
+    strfcpy (tmp, NONULL (Prefix), sizeof (tmp));
     tmplen = mutt_strlen (tmp);
     p = tmp + tmplen;
     tmplen = sizeof (tmp) - tmplen;
   }
 
   fseek (f, offset, 0);
-  while (bytes > 0)
-  {
-    if (fgets (p, tmplen - 1, f) == NULL) break;
+  while (bytes > 0) {
+    if (fgets (p, tmplen - 1, f) == NULL)
+      break;
     bytes -= mutt_strlen (p);
     if (*bufmax == *buflen)
       safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
     buf[(*buflen)++] = safe_strdup (tmp);
   }
-  if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */
+  if (buf && *bufmax == *buflen) {      /* Do not smash memory past buf */
     safe_realloc (&buf, sizeof (char *) * (++*bufmax));
   }
-  if (buf) buf[*buflen] = NULL;
+  if (buf)
+    buf[*buflen] = NULL;
   return (buf);
 }
 
-static char **
-be_snarf_file (const char *path, char **buf, int *max, int *len, int verbose)
+static char **be_snarf_file (const char *path, char **buf, int *max, int *len,
+                             int verbose)
 {
   FILE *f;
   char tmp[LONG_STRING];
   struct stat sb;
-  
-  if ((f = fopen (path, "r")))
-  {
+
+  if ((f = fopen (path, "r"))) {
     fstat (fileno (f), &sb);
     buf = be_snarf_data (f, buf, max, len, 0, sb.st_size, 0);
-    if (verbose)
-    {
-      snprintf(tmp, sizeof(tmp), "\"%s\" %lu bytes\n", path, (unsigned long) sb.st_size);
-      addstr(tmp);
+    if (verbose) {
+      snprintf (tmp, sizeof (tmp), "\"%s\" %lu bytes\n", path,
+                (unsigned long) sb.st_size);
+      addstr (tmp);
     }
     fclose (f);
   }
-  else
-  {
-    snprintf(tmp, sizeof(tmp), "%s: %s\n", path, strerror(errno));
-    addstr(tmp);
+  else {
+    snprintf (tmp, sizeof (tmp), "%s: %s\n", path, strerror (errno));
+    addstr (tmp);
   }
   return (buf);
 }
@@ -121,15 +118,16 @@ static int be_barf_file (const char *path, char **buf, int buflen)
 {
   FILE *f;
   int i;
-  
-  if ((f = safe_fopen (path, "w")) == NULL)            /* __FOPEN_CHECKED__ */
-  {
+
+  if ((f = safe_fopen (path, "w")) == NULL) {   /* __FOPEN_CHECKED__ */
     addstr (strerror (errno));
     addch ('\n');
     return (-1);
   }
-  for (i = 0; i < buflen; i++) fputs (buf[i], f);
-  if (fclose (f) == 0) return 0;
+  for (i = 0; i < buflen; i++)
+    fputs (buf[i], f);
+  if (fclose (f) == 0)
+    return 0;
   printw ("fclose: %s\n", strerror (errno));
   return (-1);
 }
@@ -142,44 +140,40 @@ static void be_free_memory (char **buf, int buflen)
     FREE (&buf);
 }
 
-static char **
-be_include_messages (char *msg, char **buf, int *bufmax, int *buflen,
-                    int pfx, int inc_hdrs)
+static char **be_include_messages (char *msg, char **buf, int *bufmax,
+                                   int *buflen, int pfx, int inc_hdrs)
 {
   int offset, bytes, n;
   char tmp[LONG_STRING];
 
-  while ((msg = strtok (msg, " ,")) != NULL)
-  {
+  while ((msg = strtok (msg, " ,")) != NULL) {
     n = atoi (msg);
-    if (n > 0 && n <= Context->msgcount)
-    {
+    if (n > 0 && n <= Context->msgcount) {
       n--;
 
       /* add the attribution */
-      if (Attribution)
-      {
-       mutt_make_string (tmp, sizeof (tmp) - 1, Attribution, Context, Context->hdrs[n]);
-       strcat (tmp, "\n");     /* __STRCAT_CHECKED__ */
+      if (Attribution) {
+        mutt_make_string (tmp, sizeof (tmp) - 1, Attribution, Context,
+                          Context->hdrs[n]);
+        strcat (tmp, "\n");     /* __STRCAT_CHECKED__ */
       }
 
       if (*bufmax == *buflen)
-       safe_realloc ( &buf, sizeof (char *) * (*bufmax += 25));
+        safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
       buf[(*buflen)++] = safe_strdup (tmp);
 
       bytes = Context->hdrs[n]->content->length;
-      if (inc_hdrs)
-      {
-       offset = Context->hdrs[n]->offset;
-       bytes += Context->hdrs[n]->content->offset - offset;
+      if (inc_hdrs) {
+        offset = Context->hdrs[n]->offset;
+        bytes += Context->hdrs[n]->content->offset - offset;
       }
       else
-       offset = Context->hdrs[n]->content->offset;
+        offset = Context->hdrs[n]->content->offset;
       buf = be_snarf_data (Context->fp, buf, bufmax, buflen, offset, bytes,
-                          pfx);
+                           pfx);
 
       if (*bufmax == *buflen)
-       safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
+        safe_realloc (&buf, sizeof (char *) * (*bufmax += 25));
       buf[(*buflen)++] = safe_strdup ("\n");
     }
     else
@@ -189,36 +183,32 @@ be_include_messages (char *msg, char **buf, int *bufmax, int *buflen,
   return (buf);
 }
 
-static void be_print_header (ENVELOPE *env)
+static void be_print_header (ENVELOPE * env)
 {
   char tmp[HUGE_STRING];
 
-  if (env->to)
-  {
+  if (env->to) {
     addstr ("To: ");
     tmp[0] = 0;
     rfc822_write_address (tmp, sizeof (tmp), env->to, 1);
     addstr (tmp);
     addch ('\n');
   }
-  if (env->cc)
-  {
+  if (env->cc) {
     addstr ("Cc: ");
     tmp[0] = 0;
     rfc822_write_address (tmp, sizeof (tmp), env->cc, 1);
     addstr (tmp);
     addch ('\n');
   }
-  if (env->bcc)
-  {
+  if (env->bcc) {
     addstr ("Bcc: ");
     tmp[0] = 0;
     rfc822_write_address (tmp, sizeof (tmp), env->bcc, 1);
     addstr (tmp);
     addch ('\n');
   }
-  if (env->subject)
-  {
+  if (env->subject) {
     addstr ("Subject: ");
     addstr (env->subject);
     addch ('\n');
@@ -229,53 +219,47 @@ static void be_print_header (ENVELOPE *env)
 /* args:
  *     force   override the $ask* vars (used for the ~h command)
  */
-static void be_edit_header (ENVELOPE *e, int force)
+static void be_edit_header (ENVELOPE * e, int force)
 {
   char tmp[HUGE_STRING];
 
-  move (LINES-1, 0);
+  move (LINES - 1, 0);
 
   addstr ("To: ");
   tmp[0] = 0;
   mutt_addrlist_to_local (e->to);
   rfc822_write_address (tmp, sizeof (tmp), e->to, 0);
-  if (!e->to || force)
-  {
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 4, 0) == 0)
-    {
+  if (!e->to || force) {
+    if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 4, 0) == 0) {
       rfc822_free_address (&e->to);
       e->to = mutt_parse_adrlist (e->to, tmp);
       e->to = mutt_expand_aliases (e->to);
-      mutt_addrlist_to_idna (e->to, NULL);     /* XXX - IDNA error reporting? */
+      mutt_addrlist_to_idna (e->to, NULL);      /* XXX - IDNA error reporting? */
       tmp[0] = 0;
       rfc822_write_address (tmp, sizeof (tmp), e->to, 1);
       mvaddstr (LINES - 1, 4, tmp);
     }
   }
-  else
-  {
-    mutt_addrlist_to_idna (e->to, NULL);       /* XXX - IDNA error reporting? */
+  else {
+    mutt_addrlist_to_idna (e->to, NULL);        /* XXX - IDNA error reporting? */
     addstr (tmp);
   }
   addch ('\n');
 
-  if (!e->subject || force)
-  {
+  if (!e->subject || force) {
     addstr ("Subject: ");
-    strfcpy (tmp, e->subject ? e->subject: "", sizeof (tmp));
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 9, 0) == 0)
+    strfcpy (tmp, e->subject ? e->subject : "", sizeof (tmp));
+    if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 9, 0) == 0)
       mutt_str_replace (&e->subject, tmp);
     addch ('\n');
   }
 
-  if ((!e->cc && option (OPTASKCC)) || force)
-  {
+  if ((!e->cc && option (OPTASKCC)) || force) {
     addstr ("Cc: ");
     tmp[0] = 0;
     mutt_addrlist_to_local (e->cc);
     rfc822_write_address (tmp, sizeof (tmp), e->cc, 0);
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 4, 0) == 0)
-    {
+    if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 4, 0) == 0) {
       rfc822_free_address (&e->cc);
       e->cc = mutt_parse_adrlist (e->cc, tmp);
       e->cc = mutt_expand_aliases (e->cc);
@@ -289,14 +273,12 @@ static void be_edit_header (ENVELOPE *e, int force)
     addch ('\n');
   }
 
-  if (option (OPTASKBCC) || force)
-  {
+  if (option (OPTASKBCC) || force) {
     addstr ("Bcc: ");
     tmp[0] = 0;
     mutt_addrlist_to_local (e->bcc);
     rfc822_write_address (tmp, sizeof (tmp), e->bcc, 0);
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 5, 0) == 0)
-    {
+    if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 5, 0) == 0) {
       rfc822_free_address (&e->bcc);
       e->bcc = mutt_parse_adrlist (e->bcc, tmp);
       e->bcc = mutt_expand_aliases (e->bcc);
@@ -311,7 +293,7 @@ static void be_edit_header (ENVELOPE *e, int force)
   }
 }
 
-int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur)
+int mutt_builtin_editor (const char *path, HEADER * msg, HEADER * cur)
 {
   char **buf = NULL;
   int bufmax = 0, buflen = 0;
@@ -320,7 +302,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur)
   int done = 0;
   int i;
   char *p;
-  
+
   scrollok (stdscr, TRUE);
 
   be_edit_header (msg->env, 0);
@@ -330,153 +312,146 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur)
   buf = be_snarf_file (path, buf, &bufmax, &buflen, 0);
 
   tmp[0] = 0;
-  while (!done)
-  {
-    if (mutt_enter_string (tmp, sizeof (tmp), LINES-1, 0, 0) == -1)
-    {
+  while (!done) {
+    if (mutt_enter_string (tmp, sizeof (tmp), LINES - 1, 0, 0) == -1) {
       tmp[0] = 0;
       continue;
     }
     addch ('\n');
 
-    if (EscChar && tmp[0] == EscChar[0] && tmp[1] != EscChar[0])
-    {
+    if (EscChar && tmp[0] == EscChar[0] && tmp[1] != EscChar[0]) {
       /* remove trailing whitespace from the line */
       p = tmp + mutt_strlen (tmp) - 1;
       while (p >= tmp && ISSPACE (*p))
-       *p-- = 0;
+        *p-- = 0;
 
       p = tmp + 2;
       SKIPWS (p);
 
-      switch (tmp[1])
-      {
-       case '?':
-         addstr (_(EditorHelp));
-         break;
-       case 'b':
-         msg->env->bcc = mutt_parse_adrlist (msg->env->bcc, p);
-         msg->env->bcc = mutt_expand_aliases (msg->env->bcc);
-         break;
-       case 'c':
-         msg->env->cc = mutt_parse_adrlist (msg->env->cc, p);
-         msg->env->cc = mutt_expand_aliases (msg->env->cc);
-         break;
-       case 'h':
-         be_edit_header (msg->env, 1);
-         break;
-       case 'F':
-       case 'f':
-       case 'm':
-       case 'M':
-         if (Context)
-         {
-           if (!*p && cur)
-           {
-             /* include the current message */
-             p = tmp + mutt_strlen (tmp) + 1;
-             snprintf (tmp + mutt_strlen (tmp), sizeof (tmp) - mutt_strlen (tmp), " %d",
-                                                               cur->msgno + 1);
-           }
-           buf = be_include_messages (p, buf, &bufmax, &buflen,
-                                      (ascii_tolower (tmp[1]) == 'm'),
-                                      (ascii_isupper ((unsigned char) tmp[1])));
-         }
-         else
-           addstr (_("No mailbox.\n"));
-         break;
-       case 'p':
-         addstr ("-----\n");
-         addstr (_("Message contains:\n"));
-         be_print_header (msg->env);
-         for (i = 0; i < buflen; i++)
-           addstr (buf[i]);
-         addstr (_("(continue)\n"));
-         break;
-       case 'q':
-         done = 1;
-         break;
-       case 'r':
-         if (*p)
-          {
-           strncpy(tmp, p, sizeof(tmp));
-           mutt_expand_path(tmp, sizeof(tmp));
-           buf = be_snarf_file (tmp, buf, &bufmax, &buflen, 1);
+      switch (tmp[1]) {
+      case '?':
+        addstr (_(EditorHelp));
+        break;
+      case 'b':
+        msg->env->bcc = mutt_parse_adrlist (msg->env->bcc, p);
+        msg->env->bcc = mutt_expand_aliases (msg->env->bcc);
+        break;
+      case 'c':
+        msg->env->cc = mutt_parse_adrlist (msg->env->cc, p);
+        msg->env->cc = mutt_expand_aliases (msg->env->cc);
+        break;
+      case 'h':
+        be_edit_header (msg->env, 1);
+        break;
+      case 'F':
+      case 'f':
+      case 'm':
+      case 'M':
+        if (Context) {
+          if (!*p && cur) {
+            /* include the current message */
+            p = tmp + mutt_strlen (tmp) + 1;
+            snprintf (tmp + mutt_strlen (tmp),
+                      sizeof (tmp) - mutt_strlen (tmp), " %d",
+                      cur->msgno + 1);
+          }
+          buf = be_include_messages (p, buf, &bufmax, &buflen,
+                                     (ascii_tolower (tmp[1]) == 'm'),
+                                     (ascii_isupper
+                                      ((unsigned char) tmp[1])));
+        }
+        else
+          addstr (_("No mailbox.\n"));
+        break;
+      case 'p':
+        addstr ("-----\n");
+        addstr (_("Message contains:\n"));
+        be_print_header (msg->env);
+        for (i = 0; i < buflen; i++)
+          addstr (buf[i]);
+        addstr (_("(continue)\n"));
+        break;
+      case 'q':
+        done = 1;
+        break;
+      case 'r':
+        if (*p) {
+          strncpy (tmp, p, sizeof (tmp));
+          mutt_expand_path (tmp, sizeof (tmp));
+          buf = be_snarf_file (tmp, buf, &bufmax, &buflen, 1);
+        }
+        else
+          addstr (_("missing filename.\n"));
+        break;
+      case 's':
+        mutt_str_replace (&msg->env->subject, p);
+        break;
+      case 't':
+        msg->env->to = rfc822_parse_adrlist (msg->env->to, p);
+        msg->env->to = mutt_expand_aliases (msg->env->to);
+        break;
+      case 'u':
+        if (buflen) {
+          buflen--;
+          strfcpy (tmp, buf[buflen], sizeof (tmp));
+          tmp[mutt_strlen (tmp) - 1] = 0;
+          FREE (&buf[buflen]);
+          buf[buflen] = NULL;
+          continue;
+        }
+        else
+          addstr (_("No lines in message.\n"));
+        break;
+
+      case 'e':
+      case 'v':
+        if (be_barf_file (path, buf, buflen) == 0) {
+          char *tag, *err;
+
+          be_free_memory (buf, buflen);
+          buf = NULL;
+          bufmax = buflen = 0;
+
+          if (option (OPTEDITHDRS)) {
+            mutt_env_to_local (msg->env);
+            mutt_edit_headers (NONULL (Visual), path, msg, NULL, 0);
+            if (mutt_env_to_idna (msg->env, &tag, &err))
+              printw (_("Bad IDN in %s: '%s'\n"), tag, err);
           }
-         else
-           addstr (_("missing filename.\n"));
-         break;
-       case 's':
-         mutt_str_replace (&msg->env->subject, p);
-         break;
-       case 't':
-         msg->env->to = rfc822_parse_adrlist (msg->env->to, p);
-         msg->env->to = mutt_expand_aliases (msg->env->to);
-         break;
-       case 'u':
-         if (buflen)
-         {
-           buflen--;
-           strfcpy (tmp, buf[buflen], sizeof (tmp));
-           tmp[mutt_strlen (tmp)-1] = 0;
-           FREE (&buf[buflen]);
-           buf[buflen] = NULL;
-           continue;
-         }
-         else
-           addstr (_("No lines in message.\n"));
-         break;
-
-       case 'e':
-       case 'v':
-         if (be_barf_file (path, buf, buflen) == 0)
-         {
-           char *tag, *err;
-           be_free_memory (buf, buflen);
-           buf = NULL;
-           bufmax = buflen = 0;
-
-           if (option (OPTEDITHDRS))
-           {
-             mutt_env_to_local (msg->env);
-             mutt_edit_headers (NONULL(Visual), path, msg, NULL, 0);
-             if (mutt_env_to_idna (msg->env, &tag, &err))
-               printw (_("Bad IDN in %s: '%s'\n"), tag, err);
-           }
-           else
-             mutt_edit_file (NONULL(Visual), path);
-
-           buf = be_snarf_file (path, buf, &bufmax, &buflen, 0);
-
-           addstr (_("(continue)\n"));
-         }
-         break;
-       case 'w':
-         be_barf_file (*p ? p : path, buf, buflen);
-         break;
-       case 'x':
-         abort = 1;
-         done = 1;
-         break;
-       default:
-         printw (_("%s: unknown editor command (~? for help)\n"), tmp);
-         break;
+          else
+            mutt_edit_file (NONULL (Visual), path);
+
+          buf = be_snarf_file (path, buf, &bufmax, &buflen, 0);
+
+          addstr (_("(continue)\n"));
+        }
+        break;
+      case 'w':
+        be_barf_file (*p ? p : path, buf, buflen);
+        break;
+      case 'x':
+        abort = 1;
+        done = 1;
+        break;
+      default:
+        printw (_("%s: unknown editor command (~? for help)\n"), tmp);
+        break;
       }
     }
     else if (mutt_strcmp (".", tmp) == 0)
       done = 1;
-    else
-    {
+    else {
       safe_strcat (tmp, sizeof (tmp), "\n");
       if (buflen == bufmax)
-       safe_realloc (&buf, sizeof (char *) * (bufmax += 25));
+        safe_realloc (&buf, sizeof (char *) * (bufmax += 25));
       buf[buflen++] = safe_strdup (tmp[1] == '~' ? tmp + 1 : tmp);
     }
-    
+
     tmp[0] = 0;
   }
 
-  if (!abort) be_barf_file (path, buf, buflen);
+  if (!abort)
+    be_barf_file (path, buf, buflen);
   be_free_memory (buf, buflen);
 
   return (abort ? -1 : 0);
index 0d037d4..d0b080f 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -17,7 +17,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /* simple, editor-based message editing */
 
@@ -43,7 +43,7 @@
  * -1   error
  */
 
-static int edit_one_message (CONTEXT *ctx, HEADER *cur)
+static int edit_one_message (CONTEXT * ctx, HEADER * cur)
 {
   char tmp[_POSIX_PATH_MAX];
   char buff[STRING];
@@ -55,7 +55,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
   unsigned short o_old;
 
   int of, cf;
-  
+
   CONTEXT tmpctx;
   MESSAGE *msg;
 
@@ -63,7 +63,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
 
   struct stat sb;
   time_t mtime = 0;
-  
+
   mutt_mktemp (tmp);
 
   omagic = DefaultMagic;
@@ -73,21 +73,21 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
 
   DefaultMagic = omagic;
 
-  if (rc == -1)
-  {
+  if (rc == -1) {
     mutt_error (_("could not create temporary folder: %s"), strerror (errno));
     return -1;
   }
 
   rc = mutt_append_message (&tmpctx, ctx, cur, 0, CH_NOLEN |
-       ((ctx->magic == M_MBOX || ctx->magic == M_MMDF) ? 0 : CH_NOSTATUS));
+                            ((ctx->magic == M_MBOX
+                              || ctx->magic == M_MMDF) ? 0 : CH_NOSTATUS));
   oerrno = errno;
 
   mx_close_mailbox (&tmpctx, NULL);
 
-  if (rc == -1)
-  {
-    mutt_error (_("could not write temporary mail folder: %s"), strerror (oerrno));
+  if (rc == -1) {
+    mutt_error (_("could not write temporary mail folder: %s"),
+                strerror (oerrno));
     goto bail;
   }
 
@@ -102,44 +102,38 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
    * remove it, the message will grow by one line each time the user edits
    * the message.
    */
-  if (sb.st_size != 0 && truncate (tmp, sb.st_size - 1) == -1)
-  {
+  if (sb.st_size != 0 && truncate (tmp, sb.st_size - 1) == -1) {
     mutt_error (_("could not truncate temporary mail folder: %s"),
-               strerror (errno));
+                strerror (errno));
     goto bail;
   }
 
-  mutt_edit_file (NONULL(Editor), tmp);
+  mutt_edit_file (NONULL (Editor), tmp);
 
-  if ((rc = stat (tmp, &sb)) == -1)
-  {
+  if ((rc = stat (tmp, &sb)) == -1) {
     mutt_error (_("Can't stat %s: %s"), tmp, strerror (errno));
     goto bail;
   }
-  
-  if (sb.st_size == 0)
-  {
+
+  if (sb.st_size == 0) {
     mutt_message (_("Message file is empty!"));
     rc = 1;
     goto bail;
   }
 
-  if (sb.st_mtime == mtime)
-  {
+  if (sb.st_mtime == mtime) {
     mutt_message (_("Message not modified!"));
     rc = 1;
     goto bail;
   }
 
-  if ((fp = fopen (tmp, "r")) == NULL)
-  {
+  if ((fp = fopen (tmp, "r")) == NULL) {
     rc = -1;
     mutt_error (_("Can't open message file: %s"), strerror (errno));
     goto bail;
   }
 
-  if (mx_open_mailbox (ctx->path, M_APPEND, &tmpctx) == NULL)
-  {
+  if (mx_open_mailbox (ctx->path, M_APPEND, &tmpctx) == NULL) {
     rc = -1;
     mutt_error (_("Can't append to folder: %s"), strerror (errno));
     goto bail;
@@ -147,9 +141,8 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
 
   of = 0;
   cf = ((tmpctx.magic == M_MBOX || tmpctx.magic == M_MMDF) ? 0 : CH_NOSTATUS);
-  
-  if (fgets (buff, sizeof (buff), fp) && is_from (buff, NULL, 0, NULL))
-  {
+
+  if (fgets (buff, sizeof (buff), fp) && is_from (buff, NULL, 0, NULL)) {
     if (tmpctx.magic == M_MBOX || tmpctx.magic == M_MMDF)
       cf = CH_FROM | CH_FORCE_FROM;
   }
@@ -162,37 +155,39 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
    *
    */
 
-  o_read = cur->read; o_old = cur->old;
+  o_read = cur->read;
+  o_old = cur->old;
   cur->read = cur->old = 0;
   msg = mx_open_new_message (&tmpctx, cur, of);
-  cur->read = o_read; cur->old = o_old;
+  cur->read = o_read;
+  cur->old = o_old;
 
-  if (msg == NULL)
-  {
+  if (msg == NULL) {
     mutt_error (_("Can't append to folder: %s"), strerror (errno));
     mx_close_mailbox (&tmpctx, NULL);
     goto bail;
   }
 
-  if ((rc = mutt_copy_hdr (fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL)) == 0)
-  {
+  if ((rc =
+       mutt_copy_hdr (fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf,
+                      NULL)) == 0) {
     fputc ('\n', msg->fp);
     rc = mutt_copy_stream (fp, msg->fp);
   }
 
   rc = mx_commit_message (msg, &tmpctx);
   mx_close_message (&msg);
-  
+
   mx_close_mailbox (&tmpctx, NULL);
-  
-  bail:
-  if (fp) fclose (fp);
+
+bail:
+  if (fp)
+    fclose (fp);
 
   if (rc >= 0)
     unlink (tmp);
 
-  if (rc == 0)
-  {
+  if (rc == 0) {
     mutt_set_flag (Context, cur, M_DELETE, 1);
     mutt_set_flag (Context, cur, M_READ, 1);
 
@@ -202,25 +197,23 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
   else if (rc == -1)
     mutt_message (_("Error. Preserving temporary file: %s"), tmp);
 
-    
+
   return rc;
 }
 
-int mutt_edit_message (CONTEXT *ctx, HEADER *hdr)
+int mutt_edit_message (CONTEXT * ctx, HEADER * hdr)
 {
   int i, j;
 
   if (hdr)
     return edit_one_message (ctx, hdr);
 
-  
-  for (i = 0; i < ctx->vcount; i++)
-  {
+
+  for (i = 0; i < ctx->vcount; i++) {
     j = ctx->v2r[i];
-    if (ctx->hdrs[j]->tagged)
-    {
+    if (ctx->hdrs[j]->tagged) {
       if (edit_one_message (ctx, ctx->hdrs[j]) == -1)
-       return -1;
+        return -1;
     }
   }
 
diff --git a/enter.c b/enter.c
index 6cf9d8d..f327001 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <string.h>
 
 /* redraw flags for mutt_enter_string() */
-enum
-{
-  M_REDRAW_INIT = 1,        /* go to end of line and redraw */
-  M_REDRAW_LINE                /* redraw entire line */
+enum {
+  M_REDRAW_INIT = 1,            /* go to end of line and redraw */
+  M_REDRAW_LINE                 /* redraw entire line */
 };
 
 static int my_wcwidth (wchar_t wc)
 {
   int n = wcwidth (wc);
+
   if (IsWPrint (wc) && n > 0)
     return n;
   if (!(wc & ~0x7f))
@@ -51,9 +51,10 @@ static int my_wcwidth (wchar_t wc)
 /* combining mark / non-spacing character */
 #define COMB_CHAR(wc) (IsWPrint (wc) && !wcwidth (wc))
 
-static int my_wcswidth (const wchar_t *s, size_t n)
+static int my_wcswidth (const wchar_t * s, size_t n)
 {
   int w = 0;
+
   while (n--)
     w += my_wcwidth (*s++);
   return w;
@@ -62,26 +63,29 @@ static int my_wcswidth (const wchar_t *s, size_t n)
 static int my_addwch (wchar_t wc)
 {
   int n = wcwidth (wc);
+
   if (IsWPrint (wc) && n > 0)
     return mutt_addwch (wc);
   if (!(wc & ~0x7f))
-    return printw ("^%c", ((int)wc + 0x40) & 0x7f);
+    return printw ("^%c", ((int) wc + 0x40) & 0x7f);
   if (!(wc & ~0xffff))
-    return printw ("\\u%04x", (int)wc);
-  return printw ("\\u%08x", (int)wc);
+    return printw ("\\u%04x", (int) wc);
+  return printw ("\\u%08x", (int) wc);
 }
 
-static size_t width_ceiling (const wchar_t *s, size_t n, int w1)
+static size_t width_ceiling (const wchar_t * s, size_t n, int w1)
 {
   const wchar_t *s0 = s;
   int w = 0;
+
   for (; n; s++, n--)
     if ((w += my_wcwidth (*s)) > w1)
       break;
-  return s - s0;  
+  return s - s0;
 }
 
-static void my_wcstombs (char *dest, size_t dlen, const wchar_t *src, size_t slen)
+static void my_wcstombs (char *dest, size_t dlen, const wchar_t * src,
+                         size_t slen)
 {
   mbstate_t st;
   size_t k;
@@ -89,7 +93,7 @@ static void my_wcstombs (char *dest, size_t dlen, const wchar_t *src, size_t sle
   /* First convert directly into the destination buffer */
   memset (&st, 0, sizeof (st));
   for (; slen && dlen >= MB_LEN_MAX; dest += k, dlen -= k, src++, slen--)
-    if ((k = wcrtomb (dest, *src, &st)) == (size_t)(-1))
+    if ((k = wcrtomb (dest, *src, &st)) == (size_t) (-1))
       break;
 
   /* If this works, we can stop now */
@@ -104,7 +108,7 @@ static void my_wcstombs (char *dest, size_t dlen, const wchar_t *src, size_t sle
     char *p = buf;
 
     for (; slen && p - buf < dlen; p += k, src++, slen--)
-      if ((k = wcrtomb (p, *src, &st)) == (size_t)(-1))
+      if ((k = wcrtomb (p, *src, &st)) == (size_t) (-1))
         break;
     p += wcrtomb (p, 0, &st);
 
@@ -116,11 +120,11 @@ static void my_wcstombs (char *dest, size_t dlen, const wchar_t *src, size_t sle
 
     /* Otherwise we truncate the string in an ugly fashion */
     memcpy (dest, buf, dlen);
-    dest[dlen - 1] = '\0'; /* assume original dlen > 0 */
+    dest[dlen - 1] = '\0';      /* assume original dlen > 0 */
   }
 }
 
-size_t my_mbstowcs (wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf)
+size_t my_mbstowcs (wchar_t ** pwbuf, size_t * pwbuflen, size_t i, char *buf)
 {
   wchar_t wc;
   mbstate_t st;
@@ -131,10 +135,8 @@ size_t my_mbstowcs (wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf)
   wbuf = *pwbuf, wbuflen = *pwbuflen;
   memset (&st, 0, sizeof (st));
   for (; (k = mbrtowc (&wc, buf, MB_LEN_MAX, &st)) &&
-         k != (size_t)(-1) && k != (size_t)(-2); buf += k)
-  {
-    if (i >= wbuflen)
-    {
+       k != (size_t) (-1) && k != (size_t) (-2); buf += k) {
+    if (i >= wbuflen) {
       wbuflen = i + 20;
       safe_realloc (&wbuf, wbuflen * sizeof (*wbuf));
     }
@@ -148,19 +150,19 @@ size_t my_mbstowcs (wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf)
  * Replace part of the wchar_t buffer, from FROM to CURPOS, by BUF.
  */
 
-static void replace_part (ENTER_STATE *state, size_t from, char *buf)
+static void replace_part (ENTER_STATE * state, size_t from, char *buf)
 {
   /* Save the suffix */
   size_t savelen = state->lastchar - state->curpos;
   wchar_t *savebuf = safe_calloc (savelen, sizeof (wchar_t));
+
   memcpy (savebuf, state->wbuf + state->curpos, savelen * sizeof (wchar_t));
 
   /* Convert to wide characters */
   state->curpos = my_mbstowcs (&state->wbuf, &state->wbuflen, from, buf);
 
   /* Make space for suffix */
-  if (state->curpos + savelen > state->wbuflen)
-  {
+  if (state->curpos + savelen > state->wbuflen) {
     state->wbuflen = state->curpos + savelen;
     safe_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t));
   }
@@ -179,10 +181,11 @@ static void replace_part (ENTER_STATE *state, size_t from, char *buf)
  *         -1 if abort.
  */
 
-int  mutt_enter_string(char *buf, size_t buflen, int y, int x, int flags)
+int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags)
 {
   int rv;
   ENTER_STATE *es = mutt_new_enter_state ();
+
   rv = _mutt_enter_string (buf, buflen, y, x, flags, 0, NULL, NULL, es);
   mutt_free_enter_state (&es);
   return rv;
@@ -190,7 +193,7 @@ int  mutt_enter_string(char *buf, size_t buflen, int y, int x, int flags)
 
 int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
                         int flags, int multiple, char ***files, int *numfiles,
-                        ENTER_STATE *state)
+                        ENTER_STATE * state)
 {
   int width = COLS - x - 1;
   int redraw;
@@ -205,15 +208,14 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
   mbstate_t mbstate;
 
   int rv = 0;
+
   memset (&mbstate, 0, sizeof (mbstate));
-  
-  if (state->wbuf)
-  {
+
+  if (state->wbuf) {
     /* Coming back after return 1 */
     redraw = M_REDRAW_LINE;
   }
-  else
-  {
+  else {
     /* Initialise wbuf from buf */
     state->wbuflen = 0;
     state->lastchar = my_mbstowcs (&state->wbuf, &state->wbuflen, 0, buf);
@@ -230,401 +232,381 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x,
     hclass = HC_COMMAND;
   else if (flags & M_PATTERN)
     hclass = HC_PATTERN;
-  else 
+  else
     hclass = HC_OTHER;
-    
-  for (;;)
-  {
-    if (redraw && !pass)
-    {
-      if (redraw == M_REDRAW_INIT)
-      {
+
+  for (;;) {
+    if (redraw && !pass) {
+      if (redraw == M_REDRAW_INIT) {
         /* Go to end of line */
         state->curpos = state->lastchar;
-        state->begin = width_ceiling (state->wbuf, state->lastchar, my_wcswidth (state->wbuf, state->lastchar) - width + 1);
-      } 
+        state->begin =
+          width_ceiling (state->wbuf, state->lastchar,
+                         my_wcswidth (state->wbuf,
+                                      state->lastchar) - width + 1);
+      }
       if (state->curpos < state->begin ||
-          my_wcswidth (state->wbuf + state->begin, state->curpos - state->begin) >= width)
-        state->begin = width_ceiling (state->wbuf, state->lastchar, my_wcswidth (state->wbuf, state->curpos) - width / 2);
+          my_wcswidth (state->wbuf + state->begin,
+                       state->curpos - state->begin) >= width)
+        state->begin =
+          width_ceiling (state->wbuf, state->lastchar,
+                         my_wcswidth (state->wbuf,
+                                      state->curpos) - width / 2);
       move (y, x);
       w = 0;
-      for (i = state->begin; i < state->lastchar; i++)
-      {
+      for (i = state->begin; i < state->lastchar; i++) {
         w += my_wcwidth (state->wbuf[i]);
         if (w > width)
           break;
         my_addwch (state->wbuf[i]);
       }
       clrtoeol ();
-      move (y, x + my_wcswidth (state->wbuf + state->begin, state->curpos - state->begin));
+      move (y,
+            x + my_wcswidth (state->wbuf + state->begin,
+                             state->curpos - state->begin));
     }
     mutt_refresh ();
 
-    if ((ch = km_dokey (MENU_EDITOR)) == -1)
-    {
-      rv = -1; 
+    if ((ch = km_dokey (MENU_EDITOR)) == -1) {
+      rv = -1;
       goto bye;
     }
 
-    if (ch != OP_NULL)
-    {
+    if (ch != OP_NULL) {
       first = 0;
       if (ch != OP_EDITOR_COMPLETE)
         state->tabs = 0;
       redraw = M_REDRAW_LINE;
-      switch (ch)
-      {
-        case OP_EDITOR_HISTORY_UP:
-          state->curpos = state->lastchar;
-          replace_part (state, 0, mutt_history_prev (hclass));
-          redraw = M_REDRAW_INIT;
-          break;
+      switch (ch) {
+      case OP_EDITOR_HISTORY_UP:
+        state->curpos = state->lastchar;
+        replace_part (state, 0, mutt_history_prev (hclass));
+        redraw = M_REDRAW_INIT;
+        break;
 
-        case OP_EDITOR_HISTORY_DOWN:
-          state->curpos = state->lastchar;
-          replace_part (state, 0, mutt_history_next (hclass));
-          redraw = M_REDRAW_INIT;
-          break;
+      case OP_EDITOR_HISTORY_DOWN:
+        state->curpos = state->lastchar;
+        replace_part (state, 0, mutt_history_next (hclass));
+        redraw = M_REDRAW_INIT;
+        break;
 
-        case OP_EDITOR_BACKSPACE:
-          if (state->curpos == 0)
-            BEEP ();
-          else
-          {
-            i = state->curpos;
-            while (i && COMB_CHAR (state->wbuf[i - 1]))
-              --i;
-            if (i)
-              --i;
-            memmove (state->wbuf + i, state->wbuf + state->curpos, (state->lastchar - state->curpos) * sizeof (wchar_t));
-            state->lastchar -= state->curpos - i;
-            state->curpos = i;
-          }
-          break;
+      case OP_EDITOR_BACKSPACE:
+        if (state->curpos == 0)
+          BEEP ();
+        else {
+          i = state->curpos;
+          while (i && COMB_CHAR (state->wbuf[i - 1]))
+            --i;
+          if (i)
+            --i;
+          memmove (state->wbuf + i, state->wbuf + state->curpos,
+                   (state->lastchar - state->curpos) * sizeof (wchar_t));
+          state->lastchar -= state->curpos - i;
+          state->curpos = i;
+        }
+        break;
 
-        case OP_EDITOR_BOL:
-          state->curpos = 0;
-          break;
+      case OP_EDITOR_BOL:
+        state->curpos = 0;
+        break;
 
-        case OP_EDITOR_EOL:
-          redraw= M_REDRAW_INIT;
-          break;
+      case OP_EDITOR_EOL:
+        redraw = M_REDRAW_INIT;
+        break;
 
-        case OP_EDITOR_KILL_LINE:
-          state->curpos = state->lastchar = 0;
-          break;
+      case OP_EDITOR_KILL_LINE:
+        state->curpos = state->lastchar = 0;
+        break;
 
-        case OP_EDITOR_KILL_EOL:
-          state->lastchar = state->curpos;
-          break;
+      case OP_EDITOR_KILL_EOL:
+        state->lastchar = state->curpos;
+        break;
 
-        case OP_EDITOR_BACKWARD_CHAR:
-          if (state->curpos == 0)
-            BEEP ();
-          else
-          {
-            while (state->curpos && COMB_CHAR (state->wbuf[state->curpos - 1]))
-              state->curpos--;
-            if (state->curpos)
-              state->curpos--;
-          }
-          break;
+      case OP_EDITOR_BACKWARD_CHAR:
+        if (state->curpos == 0)
+          BEEP ();
+        else {
+          while (state->curpos && COMB_CHAR (state->wbuf[state->curpos - 1]))
+            state->curpos--;
+          if (state->curpos)
+            state->curpos--;
+        }
+        break;
 
-        case OP_EDITOR_FORWARD_CHAR:
-          if (state->curpos == state->lastchar)
-            BEEP ();
-          else
-          {
+      case OP_EDITOR_FORWARD_CHAR:
+        if (state->curpos == state->lastchar)
+          BEEP ();
+        else {
+          ++state->curpos;
+          while (state->curpos < state->lastchar
+                 && COMB_CHAR (state->wbuf[state->curpos]))
             ++state->curpos;
-            while (state->curpos < state->lastchar && COMB_CHAR (state->wbuf[state->curpos]))
-              ++state->curpos;
-          }
-          break;
-
-        case OP_EDITOR_BACKWARD_WORD:
-          if (state->curpos == 0)
-            BEEP ();
-          else
-          {
-            while (state->curpos && iswspace (state->wbuf[state->curpos - 1]))
-              --state->curpos;
-            while (state->curpos && !iswspace (state->wbuf[state->curpos - 1]))
-              --state->curpos;
-          }
-          break;
-
-        case OP_EDITOR_FORWARD_WORD:
-          if (state->curpos == state->lastchar)
-            BEEP ();
-          else
-          {
-            while (state->curpos < state->lastchar && iswspace (state->wbuf[state->curpos]))
-              ++state->curpos;
-            while (state->curpos < state->lastchar && !iswspace (state->wbuf[state->curpos]))
-              ++state->curpos;
-          }
-          break;
+        }
+        break;
 
-        case OP_EDITOR_CAPITALIZE_WORD:
-        case OP_EDITOR_UPCASE_WORD:
-        case OP_EDITOR_DOWNCASE_WORD:
-          if (state->curpos == state->lastchar)
-          {
-            BEEP ();
-            break;
-          }
-          while (state->curpos && !iswspace (state->wbuf[state->curpos]))
+      case OP_EDITOR_BACKWARD_WORD:
+        if (state->curpos == 0)
+          BEEP ();
+        else {
+          while (state->curpos && iswspace (state->wbuf[state->curpos - 1]))
+            --state->curpos;
+          while (state->curpos && !iswspace (state->wbuf[state->curpos - 1]))
             --state->curpos;
-          while (state->curpos < state->lastchar && iswspace (state->wbuf[state->curpos]))
+        }
+        break;
+
+      case OP_EDITOR_FORWARD_WORD:
+        if (state->curpos == state->lastchar)
+          BEEP ();
+        else {
+          while (state->curpos < state->lastchar
+                 && iswspace (state->wbuf[state->curpos]))
             ++state->curpos;
-          while (state->curpos < state->lastchar && !iswspace (state->wbuf[state->curpos]))
-          {
-            if (ch == OP_EDITOR_DOWNCASE_WORD)
-              state->wbuf[state->curpos] = towlower (state->wbuf[state->curpos]);
-            else
-            {
-              state->wbuf[state->curpos] = towupper (state->wbuf[state->curpos]);
-              if (ch == OP_EDITOR_CAPITALIZE_WORD)
-                ch = OP_EDITOR_DOWNCASE_WORD;
-            }
-            state->curpos++;
-          }
-          break;
+          while (state->curpos < state->lastchar
+                 && !iswspace (state->wbuf[state->curpos]))
+            ++state->curpos;
+        }
+        break;
 
-        case OP_EDITOR_DELETE_CHAR:
-          if (state->curpos == state->lastchar)
-            BEEP ();
-          else
-          {
-            i = state->curpos;
-            while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
-              ++i;
-            if (i < state->lastchar)
-              ++i;
-            while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
-              ++i;
-            memmove (state->wbuf + state->curpos, state->wbuf + i, (state->lastchar - i) * sizeof (wchar_t));
-            state->lastchar -= i - state->curpos;
-          }
+      case OP_EDITOR_CAPITALIZE_WORD:
+      case OP_EDITOR_UPCASE_WORD:
+      case OP_EDITOR_DOWNCASE_WORD:
+        if (state->curpos == state->lastchar) {
+          BEEP ();
           break;
-
-        case OP_EDITOR_KILL_WORD:
-          /* delete to begining of word */
-          if (state->curpos != 0)
-          {
-            i = state->curpos;
-            while (i && iswspace (state->wbuf[i - 1]))
-              --i;
-            if (i)
-            {
-              if (iswalnum (state->wbuf[i - 1]))
-              {
-                for (--i; i && iswalnum (state->wbuf[i - 1]); i--)
-                  ;
-              }
-              else
-                --i;
-            }
-            memmove (state->wbuf + i, state->wbuf + state->curpos,
-                     (state->lastchar - state->curpos) * sizeof (wchar_t));
-            state->lastchar += i - state->curpos;
-            state->curpos = i;
+        }
+        while (state->curpos && !iswspace (state->wbuf[state->curpos]))
+          --state->curpos;
+        while (state->curpos < state->lastchar
+               && iswspace (state->wbuf[state->curpos]))
+          ++state->curpos;
+        while (state->curpos < state->lastchar
+               && !iswspace (state->wbuf[state->curpos])) {
+          if (ch == OP_EDITOR_DOWNCASE_WORD)
+            state->wbuf[state->curpos] =
+              towlower (state->wbuf[state->curpos]);
+          else {
+            state->wbuf[state->curpos] =
+              towupper (state->wbuf[state->curpos]);
+            if (ch == OP_EDITOR_CAPITALIZE_WORD)
+              ch = OP_EDITOR_DOWNCASE_WORD;
           }
-          break;
+          state->curpos++;
+        }
+        break;
 
-        case OP_EDITOR_KILL_EOW:
-          /* delete to end of word */
-          for (i = state->curpos;
-               i < state->lastchar && iswspace (state->wbuf[i]); i++)
-            ;
-          for (; i < state->lastchar && !iswspace (state->wbuf[i]); i++)
-            ;
+      case OP_EDITOR_DELETE_CHAR:
+        if (state->curpos == state->lastchar)
+          BEEP ();
+        else {
+          i = state->curpos;
+          while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
+            ++i;
+          if (i < state->lastchar)
+            ++i;
+          while (i < state->lastchar && COMB_CHAR (state->wbuf[i]))
+            ++i;
           memmove (state->wbuf + state->curpos, state->wbuf + i,
                    (state->lastchar - i) * sizeof (wchar_t));
-          state->lastchar += state->curpos - i;
-          break;
+          state->lastchar -= i - state->curpos;
+        }
+        break;
 
-        case OP_EDITOR_BUFFY_CYCLE:
-          if (flags & M_EFILE)
-          {
-            first = 1; /* clear input if user types a real key later */
-            my_wcstombs (buf, buflen, state->wbuf, state->curpos);
-            mutt_buffy (buf, buflen);
-            state->curpos = state->lastchar = my_mbstowcs (&state->wbuf, &state->wbuflen, 0, buf);
-            break;
-          }
-          else if (!(flags & M_FILE))
-            goto self_insert;
-          /* fall through to completion routine (M_FILE) */
-
-        case OP_EDITOR_COMPLETE:
-          state->tabs++;
-          if (flags & M_CMD)
-          {
-            for (i = state->curpos; i && state->wbuf[i-1] != ' '; i--)
-              ;
-            my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
-            if (tempbuf && templen == state->lastchar - i &&
-                !memcmp (tempbuf, state->wbuf + i, (state->lastchar - i) * sizeof (wchar_t)))
-            {
-              mutt_select_file (buf, buflen, (flags & M_EFILE) ? M_SEL_FOLDER : 0);
-              set_option (OPTNEEDREDRAW);
-              if (*buf)
-                replace_part (state, i, buf);
-              rv = 1; 
-              goto bye;
-            }
-            if (!mutt_complete (buf, buflen))
-            {
-              templen = state->lastchar - i;
-              safe_realloc (&tempbuf, templen * sizeof (wchar_t));
+      case OP_EDITOR_KILL_WORD:
+        /* delete to begining of word */
+        if (state->curpos != 0) {
+          i = state->curpos;
+          while (i && iswspace (state->wbuf[i - 1]))
+            --i;
+          if (i) {
+            if (iswalnum (state->wbuf[i - 1])) {
+              for (--i; i && iswalnum (state->wbuf[i - 1]); i--);
             }
             else
-              BEEP ();
-
-            replace_part (state, i, buf);
+              --i;
           }
-          else if (flags & M_ALIAS)
-          {
-            /* invoke the alias-menu to get more addresses */
-            for (i = state->curpos; i && state->wbuf[i-1] != ',' && 
-                 state->wbuf[i-1] != ':'; i--)
-              ;
-            for (; i < state->lastchar && state->wbuf[i] == ' '; i++)
-              ;
-            my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
-            r = mutt_alias_complete (buf, buflen);
-            replace_part (state, i, buf);
-            if (!r)
-            {
-              rv = 1;
-              goto bye;
-            }
-            break;
+          memmove (state->wbuf + i, state->wbuf + state->curpos,
+                   (state->lastchar - state->curpos) * sizeof (wchar_t));
+          state->lastchar += i - state->curpos;
+          state->curpos = i;
+        }
+        break;
+
+      case OP_EDITOR_KILL_EOW:
+        /* delete to end of word */
+        for (i = state->curpos;
+             i < state->lastchar && iswspace (state->wbuf[i]); i++);
+        for (; i < state->lastchar && !iswspace (state->wbuf[i]); i++);
+        memmove (state->wbuf + state->curpos, state->wbuf + i,
+                 (state->lastchar - i) * sizeof (wchar_t));
+        state->lastchar += state->curpos - i;
+        break;
+
+      case OP_EDITOR_BUFFY_CYCLE:
+        if (flags & M_EFILE) {
+          first = 1;            /* clear input if user types a real key later */
+          my_wcstombs (buf, buflen, state->wbuf, state->curpos);
+          mutt_buffy (buf, buflen);
+          state->curpos = state->lastchar =
+            my_mbstowcs (&state->wbuf, &state->wbuflen, 0, buf);
+          break;
+        }
+        else if (!(flags & M_FILE))
+          goto self_insert;
+        /* fall through to completion routine (M_FILE) */
+
+      case OP_EDITOR_COMPLETE:
+        state->tabs++;
+        if (flags & M_CMD) {
+          for (i = state->curpos; i && state->wbuf[i - 1] != ' '; i--);
+          my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
+          if (tempbuf && templen == state->lastchar - i &&
+              !memcmp (tempbuf, state->wbuf + i,
+                       (state->lastchar - i) * sizeof (wchar_t))) {
+            mutt_select_file (buf, buflen,
+                              (flags & M_EFILE) ? M_SEL_FOLDER : 0);
+            set_option (OPTNEEDREDRAW);
+            if (*buf)
+              replace_part (state, i, buf);
+            rv = 1;
+            goto bye;
           }
-          else if (flags & M_COMMAND)
-          {
-            my_wcstombs (buf, buflen, state->wbuf, state->curpos);
-            i = strlen (buf);
-            if (i && buf[i - 1] == '=' &&
-                mutt_var_value_complete (buf, buflen, i))
-              state->tabs = 0;
-            else if (!mutt_command_complete (buf, buflen, i, state->tabs))
-              BEEP ();
-            replace_part (state, 0, buf);
+          if (!mutt_complete (buf, buflen)) {
+            templen = state->lastchar - i;
+            safe_realloc (&tempbuf, templen * sizeof (wchar_t));
           }
-          else if (flags & (M_FILE | M_EFILE))
-          {
-            my_wcstombs (buf, buflen, state->wbuf, state->curpos);
-
-            /* see if the path has changed from the last time */
-            if ((!tempbuf && !state->lastchar) || (tempbuf && templen == state->lastchar &&
-                !memcmp (tempbuf, state->wbuf, state->lastchar * sizeof (wchar_t))))
-            {
-              _mutt_select_file (buf, buflen, 
-                                 ((flags & M_EFILE) ? M_SEL_FOLDER : 0) | (multiple ? M_SEL_MULTI : 0), 
-                                 files, numfiles);
-              set_option (OPTNEEDREDRAW);
-              if (*buf)
-              {
-                mutt_pretty_mailbox (buf);
-                if (!pass)
-                  mutt_history_add (hclass, buf);
-                rv = 0;
-                goto bye;
-              }
-
-              /* file selection cancelled */
-              rv = 1;
-              goto bye;
-            }
+          else
+            BEEP ();
 
-            if (!mutt_complete (buf, buflen))
-            {
-              templen = state->lastchar;
-              safe_realloc (&tempbuf, templen * sizeof (wchar_t));
-              memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t));
-            }
-            else
-              BEEP (); /* let the user know that nothing matched */
-            replace_part (state, 0, buf);
+          replace_part (state, i, buf);
+        }
+        else if (flags & M_ALIAS) {
+          /* invoke the alias-menu to get more addresses */
+          for (i = state->curpos; i && state->wbuf[i - 1] != ',' &&
+               state->wbuf[i - 1] != ':'; i--);
+          for (; i < state->lastchar && state->wbuf[i] == ' '; i++);
+          my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
+          r = mutt_alias_complete (buf, buflen);
+          replace_part (state, i, buf);
+          if (!r) {
+            rv = 1;
+            goto bye;
           }
-          else
-            goto self_insert;
           break;
-
-        case OP_EDITOR_COMPLETE_QUERY:
-          if (flags & M_ALIAS)
-          {
-            /* invoke the query-menu to get more addresses */
-            if ((i = state->curpos))
-            {
-              for (; i && state->wbuf[i - 1] != ','; i--)
-                ;
-              for (; i < state->curpos && state->wbuf[i] == ' '; i++)
-                ;
+        }
+        else if (flags & M_COMMAND) {
+          my_wcstombs (buf, buflen, state->wbuf, state->curpos);
+          i = strlen (buf);
+          if (i && buf[i - 1] == '=' &&
+              mutt_var_value_complete (buf, buflen, i))
+            state->tabs = 0;
+          else if (!mutt_command_complete (buf, buflen, i, state->tabs))
+            BEEP ();
+          replace_part (state, 0, buf);
+        }
+        else if (flags & (M_FILE | M_EFILE)) {
+          my_wcstombs (buf, buflen, state->wbuf, state->curpos);
+
+          /* see if the path has changed from the last time */
+          if ((!tempbuf && !state->lastchar)
+              || (tempbuf && templen == state->lastchar
+                  && !memcmp (tempbuf, state->wbuf,
+                              state->lastchar * sizeof (wchar_t)))) {
+            _mutt_select_file (buf, buflen,
+                               ((flags & M_EFILE) ? M_SEL_FOLDER : 0) |
+                               (multiple ? M_SEL_MULTI : 0), files, numfiles);
+            set_option (OPTNEEDREDRAW);
+            if (*buf) {
+              mutt_pretty_mailbox (buf);
+              if (!pass)
+                mutt_history_add (hclass, buf);
+              rv = 0;
+              goto bye;
             }
 
-            my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
-            mutt_query_complete (buf, buflen);
-            replace_part (state, i, buf);
-
-            rv = 1; 
+            /* file selection cancelled */
+            rv = 1;
             goto bye;
           }
+
+          if (!mutt_complete (buf, buflen)) {
+            templen = state->lastchar;
+            safe_realloc (&tempbuf, templen * sizeof (wchar_t));
+            memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t));
+          }
           else
-            goto self_insert;
+            BEEP ();            /* let the user know that nothing matched */
+          replace_part (state, 0, buf);
+        }
+        else
+          goto self_insert;
+        break;
 
-        case OP_EDITOR_QUOTE_CHAR:
-          {
-            event_t event;
-            /*ADDCH (LastKey);*/
-            event = mutt_getch ();
-            if (event.ch != -1)
-            {
-              LastKey = event.ch;
-              goto self_insert;
-            }
+      case OP_EDITOR_COMPLETE_QUERY:
+        if (flags & M_ALIAS) {
+          /* invoke the query-menu to get more addresses */
+          if ((i = state->curpos)) {
+            for (; i && state->wbuf[i - 1] != ','; i--);
+            for (; i < state->curpos && state->wbuf[i] == ' '; i++);
           }
 
-        case OP_EDITOR_TRANSPOSE_CHARS:
-          if (state->lastchar < 2)
-            BEEP ();
-          else
-        {
-            wchar_t t;
+          my_wcstombs (buf, buflen, state->wbuf + i, state->curpos - i);
+          mutt_query_complete (buf, buflen);
+          replace_part (state, i, buf);
 
-            if (state->curpos == 0)
-              state->curpos = 2;
-            else if (state->curpos < state->lastchar)
-              ++state->curpos;
+          rv = 1;
+          goto bye;
+        }
+        else
+          goto self_insert;
+
+      case OP_EDITOR_QUOTE_CHAR:
+        {
+          event_t event;
 
-            t = state->wbuf[state->curpos - 2];
-            state->wbuf[state->curpos - 2] = state->wbuf[state->curpos - 1];
-            state->wbuf[state->curpos - 1] = t;
+          /*ADDCH (LastKey); */
+          event = mutt_getch ();
+          if (event.ch != -1) {
+            LastKey = event.ch;
+            goto self_insert;
           }
-          break;
+        }
 
-        default:
+      case OP_EDITOR_TRANSPOSE_CHARS:
+        if (state->lastchar < 2)
           BEEP ();
+        else {
+          wchar_t t;
+
+          if (state->curpos == 0)
+            state->curpos = 2;
+          else if (state->curpos < state->lastchar)
+            ++state->curpos;
+
+          t = state->wbuf[state->curpos - 2];
+          state->wbuf[state->curpos - 2] = state->wbuf[state->curpos - 1];
+          state->wbuf[state->curpos - 1] = t;
+        }
+        break;
+
+      default:
+        BEEP ();
       }
     }
-    else
-    {
-      
-self_insert:
+    else {
+
+    self_insert:
 
       state->tabs = 0;
       /* use the raw keypress */
       ch = LastKey;
 
-      if ((ch == '#') && (flags & M_LASTFOLDER))
-      {
+      if ((ch == '#') && (flags & M_LASTFOLDER)) {
         rv = 2;
         my_wcstombs (buf, buflen, state->wbuf, state->lastchar);
         goto bye;
       }
-      
+
 #ifdef KEY_ENTER
       /* treat ENTER the same as RETURN */
       if (ch == KEY_ENTER)
@@ -642,70 +624,66 @@ self_insert:
 
         c = ch;
         k = mbrtowc (&wc, &c, 1, &mbstate);
-        if (k == (size_t)(-2))
+        if (k == (size_t) (-2))
           continue;
-        else if (k && k != 1)
-        {
+        else if (k && k != 1) {
           memset (&mbstate, 0, sizeof (mbstate));
           continue;
         }
       }
 
-      if (first && (flags & M_CLEAR))
-      {
+      if (first && (flags & M_CLEAR)) {
         first = 0;
-        if (IsWPrint (wc)) /* why? */
+        if (IsWPrint (wc))      /* why? */
           state->curpos = state->lastchar = 0;
       }
 
-      if (wc == '\r' || wc == '\n')
-      {
+      if (wc == '\r' || wc == '\n') {
         /* Convert from wide characters */
         my_wcstombs (buf, buflen, state->wbuf, state->lastchar);
         if (!pass)
           mutt_history_add (hclass, buf);
 
-        if (multiple)
-        {
+        if (multiple) {
           char **tfiles;
+
           *numfiles = 1;
           tfiles = safe_calloc (*numfiles, sizeof (char *));
           mutt_expand_path (buf, buflen);
           tfiles[0] = safe_strdup (buf);
           *files = tfiles;
         }
-        rv = 0; 
+        rv = 0;
         goto bye;
       }
-      else if (wc && (wc < ' ' || IsWPrint (wc))) /* why? */
-      {
-        if (state->lastchar >= state->wbuflen)
-        {
+      else if (wc && (wc < ' ' || IsWPrint (wc))) {     /* why? */
+        if (state->lastchar >= state->wbuflen) {
           state->wbuflen = state->lastchar + 20;
           safe_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t));
         }
-        memmove (state->wbuf + state->curpos + 1, state->wbuf + state->curpos, (state->lastchar - state->curpos) * sizeof (wchar_t));
+        memmove (state->wbuf + state->curpos + 1, state->wbuf + state->curpos,
+                 (state->lastchar - state->curpos) * sizeof (wchar_t));
         state->wbuf[state->curpos++] = wc;
         state->lastchar++;
       }
-      else
-      {
+      else {
         mutt_flushinp ();
         BEEP ();
       }
     }
   }
-  
-  bye:
-  
+
+bye:
+
   FREE (&tempbuf);
   return rv;
 }
 
-void mutt_free_enter_state (ENTER_STATE **esp)
+void mutt_free_enter_state (ENTER_STATE ** esp)
 {
-  if (!esp) return;
-  
+  if (!esp)
+    return;
+
   FREE (&(*esp)->wbuf);
   FREE (esp);
 }
index 2dda7fd..5933042 100644 (file)
--- a/extlib.c
+++ b/extlib.c
@@ -17,7 +17,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /* 
  * Some simple dummies, so we can reuse the routines from
@@ -40,4 +40,3 @@ void mutt_exit (int code)
 {
   exit (code);
 }
-
index 862ebbd..7391a99 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
  * to the specified handles.
  */
 pid_t
-mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
-                      int fdin, int fdout, int fderr)
+mutt_create_filter_fd (const char *cmd, FILE ** in, FILE ** out, FILE ** err,
+                       int fdin, int fdout, int fderr)
 {
   int pin[2], pout[2], perr[2], thepid;
 
-  if (in)
-  {
+  if (in) {
     *in = 0;
     if (pipe (pin) == -1)
       return (-1);
   }
 
-  if (out)
-  {
+  if (out) {
     *out = 0;
-    if (pipe (pout) == -1)
-    {
-      if (in)
-      {
-       close (pin[0]);
-       close (pin[1]);
+    if (pipe (pout) == -1) {
+      if (in) {
+        close (pin[0]);
+        close (pin[1]);
       }
       return (-1);
     }
   }
 
-  if (err)
-  {
+  if (err) {
     *err = 0;
-    if (pipe (perr) == -1)
-    {
-      if (in)
-      {
-       close (pin[0]);
-       close (pin[1]);
+    if (pipe (perr) == -1) {
+      if (in) {
+        close (pin[0]);
+        close (pin[1]);
       }
-      if (out)
-      {
-       close (pout[0]);
-       close (pout[1]);
+      if (out) {
+        close (pout[0]);
+        close (pout[1]);
       }
       return (-1);
     }
@@ -77,42 +69,35 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
 
   mutt_block_signals_system ();
 
-  if ((thepid = fork ()) == 0)
-  {
+  if ((thepid = fork ()) == 0) {
     mutt_unblock_signals_system (0);
 
-    if (in)
-    {
+    if (in) {
       close (pin[1]);
       dup2 (pin[0], 0);
       close (pin[0]);
     }
-    else if (fdin != -1)
-    {
+    else if (fdin != -1) {
       dup2 (fdin, 0);
       close (fdin);
     }
 
-    if (out)
-    {
+    if (out) {
       close (pout[0]);
       dup2 (pout[1], 1);
       close (pout[1]);
     }
-    else if (fdout != -1)
-    {
+    else if (fdout != -1) {
       dup2 (fdout, 1);
       close (fdout);
     }
 
-    if (err)
-    {
+    if (err) {
       close (perr[0]);
       dup2 (perr[1], 2);
       close (perr[1]);
     }
-    else if (fderr != -1)
-    {
+    else if (fderr != -1) {
       dup2 (fderr, 2);
       close (fderr);
     }
@@ -120,24 +105,20 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
     execl (EXECSHELL, "sh", "-c", cmd, NULL);
     _exit (127);
   }
-  else if (thepid == -1)
-  {
+  else if (thepid == -1) {
     mutt_unblock_signals_system (1);
 
-    if (in)
-    {
+    if (in) {
       close (pin[0]);
       close (pin[1]);
     }
-    
-    if (out)
-    {
+
+    if (out) {
       close (pout[0]);
       close (pout[1]);
     }
 
-    if (err)
-    {
+    if (err) {
       close (perr[0]);
       close (perr[1]);
     }
@@ -145,20 +126,17 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
     return (-1);
   }
 
-  if (out)
-  {
+  if (out) {
     close (pout[1]);
     *out = fdopen (pout[0], "r");
   }
 
-  if (in)
-  {
+  if (in) {
     close (pin[0]);
     *in = fdopen (pin[1], "w");
   }
 
-  if (err)
-  {
+  if (err) {
     close (perr[1]);
     *err = fdopen (perr[0], "r");
   }
@@ -166,7 +144,7 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
   return (thepid);
 }
 
-pid_t mutt_create_filter (const char *s, FILE **in, FILE **out, FILE **err)
+pid_t mutt_create_filter (const char *s, FILE ** in, FILE ** out, FILE ** err)
 {
   return (mutt_create_filter_fd (s, in, out, err, -1, -1, -1));
 }
@@ -174,10 +152,10 @@ pid_t mutt_create_filter (const char *s, FILE **in, FILE **out, FILE **err)
 int mutt_wait_filter (pid_t pid)
 {
   int rc;
-  
+
   waitpid (pid, &rc, 0);
   mutt_unblock_signals_system (1);
   rc = WIFEXITED (rc) ? WEXITSTATUS (rc) : -1;
-  
+
   return rc;
 }
diff --git a/flags.c b/flags.c
index 8cc3c42..8e1bbdb 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include "imap_private.h"
 #endif
 
-void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
+void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
 {
   int changed = h->changed;
   int deleted = ctx->deleted;
   int tagged = ctx->tagged;
 
   if (ctx->readonly && flag != M_TAG)
-    return; /* don't modify anything if we are read-only */
+    return;                     /* don't modify anything if we are read-only */
 
-  switch (flag)
-  {
-    case M_DELETE:
+  switch (flag) {
+  case M_DELETE:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_DELETE))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_DELETE))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (!h->deleted && !ctx->readonly)
-       {
-         h->deleted = 1;
-         if (upd_ctx) ctx->deleted++;
+    if (bf) {
+      if (!h->deleted && !ctx->readonly) {
+        h->deleted = 1;
+        if (upd_ctx)
+          ctx->deleted++;
 #ifdef USE_IMAP
-          /* deleted messages aren't treated as changed elsewhere so that the
-           * purge-on-sync option works correctly. This isn't applicable here */
-          if (ctx && ctx->magic == M_IMAP)
-          {
-            h->changed = 1;
-           if (upd_ctx) ctx->changed = 1;
-          }
+        /* deleted messages aren't treated as changed elsewhere so that the
+         * purge-on-sync option works correctly. This isn't applicable here */
+        if (ctx && ctx->magic == M_IMAP) {
+          h->changed = 1;
+          if (upd_ctx)
+            ctx->changed = 1;
+        }
 #endif
-       }
       }
-      else if (h->deleted)
-      {
-       h->deleted = 0;
-       if (upd_ctx)
-       {
-         ctx->deleted--;
-         if (h->appended)
-           ctx->appended--;
-       }
-       h->appended = 0; /* when undeleting, also reset the appended flag */
+    }
+    else if (h->deleted) {
+      h->deleted = 0;
+      if (upd_ctx) {
+        ctx->deleted--;
+        if (h->appended)
+          ctx->appended--;
+      }
+      h->appended = 0;          /* when undeleting, also reset the appended flag */
 #ifdef USE_IMAP
-        /* see my comment above */
-       if (ctx->magic == M_IMAP) 
-       {
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
-#endif
-       /* 
-        * If the user undeletes a message which is marked as
-        * "trash" in the maildir folder on disk, the folder has
-        * been changed, and is marked accordingly.  However, we do
-        * _not_ mark the message itself changed, because trashing
-        * is checked in specific code in the maildir folder
-        * driver. 
-        */
-       if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
-         ctx->changed = 1;
+      /* see my comment above */
+      if (ctx->magic == M_IMAP) {
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      break;
-
-    case M_APPENDED:
-      if (bf)
-      {
-       if (!h->appended)
-       {
-         h->appended = 1;
-         if (upd_ctx) ctx->appended++;
-       }
+#endif
+      /* 
+       * If the user undeletes a message which is marked as
+       * "trash" in the maildir folder on disk, the folder has
+       * been changed, and is marked accordingly.  However, we do
+       * _not_ mark the message itself changed, because trashing
+       * is checked in specific code in the maildir folder
+       * driver. 
+       */
+      if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
+        ctx->changed = 1;
+    }
+    break;
+
+  case M_APPENDED:
+    if (bf) {
+      if (!h->appended) {
+        h->appended = 1;
+        if (upd_ctx)
+          ctx->appended++;
       }
-      break;
+    }
+    break;
 
-    case M_PURGED:
-      if (bf)
-      {
-       if (!h->purged)
-         h->purged = 1;
-      }
-      else if (h->purged)
-       h->purged = 0;
-      break;
+  case M_PURGED:
+    if (bf) {
+      if (!h->purged)
+        h->purged = 1;
+    }
+    else if (h->purged)
+      h->purged = 0;
+    break;
 
-    case M_NEW:
+  case M_NEW:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_SEEN))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (h->read || h->old)
-       {
-         h->old = 0;
-         if (upd_ctx) ctx->new++;
-         if (h->read)
-         {
-           h->read = 0;
-           if (upd_ctx) ctx->unread++;
-         }
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
+    if (bf) {
+      if (h->read || h->old) {
+        h->old = 0;
+        if (upd_ctx)
+          ctx->new++;
+        if (h->read) {
+          h->read = 0;
+          if (upd_ctx)
+            ctx->unread++;
+        }
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      else if (!h->read)
-      {
-       if (!h->old)
-         if (upd_ctx) ctx->new--;
-       h->read = 1;
-       if (upd_ctx) ctx->unread--;
-       h->changed = 1;
-       if (upd_ctx) ctx->changed = 1;
-      }
-      break;
+    }
+    else if (!h->read) {
+      if (!h->old)
+        if (upd_ctx)
+          ctx->new--;
+      h->read = 1;
+      if (upd_ctx)
+        ctx->unread--;
+      h->changed = 1;
+      if (upd_ctx)
+        ctx->changed = 1;
+    }
+    break;
 
-    case M_OLD:
+  case M_OLD:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_SEEN))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (!h->old)
-       {
-         h->old = 1;
-         if (!h->read)
-           if (upd_ctx) ctx->new--;
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
-      }
-      else if (h->old)
-      {
-       h->old = 0;
-       if (!h->read)
-         if (upd_ctx) ctx->new++;
-       h->changed = 1;
-       if (upd_ctx) ctx->changed = 1;
+    if (bf) {
+      if (!h->old) {
+        h->old = 1;
+        if (!h->read)
+          if (upd_ctx)
+            ctx->new--;
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      break;
+    }
+    else if (h->old) {
+      h->old = 0;
+      if (!h->read)
+        if (upd_ctx)
+          ctx->new++;
+      h->changed = 1;
+      if (upd_ctx)
+        ctx->changed = 1;
+    }
+    break;
 
-    case M_READ:
+  case M_READ:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_SEEN))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_SEEN))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (!h->read)
-       {
-         h->read = 1;
-         if (upd_ctx) ctx->unread--;
-         if (!h->old)
-           if (upd_ctx) ctx->new--;
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
-      }
-      else if (h->read)
-      {
-       h->read = 0;
-       if (upd_ctx) ctx->unread++;
-       if (!h->old)
-         if (upd_ctx) ctx->new++;
-       h->changed = 1;
-       if (upd_ctx) ctx->changed = 1;
+    if (bf) {
+      if (!h->read) {
+        h->read = 1;
+        if (upd_ctx)
+          ctx->unread--;
+        if (!h->old)
+          if (upd_ctx)
+            ctx->new--;
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      break;
+    }
+    else if (h->read) {
+      h->read = 0;
+      if (upd_ctx)
+        ctx->unread++;
+      if (!h->old)
+        if (upd_ctx)
+          ctx->new++;
+      h->changed = 1;
+      if (upd_ctx)
+        ctx->changed = 1;
+    }
+    break;
 
-    case M_REPLIED:
+  case M_REPLIED:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_WRITE))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_WRITE))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (!h->replied)
-       {
-         h->replied = 1;
-         if (!h->read)
-         {
-           h->read = 1;
-           if (upd_ctx) ctx->unread--;
-           if (!h->old)
-             if (upd_ctx) ctx->new--;
-         }
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
+    if (bf) {
+      if (!h->replied) {
+        h->replied = 1;
+        if (!h->read) {
+          h->read = 1;
+          if (upd_ctx)
+            ctx->unread--;
+          if (!h->old)
+            if (upd_ctx)
+              ctx->new--;
+        }
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      else if (h->replied)
-      {
-       h->replied = 0;
-       h->changed = 1;
-       if (upd_ctx) ctx->changed = 1;
-      }
-      break;
+    }
+    else if (h->replied) {
+      h->replied = 0;
+      h->changed = 1;
+      if (upd_ctx)
+        ctx->changed = 1;
+    }
+    break;
 
-    case M_FLAG:
+  case M_FLAG:
 
 #ifdef USE_IMAP
-       if (ctx && ctx->magic == M_IMAP)
-               if (mutt_bit_isset (((IMAP_DATA *)ctx->data)->capabilities, ACL) \
-               && !mutt_bit_isset(((IMAP_DATA *)ctx->data)->rights,IMAP_ACL_WRITE))
-                       return;
+    if (ctx && ctx->magic == M_IMAP)
+      if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
+          && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
+                              IMAP_ACL_WRITE))
+        return;
 #endif
 
-      if (bf)
-      {
-       if (!h->flagged)
-       {
-         h->flagged = bf;
-         if (upd_ctx) ctx->flagged++;
-         h->changed = 1;
-         if (upd_ctx) ctx->changed = 1;
-       }
-      }
-      else if (h->flagged)
-      {
-       h->flagged = 0;
-       if (upd_ctx) ctx->flagged--;
-       h->changed = 1;
-       if (upd_ctx) ctx->changed = 1;
+    if (bf) {
+      if (!h->flagged) {
+        h->flagged = bf;
+        if (upd_ctx)
+          ctx->flagged++;
+        h->changed = 1;
+        if (upd_ctx)
+          ctx->changed = 1;
       }
-      break;
-
-    case M_TAG:
-      if (bf)
-      {
-       if (!h->tagged)
-       {
-         h->tagged = 1;
-         if (upd_ctx) ctx->tagged++;
-       }
-      }
-      else if (h->tagged)
-      {
-       h->tagged = 0;
-       if (upd_ctx) ctx->tagged--;
+    }
+    else if (h->flagged) {
+      h->flagged = 0;
+      if (upd_ctx)
+        ctx->flagged--;
+      h->changed = 1;
+      if (upd_ctx)
+        ctx->changed = 1;
+    }
+    break;
+
+  case M_TAG:
+    if (bf) {
+      if (!h->tagged) {
+        h->tagged = 1;
+        if (upd_ctx)
+          ctx->tagged++;
       }
-      break;
+    }
+    else if (h->tagged) {
+      h->tagged = 0;
+      if (upd_ctx)
+        ctx->tagged--;
+    }
+    break;
   }
 
-  mutt_set_header_color(ctx, h);
+  mutt_set_header_color (ctx, h);
 
   /* if the message status has changed, we need to invalidate the cached
    * search results so that any future search will match the current status
    * of this message and not what it was at the time it was last searched.
    */
-  if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged))
+  if (h->searched
+      && (changed != h->changed || deleted != ctx->deleted
+          || tagged != ctx->tagged))
     h->searched = 0;
-       draw_sidebar(0);
+  draw_sidebar (0);
 }
 
 void mutt_tag_set_flag (int flag, int bf)
@@ -314,13 +322,13 @@ void mutt_tag_set_flag (int flag, int bf)
     if (Context->hdrs[Context->v2r[j]]->tagged)
       mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
 }
-int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
+int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
 {
   THREAD *start, *cur = hdr->thread;
-  
-  if ((Sort & SORT_MASK) != SORT_THREADS)
-  {
+
+  if ((Sort & SORT_MASK) != SORT_THREADS) {
     mutt_error _("Threading is not enabled.");
+
     return (-1);
   }
 
@@ -328,15 +336,14 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
     while (cur->parent)
       cur = cur->parent;
   start = cur;
-  
+
   if (cur->message)
     mutt_set_flag (Context, cur->message, flag, bf);
 
   if ((cur = cur->child) == NULL)
     return (0);
 
-  FOREVER
-  {
+  FOREVER {
     if (cur->message)
       mutt_set_flag (Context, cur->message, flag, bf);
 
@@ -344,13 +351,11 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
       cur = cur->child;
     else if (cur->next)
       cur = cur->next;
-    else 
-    {
-      while (!cur->next)
-      {
-       cur = cur->parent;
-       if (cur == start)
-         return (0);
+    else {
+      while (!cur->next) {
+        cur = cur->parent;
+        if (cur == start)
+          return (0);
       }
       cur = cur->next;
     }
@@ -358,61 +363,60 @@ int mutt_thread_set_flag (HEADER *hdr, int flag, int bf, int subthread)
   /* not reached */
 }
 
-int mutt_change_flag (HEADER *h, int bf)
+int mutt_change_flag (HEADER * h, int bf)
 {
   int i, flag;
   event_t event;
 
-  mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ", bf ? _("Set flag") : _("Clear flag"));
+  mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
+            bf ? _("Set flag") : _("Clear flag"));
   clrtoeol ();
 
-  event = mutt_getch();
+  event = mutt_getch ();
   i = event.ch;
-  if (i == -1)
-  {
-    CLEARLINE (LINES-1);
+  if (i == -1) {
+    CLEARLINE (LINES - 1);
     return (-1);
   }
 
-  CLEARLINE (LINES-1);
-
-  switch (i)
-  {
-    case 'd':
-    case 'D':
-      flag = M_DELETE;
-      break;
-
-    case 'N':
-    case 'n':
-      flag = M_NEW;
-      break;
-
-    case 'o':
-    case 'O':
-      if (h)
-       mutt_set_flag (Context, h, M_READ, !bf);
-      else
-       mutt_tag_set_flag (M_READ, !bf);
-      flag = M_OLD;
-      break;
-
-    case 'r':
-    case 'R':
-      flag = M_REPLIED;
-      break;
-
-    case '*':
-      flag = M_TAG;
-      break;
-
-    case '!':
-      flag = M_FLAG;
-      break;
-
-    default:
-      BEEP ();
-      return (-1);
+  CLEARLINE (LINES - 1);
+
+  switch (i) {
+  case 'd':
+  case 'D':
+    flag = M_DELETE;
+    break;
+
+  case 'N':
+  case 'n':
+    flag = M_NEW;
+    break;
+
+  case 'o':
+  case 'O':
+    if (h)
+      mutt_set_flag (Context, h, M_READ, !bf);
+    else
+      mutt_tag_set_flag (M_READ, !bf);
+    flag = M_OLD;
+    break;
+
+  case 'r':
+  case 'R':
+    flag = M_REPLIED;
+    break;
+
+  case '*':
+    flag = M_TAG;
+    break;
+
+  case '!':
+    flag = M_FLAG;
+    break;
+
+  default:
+    BEEP ();
+    return (-1);
   }
 
   if (h)
diff --git a/from.c b/from.c
index c26d5b1..e8b190b 100644 (file)
--- a/from.c
+++ b/from.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -40,16 +40,16 @@ int mutt_check_month (const char *s)
   for (i = 0; i < 12; i++)
     if (mutt_strncasecmp (s, Months[i], 3) == 0)
       return (i);
-  return (-1); /* error */
+  return (-1);                  /* error */
 }
 
 static int is_day_name (const char *s)
 {
   int i;
 
-  if ((strlen (s) < 3) || !*(s + 3) || !ISSPACE (*(s+3)))
+  if ((strlen (s) < 3) || !*(s + 3) || !ISSPACE (*(s + 3)))
     return 0;
-  for (i=0; i<7; i++)
+  for (i = 0; i < 7; i++)
     if (mutt_strncasecmp (s, Weekdays[i], 3) == 0)
       return 1;
   return 0;
@@ -61,7 +61,7 @@ static int is_day_name (const char *s)
  * From [ <return-path> ] <weekday> <month> <day> <time> [ <timezone> ] <year>
  */
 
-int is_from (const char *s, char *path, size_t pathlen, time_t *tp)
+int is_from (const char *s, char *path, size_t pathlen, time_t * tp)
 {
   struct tm tm;
   int yr;
@@ -72,79 +72,79 @@ int is_from (const char *s, char *path, size_t pathlen, time_t *tp)
   if (mutt_strncmp ("From ", s, 5) != 0)
     return 0;
 
-  s = next_word (s); /* skip over the From part. */
+  s = next_word (s);            /* skip over the From part. */
   if (!*s)
     return 0;
 
   dprint (3, (debugfile, "\nis_from(): parsing: %s", s));
 
-  if (!is_day_name (s))
-  {
+  if (!is_day_name (s)) {
     const char *p;
     size_t len;
     short q = 0;
 
-    for (p = s; *p && (q || !ISSPACE (*p)); p++)
-    {
-      if (*p == '\\')
-      {
-       if (*++p == '\0') 
-         return 0;
+    for (p = s; *p && (q || !ISSPACE (*p)); p++) {
+      if (*p == '\\') {
+        if (*++p == '\0')
+          return 0;
       }
-      else if (*p == '"')
-      {
-       q = !q;
+      else if (*p == '"') {
+        q = !q;
       }
     }
-    
-    if (q || !*p) return 0;
-    
-    if (path)
-    {
+
+    if (q || !*p)
+      return 0;
+
+    if (path) {
       len = (size_t) (p - s);
       if (len + 1 > pathlen)
-       len = pathlen - 1;
+        len = pathlen - 1;
       memcpy (path, s, len);
       path[len] = 0;
       dprint (3, (debugfile, "is_from(): got return path: %s\n", path));
     }
-    
+
     s = p + 1;
     SKIPWS (s);
     if (!*s)
       return 0;
 
-    if (!is_day_name (s))
-    {
-      dprint(1, (debugfile, "is_from():  expected weekday, got: %s\n", s));
+    if (!is_day_name (s)) {
+      dprint (1, (debugfile, "is_from():  expected weekday, got: %s\n", s));
       return 0;
     }
   }
 
   s = next_word (s);
-  if (!*s) return 0;
+  if (!*s)
+    return 0;
 
   /* do a quick check to make sure that this isn't really the day of the week.
    * this could happen when receiving mail from a local user whose login name
    * is the same as a three-letter abbreviation of the day of the week.
    */
-  if (is_day_name (s))
-  {
+  if (is_day_name (s)) {
     s = next_word (s);
-    if (!*s) return 0;
+    if (!*s)
+      return 0;
   }
 
   /* now we should be on the month. */
-  if ((tm.tm_mon = mutt_check_month (s)) < 0) return 0;
+  if ((tm.tm_mon = mutt_check_month (s)) < 0)
+    return 0;
 
   /* day */
   s = next_word (s);
-  if (!*s) return 0;
-  if (sscanf (s, "%d", &tm.tm_mday) != 1) return 0;
+  if (!*s)
+    return 0;
+  if (sscanf (s, "%d", &tm.tm_mday) != 1)
+    return 0;
 
   /* time */
   s = next_word (s);
-  if (!*s) return 0;
+  if (!*s)
+    return 0;
 
   /* Accept either HH:MM or HH:MM:SS */
   if (sscanf (s, "%d:%d:%d", &tm.tm_hour, &tm.tm_min, &tm.tm_sec) == 3);
@@ -154,34 +154,40 @@ int is_from (const char *s, char *path, size_t pathlen, time_t *tp)
     return 0;
 
   s = next_word (s);
-  if (!*s) return 0;
+  if (!*s)
+    return 0;
 
   /* timezone? */
-  if (isalpha ((unsigned char) *s) || *s == '+' || *s == '-')
-  {
+  if (isalpha ((unsigned char) *s) || *s == '+' || *s == '-') {
     s = next_word (s);
-    if (!*s) return 0;
+    if (!*s)
+      return 0;
 
     /*
      * some places have two timezone fields after the time, e.g.
      *      From xxxx@yyyyyyy.fr Wed Aug  2 00:39:12 MET DST 1995
      */
-    if (isalpha ((unsigned char) *s))
-    {
+    if (isalpha ((unsigned char) *s)) {
       s = next_word (s);
-      if (!*s) return 0;
+      if (!*s)
+        return 0;
     }
   }
 
   /* year */
-  if (sscanf (s, "%d", &yr) != 1) return 0;
+  if (sscanf (s, "%d", &yr) != 1)
+    return 0;
   tm.tm_year = yr > 1900 ? yr - 1900 : (yr < 70 ? yr + 100 : yr);
-  
-  dprint (3,(debugfile, "is_from(): month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
-            tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year));
+
+  dprint (3,
+          (debugfile,
+           "is_from(): month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
+           tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
+           tm.tm_year));
 
   tm.tm_isdst = -1;
 
-  if (tp) *tp = mutt_mktime (&tm, 0);
+  if (tp)
+    *tp = mutt_mktime (&tm, 0);
   return 1;
 }
index 4bf22ee..8b0c3cc 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * This file contains the structures needed to parse ``bind'' commands, as
  */
 
 struct binding_t OpGeneric[] = {
-  { "top-page",                OP_TOP_PAGE,            "H" },
-  { "next-entry",      OP_NEXT_ENTRY,          "j" },
-  { "previous-entry",  OP_PREV_ENTRY,          "k" },
-  { "bottom-page",     OP_BOTTOM_PAGE,         "L" },
-  { "refresh",         OP_REDRAW,              "\014" },
-  { "middle-page",     OP_MIDDLE_PAGE,         "M" },
-  { "search-next",     OP_SEARCH_NEXT,         "n" },
-  { "exit",            OP_EXIT,                "q" },
-  { "tag-entry",       OP_TAG,                 "t" },
-  { "next-page",       OP_NEXT_PAGE,           "z" },
-  { "previous-page",   OP_PREV_PAGE,           "Z" },
-  { "last-entry",      OP_LAST_ENTRY,          "*" },
-  { "first-entry",     OP_FIRST_ENTRY,         "=" },
-  { "enter-command",   OP_ENTER_COMMAND,       ":" },
-  { "next-line",       OP_NEXT_LINE,           ">" },
-  { "previous-line",   OP_PREV_LINE,           "<" },
-  { "half-up",         OP_HALF_UP,             "[" },
-  { "half-down",       OP_HALF_DOWN,           "]" },
-  { "help",            OP_HELP,                "?" },
-  { "tag-prefix",      OP_TAG_PREFIX,          ";" },
-  { "tag-prefix-cond", OP_TAG_PREFIX_COND,     NULL },
-  { "end-cond",                OP_END_COND,            NULL },
-  { "shell-escape",    OP_SHELL_ESCAPE,        "!" },
-  { "select-entry",    OP_GENERIC_SELECT_ENTRY,M_ENTER_S },
-  { "search",          OP_SEARCH,              "/" },
-  { "search-reverse",  OP_SEARCH_REVERSE,      "\033/" },
-  { "search-opposite", OP_SEARCH_OPPOSITE,     NULL },
-  { "jump",            OP_JUMP,                NULL },
-  { "current-top",      OP_CURRENT_TOP,                NULL },
-  { "current-middle",   OP_CURRENT_MIDDLE,     NULL },
-  { "current-bottom",   OP_CURRENT_BOTTOM,     NULL },
-  { "what-key",                OP_WHAT_KEY,            NULL },
-  { NULL,              0,                      NULL }
+  {"top-page", OP_TOP_PAGE, "H"},
+  {"next-entry", OP_NEXT_ENTRY, "j"},
+  {"previous-entry", OP_PREV_ENTRY, "k"},
+  {"bottom-page", OP_BOTTOM_PAGE, "L"},
+  {"refresh", OP_REDRAW, "\014"},
+  {"middle-page", OP_MIDDLE_PAGE, "M"},
+  {"search-next", OP_SEARCH_NEXT, "n"},
+  {"exit", OP_EXIT, "q"},
+  {"tag-entry", OP_TAG, "t"},
+  {"next-page", OP_NEXT_PAGE, "z"},
+  {"previous-page", OP_PREV_PAGE, "Z"},
+  {"last-entry", OP_LAST_ENTRY, "*"},
+  {"first-entry", OP_FIRST_ENTRY, "="},
+  {"enter-command", OP_ENTER_COMMAND, ":"},
+  {"next-line", OP_NEXT_LINE, ">"},
+  {"previous-line", OP_PREV_LINE, "<"},
+  {"half-up", OP_HALF_UP, "["},
+  {"half-down", OP_HALF_DOWN, "]"},
+  {"help", OP_HELP, "?"},
+  {"tag-prefix", OP_TAG_PREFIX, ";"},
+  {"tag-prefix-cond", OP_TAG_PREFIX_COND, NULL},
+  {"end-cond", OP_END_COND, NULL},
+  {"shell-escape", OP_SHELL_ESCAPE, "!"},
+  {"select-entry", OP_GENERIC_SELECT_ENTRY, M_ENTER_S},
+  {"search", OP_SEARCH, "/"},
+  {"search-reverse", OP_SEARCH_REVERSE, "\033/"},
+  {"search-opposite", OP_SEARCH_OPPOSITE, NULL},
+  {"jump", OP_JUMP, NULL},
+  {"current-top", OP_CURRENT_TOP, NULL},
+  {"current-middle", OP_CURRENT_MIDDLE, NULL},
+  {"current-bottom", OP_CURRENT_BOTTOM, NULL},
+  {"what-key", OP_WHAT_KEY, NULL},
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpMain[] = {
-  { "create-alias",            OP_CREATE_ALIAS,                "a" },
-  { "bounce-message",          OP_BOUNCE_MESSAGE,              "b" },
-  { "break-thread",            OP_MAIN_BREAK_THREAD,           "#" },
-  { "change-folder",           OP_MAIN_CHANGE_FOLDER,          "c" },
-  { "change-folder-readonly",  OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
+  {"create-alias", OP_CREATE_ALIAS, "a"},
+  {"bounce-message", OP_BOUNCE_MESSAGE, "b"},
+  {"break-thread", OP_MAIN_BREAK_THREAD, "#"},
+  {"change-folder", OP_MAIN_CHANGE_FOLDER, "c"},
+  {"change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c"},
 #ifdef USE_NNTP
-  { "change-newsgroup",                OP_MAIN_CHANGE_GROUP,           "i" },
-  { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
+  {"change-newsgroup", OP_MAIN_CHANGE_GROUP, "i"},
+  {"change-newsgroup-readonly", OP_MAIN_CHANGE_GROUP_READONLY, "\033i"},
 #endif
-  { "collapse-thread",         OP_MAIN_COLLAPSE_THREAD,        "\033v" },
-  { "collapse-all",            OP_MAIN_COLLAPSE_ALL,           "\033V" },
-  { "copy-message",            OP_COPY_MESSAGE,                "C" },
-  { "decode-copy",             OP_DECODE_COPY,                 "\033C" },
-  { "decode-save",             OP_DECODE_SAVE,                 "\033s" },
-  { "delete-message",          OP_DELETE,                      "d" },
-  { "delete-pattern",          OP_MAIN_DELETE_PATTERN,         "D" },
-  { "delete-thread",           OP_DELETE_THREAD,               "\004" },
-  { "delete-subthread",                OP_DELETE_SUBTHREAD,            "\033d" },
-  { "edit",                    OP_EDIT_MESSAGE,                "e" },
-  { "edit-type",               OP_EDIT_TYPE,                   "\005" },
-  { "forward-message",         OP_FORWARD_MESSAGE,             "f" },
+  {"collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v"},
+  {"collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V"},
+  {"copy-message", OP_COPY_MESSAGE, "C"},
+  {"decode-copy", OP_DECODE_COPY, "\033C"},
+  {"decode-save", OP_DECODE_SAVE, "\033s"},
+  {"delete-message", OP_DELETE, "d"},
+  {"delete-pattern", OP_MAIN_DELETE_PATTERN, "D"},
+  {"delete-thread", OP_DELETE_THREAD, "\004"},
+  {"delete-subthread", OP_DELETE_SUBTHREAD, "\033d"},
+  {"edit", OP_EDIT_MESSAGE, "e"},
+  {"edit-type", OP_EDIT_TYPE, "\005"},
+  {"forward-message", OP_FORWARD_MESSAGE, "f"},
 #ifdef USE_NNTP
-  { "forward-to-group",                OP_FORWARD_TO_GROUP,            "\033F" },
-  { "followup-message",                OP_FOLLOWUP,                    "F" },
-  { "get-children",            OP_GET_CHILDREN,                NULL },
-  { "get-message",             OP_GET_MESSAGE,                 "\007" },
-  { "get-parent",              OP_GET_PARENT,                  "\033G" },
-  { "reconstruct-thread",      OP_RECONSTRUCT_THREAD,          NULL },
+  {"forward-to-group", OP_FORWARD_TO_GROUP, "\033F"},
+  {"followup-message", OP_FOLLOWUP, "F"},
+  {"get-children", OP_GET_CHILDREN, NULL},
+  {"get-message", OP_GET_MESSAGE, "\007"},
+  {"get-parent", OP_GET_PARENT, "\033G"},
+  {"reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL},
 #endif
-  { "flag-message",            OP_FLAG_MESSAGE,                "\033f" },
-  { "group-reply",             OP_GROUP_REPLY,                 "g" },
+  {"flag-message", OP_FLAG_MESSAGE, "\033f"},
+  {"group-reply", OP_GROUP_REPLY, "g"},
 #ifdef USE_POP
-  { "fetch-mail",              OP_MAIN_FETCH_MAIL,             "G" },
+  {"fetch-mail", OP_MAIN_FETCH_MAIL, "G"},
 #endif
 #ifdef USE_IMAP
-  { "imap-fetch-mail",         OP_MAIN_IMAP_FETCH,             NULL },
+  {"imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL},
 #endif
-  { "display-toggle-weed",             OP_DISPLAY_HEADERS,             "h" },
-  { "next-undeleted",          OP_MAIN_NEXT_UNDELETED,         "j" },
-  { "previous-undeleted",      OP_MAIN_PREV_UNDELETED,         "k" },
-  { "limit",                   OP_MAIN_LIMIT,                  "l" },
-  { "link-threads",            OP_MAIN_LINK_THREADS,           "&" },
-  { "list-reply",              OP_LIST_REPLY,                  "L" },
-  { "mail",                    OP_MAIL,                        "m" },
-  { "toggle-new",              OP_TOGGLE_NEW,                  "N" },
-  { "toggle-write",            OP_TOGGLE_WRITE,                "%" },
-  { "next-thread",             OP_MAIN_NEXT_THREAD,            "\016" },
-  { "next-subthread",          OP_MAIN_NEXT_SUBTHREAD,         "\033n" },
-  { "purge-message",           OP_PURGE_MESSAGE,               NULL },
-  { "query",                   OP_QUERY,                       "Q" },
-  { "quit",                    OP_QUIT,                        "q" },
-  { "reply",                   OP_REPLY,                       "r" },
-  { "show-limit",              OP_MAIN_SHOW_LIMIT,             "\033l" },
-  { "sort-mailbox",            OP_SORT,                        "o" },
-  { "sort-reverse",            OP_SORT_REVERSE,                "O" },
-  { "print-message",           OP_PRINT,                       "p" },
+  {"display-toggle-weed", OP_DISPLAY_HEADERS, "h"},
+  {"next-undeleted", OP_MAIN_NEXT_UNDELETED, "j"},
+  {"previous-undeleted", OP_MAIN_PREV_UNDELETED, "k"},
+  {"limit", OP_MAIN_LIMIT, "l"},
+  {"link-threads", OP_MAIN_LINK_THREADS, "&"},
+  {"list-reply", OP_LIST_REPLY, "L"},
+  {"mail", OP_MAIL, "m"},
+  {"toggle-new", OP_TOGGLE_NEW, "N"},
+  {"toggle-write", OP_TOGGLE_WRITE, "%"},
+  {"next-thread", OP_MAIN_NEXT_THREAD, "\016"},
+  {"next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n"},
+  {"purge-message", OP_PURGE_MESSAGE, NULL},
+  {"query", OP_QUERY, "Q"},
+  {"quit", OP_QUIT, "q"},
+  {"reply", OP_REPLY, "r"},
+  {"show-limit", OP_MAIN_SHOW_LIMIT, "\033l"},
+  {"sort-mailbox", OP_SORT, "o"},
+  {"sort-reverse", OP_SORT_REVERSE, "O"},
+  {"print-message", OP_PRINT, "p"},
 #ifdef USE_NNTP
-  { "post-message",            OP_POST,                        "P" },
+  {"post-message", OP_POST, "P"},
 #endif
-  { "previous-thread",         OP_MAIN_PREV_THREAD,            "\020" },
-  { "previous-subthread",      OP_MAIN_PREV_SUBTHREAD,         "\033p" },
-  { "recall-message",          OP_RECALL_MESSAGE,              "R" },
-  { "read-thread",             OP_MAIN_READ_THREAD,            "\022" },
-  { "read-subthread",          OP_MAIN_READ_SUBTHREAD,         "\033r" },
-  { "resend-message",          OP_RESEND,                      "\033e" },
-  { "save-message",            OP_SAVE,                        "s" },
-  { "tag-pattern",             OP_MAIN_TAG_PATTERN,            "T" },
-  { "tag-subthread",           OP_TAG_SUBTHREAD,               NULL },
-  { "tag-thread",              OP_TAG_THREAD,                  "\033t" },
-  { "untag-pattern",           OP_MAIN_UNTAG_PATTERN,          "\024" },
-  { "undelete-message",                OP_UNDELETE,                    "u" },
-  { "undelete-pattern",                OP_MAIN_UNDELETE_PATTERN,       "U"},
-  { "undelete-subthread",      OP_UNDELETE_SUBTHREAD,          "\033u" },
-  { "undelete-thread",         OP_UNDELETE_THREAD,             "\025" },
-  { "view-attachments",                OP_VIEW_ATTACHMENTS,            "v" },
-  { "show-version",            OP_VERSION,                     "V" },
-  { "set-flag",                        OP_MAIN_SET_FLAG,               "w" },
-  { "clear-flag",              OP_MAIN_CLEAR_FLAG,             "W" },
-  { "toggle-read",             OP_TOGGLE_READ,                 "X" },
+  {"previous-thread", OP_MAIN_PREV_THREAD, "\020"},
+  {"previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p"},
+  {"recall-message", OP_RECALL_MESSAGE, "R"},
+  {"read-thread", OP_MAIN_READ_THREAD, "\022"},
+  {"read-subthread", OP_MAIN_READ_SUBTHREAD, "\033r"},
+  {"resend-message", OP_RESEND, "\033e"},
+  {"save-message", OP_SAVE, "s"},
+  {"tag-pattern", OP_MAIN_TAG_PATTERN, "T"},
+  {"tag-subthread", OP_TAG_SUBTHREAD, NULL},
+  {"tag-thread", OP_TAG_THREAD, "\033t"},
+  {"untag-pattern", OP_MAIN_UNTAG_PATTERN, "\024"},
+  {"undelete-message", OP_UNDELETE, "u"},
+  {"undelete-pattern", OP_MAIN_UNDELETE_PATTERN, "U"},
+  {"undelete-subthread", OP_UNDELETE_SUBTHREAD, "\033u"},
+  {"undelete-thread", OP_UNDELETE_THREAD, "\025"},
+  {"view-attachments", OP_VIEW_ATTACHMENTS, "v"},
+  {"show-version", OP_VERSION, "V"},
+  {"set-flag", OP_MAIN_SET_FLAG, "w"},
+  {"clear-flag", OP_MAIN_CLEAR_FLAG, "W"},
+  {"toggle-read", OP_TOGGLE_READ, "X"},
 #ifdef USE_NNTP
-  { "catchup",                 OP_CATCHUP,                     "y" },
+  {"catchup", OP_CATCHUP, "y"},
 #endif
-  { "display-message",         OP_DISPLAY_MESSAGE,             M_ENTER_S },
-  { "buffy-list",              OP_BUFFY_LIST,                  "." },
-  { "sync-mailbox",            OP_MAIN_SYNC_FOLDER,            "$" },
-  { "display-address",         OP_DISPLAY_ADDRESS,             "@" },
-  { "pipe-message",            OP_PIPE,                        "|" },
-  { "next-new",                        OP_MAIN_NEXT_NEW,               NULL },
-  { "next-new-then-unread",    OP_MAIN_NEXT_NEW_THEN_UNREAD,   "\t" },
-  { "previous-new",            OP_MAIN_PREV_NEW,               NULL },
-  { "previous-new-then-unread",        OP_MAIN_PREV_NEW_THEN_UNREAD,   "\033\t" },
-  { "next-unread",             OP_MAIN_NEXT_UNREAD,            NULL },
-  { "previous-unread",         OP_MAIN_PREV_UNREAD,            NULL },
-  { "parent-message",          OP_MAIN_PARENT_MESSAGE,         NULL },
-
-
-  { "extract-keys",            OP_EXTRACT_KEYS,                "\013" },
-  { "forget-passphrase",       OP_FORGET_PASSPHRASE,           "\006" },
-  { "check-traditional-pgp",   OP_CHECK_TRADITIONAL,           "\033P" },
-  { "mail-key",                        OP_MAIL_KEY,                    "\033k" },
-  { "decrypt-copy",            OP_DECRYPT_COPY,                NULL },
-  { "decrypt-save",            OP_DECRYPT_SAVE,                NULL },
-
-
-  { "sidebar-scroll-up",       OP_SIDEBAR_SCROLL_UP, NULL },
-  { "sidebar-scroll-down",     OP_SIDEBAR_SCROLL_DOWN, NULL },
-  { "sidebar-next",    OP_SIDEBAR_NEXT, NULL },
-  { "sidebar-prev",    OP_SIDEBAR_PREV, NULL },
-  { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
-  { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
-  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
-  { NULL,                      0,                              NULL }
+  {"display-message", OP_DISPLAY_MESSAGE, M_ENTER_S},
+  {"buffy-list", OP_BUFFY_LIST, "."},
+  {"sync-mailbox", OP_MAIN_SYNC_FOLDER, "$"},
+  {"display-address", OP_DISPLAY_ADDRESS, "@"},
+  {"pipe-message", OP_PIPE, "|"},
+  {"next-new", OP_MAIN_NEXT_NEW, NULL},
+  {"next-new-then-unread", OP_MAIN_NEXT_NEW_THEN_UNREAD, "\t"},
+  {"previous-new", OP_MAIN_PREV_NEW, NULL},
+  {"previous-new-then-unread", OP_MAIN_PREV_NEW_THEN_UNREAD, "\033\t"},
+  {"next-unread", OP_MAIN_NEXT_UNREAD, NULL},
+  {"previous-unread", OP_MAIN_PREV_UNREAD, NULL},
+  {"parent-message", OP_MAIN_PARENT_MESSAGE, NULL},
+
+
+  {"extract-keys", OP_EXTRACT_KEYS, "\013"},
+  {"forget-passphrase", OP_FORGET_PASSPHRASE, "\006"},
+  {"check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P"},
+  {"mail-key", OP_MAIL_KEY, "\033k"},
+  {"decrypt-copy", OP_DECRYPT_COPY, NULL},
+  {"decrypt-save", OP_DECRYPT_SAVE, NULL},
+
+
+  {"sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL},
+  {"sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL},
+  {"sidebar-next", OP_SIDEBAR_NEXT, NULL},
+  {"sidebar-prev", OP_SIDEBAR_PREV, NULL},
+  {"sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
+  {"sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
+  {"sidebar-open", OP_SIDEBAR_OPEN, NULL},
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpPager[] = {
-  { "break-thread",    OP_MAIN_BREAK_THREAD,           "#" },
-  { "create-alias",    OP_CREATE_ALIAS,                "a" },
-  { "bounce-message",  OP_BOUNCE_MESSAGE,              "b" },
-  { "change-folder",   OP_MAIN_CHANGE_FOLDER,          "c" },
-  { "change-folder-readonly",  OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
+  {"break-thread", OP_MAIN_BREAK_THREAD, "#"},
+  {"create-alias", OP_CREATE_ALIAS, "a"},
+  {"bounce-message", OP_BOUNCE_MESSAGE, "b"},
+  {"change-folder", OP_MAIN_CHANGE_FOLDER, "c"},
+  {"change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c"},
 #ifdef USE_NNTP
-  { "change-newsgroup",                OP_MAIN_CHANGE_GROUP,           "i" },
-  { "change-newsgroup-readonly",OP_MAIN_CHANGE_GROUP_READONLY, "\033i" },
+  {"change-newsgroup", OP_MAIN_CHANGE_GROUP, "i"},
+  {"change-newsgroup-readonly", OP_MAIN_CHANGE_GROUP_READONLY, "\033i"},
 #endif
-  { "copy-message",    OP_COPY_MESSAGE,                "C" },
-  { "decode-copy",     OP_DECODE_COPY,                 "\033C" },
-  { "delete-message",  OP_DELETE,                      "d" },
-  { "delete-thread",   OP_DELETE_THREAD,               "\004" },
-  { "delete-subthread",        OP_DELETE_SUBTHREAD,            "\033d" },
-  { "edit",            OP_EDIT_MESSAGE,                "e" },
-  { "edit-type",       OP_EDIT_TYPE,                   "\005" },
+  {"copy-message", OP_COPY_MESSAGE, "C"},
+  {"decode-copy", OP_DECODE_COPY, "\033C"},
+  {"delete-message", OP_DELETE, "d"},
+  {"delete-thread", OP_DELETE_THREAD, "\004"},
+  {"delete-subthread", OP_DELETE_SUBTHREAD, "\033d"},
+  {"edit", OP_EDIT_MESSAGE, "e"},
+  {"edit-type", OP_EDIT_TYPE, "\005"},
 #ifdef USE_NNTP
-  { "followup-message",        OP_FOLLOWUP,                    "F" },
-  { "forward-to-group",        OP_FORWARD_TO_GROUP,            "\033F" },
+  {"followup-message", OP_FOLLOWUP, "F"},
+  {"forward-to-group", OP_FORWARD_TO_GROUP, "\033F"},
 #endif
-  { "forward-message", OP_FORWARD_MESSAGE,             "f" },
-  { "flag-message",    OP_FLAG_MESSAGE,                "\033f" },
-  { "group-reply",     OP_GROUP_REPLY,                 "g" },
+  {"forward-message", OP_FORWARD_MESSAGE, "f"},
+  {"flag-message", OP_FLAG_MESSAGE, "\033f"},
+  {"group-reply", OP_GROUP_REPLY, "g"},
 #ifdef USE_IMAP
-  { "imap-fetch-mail",  OP_MAIN_IMAP_FETCH,            NULL },
+  {"imap-fetch-mail", OP_MAIN_IMAP_FETCH, NULL},
 #endif
-  { "display-toggle-weed",     OP_DISPLAY_HEADERS,             "h" },
-  { "next-undeleted",  OP_MAIN_NEXT_UNDELETED,         "j" },
-  { "next-entry",      OP_NEXT_ENTRY,                  "J" },
-  { "previous-undeleted",OP_MAIN_PREV_UNDELETED,       "k" },
-  { "previous-entry",  OP_PREV_ENTRY,                  "K" },
-  { "link-threads",    OP_MAIN_LINK_THREADS,           "&" },
-  { "list-reply",      OP_LIST_REPLY,                  "L" },
-  { "redraw-screen",   OP_REDRAW,                      "\014" },
-  { "mail",            OP_MAIL,                        "m" },
-  { "mark-as-new",     OP_TOGGLE_NEW,                  "N" },
-  { "search-next",     OP_SEARCH_NEXT,                 "n" },
-  { "next-thread",     OP_MAIN_NEXT_THREAD,            "\016" },
-  { "next-subthread",  OP_MAIN_NEXT_SUBTHREAD,         "\033n" },
-  { "print-message",   OP_PRINT,                       "p" },
+  {"display-toggle-weed", OP_DISPLAY_HEADERS, "h"},
+  {"next-undeleted", OP_MAIN_NEXT_UNDELETED, "j"},
+  {"next-entry", OP_NEXT_ENTRY, "J"},
+  {"previous-undeleted", OP_MAIN_PREV_UNDELETED, "k"},
+  {"previous-entry", OP_PREV_ENTRY, "K"},
+  {"link-threads", OP_MAIN_LINK_THREADS, "&"},
+  {"list-reply", OP_LIST_REPLY, "L"},
+  {"redraw-screen", OP_REDRAW, "\014"},
+  {"mail", OP_MAIL, "m"},
+  {"mark-as-new", OP_TOGGLE_NEW, "N"},
+  {"search-next", OP_SEARCH_NEXT, "n"},
+  {"next-thread", OP_MAIN_NEXT_THREAD, "\016"},
+  {"next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n"},
+  {"print-message", OP_PRINT, "p"},
 #ifdef USE_NNTP
-  { "post-message",    OP_POST,                        "P" },
+  {"post-message", OP_POST, "P"},
 #endif
-  { "previous-thread", OP_MAIN_PREV_THREAD,            "\020" },
-  { "previous-subthread",OP_MAIN_PREV_SUBTHREAD,       "\033p" },
-  { "purge-message",   OP_PURGE_MESSAGE,               NULL },
-  { "quit",            OP_QUIT,                        "Q" },
-  { "exit",            OP_EXIT,                        "q" },
-  { "reply",           OP_REPLY,                       "r" },
-  { "recall-message",  OP_RECALL_MESSAGE,              "R" },
-  { "read-thread",     OP_MAIN_READ_THREAD,            "\022" },
-  { "read-subthread",  OP_MAIN_READ_SUBTHREAD,         "\033r" },
-  { "resend-message",  OP_RESEND,                      "\033e" },
-  { "save-message",    OP_SAVE,                        "s" },
-  { "skip-quoted",     OP_PAGER_SKIP_QUOTED,           "S" },
-  { "decode-save",     OP_DECODE_SAVE,                 "\033s" },
-  { "tag-message",     OP_TAG,                         "t" },
-  { "toggle-quoted",   OP_PAGER_HIDE_QUOTED,           "T" },
-  { "undelete-message",        OP_UNDELETE,                    "u" },
-  { "undelete-subthread",OP_UNDELETE_SUBTHREAD,                "\033u" },
-  { "undelete-thread", OP_UNDELETE_THREAD,             "\025" },
-  { "view-attachments",        OP_VIEW_ATTACHMENTS,            "v" },
-  { "show-version",    OP_VERSION,                     "V" },
-  { "search-toggle",   OP_SEARCH_TOGGLE,               "\\" },
-  { "display-address", OP_DISPLAY_ADDRESS,             "@" },
-  { "next-new",                OP_MAIN_NEXT_NEW,               NULL },
-  { "next-new-then-unread", 
-                        OP_MAIN_NEXT_NEW_THEN_UNREAD,   "\t" },
-  { "pipe-message",    OP_PIPE,                        "|" },
-  { "help",            OP_HELP,                        "?" },
-  { "next-page",       OP_NEXT_PAGE,                   " " },
-  { "previous-page",   OP_PREV_PAGE,                   "-" },
-  { "top",             OP_PAGER_TOP,                   "^" },
-  { "sync-mailbox",    OP_MAIN_SYNC_FOLDER,            "$" },
-  { "shell-escape",    OP_SHELL_ESCAPE,                "!" },
-  { "enter-command",   OP_ENTER_COMMAND,               ":" },
-  { "buffy-list",      OP_BUFFY_LIST,                  "." },
-  { "search",          OP_SEARCH,                      "/" },
-  { "search-reverse",  OP_SEARCH_REVERSE,              "\033/" },
-  { "search-opposite", OP_SEARCH_OPPOSITE,             NULL },
-  { "next-line",       OP_NEXT_LINE,                   M_ENTER_S },
-  { "jump",            OP_JUMP,                        NULL },
-  { "next-unread",     OP_MAIN_NEXT_UNREAD,            NULL },
-  { "previous-new",    OP_MAIN_PREV_NEW,               NULL },
-  { "previous-new-then-unread",
-                       OP_MAIN_PREV_NEW_THEN_UNREAD,   NULL },
-  { "previous-unread", OP_MAIN_PREV_UNREAD,            NULL },
-  { "half-up",         OP_HALF_UP,                     NULL },
-  { "half-down",       OP_HALF_DOWN,                   NULL },
-  { "previous-line",   OP_PREV_LINE,                   NULL },
-  { "bottom",          OP_PAGER_BOTTOM,                NULL },
-  { "parent-message",  OP_MAIN_PARENT_MESSAGE,         NULL },
-
-
-
-
-  { "check-traditional-pgp",   OP_CHECK_TRADITIONAL,   "\033P"   },
-  { "mail-key",                OP_MAIL_KEY,                    "\033k" },
-  { "extract-keys",    OP_EXTRACT_KEYS,                "\013" },
-  { "forget-passphrase",OP_FORGET_PASSPHRASE,          "\006" },
-  { "decrypt-copy",    OP_DECRYPT_COPY,                NULL },
-  { "decrypt-save",            OP_DECRYPT_SAVE,                NULL },
-
-
-  { "sidebar-scroll-up",       OP_SIDEBAR_SCROLL_UP, NULL },
-  { "sidebar-scroll-down",     OP_SIDEBAR_SCROLL_DOWN, NULL },
-  { "sidebar-next",    OP_SIDEBAR_NEXT, NULL },
-  { "sidebar-prev",    OP_SIDEBAR_PREV, NULL },
-  { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
-  { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
-  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
-  { NULL,              0,                              NULL }
+  {"previous-thread", OP_MAIN_PREV_THREAD, "\020"},
+  {"previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p"},
+  {"purge-message", OP_PURGE_MESSAGE, NULL},
+  {"quit", OP_QUIT, "Q"},
+  {"exit", OP_EXIT, "q"},
+  {"reply", OP_REPLY, "r"},
+  {"recall-message", OP_RECALL_MESSAGE, "R"},
+  {"read-thread", OP_MAIN_READ_THREAD, "\022"},
+  {"read-subthread", OP_MAIN_READ_SUBTHREAD, "\033r"},
+  {"resend-message", OP_RESEND, "\033e"},
+  {"save-message", OP_SAVE, "s"},
+  {"skip-quoted", OP_PAGER_SKIP_QUOTED, "S"},
+  {"decode-save", OP_DECODE_SAVE, "\033s"},
+  {"tag-message", OP_TAG, "t"},
+  {"toggle-quoted", OP_PAGER_HIDE_QUOTED, "T"},
+  {"undelete-message", OP_UNDELETE, "u"},
+  {"undelete-subthread", OP_UNDELETE_SUBTHREAD, "\033u"},
+  {"undelete-thread", OP_UNDELETE_THREAD, "\025"},
+  {"view-attachments", OP_VIEW_ATTACHMENTS, "v"},
+  {"show-version", OP_VERSION, "V"},
+  {"search-toggle", OP_SEARCH_TOGGLE, "\\"},
+  {"display-address", OP_DISPLAY_ADDRESS, "@"},
+  {"next-new", OP_MAIN_NEXT_NEW, NULL},
+  {"next-new-then-unread",
+   OP_MAIN_NEXT_NEW_THEN_UNREAD, "\t"},
+  {"pipe-message", OP_PIPE, "|"},
+  {"help", OP_HELP, "?"},
+  {"next-page", OP_NEXT_PAGE, " "},
+  {"previous-page", OP_PREV_PAGE, "-"},
+  {"top", OP_PAGER_TOP, "^"},
+  {"sync-mailbox", OP_MAIN_SYNC_FOLDER, "$"},
+  {"shell-escape", OP_SHELL_ESCAPE, "!"},
+  {"enter-command", OP_ENTER_COMMAND, ":"},
+  {"buffy-list", OP_BUFFY_LIST, "."},
+  {"search", OP_SEARCH, "/"},
+  {"search-reverse", OP_SEARCH_REVERSE, "\033/"},
+  {"search-opposite", OP_SEARCH_OPPOSITE, NULL},
+  {"next-line", OP_NEXT_LINE, M_ENTER_S},
+  {"jump", OP_JUMP, NULL},
+  {"next-unread", OP_MAIN_NEXT_UNREAD, NULL},
+  {"previous-new", OP_MAIN_PREV_NEW, NULL},
+  {"previous-new-then-unread",
+   OP_MAIN_PREV_NEW_THEN_UNREAD, NULL},
+  {"previous-unread", OP_MAIN_PREV_UNREAD, NULL},
+  {"half-up", OP_HALF_UP, NULL},
+  {"half-down", OP_HALF_DOWN, NULL},
+  {"previous-line", OP_PREV_LINE, NULL},
+  {"bottom", OP_PAGER_BOTTOM, NULL},
+  {"parent-message", OP_MAIN_PARENT_MESSAGE, NULL},
+
+
+
+
+  {"check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P"},
+  {"mail-key", OP_MAIL_KEY, "\033k"},
+  {"extract-keys", OP_EXTRACT_KEYS, "\013"},
+  {"forget-passphrase", OP_FORGET_PASSPHRASE, "\006"},
+  {"decrypt-copy", OP_DECRYPT_COPY, NULL},
+  {"decrypt-save", OP_DECRYPT_SAVE, NULL},
+
+
+  {"sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL},
+  {"sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL},
+  {"sidebar-next", OP_SIDEBAR_NEXT, NULL},
+  {"sidebar-prev", OP_SIDEBAR_PREV, NULL},
+  {"sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
+  {"sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
+  {"sidebar-open", OP_SIDEBAR_OPEN, NULL},
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpAttach[] = {
-  { "bounce-message",  OP_BOUNCE_MESSAGE,              "b" },
-  { "display-toggle-weed",     OP_DISPLAY_HEADERS,     "h" },
-  { "edit-type",       OP_EDIT_TYPE,                   "\005" },
+  {"bounce-message", OP_BOUNCE_MESSAGE, "b"},
+  {"display-toggle-weed", OP_DISPLAY_HEADERS, "h"},
+  {"edit-type", OP_EDIT_TYPE, "\005"},
 #ifdef USE_NNTP
-  { "followup-message",        OP_FOLLOWUP,                    "F" },
-  { "forward-to-group",        OP_FORWARD_TO_GROUP,            "\033F" },
+  {"followup-message", OP_FOLLOWUP, "F"},
+  {"forward-to-group", OP_FORWARD_TO_GROUP, "\033F"},
 #endif
-  { "print-entry",     OP_PRINT,                       "p" },
-  { "save-entry",      OP_SAVE,                        "s" },
-  { "pipe-entry",      OP_PIPE,                        "|" },
-  { "view-mailcap",    OP_ATTACH_VIEW_MAILCAP,         "m" },
-  { "reply",           OP_REPLY,                       "r" },
-  { "resend-message",  OP_RESEND,                      "\033e" },
-  { "group-reply",     OP_GROUP_REPLY,                 "g" },
-  { "list-reply",      OP_LIST_REPLY,                  "L" },
-  { "forward-message", OP_FORWARD_MESSAGE,             "f" },
-  { "view-text",       OP_ATTACH_VIEW_TEXT,            "T" },
-  { "view-attach",     OP_VIEW_ATTACH,                 M_ENTER_S },
-  { "delete-entry",    OP_DELETE,                      "d" },
-  { "undelete-entry",  OP_UNDELETE,                    "u" },
-  { "collapse-parts",  OP_ATTACH_COLLAPSE,             "v" },
-
-  { "check-traditional-pgp",   OP_CHECK_TRADITIONAL,           "\033P"   },
-  { "extract-keys",            OP_EXTRACT_KEYS,                "\013" },
-  { "forget-passphrase",       OP_FORGET_PASSPHRASE,           "\006" },
-
-  { NULL,              0,                              NULL }
+  {"print-entry", OP_PRINT, "p"},
+  {"save-entry", OP_SAVE, "s"},
+  {"pipe-entry", OP_PIPE, "|"},
+  {"view-mailcap", OP_ATTACH_VIEW_MAILCAP, "m"},
+  {"reply", OP_REPLY, "r"},
+  {"resend-message", OP_RESEND, "\033e"},
+  {"group-reply", OP_GROUP_REPLY, "g"},
+  {"list-reply", OP_LIST_REPLY, "L"},
+  {"forward-message", OP_FORWARD_MESSAGE, "f"},
+  {"view-text", OP_ATTACH_VIEW_TEXT, "T"},
+  {"view-attach", OP_VIEW_ATTACH, M_ENTER_S},
+  {"delete-entry", OP_DELETE, "d"},
+  {"undelete-entry", OP_UNDELETE, "u"},
+  {"collapse-parts", OP_ATTACH_COLLAPSE, "v"},
+
+  {"check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P"},
+  {"extract-keys", OP_EXTRACT_KEYS, "\013"},
+  {"forget-passphrase", OP_FORGET_PASSPHRASE, "\006"},
+
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpCompose[] = {
-  { "attach-file",     OP_COMPOSE_ATTACH_FILE,         "a" },
-  { "attach-message",  OP_COMPOSE_ATTACH_MESSAGE,      "A" },
-  { "attach-news-message",OP_COMPOSE_ATTACH_NEWS_MESSAGE,"\033a" },
-  { "edit-bcc",                OP_COMPOSE_EDIT_BCC,            "b" },
-  { "edit-cc",         OP_COMPOSE_EDIT_CC,             "c" },
-  { "copy-file",       OP_SAVE,                        "C" },
-  { "detach-file",     OP_DELETE,                      "D" },
-  { "toggle-disposition",OP_COMPOSE_TOGGLE_DISPOSITION,        "\004" },
-  { "edit-description",        OP_COMPOSE_EDIT_DESCRIPTION,    "d" },
-  { "edit-message",    OP_COMPOSE_EDIT_MESSAGE,        "e" },
-  { "edit-headers",    OP_COMPOSE_EDIT_HEADERS,        "E" },
-  { "edit-file",       OP_COMPOSE_EDIT_FILE,           "\030e" },
-  { "edit-encoding",   OP_COMPOSE_EDIT_ENCODING,       "\005" },
-  { "edit-from",       OP_COMPOSE_EDIT_FROM,           "\033f" },
-  { "edit-fcc",                OP_COMPOSE_EDIT_FCC,            "f" },
-  { "filter-entry",    OP_FILTER,                      "F" },
-  { "get-attachment",  OP_COMPOSE_GET_ATTACHMENT,      "G" },
-  { "display-toggle-weed",     OP_DISPLAY_HEADERS,             "h" },
-  { "ispell",          OP_COMPOSE_ISPELL,              "i" },
-  { "print-entry",     OP_PRINT,                       "l" },
-  { "edit-mime",       OP_COMPOSE_EDIT_MIME,           "m" },
-  { "new-mime",                OP_COMPOSE_NEW_MIME,            "n" },
+  {"attach-file", OP_COMPOSE_ATTACH_FILE, "a"},
+  {"attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A"},
+  {"attach-news-message", OP_COMPOSE_ATTACH_NEWS_MESSAGE, "\033a"},
+  {"edit-bcc", OP_COMPOSE_EDIT_BCC, "b"},
+  {"edit-cc", OP_COMPOSE_EDIT_CC, "c"},
+  {"copy-file", OP_SAVE, "C"},
+  {"detach-file", OP_DELETE, "D"},
+  {"toggle-disposition", OP_COMPOSE_TOGGLE_DISPOSITION, "\004"},
+  {"edit-description", OP_COMPOSE_EDIT_DESCRIPTION, "d"},
+  {"edit-message", OP_COMPOSE_EDIT_MESSAGE, "e"},
+  {"edit-headers", OP_COMPOSE_EDIT_HEADERS, "E"},
+  {"edit-file", OP_COMPOSE_EDIT_FILE, "\030e"},
+  {"edit-encoding", OP_COMPOSE_EDIT_ENCODING, "\005"},
+  {"edit-from", OP_COMPOSE_EDIT_FROM, "\033f"},
+  {"edit-fcc", OP_COMPOSE_EDIT_FCC, "f"},
+  {"filter-entry", OP_FILTER, "F"},
+  {"get-attachment", OP_COMPOSE_GET_ATTACHMENT, "G"},
+  {"display-toggle-weed", OP_DISPLAY_HEADERS, "h"},
+  {"ispell", OP_COMPOSE_ISPELL, "i"},
+  {"print-entry", OP_PRINT, "l"},
+  {"edit-mime", OP_COMPOSE_EDIT_MIME, "m"},
+  {"new-mime", OP_COMPOSE_NEW_MIME, "n"},
 #ifdef USE_NNTP
-  { "edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS,     "N" },
-  { "edit-followup-to",        OP_COMPOSE_EDIT_FOLLOWUP_TO,    "o" },
-  { "edit-x-comment-to",OP_COMPOSE_EDIT_X_COMMENT_TO,  "x" },
+  {"edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N"},
+  {"edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o"},
+  {"edit-x-comment-to", OP_COMPOSE_EDIT_X_COMMENT_TO, "x"},
 #endif
-  { "postpone-message",        OP_COMPOSE_POSTPONE_MESSAGE,    "P" },
-  { "edit-reply-to",   OP_COMPOSE_EDIT_REPLY_TO,       "r" },
-  { "rename-file",     OP_COMPOSE_RENAME_FILE,         "R" },
-  { "edit-subject",    OP_COMPOSE_EDIT_SUBJECT,        "s" },
-  { "edit-to",         OP_COMPOSE_EDIT_TO,             "t" },
-  { "edit-type",       OP_EDIT_TYPE,                   "\024" },
-  { "write-fcc",       OP_COMPOSE_WRITE_MESSAGE,       "w" },
-  { "toggle-unlink",   OP_COMPOSE_TOGGLE_UNLINK,       "u" },
-  { "toggle-recode",    OP_COMPOSE_TOGGLE_RECODE,      NULL },
-  { "update-encoding", OP_COMPOSE_UPDATE_ENCODING,     "U" },
-  { "view-attach",     OP_VIEW_ATTACH,                 M_ENTER_S },
-  { "send-message",    OP_COMPOSE_SEND_MESSAGE,        "y" },
-  { "pipe-entry",      OP_PIPE,                        "|" },
-
-  { "attach-key",      OP_COMPOSE_ATTACH_KEY,          "\033k" },
-  { "pgp-menu",                OP_COMPOSE_PGP_MENU,            "p"     },
-
-  { "forget-passphrase",OP_FORGET_PASSPHRASE,          "\006"  },
-
-  { "smime-menu",      OP_COMPOSE_SMIME_MENU,          "S"     },
+  {"postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P"},
+  {"edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r"},
+  {"rename-file", OP_COMPOSE_RENAME_FILE, "R"},
+  {"edit-subject", OP_COMPOSE_EDIT_SUBJECT, "s"},
+  {"edit-to", OP_COMPOSE_EDIT_TO, "t"},
+  {"edit-type", OP_EDIT_TYPE, "\024"},
+  {"write-fcc", OP_COMPOSE_WRITE_MESSAGE, "w"},
+  {"toggle-unlink", OP_COMPOSE_TOGGLE_UNLINK, "u"},
+  {"toggle-recode", OP_COMPOSE_TOGGLE_RECODE, NULL},
+  {"update-encoding", OP_COMPOSE_UPDATE_ENCODING, "U"},
+  {"view-attach", OP_VIEW_ATTACH, M_ENTER_S},
+  {"send-message", OP_COMPOSE_SEND_MESSAGE, "y"},
+  {"pipe-entry", OP_PIPE, "|"},
+
+  {"attach-key", OP_COMPOSE_ATTACH_KEY, "\033k"},
+  {"pgp-menu", OP_COMPOSE_PGP_MENU, "p"},
+
+  {"forget-passphrase", OP_FORGET_PASSPHRASE, "\006"},
+
+  {"smime-menu", OP_COMPOSE_SMIME_MENU, "S"},
 
 #ifdef MIXMASTER
-  { "mix",             OP_COMPOSE_MIX,                 "M" },
+  {"mix", OP_COMPOSE_MIX, "M"},
 #endif
-  
-  { NULL,              0,                              NULL }
+
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpPost[] = {
-  { "delete-entry",    OP_DELETE,      "d" },
-  { "undelete-entry",  OP_UNDELETE,    "u" },
-  { NULL,              0,              NULL }
+  {"delete-entry", OP_DELETE, "d"},
+  {"undelete-entry", OP_UNDELETE, "u"},
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpAlias[] = {
-  { "delete-entry",    OP_DELETE,      "d" },
-  { "undelete-entry",  OP_UNDELETE,    "u" },
-  { NULL,              0,              NULL }
+  {"delete-entry", OP_DELETE, "d"},
+  {"undelete-entry", OP_UNDELETE, "u"},
+  {NULL, 0, NULL}
 };
-  
+
 
 /* The file browser */
 struct binding_t OpBrowser[] = {
-  { "change-dir",      OP_CHANGE_DIRECTORY,    "c" },
-  { "display-filename",        OP_BROWSER_TELL,        "@" },
-  { "enter-mask",      OP_ENTER_MASK,          "m" },
-  { "sort",            OP_SORT,                "o" },
-  { "sort-reverse",    OP_SORT_REVERSE,        "O" },
-  { "select-new",      OP_BROWSER_NEW_FILE,    "N" },
-  { "check-new",       OP_CHECK_NEW,           NULL },
-  { "toggle-mailboxes", OP_TOGGLE_MAILBOXES,   "\t" },
+  {"change-dir", OP_CHANGE_DIRECTORY, "c"},
+  {"display-filename", OP_BROWSER_TELL, "@"},
+  {"enter-mask", OP_ENTER_MASK, "m"},
+  {"sort", OP_SORT, "o"},
+  {"sort-reverse", OP_SORT_REVERSE, "O"},
+  {"select-new", OP_BROWSER_NEW_FILE, "N"},
+  {"check-new", OP_CHECK_NEW, NULL},
+  {"toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t"},
 #ifdef USE_NNTP
-  { "reload-active",   OP_LOAD_ACTIVE,         "g"},
-  { "subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S" },
-  { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U" },
-  { "catchup",         OP_CATCHUP,             "y" },
-  { "uncatchup",       OP_UNCATCHUP,           "Y" },
+  {"reload-active", OP_LOAD_ACTIVE, "g"},
+  {"subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S"},
+  {"unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U"},
+  {"catchup", OP_CATCHUP, "y"},
+  {"uncatchup", OP_UNCATCHUP, "Y"},
 #endif
-  { "view-file",       OP_BROWSER_VIEW_FILE,   " " },
-  { "buffy-list",      OP_BUFFY_LIST,          "." },
+  {"view-file", OP_BROWSER_VIEW_FILE, " "},
+  {"buffy-list", OP_BUFFY_LIST, "."},
 #ifdef USE_IMAP
-  { "create-mailbox",   OP_CREATE_MAILBOX,      "C" },
-  { "delete-mailbox",   OP_DELETE_MAILBOX,      "d" },
-  { "rename-mailbox",   OP_RENAME_MAILBOX,      "r" },
+  {"create-mailbox", OP_CREATE_MAILBOX, "C"},
+  {"delete-mailbox", OP_DELETE_MAILBOX, "d"},
+  {"rename-mailbox", OP_RENAME_MAILBOX, "r"},
 #endif
 #if defined USE_IMAP || defined USE_NNTP
-  { "subscribe",       OP_BROWSER_SUBSCRIBE,   "s" },
-  { "unsubscribe",     OP_BROWSER_UNSUBSCRIBE, "u" },
+  {"subscribe", OP_BROWSER_SUBSCRIBE, "s"},
+  {"unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u"},
 #endif
 #ifdef USE_IMAP
-  { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
+  {"toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T"},
 #endif
-  { NULL,              0,                      NULL }
+  {NULL, 0, NULL}
 };
 
 /* External Query Menu */
 struct binding_t OpQuery[] = {
-  { "create-alias",    OP_CREATE_ALIAS,        "a" },
-  { "mail",            OP_MAIL,                "m" },
-  { "query",           OP_QUERY,               "Q" },
-  { "query-append",    OP_QUERY_APPEND,        "A" },
-  { NULL,              0,                      NULL }
+  {"create-alias", OP_CREATE_ALIAS, "a"},
+  {"mail", OP_MAIL, "m"},
+  {"query", OP_QUERY, "Q"},
+  {"query-append", OP_QUERY_APPEND, "A"},
+  {NULL, 0, NULL}
 };
 
 struct binding_t OpEditor[] = {
-  { "bol",             OP_EDITOR_BOL,                  "\001" },
-  { "backward-char",   OP_EDITOR_BACKWARD_CHAR,        "\002" },
-  { "backward-word",   OP_EDITOR_BACKWARD_WORD,        "\033b"},
-  { "capitalize-word", OP_EDITOR_CAPITALIZE_WORD,      "\033c"},
-  { "downcase-word",   OP_EDITOR_DOWNCASE_WORD,        "\033l"},
-  { "upcase-word",     OP_EDITOR_UPCASE_WORD,          "\033u"},
-  { "delete-char",     OP_EDITOR_DELETE_CHAR,          "\004" },
-  { "eol",             OP_EDITOR_EOL,                  "\005" },
-  { "forward-char",    OP_EDITOR_FORWARD_CHAR,         "\006" },
-  { "forward-word",    OP_EDITOR_FORWARD_WORD,         "\033f"},
-  { "backspace",       OP_EDITOR_BACKSPACE,            "\010" },
-  { "kill-eol",                OP_EDITOR_KILL_EOL,             "\013" },
-  { "kill-eow",                OP_EDITOR_KILL_EOW,             "\033d"},
-  { "kill-line",       OP_EDITOR_KILL_LINE,            "\025" },
-  { "quote-char",      OP_EDITOR_QUOTE_CHAR,           "\026" },
-  { "kill-word",       OP_EDITOR_KILL_WORD,            "\027" },
-  { "complete",                OP_EDITOR_COMPLETE,             "\t"   },
-  { "complete-query",  OP_EDITOR_COMPLETE_QUERY,       "\024" },
-  { "buffy-cycle",     OP_EDITOR_BUFFY_CYCLE,          " "    },
-  { "history-up",      OP_EDITOR_HISTORY_UP,           NULL   },
-  { "history-down",    OP_EDITOR_HISTORY_DOWN,         NULL   },
-  { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS,      NULL   },
-  { NULL,              0,                              NULL   }
+  {"bol", OP_EDITOR_BOL, "\001"},
+  {"backward-char", OP_EDITOR_BACKWARD_CHAR, "\002"},
+  {"backward-word", OP_EDITOR_BACKWARD_WORD, "\033b"},
+  {"capitalize-word", OP_EDITOR_CAPITALIZE_WORD, "\033c"},
+  {"downcase-word", OP_EDITOR_DOWNCASE_WORD, "\033l"},
+  {"upcase-word", OP_EDITOR_UPCASE_WORD, "\033u"},
+  {"delete-char", OP_EDITOR_DELETE_CHAR, "\004"},
+  {"eol", OP_EDITOR_EOL, "\005"},
+  {"forward-char", OP_EDITOR_FORWARD_CHAR, "\006"},
+  {"forward-word", OP_EDITOR_FORWARD_WORD, "\033f"},
+  {"backspace", OP_EDITOR_BACKSPACE, "\010"},
+  {"kill-eol", OP_EDITOR_KILL_EOL, "\013"},
+  {"kill-eow", OP_EDITOR_KILL_EOW, "\033d"},
+  {"kill-line", OP_EDITOR_KILL_LINE, "\025"},
+  {"quote-char", OP_EDITOR_QUOTE_CHAR, "\026"},
+  {"kill-word", OP_EDITOR_KILL_WORD, "\027"},
+  {"complete", OP_EDITOR_COMPLETE, "\t"},
+  {"complete-query", OP_EDITOR_COMPLETE_QUERY, "\024"},
+  {"buffy-cycle", OP_EDITOR_BUFFY_CYCLE, " "},
+  {"history-up", OP_EDITOR_HISTORY_UP, NULL},
+  {"history-down", OP_EDITOR_HISTORY_DOWN, NULL},
+  {"transpose-chars", OP_EDITOR_TRANSPOSE_CHARS, NULL},
+  {NULL, 0, NULL}
 };
 
 
 
 struct binding_t OpPgp[] = {
-  { "verify-key",      OP_VERIFY_KEY,          "c" },
-  { "view-name",       OP_VIEW_ID,             "%" },
-  { NULL,              0,                              NULL }
+  {"verify-key", OP_VERIFY_KEY, "c"},
+  {"view-name", OP_VIEW_ID, "%"},
+  {NULL, 0, NULL}
 };
 
 
@@ -478,22 +478,22 @@ struct binding_t OpPgp[] = {
    for the SMIME menu.  */
 struct binding_t OpSmime[] = {
 #ifdef CRYPT_BACKEND_GPGME
-  { "verify-key",    OP_VERIFY_KEY,             "c" },
-  { "view-name",     OP_VIEW_ID,               "%" },
+  {"verify-key", OP_VERIFY_KEY, "c"},
+  {"view-name", OP_VIEW_ID, "%"},
 #endif
-  { NULL,      0,      NULL }
+  {NULL, 0, NULL}
 };
 
 
 
 #ifdef MIXMASTER
 struct binding_t OpMix[] = {
-  { "accept",          OP_MIX_USE,     M_ENTER_S },
-  { "append",          OP_MIX_APPEND,  "a"       },
-  { "insert",          OP_MIX_INSERT,  "i"       },
-  { "delete",          OP_MIX_DELETE,  "d"       },
-  { "chain-prev",      OP_MIX_CHAIN_PREV, "<left>" },
-  { "chain-next",      OP_MIX_CHAIN_NEXT, "<right>" },
-  { NULL,              0,              NULL }
+  {"accept", OP_MIX_USE, M_ENTER_S},
+  {"append", OP_MIX_APPEND, "a"},
+  {"insert", OP_MIX_INSERT, "i"},
+  {"delete", OP_MIX_DELETE, "d"},
+  {"chain-prev", OP_MIX_CHAIN_PREV, "<left>"},
+  {"chain-next", OP_MIX_CHAIN_NEXT, "<right>"},
+  {NULL, 0, NULL}
 };
 #endif /* MIXMASTER */
index 7163627..d11c26d 100644 (file)
@@ -19,10 +19,10 @@ int fclose ();
 static void strip_trailing_dot (char *q)
 {
   char *p = q;
-  
+
   for (; *q; q++)
     p = q;
-  
+
   if (*p == '.')
     *p = '\0';
 }
@@ -34,32 +34,32 @@ int getdnsdomainname (char *s, size_t l)
   char *p = NULL;
   char *q;
 
-  if ((f = fopen ("/etc/resolv.conf", "r")) == NULL) return (-1);
+  if ((f = fopen ("/etc/resolv.conf", "r")) == NULL)
+    return (-1);
 
   tmp[sizeof (tmp) - 1] = 0;
 
-  l--; /* save room for the terminal \0 */
+  l--;                          /* save room for the terminal \0 */
 
-  while (fgets (tmp, sizeof (tmp) - 1, f) != NULL)
-  {
+  while (fgets (tmp, sizeof (tmp) - 1, f) != NULL) {
     p = tmp;
-    while (ISSPACE (*p)) p++;
-    if (mutt_strncmp ("domain", p, 6) == 0 || mutt_strncmp ("search", p, 6) == 0)
-    {
+    while (ISSPACE (*p))
+      p++;
+    if (mutt_strncmp ("domain", p, 6) == 0
+        || mutt_strncmp ("search", p, 6) == 0) {
       p += 6;
-      
+
       for (q = strtok (p, " \t\n"); q; q = strtok (NULL, " \t\n"))
-       if (strcmp (q, "."))
-         break;
-
-      if (q)
-      {
-       strip_trailing_dot (q);
-       strfcpy (s, q, l);
-       safe_fclose (&f);
-       return 0;
+        if (strcmp (q, "."))
+          break;
+
+      if (q) {
+        strip_trailing_dot (q);
+        strfcpy (s, q, l);
+        safe_fclose (&f);
+        return 0;
       }
-      
+
     }
   }
 
index 45449e8..35ec648 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 WHERE void (*mutt_error) (const char *, ...);
 WHERE void (*mutt_message) (const char *, ...);
@@ -56,6 +56,7 @@ WHERE char *Fqdn;
 WHERE char *HdrFmt;
 WHERE char *Homedir;
 WHERE char *Hostname;
+
 #ifdef USE_IMAP
 WHERE char *ImapAuthenticators INITVAL (NULL);
 WHERE char *ImapDelimChars INITVAL (NULL);
@@ -69,6 +70,7 @@ WHERE char *Ispell;
 WHERE char *Locale;
 WHERE char *MailcapPath;
 WHERE char *Maildir;
+
 #if USE_HCACHE
 WHERE char *HeaderCache;
 WHERE char *HeaderCachePageSize;
@@ -92,6 +94,7 @@ WHERE char *MixEntryFormat;
 WHERE char *OperatingSystem INITVAL (NULL);
 
 WHERE char *Muttrc INITVAL (NULL);
+
 #ifdef USE_NNTP
 WHERE char *NewsCacheDir;
 WHERE char *GroupFormat;
@@ -105,6 +108,7 @@ WHERE char *Outbox;
 WHERE char *Pager;
 WHERE char *PagerFmt;
 WHERE char *PipeSep;
+
 #ifdef USE_POP
 WHERE char *PopAuthenticators INITVAL (NULL);
 WHERE short PopCheckTimeout;
@@ -125,6 +129,7 @@ WHERE char *SidebarDelim;
 WHERE char *Signature;
 WHERE char *SignOffString;
 WHERE char *SimpleSearch;
+
 #if defined(USE_LIBESMTP)
 WHERE char *SmtpAuthUser;
 WHERE char *SmtpAuthPass;
@@ -133,6 +138,7 @@ WHERE unsigned short SmtpPort;
 #endif
 WHERE char *Spoolfile;
 WHERE char *SpamSep;
+
 #if defined(USE_SSL) || defined(USE_NSS) || defined(USE_GNUTLS)
 WHERE char *SslCertFile INITVAL (NULL);
 #endif
@@ -159,32 +165,32 @@ WHERE char *XtermIcon;
 WHERE char *CurrentFolder;
 WHERE char *LastFolder;
 
-WHERE LIST *AutoViewList INITVAL(0);
-WHERE LIST *AlternativeOrderList INITVAL(0);
-WHERE LIST *HeaderOrderList INITVAL(0);
-WHERE LIST *Ignore INITVAL(0);
-WHERE LIST *MimeLookupList INITVAL(0);
-WHERE LIST *UnIgnore INITVAL(0);
-
-WHERE RX_LIST *Alternates INITVAL(0);
-WHERE RX_LIST *UnAlternates INITVAL(0);
-WHERE RX_LIST *MailLists INITVAL(0);
-WHERE RX_LIST *UnMailLists INITVAL(0);
-WHERE RX_LIST *SubscribedLists INITVAL(0);
-WHERE RX_LIST *UnSubscribedLists INITVAL(0);
-WHERE SPAM_LIST *SpamList INITVAL(0);
-WHERE RX_LIST *NoSpamList INITVAL(0);
+WHERE LIST *AutoViewList INITVAL (0);
+WHERE LIST *AlternativeOrderList INITVAL (0);
+WHERE LIST *HeaderOrderList INITVAL (0);
+WHERE LIST *Ignore INITVAL (0);
+WHERE LIST *MimeLookupList INITVAL (0);
+WHERE LIST *UnIgnore INITVAL (0);
+
+WHERE RX_LIST *Alternates INITVAL (0);
+WHERE RX_LIST *UnAlternates INITVAL (0);
+WHERE RX_LIST *MailLists INITVAL (0);
+WHERE RX_LIST *UnMailLists INITVAL (0);
+WHERE RX_LIST *SubscribedLists INITVAL (0);
+WHERE RX_LIST *UnSubscribedLists INITVAL (0);
+WHERE SPAM_LIST *SpamList INITVAL (0);
+WHERE RX_LIST *NoSpamList INITVAL (0);
 
 /* bit vector for boolean variables */
 #ifdef MAIN_C
-unsigned char Options[(OPTMAX + 7)/8];
+unsigned char Options[(OPTMAX + 7) / 8];
 #else
 extern unsigned char Options[];
 #endif
 
 /* bit vector for the yes/no/ask variable type */
 #ifdef MAIN_C
-unsigned char QuadOptions[(OPT_MAX*2 + 7) / 8];
+unsigned char QuadOptions[(OPT_MAX * 2 + 7) / 8];
 #else
 extern unsigned char QuadOptions[];
 #endif
@@ -205,7 +211,7 @@ WHERE short ReadInc;
 WHERE short SendmailWait;
 WHERE short SleepTime INITVAL (1);
 WHERE short Timeout;
-WHERE short Umask INITVAL(0077);
+WHERE short Umask INITVAL (0077);
 WHERE short WrapMargin;
 WHERE short WriteInc;
 WHERE short MaxLineLength;
@@ -214,9 +220,10 @@ WHERE short ScoreThresholdDelete;
 WHERE short ScoreThresholdRead;
 WHERE short ScoreThresholdFlag;
 
-WHERE struct buffy_t *CurBuffy INITVAL(0);
-WHERE short DrawFullLine INITVAL(0);
+WHERE struct buffy_t *CurBuffy INITVAL (0);
+WHERE short DrawFullLine INITVAL (0);
 WHERE short SidebarWidth;
+
 #ifdef USE_IMAP
 WHERE short ImapKeepalive;
 WHERE short ImapBuffyTimeout;
@@ -280,17 +287,23 @@ WHERE int debuglevel INITVAL (0);
 
 #ifdef MAIN_C
 const char *Weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-const char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ERR" };
-
-const char *BodyTypes[] = { "x-unknown", "audio", "application", "image", "message", "model", "multipart", "text", "video" };
-const char *BodyEncodings[] = { "x-unknown", "7bit", "8bit", "quoted-printable", "base64", "binary", "x-uuencoded" };
+const char *Months[] =
+  { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
+"Nov", "Dec", "ERR" };
+
+const char *BodyTypes[] =
+  { "x-unknown", "audio", "application", "image", "message", "model",
+"multipart", "text", "video" };
+const char *BodyEncodings[] =
+  { "x-unknown", "7bit", "8bit", "quoted-printable", "base64", "binary",
+"x-uuencoded" };
 #else
 extern const char *Weekdays[];
 extern const char *Months[];
 #endif
 
 #ifdef MAIN_C
-/* so that global vars get included */ 
+/* so that global vars get included */
 #include "mx.h"
 #include "mutt_regex.h"
 #include "buffy.h"
index caf2f21..f2e740c 100644 (file)
@@ -78,11 +78,10 @@ static void fix_uid (char *uid)
   char *s, *d;
   iconv_t cd;
 
-  for (s = d = uid; *s;)
-  {
-    if (*s == '\\' && *(s+1) == 'x' && isxdigit ((unsigned char) *(s+2)) && isxdigit ((unsigned char) *(s+3)))
-    {
-      *d++ = hexval (*(s+2)) << 4 | hexval (*(s+3));
+  for (s = d = uid; *s;) {
+    if (*s == '\\' && *(s + 1) == 'x' && isxdigit ((unsigned char) *(s + 2))
+        && isxdigit ((unsigned char) *(s + 3))) {
+      *d++ = hexval (*(s + 2)) << 4 | hexval (*(s + 3));
       s += 4;
     }
     else
@@ -90,26 +89,23 @@ static void fix_uid (char *uid)
   }
   *d = '\0';
 
-  if (_chs && (cd = mutt_iconv_open (_chs, "utf-8", 0)) != (iconv_t)-1)
-  {
-    int n = s - uid + 1; /* chars available in original buffer */
+  if (_chs && (cd = mutt_iconv_open (_chs, "utf-8", 0)) != (iconv_t) - 1) {
+    int n = s - uid + 1;        /* chars available in original buffer */
     char *buf;
     ICONV_CONST char *ib;
     char *ob;
     size_t ibl, obl;
 
-    buf = safe_malloc (n+1);
+    buf = safe_malloc (n + 1);
     ib = uid, ibl = d - uid + 1, ob = buf, obl = n;
     iconv (cd, &ib, &ibl, &ob, &obl);
-    if (!ibl)
-    {
-      if (ob-buf < n)
-      {
-       memcpy (uid, buf, ob-buf);
-       uid[ob-buf] = '\0';
+    if (!ibl) {
+      if (ob - buf < n) {
+        memcpy (uid, buf, ob - buf);
+        uid[ob - buf] = '\0';
       }
-      else if (ob-buf == n && (buf[n] = 0, strlen (buf) < n))
-       memcpy (uid, buf, n);
+      else if (ob - buf == n && (buf[n] = 0, strlen (buf) < n))
+        memcpy (uid, buf, n);
     }
     FREE (&buf);
     iconv_close (cd);
@@ -127,193 +123,184 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
   *is_subkey = 0;
   if (!*buf)
     return NULL;
-  
+
   dprint (2, (debugfile, "parse_pub_line: buf = `%s'\n", buf));
-  
-  for (p = buf; p; p = pend)
-  {
+
+  for (p = buf; p; p = pend) {
     if ((pend = strchr (p, ':')))
       *pend++ = 0;
     field++;
     if (field > 1 && !*p)
       continue;
 
-    switch (field)
-    {
-      case 1:                  /* record type */
+    switch (field) {
+    case 1:                    /* record type */
       {
-       dprint (2, (debugfile, "record type: %s\n", p));
-       
-       if (!mutt_strcmp (p, "pub"))
-         ;
-       else if (!mutt_strcmp (p, "sub"))
-         *is_subkey = 1;
-       else if (!mutt_strcmp (p, "sec"))
-         ;
-       else if (!mutt_strcmp (p, "ssb"))
-         *is_subkey = 1;
-       else if (!mutt_strcmp (p, "uid"))
-         is_uid = 1;
-       else
-         return NULL;
-       
-       if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
-         k = safe_calloc (sizeof *k, 1);
-
-       break;
+        dprint (2, (debugfile, "record type: %s\n", p));
+
+        if (!mutt_strcmp (p, "pub"));
+        else if (!mutt_strcmp (p, "sub"))
+          *is_subkey = 1;
+        else if (!mutt_strcmp (p, "sec"));
+        else if (!mutt_strcmp (p, "ssb"))
+          *is_subkey = 1;
+        else if (!mutt_strcmp (p, "uid"))
+          is_uid = 1;
+        else
+          return NULL;
+
+        if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
+          k = safe_calloc (sizeof *k, 1);
+
+        break;
       }
-      case 2:                  /* trust info */
+    case 2:                    /* trust info */
       {
-       dprint (2, (debugfile, "trust info: %s\n", p));
-       
-       switch (*p)
-       {                               /* look only at the first letter */
-         case 'e':
-           flags |= KEYFLAG_EXPIRED;
-           break;
-         case 'r':
-           flags |= KEYFLAG_REVOKED;
-           break;
-         case 'd':
-           flags |= KEYFLAG_DISABLED;
-           break;
-         case 'n':
-           trust = 1;
-           break;
-         case 'm':
-           trust = 2;
-           break;
-         case 'f':
-           trust = 3;
-           break;
-         case 'u':
-           trust = 3;
-           break;
-       }
+        dprint (2, (debugfile, "trust info: %s\n", p));
+
+        switch (*p) {           /* look only at the first letter */
+        case 'e':
+          flags |= KEYFLAG_EXPIRED;
+          break;
+        case 'r':
+          flags |= KEYFLAG_REVOKED;
+          break;
+        case 'd':
+          flags |= KEYFLAG_DISABLED;
+          break;
+        case 'n':
+          trust = 1;
+          break;
+        case 'm':
+          trust = 2;
+          break;
+        case 'f':
+          trust = 3;
+          break;
+        case 'u':
+          trust = 3;
+          break;
+        }
 
         if (!is_uid && !(*is_subkey && option (OPTPGPIGNORESUB)))
-         k->flags |= flags;
+          k->flags |= flags;
 
-       break;
+        break;
       }
-      case 3:                  /* key length  */
+    case 3:                    /* key length  */
       {
-       
-       dprint (2, (debugfile, "key len: %s\n", p));
-       
-       if (!(*is_subkey && option (OPTPGPIGNORESUB)))
-         k->keylen = atoi (p); /* fixme: add validation checks */
-       break;
+
+        dprint (2, (debugfile, "key len: %s\n", p));
+
+        if (!(*is_subkey && option (OPTPGPIGNORESUB)))
+          k->keylen = atoi (p); /* fixme: add validation checks */
+        break;
       }
-      case 4:                  /* pubkey algo */
+    case 4:                    /* pubkey algo */
       {
-       
-       dprint (2, (debugfile, "pubkey algorithm: %s\n", p));
-       
-       if (!(*is_subkey && option (OPTPGPIGNORESUB)))
-       {
-         k->numalg = atoi (p);
-         k->algorithm = pgp_pkalgbytype (atoi (p));
-       }
-       break;
+
+        dprint (2, (debugfile, "pubkey algorithm: %s\n", p));
+
+        if (!(*is_subkey && option (OPTPGPIGNORESUB))) {
+          k->numalg = atoi (p);
+          k->algorithm = pgp_pkalgbytype (atoi (p));
+        }
+        break;
       }
-      case 5:                  /* 16 hex digits with the long keyid. */
+    case 5:                    /* 16 hex digits with the long keyid. */
       {
-       dprint (2, (debugfile, "key id: %s\n", p));
-       
-       if (!(*is_subkey && option (OPTPGPIGNORESUB)))
-         mutt_str_replace (&k->keyid, p);
-       break;
+        dprint (2, (debugfile, "key id: %s\n", p));
+
+        if (!(*is_subkey && option (OPTPGPIGNORESUB)))
+          mutt_str_replace (&k->keyid, p);
+        break;
 
       }
-      case 6:                  /* timestamp (1998-02-28) */
+    case 6:                    /* timestamp (1998-02-28) */
       {
-       char tstr[11];
-       struct tm time;
-       
-       dprint (2, (debugfile, "time stamp: %s\n", p));
-       
-       if (!p)
-         break;
-       time.tm_sec = 0;
-       time.tm_min = 0;
-       time.tm_hour = 12;
-       strncpy (tstr, p, 11);
-       tstr[4] = '\0';
-       time.tm_year = atoi (tstr)-1900;
-       tstr[7] = '\0';
-       time.tm_mon = (atoi (tstr+5))-1;
-       time.tm_mday = atoi (tstr+8);
-       k->gen_time = mutt_mktime (&time, 0);
+        char tstr[11];
+        struct tm time;
+
+        dprint (2, (debugfile, "time stamp: %s\n", p));
+
+        if (!p)
+          break;
+        time.tm_sec = 0;
+        time.tm_min = 0;
+        time.tm_hour = 12;
+        strncpy (tstr, p, 11);
+        tstr[4] = '\0';
+        time.tm_year = atoi (tstr) - 1900;
+        tstr[7] = '\0';
+        time.tm_mon = (atoi (tstr + 5)) - 1;
+        time.tm_mday = atoi (tstr + 8);
+        k->gen_time = mutt_mktime (&time, 0);
         break;
       }
-      case 7:                  /* valid for n days */
-        break;
-      case 8:                  /* Local id         */
-        break;
-      case 9:                  /* ownertrust       */
-        break;
-      case 10:                 /* name             */
+    case 7:                    /* valid for n days */
+      break;
+    case 8:                    /* Local id         */
+      break;
+    case 9:                    /* ownertrust       */
+      break;
+    case 10:                   /* name             */
       {
-       if (!pend || !*p)
-         break;                        /* empty field or no trailing colon */
-
-       /* ignore user IDs on subkeys */
-       if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))
-         break;
-       
-       dprint (2, (debugfile, "user ID: %s\n", p));
-       
-       uid = safe_calloc (sizeof (pgp_uid_t), 1);
-       fix_uid (p);
-       uid->addr = safe_strdup (p);
-       uid->trust = trust;
-       uid->flags |= flags;
-       uid->parent = k;
-       uid->next = k->address;
-       k->address = uid;
-       
-       if (strstr (p, "ENCR"))
-         k->flags |= KEYFLAG_PREFER_ENCRYPTION;
-       if (strstr (p, "SIGN"))
-         k->flags |= KEYFLAG_PREFER_SIGNING;
-
-       break;
-      }
-      case 11:                 /* signature class  */
-        break;
-      case 12:                 /* key capabilities */
-       dprint (2, (debugfile, "capabilities info: %s\n", p));
-       
-       while(*p)
-         {
-           switch(*p++)
-             {
-             case 'D':
-               flags |= KEYFLAG_DISABLED;
-               break;
-
-             case 'e':
-               flags |= KEYFLAG_CANENCRYPT;
-               break;
-
-             case 's':
-               flags |= KEYFLAG_CANSIGN;
-               break;
-             }
-         }
-
-        if (!is_uid && 
-           (!*is_subkey || !option (OPTPGPIGNORESUB)
-            || !((flags & KEYFLAG_DISABLED)
-                 || (flags & KEYFLAG_REVOKED)
-                 || (flags & KEYFLAG_EXPIRED))))
-         k->flags |= flags;
-
-       break;
-      
-      default:
+        if (!pend || !*p)
+          break;                /* empty field or no trailing colon */
+
+        /* ignore user IDs on subkeys */
+        if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))
+          break;
+
+        dprint (2, (debugfile, "user ID: %s\n", p));
+
+        uid = safe_calloc (sizeof (pgp_uid_t), 1);
+        fix_uid (p);
+        uid->addr = safe_strdup (p);
+        uid->trust = trust;
+        uid->flags |= flags;
+        uid->parent = k;
+        uid->next = k->address;
+        k->address = uid;
+
+        if (strstr (p, "ENCR"))
+          k->flags |= KEYFLAG_PREFER_ENCRYPTION;
+        if (strstr (p, "SIGN"))
+          k->flags |= KEYFLAG_PREFER_SIGNING;
+
         break;
+      }
+    case 11:                   /* signature class  */
+      break;
+    case 12:                   /* key capabilities */
+      dprint (2, (debugfile, "capabilities info: %s\n", p));
+
+      while (*p) {
+        switch (*p++) {
+        case 'D':
+          flags |= KEYFLAG_DISABLED;
+          break;
+
+        case 'e':
+          flags |= KEYFLAG_CANENCRYPT;
+          break;
+
+        case 's':
+          flags |= KEYFLAG_CANSIGN;
+          break;
+        }
+      }
+
+      if (!is_uid && (!*is_subkey || !option (OPTPGPIGNORESUB)
+                      || !((flags & KEYFLAG_DISABLED)
+                           || (flags & KEYFLAG_REVOKED)
+                           || (flags & KEYFLAG_EXPIRED))))
+        k->flags |= flags;
+
+      break;
+
+    default:
+      break;
     }
   }
   return k;
@@ -332,41 +319,36 @@ pgp_key_t pgp_get_candidates (pgp_ring_t keyring, LIST * hints)
     return NULL;
 
   mutt_str_replace (&_chs, Charset);
-  
+
   thepid = pgp_invoke_list_keys (NULL, &fp, NULL, -1, -1, devnull,
-                                keyring, hints);
-  if (thepid == -1)
-  {
+                                 keyring, hints);
+  if (thepid == -1) {
     close (devnull);
     return NULL;
   }
 
   kend = &db;
   k = NULL;
-  while (fgets (buf, sizeof (buf) - 1, fp))
-  {
+  while (fgets (buf, sizeof (buf) - 1, fp)) {
     if (!(kk = parse_pub_line (buf, &is_sub, k)))
       continue;
 
     /* Only append kk to the list if it's new. */
-    if (kk != k)
-    {
+    if (kk != k) {
       if (k)
-       kend = &k->next;
+        kend = &k->next;
       *kend = k = kk;
 
-      if (is_sub)
-      {
-       pgp_uid_t **l;
-       
-       k->flags  |= KEYFLAG_SUBKEY;
-       k->parent  = mainkey;
-       for (l = &k->address; *l; l = &(*l)->next)
-         ;
-       *l = pgp_copy_uids (mainkey->address, k);
+      if (is_sub) {
+        pgp_uid_t **l;
+
+        k->flags |= KEYFLAG_SUBKEY;
+        k->parent = mainkey;
+        for (l = &k->address; *l; l = &(*l)->next);
+        *l = pgp_copy_uids (mainkey->address, k);
       }
       else
-       mainkey = k;
+        mainkey = k;
     }
   }
 
@@ -377,7 +359,6 @@ pgp_key_t pgp_get_candidates (pgp_ring_t keyring, LIST * hints)
   mutt_wait_filter (thepid);
 
   close (devnull);
-  
+
   return db;
 }
-
index 030916d..8ddee8c 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -46,28 +46,28 @@ typedef void handler_f (BODY *, STATE *);
 typedef handler_f *handler_t;
 
 int Index_hex[128] = {
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-     0, 1, 2, 3,  4, 5, 6, 7,  8, 9,-1,-1, -1,-1,-1,-1,
-    -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
+  -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
 };
 
 int Index_64[128] = {
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
-    52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
-    -1, 0, 1, 2,  3, 4, 5, 6,  7, 8, 9,10, 11,12,13,14,
-    15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
-    -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
-    41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+  -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+  15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+  -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
 };
 
-static void state_prefix_put (const char *d, size_t dlen, STATE *s)
+static void state_prefix_put (const char *d, size_t dlen, STATE * s)
 {
   if (s->prefix)
     while (dlen--)
@@ -76,37 +76,33 @@ static void state_prefix_put (const char *d, size_t dlen, STATE *s)
     fwrite (d, dlen, 1, s->fpout);
 }
 
-void mutt_convert_to_state(iconv_t cd, char *bufi, size_t *l, STATE *s)
+void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s)
 {
   char bufo[BUFO_SIZE];
   ICONV_CONST char *ib;
   char *ob;
   size_t ibl, obl;
 
-  if (!bufi)
-  {
-    if (cd != (iconv_t)(-1))
-    {
+  if (!bufi) {
+    if (cd != (iconv_t) (-1)) {
       ob = bufo, obl = sizeof (bufo);
       iconv (cd, 0, 0, &ob, &obl);
       if (ob != bufo)
-       state_prefix_put (bufo, ob - bufo, s);
+        state_prefix_put (bufo, ob - bufo, s);
     }
     if (Quotebuf[0] != '\0')
       state_prefix_putc ('\n', s);
     return;
   }
 
-  if (cd == (iconv_t)(-1))
-  {
+  if (cd == (iconv_t) (-1)) {
     state_prefix_put (bufi, *l, s);
     *l = 0;
     return;
   }
 
   ib = bufi, ibl = *l;
-  for (;;)
-  {
+  for (;;) {
     ob = bufo, obl = sizeof (bufo);
     mutt_iconv (cd, &ib, &ibl, &ob, &obl, 0, "?");
     if (ob == bufo)
@@ -117,32 +113,28 @@ void mutt_convert_to_state(iconv_t cd, char *bufi, size_t *l, STATE *s)
   *l = ibl;
 }
 
-void mutt_decode_xbit (STATE *s, long len, int istext, iconv_t cd)
+void mutt_decode_xbit (STATE * s, long len, int istext, iconv_t cd)
 {
   int c, ch;
   char bufi[BUFI_SIZE];
   size_t l = 0;
 
-  if (istext)
-  {
-    state_set_prefix(s);
-
-    while ((c = fgetc(s->fpin)) != EOF && len--)
-    {
-      if(c == '\r' && len)
-      {
-       if((ch = fgetc(s->fpin)) == '\n')
-       {
-         c = ch;
-         len--;
-       }
-       else 
-         ungetc(ch, s->fpin);
+  if (istext) {
+    state_set_prefix (s);
+
+    while ((c = fgetc (s->fpin)) != EOF && len--) {
+      if (c == '\r' && len) {
+        if ((ch = fgetc (s->fpin)) == '\n') {
+          c = ch;
+          len--;
+        }
+        else
+          ungetc (ch, s->fpin);
       }
 
       bufi[l++] = c;
       if (l == sizeof (bufi))
-       mutt_convert_to_state (cd, bufi, &l, s);
+        mutt_convert_to_state (cd, bufi, &l, s);
     }
 
     mutt_convert_to_state (cd, bufi, &l, s);
@@ -157,24 +149,22 @@ void mutt_decode_xbit (STATE *s, long len, int istext, iconv_t cd)
 static int qp_decode_triple (char *s, char *d)
 {
   /* soft line break */
-  if (*s == '=' && !(*(s+1)))
+  if (*s == '=' && !(*(s + 1)))
     return 1;
-  
+
   /* quoted-printable triple */
   if (*s == '=' &&
-      isxdigit ((unsigned char) *(s+1)) &&
-      isxdigit ((unsigned char) *(s+2)))
-  {
-    *d = (hexval (*(s+1)) << 4) | hexval (*(s+2));
+      isxdigit ((unsigned char) *(s + 1)) &&
+      isxdigit ((unsigned char) *(s + 2))) {
+    *d = (hexval (*(s + 1)) << 4) | hexval (*(s + 2));
     return 0;
   }
-  
+
   /* something else */
   return -1;
 }
 
-static void qp_decode_line (char *dest, char *src, size_t *l,
-                           int last)
+static void qp_decode_line (char *dest, char *src, size_t * l, int last)
 {
   char *d, *s;
   char c;
@@ -183,20 +173,26 @@ static void qp_decode_line (char *dest, char *src, size_t *l,
   int soft = 0;
 
   /* decode the line */
-  
-  for (d = dest, s = src; *s;)
-  {
-    switch ((kind = qp_decode_triple (s, &c)))
-    {
-      case  0: *d++ = c; s += 3; break;        /* qp triple */
-      case -1: *d++ = *s++;      break; /* single character */
-      case  1: soft = 1; s++;   break; /* soft line break */
+
+  for (d = dest, s = src; *s;) {
+    switch ((kind = qp_decode_triple (s, &c))) {
+    case 0:
+      *d++ = c;
+      s += 3;
+      break;                    /* qp triple */
+    case -1:
+      *d++ = *s++;
+      break;                    /* single character */
+    case 1:
+      soft = 1;
+      s++;
+      break;                    /* soft line break */
     }
   }
 
   if (!soft && last == '\n')
     *d++ = '\n';
-  
+
   *d = '\0';
   *l = d - dest;
 }
@@ -225,23 +221,22 @@ static void qp_decode_line (char *dest, char *src, size_t *l,
  * 
  */
 
-void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
+void mutt_decode_quoted (STATE * s, long len, int istext, iconv_t cd)
 {
   char line[STRING];
-  char decline[2*STRING];
+  char decline[2 * STRING];
   size_t l = 0;
-  size_t linelen;      /* number of input bytes in `line' */
+  size_t linelen;               /* number of input bytes in `line' */
   size_t l3;
-  
-  int last;    /* store the last character in the input line */
-  
+
+  int last;                     /* store the last character in the input line */
+
   if (istext)
-    state_set_prefix(s);
+    state_set_prefix (s);
 
-  while (len > 0)
-  {
+  while (len > 0) {
     last = 0;
-    
+
     /*
      * It's ok to use a fixed size buffer for input, even if the line turns
      * out to be longer than this.  Just process the line in chunks.  This
@@ -249,10 +244,10 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
      * lines are at most 76 characters, but we should be liberal about what
      * we accept.
      */
-    if (fgets (line, MIN ((ssize_t)sizeof (line), len + 1), s->fpin) == NULL)
+    if (fgets (line, MIN ((ssize_t) sizeof (line), len + 1), s->fpin) == NULL)
       break;
 
-    linelen = strlen(line);
+    linelen = strlen (line);
     len -= linelen;
 
     /*
@@ -262,11 +257,10 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
     last = linelen ? line[linelen - 1] : 0;
 
     /* chop trailing whitespace if we got the full line */
-    if (last == '\n')
-    {
-      while (linelen > 0 && ISSPACE (line[linelen-1]))
-       linelen--;
-      line[linelen]=0;
+    if (last == '\n') {
+      while (linelen > 0 && ISSPACE (line[linelen - 1]))
+        linelen--;
+      line[linelen] = 0;
     }
 
     /* decode and do character set conversion */
@@ -276,10 +270,10 @@ void mutt_decode_quoted (STATE *s, long len, int istext, iconv_t cd)
   }
 
   mutt_convert_to_state (cd, 0, 0, s);
-  state_reset_prefix(s);
+  state_reset_prefix (s);
 }
 
-void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd)
+void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd)
 {
   char buf[5];
   int c1, c2, c3, c4, ch, cr = 0, i;
@@ -288,22 +282,19 @@ void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd)
 
   buf[4] = 0;
 
-  if (istext) 
-    state_set_prefix(s);
+  if (istext)
+    state_set_prefix (s);
 
-  while (len > 0)
-  {
-    for (i = 0 ; i < 4 && len > 0 ; len--)
-    {
+  while (len > 0) {
+    for (i = 0; i < 4 && len > 0; len--) {
       if ((ch = fgetc (s->fpin)) == EOF)
-       break;
-      if (ch >= 0 && ch < 128 && (base64val(ch) != -1 || ch == '='))
-       buf[i++] = ch;
+        break;
+      if (ch >= 0 && ch < 128 && (base64val (ch) != -1 || ch == '='))
+        buf[i++] = ch;
     }
-    if (i != 4)
-    {
+    if (i != 4) {
       dprint (2, (debugfile, "%s:%d [mutt_decode_base64()]: "
-                 "didn't get a multiple of 4 chars.\n", __FILE__, __LINE__));
+                  "didn't get a multiple of 4 chars.\n", __FILE__, __LINE__));
       break;
     }
 
@@ -311,11 +302,11 @@ void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd)
     c2 = base64val (buf[1]);
     ch = (c1 << 2) | (c2 >> 4);
 
-    if (cr && ch != '\n') 
+    if (cr && ch != '\n')
       bufi[l++] = '\r';
 
     cr = 0;
-      
+
     if (istext && ch == '\r')
       cr = 1;
     else
@@ -336,7 +327,8 @@ void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd)
     else
       bufi[l++] = ch;
 
-    if (buf[3] == '=') break;
+    if (buf[3] == '=')
+      break;
     c4 = base64val (buf[3]);
     ch = ((c3 & 0x3) << 6) | c4;
 
@@ -348,17 +340,18 @@ void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd)
       cr = 1;
     else
       bufi[l++] = ch;
-    
+
     if (l + 8 >= sizeof (bufi))
       mutt_convert_to_state (cd, bufi, &l, s);
   }
 
-  if (cr) bufi[l++] = '\r';
+  if (cr)
+    bufi[l++] = '\r';
 
   mutt_convert_to_state (cd, bufi, &l, s);
   mutt_convert_to_state (cd, 0, 0, s);
 
-  state_reset_prefix(s);
+  state_reset_prefix (s);
 }
 
 unsigned char decode_byte (char ch)
@@ -368,7 +361,7 @@ unsigned char decode_byte (char ch)
   return ch - 32;
 }
 
-void mutt_decode_uuencoded (STATE *s, long len, int istext, iconv_t cd)
+void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd)
 {
   char tmps[SHORT_STRING];
   char linelen, c, l, out;
@@ -376,38 +369,34 @@ void mutt_decode_uuencoded (STATE *s, long len, int istext, iconv_t cd)
   char bufi[BUFI_SIZE];
   size_t k = 0;
 
-  if(istext)
-    state_set_prefix(s);
-  
-  while(len > 0)
-  {
-    if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL)
+  if (istext)
+    state_set_prefix (s);
+
+  while (len > 0) {
+    if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
       return;
-    len -= mutt_strlen(tmps);
+    len -= mutt_strlen (tmps);
     if ((!mutt_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5]))
       break;
   }
-  while(len > 0)
-  {
-    if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL)
+  while (len > 0) {
+    if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL)
       return;
-    len -= mutt_strlen(tmps);
+    len -= mutt_strlen (tmps);
     if (!mutt_strncmp (tmps, "end", 3))
       break;
     pt = tmps;
     linelen = decode_byte (*pt);
     pt++;
-    for (c = 0; c < linelen;)
-    {
-      for (l = 2; l <= 6; l += 2)
-      {
-       out = decode_byte (*pt) << l;
-       pt++;
-       out |= (decode_byte (*pt) >> (6 - l));
-       bufi[k++] = out;
-       c++;
-       if (c == linelen)
-         break;
+    for (c = 0; c < linelen;) {
+      for (l = 2; l <= 6; l += 2) {
+        out = decode_byte (*pt) << l;
+        pt++;
+        out |= (decode_byte (*pt) >> (6 - l));
+        bufi[k++] = out;
+        c++;
+        if (c == linelen)
+          break;
       }
       mutt_convert_to_state (cd, bufi, &k, s);
       pt++;
@@ -416,8 +405,8 @@ void mutt_decode_uuencoded (STATE *s, long len, int istext, iconv_t cd)
 
   mutt_convert_to_state (cd, bufi, &k, s);
   mutt_convert_to_state (cd, 0, 0, s);
-  
-  state_reset_prefix(s);
+
+  state_reset_prefix (s);
 }
 
 /* ----------------------------------------------------------------------------
@@ -425,34 +414,35 @@ void mutt_decode_uuencoded (STATE *s, long len, int istext, iconv_t cd)
  */
 
 #define IndentSize (4)
-    
-enum { RICH_PARAM=0, RICH_BOLD, RICH_UNDERLINE, RICH_ITALIC, RICH_NOFILL, 
+
+enum { RICH_PARAM = 0, RICH_BOLD, RICH_UNDERLINE, RICH_ITALIC, RICH_NOFILL,
   RICH_INDENT, RICH_INDENT_RIGHT, RICH_EXCERPT, RICH_CENTER, RICH_FLUSHLEFT,
-  RICH_FLUSHRIGHT, RICH_COLOR, RICH_LAST_TAG };
+  RICH_FLUSHRIGHT, RICH_COLOR, RICH_LAST_TAG
+};
 
 static struct {
   const char *tag_name;
   int index;
 } EnrichedTags[] = {
-  { "param",           RICH_PARAM },
-  { "bold",            RICH_BOLD },
-  { "italic",          RICH_ITALIC },
-  { "underline",       RICH_UNDERLINE },
-  { "nofill",          RICH_NOFILL },
-  { "excerpt",         RICH_EXCERPT },
-  { "indent",          RICH_INDENT },
-  { "indentright",     RICH_INDENT_RIGHT },
-  { "center",          RICH_CENTER },
-  { "flushleft",       RICH_FLUSHLEFT },
-  { "flushright",      RICH_FLUSHRIGHT },
-  { "flushboth",       RICH_FLUSHLEFT },
-  { "color",           RICH_COLOR },
-  { "x-color",         RICH_COLOR },
-  { NULL,              -1 }
+  {
+  "param", RICH_PARAM}, {
+  "bold", RICH_BOLD}, {
+  "italic", RICH_ITALIC}, {
+  "underline", RICH_UNDERLINE}, {
+  "nofill", RICH_NOFILL}, {
+  "excerpt", RICH_EXCERPT}, {
+  "indent", RICH_INDENT}, {
+  "indentright", RICH_INDENT_RIGHT}, {
+  "center", RICH_CENTER}, {
+  "flushleft", RICH_FLUSHLEFT}, {
+  "flushright", RICH_FLUSHRIGHT}, {
+  "flushboth", RICH_FLUSHLEFT}, {
+  "color", RICH_COLOR}, {
+  "x-color", RICH_COLOR}, {
+  NULL, -1}
 };
 
-struct enriched_state
-{
+struct enriched_state {
   char *buffer;
   char *line;
   char *param;
@@ -475,63 +465,52 @@ static void enriched_wrap (struct enriched_state *stte)
   int x;
   int extra;
 
-  if (stte->line_len)
-  {
-    if (stte->tag_level[RICH_CENTER] || stte->tag_level[RICH_FLUSHRIGHT])
-    {
+  if (stte->line_len) {
+    if (stte->tag_level[RICH_CENTER] || stte->tag_level[RICH_FLUSHRIGHT]) {
       /* Strip trailing white space */
       size_t y = stte->line_used - 1;
 
-      while (y && ISSPACE (stte->line[y]))
-      {
-       stte->line[y] = '\0';
-       y--;
-       stte->line_used--;
-       stte->line_len--;
+      while (y && ISSPACE (stte->line[y])) {
+        stte->line[y] = '\0';
+        y--;
+        stte->line_used--;
+        stte->line_len--;
       }
-      if (stte->tag_level[RICH_CENTER])
-      {
-       /* Strip leading whitespace */
-       y = 0;
-
-       while (stte->line[y] && ISSPACE (stte->line[y]))
-         y++;
-       if (y)
-       {
-         size_t z;
-
-         for (z = y ; z <= stte->line_used; z++)
-         {
-           stte->line[z - y] = stte->line[z];
-         }
-
-         stte->line_len -= y;
-         stte->line_used -= y;
-       }
+      if (stte->tag_level[RICH_CENTER]) {
+        /* Strip leading whitespace */
+        y = 0;
+
+        while (stte->line[y] && ISSPACE (stte->line[y]))
+          y++;
+        if (y) {
+          size_t z;
+
+          for (z = y; z <= stte->line_used; z++) {
+            stte->line[z - y] = stte->line[z];
+          }
+
+          stte->line_len -= y;
+          stte->line_used -= y;
+        }
       }
     }
 
     extra = stte->WrapMargin - stte->line_len - stte->indent_len -
       (stte->tag_level[RICH_INDENT_RIGHT] * IndentSize);
-    if (extra > 0) 
-    {
-      if (stte->tag_level[RICH_CENTER]) 
-      {
-       x = extra / 2;
-       while (x)
-       {
-         state_putc (' ', stte->s);
-         x--;
-       }
-      } 
-      else if (stte->tag_level[RICH_FLUSHRIGHT])
-      {
-       x = extra-1;
-       while (x)
-       {
-         state_putc (' ', stte->s);
-         x--;
-       }
+    if (extra > 0) {
+      if (stte->tag_level[RICH_CENTER]) {
+        x = extra / 2;
+        while (x) {
+          state_putc (' ', stte->s);
+          x--;
+        }
+      }
+      else if (stte->tag_level[RICH_FLUSHRIGHT]) {
+        x = extra - 1;
+        while (x) {
+          state_putc (' ', stte->s);
+          x--;
+        }
       }
     }
     state_puts (stte->line, stte->s);
@@ -542,38 +521,31 @@ static void enriched_wrap (struct enriched_state *stte)
   stte->line_len = 0;
   stte->line_used = 0;
   stte->indent_len = 0;
-  if (stte->s->prefix)
-  {
+  if (stte->s->prefix) {
     state_puts (stte->s->prefix, stte->s);
     stte->indent_len += mutt_strlen (stte->s->prefix);
   }
 
-  if (stte->tag_level[RICH_EXCERPT])
-  {
+  if (stte->tag_level[RICH_EXCERPT]) {
     x = stte->tag_level[RICH_EXCERPT];
-    while (x) 
-    {
-      if (stte->s->prefix)
-      {
-       state_puts (stte->s->prefix, stte->s);
-           stte->indent_len += mutt_strlen (stte->s->prefix);
+    while (x) {
+      if (stte->s->prefix) {
+        state_puts (stte->s->prefix, stte->s);
+        stte->indent_len += mutt_strlen (stte->s->prefix);
       }
-      else
-      {
-       state_puts ("> ", stte->s);
-       stte->indent_len += mutt_strlen ("> ");
+      else {
+        state_puts ("> ", stte->s);
+        stte->indent_len += mutt_strlen ("> ");
       }
       x--;
     }
   }
   else
     stte->indent_len = 0;
-  if (stte->tag_level[RICH_INDENT])
-  {
+  if (stte->tag_level[RICH_INDENT]) {
     x = stte->tag_level[RICH_INDENT] * IndentSize;
     stte->indent_len += x;
-    while (x) 
-    {
+    while (x) {
       state_putc (' ', stte->s);
       x--;
     }
@@ -582,91 +554,79 @@ static void enriched_wrap (struct enriched_state *stte)
 
 static void enriched_flush (struct enriched_state *stte, int wrap)
 {
-  if (!stte->tag_level[RICH_NOFILL] && (stte->line_len + stte->word_len > 
-      (stte->WrapMargin - (stte->tag_level[RICH_INDENT_RIGHT] * IndentSize) - 
-       stte->indent_len)))
+  if (!stte->tag_level[RICH_NOFILL] && (stte->line_len + stte->word_len >
+                                        (stte->WrapMargin -
+                                         (stte->tag_level[RICH_INDENT_RIGHT] *
+                                          IndentSize) - stte->indent_len)))
     enriched_wrap (stte);
 
-  if (stte->buff_used)
-  {
+  if (stte->buff_used) {
     stte->buffer[stte->buff_used] = '\0';
     stte->line_used += stte->buff_used;
-    if (stte->line_used > stte->line_max)
-    {
+    if (stte->line_used > stte->line_max) {
       stte->line_max = stte->line_used;
       safe_realloc (&stte->line, stte->line_max + 1);
     }
-    strcat (stte->line, stte->buffer); /* __STRCAT_CHECKED__ */
+    strcat (stte->line, stte->buffer);  /* __STRCAT_CHECKED__ */
     stte->line_len += stte->word_len;
     stte->word_len = 0;
     stte->buff_used = 0;
   }
-  if (wrap) 
-    enriched_wrap(stte);
+  if (wrap)
+    enriched_wrap (stte);
 }
 
 
 static void enriched_putc (int c, struct enriched_state *stte)
 {
-  if (stte->tag_level[RICH_PARAM]) 
-  {
-    if (stte->tag_level[RICH_COLOR]) 
-    {
+  if (stte->tag_level[RICH_PARAM]) {
+    if (stte->tag_level[RICH_COLOR]) {
       if (stte->param_used + 1 >= stte->param_len)
-       safe_realloc (&stte->param, (stte->param_len += STRING));
+        safe_realloc (&stte->param, (stte->param_len += STRING));
 
       stte->param[stte->param_used++] = c;
     }
-    return; /* nothing to do */
+    return;                     /* nothing to do */
   }
 
   /* see if more space is needed (plus extra for possible rich characters) */
-  if (stte->buff_len < stte->buff_used + 3)
-  {
+  if (stte->buff_len < stte->buff_used + 3) {
     stte->buff_len += LONG_STRING;
     safe_realloc (&stte->buffer, stte->buff_len + 1);
   }
 
-  if ((!stte->tag_level[RICH_NOFILL] && ISSPACE (c)) || c == '\0' )
-  {
+  if ((!stte->tag_level[RICH_NOFILL] && ISSPACE (c)) || c == '\0') {
     if (c == '\t')
       stte->word_len += 8 - (stte->line_len + stte->word_len) % 8;
     else
       stte->word_len++;
-    
+
     stte->buffer[stte->buff_used++] = c;
     enriched_flush (stte, 0);
   }
-  else
-  {
-    if (stte->s->flags & M_DISPLAY)
-    {
-      if (stte->tag_level[RICH_BOLD])
-      {
-       stte->buffer[stte->buff_used++] = c;
-       stte->buffer[stte->buff_used++] = '\010';
-       stte->buffer[stte->buff_used++] = c;
+  else {
+    if (stte->s->flags & M_DISPLAY) {
+      if (stte->tag_level[RICH_BOLD]) {
+        stte->buffer[stte->buff_used++] = c;
+        stte->buffer[stte->buff_used++] = '\010';
+        stte->buffer[stte->buff_used++] = c;
       }
-      else if (stte->tag_level[RICH_UNDERLINE])
-      {
+      else if (stte->tag_level[RICH_UNDERLINE]) {
 
-       stte->buffer[stte->buff_used++] = '_';
-       stte->buffer[stte->buff_used++] = '\010';
-       stte->buffer[stte->buff_used++] = c;
+        stte->buffer[stte->buff_used++] = '_';
+        stte->buffer[stte->buff_used++] = '\010';
+        stte->buffer[stte->buff_used++] = c;
       }
-      else if (stte->tag_level[RICH_ITALIC])
-      {
-       stte->buffer[stte->buff_used++] = c;
-       stte->buffer[stte->buff_used++] = '\010';
-       stte->buffer[stte->buff_used++] = '_';
+      else if (stte->tag_level[RICH_ITALIC]) {
+        stte->buffer[stte->buff_used++] = c;
+        stte->buffer[stte->buff_used++] = '\010';
+        stte->buffer[stte->buff_used++] = '_';
       }
-      else
-      {
-       stte->buffer[stte->buff_used++] = c;
+      else {
+        stte->buffer[stte->buff_used++] = c;
       }
     }
-    else
-    {
+    else {
       stte->buffer[stte->buff_used++] = c;
     }
     stte->word_len++;
@@ -677,14 +637,12 @@ static void enriched_puts (char *s, struct enriched_state *stte)
 {
   char *c;
 
-  if (stte->buff_len < stte->buff_used + mutt_strlen(s))
-  {
+  if (stte->buff_len < stte->buff_used + mutt_strlen (s)) {
     stte->buff_len += LONG_STRING;
     safe_realloc (&stte->buffer, stte->buff_len + 1);
   }
   c = s;
-  while (*c)
-  {
+  while (*c) {
     stte->buffer[stte->buff_used++] = *c;
     c++;
   }
@@ -697,80 +655,67 @@ static void enriched_set_flags (const char *tag, struct enriched_state *stte)
 
   if (*tagptr == '/')
     tagptr++;
-  
+
   for (i = 0, j = -1; EnrichedTags[i].tag_name; i++)
-    if (ascii_strcasecmp (EnrichedTags[i].tag_name,tagptr) == 0)
-    {
+    if (ascii_strcasecmp (EnrichedTags[i].tag_name, tagptr) == 0) {
       j = EnrichedTags[i].index;
       break;
     }
 
-  if (j != -1)
-  {
+  if (j != -1) {
     if (j == RICH_CENTER || j == RICH_FLUSHLEFT || j == RICH_FLUSHRIGHT)
       enriched_flush (stte, 1);
 
-    if (*tag == '/')
-    {
-      if (stte->tag_level[j]) /* make sure not to go negative */
-       stte->tag_level[j]--;
-      if ((stte->s->flags & M_DISPLAY) && j == RICH_PARAM && stte->tag_level[RICH_COLOR])
-      {
-       stte->param[stte->param_used] = '\0';
-       if (!ascii_strcasecmp(stte->param, "black"))
-       {
-         enriched_puts("\033[30m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "red"))
-       {
-         enriched_puts("\033[31m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "green"))
-       {
-         enriched_puts("\033[32m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "yellow"))
-       {
-         enriched_puts("\033[33m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "blue"))
-       {
-         enriched_puts("\033[34m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "magenta"))
-       {
-         enriched_puts("\033[35m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "cyan"))
-       {
-         enriched_puts("\033[36m", stte);
-       }
-       else if (!ascii_strcasecmp(stte->param, "white"))
-       {
-         enriched_puts("\033[37m", stte);
-       }
+    if (*tag == '/') {
+      if (stte->tag_level[j])   /* make sure not to go negative */
+        stte->tag_level[j]--;
+      if ((stte->s->flags & M_DISPLAY) && j == RICH_PARAM
+          && stte->tag_level[RICH_COLOR]) {
+        stte->param[stte->param_used] = '\0';
+        if (!ascii_strcasecmp (stte->param, "black")) {
+          enriched_puts ("\033[30m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "red")) {
+          enriched_puts ("\033[31m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "green")) {
+          enriched_puts ("\033[32m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "yellow")) {
+          enriched_puts ("\033[33m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "blue")) {
+          enriched_puts ("\033[34m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "magenta")) {
+          enriched_puts ("\033[35m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "cyan")) {
+          enriched_puts ("\033[36m", stte);
+        }
+        else if (!ascii_strcasecmp (stte->param, "white")) {
+          enriched_puts ("\033[37m", stte);
+        }
       }
-      if ((stte->s->flags & M_DISPLAY) && j == RICH_COLOR)
-      {
-       enriched_puts("\033[0m", stte);
+      if ((stte->s->flags & M_DISPLAY) && j == RICH_COLOR) {
+        enriched_puts ("\033[0m", stte);
       }
 
       /* flush parameter buffer when closing the tag */
-      if (j == RICH_PARAM)
-      {
-       stte->param_used = 0;
-       stte->param[0] = '\0';
+      if (j == RICH_PARAM) {
+        stte->param_used = 0;
+        stte->param[0] = '\0';
       }
     }
     else
       stte->tag_level[j]++;
 
     if (j == RICH_EXCERPT)
-      enriched_flush(stte, 1);
+      enriched_flush (stte, 1);
   }
 }
 
-void text_enriched_handler (BODY *a, STATE *s)
+void text_enriched_handler (BODY * a, STATE * s)
 {
   enum {
     TEXT, LANGLE, TAG, BOGUS_TAG, NEWLINE, ST_EOF, DONE
@@ -784,7 +729,9 @@ void text_enriched_handler (BODY *a, STATE *s)
 
   memset (&stte, 0, sizeof (stte));
   stte.s = s;
-  stte.WrapMargin = ((s->flags & M_DISPLAY) ? (COLS-4) : ((COLS-4)<72)?(COLS-4):72);
+  stte.WrapMargin =
+    ((s->flags & M_DISPLAY) ? (COLS - 4) : ((COLS - 4) <
+                                            72) ? (COLS - 4) : 72);
   stte.line_max = stte.WrapMargin * 4;
   stte.line = (char *) safe_calloc (1, stte.line_max + 1);
   stte.param = (char *) safe_calloc (1, STRING);
@@ -792,107 +739,96 @@ void text_enriched_handler (BODY *a, STATE *s)
   stte.param_len = STRING;
   stte.param_used = 0;
 
-  if (s->prefix)
-  {
+  if (s->prefix) {
     state_puts (s->prefix, s);
     stte.indent_len += mutt_strlen (s->prefix);
   }
 
-  while (state != DONE)
-  {
-    if (state != ST_EOF)
-    {
+  while (state != DONE) {
+    if (state != ST_EOF) {
       if (!bytes || (c = fgetc (s->fpin)) == EOF)
-       state = ST_EOF;
+        state = ST_EOF;
       else
-       bytes--;
+        bytes--;
     }
 
-    switch (state)
-    {
-      case TEXT :
-       switch (c)
-       {
-         case '<' :
-           state = LANGLE;
-           break;
-
-         case '\n' :
-           if (stte.tag_level[RICH_NOFILL])
-           {
-             enriched_flush (&stte, 1);
-           }
-           else 
-           {
-             enriched_putc (' ', &stte);
-             state = NEWLINE;
-           }
-           break;
-
-         default:
-           enriched_putc (c, &stte);
-       }
-       break;
-
-      case LANGLE :
-       if (c == '<')
-       {
-         enriched_putc (c, &stte);
-         state = TEXT;
-         break;
-       }
-       else
-       {
-         tag_len = 0;
-         state = TAG;
-       }
-       /* Yes, fall through (it wasn't a <<, so this char is first in TAG) */
-      case TAG :
-       if (c == '>')
-       {
-         tag[tag_len] = '\0';
-         enriched_set_flags (tag, &stte);
-         state = TEXT;
-       }
-       else if (tag_len < LONG_STRING)  /* ignore overly long tags */
-         tag[tag_len++] = c;
-       else
-         state = BOGUS_TAG;
-       break;
-
-      case BOGUS_TAG :
-       if (c == '>')
-         state = TEXT;
-       break;
-
-      case NEWLINE :
-       if (c == '\n')
-         enriched_flush (&stte, 1);
-       else
-       {
-         ungetc (c, s->fpin);
-         bytes++;
-         state = TEXT;
-       }
-       break;
-
-      case ST_EOF :
-       enriched_putc ('\0', &stte);
+    switch (state) {
+    case TEXT:
+      switch (c) {
+      case '<':
+        state = LANGLE;
+        break;
+
+      case '\n':
+        if (stte.tag_level[RICH_NOFILL]) {
+          enriched_flush (&stte, 1);
+        }
+        else {
+          enriched_putc (' ', &stte);
+          state = NEWLINE;
+        }
+        break;
+
+      default:
+        enriched_putc (c, &stte);
+      }
+      break;
+
+    case LANGLE:
+      if (c == '<') {
+        enriched_putc (c, &stte);
+        state = TEXT;
+        break;
+      }
+      else {
+        tag_len = 0;
+        state = TAG;
+      }
+      /* Yes, fall through (it wasn't a <<, so this char is first in TAG) */
+    case TAG:
+      if (c == '>') {
+        tag[tag_len] = '\0';
+        enriched_set_flags (tag, &stte);
+        state = TEXT;
+      }
+      else if (tag_len < LONG_STRING)   /* ignore overly long tags */
+        tag[tag_len++] = c;
+      else
+        state = BOGUS_TAG;
+      break;
+
+    case BOGUS_TAG:
+      if (c == '>')
+        state = TEXT;
+      break;
+
+    case NEWLINE:
+      if (c == '\n')
         enriched_flush (&stte, 1);
-       state = DONE;
-       break;
+      else {
+        ungetc (c, s->fpin);
+        bytes++;
+        state = TEXT;
+      }
+      break;
 
-      case DONE: /* not reached, but gcc complains if this is absent */
-       break;
+    case ST_EOF:
+      enriched_putc ('\0', &stte);
+      enriched_flush (&stte, 1);
+      state = DONE;
+      break;
+
+    case DONE:                 /* not reached, but gcc complains if this is absent */
+      break;
     }
   }
 
-  state_putc ('\n', s); /* add a final newline */
+  state_putc ('\n', s);         /* add a final newline */
 
   FREE (&(stte.buffer));
   FREE (&(stte.line));
   FREE (&(stte.param));
-}                                                                              
+}
 
 /*
  * An implementation of RFC 2646.
@@ -909,39 +845,40 @@ static int flowed_maybe_quoted (char *cont)
   return regexec ((regex_t *) QuoteRegexp.rx, cont, 0, NULL, 0) == 0;
 }
 
-static void flowed_quote (STATE *s, int level)
+static void flowed_quote (STATE * s, int level)
 {
   int i;
-  
-  if (s->prefix)
-  {
+
+  if (s->prefix) {
     if (option (OPTTEXTFLOWED))
       level++;
     else
       state_puts (s->prefix, s);
   }
-  
+
   for (i = 0; i < level; i++)
     state_putc ('>', s);
 }
 
-static void flowed_stuff (STATE *s, char *cont, int level)
+static void flowed_stuff (STATE * s, char *cont, int level)
 {
   if (!option (OPTTEXTFLOWED) && !(s->flags & M_DISPLAY))
     return;
 
-  if (s->flags & M_DISPLAY)
-  {
+  if (s->flags & M_DISPLAY) {
     /* 
      * Hack: If we are in the beginning of the line and there is 
      * some text on the line which looks like it's quoted, turn off 
      * ANSI colors, so quote coloring doesn't affect this line. 
      */
-    if (*cont && !level && !mutt_strcmp (Pager, "builtin") && flowed_maybe_quoted (cont))
-      state_puts ("\033[0m",s);
+    if (*cont && !level && !mutt_strcmp (Pager, "builtin")
+        && flowed_maybe_quoted (cont))
+      state_puts ("\033[0m", s);
   }
-  else if ((!(s->flags & M_PRINTING)) && 
-          ((*cont == ' ') || (*cont == '>') || (!level && !mutt_strncmp (cont, "From ", 5))))
+  else if ((!(s->flags & M_PRINTING)) && ((*cont == ' ') || (*cont == '>')
+                                          || (!level
+                                              && !mutt_strncmp (cont, "From ",
+                                                                5))))
     state_putc (' ', s);
 }
 
@@ -956,81 +893,78 @@ static char *flowed_skip_indent (char *prefix, char *cont)
 static int flowed_visual_strlen (char *l, int i)
 {
   int j;
-  for (j = 0; *l; l++)
-  {
+
+  for (j = 0; *l; l++) {
     if (*l == '\t')
       j += 8 - ((i + j) % 8);
     else
       j++;
   }
-  
+
   return j;
 }
 
-static void text_plain_flowed_handler (BODY *a, STATE *s)
+static void text_plain_flowed_handler (BODY * a, STATE * s)
 {
   char line[LONG_STRING];
   char indent[LONG_STRING];
 
-  int  quoted = -1;
-  int  last_quoted;
-  int  full = 1;
-  int  last_full;
-  int  col = 0, tmpcol;
-
-  int  i_add = 0;
-  int  add = 0;
-  int  soft = 0;
-  int  l, rl;
-  
-  int  flowed_max;
-  int  bytes = a->length;
-  int  actually_wrap = 0;
-  
+  int quoted = -1;
+  int last_quoted;
+  int full = 1;
+  int last_full;
+  int col = 0, tmpcol;
+
+  int i_add = 0;
+  int add = 0;
+  int soft = 0;
+  int l, rl;
+
+  int flowed_max;
+  int bytes = a->length;
+  int actually_wrap = 0;
+
   char *cont = NULL;
   char *tail = NULL;
   char *lc = NULL;
   char *t;
-  
+
   *indent = '\0';
-  
+
   if (s->prefix)
     add = 1;
-  
+
   /*
-  if ((flowed_max = FLOWED_MAX) > COLS - 3)
-    flowed_max = COLS - 3;
-  if (flowed_max > COLS - WrapMargin)
-    flowed_max = COLS - WrapMargin;
-  if (flowed_max <= 0)
-    flowed_max = COLS;
-    */
+     if ((flowed_max = FLOWED_MAX) > COLS - 3)
+     flowed_max = COLS - 3;
+     if (flowed_max > COLS - WrapMargin)
+     flowed_max = COLS - WrapMargin;
+     if (flowed_max <= 0)
+     flowed_max = COLS;
+   */
   flowed_max = COLS - WrapMargin;
   if (flowed_max <= 0)
     flowed_max = COLS;
-  
-  fprintf(stderr,"flowed_max = %d\n",flowed_max);
 
-  while (bytes > 0 && fgets (line, sizeof (line), s->fpin))
-  {
-    bytes        -= strlen (line);
-    tail          = NULL;
+  fprintf (stderr, "flowed_max = %d\n", flowed_max);
+
+  while (bytes > 0 && fgets (line, sizeof (line), s->fpin)) {
+    bytes -= strlen (line);
+    tail = NULL;
+
+    last_full = full;
 
-    last_full     = full;
-    
     /* 
      * If the last line wasn't fully read, this is the
      * tail of some line. 
      */
-    actually_wrap = !last_full; 
-    
-    if ((t = strrchr (line, '\r')) || (t = strrchr (line, '\n')))
-    {
-      *t   = '\0';
+    actually_wrap = !last_full;
+
+    if ((t = strrchr (line, '\r')) || (t = strrchr (line, '\n'))) {
+      *t = '\0';
       full = 1;
     }
-    else if ((t = strrchr (line, ' ')) || (t = strrchr (line, '\t')))
-    {
+    else if ((t = strrchr (line, ' ')) || (t = strrchr (line, '\t'))) {
       /* 
        * Bad: We have a line of more than LONG_STRING characters.
        * (Which SHOULD NOT happen, since lines SHOULD be <= 79
@@ -1045,14 +979,13 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
        */
 
       full = 0;
-      l    = strlen (t + 1);
+      l = strlen (t + 1);
       t[0] = ' ';
       t[1] = '\0';
 
-      if (l)
-      {
-       fseek (s->fpin, -l, SEEK_CUR);
-       bytes += l;
+      if (l) {
+        fseek (s->fpin, -l, SEEK_CUR);
+        bytes += l;
       }
     }
     else
@@ -1060,27 +993,24 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 
     last_quoted = quoted;
 
-    if (last_full)
-    {
+    if (last_full) {
       /* 
        * We are in the beginning of a new line. Determine quote level
        * and indentation prefix 
        */
-      for (quoted = 0; line[quoted] == '>'; quoted++)
-       ;
-      
+      for (quoted = 0; line[quoted] == '>'; quoted++);
+
       cont = line + quoted;
-      
+
       /* undo space stuffing */
       if (*cont == ' ')
-       cont++;
+        cont++;
 
       /* If there is an indentation, record it. */
-      cont  = flowed_skip_indent (indent, cont);
+      cont = flowed_skip_indent (indent, cont);
       i_add = flowed_visual_strlen (indent, quoted + add);
     }
-    else
-    {
+    else {
       /* 
        * This is just the tail of some over-long line. Keep
        * indentation and quote levels.  Don't unstuff.
@@ -1090,63 +1020,56 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 
     /* If we have a change in quoting depth, wrap. */
 
-    if (col && last_quoted != quoted && last_quoted >= 0)
-    {
+    if (col && last_quoted != quoted && last_quoted >= 0) {
       state_putc ('\n', s);
       col = 0;
     }
-    
-    do 
-    {
+
+    do {
       if (tail)
-       cont = tail;
+        cont = tail;
 
       SKIPWS (cont);
-      
+
       tail = NULL;
       soft = 0;
-      
+
       /* try to find a point for word wrapping */
 
     retry_wrap:
-      l  = flowed_visual_strlen (cont, quoted + i_add + add + col);
+      l = flowed_visual_strlen (cont, quoted + i_add + add + col);
       rl = mutt_strlen (cont);
-      if (quoted + i_add + add + col + l > flowed_max)
-      {
-       actually_wrap = 1;
-
-       for (tmpcol = quoted + i_add + add + col, t = cont;
-            *t && tmpcol < flowed_max; t++)
-       {
-         if (*t == ' ' || *t == '\t')
-           tail = t;
-         if (*t == '\t')
-           tmpcol = (tmpcol & ~7) + 8;
-         else
-           tmpcol++;
-       }
-       
-       if (tail)
-       {
-         *tail++ = '\0';
-         soft = 2;
-       }
+      if (quoted + i_add + add + col + l > flowed_max) {
+        actually_wrap = 1;
+
+        for (tmpcol = quoted + i_add + add + col, t = cont;
+             *t && tmpcol < flowed_max; t++) {
+          if (*t == ' ' || *t == '\t')
+            tail = t;
+          if (*t == '\t')
+            tmpcol = (tmpcol & ~7) + 8;
+          else
+            tmpcol++;
+        }
+
+        if (tail) {
+          *tail++ = '\0';
+          soft = 2;
+        }
       }
 
       /* We seem to be desperate.  Get me a new line, and retry. */
-      if (!tail && (quoted + add + col + i_add + l > flowed_max) && col)
-      {
-       state_putc ('\n', s);
-       col = 0;
-       goto retry_wrap;
+      if (!tail && (quoted + add + col + i_add + l > flowed_max) && col) {
+        state_putc ('\n', s);
+        col = 0;
+        goto retry_wrap;
       }
 
       /* Detect soft line breaks. */
-      if (!soft && ascii_strcmp (cont, "-- "))
-      {
-       lc = strrchr (cont, ' ');
-       if (lc && lc[1] == '\0')
-         soft = 1;
+      if (!soft && ascii_strcmp (cont, "-- ")) {
+        lc = strrchr (cont, ' ');
+        if (lc && lc[1] == '\0')
+          soft = 1;
       }
 
       /* 
@@ -1158,36 +1081,34 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
        * the line's actual content.  You never know what people put
        * into their regular expressions. 
        */
-      if (!col)
-      {
-       char tmp[LONG_STRING];
-       snprintf (tmp, sizeof (tmp), "%s%s", indent, cont);
+      if (!col) {
+        char tmp[LONG_STRING];
+
+        snprintf (tmp, sizeof (tmp), "%s%s", indent, cont);
 
-       flowed_quote (s, quoted);
-       flowed_stuff (s, tmp, quoted + add);
+        flowed_quote (s, quoted);
+        flowed_stuff (s, tmp, quoted + add);
 
-       state_puts (indent, s);
+        state_puts (indent, s);
       }
 
       /* output the text */
       state_puts (cont, s);
       col += flowed_visual_strlen (cont, quoted + i_add + add + col);
-      
+
       /* possibly indicate a soft line break */
-      if (soft == 2)
-      {
-       state_putc (' ', s);
-       col++;
+      if (soft == 2) {
+        state_putc (' ', s);
+        col++;
       }
-      
+
       /* 
        * Wrap if this display line corresponds to a 
        * text line. Don't wrap if we changed the line.
        */
-      if (!soft || (!actually_wrap && full))
-      {
-       state_putc ('\n', s);
-       col = 0;
+      if (!soft || (!actually_wrap && full)) {
+        state_putc ('\n', s);
+        col = 0;
       }
     }
     while (tail);
@@ -1195,44 +1116,47 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 
   if (col)
     state_putc ('\n', s);
-  
+
 }
 #endif
 
-static int get_quote_level(char * line) {
+static int get_quote_level (char *line)
+{
   int quoted;
+
   for (quoted = 0; line[quoted] == '>'; quoted++);
   return quoted;
 }
 
-static void print_flowed_line(char * line, STATE *s,int ql) {
+static void print_flowed_line (char *line, STATE * s, int ql)
+{
   int width;
-  char * pos, * oldpos;
-  int len = strlen(line);
+  char *pos, *oldpos;
+  int len = strlen (line);
   int i;
 
   if (MaxLineLength > 0) {
     width = MaxLineLength - WrapMargin - ql - 1;
-    if (option(OPTSTUFFQUOTED))
+    if (option (OPTSTUFFQUOTED))
       --width;
     if (width < 0)
       width = MaxLineLength;
-  } 
+  }
   else {
-    if (option(OPTMBOXPANE))
+    if (option (OPTMBOXPANE))
       width = COLS - SidebarWidth - WrapMargin - ql - 1;
     else
       width = COLS - WrapMargin - ql - 1;
-    
-    if (option(OPTSTUFFQUOTED))
+
+    if (option (OPTSTUFFQUOTED))
       --width;
     if (width < 0)
       width = COLS;
-  } 
+  }
 
   /* fprintf(stderr,"print_flowed_line will print `%s' with ql = %d\n",line,ql); */
 
-  if (strlen(line)==0) {
+  if (strlen (line) == 0) {
     if (option (OPTQUOTEEMPTY)) {
       if (s->prefix)
         state_puts(s->prefix,s);
@@ -1244,31 +1168,34 @@ static void print_flowed_line(char * line, STATE *s,int ql) {
     return;
   }
 
-  pos=line+ql+width;
-  oldpos=line+ql;
-  if (ql>0 && ISBLANK(*oldpos)) ++oldpos;
+  pos = line + ql + width;
+  oldpos = line + ql;
+  if (ql > 0 && ISBLANK (*oldpos))
+    ++oldpos;
 
   /* fprintf(stderr,"oldpos = %p line+len = %p\n",oldpos,line+len); */
 
-  for (;oldpos<line+len;pos+=width) {
+  for (; oldpos < line + len; pos += width) {
     /* fprintf(stderr,"outer for loop\n"); */
-    if (pos<line+len) { /* only search a new position when we're not over the end of the string w/ pos */
+    if (pos < line + len) {     /* only search a new position when we're not over the end of the string w/ pos */
       /* fprintf(stderr,"if 1\n"); */
       if (*pos == ' ') {
         /* fprintf(stderr,"if 2: good luck! found a space\n"); */
         *pos = '\0';
         ++pos;
-      } else {
+      }
+      else {
         /* fprintf(stderr,"if 2: else\n"); */
-        char * save = pos;
-        while (pos>=oldpos && !isspace(*pos)) {
+        char *save = pos;
+
+        while (pos >= oldpos && !isspace (*pos)) {
           /* fprintf(stderr,"pos(%p) > oldpos(%p)\n",pos,oldpos); */
           --pos;
         }
         if (pos < oldpos) {
           /* fprintf(stderr,"wow, no space found, searching the other direction\n"); */
           pos = save;
-          while (pos < line+len && *pos && !isspace(*pos)) {
+          while (pos < line + len && *pos && !isspace (*pos)) {
             /* fprintf(stderr,"pos(%p) < line+len(%p)\n",pos,line+len); */
             ++pos;
           }
@@ -1277,75 +1204,85 @@ static void print_flowed_line(char * line, STATE *s,int ql) {
         *pos = '\0';
         ++pos;
       }
-    } else {
+    }
+    else {
       /* fprintf(stderr,"if 1 else\n"); */
     }
     if (s->prefix)
-      state_puts(s->prefix,s);
-    for (i=0;i<ql;++i)
-      state_putc('>',s);
-    if (option(OPTSTUFFQUOTED) && (ql>0 || s->prefix)) state_putc(' ',s);
-    state_puts(oldpos,s);
+      state_puts (s->prefix, s);
+    for (i = 0; i < ql; ++i)
+      state_putc ('>', s);
+    if (option (OPTSTUFFQUOTED) && (ql > 0 || s->prefix))
+      state_putc (' ', s);
+    state_puts (oldpos, s);
     /* fprintf(stderr,"print_flowed_line: `%s'\n",oldpos); */
-    if (pos<line+len)
-      state_putc(' ',s);
-    state_putc('\n',s);
+    if (pos < line + len)
+      state_putc (' ', s);
+    state_putc ('\n', s);
     oldpos = pos;
   }
   /*state_puts(line,s);
-  state_putc('\n',s);*/
+     state_putc('\n',s); */
 }
 
-static void text_plain_flowed_handler (BODY *a, STATE *s)
+static void text_plain_flowed_handler (BODY * a, STATE * s)
 {
   int bytes = a->length;
   char buf[LONG_STRING];
-  char * curline = strdup("");
-  char * t;
+  char *curline = strdup ("");
+  char *t;
   unsigned int curline_len = 1;
   unsigned int quotelevel = 0, newql = 0;
   int append_next_line = 0;
   int first_line = 1;
 
-  while (bytes > 0 && fgets(buf,sizeof(buf),s->fpin)) {
+  while (bytes > 0 && fgets (buf, sizeof (buf), s->fpin)) {
 
     /* fprintf(stderr,"read `%s'",buf); */
-    bytes -= strlen(buf);
+    bytes -= strlen (buf);
 
-    newql = get_quote_level(buf);
+    newql = get_quote_level (buf);
 
-    if ((t=strrchr(buf,'\n')) || (t=strrchr(buf,'\r'))) {
+    if ((t = strrchr (buf, '\n')) || (t = strrchr (buf, '\r'))) {
       *t = '\0';
-      if (strlen(curline)>0 && curline[strlen(curline)-1]==' ' && newql==quotelevel && strcmp(curline+quotelevel,"-- ")!=0) {
-        if (buf[newql]==' ')
-          curline[strlen(curline)-1] = '\0';
-
-        curline = realloc(curline,curline_len+strlen(buf));
-        if (curline_len == 1) *curline = '\0';
-        curline_len+=strlen(buf);
-        safe_strncat(curline,curline_len,buf+newql,strlen(buf+newql));
-      } else {
+      if (strlen (curline) > 0 && curline[strlen (curline) - 1] == ' '
+          && newql == quotelevel
+          && strcmp (curline + quotelevel, "-- ") != 0) {
+        if (buf[newql] == ' ')
+          curline[strlen (curline) - 1] = '\0';
+
+        curline = realloc (curline, curline_len + strlen (buf));
+        if (curline_len == 1)
+          *curline = '\0';
+        curline_len += strlen (buf);
+        safe_strncat (curline, curline_len, buf + newql,
+                      strlen (buf + newql));
+      }
+      else {
         if (first_line) {
           first_line = 0;
-        } else {
-          print_flowed_line(curline,s,quotelevel);
         }
-        FREE(&curline);
+        else {
+          print_flowed_line (curline, s, quotelevel);
+        }
+        FREE (&curline);
         curline_len = 1;
-        curline = realloc(curline,curline_len+strlen(buf));
-        if (curline_len == 1) *curline = '\0';
-        curline_len+=strlen(buf);
-        safe_strncat(curline,curline_len,buf,strlen(buf));
+        curline = realloc (curline, curline_len + strlen (buf));
+        if (curline_len == 1)
+          *curline = '\0';
+        curline_len += strlen (buf);
+        safe_strncat (curline, curline_len, buf, strlen (buf));
         quotelevel = newql;
       }
-    } else {
+    }
+    else {
       append_next_line = 1;
       /* @todo: add handling of very long lines */
     }
   }
   if (curline) {
-    print_flowed_line(curline,s,quotelevel);
-    FREE(&curline);
+    print_flowed_line (curline, s, quotelevel);
+    FREE (&curline);
   }
 }
 
@@ -1355,7 +1292,7 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 #define TXTPLAIN    2
 #define TXTENRICHED 3
 
-static void alternative_handler (BODY *a, STATE *s)
+static void alternative_handler (BODY * a, STATE * s)
 {
   BODY *choice = NULL;
   BODY *b;
@@ -1365,16 +1302,19 @@ static void alternative_handler (BODY *a, STATE *s)
   int mustfree = 0;
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
-      a->encoding == ENCUUENCODED)
-  {
+      a->encoding == ENCUUENCODED) {
     struct stat st;
+
     mustfree = 1;
     fstat (fileno (s->fpin), &st);
     b = mutt_new_body ();
     b->length = (long) st.st_size;
     b->parts = mutt_parse_multipart (s->fpin,
-                 mutt_get_parameter ("boundary", a->parameter),
-                 (long) st.st_size, ascii_strcasecmp ("digest", a->subtype) == 0);
+                                     mutt_get_parameter ("boundary",
+                                                         a->parameter),
+                                     (long) st.st_size,
+                                     ascii_strcasecmp ("digest",
+                                                       a->subtype) == 0);
   }
   else
     b = a;
@@ -1383,38 +1323,33 @@ static void alternative_handler (BODY *a, STATE *s)
 
   /* First, search list of prefered types */
   t = AlternativeOrderList;
-  while (t && !choice)
-  {
+  while (t && !choice) {
     char *c;
-    int btlen;  /* length of basetype */
-    int wild;  /* do we have a wildcard to match all subtypes? */
+    int btlen;                  /* length of basetype */
+    int wild;                   /* do we have a wildcard to match all subtypes? */
 
     c = strchr (t->data, '/');
-    if (c)
-    {
+    if (c) {
       wild = (c[1] == '*' && c[2] == 0);
       btlen = c - t->data;
     }
-    else
-    {
+    else {
       wild = 1;
       btlen = mutt_strlen (t->data);
     }
 
-    if (a && a->parts) 
+    if (a && a->parts)
       b = a->parts;
     else
       b = a;
-    while (b)
-    {
-      const char *bt = TYPE(b);
-      if (!ascii_strncasecmp (bt, t->data, btlen) && bt[btlen] == 0)
-      {
-       /* the basetype matches */
-       if (wild || !ascii_strcasecmp (t->data + btlen + 1, b->subtype))
-       {
-         choice = b;
-       }
+    while (b) {
+      const char *bt = TYPE (b);
+
+      if (!ascii_strncasecmp (bt, t->data, btlen) && bt[btlen] == 0) {
+        /* the basetype matches */
+        if (wild || !ascii_strcasecmp (t->data + btlen + 1, b->subtype)) {
+          choice = b;
+        }
       }
       b = b->next;
     }
@@ -1422,106 +1357,94 @@ static void alternative_handler (BODY *a, STATE *s)
   }
 
   /* Next, look for an autoviewable type */
-  if (!choice)
-  {
-    if (a && a->parts) 
+  if (!choice) {
+    if (a && a->parts)
       b = a->parts;
     else
       b = a;
-    while (b)
-    {
+    while (b) {
       snprintf (buf, sizeof (buf), "%s/%s", TYPE (b), b->subtype);
-      if (mutt_is_autoview (b, buf))
-      {
-       rfc1524_entry *entry = rfc1524_new_entry ();
-
-       if (rfc1524_mailcap_lookup (b, buf, entry, M_AUTOVIEW))
-       {
-         choice = b;
-       }
-       rfc1524_free_entry (&entry);
+      if (mutt_is_autoview (b, buf)) {
+        rfc1524_entry *entry = rfc1524_new_entry ();
+
+        if (rfc1524_mailcap_lookup (b, buf, entry, M_AUTOVIEW)) {
+          choice = b;
+        }
+        rfc1524_free_entry (&entry);
       }
       b = b->next;
     }
   }
 
   /* Then, look for a text entry */
-  if (!choice)
-  {
-    if (a && a->parts) 
+  if (!choice) {
+    if (a && a->parts)
       b = a->parts;
     else
       b = a;
-    while (b)
-    {
-      if (b->type == TYPETEXT)
-      {
-       if (! ascii_strcasecmp ("plain", b->subtype) && type <= TXTPLAIN)
-       {
-         choice = b;
-         type = TXTPLAIN;
-       }
-       else if (! ascii_strcasecmp ("enriched", b->subtype) && type <= TXTENRICHED)
-       {
-         choice = b;
-         type = TXTENRICHED;
-       }
-       else if (! ascii_strcasecmp ("html", b->subtype) && type <= TXTHTML)
-       {
-         choice = b;
-         type = TXTHTML;
-       }
+    while (b) {
+      if (b->type == TYPETEXT) {
+        if (!ascii_strcasecmp ("plain", b->subtype) && type <= TXTPLAIN) {
+          choice = b;
+          type = TXTPLAIN;
+        }
+        else if (!ascii_strcasecmp ("enriched", b->subtype)
+                 && type <= TXTENRICHED) {
+          choice = b;
+          type = TXTENRICHED;
+        }
+        else if (!ascii_strcasecmp ("html", b->subtype) && type <= TXTHTML) {
+          choice = b;
+          type = TXTHTML;
+        }
       }
       b = b->next;
     }
   }
 
   /* Finally, look for other possibilities */
-  if (!choice)
-  {
-    if (a && a->parts) 
+  if (!choice) {
+    if (a && a->parts)
       b = a->parts;
     else
       b = a;
-    while (b)
-    {
+    while (b) {
       if (mutt_can_decode (b))
-       choice = b;
+        choice = b;
       b = b->next;
     }
   }
 
-  if (choice)
-  {
-    if (s->flags & M_DISPLAY && !option (OPTWEED))
-    {
+  if (choice) {
+    if (s->flags & M_DISPLAY && !option (OPTWEED)) {
       fseek (s->fpin, choice->hdr_offset, 0);
-      mutt_copy_bytes(s->fpin, s->fpout, choice->offset-choice->hdr_offset);
+      mutt_copy_bytes (s->fpin, s->fpout,
+                       choice->offset - choice->hdr_offset);
     }
     mutt_body_handler (choice, s);
   }
-  else if (s->flags & M_DISPLAY)
-  {
+  else if (s->flags & M_DISPLAY) {
     /* didn't find anything that we could display! */
     state_mark_attach (s);
-    state_puts(_("[-- Error:  Could not display any parts of Multipart/Alternative! --]\n"), s);
+    state_puts (_
+                ("[-- Error:  Could not display any parts of Multipart/Alternative! --]\n"),
+                s);
   }
 
   if (mustfree)
-    mutt_free_body(&a);
+    mutt_free_body (&a);
 }
 
 /* handles message/rfc822 body parts */
-void message_handler (BODY *a, STATE *s)
+void message_handler (BODY * a, STATE * s)
 {
   struct stat st;
   BODY *b;
   long off_start;
 
   off_start = ftell (s->fpin);
-  if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || 
-      a->encoding == ENCUUENCODED)
-  {
+  if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
+      a->encoding == ENCUUENCODED) {
     fstat (fileno (s->fpin), &st);
     b = mutt_new_body ();
     b->length = (long) st.st_size;
@@ -1530,11 +1453,13 @@ void message_handler (BODY *a, STATE *s)
   else
     b = a;
 
-  if (b->parts)
-  {
+  if (b->parts) {
     mutt_copy_hdr (s->fpin, s->fpout, off_start, b->parts->offset,
-       (((s->flags & M_WEED) || ((s->flags & (M_DISPLAY|M_PRINTING)) && option (OPTWEED))) ? (CH_WEED | CH_REORDER) : 0) |
-       (s->prefix ? CH_PREFIX : 0) | CH_DECODE | CH_FROM, s->prefix);
+                   (((s->flags & M_WEED)
+                     || ((s->flags & (M_DISPLAY | M_PRINTING))
+                         && option (OPTWEED))) ? (CH_WEED | CH_REORDER) : 0) |
+                   (s->prefix ? CH_PREFIX : 0) | CH_DECODE | CH_FROM,
+                   s->prefix);
 
     if (s->prefix)
       state_puts (s->prefix, s);
@@ -1549,7 +1474,7 @@ void message_handler (BODY *a, STATE *s)
 }
 
 /* returns 1 if decoding the attachment will produce output */
-int mutt_can_decode (BODY *a)
+int mutt_can_decode (BODY * a)
 {
   char type[STRING];
 
@@ -1560,36 +1485,32 @@ int mutt_can_decode (BODY *a)
     return (1);
   else if (a->type == TYPEMESSAGE)
     return (1);
-  else if (a->type == TYPEMULTIPART)
-  {
+  else if (a->type == TYPEMULTIPART) {
     BODY *p;
 
-    if (WithCrypto)
-    {
+    if (WithCrypto) {
       if (ascii_strcasecmp (a->subtype, "signed") == 0 ||
-         ascii_strcasecmp (a->subtype, "encrypted") == 0)
+          ascii_strcasecmp (a->subtype, "encrypted") == 0)
         return (1);
     }
 
-    for (p = a->parts; p; p = p->next)
-    {
+    for (p = a->parts; p; p = p->next) {
       if (mutt_can_decode (p))
         return (1);
     }
-    
+
   }
-  else if (WithCrypto && a->type == TYPEAPPLICATION)
-  {
-    if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp(a))
+  else if (WithCrypto && a->type == TYPEAPPLICATION) {
+    if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (a))
       return (1);
-    if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(a))
+    if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (a))
       return (1);
   }
 
   return (0);
 }
 
-void multipart_handler (BODY *a, STATE *s)
+void multipart_handler (BODY * a, STATE * s)
 {
   BODY *b, *p;
   char length[5];
@@ -1597,58 +1518,55 @@ void multipart_handler (BODY *a, STATE *s)
   int count;
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
-      a->encoding == ENCUUENCODED)
-  {
+      a->encoding == ENCUUENCODED) {
     fstat (fileno (s->fpin), &st);
     b = mutt_new_body ();
     b->length = (long) st.st_size;
     b->parts = mutt_parse_multipart (s->fpin,
-                 mutt_get_parameter ("boundary", a->parameter),
-                 (long) st.st_size, ascii_strcasecmp ("digest", a->subtype) == 0);
+                                     mutt_get_parameter ("boundary",
+                                                         a->parameter),
+                                     (long) st.st_size,
+                                     ascii_strcasecmp ("digest",
+                                                       a->subtype) == 0);
   }
   else
     b = a;
 
-  for (p = b->parts, count = 1; p; p = p->next, count++)
-  {
-    if (s->flags & M_DISPLAY)
-    {
+  for (p = b->parts, count = 1; p; p = p->next, count++) {
+    if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
       state_printf (s, _("[-- Attachment #%d"), count);
-      if (p->description || p->filename || p->form_name)
-      {
-       state_puts (": ", s);
-       state_puts (p->description ? p->description :
-                   p->filename ? p->filename : p->form_name, s);
+      if (p->description || p->filename || p->form_name) {
+        state_puts (": ", s);
+        state_puts (p->description ? p->description :
+                    p->filename ? p->filename : p->form_name, s);
       }
       state_puts (" --]\n", s);
 
       mutt_pretty_size (length, sizeof (length), p->length);
-      
+
       state_mark_attach (s);
       state_printf (s, _("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n"),
-                   TYPE (p), p->subtype, ENCODING (p->encoding), length);
-      if (!option (OPTWEED))
-      {
-       fseek (s->fpin, p->hdr_offset, 0);
-       mutt_copy_bytes(s->fpin, s->fpout, p->offset-p->hdr_offset);
+                    TYPE (p), p->subtype, ENCODING (p->encoding), length);
+      if (!option (OPTWEED)) {
+        fseek (s->fpin, p->hdr_offset, 0);
+        mutt_copy_bytes (s->fpin, s->fpout, p->offset - p->hdr_offset);
       }
       else
-       state_putc ('\n', s);
+        state_putc ('\n', s);
     }
-    else
-    {
+    else {
       if (p->description && mutt_can_decode (p))
-       state_printf (s, "Content-Description: %s\n", p->description);
+        state_printf (s, "Content-Description: %s\n", p->description);
 
       if (p->form_name)
-       state_printf(s, "%s: \n", p->form_name);
+        state_printf (s, "%s: \n", p->form_name);
 
     }
     mutt_body_handler (p, s);
     state_putc ('\n', s);
     if ((s->flags & M_REPLYING)
-       && (option (OPTINCLUDEONLYFIRST)) && (s->flags & M_FIRSTDONE))
+        && (option (OPTINCLUDEONLYFIRST)) && (s->flags & M_FIRSTDONE))
       break;
   }
 
@@ -1657,7 +1575,7 @@ void multipart_handler (BODY *a, STATE *s)
     mutt_free_body (&b);
 }
 
-void autoview_handler (BODY *a, STATE *s)
+void autoview_handler (BODY * a, STATE * s)
 {
   rfc1524_entry *entry = rfc1524_new_entry ();
   char buffer[LONG_STRING];
@@ -1676,97 +1594,84 @@ void autoview_handler (BODY *a, STATE *s)
 
   fname = safe_strdup (a->filename);
   mutt_sanitize_filename (fname, 1);
-  rfc1524_expand_filename (entry->nametemplate, fname, tempfile, sizeof (tempfile));
+  rfc1524_expand_filename (entry->nametemplate, fname, tempfile,
+                           sizeof (tempfile));
   FREE (&fname);
 
-  if (entry->command)
-  {
+  if (entry->command) {
     strfcpy (command, entry->command, sizeof (command));
 
     /* rfc1524_expand_command returns 0 if the file is required */
-    piped = rfc1524_expand_command (a, tempfile, type, command, sizeof (command));
+    piped =
+      rfc1524_expand_command (a, tempfile, type, command, sizeof (command));
 
-    if (s->flags & M_DISPLAY)
-    {
+    if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
       state_printf (s, _("[-- Autoview using %s --]\n"), command);
-      mutt_message(_("Invoking autoview command: %s"),command);
+      mutt_message (_("Invoking autoview command: %s"), command);
     }
 
-    if ((fpin = safe_fopen (tempfile, "w+")) == NULL)
-    {
+    if ((fpin = safe_fopen (tempfile, "w+")) == NULL) {
       mutt_perror ("fopen");
       rfc1524_free_entry (&entry);
       return;
     }
-    
+
     mutt_copy_bytes (s->fpin, fpin, a->length);
 
-    if(!piped)
-    {
+    if (!piped) {
       safe_fclose (&fpin);
       thepid = mutt_create_filter (command, NULL, &fpout, &fperr);
     }
-    else
-    {
+    else {
       unlink (tempfile);
       fflush (fpin);
       rewind (fpin);
       thepid = mutt_create_filter_fd (command, NULL, &fpout, &fperr,
-                                     fileno(fpin), -1, -1);
+                                      fileno (fpin), -1, -1);
     }
 
-    if (thepid < 0)
-    {
+    if (thepid < 0) {
       mutt_perror _("Can't create filter");
-      if (s->flags & M_DISPLAY)
-      {
-       state_mark_attach (s);
-       state_printf (s, _("[-- Can't run %s. --]\n"), command);
+
+      if (s->flags & M_DISPLAY) {
+        state_mark_attach (s);
+        state_printf (s, _("[-- Can't run %s. --]\n"), command);
       }
       goto bail;
     }
-    
-    if (s->prefix)
-    {
-      while (fgets (buffer, sizeof(buffer), fpout) != NULL)
-      {
+
+    if (s->prefix) {
+      while (fgets (buffer, sizeof (buffer), fpout) != NULL) {
         state_puts (s->prefix, s);
         state_puts (buffer, s);
       }
       /* check for data on stderr */
-      if (fgets (buffer, sizeof(buffer), fperr)) 
-      {
-       if (s->flags & M_DISPLAY)
-       {
-         state_mark_attach (s);
-         state_printf (s, _("[-- Autoview stderr of %s --]\n"), command);
-       }
-
-       state_puts (s->prefix, s);
-       state_puts (buffer, s);
-       while (fgets (buffer, sizeof(buffer), fperr) != NULL)
-       {
-         state_puts (s->prefix, s);
-         state_puts (buffer, s);
-       }
+      if (fgets (buffer, sizeof (buffer), fperr)) {
+        if (s->flags & M_DISPLAY) {
+          state_mark_attach (s);
+          state_printf (s, _("[-- Autoview stderr of %s --]\n"), command);
+        }
+
+        state_puts (s->prefix, s);
+        state_puts (buffer, s);
+        while (fgets (buffer, sizeof (buffer), fperr) != NULL) {
+          state_puts (s->prefix, s);
+          state_puts (buffer, s);
+        }
       }
     }
-    else
-    {
+    else {
       mutt_copy_stream (fpout, s->fpout);
       /* Check for stderr messages */
-      if (fgets (buffer, sizeof(buffer), fperr))
-      {
-       if (s->flags & M_DISPLAY)
-       {
-         state_mark_attach (s);
-         state_printf (s, _("[-- Autoview stderr of %s --]\n"), 
-                       command);
-       }
-       
-       state_puts (buffer, s);
-       mutt_copy_stream (fperr, s->fpout);
+      if (fgets (buffer, sizeof (buffer), fperr)) {
+        if (s->flags & M_DISPLAY) {
+          state_mark_attach (s);
+          state_printf (s, _("[-- Autoview stderr of %s --]\n"), command);
+        }
+
+        state_puts (buffer, s);
+        mutt_copy_stream (fperr, s->fpout);
       }
     }
 
@@ -1780,25 +1685,25 @@ void autoview_handler (BODY *a, STATE *s)
     else
       mutt_unlink (tempfile);
 
-    if (s->flags & M_DISPLAY) 
+    if (s->flags & M_DISPLAY)
       mutt_clear_error ();
   }
   rfc1524_free_entry (&entry);
 }
 
-static void external_body_handler (BODY *b, STATE *s)
+static void external_body_handler (BODY * b, STATE * s)
 {
   const char *access_type;
   const char *expiration;
   time_t expire;
 
   access_type = mutt_get_parameter ("access-type", b->parameter);
-  if (!access_type)
-  {
-    if (s->flags & M_DISPLAY)
-    {
+  if (!access_type) {
+    if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
-      state_puts (_("[-- Error: message/external-body has no access-type parameter --]\n"), s);
+      state_puts (_
+                  ("[-- Error: message/external-body has no access-type parameter --]\n"),
+                  s);
     }
     return;
   }
@@ -1809,121 +1714,110 @@ static void external_body_handler (BODY *b, STATE *s)
   else
     expire = -1;
 
-  if (!ascii_strcasecmp (access_type, "x-mutt-deleted"))
-  {
-    if (s->flags & (M_DISPLAY|M_PRINTING))
-    {
+  if (!ascii_strcasecmp (access_type, "x-mutt-deleted")) {
+    if (s->flags & (M_DISPLAY | M_PRINTING)) {
       char *length;
       char pretty_size[10];
-      
+
       state_mark_attach (s);
       state_printf (s, _("[-- This %s/%s attachment "),
-              TYPE(b->parts), b->parts->subtype);
+                    TYPE (b->parts), b->parts->subtype);
       length = mutt_get_parameter ("length", b->parameter);
-      if (length)
-      {
-       mutt_pretty_size (pretty_size, sizeof (pretty_size),
-                         strtol (length, NULL, 10));
-       state_printf (s, _("(size %s bytes) "), pretty_size);
+      if (length) {
+        mutt_pretty_size (pretty_size, sizeof (pretty_size),
+                          strtol (length, NULL, 10));
+        state_printf (s, _("(size %s bytes) "), pretty_size);
       }
       state_puts (_("has been deleted --]\n"), s);
 
-      if (expire != -1)
-      {
-       state_mark_attach (s);
-       state_printf (s, _("[-- on %s --]\n"), expiration);
+      if (expire != -1) {
+        state_mark_attach (s);
+        state_printf (s, _("[-- on %s --]\n"), expiration);
       }
-      if (b->parts->filename)
-      {
-       state_mark_attach (s);
-       state_printf (s, _("[-- name: %s --]\n"), b->parts->filename);
+      if (b->parts->filename) {
+        state_mark_attach (s);
+        state_printf (s, _("[-- name: %s --]\n"), b->parts->filename);
       }
 
       mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
-                    (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
-                    CH_DECODE , NULL);
+                     (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                     CH_DECODE, NULL);
     }
   }
-  else if(expiration && expire < time(NULL))
-  {
-    if (s->flags & M_DISPLAY)
-    {
+  else if (expiration && expire < time (NULL)) {
+    if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
       state_printf (s, _("[-- This %s/%s attachment is not included, --]\n"),
-                   TYPE(b->parts), b->parts->subtype);
+                    TYPE (b->parts), b->parts->subtype);
       state_attach_puts (_("[-- and the indicated external source has --]\n"
-                          "[-- expired. --]\n"), s);
+                           "[-- expired. --]\n"), s);
 
-      mutt_copy_hdr(s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
-                   (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
-                   CH_DECODE, NULL);
+      mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+                     (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                     CH_DECODE, NULL);
     }
   }
-  else
-  {
-    if (s->flags & M_DISPLAY)
-    {
+  else {
+    if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
       state_printf (s,
-                   _("[-- This %s/%s attachment is not included, --]\n"),
-                   TYPE (b->parts), b->parts->subtype);
+                    _("[-- This %s/%s attachment is not included, --]\n"),
+                    TYPE (b->parts), b->parts->subtype);
       state_mark_attach (s);
-      state_printf (s, 
-                   _("[-- and the indicated access-type %s is unsupported --]\n"),
-                   access_type);
+      state_printf (s,
+                    _
+                    ("[-- and the indicated access-type %s is unsupported --]\n"),
+                    access_type);
       mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
-                    (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
-                    CH_DECODE , NULL);
+                     (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
+                     CH_DECODE, NULL);
     }
   }
 }
 
-void mutt_decode_attachment (BODY *b, STATE *s)
+void mutt_decode_attachment (BODY * b, STATE * s)
 {
   int istext = mutt_is_text_part (b);
-  iconv_t cd = (iconv_t)(-1);
+  iconv_t cd = (iconv_t) (-1);
 
   Quotebuf[0] = '\0';
 
-  if (istext)
-  {
-    if(s->flags & M_CHARCONV)
-    {
+  if (istext) {
+    if (s->flags & M_CHARCONV) {
       char *charset = mutt_get_parameter ("charset", b->parameter);
+
       if (!option (OPTSTRICTMIME) && !charset)
         charset = mutt_get_first_charset (AssumedCharset);
       if (charset && Charset)
         cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
     }
-    else
-    {
+    else {
       if (b->file_charset)
         cd = mutt_iconv_open (Charset, b->file_charset, M_ICONV_HOOK_FROM);
     }
   }
 
   fseek (s->fpin, b->offset, 0);
-  switch (b->encoding)
-  {
-    case ENCQUOTEDPRINTABLE:
-      mutt_decode_quoted (s, b->length, istext, cd);
-      break;
-    case ENCBASE64:
-      mutt_decode_base64 (s, b->length, istext, cd);
-      break;
-    case ENCUUENCODED:
-      mutt_decode_uuencoded (s, b->length, istext, cd);
-      break;
-    default:
-      mutt_decode_xbit (s, b->length, istext, cd);
-      break;
+  switch (b->encoding) {
+  case ENCQUOTEDPRINTABLE:
+    mutt_decode_quoted (s, b->length, istext, cd);
+    break;
+  case ENCBASE64:
+    mutt_decode_base64 (s, b->length, istext, cd);
+    break;
+  case ENCUUENCODED:
+    mutt_decode_uuencoded (s, b->length, istext, cd);
+    break;
+  default:
+    mutt_decode_xbit (s, b->length, istext, cd);
+    break;
   }
 
-  if (cd != (iconv_t)(-1))
+  if (cd != (iconv_t) (-1))
     iconv_close (cd);
 }
 
-void mutt_body_handler (BODY *b, STATE *s)
+void mutt_body_handler (BODY * b, STATE * s)
 {
   int decode = 0;
   int plaintext = 0;
@@ -1935,71 +1829,68 @@ void mutt_body_handler (BODY *b, STATE *s)
   char type[STRING];
 
   int oflags = s->flags;
-  
+
   /* first determine which handler to use to process this part */
 
   snprintf (type, sizeof (type), "%s/%s", TYPE (b), b->subtype);
-  if (mutt_is_autoview (b, type))
-  {
+  if (mutt_is_autoview (b, type)) {
     rfc1524_entry *entry = rfc1524_new_entry ();
 
-    if (rfc1524_mailcap_lookup (b, type, entry, M_AUTOVIEW))
-    {
-      handler   = autoview_handler;
+    if (rfc1524_mailcap_lookup (b, type, entry, M_AUTOVIEW)) {
+      handler = autoview_handler;
       s->flags &= ~M_CHARCONV;
     }
     rfc1524_free_entry (&entry);
   }
-  else if (b->type == TYPETEXT)
-  {
-    if (ascii_strcasecmp ("plain", b->subtype) == 0)
-    {
+  else if (b->type == TYPETEXT) {
+    if (ascii_strcasecmp ("plain", b->subtype) == 0) {
       /* avoid copying this part twice since removing the transfer-encoding is
        * the only operation needed.
        */
       if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
-       handler = crypt_pgp_application_pgp_handler;
-      else if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
-       handler = text_plain_flowed_handler;
+        handler = crypt_pgp_application_pgp_handler;
       else
-       plaintext = 1;
+        if (ascii_strcasecmp
+            ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
+        handler = text_plain_flowed_handler;
+      else
+        plaintext = 1;
     }
     else if (ascii_strcasecmp ("enriched", b->subtype) == 0)
       handler = text_enriched_handler;
-    else /* text body type without a handler */
+    else                        /* text body type without a handler */
       plaintext = 1;
   }
-  else if (b->type == TYPEMESSAGE)
-  {
-    if(mutt_is_message_type(b->type, b->subtype))
+  else if (b->type == TYPEMESSAGE) {
+    if (mutt_is_message_type (b->type, b->subtype))
       handler = message_handler;
     else if (!ascii_strcasecmp ("delivery-status", b->subtype))
       plaintext = 1;
     else if (!ascii_strcasecmp ("external-body", b->subtype))
       handler = external_body_handler;
   }
-  else if (b->type == TYPEMULTIPART)
-  {
+  else if (b->type == TYPEMULTIPART) {
     char *p;
 
     if (ascii_strcasecmp ("alternative", b->subtype) == 0)
       handler = alternative_handler;
-    else if (WithCrypto && ascii_strcasecmp ("signed", b->subtype) == 0)
-    {
+    else if (WithCrypto && ascii_strcasecmp ("signed", b->subtype) == 0) {
       p = mutt_get_parameter ("protocol", b->parameter);
 
       if (!p)
-        mutt_error _("Error: multipart/signed has no protocol.");
+        mutt_error (_("Error: multipart/signed has no protocol."));
+
       else if (s->flags & M_VERIFY)
-       handler = mutt_signed_handler;
+        handler = mutt_signed_handler;
     }
     else if ((WithCrypto & APPLICATION_PGP)
-             && mutt_strcasecmp ("encrypted", b->subtype) == 0)
-    {
+             && mutt_strcasecmp ("encrypted", b->subtype) == 0) {
       p = mutt_get_parameter ("protocol", b->parameter);
 
       if (!p)
-        mutt_error _("Error: multipart/encrypted has no protocol parameter!");
+        mutt_error (_
+                    ("Error: multipart/encrypted has no protocol parameter!"));
+
       else if (ascii_strcasecmp ("application/pgp-encrypted", p) == 0)
         handler = crypt_pgp_encrypted_handler;
     }
@@ -2007,111 +1898,101 @@ void mutt_body_handler (BODY *b, STATE *s)
     if (!handler)
       handler = multipart_handler;
   }
-  else if (WithCrypto && b->type == TYPEAPPLICATION)
-  {
+  else if (WithCrypto && b->type == TYPEAPPLICATION) {
     if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
       handler = crypt_pgp_application_pgp_handler;
-    if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(b))
+    if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (b))
       handler = crypt_smime_application_smime_handler;
   }
 
 
-  if (plaintext || handler)
-  {
+  if (plaintext || handler) {
     fseek (s->fpin, b->offset, 0);
 
     /* see if we need to decode this part before processing it */
-    if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
-       b->encoding == ENCUUENCODED || plaintext || 
-       mutt_is_text_part (b))                          /* text subtypes may
-                                                        * require character
-                                                        * set conversion even
-                                                        * with 8bit encoding.
-                                                        */
-    {
+    if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE || b->encoding == ENCUUENCODED || plaintext || mutt_is_text_part (b)) {   /* text subtypes may
+                                                                                                                                                 * require character
+                                                                                                                                                 * set conversion even
+                                                                                                                                                 * with 8bit encoding.
+                                                                                                                                                 */
       int origType = b->type;
       char *savePrefix = NULL;
 
-      if (!plaintext)
-      {
-       /* decode to a tempfile, saving the original destination */
-       fp = s->fpout;
-       mutt_mktemp (tempfile);
-       if ((s->fpout = safe_fopen (tempfile, "w")) == NULL)
-       {
-         mutt_error _("Unable to open temporary file!");
-         goto bail;
-       }
-       /* decoding the attachment changes the size and offset, so save a copy
-        * of the "real" values now, and restore them after processing
-        */
-       tmplength = b->length;
-       tmpoffset = b->offset;
-
-       /* if we are decoding binary bodies, we don't want to prefix each
-        * line with the prefix or else the data will get corrupted.
-        */
-       savePrefix = s->prefix;
-       s->prefix = NULL;
-
-       decode = 1;
+      if (!plaintext) {
+        /* decode to a tempfile, saving the original destination */
+        fp = s->fpout;
+        mutt_mktemp (tempfile);
+        if ((s->fpout = safe_fopen (tempfile, "w")) == NULL) {
+          mutt_error _("Unable to open temporary file!");
+
+          goto bail;
+        }
+        /* decoding the attachment changes the size and offset, so save a copy
+         * of the "real" values now, and restore them after processing
+         */
+        tmplength = b->length;
+        tmpoffset = b->offset;
+
+        /* if we are decoding binary bodies, we don't want to prefix each
+         * line with the prefix or else the data will get corrupted.
+         */
+        savePrefix = s->prefix;
+        s->prefix = NULL;
+
+        decode = 1;
       }
       else
-       b->type = TYPETEXT;
+        b->type = TYPETEXT;
 
       mutt_decode_attachment (b, s);
 
-      if (decode)
-      {
-       b->length = ftell (s->fpout);
-       b->offset = 0;
-       fclose (s->fpout);
+      if (decode) {
+        b->length = ftell (s->fpout);
+        b->offset = 0;
+        fclose (s->fpout);
 
-       /* restore final destination and substitute the tempfile for input */
-       s->fpout = fp;
-       fp = s->fpin;
-       s->fpin = safe_fopen (tempfile, "r");
-       unlink (tempfile);
+        /* restore final destination and substitute the tempfile for input */
+        s->fpout = fp;
+        fp = s->fpin;
+        s->fpin = safe_fopen (tempfile, "r");
+        unlink (tempfile);
 
-       /* restore the prefix */
-       s->prefix = savePrefix;
+        /* restore the prefix */
+        s->prefix = savePrefix;
       }
 
       b->type = origType;
     }
 
     /* process the (decoded) body part */
-    if (handler)
-    {
+    if (handler) {
       handler (b, s);
 
-      if (decode)
-      {
-       b->length = tmplength;
-       b->offset = tmpoffset;
+      if (decode) {
+        b->length = tmplength;
+        b->offset = tmpoffset;
 
-       /* restore the original source stream */
-       fclose (s->fpin);
-       s->fpin = fp;
+        /* restore the original source stream */
+        fclose (s->fpin);
+        s->fpin = fp;
       }
     }
     s->flags |= M_FIRSTDONE;
   }
-  else if (s->flags & M_DISPLAY)
-  {
+  else if (s->flags & M_DISPLAY) {
     state_mark_attach (s);
     state_printf (s, _("[-- %s/%s is unsupported "), TYPE (b), b->subtype);
-    if (!option (OPTVIEWATTACH))
-    {
-      if (km_expand_key (type, sizeof(type),
-                       km_find_func (MENU_PAGER, OP_VIEW_ATTACHMENTS)))
-       fprintf (s->fpout, _("(use '%s' to view this part)"), type);
+    if (!option (OPTVIEWATTACH)) {
+      if (km_expand_key
+          (type, sizeof (type),
+           km_find_func (MENU_PAGER, OP_VIEW_ATTACHMENTS)))
+        fprintf (s->fpout, _("(use '%s' to view this part)"), type);
       else
-       fputs (_("(need 'view-attachments' bound to key!)"), s->fpout);
+        fputs (_("(need 'view-attachments' bound to key!)"), s->fpout);
     }
     fputs (" --]\n", s->fpout);
   }
-  
-  bail:
+
+bail:
   s->flags = oflags | (s->flags & M_FIRSTDONE);
 }
diff --git a/hash.c b/hash.c
index 4e12b15..a2dc11e 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -48,6 +48,7 @@ int hash_string (const unsigned char *s, int n)
 HASH *hash_create (int nelem)
 {
   HASH *table = safe_malloc (sizeof (HASH));
+
   if (nelem == 0)
     nelem = 2;
   table->nelem = nelem;
@@ -56,7 +57,7 @@ HASH *hash_create (int nelem)
   return table;
 }
 
-HASH *hash_resize (HASH *ptr, int nelem)
+HASH *hash_resize (HASH * ptr, int nelem)
 {
   HASH *table;
   struct hash_elem *elem, *tmp;
@@ -64,10 +65,8 @@ HASH *hash_resize (HASH *ptr, int nelem)
 
   table = hash_create (nelem);
 
-  for (i = 0; i < ptr->nelem; i++)
-  {
-    for (elem = ptr->table[i]; elem; )
-    {
+  for (i = 0; i < ptr->nelem; i++) {
+    for (elem = ptr->table[i]; elem;) {
       tmp = elem;
       elem = elem->next;
       hash_insert (table, tmp->key, tmp->data, 1);
@@ -95,27 +94,23 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup)
   ptr->key = key;
   ptr->data = data;
 
-  if (allow_dup)
-  {
+  if (allow_dup) {
     ptr->next = table->table[h];
     table->table[h] = ptr;
     table->curnelem++;
   }
-  else
-  {
+  else {
     struct hash_elem *tmp, *last;
     int r;
 
-    for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next)
-    {
+    for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next) {
       r = mutt_strcmp (tmp->key, key);
-      if (r == 0)
-      {
-       FREE (&ptr);
-       return (-1);
+      if (r == 0) {
+        FREE (&ptr);
+        return (-1);
       }
       if (r > 0)
-       break;
+        break;
     }
     if (last)
       last->next = ptr;
@@ -130,30 +125,29 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup)
 void *hash_find_hash (const HASH * table, int hash, const char *key)
 {
   struct hash_elem *ptr = table->table[hash];
-  for (; ptr; ptr = ptr->next)
-  {
+
+  for (; ptr; ptr = ptr->next) {
     if (mutt_strcmp (key, ptr->key) == 0)
       return (ptr->data);
   }
   return NULL;
 }
 
-void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
-                      void (*destroy) (void *))
+void hash_delete_hash (HASH * table, int hash, const char *key,
+                       const void *data, void (*destroy) (void *))
 {
   struct hash_elem *ptr = table->table[hash];
   struct hash_elem **last = &table->table[hash];
 
-  for (; ptr; last = &ptr->next, ptr = ptr->next)
-  {
+  for (; ptr; last = &ptr->next, ptr = ptr->next) {
     /* if `data' is given, look for a matching ->data member.  this is
      * required for the case where we have multiple entries with the same
      * key
      */
-    if ((data == ptr->data) || (!data && mutt_strcmp (ptr->key, key) == 0))
-    {
+    if ((data == ptr->data) || (!data && mutt_strcmp (ptr->key, key) == 0)) {
       *last = ptr->next;
-      if (destroy) destroy (ptr->data);
+      if (destroy)
+        destroy (ptr->data);
       FREE (&ptr);
       table->curnelem--;
       return;
@@ -164,20 +158,18 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data
 /* ptr         pointer to the hash table to be freed
  * destroy()   function to call to free the ->data member (optional) 
  */
-void hash_destroy (HASH **ptr, void (*destroy) (void *))
+void hash_destroy (HASH ** ptr, void (*destroy) (void *))
 {
   int i;
   HASH *pptr = *ptr;
   struct hash_elem *elem, *tmp;
 
-  for (i = 0 ; i < pptr->nelem; i++)
-  {
-    for (elem = pptr->table[i]; elem; )
-    {
+  for (i = 0; i < pptr->nelem; i++) {
+    for (elem = pptr->table[i]; elem;) {
       tmp = elem;
       elem = elem->next;
       if (destroy)
-       destroy (tmp->data);
+        destroy (tmp->data);
       FREE (&tmp);
     }
   }
diff --git a/hash.h b/hash.h
index a1d5e91..d91c264 100644 (file)
--- a/hash.h
+++ b/hash.h
 #ifndef _HASH_H
 #define _HASH_H
 
-struct hash_elem
-{
+struct hash_elem {
   const char *key;
   void *data;
   struct hash_elem *next;
 };
 
-typedef struct
-{
+typedef struct {
   int nelem, curnelem;
   struct hash_elem **table;
-}
-HASH;
+} HASH;
 
 #define hash_find(table, key) hash_find_hash(table, hash_string ((unsigned char *)key, table->nelem), key)
 
@@ -42,8 +39,8 @@ int hash_string (const unsigned char *s, int n);
 int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
 HASH *hash_resize (HASH * table, int nelem);
 void *hash_find_hash (const HASH * table, int hash, const char *key);
-void hash_delete_hash (HASH * table, int hash, const char *key, const void *data,
-                      void (*destroy) (void *));
+void hash_delete_hash (HASH * table, int hash, const char *key,
+                       const void *data, void (*destroy) (void *));
 void hash_destroy (HASH ** hash, void (*destroy) (void *));
 
 #endif
index eea6d20..cef8fc1 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -28,7 +28,7 @@
 
 #if HAVE_CONFIG_H
 #include "config.h"
-#endif                         /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
 
 #ifdef USE_HCACHE
 
 
 #if HAVE_GDBM
 static struct
-header_cache
-{
-       GDBM_FILE db;
-       char *folder;
-       unsigned int crc;
+  header_cache {
+  GDBM_FILE db;
+  char *folder;
+  unsigned int crc;
 } HEADER_CACHE;
 #elif HAVE_DB4
 static struct
-header_cache
-{
-       DB_ENV *env;
-       DB *db;
-       unsigned int crc;
-       int fd;
-       char lockfile[_POSIX_PATH_MAX];
+  header_cache {
+  DB_ENV *env;
+  DB *db;
+  unsigned int crc;
+  int fd;
+  char lockfile[_POSIX_PATH_MAX];
 } HEADER_CACHE;
 #endif
 
-typedef union
-{
-        struct timeval timeval;
-        uint64_t uid_validity;
+typedef union {
+  struct timeval timeval;
+  uint64_t uid_validity;
 } validate;
 
-static void *
-lazy_malloc(size_t siz)
+static void *lazy_malloc (size_t siz)
 {
-       if (0 < siz && siz < 4096) {
-               siz = 4096;
-       }
+  if (0 < siz && siz < 4096) {
+    siz = 4096;
+  }
 
-       return safe_malloc(siz);
+  return safe_malloc (siz);
 }
 
-static void
-lazy_realloc(void *ptr, size_t siz)
+static void lazy_realloc (void *ptr, size_t siz)
 {
-       void **p = (void **)ptr;
+  void **p = (void **) ptr;
 
-       if ( p != NULL
-       &&   0 < siz
-       && siz < 4096) {
-               return;
-       }
+  if (p != NULL && 0 < siz && siz < 4096) {
+    return;
+  }
 
-       safe_realloc(ptr, siz);
+  safe_realloc (ptr, siz);
 }
 
-static unsigned char *
-dump_int(unsigned int i, unsigned char *d, int *off)
+static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)
 {
-       lazy_realloc(&d, *off + sizeof(int));
-       memcpy(d + *off, &i, sizeof(int));
-       (*off) += sizeof(int);
+  lazy_realloc (&d, *off + sizeof (int));
+  memcpy (d + *off, &i, sizeof (int));
+  (*off) += sizeof (int);
 
-       return d;
+  return d;
 }
 
-static void
-restore_int(unsigned int *i, const unsigned char *d, int *off)
+static void restore_int (unsigned int *i, const unsigned char *d, int *off)
 {
-       memcpy(i, d + *off, sizeof(int));
-       (*off) += sizeof(int);
+  memcpy (i, d + *off, sizeof (int));
+  (*off) += sizeof (int);
 }
 
-static unsigned char *
-dump_char(char *c, unsigned char *d, int *off)
+static unsigned char *dump_char (char *c, unsigned char *d, int *off)
 {
-       unsigned int size;
+  unsigned int size;
 
-       if (c == NULL) {
-               size = 0;
-               d = dump_int(size, d, off);
-               return d;
-       }
+  if (c == NULL) {
+    size = 0;
+    d = dump_int (size, d, off);
+    return d;
+  }
 
-       size = mutt_strlen(c) + 1;
-       d = dump_int(size, d, off);
-       lazy_realloc(&d, *off + size);
-       memcpy(d + *off, c, size);
-       *off += size;
+  size = mutt_strlen (c) + 1;
+  d = dump_int (size, d, off);
+  lazy_realloc (&d, *off + size);
+  memcpy (d + *off, c, size);
+  *off += size;
 
-       return d;
+  return d;
 }
 
 #if 0
-static unsigned char *
-dump_char_size(char *c, unsigned char *d, int *off, ssize_t size)
+static unsigned char *dump_char_size (char *c, unsigned char *d, int *off,
+                                      ssize_t size)
 {
-       if (c == NULL) {
-               size = 0;
-               d = dump_int(size, d, off);
-               return d;
-       }
+  if (c == NULL) {
+    size = 0;
+    d = dump_int (size, d, off);
+    return d;
+  }
 
-       d = dump_int(size, d, off);
-       lazy_realloc(&d, *off + size);
-       memcpy(d + *off, c, size);
-       *off += size;
+  d = dump_int (size, d, off);
+  lazy_realloc (&d, *off + size);
+  memcpy (d + *off, c, size);
+  *off += size;
 
-       return d;
+  return d;
 }
 #endif
 
-static void
-restore_char(char **c, const unsigned char *d, int *off)
+static void restore_char (char **c, const unsigned char *d, int *off)
 {
-       unsigned int size;
-       restore_int(&size, d, off);
+  unsigned int size;
 
-       if (size == 0) {
-               *c = NULL;
-               return;
-       }
+  restore_int (&size, d, off);
 
-       *c = safe_malloc(size);
-       memcpy(*c, d + *off, size);
-       *off += size;
+  if (size == 0) {
+    *c = NULL;
+    return;
+  }
+
+  *c = safe_malloc (size);
+  memcpy (*c, d + *off, size);
+  *off += size;
 }
 
-static unsigned char *
-dump_address(ADDRESS *a, unsigned char *d, int *off)
+static unsigned char *dump_address (ADDRESS * a, unsigned char *d, int *off)
 {
-       unsigned int counter = 0;
-       unsigned int start_off = *off;
+  unsigned int counter = 0;
+  unsigned int start_off = *off;
 
-       d = dump_int(0xdeadbeef, d, off);
+  d = dump_int (0xdeadbeef, d, off);
 
-       while (a) {
+  while (a) {
 #ifdef EXACT_ADDRESS
-               d = dump_char(a->val, d, off);
+    d = dump_char (a->val, d, off);
 #endif
-               d = dump_char(a->personal, d, off);
-               d = dump_char(a->mailbox, d, off);
-               d = dump_int(a->group, d, off);
-               a = a->next;
-               counter++;
-       }
+    d = dump_char (a->personal, d, off);
+    d = dump_char (a->mailbox, d, off);
+    d = dump_int (a->group, d, off);
+    a = a->next;
+    counter++;
+  }
 
-       memcpy(d + start_off, &counter, sizeof(int));
+  memcpy (d + start_off, &counter, sizeof (int));
 
-       return d;
+  return d;
 }
 
-static void
-restore_address(ADDRESS **a, const unsigned char *d, int *off)
+static void restore_address (ADDRESS ** a, const unsigned char *d, int *off)
 {
-       unsigned int counter;
+  unsigned int counter;
 
-       restore_int(&counter, d, off);
+  restore_int (&counter, d, off);
 
-       while (counter) {
-               *a = safe_malloc(sizeof(ADDRESS));
+  while (counter) {
+    *a = safe_malloc (sizeof (ADDRESS));
 #ifdef EXACT_ADDRESS
-               restore_char(&(*a)->val, d, off);
+    restore_char (&(*a)->val, d, off);
 #endif
-               restore_char(&(*a)->personal, d, off);
-               restore_char(&(*a)->mailbox, d, off);
-               restore_int((unsigned int *)&(*a)->group, d, off);
-               a = &(*a)->next;
-               counter--;
-       }
+    restore_char (&(*a)->personal, d, off);
+    restore_char (&(*a)->mailbox, d, off);
+    restore_int ((unsigned int *) &(*a)->group, d, off);
+    a = &(*a)->next;
+    counter--;
+  }
 
-       *a = NULL;
+  *a = NULL;
 }
 
-static unsigned char *
-dump_list(LIST *l, unsigned char *d, int *off)
+static unsigned char *dump_list (LIST * l, unsigned char *d, int *off)
 {
-       unsigned int counter = 0;
-       unsigned int start_off = *off;
+  unsigned int counter = 0;
+  unsigned int start_off = *off;
 
-       d = dump_int(0xdeadbeef, d, off);
+  d = dump_int (0xdeadbeef, d, off);
 
-       while (l) {
-               d = dump_char(l->data, d, off);
-               l = l->next;
-               counter++;
-       }
+  while (l) {
+    d = dump_char (l->data, d, off);
+    l = l->next;
+    counter++;
+  }
 
-       memcpy(d + start_off, &counter, sizeof(int));
+  memcpy (d + start_off, &counter, sizeof (int));
 
-       return d;
+  return d;
 }
 
-static void
-restore_list(LIST **l, const unsigned char *d, int *off)
+static void restore_list (LIST ** l, const unsigned char *d, int *off)
 {
-       unsigned int counter;
+  unsigned int counter;
 
-       restore_int(&counter, d, off);
+  restore_int (&counter, d, off);
 
-       while (counter) {
-               *l = safe_malloc(sizeof(LIST));
-               restore_char(&(*l)->data, d, off);
-               l = &(*l)->next;
-               counter--;
-       }
+  while (counter) {
+    *l = safe_malloc (sizeof (LIST));
+    restore_char (&(*l)->data, d, off);
+    l = &(*l)->next;
+    counter--;
+  }
 
-       *l = NULL;
+  *l = NULL;
 }
 
 #if 0
-static unsigned char *
-dump_buffer(BUFFER *b, unsigned char *d, int *off)
+static unsigned char *dump_buffer (BUFFER * b, unsigned char *d, int *off)
 {
-       if (! b) {
-               d = dump_int(0, d, off);
-               return d;
-       } else {
-               d = dump_int(1, d, off);
-       }
+  if (!b) {
+    d = dump_int (0, d, off);
+    return d;
+  }
+  else {
+    d = dump_int (1, d, off);
+  }
 
-       d = dump_char_size(b->data, d, off, b->dsize + 1);
-       d = dump_int(b->dptr - b->data, d, off);
-       d = dump_int(b->dsize, d, off);
-       d = dump_int(b->destroy, d, off);
+  d = dump_char_size (b->data, d, off, b->dsize + 1);
+  d = dump_int (b->dptr - b->data, d, off);
+  d = dump_int (b->dsize, d, off);
+  d = dump_int (b->destroy, d, off);
 
-       return d;
+  return d;
 }
 
-static void
-restore_buffer(BUFFER **b, const unsigned char *d, int *off)
+static void restore_buffer (BUFFER ** b, const unsigned char *d, int *off)
 {
-       unsigned int used;
-       unsigned int offset;
-       restore_int(&used, d, off);
-       if (! used) {
-               return;
-       }
+  unsigned int used;
+  unsigned int offset;
+
+  restore_int (&used, d, off);
+  if (!used) {
+    return;
+  }
 
-       *b = safe_malloc(sizeof(BUFFER));
+  *b = safe_malloc (sizeof (BUFFER));
 
-       restore_char(& (*b)->data, d, off);
-       restore_int(& offset, d, off);
-       (*b)->dptr = (*b)->data + offset;
-       restore_int(& (*b)->dsize, d, off);
-       restore_int((unsigned int *) & (*b)->destroy, d, off);
+  restore_char (&(*b)->data, d, off);
+  restore_int (&offset, d, off);
+  (*b)->dptr = (*b)->data + offset;
+  restore_int (&(*b)->dsize, d, off);
+  restore_int ((unsigned int *) &(*b)->destroy, d, off);
 }
 #endif
 
-static unsigned char *
-dump_parameter(PARAMETER *p, unsigned char *d, int *off)
+static unsigned char *dump_parameter (PARAMETER * p, unsigned char *d,
+                                      int *off)
 {
-       unsigned int counter = 0;
-       unsigned int start_off = *off;
+  unsigned int counter = 0;
+  unsigned int start_off = *off;
 
-       d = dump_int(0xdeadbeef, d, off);
+  d = dump_int (0xdeadbeef, d, off);
 
-       while (p) {
-               d = dump_char(p->attribute, d, off);
-               d = dump_char(p->value, d, off);
-               p = p->next;
-               counter++;
-       }
+  while (p) {
+    d = dump_char (p->attribute, d, off);
+    d = dump_char (p->value, d, off);
+    p = p->next;
+    counter++;
+  }
 
-       memcpy(d + start_off, &counter, sizeof(int));
+  memcpy (d + start_off, &counter, sizeof (int));
 
-       return d;
+  return d;
 }
 
 static void
-restore_parameter(PARAMETER **p, const unsigned char *d, int *off)
+restore_parameter (PARAMETER ** p, const unsigned char *d, int *off)
 {
-       unsigned int counter;
+  unsigned int counter;
 
-       restore_int(&counter, d, off);
+  restore_int (&counter, d, off);
 
-       while (counter) {
-               *p = safe_malloc(sizeof(PARAMETER));
-               restore_char(&(*p)->attribute, d, off);
-               restore_char(&(*p)->value, d, off);
-               p = &(*p)->next;
-               counter--;
-       }
+  while (counter) {
+    *p = safe_malloc (sizeof (PARAMETER));
+    restore_char (&(*p)->attribute, d, off);
+    restore_char (&(*p)->value, d, off);
+    p = &(*p)->next;
+    counter--;
+  }
 
-       *p = NULL;
+  *p = NULL;
 }
 
-static unsigned char *
-dump_body(BODY *c, unsigned char *d, int *off)
+static unsigned char *dump_body (BODY * c, unsigned char *d, int *off)
 {
-       lazy_realloc(&d, *off + sizeof(BODY));
-       memcpy(d + *off, c, sizeof(BODY));
-       *off += sizeof(BODY);
+  lazy_realloc (&d, *off + sizeof (BODY));
+  memcpy (d + *off, c, sizeof (BODY));
+  *off += sizeof (BODY);
 
-       d = dump_char(c->xtype, d, off);
-       d = dump_char(c->subtype, d, off);
+  d = dump_char (c->xtype, d, off);
+  d = dump_char (c->subtype, d, off);
 
-       d = dump_parameter(c->parameter, d, off);
+  d = dump_parameter (c->parameter, d, off);
 
-       d = dump_char(c->description, d, off);
-       d = dump_char(c->form_name, d, off);
-       d = dump_char(c->filename, d, off);
-       d = dump_char(c->d_filename, d, off);
+  d = dump_char (c->description, d, off);
+  d = dump_char (c->form_name, d, off);
+  d = dump_char (c->filename, d, off);
+  d = dump_char (c->d_filename, d, off);
 
-       return d;
+  return d;
 }
 
-static void
-restore_body(BODY *c, const unsigned char *d, int *off)
+static void restore_body (BODY * c, const unsigned char *d, int *off)
 {
-       memcpy(c, d + *off, sizeof(BODY));
-       *off += sizeof(BODY);
+  memcpy (c, d + *off, sizeof (BODY));
+  *off += sizeof (BODY);
 
-       restore_char(& c->xtype, d, off);
-       restore_char(& c->subtype, d, off);
+  restore_char (&c->xtype, d, off);
+  restore_char (&c->subtype, d, off);
 
-       restore_parameter(& c->parameter, d, off);
+  restore_parameter (&c->parameter, d, off);
 
-       restore_char(& c->description, d, off);
-       restore_char(& c->form_name, d, off);
-       restore_char(& c->filename, d, off);
-       restore_char(& c->d_filename, d, off);
+  restore_char (&c->description, d, off);
+  restore_char (&c->form_name, d, off);
+  restore_char (&c->filename, d, off);
+  restore_char (&c->d_filename, d, off);
 }
 
-static unsigned char *
-dump_envelope(ENVELOPE *e, unsigned char *d, int *off)
+static unsigned char *dump_envelope (ENVELOPE * e, unsigned char *d, int *off)
 {
-       d = dump_address(e->return_path, d, off);
-       d = dump_address(e->from, d, off);
-       d = dump_address(e->to, d, off);
-       d = dump_address(e->cc, d, off);
-       d = dump_address(e->bcc, d, off);
-       d = dump_address(e->sender, d, off);
-       d = dump_address(e->reply_to, d, off);
-       d = dump_address(e->mail_followup_to, d, off);
+  d = dump_address (e->return_path, d, off);
+  d = dump_address (e->from, d, off);
+  d = dump_address (e->to, d, off);
+  d = dump_address (e->cc, d, off);
+  d = dump_address (e->bcc, d, off);
+  d = dump_address (e->sender, d, off);
+  d = dump_address (e->reply_to, d, off);
+  d = dump_address (e->mail_followup_to, d, off);
 
-       d = dump_char(e->subject, d, off);
-       if (e->real_subj) {
-               d = dump_int(e->real_subj - e->subject, d, off);
-       } else {
-               d = dump_int(-1, d, off);
-       }
-       d = dump_char(e->message_id, d, off);
-       d = dump_char(e->supersedes, d, off);
-       d = dump_char(e->date, d, off);
-       d = dump_char(e->x_label, d, off);
+  d = dump_char (e->subject, d, off);
+  if (e->real_subj) {
+    d = dump_int (e->real_subj - e->subject, d, off);
+  }
+  else {
+    d = dump_int (-1, d, off);
+  }
+  d = dump_char (e->message_id, d, off);
+  d = dump_char (e->supersedes, d, off);
+  d = dump_char (e->date, d, off);
+  d = dump_char (e->x_label, d, off);
 
-       d = dump_list(e->references, d, off);
-       d = dump_list(e->in_reply_to, d, off);
-       d = dump_list(e->userhdrs, d, off);
+  d = dump_list (e->references, d, off);
+  d = dump_list (e->in_reply_to, d, off);
+  d = dump_list (e->userhdrs, d, off);
 
-       return d;
+  return d;
 }
 
-static void
-restore_envelope(ENVELOPE *e, const unsigned char *d, int *off)
-{
-       int real_subj_off;
-
-       restore_address(& e->return_path, d, off);
-       restore_address(& e->from, d, off);
-       restore_address(& e->to, d, off);
-       restore_address(& e->cc, d, off);
-       restore_address(& e->bcc, d, off);
-       restore_address(& e->sender, d, off);
-       restore_address(& e->reply_to, d, off);
-       restore_address(& e->mail_followup_to, d, off);
-
-       restore_char(& e->subject, d, off);
-       restore_int((unsigned int *) (& real_subj_off), d, off);
-       if (0 <= real_subj_off) {
-               e->real_subj = e->subject + real_subj_off;
-       } else {
-               e->real_subj = NULL;
-       }
-       restore_char(& e->message_id, d, off);
-       restore_char(& e->supersedes, d, off);
-       restore_char(& e->date, d, off);
-       restore_char(& e->x_label, d, off);
-
-       restore_list(& e->references, d, off);
-       restore_list(& e->in_reply_to, d, off);
-       restore_list(& e->userhdrs, d, off);
+static void restore_envelope (ENVELOPE * e, const unsigned char *d, int *off)
+{
+  int real_subj_off;
+
+  restore_address (&e->return_path, d, off);
+  restore_address (&e->from, d, off);
+  restore_address (&e->to, d, off);
+  restore_address (&e->cc, d, off);
+  restore_address (&e->bcc, d, off);
+  restore_address (&e->sender, d, off);
+  restore_address (&e->reply_to, d, off);
+  restore_address (&e->mail_followup_to, d, off);
+
+  restore_char (&e->subject, d, off);
+  restore_int ((unsigned int *) (&real_subj_off), d, off);
+  if (0 <= real_subj_off) {
+    e->real_subj = e->subject + real_subj_off;
+  }
+  else {
+    e->real_subj = NULL;
+  }
+  restore_char (&e->message_id, d, off);
+  restore_char (&e->supersedes, d, off);
+  restore_char (&e->date, d, off);
+  restore_char (&e->x_label, d, off);
+
+  restore_list (&e->references, d, off);
+  restore_list (&e->in_reply_to, d, off);
+  restore_list (&e->userhdrs, d, off);
 }
 
 static
-unsigned int crc32(unsigned int crc, unsigned char const *p, size_t len)
+unsigned int crc32 (unsigned int crc, unsigned char const *p, size_t len)
 {
-       int i;
-       while (len--) {
-               crc ^= *p++;
-               for (i = 0; i < 8; i++)
-                       crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
-       }
-       return crc;
+  int i;
+
+  while (len--) {
+    crc ^= *p++;
+    for (i = 0; i < 8; i++)
+      crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
+  }
+  return crc;
 }
 
-static int
-generate_crc32()
+static int generate_crc32 ()
 {
-       int crc = 0;
+  int crc = 0;
 
-       crc = crc32(crc, (unsigned char const *) "sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613", mutt_strlen("sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613"));
+  crc = crc32 (crc, (unsigned char const *)
+               "sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613",
+               mutt_strlen
+               ("sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613"));
 
 #if HAVE_LANGINFO_CODESET
-       crc = crc32(crc, (unsigned char const *) Charset, mutt_strlen(Charset));
-       crc = crc32(crc, (unsigned char const *) "HAVE_LANGINFO_CODESET", mutt_strlen("HAVE_LANGINFO_CODESET"));
+  crc = crc32 (crc, (unsigned char const *) Charset, mutt_strlen (Charset));
+  crc =
+    crc32 (crc, (unsigned char const *) "HAVE_LANGINFO_CODESET",
+           mutt_strlen ("HAVE_LANGINFO_CODESET"));
 #endif
 
 #if EXACT_ADDRESS
-       crc = crc32(crc, (unsigned char const *) "EXACT_ADDRESS", mutt_strlen("EXACT_ADDRESS"));
+  crc =
+    crc32 (crc, (unsigned char const *) "EXACT_ADDRESS",
+           mutt_strlen ("EXACT_ADDRESS"));
 #endif
 
 #ifdef USE_POP
-       crc = crc32(crc, (unsigned char const *) "USE_POP", mutt_strlen("USE_POP"));
+  crc =
+    crc32 (crc, (unsigned char const *) "USE_POP", mutt_strlen ("USE_POP"));
 #endif
 
 #ifdef MIXMASTER
-       crc = crc32(crc, (unsigned char const *) "MIXMASTER", mutt_strlen("MIXMASTER"));
+  crc =
+    crc32 (crc, (unsigned char const *) "MIXMASTER",
+           mutt_strlen ("MIXMASTER"));
 #endif
 
 #ifdef USE_IMAP
-       crc = crc32(crc, (unsigned char const *) "USE_IMAP", mutt_strlen("USE_IMAP"));
+  crc =
+    crc32 (crc, (unsigned char const *) "USE_IMAP", mutt_strlen ("USE_IMAP"));
 #endif
-       return crc;
+  return crc;
 }
 
-static int
-crc32_matches(const char *d, unsigned int crc)
+static int crc32_matches (const char *d, unsigned int crc)
 {
-       int off = sizeof(validate);
-       unsigned int mycrc = 0;
+  int off = sizeof (validate);
+  unsigned int mycrc = 0;
 
-       if (! d) {
-               return 0;
-       }
+  if (!d) {
+    return 0;
+  }
 
-       restore_int(&mycrc, (unsigned char *) d, &off);
+  restore_int (&mycrc, (unsigned char *) d, &off);
 
-       return (crc == mycrc);
+  return (crc == mycrc);
 }
 
 /* Append md5sumed folder to path if path is a directory. */
-static const char *
-mutt_hcache_per_folder(const char *path, const char *folder)
+static const char *mutt_hcache_per_folder (const char *path,
+                                           const char *folder)
 {
-       static char mutt_hcache_per_folder_path[_POSIX_PATH_MAX];
-       struct stat path_stat;
-       MD5_CTX md5;
-       unsigned char md5sum[16];
-       int ret;
+  static char mutt_hcache_per_folder_path[_POSIX_PATH_MAX];
+  struct stat path_stat;
+  MD5_CTX md5;
+  unsigned char md5sum[16];
+  int ret;
 
-       ret = stat(path, &path_stat);
-       if (ret < 0) {
-               return path;
-       }
+  ret = stat (path, &path_stat);
+  if (ret < 0) {
+    return path;
+  }
 
-       if (! S_ISDIR(path_stat.st_mode)) {
-               return path;
-       }
+  if (!S_ISDIR (path_stat.st_mode)) {
+    return path;
+  }
 
-       MD5Init(&md5);
-       MD5Update(&md5, (unsigned char *) folder, strlen(folder));
-       MD5Final(md5sum, &md5);
+  MD5Init (&md5);
+  MD5Update (&md5, (unsigned char *) folder, strlen (folder));
+  MD5Final (md5sum, &md5);
 
-       ret = snprintf(mutt_hcache_per_folder_path, _POSIX_PATH_MAX,
-                        "%s/%02x%02x%02x%02x%02x%02x%02x%02x"
-                        "%02x%02x%02x%02x%02x%02x%02x%02x",
-                       path, md5sum[0], md5sum[1], md5sum[2], md5sum[3],
-                       md5sum[4], md5sum[5], md5sum[6], md5sum[7], md5sum[8],
-                       md5sum[9], md5sum[10], md5sum[11], md5sum[12],
-                       md5sum[13], md5sum[14], md5sum[15]);
+  ret = snprintf (mutt_hcache_per_folder_path, _POSIX_PATH_MAX,
+                  "%s/%02x%02x%02x%02x%02x%02x%02x%02x"
+                  "%02x%02x%02x%02x%02x%02x%02x%02x",
+                  path, md5sum[0], md5sum[1], md5sum[2], md5sum[3],
+                  md5sum[4], md5sum[5], md5sum[6], md5sum[7], md5sum[8],
+                  md5sum[9], md5sum[10], md5sum[11], md5sum[12],
+                  md5sum[13], md5sum[14], md5sum[15]);
 
-       if (ret <= 0) {
-               return path;
-       }
+  if (ret <= 0) {
+    return path;
+  }
 
-       return mutt_hcache_per_folder_path;
+  return mutt_hcache_per_folder_path;
 }
 
 /* This function transforms a header into a char so that it is useable by
  * db_store */
-static void *
-mutt_hcache_dump(void *_db, HEADER *h, int *off, uint64_t uid_validity)
+static void *mutt_hcache_dump (void *_db, HEADER * h, int *off,
+                               uint64_t uid_validity)
 {
-       struct header_cache *db = _db;
-       unsigned char *d = NULL;
-       *off             = 0;
+  struct header_cache *db = _db;
+  unsigned char *d = NULL;
+
+  *off = 0;
+
+  d = lazy_malloc (sizeof (validate));
 
-       d = lazy_malloc(sizeof(validate));
+  if (uid_validity) {
+    memcpy (d, &uid_validity, sizeof (uint64_t));
+  }
+  else {
+    struct timeval now;
 
-       if (uid_validity) {
-               memcpy(d, &uid_validity, sizeof(uint64_t));
-       } else {
-               struct timeval now;
-               gettimeofday(&now, NULL);
-               memcpy(d, &now, sizeof(struct timeval));
-       }
-       *off += sizeof(validate);
+    gettimeofday (&now, NULL);
+    memcpy (d, &now, sizeof (struct timeval));
+  }
+  *off += sizeof (validate);
 
-       d = dump_int(db->crc, d, off);
+  d = dump_int (db->crc, d, off);
 
-       lazy_realloc(&d, *off + sizeof(HEADER));
-       memcpy(d + *off, h, sizeof(HEADER));
-       *off += sizeof(HEADER);
+  lazy_realloc (&d, *off + sizeof (HEADER));
+  memcpy (d + *off, h, sizeof (HEADER));
+  *off += sizeof (HEADER);
 
-       d = dump_envelope(h->env, d, off);
-       d = dump_body(h->content, d, off);
-       d = dump_char(h->maildir_flags, d, off);
+  d = dump_envelope (h->env, d, off);
+  d = dump_body (h->content, d, off);
+  d = dump_char (h->maildir_flags, d, off);
 
-       return d;
+  return d;
 }
 
-HEADER *
-mutt_hcache_restore(const unsigned char *d, HEADER **oh)
+HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
 {
-       int off = 0;
-       HEADER *h        = mutt_new_header();
+  int off = 0;
+  HEADER *h = mutt_new_header ();
 
-       /* skip validate */
-       off += sizeof(validate);
+  /* skip validate */
+  off += sizeof (validate);
 
-       /* skip crc */
-       off += sizeof(unsigned int);
+  /* skip crc */
+  off += sizeof (unsigned int);
 
-       memcpy(h, d + off, sizeof(HEADER));
-       off += sizeof(HEADER);
+  memcpy (h, d + off, sizeof (HEADER));
+  off += sizeof (HEADER);
 
-       h->env = mutt_new_envelope();
-       restore_envelope(h->env, d, &off);
+  h->env = mutt_new_envelope ();
+  restore_envelope (h->env, d, &off);
 
-       h->content = mutt_new_body();
-       restore_body(h->content, d, &off);
+  h->content = mutt_new_body ();
+  restore_body (h->content, d, &off);
 
-       restore_char(&h->maildir_flags, d, &off);
+  restore_char (&h->maildir_flags, d, &off);
 
-       /* this is needed for maildir style mailboxes */
-       if (oh) {
-               h->old  = (*oh)->old;
-               h->path = safe_strdup((*oh)->path);
-               mutt_free_header (oh);
-       }
+  /* this is needed for maildir style mailboxes */
+  if (oh) {
+    h->old = (*oh)->old;
+    h->path = safe_strdup ((*oh)->path);
+    mutt_free_header (oh);
+  }
 
-       return h;
+  return h;
 }
 
 #if HAVE_GDBM
 
-void *
-mutt_hcache_open(const char *path, const char *folder)
+void *mutt_hcache_open (const char *path, const char *folder)
 {
-       struct header_cache *h = safe_calloc(1, sizeof(HEADER_CACHE));
-       int pagesize = atoi(HeaderCachePageSize) ? atoi(HeaderCachePageSize) : 16384;
-       h->db     = NULL;
-        h->folder = safe_strdup (folder);
-       h->crc    = generate_crc32();
+  struct header_cache *h = safe_calloc (1, sizeof (HEADER_CACHE));
+  int pagesize =
+    atoi (HeaderCachePageSize) ? atoi (HeaderCachePageSize) : 16384;
+  h->db = NULL;
+  h->folder = safe_strdup (folder);
+  h->crc = generate_crc32 ();
 
-       if (! path || path[0] == '\0') {
-               FREE(& h->folder);
-               FREE(& h);
-               return NULL;
-       }
+  if (!path || path[0] == '\0') {
+    FREE (&h->folder);
+    FREE (&h);
+    return NULL;
+  }
 
-       path = mutt_hcache_per_folder(path, folder);
+  path = mutt_hcache_per_folder (path, folder);
 
-       h->db = gdbm_open((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL);
-       if (h->db) {
-               return h;
-       }
+  h->db = gdbm_open ((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL);
+  if (h->db) {
+    return h;
+  }
 
-       /* if rw failed try ro */
-       h->db = gdbm_open((char *) path, pagesize, GDBM_READER, 00600, NULL);
-       if(h->db) {
-               return h;
-       } else {
-               FREE(& h->folder);
-               FREE(& h);
+  /* if rw failed try ro */
+  h->db = gdbm_open ((char *) path, pagesize, GDBM_READER, 00600, NULL);
+  if (h->db) {
+    return h;
+  }
+  else {
+    FREE (&h->folder);
+    FREE (&h);
 
-               return NULL;
-       }
+    return NULL;
+  }
 }
 
-void
-mutt_hcache_close(void *db)
+void mutt_hcache_close (void *db)
 {
-       struct header_cache *h = db;
+  struct header_cache *h = db;
 
-       if (! h) {
-               return;
-       }
+  if (!h) {
+    return;
+  }
 
-       gdbm_close(h->db);
-       FREE(& h->folder);
-       FREE(& h);
+  gdbm_close (h->db);
+  FREE (&h->folder);
+  FREE (&h);
 }
 
-void *
-mutt_hcache_fetch(void *db, const char *filename, size_t (*keylen)(const char *fn))
+void *mutt_hcache_fetch (void *db, const char *filename,
+                         size_t (*keylen) (const char *fn))
 {
-       struct header_cache *h = db;
-       datum key;
-       datum data;
-       char path[_POSIX_PATH_MAX];
+  struct header_cache *h = db;
+  datum key;
+  datum data;
+  char path[_POSIX_PATH_MAX];
 
-       if (! h) {
-               return NULL;
-       }
+  if (!h) {
+    return NULL;
+  }
 
-       strncpy(path, h->folder, sizeof(path));
-       strncat(path, filename, sizeof(path) - mutt_strlen(path));
+  strncpy (path, h->folder, sizeof (path));
+  strncat (path, filename, sizeof (path) - mutt_strlen (path));
 
-       key.dptr  = path;
-       key.dsize = keylen(path);
+  key.dptr = path;
+  key.dsize = keylen (path);
 
-       data = gdbm_fetch(h->db, key);
+  data = gdbm_fetch (h->db, key);
 
-       if (! crc32_matches(data.dptr, h->crc)) {
-               free(data.dptr);
-               return NULL;
-       }
+  if (!crc32_matches (data.dptr, h->crc)) {
+    free (data.dptr);
+    return NULL;
+  }
 
-       return data.dptr;
+  return data.dptr;
 }
 
 int
-mutt_hcache_store(void *db, const char *filename, HEADER *header, uint64_t uid_validity, size_t (*keylen)(const char *fn))
+mutt_hcache_store (void *db, const char *filename, HEADER * header,
+                   uint64_t uid_validity, size_t (*keylen) (const char *fn))
 {
-       struct header_cache *h = db;
-       datum key;
-       datum data;
-       char path[_POSIX_PATH_MAX];
-       int ret;
+  struct header_cache *h = db;
+  datum key;
+  datum data;
+  char path[_POSIX_PATH_MAX];
+  int ret;
 
-       if (! h) {
-               return -1;
-       }
+  if (!h) {
+    return -1;
+  }
 
-       strncpy(path, h->folder, sizeof(path));
-       strncat(path, filename, sizeof(path) - mutt_strlen(path));
+  strncpy (path, h->folder, sizeof (path));
+  strncat (path, filename, sizeof (path) - mutt_strlen (path));
 
-       key.dptr  = path;
-       key.dsize = keylen(path);
+  key.dptr = path;
+  key.dsize = keylen (path);
 
-       data.dptr = mutt_hcache_dump(db, header, &data.dsize, uid_validity);
+  data.dptr = mutt_hcache_dump (db, header, &data.dsize, uid_validity);
 
-       ret = gdbm_store(h->db, key, data, GDBM_REPLACE);
+  ret = gdbm_store (h->db, key, data, GDBM_REPLACE);
 
-       FREE(& data.dptr);
+  FREE (&data.dptr);
 
-       return ret;
+  return ret;
 }
 
 int
-mutt_hcache_delete(void *db, const char *filename, size_t (*keylen)(const char *fn))
+mutt_hcache_delete (void *db, const char *filename,
+                    size_t (*keylen) (const char *fn))
 {
-       datum key;
-       struct header_cache *h = db;
-       char path[_POSIX_PATH_MAX];
+  datum key;
+  struct header_cache *h = db;
+  char path[_POSIX_PATH_MAX];
 
-       if (! h) {
-               return -1;
-       }
+  if (!h) {
+    return -1;
+  }
 
-       strncpy(path, h->folder, sizeof(path));
-       strncat(path, filename, sizeof(path) - mutt_strlen(path));
+  strncpy (path, h->folder, sizeof (path));
+  strncat (path, filename, sizeof (path) - mutt_strlen (path));
 
-       key.dptr  = path;
-       key.dsize = keylen(path);
+  key.dptr = path;
+  key.dsize = keylen (path);
 
-       return gdbm_delete(h->db, key);
+  return gdbm_delete (h->db, key);
 }
 #elif HAVE_DB4
 
-static void
-mutt_hcache_dbt_init(DBT *dbt, void *data, size_t len)
+static void mutt_hcache_dbt_init (DBT * dbt, void *data, size_t len)
 {
-       dbt->data = data;
-       dbt->size = dbt->ulen = len;
-       dbt->dlen = dbt->doff = 0;
-       dbt->flags = DB_DBT_USERMEM;
+  dbt->data = data;
+  dbt->size = dbt->ulen = len;
+  dbt->dlen = dbt->doff = 0;
+  dbt->flags = DB_DBT_USERMEM;
 }
 
-static void
-mutt_hcache_dbt_empty_init(DBT *dbt)
+static void mutt_hcache_dbt_empty_init (DBT * dbt)
 {
-       dbt->data = NULL;
-       dbt->size = dbt->ulen = dbt->dlen = dbt->doff = 0;
-       dbt->flags = 0;
+  dbt->data = NULL;
+  dbt->size = dbt->ulen = dbt->dlen = dbt->doff = 0;
+  dbt->flags = 0;
 }
 
-void *
-mutt_hcache_open(const char *path, const char *folder)
+void *mutt_hcache_open (const char *path, const char *folder)
 {
-       struct stat sb;
-       u_int32_t createflags = DB_CREATE;
-       int ret;
-       struct header_cache *h = calloc(1, sizeof(HEADER_CACHE));
-       int pagesize = atoi(HeaderCachePageSize);
+  struct stat sb;
+  u_int32_t createflags = DB_CREATE;
+  int ret;
+  struct header_cache *h = calloc (1, sizeof (HEADER_CACHE));
+  int pagesize = atoi (HeaderCachePageSize);
 
 
-       h->crc = generate_crc32();
+  h->crc = generate_crc32 ();
 
-       if (! path || path[0] == '\0') {
-               FREE(& h);
-               return NULL;
-       }
+  if (!path || path[0] == '\0') {
+    FREE (&h);
+    return NULL;
+  }
 
-       path = mutt_hcache_per_folder(path, folder);
+  path = mutt_hcache_per_folder (path, folder);
 
-       snprintf (h->lockfile, _POSIX_PATH_MAX, "%s-lock-hack", path);
+  snprintf (h->lockfile, _POSIX_PATH_MAX, "%s-lock-hack", path);
 
-       h->fd = open(h->lockfile, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
-       if (h->fd < 0) {
-               FREE (&h);
-               return NULL;
-       }
+  h->fd = open (h->lockfile, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
+  if (h->fd < 0) {
+    FREE (&h);
+    return NULL;
+  }
 
-       if (mx_lock_file(h->lockfile, h->fd, 1, 0, 5)) {
-               close(h->fd);
-               FREE (&h);
-               return NULL;
-       }
+  if (mx_lock_file (h->lockfile, h->fd, 1, 0, 5)) {
+    close (h->fd);
+    FREE (&h);
+    return NULL;
+  }
 
-       ret = db_env_create(&h->env, 0);
-       if (ret) {
-               mx_unlock_file(h->lockfile, h->fd, 0);
-               close(h->fd);
-               FREE(& h);
-               return NULL;
-       }
+  ret = db_env_create (&h->env, 0);
+  if (ret) {
+    mx_unlock_file (h->lockfile, h->fd, 0);
+    close (h->fd);
+    FREE (&h);
+    return NULL;
+  }
 
-       ret = h->env->open(h->env, NULL, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0600);
-       if (! ret) {
-               ret = db_create(&h->db, h->env, 0);
-               if (ret) {
-                       h->env->close(h->env, 0);
-                       mx_unlock_file(h->lockfile, h->fd, 0);
-                       close(h->fd);
-                       FREE(& h);
-                       return NULL;
-               }
-       }
+  ret =
+    h->env->open (h->env, NULL, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0600);
+  if (!ret) {
+    ret = db_create (&h->db, h->env, 0);
+    if (ret) {
+      h->env->close (h->env, 0);
+      mx_unlock_file (h->lockfile, h->fd, 0);
+      close (h->fd);
+      FREE (&h);
+      return NULL;
+    }
+  }
 
-       if (stat(path, &sb) != 0 && errno == ENOENT) {
-               createflags |= DB_EXCL;
-               h->db->set_pagesize(h->db, pagesize);
-       }
+  if (stat (path, &sb) != 0 && errno == ENOENT) {
+    createflags |= DB_EXCL;
+    h->db->set_pagesize (h->db, pagesize);
+  }
 
-       ret = h->db->open(h->db, NULL, path, folder, DB_BTREE, createflags, 0600);
-       if (ret) {
-               h->db->close(h->db, 0);
-               h->env->close(h->env, 0);
-               mx_unlock_file(h->lockfile, h->fd, 0);
-               close(h->fd);
-               FREE(& h);
-               return NULL;
-       }
+  ret = h->db->open (h->db, NULL, path, folder, DB_BTREE, createflags, 0600);
+  if (ret) {
+    h->db->close (h->db, 0);
+    h->env->close (h->env, 0);
+    mx_unlock_file (h->lockfile, h->fd, 0);
+    close (h->fd);
+    FREE (&h);
+    return NULL;
+  }
 
-       return h;
+  return h;
 }
 
-void
-mutt_hcache_close(void *db)
+void mutt_hcache_close (void *db)
 {
-       struct header_cache *h = db;
-       int ret;
+  struct header_cache *h = db;
+  int ret;
 
-       if (! h) {
-               return;
-       }
+  if (!h) {
+    return;
+  }
 
-       h->db->close(h->db, 0);
-       h->env->close(h->env, 0);
-       mx_unlock_file(h->lockfile, h->fd, 0);
-       close(h->fd);
-       FREE(& h);
+  h->db->close (h->db, 0);
+  h->env->close (h->env, 0);
+  mx_unlock_file (h->lockfile, h->fd, 0);
+  close (h->fd);
+  FREE (&h);
 }
 
-void *
-mutt_hcache_fetch(void *db, const char *filename, size_t (*keylen)(const char *fn))
+void *mutt_hcache_fetch (void *db, const char *filename,
+                         size_t (*keylen) (const char *fn))
 {
-       DBT key;
-       DBT data;
-       struct header_cache *h = db;
+  DBT key;
+  DBT data;
+  struct header_cache *h = db;
 
-       if (! h) {
-               return NULL;
-       }
+  if (!h) {
+    return NULL;
+  }
 
-       filename++; /* skip '/' */
+  filename++;                   /* skip '/' */
 
-       mutt_hcache_dbt_init(&key, (void *) filename, keylen(filename));
-       mutt_hcache_dbt_empty_init(&data);
-       data.flags = DB_DBT_MALLOC;
+  mutt_hcache_dbt_init (&key, (void *) filename, keylen (filename));
+  mutt_hcache_dbt_empty_init (&data);
+  data.flags = DB_DBT_MALLOC;
 
-       h->db->get(h->db, NULL, &key, &data, 0);
+  h->db->get (h->db, NULL, &key, &data, 0);
 
-       if (! crc32_matches(data.data, h->crc)) {
-               free(data.data);
-               return NULL;
-       }
+  if (!crc32_matches (data.data, h->crc)) {
+    free (data.data);
+    return NULL;
+  }
 
-       return data.data;
+  return data.data;
 }
 
 int
-mutt_hcache_store(void *db, const char *filename, HEADER *header, uint64_t uid_validity, size_t (*keylen)(const char *fn))
+mutt_hcache_store (void *db, const char *filename, HEADER * header,
+                   uint64_t uid_validity, size_t (*keylen) (const char *fn))
 {
-       DBT key;
-       DBT data;
-       int ret;
-       struct header_cache *h = db;
+  DBT key;
+  DBT data;
+  int ret;
+  struct header_cache *h = db;
 
-       if (! h) {
-               return -1;
-       }
+  if (!h) {
+    return -1;
+  }
 
-       filename++; /* skip '/' */
+  filename++;                   /* skip '/' */
 
-       mutt_hcache_dbt_init(&key, (void *) filename, keylen(filename));
+  mutt_hcache_dbt_init (&key, (void *) filename, keylen (filename));
 
-       mutt_hcache_dbt_empty_init(&data);
-       data.flags = DB_DBT_USERMEM;
-       data.data = mutt_hcache_dump(db, header, (signed int *) &data.size, uid_validity);
-       data.ulen = data.size;
+  mutt_hcache_dbt_empty_init (&data);
+  data.flags = DB_DBT_USERMEM;
+  data.data =
+    mutt_hcache_dump (db, header, (signed int *) &data.size, uid_validity);
+  data.ulen = data.size;
 
-       ret = h->db->put(h->db, NULL, &key, &data, 0);
+  ret = h->db->put (h->db, NULL, &key, &data, 0);
 
-       FREE(& data.data);
+  FREE (&data.data);
 
-       return ret;
+  return ret;
 }
 
 int
-mutt_hcache_delete(void *db, const char *filename, size_t (*keylen)(const char *fn))
+mutt_hcache_delete (void *db, const char *filename,
+                    size_t (*keylen) (const char *fn))
 {
-       DBT key;
-       struct header_cache *h = db;
+  DBT key;
+  struct header_cache *h = db;
 
-       if (! h) {
-               return -1;
-       }
+  if (!h) {
+    return -1;
+  }
 
-       filename++; /* skip '/' */
+  filename++;                   /* skip '/' */
 
-       mutt_hcache_dbt_init(&key, (void *) filename, keylen(filename));
-       return h->db->del(h->db, NULL, &key, 0);
+  mutt_hcache_dbt_init (&key, (void *) filename, keylen (filename));
+  return h->db->del (h->db, NULL, &key, 0);
 }
 #endif
 
index 7db6ede..6304608 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <string.h>
 #include <locale.h>
 
-int mutt_is_mail_list (ADDRESS *addr)
+int mutt_is_mail_list (ADDRESS * addr)
 {
   if (!mutt_match_rx_list (addr->mailbox, UnMailLists))
     return mutt_match_rx_list (addr->mailbox, MailLists);
   return 0;
 }
 
-int mutt_is_subscribed_list (ADDRESS *addr)
+int mutt_is_subscribed_list (ADDRESS * addr)
 {
   if (!mutt_match_rx_list (addr->mailbox, UnMailLists)
       && !mutt_match_rx_list (addr->mailbox, UnSubscribedLists))
@@ -52,14 +52,12 @@ int mutt_is_subscribed_list (ADDRESS *addr)
  * return 1.  Otherwise, simply return 0.
  */
 static int
-check_for_mailing_list (ADDRESS *adr, char *pfx, char *buf, int buflen)
+check_for_mailing_list (ADDRESS * adr, char *pfx, char *buf, int buflen)
 {
-  for (; adr; adr = adr->next)
-  {
-    if (mutt_is_subscribed_list (adr))
-    {
+  for (; adr; adr = adr->next) {
+    if (mutt_is_subscribed_list (adr)) {
       if (pfx && buf && buflen)
-       snprintf (buf, buflen, "%s%s", pfx, mutt_get_name (adr));
+        snprintf (buf, buflen, "%s%s", pfx, mutt_get_name (adr));
       return 1;
     }
   }
@@ -70,15 +68,12 @@ check_for_mailing_list (ADDRESS *adr, char *pfx, char *buf, int buflen)
  * If one is found, print the address of the list into buf, then return 1.
  * Otherwise, simply return 0.
  */
-static int
-check_for_mailing_list_addr (ADDRESS *adr, char *buf, int buflen)
+static int check_for_mailing_list_addr (ADDRESS * adr, char *buf, int buflen)
 {
-  for (; adr; adr = adr->next)
-  {
-    if (mutt_is_subscribed_list (adr))
-    {
+  for (; adr; adr = adr->next) {
+    if (mutt_is_subscribed_list (adr)) {
       if (buf && buflen)
-       snprintf (buf, buflen, "%s", adr->mailbox);
+        snprintf (buf, buflen, "%s", adr->mailbox);
       return 1;
     }
   }
@@ -86,12 +81,10 @@ check_for_mailing_list_addr (ADDRESS *adr, char *buf, int buflen)
 }
 
 
-static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a)
+static int first_mailing_list (char *buf, size_t buflen, ADDRESS * a)
 {
-  for (; a; a = a->next)
-  {
-    if (mutt_is_subscribed_list (a))
-    {
+  for (; a; a = a->next) {
+    if (mutt_is_subscribed_list (a)) {
       mutt_save_path (buf, buflen, a);
       return 1;
     }
@@ -99,14 +92,13 @@ static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a)
   return 0;
 }
 
-static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
+static void make_from (ENVELOPE * hdr, char *buf, size_t len, int do_lists)
 {
   int me;
 
   me = mutt_addr_is_user (hdr->from);
 
-  if (do_lists || me)
-  {
+  if (do_lists || me) {
     if (check_for_mailing_list (hdr->to, "To ", buf, len))
       return;
     if (check_for_mailing_list (hdr->cc, "Cc ", buf, len))
@@ -123,14 +115,14 @@ static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
     *buf = 0;
 }
 
-static void make_from_addr (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
+static void make_from_addr (ENVELOPE * hdr, char *buf, size_t len,
+                            int do_lists)
 {
   int me;
 
   me = mutt_addr_is_user (hdr->from);
 
-  if (do_lists || me)
-  {
+  if (do_lists || me) {
     if (check_for_mailing_list_addr (hdr->to, buf, len))
       return;
     if (check_for_mailing_list_addr (hdr->cc, buf, len))
@@ -147,7 +139,7 @@ static void make_from_addr (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
     *buf = 0;
 }
 
-static int user_in_addr (ADDRESS *a)
+static int user_in_addr (ADDRESS * a)
 {
   for (; a; a = a->next)
     if (mutt_addr_is_user (a))
@@ -163,22 +155,20 @@ static int user_in_addr (ADDRESS *a)
  * 4: user is originator
  * 5: sent to a subscribed mailinglist
  */
-int mutt_user_is_recipient (HEADER *h)
+int mutt_user_is_recipient (HEADER * h)
 {
   ENVELOPE *env = h->env;
 
-  if(!h->recip_valid)
-  {
+  if (!h->recip_valid) {
     h->recip_valid = 1;
-    
+
     if (mutt_addr_is_user (env->from))
       h->recipient = 4;
-    else if (user_in_addr (env->to))
-    {
+    else if (user_in_addr (env->to)) {
       if (env->to->next || env->cc)
-       h->recipient = 2; /* non-unique recipient */
+        h->recipient = 2;       /* non-unique recipient */
       else
-       h->recipient = 1; /* unique recipient */
+        h->recipient = 1;       /* unique recipient */
     }
     else if (user_in_addr (env->cc))
       h->recipient = 3;
@@ -189,7 +179,7 @@ int mutt_user_is_recipient (HEADER *h)
     else
       h->recipient = 0;
   }
-  
+
   return h->recipient;
 }
 
@@ -225,22 +215,19 @@ int mutt_user_is_recipient (HEADER *h)
  * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
  * %Z = status flags   */
 
-struct hdr_format_info
-{
+struct hdr_format_info {
   CONTEXT *ctx;
   HEADER *hdr;
 };
 
-static const char *
-hdr_format_str (char *dest,
-               size_t destlen,
-               char op,
-               const char *src,
-               const char *prefix,
-               const char *ifstring,
-               const char *elsestring,
-               unsigned long data,
-               format_flag flags)
+static const char *hdr_format_str (char *dest,
+                                   size_t destlen,
+                                   char op,
+                                   const char *src,
+                                   const char *prefix,
+                                   const char *ifstring,
+                                   const char *elsestring,
+                                   unsigned long data, format_flag flags)
 {
   struct hdr_format_info *hfi = (struct hdr_format_info *) data;
   HEADER *hdr, *htmp;
@@ -250,6 +237,7 @@ hdr_format_str (char *dest,
   int optional = (flags & M_FORMAT_OPTIONAL);
   int threads = ((Sort & SORT_MASK) == SORT_THREADS);
   int is_index = (flags & M_FORMAT_INDEX);
+
 #define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 1)
 #define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && mutt_thread_contains_unread (ctx, hdr) == 2)
   size_t len;
@@ -258,489 +246,477 @@ hdr_format_str (char *dest,
   ctx = hfi->ctx;
 
   dest[0] = 0;
-  switch (op)
-  {
-    case 'A':
-      if(hdr->env->reply_to && hdr->env->reply_to->mailbox)
-      {
-       mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->reply_to));
-       break;
-      }
-      /* fall through if 'A' returns nothing */
-
-    case 'a':
-      if(hdr->env->from && hdr->env->from->mailbox)
-      {
-       mutt_format_s (dest, destlen, prefix, mutt_addr_for_display (hdr->env->from));
-      }
-      else
-        dest[0] = '\0';
+  switch (op) {
+  case 'A':
+    if (hdr->env->reply_to && hdr->env->reply_to->mailbox) {
+      mutt_format_s (dest, destlen, prefix,
+                     mutt_addr_for_display (hdr->env->reply_to));
       break;
+    }
+    /* fall through if 'A' returns nothing */
 
-    case 'B':
-      if (!first_mailing_list (dest, destlen, hdr->env->to) &&
-         !first_mailing_list (dest, destlen, hdr->env->cc))
-       dest[0] = 0;
-      if (dest[0])
-      {
-       strfcpy (buf2, dest, sizeof(buf2));
-       mutt_format_s (dest, destlen, prefix, buf2);
-       break;
-      }
-      /* fall through if 'B' returns nothing */
-
-    case 'b':
-      if(ctx)
-      {
-       if ((p = strrchr (ctx->path, '/')))
-         strfcpy (dest, p + 1, destlen);
-       else
-         strfcpy (dest, ctx->path, destlen);
-      }
-      else 
-       strfcpy(dest, "(null)", destlen);
-      strfcpy (buf2, dest, sizeof(buf2));
-      mutt_format_s (dest, destlen, prefix, buf2);
-      break;
-    
-    case 'c':
-      mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);
+  case 'a':
+    if (hdr->env->from && hdr->env->from->mailbox) {
+      mutt_format_s (dest, destlen, prefix,
+                     mutt_addr_for_display (hdr->env->from));
+    }
+    else
+      dest[0] = '\0';
+    break;
+
+  case 'B':
+    if (!first_mailing_list (dest, destlen, hdr->env->to) &&
+        !first_mailing_list (dest, destlen, hdr->env->cc))
+      dest[0] = 0;
+    if (dest[0]) {
+      strfcpy (buf2, dest, sizeof (buf2));
       mutt_format_s (dest, destlen, prefix, buf2);
       break;
+    }
+    /* fall through if 'B' returns nothing */
 
-    case 'C':
-      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-      snprintf (dest, destlen, fmt, hdr->msgno + 1);
-      break;
-
-    case 'd':
-    case 'D':
-    case '{':
-    case '[':
-    case '(':
-    case '<':
-
-      /* preprocess $date_format to handle %Z */
-      {
-       const char *cp;
-       struct tm *tm; 
-       time_t T;
-
-       p = dest;
-
-       cp = (op == 'd' || op == 'D') ? (NONULL (DateFmt)) : src;
-       if (*cp == '!')
-       {
-         do_locales = 0;
-         cp++;
-       }
-       else
-         do_locales = 1;
-
-       len = destlen - 1;
-       while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||
-                          (op == '{' && *cp != '}') || 
-                          (op == '[' && *cp != ']') ||
-                          (op == '(' && *cp != ')') ||
-                          (op == '<' && *cp != '>')))
-       {
-         if (*cp == '%')
-         {
-           cp++;
-           if ((*cp == 'Z' || *cp == 'z') && (op == 'd' || op == '{'))
-           {
-             if (len >= 5)
-             {
-               sprintf (p, "%c%02u%02u", hdr->zoccident ? '-' : '+',
-                        hdr->zhours, hdr->zminutes);
-               p += 5;
-               len -= 5;
-             }
-             else
-               break; /* not enough space left */
-           }
-           else
-           {
-             if (len >= 2)
-             {
-               *p++ = '%';
-               *p++ = *cp;
-               len -= 2;
-             }
-             else
-               break; /* not enough space */
-           }
-           cp++;
-         }
-         else
-         {
-           *p++ = *cp++;
-           len--;
-         }
-       }
-       *p = 0;
-
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
-
-       if (op == '[' || op == 'D')
-         tm = localtime (&hdr->date_sent);
-       else if (op == '(')
-         tm = localtime (&hdr->received);
-       else if (op == '<')
-       {
-         T = time (NULL);
-         tm = localtime (&T);
-       }
-       else
-       {
-         /* restore sender's time zone */
-         T = hdr->date_sent;
-         if (hdr->zoccident)
-           T -= (hdr->zhours * 3600 + hdr->zminutes * 60);
-         else
-           T += (hdr->zhours * 3600 + hdr->zminutes * 60);
-         tm = gmtime (&T);
-       }
-
-       strftime (buf2, sizeof (buf2), dest, tm);
-
-       if (do_locales)
-         setlocale (LC_TIME, "C");
-
-       mutt_format_s (dest, destlen, prefix, buf2);
-       if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
-         src = cp + 1;
-      }
-      break;
+  case 'b':
+    if (ctx) {
+      if ((p = strrchr (ctx->path, '/')))
+        strfcpy (dest, p + 1, destlen);
+      else
+        strfcpy (dest, ctx->path, destlen);
+    }
+    else
+      strfcpy (dest, "(null)", destlen);
+    strfcpy (buf2, dest, sizeof (buf2));
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'c':
+    mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'C':
+    snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+    snprintf (dest, destlen, fmt, hdr->msgno + 1);
+    break;
+
+  case 'd':
+  case 'D':
+  case '{':
+  case '[':
+  case '(':
+  case '<':
+
+    /* preprocess $date_format to handle %Z */
+    {
+      const char *cp;
+      struct tm *tm;
+      time_t T;
 
-    case 'e':
-      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-      snprintf (dest, destlen, fmt, mutt_messages_in_thread(ctx, hdr, 1));
-      break;
+      p = dest;
 
-    case 'E':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, mutt_messages_in_thread(ctx, hdr, 0));
+      cp = (op == 'd' || op == 'D') ? (NONULL (DateFmt)) : src;
+      if (*cp == '!') {
+        do_locales = 0;
+        cp++;
       }
-      else if (mutt_messages_in_thread(ctx, hdr, 0) <= 1)
-       optional = 0;
-      break;
-
-    case 'f':
-      buf2[0] = 0;
-      rfc822_write_address (buf2, sizeof (buf2), hdr->env->from, 1);
-      mutt_format_s (dest, destlen, prefix, buf2);
-      break;
-
-    case 'F':
-      if (!optional)
-      {
-        make_from (hdr->env, buf2, sizeof (buf2), 0);
-       mutt_format_s (dest, destlen, prefix, buf2);
+      else
+        do_locales = 1;
+
+      len = destlen - 1;
+      while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||
+                         (op == '{' && *cp != '}') ||
+                         (op == '[' && *cp != ']') ||
+                         (op == '(' && *cp != ')') ||
+                         (op == '<' && *cp != '>'))) {
+        if (*cp == '%') {
+          cp++;
+          if ((*cp == 'Z' || *cp == 'z') && (op == 'd' || op == '{')) {
+            if (len >= 5) {
+              sprintf (p, "%c%02u%02u", hdr->zoccident ? '-' : '+',
+                       hdr->zhours, hdr->zminutes);
+              p += 5;
+              len -= 5;
+            }
+            else
+              break;            /* not enough space left */
+          }
+          else {
+            if (len >= 2) {
+              *p++ = '%';
+              *p++ = *cp;
+              len -= 2;
+            }
+            else
+              break;            /* not enough space */
+          }
+          cp++;
+        }
+        else {
+          *p++ = *cp++;
+          len--;
+        }
+      }
+      *p = 0;
+
+      if (do_locales && Locale)
+        setlocale (LC_TIME, Locale);
+
+      if (op == '[' || op == 'D')
+        tm = localtime (&hdr->date_sent);
+      else if (op == '(')
+        tm = localtime (&hdr->received);
+      else if (op == '<') {
+        T = time (NULL);
+        tm = localtime (&T);
+      }
+      else {
+        /* restore sender's time zone */
+        T = hdr->date_sent;
+        if (hdr->zoccident)
+          T -= (hdr->zhours * 3600 + hdr->zminutes * 60);
+        else
+          T += (hdr->zhours * 3600 + hdr->zminutes * 60);
+        tm = gmtime (&T);
       }
-      else if (mutt_addr_is_user (hdr->env->from))
-        optional = 0;
-      break;
-
-#ifdef USE_NNTP
-    case 'g':
-      mutt_format_s (dest, destlen, prefix, hdr->env->newsgroups ? hdr->env->newsgroups : "");
-      break;
-#endif
 
-    case 'H':
-      /* (Hormel) spam score */
-      if (optional)
-       optional = hdr->env->spam ? 1 : 0;
+      strftime (buf2, sizeof (buf2), dest, tm);
 
-       if (hdr->env->spam)
-         mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->spam->data));
-       else
-         mutt_format_s (dest, destlen, prefix, "");
+      if (do_locales)
+        setlocale (LC_TIME, "C");
 
-      break;
+      mutt_format_s (dest, destlen, prefix, buf2);
+      if (len > 0 && op != 'd' && op != 'D')    /* Skip ending op */
+        src = cp + 1;
+    }
+    break;
 
-    case 'i':
-      mutt_format_s (dest, destlen, prefix, hdr->env->message_id ? hdr->env->message_id : "<no.id>");
-      break;
+  case 'e':
+    snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+    snprintf (dest, destlen, fmt, mutt_messages_in_thread (ctx, hdr, 1));
+    break;
 
-    case 'I':
-      {
-       int iflag = FALSE;
-       int j = 0;
-
-       for (i = 0; hdr->env->from && hdr->env->from->personal &&
-                   hdr->env->from->personal[i] && j < SHORT_STRING - 1; i++)
-       {
-         if (isalpha ((int)hdr->env->from->personal[i]))
-         {
-           if (!iflag)
-           {
-             buf2[j++] = hdr->env->from->personal[i];
-             iflag = TRUE;
-           }
-         }
-         else
-           iflag = FALSE;
-       }
-
-       buf2[j] = '\0';
-      }
+  case 'E':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, mutt_messages_in_thread (ctx, hdr, 0));
+    }
+    else if (mutt_messages_in_thread (ctx, hdr, 0) <= 1)
+      optional = 0;
+    break;
+
+  case 'f':
+    buf2[0] = 0;
+    rfc822_write_address (buf2, sizeof (buf2), hdr->env->from, 1);
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'F':
+    if (!optional) {
+      make_from (hdr->env, buf2, sizeof (buf2), 0);
       mutt_format_s (dest, destlen, prefix, buf2);
-      break;
+    }
+    else if (mutt_addr_is_user (hdr->env->from))
+      optional = 0;
+    break;
 
-    case 'l':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, (int) hdr->lines);
-      }
-      else if (hdr->lines <= 0)
-        optional = 0;
-      break;
+#ifdef USE_NNTP
+  case 'g':
+    mutt_format_s (dest, destlen, prefix,
+                   hdr->env->newsgroups ? hdr->env->newsgroups : "");
+    break;
+#endif
 
-    case 'L':
-      if (!optional)
-      {
-       make_from (hdr->env, buf2, sizeof (buf2), 1);
-       mutt_format_s (dest, destlen, prefix, buf2);
-      }
-      else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) &&
-              !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0))
-      {
-       optional = 0;
-      }
-      break;
+  case 'H':
+    /* (Hormel) spam score */
+    if (optional)
+      optional = hdr->env->spam ? 1 : 0;
 
-    case 'm':
-      if(ctx)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, ctx->msgcount);
-      }
-      else
-       strfcpy(dest, "(null)", destlen);
-      break;
+    if (hdr->env->spam)
+      mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->spam->data));
+    else
+      mutt_format_s (dest, destlen, prefix, "");
 
-    case 'n':
-      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->from));
-      break;
+    break;
 
-    case 'N':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, hdr->score);
-      }
-      else
-      {
-       if (hdr->score == 0)
-         optional = 0;
-      }
-      break;
+  case 'i':
+    mutt_format_s (dest, destlen, prefix,
+                   hdr->env->message_id ? hdr->env->message_id : "<no.id>");
+    break;
 
-    case 'O':
-      if (!optional)
-      {
-       make_from_addr (hdr->env, buf2, sizeof (buf2), 1);
-       if (!option (OPTSAVEADDRESS) && (p = strpbrk (buf2, "%@")))
-         *p = 0;
-       mutt_format_s (dest, destlen, prefix, buf2);
-      }
-      else if (!check_for_mailing_list_addr (hdr->env->to, NULL, 0) &&
-              !check_for_mailing_list_addr (hdr->env->cc, NULL, 0))
-      {
-       optional = 0;
+  case 'I':
+    {
+      int iflag = FALSE;
+      int j = 0;
+
+      for (i = 0; hdr->env->from && hdr->env->from->personal &&
+           hdr->env->from->personal[i] && j < SHORT_STRING - 1; i++) {
+        if (isalpha ((int) hdr->env->from->personal[i])) {
+          if (!iflag) {
+            buf2[j++] = hdr->env->from->personal[i];
+            iflag = TRUE;
+          }
+        }
+        else
+          iflag = FALSE;
       }
-      break;
 
-    case 'M':
-      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-      if (!optional)
-      {
-       if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1)
-         snprintf (dest, destlen, fmt, hdr->num_hidden);
-       else if (is_index && threads)
-         mutt_format_s (dest, destlen, prefix, " ");
-       else
-         *dest = '\0';
-      }
-      else
-      {
-       if (!(threads && is_index && hdr->collapsed && hdr->num_hidden > 1))
-         optional = 0;
-      }
-      break;
+      buf2[j] = '\0';
+    }
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
 
-    case 's':
-      
-      if (flags & M_FORMAT_TREE && !hdr->collapsed)
-      {
-       if (flags & M_FORMAT_FORCESUBJ)
-       {
-         mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
-         snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
-         mutt_format_s_tree (dest, destlen, prefix, buf2);
-       }
-       else
-         mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
-      }
-      else
-       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
-      break;
+  case 'l':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, (int) hdr->lines);
+    }
+    else if (hdr->lines <= 0)
+      optional = 0;
+    break;
 
-    case 'S':
-      if (hdr->deleted)
-       ch = 'D';
-      else if (hdr->attach_del)
-       ch = 'd';
-      else if (hdr->tagged)
-       ch = '*';
-      else if (hdr->flagged)
-       ch = '!';
-      else if (hdr->replied)
-       ch = 'r';
-      else if (hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
-       ch = '-';
-      else if (hdr->old)
-       ch = 'O';
-      else
-       ch = 'N';
+  case 'L':
+    if (!optional) {
+      make_from (hdr->env, buf2, sizeof (buf2), 1);
+      mutt_format_s (dest, destlen, prefix, buf2);
+    }
+    else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) &&
+             !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0)) {
+      optional = 0;
+    }
+    break;
 
-      /* FOO - this is probably unsafe, but we are not likely to have such
-        a short string passed into this routine */
-      *dest = ch;
-      *(dest + 1) = 0;
-      break;
+  case 'm':
+    if (ctx) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, ctx->msgcount);
+    }
+    else
+      strfcpy (dest, "(null)", destlen);
+    break;
 
-    case 't':
-      buf2[0] = 0;
-      if (!check_for_mailing_list (hdr->env->to, "To ", buf2, sizeof (buf2)) &&
-         !check_for_mailing_list (hdr->env->cc, "Cc ", buf2, sizeof (buf2)))
-      {
-       if (hdr->env->to)
-         snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name (hdr->env->to));
-       else if (hdr->env->cc)
-         snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name (hdr->env->cc));
-      }
-      mutt_format_s (dest, destlen, prefix, buf2);
-      break;
+  case 'n':
+    mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->from));
+    break;
 
-    case 'T':
-      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-      snprintf (dest, destlen, fmt,
-               (Tochars && ((i = mutt_user_is_recipient (hdr))) < mutt_strlen (Tochars)) ? Tochars[i] : ' ');
-      break;
+  case 'N':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, hdr->score);
+    }
+    else {
+      if (hdr->score == 0)
+        optional = 0;
+    }
+    break;
 
-    case 'u':
-      if (hdr->env->from && hdr->env->from->mailbox)
-      {
-       strfcpy (buf2, mutt_addr_for_display (hdr->env->from), sizeof (buf2));
-       if ((p = strpbrk (buf2, "%@")))
-         *p = 0;
-      }
-      else
-       buf2[0] = 0;
+  case 'O':
+    if (!optional) {
+      make_from_addr (hdr->env, buf2, sizeof (buf2), 1);
+      if (!option (OPTSAVEADDRESS) && (p = strpbrk (buf2, "%@")))
+        *p = 0;
       mutt_format_s (dest, destlen, prefix, buf2);
-      break;
-
-    case 'v':
-      if (mutt_addr_is_user (hdr->env->from)) 
-      {
-       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;
-      }
+    }
+    else if (!check_for_mailing_list_addr (hdr->env->to, NULL, 0) &&
+             !check_for_mailing_list_addr (hdr->env->cc, NULL, 0)) {
+      optional = 0;
+    }
+    break;
+
+  case 'M':
+    snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+    if (!optional) {
+      if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1)
+        snprintf (dest, destlen, fmt, hdr->num_hidden);
+      else if (is_index && threads)
+        mutt_format_s (dest, destlen, prefix, " ");
       else
-       mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->from));
-      if ((p = strpbrk (buf2, " %@")))
-       *p = 0;
-      mutt_format_s (dest, destlen, prefix, buf2);
-      break;
-
-    case 'W':
-      if (!optional)
-       mutt_format_s (dest, destlen, prefix, hdr->env->organization ? hdr->env->organization : "");
-      else if (!hdr->env->organization)
-       optional = 0;
-      break;
+        *dest = '\0';
+    }
+    else {
+      if (!(threads && is_index && hdr->collapsed && hdr->num_hidden > 1))
+        optional = 0;
+    }
+    break;
 
-    case 'Z':
-    
-      ch = ' ';
-
-      if (WithCrypto && hdr->security & GOODSIGN)
-        ch = 'S';
-      else if (WithCrypto && hdr->security & ENCRYPT)
-       ch = 'P';
-      else if (WithCrypto && hdr->security & SIGN)
-        ch = 's';
-      else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY)
-        ch = 'K';
-
-      snprintf (buf2, sizeof (buf2),
-               "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' : 
-               ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
-               ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))),
-               hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
-               hdr->tagged ? '*' :
-               (hdr->flagged ? '!' :
-                (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
-      mutt_format_s (dest, destlen, prefix, buf2);
-      break;
+  case 's':
 
-     case 'y':
-       if (optional)
-        optional = hdr->env->x_label ? 1 : 0;
-
-       mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
-       break;
-    case 'Y':
-      if (hdr->env->x_label)
-      {
-       i = 1;  /* reduce reuse recycle */
-       htmp = NULL;
-       if (flags & M_FORMAT_TREE
-           && (hdr->thread->prev && hdr->thread->prev->message
-               && hdr->thread->prev->message->env->x_label))
-         htmp = hdr->thread->prev->message;
-       else if (flags & M_FORMAT_TREE
-                && (hdr->thread->parent && hdr->thread->parent->message
-                    && hdr->thread->parent->message->env->x_label))
-         htmp = hdr->thread->parent->message;
-       if (htmp && mutt_strcasecmp (hdr->env->x_label,
-                                    htmp->env->x_label) == 0)
-         i = 0;
+    if (flags & M_FORMAT_TREE && !hdr->collapsed) {
+      if (flags & M_FORMAT_FORCESUBJ) {
+        mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
+        snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
+        mutt_format_s_tree (dest, destlen, prefix, buf2);
       }
       else
-       i = 0;
+        mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
+    }
+    else
+      mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
+    break;
+
+  case 'S':
+    if (hdr->deleted)
+      ch = 'D';
+    else if (hdr->attach_del)
+      ch = 'd';
+    else if (hdr->tagged)
+      ch = '*';
+    else if (hdr->flagged)
+      ch = '!';
+    else if (hdr->replied)
+      ch = 'r';
+    else if (hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
+      ch = '-';
+    else if (hdr->old)
+      ch = 'O';
+    else
+      ch = 'N';
+
+    /* FOO - this is probably unsafe, but we are not likely to have such
+       a short string passed into this routine */
+    *dest = ch;
+    *(dest + 1) = 0;
+    break;
+
+  case 't':
+    buf2[0] = 0;
+    if (!check_for_mailing_list (hdr->env->to, "To ", buf2, sizeof (buf2)) &&
+        !check_for_mailing_list (hdr->env->cc, "Cc ", buf2, sizeof (buf2))) {
+      if (hdr->env->to)
+        snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name (hdr->env->to));
+      else if (hdr->env->cc)
+        snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name (hdr->env->cc));
+    }
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'T':
+    snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+    snprintf (dest, destlen, fmt,
+              (Tochars
+               && ((i = mutt_user_is_recipient (hdr))) <
+               mutt_strlen (Tochars)) ? Tochars[i] : ' ');
+    break;
+
+  case 'u':
+    if (hdr->env->from && hdr->env->from->mailbox) {
+      strfcpy (buf2, mutt_addr_for_display (hdr->env->from), sizeof (buf2));
+      if ((p = strpbrk (buf2, "%@")))
+        *p = 0;
+    }
+    else
+      buf2[0] = 0;
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'v':
+    if (mutt_addr_is_user (hdr->env->from)) {
+      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;
+    }
+    else
+      mutt_format_s (buf2, sizeof (buf2), prefix,
+                     mutt_get_name (hdr->env->from));
+    if ((p = strpbrk (buf2, " %@")))
+      *p = 0;
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'W':
+    if (!optional)
+      mutt_format_s (dest, destlen, prefix,
+                     hdr->env->organization ? hdr->env->organization : "");
+    else if (!hdr->env->organization)
+      optional = 0;
+    break;
+
+  case 'Z':
+
+    ch = ' ';
+
+    if (WithCrypto && hdr->security & GOODSIGN)
+      ch = 'S';
+    else if (WithCrypto && hdr->security & ENCRYPT)
+      ch = 'P';
+    else if (WithCrypto && hdr->security & SIGN)
+      ch = 's';
+    else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY)
+      ch = 'K';
+
+    snprintf (buf2, sizeof (buf2),
+              "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
+                                             ((hdr->read
+                                               && (ctx
+                                                   && ctx->msgnotreadyet !=
+                                                   hdr->msgno))
+                                              ? (hdr->
+                                                 replied ? 'r' : ' ') : (hdr->
+                                                                         old ?
+                                                                         'O' :
+                                                                         'N')))),
+              hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
+              hdr->tagged ? '*' : (hdr->
+                                   flagged ? '!' : (Tochars
+                                                    &&
+                                                    ((i =
+                                                      mutt_user_is_recipient
+                                                      (hdr)) <
+                                                     mutt_strlen (Tochars)) ?
+                                                    Tochars[i] : ' ')));
+    mutt_format_s (dest, destlen, prefix, buf2);
+    break;
+
+  case 'y':
+    if (optional)
+      optional = hdr->env->x_label ? 1 : 0;
+
+    mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
+    break;
+
+  case 'Y':
+    if (hdr->env->x_label) {
+      i = 1;                    /* reduce reuse recycle */
+      htmp = NULL;
+      if (flags & M_FORMAT_TREE
+          && (hdr->thread->prev && hdr->thread->prev->message
+              && hdr->thread->prev->message->env->x_label))
+        htmp = hdr->thread->prev->message;
+      else if (flags & M_FORMAT_TREE
+               && (hdr->thread->parent && hdr->thread->parent->message
+                   && hdr->thread->parent->message->env->x_label))
+        htmp = hdr->thread->parent->message;
+      if (htmp && mutt_strcasecmp (hdr->env->x_label,
+                                   htmp->env->x_label) == 0)
+        i = 0;
+    }
+    else
+      i = 0;
 
-      if (optional)
-       optional = i;
+    if (optional)
+      optional = i;
 
-      if (i)
-        mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
-      else
-        mutt_format_s (dest, destlen, prefix, "");
+    if (i)
+      mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
+    else
+      mutt_format_s (dest, destlen, prefix, "");
 
-      break;
+    break;
 
-    default:
-      snprintf (dest, destlen, "%%%s%c", prefix, op);
-      break;
+  default:
+    snprintf (dest, destlen, "%%%s%c", prefix, op);
+    break;
   }
 
   if (optional)
-    mutt_FormatString (dest, destlen, ifstring, hdr_format_str, (unsigned long) hfi, flags);
+    mutt_FormatString (dest, destlen, ifstring, hdr_format_str,
+                       (unsigned long) hfi, flags);
   else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, elsestring, hdr_format_str, (unsigned long) hfi, flags);
+    mutt_FormatString (dest, destlen, elsestring, hdr_format_str,
+                       (unsigned long) hfi, flags);
 
   return (src);
 #undef THREAD_NEW
@@ -748,12 +724,14 @@ hdr_format_str (char *dest,
 }
 
 void
-_mutt_make_string (char *dest, size_t destlen, const char *s, CONTEXT *ctx, HEADER *hdr, format_flag flags)
+_mutt_make_string (char *dest, size_t destlen, const char *s, CONTEXT * ctx,
+                   HEADER * hdr, format_flag flags)
 {
   struct hdr_format_info hfi;
 
   hfi.hdr = hdr;
   hfi.ctx = ctx;
 
-  mutt_FormatString (dest, destlen, s, hdr_format_str, (unsigned long) &hfi, flags);
+  mutt_FormatString (dest, destlen, s, hdr_format_str, (unsigned long) &hfi,
+                     flags);
 }
index 6283081..c83d6d7 100644 (file)
--- a/headers.c
+++ b/headers.c
 #include <ctype.h>
 
 void mutt_edit_headers (const char *editor,
-                       const char *body,
-                       HEADER *msg,
-                       char *fcc,
-                       size_t fcclen)
+                        const char *body,
+                        HEADER * msg, char *fcc, size_t fcclen)
 {
-  char path[_POSIX_PATH_MAX];  /* tempfile used to edit headers + body */
+  char path[_POSIX_PATH_MAX];   /* tempfile used to edit headers + body */
   char buffer[LONG_STRING];
   char *p;
   FILE *ifp, *ofp;
@@ -45,19 +43,17 @@ void mutt_edit_headers (const char *editor,
   LIST *cur, **last = NULL, *tmp;
 
   mutt_mktemp (path);
-  if ((ofp = safe_fopen (path, "w")) == NULL)
-  {
+  if ((ofp = safe_fopen (path, "w")) == NULL) {
     mutt_perror (path);
     return;
   }
-  
+
   mutt_env_to_local (msg->env);
   mutt_write_rfc822_header (ofp, msg->env, NULL, 1, 0);
-  fputc ('\n', ofp);   /* tie off the header. */
+  fputc ('\n', ofp);            /* tie off the header. */
 
   /* now copy the body of the message. */
-  if ((ifp = fopen (body, "r")) == NULL)
-  {
+  if ((ifp = fopen (body, "r")) == NULL) {
     mutt_perror (body);
     return;
   }
@@ -67,8 +63,7 @@ void mutt_edit_headers (const char *editor,
   fclose (ifp);
   fclose (ofp);
 
-  if (stat (path, &st) == -1)
-  {
+  if (stat (path, &st) == -1) {
     mutt_perror (path);
     return;
   }
@@ -77,9 +72,9 @@ void mutt_edit_headers (const char *editor,
 
   mutt_edit_file (editor, path);
   stat (path, &st);
-  if (mtime == st.st_mtime)
-  {
-    dprint (1, (debugfile, "ci_edit_headers(): temp file was not modified.\n"));
+  if (mtime == st.st_mtime) {
+    dprint (1,
+            (debugfile, "ci_edit_headers(): temp file was not modified.\n"));
     /* the file has not changed! */
     mutt_unlink (path);
     return;
@@ -89,20 +84,18 @@ void mutt_edit_headers (const char *editor,
   mutt_free_list (&msg->env->userhdrs);
 
   /* Read the temp file back in */
-  if ((ifp = fopen (path, "r")) == NULL)
-  {
+  if ((ifp = fopen (path, "r")) == NULL) {
     mutt_perror (path);
     return;
   }
-  
-  if ((ofp = safe_fopen (body, "w")) == NULL)
-  {
+
+  if ((ofp = safe_fopen (body, "w")) == NULL) {
     /* intentionally leak a possible temporary file here */
     fclose (ifp);
     mutt_perror (body);
     return;
   }
-  
+
   n = mutt_read_rfc822_header (ifp, NULL, 1, 0);
   while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0)
     fwrite (buffer, 1, i, ofp);
@@ -115,13 +108,14 @@ void mutt_edit_headers (const char *editor,
   msg->env->references = NULL;
 
   mutt_free_envelope (&msg->env);
-  msg->env = n; n = NULL;
+  msg->env = n;
+  n = NULL;
 
   if (!msg->env->in_reply_to)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
+    if (!option (OPTNEWSSEND))
 #endif
-    mutt_free_list (&msg->env->references);
+      mutt_free_list (&msg->env->references);
 
   mutt_expand_aliases_env (msg->env);
 
@@ -131,78 +125,67 @@ void mutt_edit_headers (const char *editor,
 
   cur = msg->env->userhdrs;
   last = &msg->env->userhdrs;
-  while (cur)
-  {
+  while (cur) {
     keep = 1;
 
     /* keep track of whether or not we see the in-reply-to field.  if we did
      * not, remove the references: field later so that we can generate a new
      * message based upon this one.
      */
-    if (fcc && ascii_strncasecmp ("fcc:", cur->data, 4) == 0)
-    {
+    if (fcc && ascii_strncasecmp ("fcc:", cur->data, 4) == 0) {
       p = cur->data + 4;
       SKIPWS (p);
-      if (*p)
-      {
-       strfcpy (fcc, p, fcclen);
-       mutt_pretty_mailbox (fcc);
+      if (*p) {
+        strfcpy (fcc, p, fcclen);
+        mutt_pretty_mailbox (fcc);
       }
       keep = 0;
     }
-    else if (ascii_strncasecmp ("attach:", cur->data, 7) == 0)
-    {
+    else if (ascii_strncasecmp ("attach:", cur->data, 7) == 0) {
       BODY *body;
       BODY *parts;
       char *q;
 
       p = cur->data + 7;
       SKIPWS (p);
-      if (*p)
-      {
-       if ((q = strpbrk (p, " \t")))
-       {
-         mutt_substrcpy (path, p, q, sizeof (path));
-         SKIPWS (q);
-       }
-       else
-         strfcpy (path, p, sizeof (path));
-       mutt_expand_path (path, sizeof (path));
-       if ((body = mutt_make_file_attach (path)))
-       {
-         body->description = safe_strdup (q);
-         for (parts = msg->content; parts->next; parts = parts->next) ;
-         parts->next = body;
-       }
-       else
-       {
-         mutt_pretty_mailbox (path);
-         mutt_error (_("%s: unable to attach file"), path);
-       }
+      if (*p) {
+        if ((q = strpbrk (p, " \t"))) {
+          mutt_substrcpy (path, p, q, sizeof (path));
+          SKIPWS (q);
+        }
+        else
+          strfcpy (path, p, sizeof (path));
+        mutt_expand_path (path, sizeof (path));
+        if ((body = mutt_make_file_attach (path))) {
+          body->description = safe_strdup (q);
+          for (parts = msg->content; parts->next; parts = parts->next);
+          parts->next = body;
+        }
+        else {
+          mutt_pretty_mailbox (path);
+          mutt_error (_("%s: unable to attach file"), path);
+        }
       }
       keep = 0;
     }
 
 
     else if ((WithCrypto & APPLICATION_PGP)
-             &&ascii_strncasecmp ("pgp:", cur->data, 4) == 0)
-    {
+             && ascii_strncasecmp ("pgp:", cur->data, 4) == 0) {
       msg->security = mutt_parse_crypt_hdr (cur->data + 4, 0);
       if (msg->security)
-       msg->security |= APPLICATION_PGP;
+        msg->security |= APPLICATION_PGP;
       keep = 0;
     }
 
-    if (keep)
-    {
+    if (keep) {
       last = &cur->next;
-      cur  = cur->next;
+      cur = cur->next;
     }
-    else
-    {
-      tmp       = cur;
-      *last     = cur->next;
-      cur       = cur->next;
+    else {
+      tmp = cur;
+      *last = cur->next;
+      cur = cur->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
     }
diff --git a/help.c b/help.c
index a4985a9..64da4c8 100644 (file)
--- a/help.c
+++ b/help.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #define HELP_C
 
@@ -36,21 +36,19 @@ static struct binding_t *help_lookupFunction (int op, int menu)
   int i;
   struct binding_t *map;
 
-  if (menu != MENU_PAGER)
-  {
+  if (menu != MENU_PAGER) {
     /* first look in the generic map for the function */
     for (i = 0; OpGeneric[i].name; i++)
       if (OpGeneric[i].op == op)
-       return (&OpGeneric[i]);    
+        return (&OpGeneric[i]);
   }
 
-  if ((map = km_get_table(menu)))
-  {
+  if ((map = km_get_table (menu))) {
     for (i = 0; map[i].name; i++)
       if (map[i].op == op)
-       return (&map[i]);
+        return (&map[i]);
   }
-  
+
   return (NULL);
 }
 
@@ -65,17 +63,15 @@ void mutt_make_help (char *d, size_t dlen, char *txt, int menu, int op)
     d[0] = 0;
 }
 
-char *
-mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items)
+char *mutt_compile_help (char *buf, size_t buflen, int menu,
+                         struct mapping_t *items)
 {
   int i;
   size_t len;
   char *pbuf = buf;
-  
-  for (i = 0; items[i].name && buflen > 2; i++)
-  {
-    if (i)
-    {
+
+  for (i = 0; items[i].name && buflen > 2; i++) {
+    if (i) {
       *pbuf++ = ' ';
       *pbuf++ = ' ';
       buflen -= 2;
@@ -88,7 +84,7 @@ mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items)
   return buf;
 }
 
-static int print_macro (FILE *f, int maxwidth, const char **macro)
+static int print_macro (FILE * f, int maxwidth, const char **macro)
 {
   int n = maxwidth;
   wchar_t wc;
@@ -99,47 +95,44 @@ static int print_macro (FILE *f, int maxwidth, const char **macro)
 
   memset (&mbstate1, 0, sizeof (mbstate1));
   memset (&mbstate2, 0, sizeof (mbstate2));
-  for (; len && (k = mbrtowc (&wc, *macro, len, &mbstate1)); *macro += k, len -= k)
-  {
-    if (k == (size_t)(-1) || k == (size_t)(-2))
-    {
-      k = (k == (size_t)(-1)) ? 1 : len;
+  for (; len && (k = mbrtowc (&wc, *macro, len, &mbstate1));
+       *macro += k, len -= k) {
+    if (k == (size_t) (-1) || k == (size_t) (-2)) {
+      k = (k == (size_t) (-1)) ? 1 : len;
       wc = replacement_char ();
     }
     /* glibc-2.1.3's wcwidth() returns 1 for unprintable chars! */
-    if (IsWPrint (wc) && (w = wcwidth (wc)) >= 0)
-    {
+    if (IsWPrint (wc) && (w = wcwidth (wc)) >= 0) {
       if (w > n)
-       break;
+        break;
       n -= w;
       {
-       char buf[MB_LEN_MAX*2];
-       size_t n1, n2;
-       if ((n1 = wcrtomb (buf, wc, &mbstate2)) != (size_t)(-1) &&
-           (n2 = wcrtomb (buf + n1, 0, &mbstate2)) != (size_t)(-1))
-         fputs (buf, f);
+        char buf[MB_LEN_MAX * 2];
+        size_t n1, n2;
+
+        if ((n1 = wcrtomb (buf, wc, &mbstate2)) != (size_t) (-1) &&
+            (n2 = wcrtomb (buf + n1, 0, &mbstate2)) != (size_t) (-1))
+          fputs (buf, f);
       }
     }
-    else if (wc < 0x20 || wc == 0x7f)
-    {
+    else if (wc < 0x20 || wc == 0x7f) {
       if (2 > n)
-       break;
+        break;
       n -= 2;
       if (wc == '\033')
-       fprintf (f, "\\e");
+        fprintf (f, "\\e");
       else if (wc == '\n')
-       fprintf (f, "\\n");
+        fprintf (f, "\\n");
       else if (wc == '\r')
-       fprintf (f, "\\r");
+        fprintf (f, "\\r");
       else if (wc == '\t')
-       fprintf (f, "\\t");
+        fprintf (f, "\\t");
       else
-       fprintf (f, "^%c", (char)((wc + '@') & 0x7f));
+        fprintf (f, "^%c", (char) ((wc + '@') & 0x7f));
     }
-    else
-    {
+    else {
       if (1 > n)
-       break;
+        break;
       n -= 1;
       fprintf (f, "?");
     }
@@ -147,13 +140,12 @@ static int print_macro (FILE *f, int maxwidth, const char **macro)
   return (maxwidth - n);
 }
 
-static int pad (FILE *f, int col, int i)
+static int pad (FILE * f, int col, int i)
 {
   char fmt[8];
 
-  if (col < i)
-  {
-    snprintf (fmt, sizeof(fmt), "%%-%ds", i - col);
+  if (col < i) {
+    snprintf (fmt, sizeof (fmt), "%%-%ds", i - col);
     fprintf (f, fmt, "");
     return (i);
   }
@@ -161,8 +153,8 @@ static int pad (FILE *f, int col, int i)
   return (col + 1);
 }
 
-static void format_line (FILE *f, int ismacro,
-                        const char *t1, const char *t2, const char *t3)
+static void format_line (FILE * f, int ismacro,
+                         const char *t1, const char *t2, const char *t3)
 {
   int col;
   int col_a, col_b;
@@ -173,31 +165,27 @@ static void format_line (FILE *f, int ismacro,
 
   /* don't try to press string into one line with less than 40 characters.
      The double paranthesis avoid a gcc warning, sigh ... */
-  if ((split = COLS < 40))
-  {
+  if ((split = COLS < 40)) {
     col_a = col = 0;
     col_b = LONG_STRING;
     fputc ('\n', f);
   }
-  else
-  {
+  else {
     col_a = COLS > 83 ? (COLS - 32) >> 2 : 12;
     col_b = COLS > 49 ? (COLS - 10) >> 1 : 19;
-    col = pad (f, mutt_strlen(t1), col_a);
+    col = pad (f, mutt_strlen (t1), col_a);
   }
 
-  if (ismacro > 0)
-  {
+  if (ismacro > 0) {
     if (!mutt_strcmp (Pager, "builtin"))
       fputs ("_\010", f);
     fputs ("M ", f);
     col += 2;
 
-    if (!split)
-    {
+    if (!split) {
       col += print_macro (f, col_b - col - 4, &t2);
       if (mutt_strlen (t2) > col_b - col)
-       t2 = "...";
+        t2 = "...";
     }
   }
 
@@ -207,47 +195,39 @@ static void format_line (FILE *f, int ismacro,
   else
     col = pad (f, col, col_b);
 
-  if (split)
-  {
+  if (split) {
     print_macro (f, LONG_STRING, &t3);
     fputc ('\n', f);
   }
-  else
-  {
-    while (*t3)
-    {
+  else {
+    while (*t3) {
       n = COLS - col;
 
-      if (ismacro >= 0)
-      {
-       SKIPWS(t3);
-
-       /* FIXME: this is completely wrong */
-       if ((n = mutt_strlen (t3)) > COLS - col)
-       {
-         n = COLS - col;
-         for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--) ;
-         if (col_a)
-           n = col_a;
-       }
+      if (ismacro >= 0) {
+        SKIPWS (t3);
+
+        /* FIXME: this is completely wrong */
+        if ((n = mutt_strlen (t3)) > COLS - col) {
+          n = COLS - col;
+          for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--);
+          if (col_a)
+            n = col_a;
+        }
       }
 
       print_macro (f, n, &t3);
 
-      if (*t3)
-      {
-        if (mutt_strcmp (Pager, "builtin"))
-       {
-         fputc ('\n', f);
-         n = 0;
-       }
-       else
-       {
-         n += col - COLS;
-         if (option (OPTMARKERS))
-           ++n;
-       }
-       col = pad (f, n, col_b);
+      if (*t3) {
+        if (mutt_strcmp (Pager, "builtin")) {
+          fputc ('\n', f);
+          n = 0;
+        }
+        else {
+          n += col - COLS;
+          if (option (OPTMARKERS))
+            ++n;
+        }
+        col = pad (f, n, col_b);
       }
     }
   }
@@ -255,31 +235,28 @@ static void format_line (FILE *f, int ismacro,
   fputc ('\n', f);
 }
 
-static void dump_menu (FILE *f, int menu)
+static void dump_menu (FILE * f, int menu)
 {
   struct keymap_t *map;
   struct binding_t *b;
   char buf[SHORT_STRING];
 
   /* browse through the keymap table */
-  for (map = Keymaps[menu]; map; map = map->next)
-  {
-    if (map->op != OP_NULL)
-    {
+  for (map = Keymaps[menu]; map; map = map->next) {
+    if (map->op != OP_NULL) {
       km_expand_key (buf, sizeof (buf), map);
 
-      if (map->op == OP_MACRO)
-      {
-       if (map->descr == NULL)
-         format_line (f, -1, buf, "macro", map->macro);
+      if (map->op == OP_MACRO) {
+        if (map->descr == NULL)
+          format_line (f, -1, buf, "macro", map->macro);
         else
-         format_line (f, 1, buf, map->macro, map->descr);
+          format_line (f, 1, buf, map->macro, map->descr);
       }
-      else
-      {
-       b = help_lookupFunction (map->op, menu);
-       format_line (f, 0, buf, b ? b->name : "UNKNOWN",
-             b ? _(HelpStrings[b->op]) : _("ERROR: please report this bug"));
+      else {
+        b = help_lookupFunction (map->op, menu);
+        format_line (f, 0, buf, b ? b->name : "UNKNOWN",
+                     b ? _(HelpStrings[b->op]) :
+                     _("ERROR: please report this bug"));
       }
     }
   }
@@ -293,17 +270,15 @@ static int is_bound (struct keymap_t *map, int op)
   return 0;
 }
 
-static void dump_unbound (FILE *f,
-                         struct binding_t *funcs,
-                         struct keymap_t *map,
-                         struct keymap_t *aux)
+static void dump_unbound (FILE * f,
+                          struct binding_t *funcs,
+                          struct keymap_t *map, struct keymap_t *aux)
 {
   int i;
 
-  for (i = 0; funcs[i].name; i++)
-  {
-    if (! is_bound (map, funcs[i].op) &&
-       (!aux || ! is_bound (aux, funcs[i].op)))
+  for (i = 0; funcs[i].name; i++) {
+    if (!is_bound (map, funcs[i].op) &&
+        (!aux || !is_bound (aux, funcs[i].op)))
       format_line (f, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]));
   }
 }
@@ -322,34 +297,31 @@ void mutt_help (int menu)
   desc = mutt_getnamebyvalue (menu, Menus);
   if (!desc)
     desc = _("<UNKNOWN>");
-  
+
   do {
-    if ((f = safe_fopen (t, "w")) == NULL)
-    {
+    if ((f = safe_fopen (t, "w")) == NULL) {
       mutt_perror (t);
       return;
     }
-  
+
     dump_menu (f, menu);
-    if (menu != MENU_EDITOR && menu != MENU_PAGER)
-    {
+    if (menu != MENU_EDITOR && menu != MENU_PAGER) {
       fputs (_("\nGeneric bindings:\n\n"), f);
       dump_menu (f, MENU_GENERIC);
     }
-  
+
     fputs (_("\nUnbound functions:\n\n"), f);
     if (funcs)
       dump_unbound (f, funcs, Keymaps[menu], NULL);
     if (menu != MENU_PAGER)
       dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
-  
+
     fclose (f);
-  
+
     snprintf (buf, sizeof (buf), _("Help for %s"), desc);
   }
   while
     (mutt_do_pager (buf, t,
-                   M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP,
-                   NULL)
+                    M_PAGER_RETWINCH | M_PAGER_MARKER | M_PAGER_NSKIP, NULL)
      == OP_REFORMAT_WINCH);
 }
index 5f33569..1464345 100644 (file)
--- a/history.c
+++ b/history.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 
 /* global vars used for the string-history routines */
 
-struct history
-{
+struct history {
   char **hist;
   short cur;
   short last;
-}; 
+};
 
 static struct history History[HC_LAST];
 static int OldSize = 0;
@@ -39,65 +38,62 @@ static void init_history (struct history *h)
 {
   int i;
 
-  if(OldSize)
-  {
-    if (h->hist)
-    {
-      for (i = 0 ; i < OldSize ; i ++)
-       FREE (&h->hist[i]);
+  if (OldSize) {
+    if (h->hist) {
+      for (i = 0; i < OldSize; i++)
+        FREE (&h->hist[i]);
       FREE (&h->hist);
     }
   }
-  
+
   if (HistSize)
     h->hist = safe_calloc (HistSize, sizeof (char *));
-  
+
   h->cur = 0;
   h->last = 0;
 }
 
-void mutt_init_history(void)
+void mutt_init_history (void)
 {
   history_class_t hclass;
-  
+
   if (HistSize == OldSize)
     return;
-  
-  for(hclass = HC_FIRST; hclass < HC_LAST; hclass++)
-    init_history(&History[hclass]);
+
+  for (hclass = HC_FIRST; hclass < HC_LAST; hclass++)
+    init_history (&History[hclass]);
 
   OldSize = HistSize;
 }
-  
+
 void mutt_history_add (history_class_t hclass, const char *s)
 {
   int prev;
   struct history *h = &History[hclass];
-  
+
   if (!HistSize)
-    return; /* disabled */
+    return;                     /* disabled */
 
-  if (*s)
-  {
+  if (*s) {
     prev = h->last - 1;
-    if (prev < 0) prev = HistSize - 1;
-    if (!h->hist[prev] || mutt_strcmp (h->hist[prev], s) != 0)
-    {
+    if (prev < 0)
+      prev = HistSize - 1;
+    if (!h->hist[prev] || mutt_strcmp (h->hist[prev], s) != 0) {
       mutt_str_replace (&h->hist[h->last++], s);
       if (h->last > HistSize - 1)
-       h->last = 0;
+        h->last = 0;
     }
   }
-  h->cur = h->last; /* reset to the last entry */
+  h->cur = h->last;             /* reset to the last entry */
 }
 
 char *mutt_history_next (history_class_t hclass)
 {
   int next;
   struct history *h = &History[hclass];
-  
+
   if (!HistSize)
-    return (""); /* disabled */
+    return ("");                /* disabled */
 
   next = h->cur + 1;
   if (next > HistSize - 1)
@@ -112,11 +108,10 @@ char *mutt_history_prev (history_class_t hclass)
   struct history *h = &History[hclass];
 
   if (!HistSize)
-    return (""); /* disabled */
+    return ("");                /* disabled */
 
   prev = h->cur - 1;
-  if (prev < 0)
-  {
+  if (prev < 0) {
     prev = HistSize - 1;
     while (prev > 0 && h->hist[prev] == NULL)
       prev--;
index b32a47a..291613d 100644 (file)
--- a/history.h
+++ b/history.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _HISTORY_H
 #define _HISTORY_H
 
-enum history_class
-{
+enum history_class {
   HC_CMD,
   HC_ALIAS,
   HC_COMMAND,
@@ -34,9 +33,9 @@ enum history_class
 
 typedef enum history_class history_class_t;
 
-void mutt_init_history(void);
-void mutt_history_add(history_class_t, const char *);
-char *mutt_history_next(history_class_t);
-char *mutt_history_prev(history_class_t);
+void mutt_init_history (void);
+void mutt_history_add (history_class_t, const char *);
+char *mutt_history_next (history_class_t);
+char *mutt_history_prev (history_class_t);
 
 #endif
diff --git a/hook.c b/hook.c
index 74b2f5d..f3853a9 100644 (file)
--- a/hook.c
+++ b/hook.c
 #include <ctype.h>
 #include <unistd.h>
 
-typedef struct hook
-{
-  int type;            /* hook type */
-  REGEXP rx;           /* regular expression */
-  char *command;       /* filename, command or pattern to execute */
-  pattern_t *pattern;  /* used for fcc,save,send-hook */
+typedef struct hook {
+  int type;                     /* hook type */
+  REGEXP rx;                    /* regular expression */
+  char *command;                /* filename, command or pattern to execute */
+  pattern_t *pattern;           /* used for fcc,save,send-hook */
   struct hook *next;
 } HOOK;
 
@@ -47,7 +46,8 @@ static HOOK *Hooks = NULL;
 
 static int current_hook_type = 0;
 
-int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_hook (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err)
 {
   HOOK *ptr;
   BUFFER command, pattern;
@@ -59,8 +59,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   memset (&pattern, 0, sizeof (pattern));
   memset (&command, 0, sizeof (command));
 
-  if (*s->dptr == '!')
-  {
+  if (*s->dptr == '!') {
     s->dptr++;
     SKIPWS (s->dptr);
     not = 1;
@@ -68,28 +67,27 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 
   mutt_extract_token (&pattern, s, 0);
 
-  if (!MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("too few arguments"), err->dsize);
     goto error;
   }
 
-  mutt_extract_token (&command, s, (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_ACCOUNTHOOK | M_REPLYHOOK)) ?  M_TOKEN_SPACE : 0);
+  mutt_extract_token (&command, s,
+                      (data &
+                       (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK |
+                        M_ACCOUNTHOOK | M_REPLYHOOK)) ? M_TOKEN_SPACE : 0);
 
-  if (!command.data)
-  {
+  if (!command.data) {
     strfcpy (err->data, _("too few arguments"), err->dsize);
     goto error;
   }
 
-  if (MoreArgs (s))
-  {
+  if (MoreArgs (s)) {
     strfcpy (err->data, _("too many arguments"), err->dsize);
     goto error;
   }
 
-  if (data & (M_FOLDERHOOK | M_MBOXHOOK))
-  {
+  if (data & (M_FOLDERHOOK | M_MBOXHOOK)) {
     strfcpy (path, pattern.data, sizeof (path));
     _mutt_expand_path (path, sizeof (path), 1);
     FREE (&pattern.data);
@@ -97,10 +95,8 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
     pattern.data = safe_strdup (path);
   }
 #ifdef USE_COMPRESSED
-  else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK))
-  {
-    if (mutt_test_compress_command (command.data))
-    {
+  else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) {
+    if (mutt_test_compress_command (command.data)) {
       strfcpy (err->data, _("bad formatted command string"), err->dsize);
       return (-1);
     }
@@ -108,8 +104,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 #endif
   else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
            && (!WithCrypto || !(data & M_CRYPTHOOK))
-      )
-  {
+    ) {
     char tmp[HUGE_STRING];
 
     strfcpy (tmp, pattern.data, sizeof (tmp));
@@ -119,8 +114,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
     pattern.data = safe_strdup (tmp);
   }
 
-  if (data & (M_MBOXHOOK | M_SAVEHOOK | M_FCCHOOK))
-  {
+  if (data & (M_MBOXHOOK | M_SAVEHOOK | M_FCCHOOK)) {
     strfcpy (path, command.data, sizeof (path));
     mutt_expand_path (path, sizeof (path));
     FREE (&command.data);
@@ -129,55 +123,58 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   }
 
   /* check to make sure that a matching hook doesn't already exist */
-  for (ptr = Hooks; ptr; ptr = ptr->next)
-  {
+  for (ptr = Hooks; ptr; ptr = ptr->next) {
     if (ptr->type == data &&
-       ptr->rx.not == not &&
-       !mutt_strcmp (pattern.data, ptr->rx.pattern))
-    {
-      if (data & (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK | M_ACCOUNTHOOK | M_REPLYHOOK))
-      {
-       /* these hooks allow multiple commands with the same
-        * pattern, so if we've already seen this pattern/command pair, just
-        * ignore it instead of creating a duplicate */
-       if (!mutt_strcmp (ptr->command, command.data))
-       {
-         FREE (&command.data);
-         FREE (&pattern.data);
-         return 0;
-       }
+        ptr->rx.not == not && !mutt_strcmp (pattern.data, ptr->rx.pattern)) {
+      if (data &
+          (M_FOLDERHOOK | M_SENDHOOK | M_SEND2HOOK | M_MESSAGEHOOK |
+           M_ACCOUNTHOOK | M_REPLYHOOK)) {
+        /* these hooks allow multiple commands with the same
+         * pattern, so if we've already seen this pattern/command pair, just
+         * ignore it instead of creating a duplicate */
+        if (!mutt_strcmp (ptr->command, command.data)) {
+          FREE (&command.data);
+          FREE (&pattern.data);
+          return 0;
+        }
       }
-      else
-      {
-       /* other hooks only allow one command per pattern, so update the
-        * entry with the new command.  this currently does not change the
-        * order of execution of the hooks, which i think is desirable since
-        * a common action to perform is to change the default (.) entry
-        * based upon some other information. */
-       FREE (&ptr->command);
-       ptr->command = command.data;
-       FREE (&pattern.data);
-       return 0;
+      else {
+        /* other hooks only allow one command per pattern, so update the
+         * entry with the new command.  this currently does not change the
+         * order of execution of the hooks, which i think is desirable since
+         * a common action to perform is to change the default (.) entry
+         * based upon some other information. */
+        FREE (&ptr->command);
+        ptr->command = command.data;
+        FREE (&pattern.data);
+        return 0;
       }
     }
     if (!ptr->next)
       break;
   }
 
-  if (data & (M_SENDHOOK | M_SEND2HOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK | M_REPLYHOOK))
-  {
-    if ((pat = mutt_pattern_comp (pattern.data,
-          (data & (M_SENDHOOK | M_SEND2HOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG,
-                                 err)) == NULL)
+  if (data &
+      (M_SENDHOOK | M_SEND2HOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK |
+       M_REPLYHOOK)) {
+    if ((pat =
+         mutt_pattern_comp (pattern.data,
+                            (data & (M_SENDHOOK | M_SEND2HOOK | M_FCCHOOK)) ?
+                            0 : M_FULL_MSG, err)) == NULL)
       goto error;
   }
-  else
-  {
+  else {
     rx = safe_malloc (sizeof (regex_t));
 #ifdef M_CRYPTHOOK
-    if ((rc = REGCOMP (rx, NONULL(pattern.data), ((data & (M_CRYPTHOOK|M_CHARSETHOOK)) ? REG_ICASE : 0))) != 0)
+    if ((rc =
+         REGCOMP (rx, NONULL (pattern.data),
+                  ((data & (M_CRYPTHOOK | M_CHARSETHOOK)) ? REG_ICASE : 0)))
+        != 0)
 #else
-    if ((rc = REGCOMP (rx, NONULL(pattern.data), (data & (M_CHARSETHOOK|M_ICONVHOOK)) ? REG_ICASE : 0)) != 0)
+    if ((rc =
+         REGCOMP (rx, NONULL (pattern.data),
+                  (data & (M_CHARSETHOOK | M_ICONVHOOK)) ? REG_ICASE : 0)) !=
+        0)
 #endif /* M_CRYPTHOOK */
     {
       regerror (rc, rx, err->data, err->dsize);
@@ -187,8 +184,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
     }
   }
 
-  if (ptr)
-  {
+  if (ptr) {
     ptr->next = safe_calloc (1, sizeof (HOOK));
     ptr = ptr->next;
   }
@@ -208,12 +204,11 @@ error:
   return (-1);
 }
 
-static void delete_hook (HOOK *h)
+static void delete_hook (HOOK * h)
 {
   FREE (&h->command);
   FREE (&h->rx.pattern);
-  if (h->rx.rx)
-  {
+  if (h->rx.rx) {
     regfree (h->rx.rx);
   }
   mutt_pattern_free (&h->pattern);
@@ -226,18 +221,15 @@ static void delete_hooks (int type)
   HOOK *h;
   HOOK *prev;
 
-  while (h = Hooks, h && (type == 0 || type == h->type))
-  {
+  while (h = Hooks, h && (type == 0 || type == h->type)) {
     Hooks = h->next;
     delete_hook (h);
   }
 
-  prev = h; /* Unused assignment to avoid compiler warnings */
+  prev = h;                     /* Unused assignment to avoid compiler warnings */
 
-  while (h)
-  {
-    if (type == h->type)
-    {
+  while (h) {
+    if (type == h->type) {
       prev->next = h->next;
       delete_hook (h);
     }
@@ -247,36 +239,32 @@ static void delete_hooks (int type)
   }
 }
 
-int mutt_parse_unhook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_unhook (BUFFER * buf, BUFFER * s, unsigned long data,
+                       BUFFER * err)
 {
-  while (MoreArgs (s))
-  {
+  while (MoreArgs (s)) {
     mutt_extract_token (buf, s, 0);
-    if (mutt_strcmp ("*", buf->data) == 0)
-    {
-      if (current_hook_type)
-      {
-       snprintf (err->data, err->dsize,
-                 _("unhook: Can't do unhook * from within a hook."));
-       return -1;
+    if (mutt_strcmp ("*", buf->data) == 0) {
+      if (current_hook_type) {
+        snprintf (err->data, err->dsize,
+                  _("unhook: Can't do unhook * from within a hook."));
+        return -1;
       }
       delete_hooks (0);
     }
-    else
-    {
+    else {
       int type = mutt_get_hook_type (buf->data);
 
-      if (!type)
-      {
-       snprintf (err->data, err->dsize,
-                _("unhook: unknown hook type: %s"), buf->data);
-       return (-1);
+      if (!type) {
+        snprintf (err->data, err->dsize,
+                  _("unhook: unknown hook type: %s"), buf->data);
+        return (-1);
       }
-      if (current_hook_type == type)
-      {
-       snprintf (err->data, err->dsize, _("unhook: Can't delete a %s from within a %s."),
-                 buf->data, buf->data);
-       return -1;
+      if (current_hook_type == type) {
+        snprintf (err->data, err->dsize,
+                  _("unhook: Can't delete a %s from within a %s."), buf->data,
+                  buf->data);
+        return -1;
       }
       delete_hooks (type);
     }
@@ -291,32 +279,28 @@ void mutt_folder_hook (char *path)
   char buf[STRING];
 
   current_hook_type = M_FOLDERHOOK;
-  
+
   err.data = buf;
   err.dsize = sizeof (buf);
   memset (&token, 0, sizeof (token));
-  for (; tmp; tmp = tmp->next)
-  {
-    if(!tmp->command)
+  for (; tmp; tmp = tmp->next) {
+    if (!tmp->command)
       continue;
 
-    if (tmp->type & M_FOLDERHOOK)
-    {
-      if ((regexec (tmp->rx.rx, path, 0, NULL, 0) == 0) ^ tmp->rx.not)
-      {
-       if (mutt_parse_rc_line (tmp->command, &token, &err) == -1)
-       {
-         mutt_error ("%s", err.data);
-         FREE (&token.data);
-         mutt_sleep (1);       /* pause a moment to let the user see the error */
-         current_hook_type = 0;
-         return;
-       }
+    if (tmp->type & M_FOLDERHOOK) {
+      if ((regexec (tmp->rx.rx, path, 0, NULL, 0) == 0) ^ tmp->rx.not) {
+        if (mutt_parse_rc_line (tmp->command, &token, &err) == -1) {
+          mutt_error ("%s", err.data);
+          FREE (&token.data);
+          mutt_sleep (1);       /* pause a moment to let the user see the error */
+          current_hook_type = 0;
+          return;
+        }
       }
     }
   }
   FREE (&token.data);
-  
+
   current_hook_type = 0;
 }
 
@@ -325,72 +309,67 @@ char *mutt_find_hook (int type, const char *pat)
   HOOK *tmp = Hooks;
 
   for (; tmp; tmp = tmp->next)
-    if (tmp->type & type)
-    {
+    if (tmp->type & type) {
       if (regexec (tmp->rx.rx, pat, 0, NULL, 0) == 0)
-       return (tmp->command);
+        return (tmp->command);
     }
   return (NULL);
 }
 
-void mutt_message_hook (CONTEXT *ctx, HEADER *hdr, int type)
+void mutt_message_hook (CONTEXT * ctx, HEADER * hdr, int type)
 {
   BUFFER err, token;
   HOOK *hook;
   char buf[STRING];
 
   current_hook_type = type;
-  
+
   err.data = buf;
   err.dsize = sizeof (buf);
   memset (&token, 0, sizeof (token));
-  for (hook = Hooks; hook; hook = hook->next)
-  {
-    if(!hook->command)
+  for (hook = Hooks; hook; hook = hook->next) {
+    if (!hook->command)
       continue;
 
     if (hook->type & type)
       if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not)
-       if (mutt_parse_rc_line (hook->command, &token, &err) != 0)
-       {
-         FREE (&token.data);
-         mutt_error ("%s", err.data);
-         mutt_sleep (1);
-         current_hook_type = 0;
-         return;
-       }
+        if (mutt_parse_rc_line (hook->command, &token, &err) != 0) {
+          FREE (&token.data);
+          mutt_error ("%s", err.data);
+          mutt_sleep (1);
+          current_hook_type = 0;
+          return;
+        }
   }
   FREE (&token.data);
   current_hook_type = 0;
 }
 
 static int
-mutt_addr_hook (char *path, size_t pathlen, int type, CONTEXT *ctx, HEADER *hdr)
+mutt_addr_hook (char *path, size_t pathlen, int type, CONTEXT * ctx,
+                HEADER * hdr)
 {
   HOOK *hook;
 
   /* determine if a matching hook exists */
-  for (hook = Hooks; hook; hook = hook->next)
-  {
-    if(!hook->command)
+  for (hook = Hooks; hook; hook = hook->next) {
+    if (!hook->command)
       continue;
 
     if (hook->type & type)
-      if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not)
-      {
-       mutt_make_string (path, pathlen, hook->command, ctx, hdr);
-       return 0;
+      if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not) {
+        mutt_make_string (path, pathlen, hook->command, ctx, hdr);
+        return 0;
       }
   }
 
   return -1;
 }
 
-void mutt_default_save (char *path, size_t pathlen, HEADER *hdr)
+void mutt_default_save (char *path, size_t pathlen, HEADER * hdr)
 {
   *path = 0;
-  if (mutt_addr_hook (path, pathlen, M_SAVEHOOK, Context, hdr) != 0)
-  {
+  if (mutt_addr_hook (path, pathlen, M_SAVEHOOK, Context, hdr) != 0) {
     char tmp[_POSIX_PATH_MAX];
     ADDRESS *adr;
     ENVELOPE *env = hdr->env;
@@ -406,30 +385,27 @@ void mutt_default_save (char *path, size_t pathlen, HEADER *hdr)
       adr = env->cc;
     else
       adr = NULL;
-    if (adr)
-    {
+    if (adr) {
       mutt_safe_path (tmp, sizeof (tmp), adr);
       snprintf (path, pathlen, "=%s", tmp);
     }
   }
 }
 
-void mutt_select_fcc (char *path, size_t pathlen, HEADER *hdr)
+void mutt_select_fcc (char *path, size_t pathlen, HEADER * hdr)
 {
   ADDRESS *adr;
   char buf[_POSIX_PATH_MAX];
   ENVELOPE *env = hdr->env;
 
-  if (mutt_addr_hook (path, pathlen, M_FCCHOOK, NULL, hdr) != 0)
-  {
+  if (mutt_addr_hook (path, pathlen, M_FCCHOOK, NULL, hdr) != 0) {
     if ((option (OPTSAVENAME) || option (OPTFORCENAME)) &&
-       (env->to || env->cc || env->bcc))
-    {
+        (env->to || env->cc || env->bcc)) {
       adr = env->to ? env->to : (env->cc ? env->cc : env->bcc);
       mutt_safe_path (buf, sizeof (buf), adr);
-      mutt_concat_path (path, NONULL(Maildir), buf, pathlen);
+      mutt_concat_path (path, NONULL (Maildir), buf, pathlen);
       if (!option (OPTFORCENAME) && mx_access (path, W_OK) != 0)
-       strfcpy (path, NONULL (Outbox), pathlen);
+        strfcpy (path, NONULL (Outbox), pathlen);
     }
     else
       strfcpy (path, NONULL (Outbox), pathlen);
@@ -441,10 +417,10 @@ static char *_mutt_string_hook (const char *match, int hook)
 {
   HOOK *tmp = Hooks;
 
-  for (; tmp; tmp = tmp->next)
-  {
+  for (; tmp; tmp = tmp->next) {
     if ((tmp->type & hook) && ((match &&
-        regexec (tmp->rx.rx, match, 0, NULL, 0) == 0) ^ tmp->rx.not))
+                                regexec (tmp->rx.rx, match, 0, NULL,
+                                         0) == 0) ^ tmp->rx.not))
       return (tmp->command);
   }
   return (NULL);
@@ -460,15 +436,15 @@ char *mutt_iconv_hook (const char *chs)
   return _mutt_string_hook (chs, M_ICONVHOOK);
 }
 
-char *mutt_crypt_hook (ADDRESS *adr)
+char *mutt_crypt_hook (ADDRESS * adr)
 {
   return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
 }
 
 #ifdef USE_SOCKET
-void mutt_account_hook (const charurl)
+void mutt_account_hook (const char *url)
 {
-  HOOKhook;
+  HOOK *hook;
   BUFFER token;
   BUFFER err;
   char buf[STRING];
@@ -477,20 +453,17 @@ void mutt_account_hook (const char* url)
   err.dsize = sizeof (buf);
   memset (&token, 0, sizeof (token));
 
-  for (hook = Hooks; hook; hook = hook->next)
-  {
-    if (! (hook->command && (hook->type & M_ACCOUNTHOOK)))
+  for (hook = Hooks; hook; hook = hook->next) {
+    if (!(hook->command && (hook->type & M_ACCOUNTHOOK)))
       continue;
 
-    if ((regexec (hook->rx.rx, url, 0, NULL, 0) == 0) ^ hook->rx.not)
-    {
-      if (mutt_parse_rc_line (hook->command, &token, &err) == -1)
-      {
-       FREE (&token.data);
-       mutt_error ("%s", err.data);
-       mutt_sleep (1);
+    if ((regexec (hook->rx.rx, url, 0, NULL, 0) == 0) ^ hook->rx.not) {
+      if (mutt_parse_rc_line (hook->command, &token, &err) == -1) {
+        FREE (&token.data);
+        mutt_error ("%s", err.data);
+        mutt_sleep (1);
 
-       return;
+        return;
       }
     }
   }
index e26d275..d0a061f 100644 (file)
@@ -1,8 +1,6 @@
-# Makefile.in generated by automake 1.7.6 from Makefile.am.
-# @configure_input@
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-@SET_MAKE@
+
+SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+
 top_builddir = ..
 
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
 INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+host_alias = @host_alias@
 host_triplet = @host@
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
-
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BUILD_IMAP_FALSE = @BUILD_IMAP_FALSE@
-BUILD_IMAP_TRUE = @BUILD_IMAP_TRUE@
 BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
 CATALOGS = @CATALOGS@
 CATOBJEXT = @CATOBJEXT@
 CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
 CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
 DBX = @DBX@
 DEBUGGER = @DEBUGGER@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
 DOTLOCK_GROUP = @DOTLOCK_GROUP@
 DOTLOCK_PERMISSION = @DOTLOCK_PERMISSION@
 DOTLOCK_TARGET = @DOTLOCK_TARGET@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
 GDB = @GDB@
 GENCAT = @GENCAT@
 GLIBC21 = @GLIBC21@
 GMOFILES = @GMOFILES@
 GMSGFMT = @GMSGFMT@
 GPGME_CONFIG = @GPGME_CONFIG@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+HAVE_LIB = @HAVE_LIB@
 INSTOBJEXT = @INSTOBJEXT@
 INTLBISON = @INTLBISON@
 INTLLIBS = @INTLLIBS@
@@ -88,7 +84,7 @@ INTLOBJS = @INTLOBJS@
 INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
 ISPELL = @ISPELL@
 KRB5CFGPATH = @KRB5CFGPATH@
-LDFLAGS = @LDFLAGS@
+LIB = @LIB@
 LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
 LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
 LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
@@ -97,90 +93,39 @@ LIBGPGME_LIBS = @LIBGPGME_LIBS@
 LIBICONV = @LIBICONV@
 LIBIMAP = @LIBIMAP@
 LIBIMAPDEPS = @LIBIMAPDEPS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LTLIBOBJS = @LTLIBOBJS@
+LTLIB = @LTLIB@
 MAKEINFO = @MAKEINFO@
 MKINSTALLDIRS = @MKINSTALLDIRS@
 MSGFMT = @MSGFMT@
 MUTTLIBS = @MUTTLIBS@
 MUTT_LIB_OBJECTS = @MUTT_LIB_OBJECTS@
-OBJEXT = @OBJEXT@
 OPS = @OPS@
 PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
 PGPAUX_TARGET = @PGPAUX_TARGET@
 POFILES = @POFILES@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SDB = @SDB@
 SENDMAIL = @SENDMAIL@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
+SGML2HTML_CMD = @SGML2HTML_CMD@
+SGML2PS_CMD = @SGML2PS_CMD@
+SGML2TXT_CMD = @SGML2TXT_CMD@
 SMIMEAUX_TARGET = @SMIMEAUX_TARGET@
-STRIP = @STRIP@
 SUBVERSION = @SUBVERSION@
 U = @U@
-USE_GSS_FALSE = @USE_GSS_FALSE@
-USE_GSS_TRUE = @USE_GSS_TRUE@
 USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 USE_NLS = @USE_NLS@
-USE_SASL_FALSE = @USE_SASL_FALSE@
-USE_SASL_TRUE = @USE_SASL_TRUE@
-USE_SSL_FALSE = @USE_SSL_FALSE@
-USE_SSL_TRUE = @USE_SSL_TRUE@
 VERSION = @VERSION@
-XGETTEXT = @XGETTEXT@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
 docdir = @docdir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
 mutt_libesmtp_config_path = @mutt_libesmtp_config_path@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
+
+AR = @AR@
 
 AUTOMAKE_OPTIONS = foreign
 
 @USE_GSS_TRUE@GSSSOURCES = auth_gss.c
-@USE_SASL_FALSE@AUTHENTICATORS = auth_anon.c auth_cram.c
-
 @USE_SASL_TRUE@AUTHENTICATORS = auth_sasl.c
+@USE_SASL_FALSE@AUTHENTICATORS = auth_anon.c auth_cram.c
 
 EXTRA_DIST = BUGS README TODO auth_anon.c auth_cram.c auth_gss.c auth_sasl.c
 
@@ -189,241 +134,205 @@ INCLUDES = -I$(top_srcdir) -I../intl
 noinst_LIBRARIES = libimap.a
 noinst_HEADERS = auth.h imap_private.h message.h
 
-libimap_a_SOURCES = auth.c auth_login.c browse.c command.c imap.c imap.h \
-       message.c utf7.c util.c $(AUTHENTICATORS) $(GSSSOURCES)
+libimap_a_SOURCES = auth.c auth_login.c browse.c command.c imap.c imap.h       message.c utf7.c util.c $(AUTHENTICATORS) $(GSSSOURCES)
 
-subdir = imap
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-LIBRARIES = $(noinst_LIBRARIES)
-
-libimap_a_AR = $(AR) cru
-libimap_a_LIBADD =
-am__libimap_a_SOURCES_DIST = auth.c auth_login.c browse.c command.c \
-       imap.c imap.h message.c utf7.c util.c auth_anon.c auth_cram.c \
-       auth_sasl.c auth_gss.c
-@USE_SASL_TRUE@am__objects_1 = auth_sasl.$(OBJEXT)
-@USE_SASL_FALSE@am__objects_1 = auth_anon.$(OBJEXT) auth_cram.$(OBJEXT)
-@USE_GSS_TRUE@am__objects_2 = auth_gss.$(OBJEXT)
-am_libimap_a_OBJECTS = auth.$(OBJEXT) auth_login.$(OBJEXT) \
-       browse.$(OBJEXT) command.$(OBJEXT) imap.$(OBJEXT) \
-       message.$(OBJEXT) utf7.$(OBJEXT) util.$(OBJEXT) \
-       $(am__objects_1) $(am__objects_2)
-libimap_a_OBJECTS = $(am_libimap_a_OBJECTS)
-
-DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
-depcomp =
-am__depfiles_maybe =
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES = 
+LIBRARIES =  $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+libimap_a_LIBADD = 
+@USE_GSS_TRUE@@USE_SASL_FALSE@libimap_a_OBJECTS =  auth.o auth_login.o \
+@USE_GSS_TRUE@@USE_SASL_FALSE@browse.o command.o imap.o message.o \
+@USE_GSS_TRUE@@USE_SASL_FALSE@utf7.o util.o auth_anon.o auth_cram.o \
+@USE_GSS_TRUE@@USE_SASL_FALSE@auth_gss.o
+@USE_GSS_FALSE@@USE_SASL_TRUE@libimap_a_OBJECTS =  auth.o auth_login.o \
+@USE_GSS_FALSE@@USE_SASL_TRUE@browse.o command.o imap.o message.o \
+@USE_GSS_FALSE@@USE_SASL_TRUE@utf7.o util.o auth_sasl.o
+@USE_GSS_TRUE@@USE_SASL_TRUE@libimap_a_OBJECTS =  auth.o auth_login.o \
+@USE_GSS_TRUE@@USE_SASL_TRUE@browse.o command.o imap.o message.o utf7.o \
+@USE_GSS_TRUE@@USE_SASL_TRUE@util.o auth_sasl.o auth_gss.o
+@USE_GSS_FALSE@@USE_SASL_FALSE@libimap_a_OBJECTS =  auth.o auth_login.o \
+@USE_GSS_FALSE@@USE_SASL_FALSE@browse.o command.o imap.o message.o \
+@USE_GSS_FALSE@@USE_SASL_FALSE@utf7.o util.o auth_anon.o auth_cram.o
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DIST_SOURCES = $(am__libimap_a_SOURCES_DIST)
-HEADERS = $(noinst_HEADERS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS =  $(noinst_HEADERS)
+
+DIST_COMMON =  README Makefile.am Makefile.in TODO
 
-DIST_COMMON = README $(noinst_HEADERS) Makefile.am Makefile.in TODO
-SOURCES = $(libimap_a_SOURCES)
 
-all: all-am
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
+TAR = tar
+GZIP_ENV = --best
+SOURCES = $(libimap_a_SOURCES)
+OBJECTS = $(libimap_a_OBJECTS)
+
+all: all-redirect
 .SUFFIXES:
-.SUFFIXES: .c .o .obj
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
-       cd $(top_srcdir) && \
-         $(AUTOMAKE) --foreign  --ignore-deps imap/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
-       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+       cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps imap/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLIBRARIES:
 
 clean-noinstLIBRARIES:
        -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
-libimap.a: $(libimap_a_OBJECTS) $(libimap_a_DEPENDENCIES) 
-       -rm -f libimap.a
-       $(libimap_a_AR) libimap.a $(libimap_a_OBJECTS) $(libimap_a_LIBADD)
-       $(RANLIB) libimap.a
 
-mostlyclean-compile:
-       -rm -f *.$(OBJEXT) core *.core
+distclean-noinstLIBRARIES:
 
-distclean-compile:
-       -rm -f *.tab.c
+maintainer-clean-noinstLIBRARIES:
 
 .c.o:
-       $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+       $(COMPILE) -c $<
+
+.s.o:
+       $(COMPILE) -c $<
 
-.c.obj:
-       $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
-uninstall-info-am:
+.S.o:
+       $(COMPILE) -c $<
 
-ETAGS = etags
-ETAGSFLAGS =
+mostlyclean-compile:
+       -rm -f *.o core *.core
 
-CTAGS = ctags
-CTAGSFLAGS =
+clean-compile:
+
+distclean-compile:
+       -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+libimap.a: $(libimap_a_OBJECTS) $(libimap_a_DEPENDENCIES)
+       -rm -f libimap.a
+       $(AR) cru libimap.a $(libimap_a_OBJECTS) $(libimap_a_LIBADD)
+       $(RANLIB) libimap.a
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP)
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       mkid -fID $$unique
+       here=`pwd` && cd $(srcdir) \
+         && mkid -f$$here/ID $$unique $(LISP)
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
        tags=; \
        here=`pwd`; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
               END { for (i in files) print i; }'`; \
-       test -z "$(ETAGS_ARGS)$$tags$$unique" \
-         || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-            $$tags $$unique
+       test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+         || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
 
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
-       tags=; \
-       here=`pwd`; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '    { files[$$0] = 1; } \
-              END { for (i in files) print i; }'`; \
-       test -z "$(CTAGS_ARGS)$$tags$$unique" \
-         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-            $$tags $$unique
+mostlyclean-tags:
 
-GTAGS:
-       here=`$(am__cd) $(top_builddir) && pwd` \
-         && cd $(top_srcdir) \
-         && gtags -i $(GTAGS_ARGS) $$here
+clean-tags:
 
 distclean-tags:
-       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+       -rm -f TAGS ID
+
+maintainer-clean-tags:
 
-top_distdir = ..
-distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = imap
 
 distdir: $(DISTFILES)
-       @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-       list='$(DISTFILES)'; for file in $$list; do \
-         case $$file in \
-           $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-           $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-         esac; \
-         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-           dir="/$$dir"; \
-           $(mkinstalldirs) "$(distdir)$$dir"; \
-         else \
-           dir=''; \
-         fi; \
+       @for file in $(DISTFILES); do \
+         d=$(srcdir); \
          if test -d $$d/$$file; then \
-           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-           fi; \
-           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+           cp -pr $$d/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
-           || cp -p $$d/$$file $(distdir)/$$file \
-           || exit 1; \
+           || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+           || cp -p $$d/$$file $(distdir)/$$file || :; \
          fi; \
        done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
 check-am: all-am
 check: check-am
-all-am: Makefile $(LIBRARIES) $(HEADERS)
-
-installdirs:
-install: install-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
 install-exec: install-exec-am
+
+install-data-am:
 install-data: install-data-am
-uninstall: uninstall-am
 
 install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LIBRARIES) $(HEADERS)
+all-redirect: all-am
 install-strip:
-       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         INSTALL_STRIP_FLAG=-s \
-         `test -z '$(STRIP)' || \
-           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+       $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
        -rm -f Makefile $(CONFIG_CLEAN_FILES)
+       -rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-       @echo "This command is intended for maintainers to use"
-       @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
-
-distclean: distclean-am
-
-distclean-am: clean-am distclean-compile distclean-generic \
-       distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
+mostlyclean-am:  mostlyclean-noinstLIBRARIES mostlyclean-compile \
+               mostlyclean-tags mostlyclean-generic
 
-info: info-am
-
-info-am:
+mostlyclean: mostlyclean-am
 
-install-data-am:
+clean-am:  clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
+               mostlyclean-am
 
-install-exec-am:
+clean: clean-am
 
-install-info: install-info-am
+distclean-am:  distclean-noinstLIBRARIES distclean-compile \
+               distclean-tags distclean-generic clean-am
 
-install-man:
+distclean: distclean-am
 
-installcheck-am:
+maintainer-clean-am:  maintainer-clean-noinstLIBRARIES \
+               maintainer-clean-compile maintainer-clean-tags \
+               maintainer-clean-generic distclean-am
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
 
 maintainer-clean: maintainer-clean-am
 
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-info-am
+.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
+check-am installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-       clean-noinstLIBRARIES ctags distclean distclean-compile \
-       distclean-generic distclean-tags distdir dvi dvi-am info \
-       info-am install install-am install-data install-data-am \
-       install-exec install-exec-am install-info install-info-am \
-       install-man install-strip installcheck installcheck-am \
-       installdirs maintainer-clean maintainer-clean-generic \
-       mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
-       ps ps-am tags uninstall uninstall-am uninstall-info-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
index d52f86f..4e30c9c 100644 (file)
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* IMAP login/authentication code */
 
 
 static imap_auth_t imap_authenticators[] = {
 #ifdef USE_SASL
-  { imap_auth_sasl, NULL },
+  {imap_auth_sasl, NULL},
 #else
-  { imap_auth_anon, "anonymous" },
+  {imap_auth_anon, "anonymous"},
 #endif
 #ifdef USE_GSS
-  { imap_auth_gss, "gssapi" },
+  {imap_auth_gss, "gssapi"},
 #endif
   /* SASL includes CRAM-MD5 (and GSSAPI, but that's not enabled by default) */
 #ifndef USE_SASL
-  { imap_auth_cram_md5, "cram-md5" },
+  {imap_auth_cram_md5, "cram-md5"},
 #endif
-  { imap_auth_login, "login" },
+  {imap_auth_login, "login"},
 
-  { NULL }
+  {NULL}
 };
 
 /* imap_authenticate: Attempt to authenticate using either user-specified
  *   authentication method if specified, or any. */
-int imap_authenticate (IMAP_DATA* idata)
+int imap_authenticate (IMAP_DATA * idata)
 {
-  imap_auth_tauthenticator;
-  charmethods;
-  charmethod;
-  chardelim;
+  imap_auth_t *authenticator;
+  char *methods;
+  char *method;
+  char *delim;
   int r = -1;
 
-  if (ImapAuthenticators && *ImapAuthenticators)
-  {
+  if (ImapAuthenticators && *ImapAuthenticators) {
     /* Try user-specified list of authentication methods */
     methods = safe_strdup (ImapAuthenticators);
 
-    for (method = methods; method; method = delim)
-    {
+    for (method = methods; method; method = delim) {
       delim = strchr (method, ':');
       if (delim)
-       *delim++ = '\0';
-      if (! method[0])
-       continue;
-      
-      dprint (2, (debugfile, "imap_authenticate: Trying method %s\n", method));
+        *delim++ = '\0';
+      if (!method[0])
+        continue;
+
+      dprint (2,
+              (debugfile, "imap_authenticate: Trying method %s\n", method));
       authenticator = imap_authenticators;
 
-      while (authenticator->authenticate)
-      {
-       if (!authenticator->method ||
-           !ascii_strcasecmp (authenticator->method, method))
-         if ((r = authenticator->authenticate (idata, method)) !=
-             IMAP_AUTH_UNAVAIL)
-         {
-           FREE (&methods);
-           return r;
-         }
-       
-       authenticator++;
+      while (authenticator->authenticate) {
+        if (!authenticator->method ||
+            !ascii_strcasecmp (authenticator->method, method))
+          if ((r = authenticator->authenticate (idata, method)) !=
+              IMAP_AUTH_UNAVAIL) {
+            FREE (&methods);
+            return r;
+          }
+
+        authenticator++;
       }
     }
 
     FREE (&methods);
   }
-  else
-  {
+  else {
     /* Fall back to default: any authenticator */
-    dprint (2, (debugfile, "imap_authenticate: Using any available method.\n"));
+    dprint (2,
+            (debugfile, "imap_authenticate: Using any available method.\n"));
     authenticator = imap_authenticators;
 
-    while (authenticator->authenticate)
-    {
-      if ((r = authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL)
-       return r;
+    while (authenticator->authenticate) {
+      if ((r =
+           authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL)
+        return r;
       authenticator++;
     }
   }
 
-  if (r == IMAP_AUTH_UNAVAIL)
-  {
+  if (r == IMAP_AUTH_UNAVAIL) {
     mutt_error (_("No authenticators available"));
     mutt_sleep (1);
   }
-  
+
   return r;
 }
index 608efc2..345f98e 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* common defs for authenticators. A good place to set up a generic callback
  * system */
 #ifndef _IMAP_AUTH_H
 #define _IMAP_AUTH_H 1
 
-typedef enum
-{
+typedef enum {
   IMAP_AUTH_SUCCESS = 0,
   IMAP_AUTH_FAILURE,
   IMAP_AUTH_UNAVAIL
 } imap_auth_res_t;
 
 
-typedef struct
-{
+typedef struct {
   /* do authentication, using named method or any available if method is NULL */
-  imap_auth_res_t (*authenticate) (IMAP_DATA* idata, const char* method);
+  imap_auth_res_t (*authenticate) (IMAP_DATA * idata, const char *method);
   /* name of authentication method supported, NULL means variable. If this
    * is not null, authenticate may ignore the second parameter. */
-  const charmethod;
+  const char *method;
 } imap_auth_t;
 
 /* external authenticator prototypes */
 #ifndef USE_SASL
-imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method);
-imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method);
+imap_auth_res_t imap_auth_anon (IMAP_DATA * idata, const char *method);
+imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA * idata, const char *method);
 #endif
-imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method);
+imap_auth_res_t imap_auth_login (IMAP_DATA * idata, const char *method);
+
 #ifdef USE_GSS
-imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method);
+imap_auth_res_t imap_auth_gss (IMAP_DATA * idata, const char *method);
 #endif
 #ifdef USE_SASL
-imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method);
+imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method);
 #endif
 
 #endif /* _IMAP_AUTH_H */
index 6610374..6fcc451 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* IMAP login/authentication code */
 
@@ -27,7 +27,7 @@
 #include "auth.h"
 
 /* this is basically a stripped-down version of the cram-md5 method. */
-imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method)
+imap_auth_res_t imap_auth_anon (IMAP_DATA * idata, const char *method)
 {
   int rc;
 
@@ -48,20 +48,18 @@ imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_RESPOND)
-  {
+  if (rc != IMAP_CMD_RESPOND) {
     dprint (1, (debugfile, "Invalid response from server.\n"));
     goto bail;
   }
 
-  mutt_socket_write (idata->conn, "ZHVtbXkK\r\n"); /* base64 ("dummy") */
+  mutt_socket_write (idata->conn, "ZHVtbXkK\r\n");      /* base64 ("dummy") */
 
   do
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
-  
-  if (rc != IMAP_CMD_OK)
-  {
+
+  if (rc != IMAP_CMD_OK) {
     dprint (1, (debugfile, "Error receiving server response.\n"));
     goto bail;
   }
@@ -69,7 +67,7 @@ imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method)
   if (imap_code (idata->cmd.buf))
     return IMAP_AUTH_SUCCESS;
 
- bail:
+bail:
   mutt_error _("Anonymous authentication failed.");
   mutt_sleep (2);
   return IMAP_AUTH_FAILURE;
index b440dd2..8b10f33 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* IMAP login/authentication code */
 
 #define MD5_DIGEST_LEN 16
 
 /* forward declarations */
-static void hmac_md5 (const char* password, char* challenge,
-  unsigned char* response);
+static void hmac_md5 (const char *password, char *challenge,
+                      unsigned char *response);
 
 /* imap_auth_cram_md5: AUTH=CRAM-MD5 support. */
-imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
+imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA * idata, const char *method)
 {
-  char ibuf[LONG_STRING*2], obuf[LONG_STRING];
+  char ibuf[LONG_STRING * 2], obuf[LONG_STRING];
   unsigned char hmac_response[MD5_DIGEST_LEN];
   int len;
   int rc;
@@ -64,15 +64,13 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
   do
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
-  
-  if (rc != IMAP_CMD_RESPOND)
-  {
+
+  if (rc != IMAP_CMD_RESPOND) {
     dprint (1, (debugfile, "Invalid response from server: %s\n", ibuf));
     goto bail;
   }
 
-  if ((len = mutt_from_base64 (obuf, idata->cmd.buf + 2)) == -1)
-  {
+  if ((len = mutt_from_base64 (obuf, idata->cmd.buf + 2)) == -1) {
     dprint (1, (debugfile, "Error decoding base64 response.\n"));
     goto bail;
   }
@@ -94,20 +92,22 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
   hmac_md5 (idata->conn->account.pass, obuf, hmac_response);
   /* dubious optimisation I saw elsewhere: make the whole string in one call */
   snprintf (obuf, sizeof (obuf),
-    "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
-    idata->conn->account.user,
-    hmac_response[0], hmac_response[1], hmac_response[2], hmac_response[3],
-    hmac_response[4], hmac_response[5], hmac_response[6], hmac_response[7],
-    hmac_response[8], hmac_response[9], hmac_response[10], hmac_response[11],
-    hmac_response[12], hmac_response[13], hmac_response[14], hmac_response[15]);
-  dprint(2, (debugfile, "CRAM response: %s\n", obuf));
+            "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+            idata->conn->account.user,
+            hmac_response[0], hmac_response[1], hmac_response[2],
+            hmac_response[3], hmac_response[4], hmac_response[5],
+            hmac_response[6], hmac_response[7], hmac_response[8],
+            hmac_response[9], hmac_response[10], hmac_response[11],
+            hmac_response[12], hmac_response[13], hmac_response[14],
+            hmac_response[15]);
+  dprint (2, (debugfile, "CRAM response: %s\n", obuf));
 
   /* XXX - ibuf must be long enough to store the base64 encoding of obuf, 
    * plus the additional debris
    */
-  
-  mutt_to_base64 ((unsigned char*) ibuf, (unsigned char*) obuf, strlen (obuf),
-                 sizeof (ibuf) - 2);
+
+  mutt_to_base64 ((unsigned char *) ibuf, (unsigned char *) obuf,
+                  strlen (obuf), sizeof (ibuf) - 2);
   safe_strcat (ibuf, sizeof (ibuf), "\r\n");
   mutt_socket_write (idata->conn, ibuf);
 
@@ -115,8 +115,7 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_OK)
-  {
+  if (rc != IMAP_CMD_OK) {
     dprint (1, (debugfile, "Error receiving server response.\n"));
     goto bail;
   }
@@ -124,19 +123,19 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
   if (imap_code (idata->cmd.buf))
     return IMAP_AUTH_SUCCESS;
 
- bail:
+bail:
   mutt_error _("CRAM-MD5 authentication failed.");
   mutt_sleep (2);
   return IMAP_AUTH_FAILURE;
 }
 
 /* hmac_md5: produce CRAM-MD5 challenge response. */
-static void hmac_md5 (const char* password, char* challenge,
-  unsigned char* response)
+static void hmac_md5 (const char *password, char *challenge,
+                      unsigned char *response)
 {
   MD5_CTX ctx;
   unsigned char ipad[MD5_BLOCK_LEN], opad[MD5_BLOCK_LEN];
-  unsigned char secret[MD5_BLOCK_LEN+1];
+  unsigned char secret[MD5_BLOCK_LEN + 1];
   unsigned char hash_passwd[MD5_DIGEST_LEN];
   unsigned int secret_len, chal_len;
   int i;
@@ -146,12 +145,11 @@ static void hmac_md5 (const char* password, char* challenge,
 
   /* passwords longer than MD5_BLOCK_LEN bytes are substituted with their MD5
    * digests */
-  if (secret_len > MD5_BLOCK_LEN)
-  {
+  if (secret_len > MD5_BLOCK_LEN) {
     MD5Init (&ctx);
-    MD5Update (&ctx, (unsigned char*) password, secret_len);
+    MD5Update (&ctx, (unsigned char *) password, secret_len);
     MD5Final (hash_passwd, &ctx);
-    strfcpy ((char*) secret, (char*) hash_passwd, MD5_DIGEST_LEN);
+    strfcpy ((char *) secret, (char *) hash_passwd, MD5_DIGEST_LEN);
     secret_len = MD5_DIGEST_LEN;
   }
   else
@@ -162,8 +160,7 @@ static void hmac_md5 (const char* password, char* challenge,
   memcpy (ipad, secret, secret_len);
   memcpy (opad, secret, secret_len);
 
-  for (i = 0; i < MD5_BLOCK_LEN; i++)
-  {
+  for (i = 0; i < MD5_BLOCK_LEN; i++) {
     ipad[i] ^= 0x36;
     opad[i] ^= 0x5c;
   }
@@ -171,7 +168,7 @@ static void hmac_md5 (const char* password, char* challenge,
   /* inner hash: challenge and ipadded secret */
   MD5Init (&ctx);
   MD5Update (&ctx, ipad, MD5_BLOCK_LEN);
-  MD5Update (&ctx, (unsigned char*) challenge, chal_len);
+  MD5Update (&ctx, (unsigned char *) challenge, chal_len);
   MD5Final (response, &ctx);
 
   /* outer hash: inner hash and opadded secret */
index e687fbd..37172d7 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* GSS login/authentication code */
 
@@ -43,7 +43,7 @@
 #define GSS_AUTH_P_PRIVACY   4
 
 /* imap_auth_gss: AUTH=GSSAPI support. */
-imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
+imap_auth_res_t imap_auth_gss (IMAP_DATA * idata, const char *method)
 {
   gss_buffer_desc request_buf, send_token;
   gss_buffer_t sec_token;
@@ -62,25 +62,23 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
 
   if (mutt_account_getuser (&idata->conn->account))
     return IMAP_AUTH_FAILURE;
-  
+
   /* get an IMAP service ticket for the server */
   snprintf (buf1, sizeof (buf1), "imap@%s", idata->conn->account.host);
   request_buf.value = buf1;
   request_buf.length = strlen (buf1) + 1;
   maj_stat = gss_import_name (&min_stat, &request_buf, gss_nt_service_name,
-    &target_name);
-  if (maj_stat != GSS_S_COMPLETE)
-  {
+                              &target_name);
+  if (maj_stat != GSS_S_COMPLETE) {
     dprint (2, (debugfile, "Couldn't get service name for [%s]\n", buf1));
     return IMAP_AUTH_UNAVAIL;
   }
-#ifdef DEBUG   
-  else if (debuglevel >= 2)
-  {
+#ifdef DEBUG
+  else if (debuglevel >= 2) {
     maj_stat = gss_display_name (&min_stat, target_name, &request_buf,
-      &mech_name);
+                                 &mech_name);
     dprint (2, (debugfile, "Using service name [%s]\n",
-      (char*) request_buf.value));
+                (char *) request_buf.value));
     maj_stat = gss_release_buffer (&min_stat, &request_buf);
   }
 #endif
@@ -90,11 +88,12 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
 
   /* build token */
   maj_stat = gss_init_sec_context (&min_stat, GSS_C_NO_CREDENTIAL, &context,
-    target_name, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG, 0, 
-    GSS_C_NO_CHANNEL_BINDINGS, sec_token, NULL, &send_token,
-    (unsigned int*) &cflags, NULL);
-  if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED)
-  {
+                                   target_name, GSS_C_NO_OID,
+                                   GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG, 0,
+                                   GSS_C_NO_CHANNEL_BINDINGS, sec_token, NULL,
+                                   &send_token, (unsigned int *) &cflags,
+                                   NULL);
+  if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
     dprint (1, (debugfile, "Error acquiring credentials - no TGT?\n"));
     gss_release_name (&min_stat, &target_name);
 
@@ -111,8 +110,7 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_RESPOND)
-  {
+  if (rc != IMAP_CMD_RESPOND) {
     dprint (2, (debugfile, "Invalid response from server: %s\n", buf1));
     gss_release_name (&min_stat, &target_name);
     goto bail;
@@ -120,21 +118,19 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
 
   /* now start the security context initialisation loop... */
   dprint (2, (debugfile, "Sending credentials\n"));
-  mutt_to_base64 ((unsigned char*) buf1, send_token.value, send_token.length,
-    sizeof (buf1) - 2);
+  mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
+                  sizeof (buf1) - 2);
   gss_release_buffer (&min_stat, &send_token);
   safe_strcat (buf1, sizeof (buf1), "\r\n");
   mutt_socket_write (idata->conn, buf1);
 
-  while (maj_stat == GSS_S_CONTINUE_NEEDED)
-  {
+  while (maj_stat == GSS_S_CONTINUE_NEEDED) {
     /* Read server data */
     do
       rc = imap_cmd_step (idata);
     while (rc == IMAP_CMD_CONTINUE);
 
-    if (rc != IMAP_CMD_RESPOND)
-    {
+    if (rc != IMAP_CMD_RESPOND) {
       dprint (1, (debugfile, "Error receiving server response.\n"));
       gss_release_name (&min_stat, &target_name);
       goto bail;
@@ -146,18 +142,19 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
 
     /* Write client data */
     maj_stat = gss_init_sec_context (&min_stat, GSS_C_NO_CREDENTIAL, &context,
-      target_name, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG, 0, 
-      GSS_C_NO_CHANNEL_BINDINGS, sec_token, NULL, &send_token,
-      (unsigned int*) &cflags, NULL);
-    if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED)
-    {
+                                     target_name, GSS_C_NO_OID,
+                                     GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG,
+                                     0, GSS_C_NO_CHANNEL_BINDINGS, sec_token,
+                                     NULL, &send_token,
+                                     (unsigned int *) &cflags, NULL);
+    if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
       dprint (1, (debugfile, "Error exchanging credentials\n"));
       gss_release_name (&min_stat, &target_name);
 
       goto err_abort_cmd;
     }
-    mutt_to_base64 ((unsigned char*) buf1, send_token.value,
-      send_token.length, sizeof (buf1) - 2);
+    mutt_to_base64 ((unsigned char *) buf1, send_token.value,
+                    send_token.length, sizeof (buf1) - 2);
     gss_release_buffer (&min_stat, &send_token);
     safe_strcat (buf1, sizeof (buf1), "\r\n");
     mutt_socket_write (idata->conn, buf1);
@@ -170,8 +167,7 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_RESPOND)
-  {
+  if (rc != IMAP_CMD_RESPOND) {
     dprint (1, (debugfile, "Error receiving server response.\n"));
     goto bail;
   }
@@ -179,9 +175,8 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
   request_buf.value = buf2;
 
   maj_stat = gss_unwrap (&min_stat, context, &request_buf, &send_token,
-    &cflags, &quality);
-  if (maj_stat != GSS_S_COMPLETE)
-  {
+                         &cflags, &quality);
+  if (maj_stat != GSS_S_COMPLETE) {
     dprint (2, (debugfile, "Couldn't unwrap security level data\n"));
     gss_release_buffer (&min_stat, &send_token);
     goto err_abort_cmd;
@@ -189,26 +184,25 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
   dprint (2, (debugfile, "Credential exchange complete\n"));
 
   /* first octet is security levels supported. We want NONE */
-  server_conf_flags = ((char*) send_token.value)[0];
-  if ( !(((char*) send_token.value)[0] & GSS_AUTH_P_NONE) )
-  {
+  server_conf_flags = ((char *) send_token.value)[0];
+  if (!(((char *) send_token.value)[0] & GSS_AUTH_P_NONE)) {
     dprint (2, (debugfile, "Server requires integrity or privacy\n"));
     gss_release_buffer (&min_stat, &send_token);
     goto err_abort_cmd;
   }
 
   /* we don't care about buffer size if we don't wrap content. But here it is */
-  ((char*) send_token.value)[0] = 0;
+  ((char *) send_token.value)[0] = 0;
   buf_size = ntohl (*((long *) send_token.value));
   gss_release_buffer (&min_stat, &send_token);
   dprint (2, (debugfile, "Unwrapped security level flags: %c%c%c\n",
-    server_conf_flags & GSS_AUTH_P_NONE      ? 'N' : '-',
-    server_conf_flags & GSS_AUTH_P_INTEGRITY ? 'I' : '-',
-    server_conf_flags & GSS_AUTH_P_PRIVACY   ? 'P' : '-'));
+              server_conf_flags & GSS_AUTH_P_NONE ? 'N' : '-',
+              server_conf_flags & GSS_AUTH_P_INTEGRITY ? 'I' : '-',
+              server_conf_flags & GSS_AUTH_P_PRIVACY ? 'P' : '-'));
   dprint (2, (debugfile, "Maximum GSS token size is %ld\n", buf_size));
 
   /* agree to terms (hack!) */
-  buf_size = htonl (buf_size); /* not relevant without integrity/privacy */
+  buf_size = htonl (buf_size);  /* not relevant without integrity/privacy */
   memcpy (buf1, &buf_size, 4);
   buf1[0] = GSS_AUTH_P_NONE;
   /* server decides if principal can log in as user */
@@ -216,17 +210,16 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
   request_buf.value = buf1;
   request_buf.length = 4 + strlen (idata->conn->account.user) + 1;
   maj_stat = gss_wrap (&min_stat, context, 0, GSS_C_QOP_DEFAULT, &request_buf,
-    &cflags, &send_token);
-  if (maj_stat != GSS_S_COMPLETE)
-  {
+                       &cflags, &send_token);
+  if (maj_stat != GSS_S_COMPLETE) {
     dprint (2, (debugfile, "Error creating login request\n"));
     goto err_abort_cmd;
   }
 
-  mutt_to_base64 ((unsigned char*) buf1, send_token.value, send_token.length,
-                 sizeof (buf1) - 2);
+  mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
+                  sizeof (buf1) - 2);
   dprint (2, (debugfile, "Requesting authorisation as %s\n",
-    idata->conn->account.user));
+              idata->conn->account.user));
   safe_strcat (buf1, sizeof (buf1), "\r\n");
   mutt_socket_write (idata->conn, buf1);
 
@@ -234,13 +227,11 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
   do
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
-  if (rc == IMAP_CMD_RESPOND)
-  {
+  if (rc == IMAP_CMD_RESPOND) {
     dprint (1, (debugfile, "Unexpected server continuation request.\n"));
     goto err_abort_cmd;
   }
-  if (imap_code (idata->cmd.buf))
-  {
+  if (imap_code (idata->cmd.buf)) {
     /* flush the security context */
     dprint (2, (debugfile, "Releasing GSS credentials\n"));
     maj_stat = gss_delete_sec_context (&min_stat, &context, &send_token);
@@ -258,13 +249,13 @@ imap_auth_res_t imap_auth_gss (IMAP_DATA* idata, const char* method)
   else
     goto bail;
 
- err_abort_cmd:
+err_abort_cmd:
   mutt_socket_write (idata->conn, "*\r\n");
   do
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
- bail:
+bail:
   mutt_error _("GSSAPI authentication failed.");
   mutt_sleep (2);
   return IMAP_AUTH_FAILURE;
index af1fa21..51667fb 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* plain LOGIN support */
 
 #include "auth.h"
 
 /* imap_auth_login: Plain LOGIN support */
-imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method)
+imap_auth_res_t imap_auth_login (IMAP_DATA * idata, const char *method)
 {
   char q_user[SHORT_STRING], q_pass[SHORT_STRING];
   char buf[STRING];
   int rc;
 
-  if (mutt_bit_isset (idata->capabilities, LOGINDISABLED))
-  {
+  if (mutt_bit_isset (idata->capabilities, LOGINDISABLED)) {
     mutt_message _("LOGIN disabled on this server.");
+
     return IMAP_AUTH_UNAVAIL;
   }
 
@@ -55,16 +55,17 @@ imap_auth_res_t imap_auth_login (IMAP_DATA* idata, const char* method)
 
   if (debuglevel < IMAP_LOG_PASS)
     dprint (2, (debugfile, "Sending LOGIN command for %s...\n",
-      idata->conn->account.user));
+                idata->conn->account.user));
 #endif
 
   snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass);
   rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK | IMAP_CMD_PASS);
-  
+
   if (!rc)
     return IMAP_AUTH_SUCCESS;
 
   mutt_error _("Login failed.");
+
   mutt_sleep (2);
   return IMAP_AUTH_FAILURE;
 }
index a76677f..49c09a3 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* SASL login/authentication code */
 
 #endif
 
 /* imap_auth_sasl: Default authenticator if available. */
-imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
+imap_auth_res_t imap_auth_sasl (IMAP_DATA * idata, const char *method)
 {
-  sasl_conn_tsaslconn;
-  sasl_interact_tinteraction = NULL;
+  sasl_conn_t *saslconn;
+  sasl_interact_t *interaction = NULL;
   int rc, irc;
   char buf[HUGE_STRING];
-  const char* mech;
+  const char *mech;
+
 #ifdef USE_SASL2
   const char *pc = NULL;
 #else
-  charpc = NULL;
+  char *pc = NULL;
 #endif
   unsigned int len, olen;
   unsigned char client_start;
 
-  if (mutt_sasl_client_new (idata->conn, &saslconn) < 0)
-  {
+  if (mutt_sasl_client_new (idata->conn, &saslconn) < 0) {
     dprint (1, (debugfile,
-      "imap_auth_sasl: Error allocating SASL connection.\n"));
+                "imap_auth_sasl: Error allocating SASL connection.\n"));
     return IMAP_AUTH_FAILURE;
   }
 
   rc = SASL_FAIL;
 
   /* If the user hasn't specified a method, use any available */
-  if (!method)
-  {
+  if (!method) {
     method = idata->capstr;
 
     /* hack for SASL ANONYMOUS support:
@@ -74,40 +73,41 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
       return IMAP_AUTH_FAILURE;
 
     if (mutt_bit_isset (idata->capabilities, AUTH_ANON) &&
-       (!idata->conn->account.user[0] ||
-        !ascii_strncmp (idata->conn->account.user, "anonymous", 9)))
+        (!idata->conn->account.user[0] ||
+         !ascii_strncmp (idata->conn->account.user, "anonymous", 9)))
 #ifdef USE_SASL2
-      rc = sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, &pc, &olen, 
+      rc = sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, &pc, &olen,
                               &mech);
 #else
-      rc = sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, NULL, &pc, &olen,
-                             &mech);
+      rc =
+        sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, NULL, &pc, &olen,
+                           &mech);
 #endif
   }
-  
+
   if (rc != SASL_OK && rc != SASL_CONTINUE)
-    do
-    {
+    do {
 #ifdef USE_SASL2
       rc = sasl_client_start (saslconn, method, &interaction,
-        &pc, &olen, &mech);
+                              &pc, &olen, &mech);
 #else
       rc = sasl_client_start (saslconn, method, NULL, &interaction,
-        &pc, &olen, &mech);
+                              &pc, &olen, &mech);
 #endif
       if (rc == SASL_INTERACT)
-       mutt_sasl_interact (interaction);
+        mutt_sasl_interact (interaction);
     }
     while (rc == SASL_INTERACT);
 
   client_start = (olen > 0);
 
-  if (rc != SASL_OK && rc != SASL_CONTINUE)
-  {
+  if (rc != SASL_OK && rc != SASL_CONTINUE) {
     if (method)
       dprint (2, (debugfile, "imap_auth_sasl: %s unavailable\n", method));
     else
-      dprint (1, (debugfile, "imap_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
+      dprint (1,
+              (debugfile,
+               "imap_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
     /* SASL doesn't support LOGIN, so fall back */
 
     return IMAP_AUTH_UNAVAIL;
@@ -120,14 +120,12 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
   irc = IMAP_CMD_CONTINUE;
 
   /* looping protocol */
-  while (rc == SASL_CONTINUE || olen > 0)
-  {
+  while (rc == SASL_CONTINUE || olen > 0) {
     do
       irc = imap_cmd_step (idata);
     while (irc == IMAP_CMD_CONTINUE);
 
-    if (method && irc == IMAP_CMD_NO)
-    {
+    if (method && irc == IMAP_CMD_NO) {
       dprint (2, (debugfile, "imap_auth_sasl: %s failed\n", method));
       sasl_dispose (&saslconn);
       return IMAP_AUTH_UNAVAIL;
@@ -136,27 +134,27 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
     if (irc == IMAP_CMD_BAD || irc == IMAP_CMD_NO)
       goto bail;
 
-    if (irc == IMAP_CMD_RESPOND)
-    {
+    if (irc == IMAP_CMD_RESPOND) {
 #ifdef USE_SASL2
-      if (sasl_decode64 (idata->cmd.buf+2, strlen (idata->cmd.buf+2), buf, LONG_STRING-1,
+      if (sasl_decode64
+          (idata->cmd.buf + 2, strlen (idata->cmd.buf + 2), buf,
+           LONG_STRING - 1,
 #else
-      if (sasl_decode64 (idata->cmd.buf+2, strlen (idata->cmd.buf+2), buf,
+      if (sasl_decode64 (idata->cmd.buf + 2, strlen (idata->cmd.buf + 2), buf,
 #endif
-                        &len) != SASL_OK)
-      {
-       dprint (1, (debugfile, "imap_auth_sasl: error base64-decoding server response.\n"));
-       goto bail;
+                         &len) != SASL_OK) {
+        dprint (1,
+                (debugfile,
+                 "imap_auth_sasl: error base64-decoding server response.\n"));
+        goto bail;
       }
     }
 
-    if (!client_start)
-    {
-      do
-      {
-       rc = sasl_client_step (saslconn, buf, len, &interaction, &pc, &olen);
-       if (rc == SASL_INTERACT)
-         mutt_sasl_interact (interaction);
+    if (!client_start) {
+      do {
+        rc = sasl_client_step (saslconn, buf, len, &interaction, &pc, &olen);
+        if (rc == SASL_INTERACT)
+          mutt_sasl_interact (interaction);
       }
       while (rc == SASL_INTERACT);
     }
@@ -164,12 +162,12 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
       client_start = 0;
 
     /* send out response, or line break if none needed */
-    if (olen)
-    {
-      if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK)
-      {
-       dprint (1, (debugfile, "imap_auth_sasl: error base64-encoding client response.\n"));
-       goto bail;
+    if (olen) {
+      if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) {
+        dprint (1,
+                (debugfile,
+                 "imap_auth_sasl: error base64-encoding client response.\n"));
+        goto bail;
       }
 
       /* sasl_client_st(art|ep) allocate pc with malloc, expect me to 
@@ -178,20 +176,19 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
       FREE (&pc);
 #endif
     }
-    
-    if (irc == IMAP_CMD_RESPOND)
-    {
+
+    if (irc == IMAP_CMD_RESPOND) {
       strfcpy (buf + olen, "\r\n", sizeof (buf) - olen);
       mutt_socket_write (idata->conn, buf);
     }
 
     /* If SASL has errored out, send an abort string to the server */
-    if (rc < 0)
-    {
+    if (rc < 0) {
       mutt_socket_write (idata->conn, "*\r\n");
-      dprint (1, (debugfile, "imap_auth_sasl: sasl_client_step error %d\n",rc));
+      dprint (1,
+              (debugfile, "imap_auth_sasl: sasl_client_step error %d\n", rc));
     }
-         
+
     olen = 0;
   }
 
@@ -202,15 +199,14 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
   if (rc != SASL_OK)
     goto bail;
 
-  if (imap_code (idata->cmd.buf))
-  {
+  if (imap_code (idata->cmd.buf)) {
     mutt_sasl_setup_conn (idata->conn, saslconn);
     return IMAP_AUTH_SUCCESS;
   }
 
- bail:
+bail:
   mutt_error _("SASL authentication failed.");
-  mutt_sleep(2);
+  mutt_sleep (2);
   sasl_dispose (&saslconn);
 
   return IMAP_AUTH_FAILURE;
index f2b01f4..b5e7ac8 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* Mutt browser support routines */
 
 #include "imap_private.h"
 
 /* -- forward declarations -- */
-static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,
-  struct browser_state* state, short isparent);
+static int browse_add_list_result (IMAP_DATA * idata, const char *cmd,
+                                   struct browser_state *state,
+                                   short isparent);
 static void imap_add_folder (char delim, char *folder, int noselect,
-  int noinferiors, struct browser_state *state, short isparent);
-static int compare_names(struct folder_file *a, struct folder_file *b);
-static int browse_get_namespace (IMAP_DATA *idata, char *nsbuf, int nsblen, 
-  IMAP_NAMESPACE_INFO *nsi, int nsilen, int *nns);
-static int browse_verify_namespace (IMAP_DATA* idata,
-  IMAP_NAMESPACE_INFO* nsi, int nns);
+                             int noinferiors, struct browser_state *state,
+                             short isparent);
+static int compare_names (struct folder_file *a, struct folder_file *b);
+static int browse_get_namespace (IMAP_DATA * idata, char *nsbuf, int nsblen,
+                                 IMAP_NAMESPACE_INFO * nsi, int nsilen,
+                                 int *nns);
+static int browse_verify_namespace (IMAP_DATA * idata,
+                                    IMAP_NAMESPACE_INFO * nsi, int nns);
 
 /* imap_browse: IMAP hook into the folder browser, fills out browser_state,
  *   given a current folder to browse */
-int imap_browse (char* path, struct browser_state* state)
+int imap_browse (char *path, struct browser_state *state)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   char buf[LONG_STRING];
   char buf2[LONG_STRING];
   char nsbuf[LONG_STRING];
@@ -63,42 +66,40 @@ int imap_browse (char* path, struct browser_state* state)
   int noinferiors;
   IMAP_MBOX mx;
 
-  if (imap_parse_path (path, &mx))
-  {
+  if (imap_parse_path (path, &mx)) {
     mutt_error (_("%s is an invalid IMAP path"), path);
     return -1;
   }
 
-  strfcpy (list_cmd, option (OPTIMAPLSUB) ? "LSUB" : "LIST", sizeof (list_cmd));
+  strfcpy (list_cmd, option (OPTIMAPLSUB) ? "LSUB" : "LIST",
+           sizeof (list_cmd));
 
   if (!(idata = imap_conn_find (&(mx.account), 0)))
     goto fail;
 
-  if (!mx.mbox)
-  {
+  if (!mx.mbox) {
     home_namespace = 1;
-    mbox[0] = '\0';            /* Do not replace "" with "INBOX" here */
-    mx.mbox = safe_strdup(ImapHomeNamespace);
+    mbox[0] = '\0';             /* Do not replace "" with "INBOX" here */
+    mx.mbox = safe_strdup (ImapHomeNamespace);
     nns = 0;
-    if (mutt_bit_isset(idata->capabilities,NAMESPACE))
-    {
+    if (mutt_bit_isset (idata->capabilities, NAMESPACE)) {
       mutt_message _("Getting namespaces...");
-      if (browse_get_namespace (idata, nsbuf, sizeof (nsbuf), 
-                        nsi, sizeof (nsi),  &nns) != 0)
-       goto fail;
+
+      if (browse_get_namespace (idata, nsbuf, sizeof (nsbuf),
+                                nsi, sizeof (nsi), &nns) != 0)
+        goto fail;
       if (browse_verify_namespace (idata, nsi, nns) != 0)
-       goto fail;
+        goto fail;
     }
   }
 
   mutt_message _("Getting folder list...");
 
   /* skip check for parents when at the root */
-  if (mx.mbox && mx.mbox[0] != '\0')
-  {
+  if (mx.mbox && mx.mbox[0] != '\0') {
     imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
     imap_munge_mbox_name (buf, sizeof (buf), mbox);
-    imap_unquote_string(buf); /* As kludgy as it gets */
+    imap_unquote_string (buf);  /* As kludgy as it gets */
     mbox[sizeof (mbox) - 1] = '\0';
     strncpy (mbox, buf, sizeof (mbox) - 1);
     n = mutt_strlen (mbox);
@@ -107,23 +108,19 @@ int imap_browse (char* path, struct browser_state* state)
 
     /* if our target exists and has inferiors, enter it if we
      * aren't already going to */
-    if (mbox[n-1] != idata->delim)
-    {
+    if (mbox[n - 1] != idata->delim) {
       snprintf (buf, sizeof (buf), "%s \"\" \"%s\"", list_cmd, mbox);
       imap_cmd_start (idata, buf);
-      do 
-      {
+      do {
         if (imap_parse_list_response (idata, &cur_folder, &noselect,
-            &noinferiors, &idata->delim) != 0)
-         goto fail;
+                                      &noinferiors, &idata->delim) != 0)
+          goto fail;
 
-        if (cur_folder)
-        {
+        if (cur_folder) {
           imap_unmunge_mbox_name (cur_folder);
 
           if (!noinferiors && cur_folder[0] &&
-            (n = strlen (mbox)) < LONG_STRING-1)
-          {
+              (n = strlen (mbox)) < LONG_STRING - 1) {
             mbox[n++] = idata->delim;
             mbox[n] = '\0';
           }
@@ -133,11 +130,10 @@ int imap_browse (char* path, struct browser_state* state)
     }
 
     /* if we're descending a folder, mark it as current in browser_state */
-    if (mbox[n-1] == idata->delim)
-    {
+    if (mbox[n - 1] == idata->delim) {
       /* don't show parents in the home namespace */
       if (!home_namespace)
-       showparents = 1;
+        showparents = 1;
       imap_qualify_path (buf, sizeof (buf), &mx, mbox);
       state->folder = safe_strdup (buf);
       n--;
@@ -149,23 +145,20 @@ int imap_browse (char* path, struct browser_state* state)
      *  and tack on delimiter ourselves.
      * Further note: UW-IMAP servers return nothing when asked for 
      *  NAMESPACES without delimiters at the end. Argh! */
-    for (n--; n >= 0 && mbox[n] != idata->delim ; n--);
-    if (n > 0)                 /* "aaaa/bbbb/" -> "aaaa" */
-    {
+    for (n--; n >= 0 && mbox[n] != idata->delim; n--);
+    if (n > 0) {                /* "aaaa/bbbb/" -> "aaaa" */
       /* forget the check, it is too delicate (see above). Have we ever
        * had the parent not exist? */
       ctmp = mbox[n];
       mbox[n] = '\0';
 
-      if (showparents)
-      {
-       dprint (3, (debugfile, "imap_init_browse: adding parent %s\n", mbox));
-       imap_add_folder (idata->delim, mbox, 1, 0, state, 1);
+      if (showparents) {
+        dprint (3, (debugfile, "imap_init_browse: adding parent %s\n", mbox));
+        imap_add_folder (idata->delim, mbox, 1, 0, state, 1);
       }
 
       /* if our target isn't a folder, we are in our superior */
-      if (!state->folder)
-      {
+      if (!state->folder) {
         /* store folder with delimiter */
         mbox[n++] = ctmp;
         ctmp = mbox[n];
@@ -174,17 +167,16 @@ int imap_browse (char* path, struct browser_state* state)
         state->folder = safe_strdup (buf);
       }
       mbox[n] = ctmp;
-    } 
+    }
     /* "/bbbb/" -> add  "/", "aaaa/" -> add "" */
-    else
-    {
+    else {
       char relpath[2];
+
       /* folder may be "/" */
-      snprintf (relpath, sizeof (relpath), "%c" , n < 0 ? '\0' : idata->delim);
+      snprintf (relpath, sizeof (relpath), "%c", n < 0 ? '\0' : idata->delim);
       if (showparents)
-        imap_add_folder (idata->delim, relpath, 1, 0, state, 1); 
-      if (!state->folder)
-      {
+        imap_add_folder (idata->delim, relpath, 1, 0, state, 1);
+      if (!state->folder) {
         imap_qualify_path (buf, sizeof (buf), &mx, relpath);
         state->folder = safe_strdup (buf);
       }
@@ -192,14 +184,12 @@ int imap_browse (char* path, struct browser_state* state)
   }
 
   /* no namespace, no folder: set folder to host only */
-  if (!state->folder)
-  {
+  if (!state->folder) {
     imap_qualify_path (buf, sizeof (buf), &mx, NULL);
     state->folder = safe_strdup (buf);
   }
 
-  if (home_namespace && mbox[0] != '\0')
-  {
+  if (home_namespace && mbox[0] != '\0') {
     /* Listing the home namespace, so INBOX should be included. Home 
      * namespace is not "", so we have to list it explicitly. We ask the 
      * server to see if it has descendants. */
@@ -218,117 +208,117 @@ int imap_browse (char* path, struct browser_state* state)
   if (browse_add_list_result (idata, buf, state, 0))
     goto fail;
 
-  if (!state->entrylen)
-  {
+  if (!state->entrylen) {
     mutt_error _("No such folder");
+
     goto fail;
   }
 
   mutt_clear_error ();
 
-  qsort(&(state->entry[nsup]),state->entrylen-nsup,sizeof(state->entry[0]),
-       (int (*)(const void*,const void*)) compare_names);
-  if (home_namespace)
-  {                            /* List additional namespaces */
+  qsort (&(state->entry[nsup]), state->entrylen - nsup,
+         sizeof (state->entry[0]),
+         (int (*)(const void *, const void *)) compare_names);
+  if (home_namespace) {         /* List additional namespaces */
     for (i = 0; i < nns; i++)
       if (nsi[i].listable && !nsi[i].home_namespace) {
-       imap_add_folder(nsi[i].delim, nsi[i].prefix, nsi[i].noselect,
-                       nsi[i].noinferiors, state, 0);
-       dprint (3, (debugfile, "imap_browse: adding namespace: %s\n",
-                   nsi[i].prefix));
+        imap_add_folder (nsi[i].delim, nsi[i].prefix, nsi[i].noselect,
+                         nsi[i].noinferiors, state, 0);
+        dprint (3, (debugfile, "imap_browse: adding namespace: %s\n",
+                    nsi[i].prefix));
       }
   }
 
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
 /* imap_mailbox_create: Prompt for a new mailbox name, and try to create it */
-int imap_mailbox_create (const charfolder)
+int imap_mailbox_create (const char *folder)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   IMAP_MBOX mx;
   char buf[LONG_STRING];
   short n;
 
-  if (imap_parse_path (folder, &mx) < 0)
-  {
+  if (imap_parse_path (folder, &mx) < 0) {
     dprint (1, (debugfile, "imap_mailbox_create: Bad starting path %s\n",
-      folder));
+                folder));
     return -1;
   }
 
-  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW)))
-  {
-    dprint (1, (debugfile, "imap_mailbox_create: Couldn't find open connection to %s", mx.account.host));
+  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) {
+    dprint (1,
+            (debugfile,
+             "imap_mailbox_create: Couldn't find open connection to %s",
+             mx.account.host));
     goto fail;
   }
-  
+
   strfcpy (buf, NONULL (mx.mbox), sizeof (buf));
 
   /* append a delimiter if necessary */
   n = mutt_strlen (buf);
-  if (n && (n < sizeof (buf) - 1) && (buf[n-1] != idata->delim))
-  {
+  if (n && (n < sizeof (buf) - 1) && (buf[n - 1] != idata->delim)) {
     buf[n++] = idata->delim;
     buf[n] = '\0';
   }
-  
+
   if (mutt_get_field (_("Create mailbox: "), buf, sizeof (buf), M_FILE) < 0)
     goto fail;
 
-  if (!mutt_strlen (buf))
-  {
+  if (!mutt_strlen (buf)) {
     mutt_error (_("Mailbox must have a name."));
-    mutt_sleep(1);
+    mutt_sleep (1);
     goto fail;
   }
-  
+
   if (imap_create_mailbox (idata, buf) < 0)
     goto fail;
 
   mutt_message _("Mailbox created.");
+
   mutt_sleep (0);
 
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
-int imap_mailbox_rename(const char* mailbox)
+int imap_mailbox_rename (const char *mailbox)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   IMAP_MBOX mx;
   char buf[LONG_STRING];
   char newname[SHORT_STRING];
 
-  if (imap_parse_path (mailbox, &mx) < 0)
-  {
+  if (imap_parse_path (mailbox, &mx) < 0) {
     dprint (1, (debugfile, "imap_mailbox_rename: Bad source mailbox %s\n",
-      mailbox));
+                mailbox));
     return -1;
   }
 
-  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW)))
-  {
-    dprint (1, (debugfile, "imap_mailbox_rename: Couldn't find open connection to %s", mx.account.host));
+  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) {
+    dprint (1,
+            (debugfile,
+             "imap_mailbox_rename: Couldn't find open connection to %s",
+             mx.account.host));
     goto fail;
   }
 
-  snprintf(buf, sizeof (buf), _("Rename mailbox %s to: "), mx.mbox);
-  
- if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0)
+  snprintf (buf, sizeof (buf), _("Rename mailbox %s to: "), mx.mbox);
+
 if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0)
     goto fail;
 
-  if (!mutt_strlen (newname))
-  {
+  if (!mutt_strlen (newname)) {
     mutt_error (_("Mailbox must have a name."));
     mutt_sleep (1);
     goto fail;
@@ -346,46 +336,44 @@ int imap_mailbox_rename(const char* mailbox)
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
-static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,
-  struct browser_state* state, short isparent)
+static int browse_add_list_result (IMAP_DATA * idata, const char *cmd,
+                                   struct browser_state *state,
+                                   short isparent)
 {
   char *name;
   int noselect;
   int noinferiors;
   IMAP_MBOX mx;
 
-  if (imap_parse_path (state->folder, &mx))
-  {
+  if (imap_parse_path (state->folder, &mx)) {
     dprint (2, (debugfile,
-      "browse_add_list_result: current folder %s makes no sense\n", state->folder));
+                "browse_add_list_result: current folder %s makes no sense\n",
+                state->folder));
     return -1;
   }
 
   imap_cmd_start (idata, cmd);
 
-  do 
-  {
-    if (imap_parse_list_response(idata, &name, &noselect, &noinferiors,
-        &idata->delim) != 0)
-    {
+  do {
+    if (imap_parse_list_response (idata, &name, &noselect, &noinferiors,
+                                  &idata->delim) != 0) {
       FREE (&mx.mbox);
       return -1;
     }
 
-    if (name)
-    {
+    if (name) {
       /* Let a parent folder never be selectable for navigation */
       if (isparent)
         noselect = 1;
       /* prune current folder from output */
       if (isparent || mutt_strncmp (name, mx.mbox, strlen (name)))
         imap_add_folder (idata->delim, name, noselect, noinferiors, state,
-          isparent);
+                         isparent);
     }
   }
   while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0));
@@ -397,7 +385,8 @@ static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,
 /* imap_add_folder: add a folder name to the browser list, formatting it as
  *   necessary. */
 static void imap_add_folder (char delim, char *folder, int noselect,
-  int noinferiors, struct browser_state *state, short isparent)
+                             int noinferiors, struct browser_state *state,
+                             short isparent)
 {
   char tmp[LONG_STRING];
   char relpath[LONG_STRING];
@@ -408,12 +397,12 @@ static void imap_add_folder (char delim, char *folder, int noselect,
 
   imap_unmunge_mbox_name (folder);
 
-  if (state->entrylen + 1 == state->entrymax)
-  {
+  if (state->entrylen + 1 == state->entrymax) {
     safe_realloc (&state->entry,
-      sizeof (struct folder_file) * (state->entrymax += 256));
+                  sizeof (struct folder_file) * (state->entrymax += 256));
     memset (state->entry + state->entrylen, 0,
-      (sizeof (struct folder_file) * (state->entrymax - state->entrylen)));
+            (sizeof (struct folder_file) *
+             (state->entrymax - state->entrylen)));
   }
 
   /* render superiors as unix-standard ".." */
@@ -428,8 +417,7 @@ static void imap_add_folder (char delim, char *folder, int noselect,
   /* apply filemask filter. This should really be done at menu setup rather
    * than at scan, since it's so expensive to scan. But that's big changes
    * to browser.c */
-  if (!((regexec (Mask.rx, relpath, 0, NULL, 0) == 0) ^ Mask.not))
-  {
+  if (!((regexec (Mask.rx, relpath, 0, NULL, 0) == 0) ^ Mask.not)) {
     FREE (&mx.mbox);
     return;
   }
@@ -438,12 +426,11 @@ static void imap_add_folder (char delim, char *folder, int noselect,
   (state->entry)[state->entrylen].name = safe_strdup (tmp);
 
   /* mark desc with delim in browser if it can have subfolders */
-  if (!isparent && !noinferiors && strlen (relpath) < sizeof (relpath) - 1)
-  {
+  if (!isparent && !noinferiors && strlen (relpath) < sizeof (relpath) - 1) {
     relpath[strlen (relpath) + 1] = '\0';
     relpath[strlen (relpath)] = delim;
   }
-  
+
   (state->entry)[state->entrylen].desc = safe_strdup (relpath);
 
   (state->entry)[state->entrylen].imap = 1;
@@ -458,13 +445,14 @@ static void imap_add_folder (char delim, char *folder, int noselect,
   FREE (&mx.mbox);
 }
 
-static int compare_names(struct folder_file *a, struct folder_file *b) 
+static int compare_names (struct folder_file *a, struct folder_file *b)
 {
-  return mutt_strcmp(a->name, b->name);
+  return mutt_strcmp (a->name, b->name);
 }
 
-static int browse_get_namespace (IMAP_DATA* idata, char* nsbuf, int nsblen,
-  IMAP_NAMESPACE_INFO* nsi, int nsilen, int* nns)
+static int browse_get_namespace (IMAP_DATA * idata, char *nsbuf, int nsblen,
+                                 IMAP_NAMESPACE_INFO * nsi, int nsilen,
+                                 int *nns)
 {
   char *s;
   int n;
@@ -475,87 +463,78 @@ static int browse_get_namespace (IMAP_DATA* idata, char* nsbuf, int nsblen,
   int rc;
 
   *nns = 0;
-  nsbuf[nsblen-1] = '\0';
+  nsbuf[nsblen - 1] = '\0';
 
   imap_cmd_start (idata, "NAMESPACE");
-  
-  do 
-  {
+
+  do {
     if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
       break;
 
     s = imap_next_word (idata->cmd.buf);
-    if (ascii_strncasecmp ("NAMESPACE", s, 9) == 0)
-    {
+    if (ascii_strncasecmp ("NAMESPACE", s, 9) == 0) {
       /* There are three sections to the response, User, Other, Shared,
        * and maybe more by extension */
-      for (type = IMAP_NS_PERSONAL; *s; type++)
-      {
-       s = imap_next_word (s);
-       if (*s && ascii_strncasecmp (s, "NIL", 3))
-       {
-         s++;
-         while (*s && *s != ')')
-         {
-           s++; /* skip ( */
-           /* copy namespace */
-           n = 0;
-           delim = '\0';
-
-           if (*s == '\"')
-           {
-             s++;
-             while (*s && *s != '\"') 
-             {
-               if (*s == '\\')
-                 s++;
-               ns[n++] = *s;
-               s++;
-             }
-             if (*s)
-               s++;
-           }
-           else
-             while (*s && !ISSPACE (*s)) 
-             {
-               ns[n++] = *s;
-               s++;
-             }
-           ns[n] = '\0';
-           /* delim? */
-           s = imap_next_word (s);
-           /* delimiter is meaningless if namespace is "". Why does
-            * Cyrus provide one?! */
-           if (n && *s && *s == '\"')
-           {
-             if (s[1] && s[2] == '\"')
-               delim = s[1];
-             else if (s[1] && s[1] == '\\' && s[2] && s[3] == '\"')
-               delim = s[2];
-           }
-           /* skip "" namespaces, they are already listed at the root */
-           if ((ns[0] != '\0') && (nsbused < nsblen) && (*nns < nsilen))
-           {
-             dprint (3, (debugfile, "browse_get_namespace: adding %s\n", ns));
-             nsi->type = type;
-             /* Cyrus doesn't append the delimiter to the namespace,
-              * but UW-IMAP does. We'll strip it here and add it back
-              * as if it were a normal directory, from the browser */
-             if (n && (ns[n-1] == delim))
-               ns[--n] = '\0';
-             strncpy (nsbuf+nsbused,ns,nsblen-nsbused-1);
-             nsi->prefix = nsbuf+nsbused;
-             nsbused += n+1;
-             nsi->delim = delim;
-             nsi++;
-             (*nns)++;
-           }
-           while (*s && *s != ')') 
-             s++;
-           if (*s)
-             s++;
-         }
-       }
+      for (type = IMAP_NS_PERSONAL; *s; type++) {
+        s = imap_next_word (s);
+        if (*s && ascii_strncasecmp (s, "NIL", 3)) {
+          s++;
+          while (*s && *s != ')') {
+            s++;                /* skip ( */
+            /* copy namespace */
+            n = 0;
+            delim = '\0';
+
+            if (*s == '\"') {
+              s++;
+              while (*s && *s != '\"') {
+                if (*s == '\\')
+                  s++;
+                ns[n++] = *s;
+                s++;
+              }
+              if (*s)
+                s++;
+            }
+            else
+              while (*s && !ISSPACE (*s)) {
+                ns[n++] = *s;
+                s++;
+              }
+            ns[n] = '\0';
+            /* delim? */
+            s = imap_next_word (s);
+            /* delimiter is meaningless if namespace is "". Why does
+             * Cyrus provide one?! */
+            if (n && *s && *s == '\"') {
+              if (s[1] && s[2] == '\"')
+                delim = s[1];
+              else if (s[1] && s[1] == '\\' && s[2] && s[3] == '\"')
+                delim = s[2];
+            }
+            /* skip "" namespaces, they are already listed at the root */
+            if ((ns[0] != '\0') && (nsbused < nsblen) && (*nns < nsilen)) {
+              dprint (3,
+                      (debugfile, "browse_get_namespace: adding %s\n", ns));
+              nsi->type = type;
+              /* Cyrus doesn't append the delimiter to the namespace,
+               * but UW-IMAP does. We'll strip it here and add it back
+               * as if it were a normal directory, from the browser */
+              if (n && (ns[n - 1] == delim))
+                ns[--n] = '\0';
+              strncpy (nsbuf + nsbused, ns, nsblen - nsbused - 1);
+              nsi->prefix = nsbuf + nsbused;
+              nsbused += n + 1;
+              nsi->delim = delim;
+              nsi++;
+              (*nns)++;
+            }
+            while (*s && *s != ')')
+              s++;
+            if (*s)
+              s++;
+          }
+        }
       }
     }
   }
@@ -568,36 +547,34 @@ static int browse_get_namespace (IMAP_DATA* idata, char* nsbuf, int nsblen,
 }
 
 /* Check which namespaces have contents */
-static int browse_verify_namespace (IMAP_DATA* idata,
-  IMAP_NAMESPACE_INFO *nsi, int nns)
+static int browse_verify_namespace (IMAP_DATA * idata,
+                                    IMAP_NAMESPACE_INFO * nsi, int nns)
 {
   char buf[LONG_STRING];
   int i = 0;
   char *name;
   char delim;
 
-  for (i = 0; i < nns; i++, nsi++)
-  {
+  for (i = 0; i < nns; i++, nsi++) {
     /* Cyrus gives back nothing if the % isn't added. This may return lots
      * of data in some cases, I guess, but I currently feel that's better
      * than invisible namespaces */
     if (nsi->delim)
       snprintf (buf, sizeof (buf), "%s \"\" \"%s%c%%\"",
-               option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix,
-               nsi->delim);
+                option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix,
+                nsi->delim);
     else
       snprintf (buf, sizeof (buf), "%s \"\" \"%s%%\"",
-               option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix);
+                option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix);
 
     imap_cmd_start (idata, buf);
 
     nsi->listable = 0;
     nsi->home_namespace = 0;
-    do 
-    {
-      if (imap_parse_list_response(idata, &name, &nsi->noselect,
-          &nsi->noinferiors, &delim) != 0)
-       return -1;
+    do {
+      if (imap_parse_list_response (idata, &name, &nsi->noselect,
+                                    &nsi->noinferiors, &delim) != 0)
+        return -1;
       nsi->listable |= (name != NULL);
     }
     while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0));
@@ -605,4 +582,3 @@ static int browse_verify_namespace (IMAP_DATA* idata,
 
   return 0;
 }
-
index 141af12..d52fb27 100644 (file)
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* command.c: routines for sending commands to an IMAP server and parsing
  *  responses */
 #define IMAP_CMD_BUFSIZE 512
 
 /* forward declarations */
-static void cmd_handle_fatal (IMAP_DATA* idata);
-static int cmd_handle_untagged (IMAP_DATA* idata);
-static void cmd_make_sequence (IMAP_DATA* idata);
-static void cmd_parse_capabilities (IMAP_DATA* idata, char* s);
-static void cmd_parse_expunge (IMAP_DATA* idata, const char* s);
-static void cmd_parse_fetch (IMAP_DATA* idata, char* s);
-static void cmd_parse_myrights (IMAP_DATA* idata, char* s);
+static void cmd_handle_fatal (IMAP_DATA * idata);
+static int cmd_handle_untagged (IMAP_DATA * idata);
+static void cmd_make_sequence (IMAP_DATA * idata);
+static void cmd_parse_capabilities (IMAP_DATA * idata, char *s);
+static void cmd_parse_expunge (IMAP_DATA * idata, const char *s);
+static void cmd_parse_fetch (IMAP_DATA * idata, char *s);
+static void cmd_parse_myrights (IMAP_DATA * idata, char *s);
 
 static char *Capabilities[] = {
   "IMAP4",
   "IMAP4rev1",
   "STATUS",
-  "ACL", 
+  "ACL",
   "NAMESPACE",
   "AUTH=CRAM-MD5",
   "AUTH=GSSAPI",
@@ -62,14 +62,13 @@ static char *Capabilities[] = {
 /* imap_cmd_start: Given an IMAP command, send it to the server.
  *   Currently a minor convenience, but helps to route all IMAP commands
  *   through a single interface. */
-int imap_cmd_start (IMAP_DATA* idata, const char* cmd)
+int imap_cmd_start (IMAP_DATA * idata, const char *cmd)
 {
-  charout;
+  char *out;
   int outlen;
   int rc;
 
-  if (idata->status == IMAP_FATAL)
-  {
+  if (idata->status == IMAP_FATAL) {
     cmd_handle_fatal (idata);
     return IMAP_CMD_BAD;
   }
@@ -77,7 +76,7 @@ int imap_cmd_start (IMAP_DATA* idata, const char* cmd)
   cmd_make_sequence (idata);
   /* seq, space, cmd, \r\n\0 */
   outlen = strlen (idata->cmd.seq) + strlen (cmd) + 4;
-  out = (char*) safe_malloc (outlen);
+  out = (char *) safe_malloc (outlen);
   snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd);
 
   rc = mutt_socket_write (idata->conn, out);
@@ -91,34 +90,31 @@ int imap_cmd_start (IMAP_DATA* idata, const char* cmd)
  *   tagged completion response, handles untagged messages, can read
  *   arbitrarily large strings (using malloc, so don't make it _too_
  *   large!). */
-int imap_cmd_step (IMAP_DATA* idata)
+int imap_cmd_step (IMAP_DATA * idata)
 {
-  IMAP_COMMANDcmd = &idata->cmd;
+  IMAP_COMMAND *cmd = &idata->cmd;
   unsigned int len = 0;
   int c;
 
-  if (idata->status == IMAP_FATAL)
-  {
+  if (idata->status == IMAP_FATAL) {
     cmd_handle_fatal (idata);
     return IMAP_CMD_BAD;
   }
 
   /* read into buffer, expanding buffer as necessary until we have a full
    * line */
-  do
-  {
-    if (len == cmd->blen)
-    {
+  do {
+    if (len == cmd->blen) {
       safe_realloc (&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE);
       cmd->blen = cmd->blen + IMAP_CMD_BUFSIZE;
       dprint (3, (debugfile, "imap_cmd_step: grew buffer to %u bytes\n",
-                 cmd->blen));
+                  cmd->blen));
     }
 
     c = mutt_socket_readln (cmd->buf + len, cmd->blen - len, idata->conn);
-    if (c <= 0)
-    {
-      dprint (1, (debugfile, "imap_cmd_step: Error reading server response.\n"));
+    if (c <= 0) {
+      dprint (1,
+              (debugfile, "imap_cmd_step: Error reading server response.\n"));
       /* cmd_handle_fatal (idata); */
       return IMAP_CMD_BAD;
     }
@@ -131,29 +127,27 @@ int imap_cmd_step (IMAP_DATA* idata)
   while (len == cmd->blen);
 
   /* don't let one large string make cmd->buf hog memory forever */
-  if ((cmd->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE))
-  {
+  if ((cmd->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) {
     safe_realloc (&cmd->buf, IMAP_CMD_BUFSIZE);
     cmd->blen = IMAP_CMD_BUFSIZE;
-    dprint (3, (debugfile, "imap_cmd_step: shrank buffer to %u bytes\n", cmd->blen));
+    dprint (3,
+            (debugfile, "imap_cmd_step: shrank buffer to %u bytes\n",
+             cmd->blen));
   }
 
-  idata->lastread = time(NULL);
+  idata->lastread = time (NULL);
 
   /* handle untagged messages. The caller still gets its shot afterwards. */
-  if (!ascii_strncmp (cmd->buf, "* ", 2) &&
-      cmd_handle_untagged (idata))
+  if (!ascii_strncmp (cmd->buf, "* ", 2) && cmd_handle_untagged (idata))
     return IMAP_CMD_BAD;
 
   /* server demands a continuation response from us */
-  if (!ascii_strncmp (cmd->buf, "+ ", 2))
-  {
+  if (!ascii_strncmp (cmd->buf, "+ ", 2)) {
     return IMAP_CMD_RESPOND;
   }
 
   /* tagged completion code */
-  if (!ascii_strncmp (cmd->buf, cmd->seq, SEQLEN))
-  {
+  if (!ascii_strncmp (cmd->buf, cmd->seq, SEQLEN)) {
     imap_cmd_finish (idata);
     return imap_code (cmd->buf) ? IMAP_CMD_OK : IMAP_CMD_NO;
   }
@@ -177,14 +171,13 @@ int imap_code (const char *s)
  *   IMAP_CMD_PASS: command contains a password. Suppress logging.
  * Return 0 on success, -1 on Failure, -2 on OK Failure
  */
-int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
+int imap_exec (IMAP_DATA * idata, const char *cmd, int flags)
 {
-  charout;
+  char *out;
   int outlen;
   int rc;
 
-  if (idata->status == IMAP_FATAL)
-  {
+  if (idata->status == IMAP_FATAL) {
     cmd_handle_fatal (idata);
     return -1;
   }
@@ -193,15 +186,15 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
   cmd_make_sequence (idata);
   /* seq, space, cmd, \r\n\0 */
   outlen = strlen (idata->cmd.seq) + strlen (cmd) + 4;
-  out = (char*) safe_malloc (outlen);
+  out = (char *) safe_malloc (outlen);
   snprintf (out, outlen, "%s %s\r\n", idata->cmd.seq, cmd);
 
   rc = mutt_socket_write_d (idata->conn, out,
-    flags & IMAP_CMD_PASS ? IMAP_LOG_PASS : IMAP_LOG_CMD);
+                            flags & IMAP_CMD_PASS ? IMAP_LOG_PASS :
+                            IMAP_LOG_CMD);
   FREE (&out);
 
-  if (rc < 0)
-  {
+  if (rc < 0) {
     cmd_handle_fatal (idata);
     return -1;
   }
@@ -211,7 +204,7 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
   while (rc == IMAP_CMD_CONTINUE);
 
   if (rc == IMAP_CMD_BAD) {
-    if (imap_reconnect(idata->ctx)!=0) {
+    if (imap_reconnect (idata->ctx) != 0) {
       return -1;
     }
     return 0;
@@ -220,12 +213,12 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
   if (rc == IMAP_CMD_NO && (flags & IMAP_CMD_FAIL_OK))
     return -2;
 
-  if (rc != IMAP_CMD_OK)
-  {
+  if (rc != IMAP_CMD_OK) {
     if (flags & IMAP_CMD_FAIL_OK)
       return -2;
 
-    dprint (1, (debugfile, "imap_exec: command failed: %s\n", idata->cmd.buf));
+    dprint (1,
+            (debugfile, "imap_exec: command failed: %s\n", idata->cmd.buf));
     return -1;
   }
 
@@ -233,7 +226,7 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
 }
 
 /* imap_cmd_running: Returns whether an IMAP command is in progress. */
-int imap_cmd_running (IMAP_DATA* idata)
+int imap_cmd_running (IMAP_DATA * idata)
 {
   if (idata->cmd.state == IMAP_CMD_CONTINUE ||
       idata->cmd.state == IMAP_CMD_RESPOND)
@@ -246,42 +239,38 @@ int imap_cmd_running (IMAP_DATA* idata)
  *   detected, do expunge). Called automatically by imap_cmd_step, but
  *   may be called at any time. Called by imap_check_mailbox just before
  *   the index is refreshed, for instance. */
-void imap_cmd_finish (IMAP_DATA* idata)
+void imap_cmd_finish (IMAP_DATA * idata)
 {
-  if (idata->status == IMAP_FATAL)
-  {
+  if (idata->status == IMAP_FATAL) {
     cmd_handle_fatal (idata);
     return;
   }
 
   if (!(idata->state == IMAP_SELECTED) || idata->ctx->closing)
     return;
-  
-  if (idata->reopen & IMAP_REOPEN_ALLOW)
-  {
+
+  if (idata->reopen & IMAP_REOPEN_ALLOW) {
     int count = idata->newMailCount;
 
     if (!(idata->reopen & IMAP_EXPUNGE_PENDING) &&
-       (idata->reopen & IMAP_NEWMAIL_PENDING)
-       && count > idata->ctx->msgcount)
-    {
+        (idata->reopen & IMAP_NEWMAIL_PENDING)
+        && count > idata->ctx->msgcount) {
       /* read new mail messages */
       dprint (2, (debugfile, "imap_cmd_finish: Fetching new mail\n"));
       /* check_status: curs_main uses imap_check_mailbox to detect
        *   whether the index needs updating */
       idata->check_status = IMAP_NEWMAIL_PENDING;
-      imap_read_headers (idata, idata->ctx->msgcount, count-1);
+      imap_read_headers (idata, idata->ctx->msgcount, count - 1);
     }
-    else if (idata->reopen & IMAP_EXPUNGE_PENDING)
-    {
+    else if (idata->reopen & IMAP_EXPUNGE_PENDING) {
       dprint (2, (debugfile, "imap_cmd_finish: Expunging mailbox\n"));
       imap_expunge_mailbox (idata);
       /* Detect whether we've gotten unexpected EXPUNGE messages */
       if (idata->reopen & IMAP_EXPUNGE_PENDING &&
-         !(idata->reopen & IMAP_EXPUNGE_EXPECTED))
-       idata->check_status = IMAP_EXPUNGE_PENDING;
+          !(idata->reopen & IMAP_EXPUNGE_EXPECTED))
+        idata->check_status = IMAP_EXPUNGE_PENDING;
       idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_NEWMAIL_PENDING |
-                        IMAP_EXPUNGE_EXPECTED);
+                         IMAP_EXPUNGE_EXPECTED);
     }
   }
 
@@ -289,78 +278,71 @@ void imap_cmd_finish (IMAP_DATA* idata)
 }
 
 /* cmd_handle_fatal: when IMAP_DATA is in fatal state, do what we can */
-static void cmd_handle_fatal (IMAP_DATA* idata)
+static void cmd_handle_fatal (IMAP_DATA * idata)
 {
   idata->status = IMAP_FATAL;
 
   if ((idata->state == IMAP_SELECTED) &&
-      (idata->reopen & IMAP_REOPEN_ALLOW) &&
-      !idata->ctx->closing)
-  {
-    /*mx_fastclose_mailbox (idata->ctx);*/
+      (idata->reopen & IMAP_REOPEN_ALLOW) && !idata->ctx->closing) {
+    /*mx_fastclose_mailbox (idata->ctx); */
     mutt_error (_("Mailbox closed"));
     mutt_sleep (1);
     idata->state = IMAP_DISCONNECTED;
-    if (imap_reconnect(idata->ctx)!=0)
-      mx_fastclose_mailbox(idata->ctx);
+    if (imap_reconnect (idata->ctx) != 0)
+      mx_fastclose_mailbox (idata->ctx);
   }
 
-  if (idata->state != IMAP_SELECTED)
-  {
+  if (idata->state != IMAP_SELECTED) {
     idata->state = IMAP_DISCONNECTED;
     idata->status = 0;
   }
 }
 
 /* cmd_handle_untagged: fallback parser for otherwise unhandled messages. */
-static int cmd_handle_untagged (IMAP_DATA* idata)
+static int cmd_handle_untagged (IMAP_DATA * idata)
 {
-  chars;
-  charpn;
+  char *s;
+  char *pn;
   int count;
 
   s = imap_next_word (idata->cmd.buf);
 
-  if ((idata->state == IMAP_SELECTED) && isdigit ((unsigned char) *s))
-  {
+  if ((idata->state == IMAP_SELECTED) && isdigit ((unsigned char) *s)) {
     pn = s;
     s = imap_next_word (s);
 
     /* EXISTS and EXPUNGE are always related to the SELECTED mailbox for the
      * connection, so update that one.
      */
-    if (ascii_strncasecmp ("EXISTS", s, 6) == 0)
-    {
+    if (ascii_strncasecmp ("EXISTS", s, 6) == 0) {
       dprint (2, (debugfile, "Handling EXISTS\n"));
 
       /* new mail arrived */
       count = atoi (pn);
 
-      if ( !(idata->reopen & IMAP_EXPUNGE_PENDING) &&
-          count < idata->ctx->msgcount)
-      {
-       /* something is wrong because the server reported fewer messages
-        * than we previously saw
-        */
-       mutt_error _("Fatal error.  Message count is out of sync!");
-       idata->status = IMAP_FATAL;
-       return -1;
+      if (!(idata->reopen & IMAP_EXPUNGE_PENDING) &&
+          count < idata->ctx->msgcount) {
+        /* something is wrong because the server reported fewer messages
+         * than we previously saw
+         */
+        mutt_error _("Fatal error.  Message count is out of sync!");
+
+        idata->status = IMAP_FATAL;
+        return -1;
       }
       /* at least the InterChange server sends EXISTS messages freely,
        * even when there is no new mail */
       else if (count == idata->ctx->msgcount)
-       dprint (3, (debugfile,
-          "cmd_handle_untagged: superfluous EXISTS message.\n"));
-      else
-      {
-       if (!(idata->reopen & IMAP_EXPUNGE_PENDING))
-        {
+        dprint (3, (debugfile,
+                    "cmd_handle_untagged: superfluous EXISTS message.\n"));
+      else {
+        if (!(idata->reopen & IMAP_EXPUNGE_PENDING)) {
           dprint (2, (debugfile,
-            "cmd_handle_untagged: New mail in %s - %d messages total.\n",
-            idata->mailbox, count));
-         idata->reopen |= IMAP_NEWMAIL_PENDING;
+                      "cmd_handle_untagged: New mail in %s - %d messages total.\n",
+                      idata->mailbox, count));
+          idata->reopen |= IMAP_NEWMAIL_PENDING;
         }
-       idata->newMailCount = count;
+        idata->newMailCount = count;
       }
     }
     /* pn vs. s: need initial seqno */
@@ -373,8 +355,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata)
     cmd_parse_capabilities (idata, s);
   else if (ascii_strncasecmp ("MYRIGHTS", s, 8) == 0)
     cmd_parse_myrights (idata, s);
-  else if (ascii_strncasecmp ("BYE", s, 3) == 0)
-  {
+  else if (ascii_strncasecmp ("BYE", s, 3) == 0) {
     dprint (2, (debugfile, "Handling BYE\n"));
 
     /* check if we're logging out */
@@ -388,21 +369,21 @@ static int cmd_handle_untagged (IMAP_DATA* idata)
     idata->status = IMAP_BYE;
 
     /*if (imap_reconnect(idata->ctx)!=0) {
-        if (idata->state == IMAP_SELECTED)
-        mx_fastclose_mailbox (idata->ctx); */ /* XXX memleak? */
-      mutt_socket_close (idata->conn);
-      idata->state = IMAP_DISCONNECTED;
-      return -1;
+       if (idata->state == IMAP_SELECTED)
+       mx_fastclose_mailbox (idata->ctx); *//* XXX memleak? */
+    mutt_socket_close (idata->conn);
+    idata->state = IMAP_DISCONNECTED;
+    return -1;
     /*} else {
-        return 0;
-      } */
+       return 0;
+       } */
   }
-  else if (option (OPTIMAPSERVERNOISE) && (ascii_strncasecmp ("NO", s, 2) == 0))
-  {
+  else if (option (OPTIMAPSERVERNOISE)
+           && (ascii_strncasecmp ("NO", s, 2) == 0)) {
     dprint (2, (debugfile, "Handling untagged NO\n"));
 
     /* Display the warning message from the server */
-    mutt_error ("%s", s+3);
+    mutt_error ("%s", s + 3);
     mutt_sleep (2);
   }
 
@@ -410,7 +391,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata)
 }
 
 /* cmd_make_sequence: make a tag suitable for starting an IMAP command */
-static void cmd_make_sequence (IMAP_DATA* idata)
+static void cmd_make_sequence (IMAP_DATA * idata)
 {
   snprintf (idata->cmd.seq, sizeof (idata->cmd.seq), "a%04u", idata->seqno++);
 
@@ -420,25 +401,23 @@ static void cmd_make_sequence (IMAP_DATA* idata)
 
 /* cmd_parse_capabilities: set capability bits according to CAPABILITY
  *   response */
-static void cmd_parse_capabilities (IMAP_DATA* idata, char* s)
+static void cmd_parse_capabilities (IMAP_DATA * idata, char *s)
 {
   int x;
 
   dprint (2, (debugfile, "Handling CAPABILITY\n"));
 
   s = imap_next_word (s);
-  FREE(&idata->capstr);
+  FREE (&idata->capstr);
   idata->capstr = safe_strdup (s);
 
   memset (idata->capabilities, 0, sizeof (idata->capabilities));
 
-  while (*s)
-  {
+  while (*s) {
     for (x = 0; x < CAPMAX; x++)
-      if (imap_wordcasecmp(Capabilities[x], s) == 0)
-      {
-       mutt_bit_set (idata->capabilities, x);
-       break;
+      if (imap_wordcasecmp (Capabilities[x], s) == 0) {
+        mutt_bit_set (idata->capabilities, x);
+        break;
       }
     s = imap_next_word (s);
   }
@@ -446,10 +425,10 @@ static void cmd_parse_capabilities (IMAP_DATA* idata, char* s)
 
 /* cmd_parse_expunge: mark headers with new sequence ID and mark idata to
  *   be reopened at our earliest convenience */
-static void cmd_parse_expunge (IMAP_DATA* idata, const char* s)
+static void cmd_parse_expunge (IMAP_DATA * idata, const char *s)
 {
   int expno, cur;
-  HEADERh;
+  HEADER *h;
 
   dprint (2, (debugfile, "Handling EXPUNGE\n"));
 
@@ -459,13 +438,12 @@ static void cmd_parse_expunge (IMAP_DATA* idata, const char* s)
    * above. Possibly we could avoid walking the whole list by resorting
    * and guessing a good starting point, but I'm guessing the resort would
    * nullify the gains */
-  for (cur = 0; cur < idata->ctx->msgcount; cur++)
-  {
+  for (cur = 0; cur < idata->ctx->msgcount; cur++) {
     h = idata->ctx->hdrs[cur];
 
-    if (h->index+1 == expno)
+    if (h->index + 1 == expno)
       h->index = -1;
-    else if (h->index+1 > expno)
+    else if (h->index + 1 > expno)
       h->index--;
   }
 
@@ -476,49 +454,46 @@ static void cmd_parse_expunge (IMAP_DATA* idata, const char* s)
  *   handles unanticipated FETCH responses, and only FLAGS data. We get
  *   these if another client has changed flags for a mailbox we've selected.
  *   Of course, a lot of code here duplicates code in message.c. */
-static void cmd_parse_fetch (IMAP_DATA* idata, char* s)
+static void cmd_parse_fetch (IMAP_DATA * idata, char *s)
 {
   int msgno, cur;
-  HEADERh = NULL;
+  HEADER *h = NULL;
 
   dprint (2, (debugfile, "Handling FETCH\n"));
 
   msgno = atoi (s);
-  
+
   if (msgno <= idata->ctx->msgcount)
-  /* see cmd_parse_expunge */
-    for (cur = 0; cur < idata->ctx->msgcount; cur++)
-    {
+    /* see cmd_parse_expunge */
+    for (cur = 0; cur < idata->ctx->msgcount; cur++) {
       h = idata->ctx->hdrs[cur];
-      
-      if (h->active && h->index+1 == msgno)
-      {
-       dprint (2, (debugfile, "Message UID %d updated\n", HEADER_DATA(h)->uid));
-       break;
+
+      if (h->active && h->index + 1 == msgno) {
+        dprint (2,
+                (debugfile, "Message UID %d updated\n",
+                 HEADER_DATA (h)->uid));
+        break;
       }
-      
+
       h = NULL;
     }
-  
-  if (!h)
-  {
+
+  if (!h) {
     dprint (1, (debugfile, "FETCH response ignored for this message\n"));
     return;
   }
-  
+
   /* skip FETCH */
   s = imap_next_word (s);
   s = imap_next_word (s);
 
-  if (*s != '(')
-  {
+  if (*s != '(') {
     dprint (1, (debugfile, "Malformed FETCH response"));
     return;
   }
   s++;
 
-  if (ascii_strncasecmp ("FLAGS", s, 5) != 0)
-  {
+  if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
     dprint (2, (debugfile, "Only handle FLAGS updates\n"));
     return;
   }
@@ -533,7 +508,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s)
 }
 
 /* cmd_parse_myrights: set rights bits according to MYRIGHTS response */
-static void cmd_parse_myrights (IMAP_DATA* idata, char* s)
+static void cmd_parse_myrights (IMAP_DATA * idata, char *s)
 {
   dprint (2, (debugfile, "Handling MYRIGHTS\n"));
 
@@ -543,37 +518,35 @@ static void cmd_parse_myrights (IMAP_DATA* idata, char* s)
   /* zero out current rights set */
   memset (idata->rights, 0, sizeof (idata->rights));
 
-  while (*s && !isspace((unsigned char) *s))
-  {
-    switch (*s) 
-    {
-      case 'l':
-       mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
-       break;
-      case 'r':
-       mutt_bit_set (idata->rights, IMAP_ACL_READ);
-       break;
-      case 's':
-       mutt_bit_set (idata->rights, IMAP_ACL_SEEN);
-       break;
-      case 'w':
-       mutt_bit_set (idata->rights, IMAP_ACL_WRITE);
-       break;
-      case 'i':
-       mutt_bit_set (idata->rights, IMAP_ACL_INSERT);
-       break;
-      case 'p':
-       mutt_bit_set (idata->rights, IMAP_ACL_POST);
-       break;
-      case 'c':
-       mutt_bit_set (idata->rights, IMAP_ACL_CREATE);
-       break;
-      case 'd':
-       mutt_bit_set (idata->rights, IMAP_ACL_DELETE);
-       break;
-      case 'a':
-       mutt_bit_set (idata->rights, IMAP_ACL_ADMIN);
-       break;
+  while (*s && !isspace ((unsigned char) *s)) {
+    switch (*s) {
+    case 'l':
+      mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
+      break;
+    case 'r':
+      mutt_bit_set (idata->rights, IMAP_ACL_READ);
+      break;
+    case 's':
+      mutt_bit_set (idata->rights, IMAP_ACL_SEEN);
+      break;
+    case 'w':
+      mutt_bit_set (idata->rights, IMAP_ACL_WRITE);
+      break;
+    case 'i':
+      mutt_bit_set (idata->rights, IMAP_ACL_INSERT);
+      break;
+    case 'p':
+      mutt_bit_set (idata->rights, IMAP_ACL_POST);
+      break;
+    case 'c':
+      mutt_bit_set (idata->rights, IMAP_ACL_CREATE);
+      break;
+    case 'd':
+      mutt_bit_set (idata->rights, IMAP_ACL_DELETE);
+      break;
+    case 'a':
+      mutt_bit_set (idata->rights, IMAP_ACL_ADMIN);
+      break;
     }
     s++;
   }
index a9552ce..270f137 100644 (file)
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* Support for IMAP4rev1, with the occasional nod to IMAP 4. */
 
 #include <sys/stat.h>
 
 /* imap forward declarations */
-static int imap_get_delim (IMAP_DATA *idata);
-static char* imap_get_flags (LIST** hflags, char* s);
-static int imap_check_acl (IMAP_DATA *idata);
-static int imap_check_capabilities (IMAP_DATA* idata);
-static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag,
-                          const char* str, char* flags, size_t flsize);
+static int imap_get_delim (IMAP_DATA * idata);
+static char *imap_get_flags (LIST ** hflags, char *s);
+static int imap_check_acl (IMAP_DATA * idata);
+static int imap_check_capabilities (IMAP_DATA * idata);
+static void imap_set_flag (IMAP_DATA * idata, int aclbit, int flag,
+                           const char *str, char *flags, size_t flsize);
 
 /* imap_access: Check permissions on an IMAP mailbox. */
-int imap_access (const charpath, int flags)
+int imap_access (const char *path, int flags)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   IMAP_MBOX mx;
   char buf[LONG_STRING];
   char mailbox[LONG_STRING];
@@ -65,8 +65,8 @@ int imap_access (const char* path, int flags)
     return -1;
 
   if (!(idata = imap_conn_find (&mx.account,
-    option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0)))
-  {
+                                option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW :
+                                0))) {
     FREE (&mx.mbox);
     return -1;
   }
@@ -80,14 +80,12 @@ int imap_access (const char* path, int flags)
     snprintf (buf, sizeof (buf), "STATUS %s (UIDVALIDITY)", mbox);
   else if (mutt_bit_isset (idata->capabilities, STATUS))
     snprintf (buf, sizeof (buf), "STATUS %s (UID-VALIDITY)", mbox);
-  else
-  {
+  else {
     dprint (2, (debugfile, "imap_access: STATUS not supported?\n"));
     return -1;
   }
 
-  if (imap_exec (idata, buf, IMAP_CMD_FAIL_OK) < 0)
-  {
+  if (imap_exec (idata, buf, IMAP_CMD_FAIL_OK) < 0) {
     dprint (1, (debugfile, "imap_access: Can't check STATUS of %s\n", mbox));
     return -1;
   }
@@ -95,20 +93,21 @@ int imap_access (const char* path, int flags)
   return 0;
 }
 
-int imap_create_mailbox (IMAP_DATA* idata, char* mailbox)
+int imap_create_mailbox (IMAP_DATA * idata, char *mailbox)
 {
   char buf[LONG_STRING], mbox[LONG_STRING];
 
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
   snprintf (buf, sizeof (buf), "CREATE %s", mbox);
-      
+
   if (imap_exec (idata, buf, 0) != 0)
     return -1;
 
   return 0;
 }
 
-int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname)
+int imap_rename_mailbox (IMAP_DATA * idata, IMAP_MBOX * mx,
+                         const char *newname)
 {
   char oldmbox[LONG_STRING];
   char newmbox[LONG_STRING];
@@ -125,26 +124,27 @@ int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname)
   return 0;
 }
 
-int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
+int imap_delete_mailbox (CONTEXT * ctx, IMAP_MBOX mx)
 {
   char buf[LONG_STRING], mbox[LONG_STRING];
   IMAP_DATA *idata;
 
   if (!ctx || !ctx->data) {
     if (!(idata = imap_conn_find (&mx.account,
-          option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW : 0)))
-    {
+                                  option (OPTIMAPPASSIVE) ? M_IMAP_CONN_NONEW
+                                  : 0))) {
       FREE (&mx.mbox);
       return -1;
     }
-  } else {
+  }
+  else {
     idata = ctx->data;
   }
 
   imap_munge_mbox_name (mbox, sizeof (mbox), mx.mbox);
   snprintf (buf, sizeof (buf), "DELETE %s", mbox);
 
-  if (imap_exec ((IMAP_DATA*) idata, buf, 0) != 0)
+  if (imap_exec ((IMAP_DATA *) idata, buf, 0) != 0)
     return -1;
 
   return 0;
@@ -152,21 +152,19 @@ int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
 
 /* imap_logout_all: close all open connections. Quick and dirty until we can
  *   make sure we've got all the context we need. */
-void imap_logout_all (void) 
+void imap_logout_all (void)
 {
-  CONNECTIONconn;
-  CONNECTIONtmp;
+  CONNECTION *conn;
+  CONNECTION *tmp;
 
   conn = mutt_socket_head ();
 
-  while (conn)
-  {
+  while (conn) {
     tmp = conn->next;
 
-    if (conn->account.type == M_ACCT_TYPE_IMAP && conn->fd >= 0)
-    {
+    if (conn->account.type == M_ACCT_TYPE_IMAP && conn->fd >= 0) {
       mutt_message (_("Closing connection to %s..."), conn->account.host);
-      imap_logout ((IMAP_DATA*) conn->data);
+      imap_logout ((IMAP_DATA *) conn->data);
       mutt_clear_error ();
       mutt_socket_close (conn);
       mutt_socket_free (conn);
@@ -179,7 +177,7 @@ void imap_logout_all (void)
 /* imap_read_literal: read bytes bytes from server into file. Not explicitly
  *   buffered, relies on FILE buffering. NOTE: strips \r from \r\n.
  *   Apparently even literals use \r\n-terminated strings ?! */
-int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
+int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes)
 {
   long pos;
   char c;
@@ -187,14 +185,15 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
   int r = 0;
 
   dprint (2, (debugfile, "imap_read_literal: reading %ld bytes\n", bytes));
-  for (pos = 0; pos < bytes; pos++)
-  {
-    if (mutt_socket_readchar (idata->conn, &c) != 1)
-    {
-      dprint (1, (debugfile, "imap_read_literal: error during read, %ld bytes read\n", pos));
+
+  for (pos = 0; pos < bytes; pos++) {
+    if (mutt_socket_readchar (idata->conn, &c) != 1) {
+      dprint (1,
+              (debugfile,
+               "imap_read_literal: error during read, %ld bytes read\n",
+               pos));
       idata->status = IMAP_FATAL;
-      
+
       return -1;
     }
 
@@ -202,8 +201,7 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
     if (r == 1 && c != '\n')
       fputc ('\r', fp);
 
-    if (c == '\r')
-    {
+    if (c == '\r') {
       r = 1;
       continue;
     }
@@ -223,28 +221,27 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
 /* imap_expunge_mailbox: Purge IMAP portion of expunged messages from the
  *   context. Must not be done while something has a handle on any headers
  *   (eg inside pager or editor). That is, check IMAP_REOPEN_ALLOW. */
-void imap_expunge_mailbox (IMAP_DATA* idata)
+void imap_expunge_mailbox (IMAP_DATA * idata)
 {
-  HEADERh;
+  HEADER *h;
   int i, cacheno;
 
-  for (i = 0; i < idata->ctx->msgcount; i++)
-  {
+  for (i = 0; i < idata->ctx->msgcount; i++) {
     h = idata->ctx->hdrs[i];
 
-    if (h->index == -1)
-    {
-      dprint (2, (debugfile, "Expunging message UID %d.\n", HEADER_DATA (h)->uid));
+    if (h->index == -1) {
+      dprint (2,
+              (debugfile, "Expunging message UID %d.\n",
+               HEADER_DATA (h)->uid));
 
       h->active = 0;
 
       /* free cached body from disk, if neccessary */
-      cacheno = HEADER_DATA(h)->uid % IMAP_CACHE_LEN;
-      if (idata->cache[cacheno].uid == HEADER_DATA(h)->uid &&
-         idata->cache[cacheno].path)
-      {
-       unlink (idata->cache[cacheno].path);
-       FREE (&idata->cache[cacheno].path);
+      cacheno = HEADER_DATA (h)->uid % IMAP_CACHE_LEN;
+      if (idata->cache[cacheno].uid == HEADER_DATA (h)->uid &&
+          idata->cache[cacheno].path) {
+        unlink (idata->cache[cacheno].path);
+        FREE (&idata->cache[cacheno].path);
       }
 
       imap_free_header_data (&h->data);
@@ -257,7 +254,7 @@ void imap_expunge_mailbox (IMAP_DATA* idata)
   mutt_sort_headers (idata->ctx, 1);
 }
 
-static int imap_get_delim (IMAP_DATA *idata)
+static int imap_get_delim (IMAP_DATA * idata)
 {
   char *s;
   int rc;
@@ -268,26 +265,24 @@ static int imap_get_delim (IMAP_DATA *idata)
 
   imap_cmd_start (idata, "LIST \"\" \"\"");
 
-  do 
-  {
+  do {
     if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
       break;
 
     s = imap_next_word (idata->cmd.buf);
-    if (ascii_strncasecmp ("LIST", s, 4) == 0)
-    {
+    if (ascii_strncasecmp ("LIST", s, 4) == 0) {
       s = imap_next_word (s);
       s = imap_next_word (s);
       if (s && s[0] == '\"' && s[1] && s[2] == '\"')
-       idata->delim = s[1];
-      else if (s && s[0] == '\"' && s[1] && s[1] == '\\' && s[2] && s[3] == '\"')
-       idata->delim = s[2];
+        idata->delim = s[1];
+      else if (s && s[0] == '\"' && s[1] && s[1] == '\\' && s[2]
+               && s[3] == '\"')
+        idata->delim = s[2];
     }
   }
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_OK)
-  {
+  if (rc != IMAP_CMD_OK) {
     dprint (1, (debugfile, "imap_get_delim: failed.\n"));
     return -1;
   }
@@ -298,15 +293,14 @@ static int imap_get_delim (IMAP_DATA *idata)
 }
 
 /* get rights for folder, let imap_handle_untagged do the rest */
-static int imap_check_acl (IMAP_DATA *idata)
+static int imap_check_acl (IMAP_DATA * idata)
 {
   char buf[LONG_STRING];
   char mbox[LONG_STRING];
 
-  imap_munge_mbox_name (mbox, sizeof(mbox), idata->mailbox);
+  imap_munge_mbox_name (mbox, sizeof (mbox), idata->mailbox);
   snprintf (buf, sizeof (buf), "MYRIGHTS %s", mbox);
-  if (imap_exec (idata, buf, 0) != 0)
-  {
+  if (imap_exec (idata, buf, 0) != 0) {
     imap_error ("imap_check_acl", buf);
     return -1;
   }
@@ -314,19 +308,18 @@ static int imap_check_acl (IMAP_DATA *idata)
 }
 
 /* imap_check_capabilities: make sure we can log in to this server. */
-static int imap_check_capabilities (IMAP_DATA* idata)
+static int imap_check_capabilities (IMAP_DATA * idata)
 {
-  if (imap_exec (idata, "CAPABILITY", 0) != 0)
-  {
+  if (imap_exec (idata, "CAPABILITY", 0) != 0) {
     imap_error ("imap_check_capabilities", idata->cmd.buf);
     return -1;
   }
 
-  if (!(mutt_bit_isset(idata->capabilities,IMAP4)
-      ||mutt_bit_isset(idata->capabilities,IMAP4REV1)))
-  {
+  if (!(mutt_bit_isset (idata->capabilities, IMAP4)
+        || mutt_bit_isset (idata->capabilities, IMAP4REV1))) {
     mutt_error _("This IMAP server is ancient. Mutt does not work with it.");
-    mutt_sleep (2);    /* pause a moment to let the user see the error */
+
+    mutt_sleep (2);             /* pause a moment to let the user see the error */
 
     return -1;
   }
@@ -336,11 +329,11 @@ static int imap_check_capabilities (IMAP_DATA* idata)
 
 /* imap_conn_find: Find an open IMAP connection matching account, or open
  *   a new one if none can be found. */
-IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags)
+IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags)
 {
-  CONNECTIONconn;
-  IMAP_DATAidata;
-  ACCOUNTcreds;
+  CONNECTION *conn;
+  IMAP_DATA *idata;
+  ACCOUNT *creds;
 
   if (!(conn = mutt_conn_find (NULL, account)))
     return NULL;
@@ -350,32 +343,27 @@ IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags)
 
   /* make sure this connection is not in SELECTED state, if neccessary */
   if (flags & M_IMAP_CONN_NOSELECT)
-    while (conn->data && ((IMAP_DATA*) conn->data)->state == IMAP_SELECTED)
-    {
+    while (conn->data && ((IMAP_DATA *) conn->data)->state == IMAP_SELECTED) {
       if (!(conn = mutt_conn_find (conn, account)))
-       return NULL;
+        return NULL;
       memcpy (&(conn->account), creds, sizeof (ACCOUNT));
     }
-  
-  idata = (IMAP_DATA*) conn->data;
+
+  idata = (IMAP_DATA *) conn->data;
 
   /* don't open a new connection if one isn't wanted */
-  if (flags & M_IMAP_CONN_NONEW)
-  {
-    if (!idata)
-    {
+  if (flags & M_IMAP_CONN_NONEW) {
+    if (!idata) {
       mutt_socket_free (conn);
       return NULL;
     }
     if (idata->state < IMAP_AUTHENTICATED)
       return NULL;
   }
-  
-  if (!idata)
-  {
+
+  if (!idata) {
     /* The current connection is a new connection */
-    if (! (idata = imap_new_idata ()))
-    {
+    if (!(idata = imap_new_idata ())) {
       mutt_socket_free (conn);
       return NULL;
     }
@@ -386,27 +374,25 @@ IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags)
 
   if (idata->state == IMAP_DISCONNECTED)
     imap_open_connection (idata);
-  if (idata->state == IMAP_CONNECTED)
-  {
-    if (!imap_authenticate (idata))
-    {
+  if (idata->state == IMAP_CONNECTED) {
+    if (!imap_authenticate (idata)) {
       idata->state = IMAP_AUTHENTICATED;
       if (idata->conn->ssf)
-       dprint (2, (debugfile, "Communication encrypted at %d bits\n",
-                   idata->conn->ssf));
+        dprint (2, (debugfile, "Communication encrypted at %d bits\n",
+                    idata->conn->ssf));
     }
     else
       mutt_account_unsetpass (&idata->conn->account);
-    
+
     FREE (&idata->capstr);
   }
   if (idata->state == IMAP_AUTHENTICATED)
     imap_get_delim (idata);
-  
+
   return idata;
 }
 
-int imap_open_connection (IMAP_DATA* idata)
+int imap_open_connection (IMAP_DATA * idata)
 {
   char buf[LONG_STRING];
 
@@ -416,7 +402,8 @@ int imap_open_connection (IMAP_DATA* idata)
   idata->state = IMAP_CONNECTED;
 
   if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) {
-    mutt_error (_("Unexpected response received from server: %s"), idata->cmd.buf);
+    mutt_error (_("Unexpected response received from server: %s"),
+                idata->cmd.buf);
     mutt_sleep (1);
 
     mutt_socket_close (idata->conn);
@@ -424,101 +411,90 @@ int imap_open_connection (IMAP_DATA* idata)
     return -1;
   }
 
-  if (ascii_strncasecmp ("* OK", idata->cmd.buf, 4) == 0)
-  {
+  if (ascii_strncasecmp ("* OK", idata->cmd.buf, 4) == 0) {
     /* TODO: Parse new tagged CAPABILITY data (* OK [CAPABILITY...]) */
     if (imap_check_capabilities (idata))
       goto bail;
 #if defined(USE_SSL) || defined(USE_GNUTLS)
     /* Attempt STARTTLS if available and desired. */
-    if (mutt_bit_isset (idata->capabilities, STARTTLS) && !idata->conn->ssf)
-    {
+    if (mutt_bit_isset (idata->capabilities, STARTTLS) && !idata->conn->ssf) {
       int rc;
 
       if ((rc = query_quadoption (OPT_SSLSTARTTLS,
-        _("Secure connection with TLS?"))) == -1)
-       goto err_close_conn;
+                                  _("Secure connection with TLS?"))) == -1)
+        goto err_close_conn;
       if (rc == M_YES) {
-       if ((rc = imap_exec (idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1)
-         goto bail;
-       if (rc != -2)
-       {
+        if ((rc = imap_exec (idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1)
+          goto bail;
+        if (rc != -2) {
 #ifdef USE_SSL
-         if (mutt_ssl_starttls (idata->conn))
+          if (mutt_ssl_starttls (idata->conn))
 #elif USE_GNUTLS
-         if (mutt_gnutls_starttls (idata->conn))
+          if (mutt_gnutls_starttls (idata->conn))
 #endif
-         {
-           mutt_error (_("Could not negotiate TLS connection"));
-           mutt_sleep (1);
-           goto err_close_conn;
-         }
-         else
-         {
-           /* RFC 2595 demands we recheck CAPABILITY after TLS completes. */
-           if (imap_exec (idata, "CAPABILITY", 0))
-             goto bail;
-         }
-       }
+          {
+            mutt_error (_("Could not negotiate TLS connection"));
+            mutt_sleep (1);
+            goto err_close_conn;
+          }
+          else {
+            /* RFC 2595 demands we recheck CAPABILITY after TLS completes. */
+            if (imap_exec (idata, "CAPABILITY", 0))
+              goto bail;
+          }
+        }
       }
     }
-#endif    
+#endif
   }
-  else if (ascii_strncasecmp ("* PREAUTH", idata->cmd.buf, 9) == 0)
-  {
+  else if (ascii_strncasecmp ("* PREAUTH", idata->cmd.buf, 9) == 0) {
     idata->state = IMAP_AUTHENTICATED;
     if (imap_check_capabilities (idata) != 0)
       goto bail;
     FREE (&idata->capstr);
-  } 
-  else
-  {
+  }
+  else {
     imap_error ("imap_open_connection()", buf);
     goto bail;
   }
 
   return 0;
 
- err_close_conn:
+err_close_conn:
   mutt_socket_close (idata->conn);
   idata->state = IMAP_DISCONNECTED;
- bail:
+bail:
   FREE (&idata->capstr);
   return -1;
 }
 
 /* imap_get_flags: Make a simple list out of a FLAGS response.
  *   return stream following FLAGS response */
-static char* imap_get_flags (LIST** hflags, char* s)
+static char *imap_get_flags (LIST ** hflags, char *s)
 {
-  LISTflags;
-  charflag_word;
+  LIST *flags;
+  char *flag_word;
   char ctmp;
 
   /* sanity-check string */
-  if (ascii_strncasecmp ("FLAGS", s, 5) != 0)
-  {
-    dprint (1, (debugfile, "imap_get_flags: not a FLAGS response: %s\n",
-      s));
+  if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
+    dprint (1, (debugfile, "imap_get_flags: not a FLAGS response: %s\n", s));
     return NULL;
   }
   s += 5;
-  SKIPWS(s);
-  if (*s != '(')
-  {
-    dprint (1, (debugfile, "imap_get_flags: bogus FLAGS response: %s\n",
-      s));
+  SKIPWS (s);
+  if (*s != '(') {
+    dprint (1, (debugfile, "imap_get_flags: bogus FLAGS response: %s\n", s));
     return NULL;
   }
 
   /* create list, update caller's flags handle */
-  flags = mutt_new_list();
+  flags = mutt_new_list ();
   *hflags = flags;
 
-  while (*s && *s != ')')
-  {
+  while (*s && *s != ')') {
     s++;
-    SKIPWS(s);
+    SKIPWS (s);
     flag_word = s;
     while (*s && (*s != ')') && !ISSPACE (*s))
       s++;
@@ -530,10 +506,9 @@ static char* imap_get_flags (LIST** hflags, char* s)
   }
 
   /* note bad flags response */
-  if (*s != ')')
-  {
+  if (*s != ')') {
     dprint (1, (debugfile,
-      "imap_get_flags: Unterminated FLAGS response: %s\n", s));
+                "imap_get_flags: Unterminated FLAGS response: %s\n", s));
     mutt_free_list (hflags);
 
     return NULL;
@@ -544,7 +519,7 @@ static char* imap_get_flags (LIST** hflags, char* s)
   return s;
 }
 
-int imap_open_mailbox (CONTEXT* ctx)
+int imap_open_mailbox (CONTEXT * ctx)
 {
   CONNECTION *conn;
   IMAP_DATA *idata;
@@ -553,9 +528,8 @@ int imap_open_mailbox (CONTEXT* ctx)
   int count = 0;
   IMAP_MBOX mx;
   int rc;
-  
-  if (imap_parse_path (ctx->path, &mx))
-  {
+
+  if (imap_parse_path (ctx->path, &mx)) {
     mutt_error (_("%s is an invalid IMAP path"), ctx->path);
     return -1;
   }
@@ -573,7 +547,7 @@ int imap_open_mailbox (CONTEXT* ctx)
 
   /* Clean up path and replace the one in the ctx */
   imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
-  FREE(&(idata->mailbox));
+  FREE (&(idata->mailbox));
   idata->mailbox = safe_strdup (buf);
   imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox);
 
@@ -584,22 +558,21 @@ int imap_open_mailbox (CONTEXT* ctx)
 
   /* clear mailbox status */
   idata->status = 0;
-  memset (idata->rights, 0, (RIGHTSMAX+7)/8);
+  memset (idata->rights, 0, (RIGHTSMAX + 7) / 8);
   idata->newMailCount = 0;
 
   mutt_message (_("Selecting %s..."), idata->mailbox);
-  imap_munge_mbox_name (buf, sizeof(buf), idata->mailbox);
+  imap_munge_mbox_name (buf, sizeof (buf), idata->mailbox);
   snprintf (bufout, sizeof (bufout), "%s %s",
-    ctx->readonly ? "EXAMINE" : "SELECT", buf);
+            ctx->readonly ? "EXAMINE" : "SELECT", buf);
 
   idata->state = IMAP_SELECTED;
 
   imap_cmd_start (idata, bufout);
 
-  do
-  {
+  do {
     char *pc;
-    
+
     if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
       break;
 
@@ -607,55 +580,49 @@ int imap_open_mailbox (CONTEXT* ctx)
 
     /* Obtain list of available flags here, may be overridden by a
      * PERMANENTFLAGS tag in the OK response */
-    if (ascii_strncasecmp ("FLAGS", pc, 5) == 0)
-    {
+    if (ascii_strncasecmp ("FLAGS", pc, 5) == 0) {
       /* don't override PERMANENTFLAGS */
-      if (!idata->flags)
-      {
-       dprint (2, (debugfile, "Getting mailbox FLAGS\n"));
-       if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL)
-         goto fail;
+      if (!idata->flags) {
+        dprint (2, (debugfile, "Getting mailbox FLAGS\n"));
+        if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL)
+          goto fail;
       }
     }
     /* PERMANENTFLAGS are massaged to look like FLAGS, then override FLAGS */
-    else if (ascii_strncasecmp ("OK [PERMANENTFLAGS", pc, 18) == 0)
-    {
+    else if (ascii_strncasecmp ("OK [PERMANENTFLAGS", pc, 18) == 0) {
       dprint (2, (debugfile, "Getting mailbox PERMANENTFLAGS\n"));
       /* safe to call on NULL */
       mutt_free_list (&(idata->flags));
       /* skip "OK [PERMANENT" so syntax is the same as FLAGS */
       pc += 13;
       if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL)
-       goto fail;
+        goto fail;
     }
 #ifdef USE_HCACHE
     /* save UIDVALIDITY for the header cache */
-    else if (ascii_strncasecmp("OK [UIDVALIDITY", pc, 14) == 0)
-    {
-           dprint(2, (debugfile, "Getting mailbox UIDVALIDITY\n"));
-           pc += 3;
-           pc = imap_next_word(pc);
+    else if (ascii_strncasecmp ("OK [UIDVALIDITY", pc, 14) == 0) {
+      dprint (2, (debugfile, "Getting mailbox UIDVALIDITY\n"));
+      pc += 3;
+      pc = imap_next_word (pc);
 
-           sscanf(pc, "%u", &(idata->uid_validity));
+      sscanf (pc, "%u", &(idata->uid_validity));
     }
 #endif
-    else
-    {
+    else {
       pc = imap_next_word (pc);
-      if (!ascii_strncasecmp ("EXISTS", pc, 6))
-      {
-       count = idata->newMailCount;
-       idata->newMailCount = 0;
+      if (!ascii_strncasecmp ("EXISTS", pc, 6)) {
+        count = idata->newMailCount;
+        idata->newMailCount = 0;
       }
     }
   }
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc == IMAP_CMD_NO)
-  {
+  if (rc == IMAP_CMD_NO) {
     char *s;
-    s = imap_next_word (idata->cmd.buf); /* skip seq */
-    s = imap_next_word (s); /* Skip response */
+
+    s = imap_next_word (idata->cmd.buf);        /* skip seq */
+    s = imap_next_word (s);     /* Skip response */
     mutt_error ("%s", s);
     mutt_sleep (2);
     goto fail;
@@ -665,28 +632,25 @@ int imap_open_mailbox (CONTEXT* ctx)
     goto fail;
 
   /* check for READ-ONLY notification */
-  if (!ascii_strncasecmp (imap_get_qualifier (idata->cmd.buf), "[READ-ONLY]", 11)  \
-  && !mutt_bit_isset (idata->capabilities, ACL))
-  {
+  if (!ascii_strncasecmp
+      (imap_get_qualifier (idata->cmd.buf), "[READ-ONLY]", 11)
+      && !mutt_bit_isset (idata->capabilities, ACL)) {
     dprint (2, (debugfile, "Mailbox is read-only.\n"));
     ctx->readonly = 1;
   }
 
 #ifdef DEBUG
   /* dump the mailbox flags we've found */
-  if (debuglevel > 2)
-  {
+  if (debuglevel > 2) {
     if (!idata->flags)
       dprint (3, (debugfile, "No folder flags found\n"));
-    else
-    {
-      LIST* t = idata->flags;
+    else {
+      LIST *t = idata->flags;
 
       dprint (3, (debugfile, "Mailbox flags: "));
 
       t = t->next;
-      while (t)
-      {
+      while (t) {
         dprint (3, (debugfile, "[%s] ", t->data));
         t = t->next;
       }
@@ -695,19 +659,17 @@ int imap_open_mailbox (CONTEXT* ctx)
   }
 #endif
 
-  if (mutt_bit_isset (idata->capabilities, ACL))
-  {
+  if (mutt_bit_isset (idata->capabilities, ACL)) {
     if (imap_check_acl (idata))
       goto fail;
-    if (!(mutt_bit_isset(idata->rights, IMAP_ACL_DELETE) ||
-          mutt_bit_isset(idata->rights, IMAP_ACL_SEEN) ||
-          mutt_bit_isset(idata->rights, IMAP_ACL_WRITE) ||
-          mutt_bit_isset(idata->rights, IMAP_ACL_INSERT)))
-       ctx->readonly = 1;
+    if (!(mutt_bit_isset (idata->rights, IMAP_ACL_DELETE) ||
+          mutt_bit_isset (idata->rights, IMAP_ACL_SEEN) ||
+          mutt_bit_isset (idata->rights, IMAP_ACL_WRITE) ||
+          mutt_bit_isset (idata->rights, IMAP_ACL_INSERT)))
+      ctx->readonly = 1;
   }
   /* assume we have all rights if ACL is unavailable */
-  else
-  {
+  else {
     mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
     mutt_bit_set (idata->rights, IMAP_ACL_READ);
     mutt_bit_set (idata->rights, IMAP_ACL_SEEN);
@@ -722,26 +684,27 @@ int imap_open_mailbox (CONTEXT* ctx)
   ctx->hdrs = safe_calloc (count, sizeof (HEADER *));
   ctx->v2r = safe_calloc (count, sizeof (int));
   ctx->msgcount = 0;
-  if (count && (imap_read_headers (idata, 0, count-1) < 0))
-  {
+  if (count && (imap_read_headers (idata, 0, count - 1) < 0)) {
     mutt_error _("Error opening mailbox");
+
     mutt_sleep (1);
     goto fail;
   }
 
-  dprint (2, (debugfile, "imap_open_mailbox: msgcount is %d\n", ctx->msgcount));
+  dprint (2,
+          (debugfile, "imap_open_mailbox: msgcount is %d\n", ctx->msgcount));
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   if (idata->state == IMAP_SELECTED)
     idata->state = IMAP_AUTHENTICATED;
- fail_noidata:
+fail_noidata:
   FREE (&mx.mbox);
   return -1;
 }
 
-int imap_open_mailbox_append (CONTEXT *ctx)
+int imap_open_mailbox_append (CONTEXT * ctx)
 {
   CONNECTION *conn;
   IMAP_DATA *idata;
@@ -768,15 +731,14 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox));
 
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-                               
-  if (mutt_bit_isset(idata->capabilities,IMAP4REV1))
+
+  if (mutt_bit_isset (idata->capabilities, IMAP4REV1))
     snprintf (buf, sizeof (buf), "STATUS %s (UIDVALIDITY)", mbox);
-  else if (mutt_bit_isset(idata->capabilities,STATUS))
+  else if (mutt_bit_isset (idata->capabilities, STATUS))
     /* We have no idea what the other guy wants. UW imapd 8.3 wants this
      * (but it does not work if another mailbox is selected) */
     snprintf (buf, sizeof (buf), "STATUS %s (UID-VALIDITY)", mbox);
-  else
-  {
+  else {
     /* STATUS not supported */
     mutt_message _("Unable to append to IMAP mailboxes at this server");
 
@@ -784,8 +746,7 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   }
 
   r = imap_exec (idata, buf, IMAP_CMD_FAIL_OK);
-  if (r == -2)
-  {
+  if (r == -2) {
     /* command failed cause folder doesn't exist */
     snprintf (buf, sizeof (buf), _("Create %s?"), mailbox);
     if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) < 1)
@@ -801,22 +762,21 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
 /* imap_logout: Gracefully log out of server. */
-void imap_logout (IMAP_DATA* idata)
+void imap_logout (IMAP_DATA * idata)
 {
   /* we set status here to let imap_handle_untagged know we _expect_ to
    * receive a bye response (so it doesn't freak out and close the conn) */
   idata->status = IMAP_BYE;
   imap_cmd_start (idata, "LOGOUT");
-  while (imap_cmd_step (idata) == IMAP_CMD_CONTINUE)
-    ;
-  FREE(& idata->cmd.buf);
-  FREE(& idata);
+  while (imap_cmd_step (idata) == IMAP_CMD_CONTINUE);
+  FREE (&idata->cmd.buf);
+  FREE (&idata);
 }
 
 /*
@@ -838,8 +798,8 @@ int imap_close_connection (CONTEXT *ctx)
 
 /* imap_set_flag: append str to flags if we currently have permission
  *   according to aclbit */
-static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag,
-  const char *str, char *flags, size_t flsize)
+static void imap_set_flag (IMAP_DATA * idata, int aclbit, int flag,
+                           const char *str, char *flags, size_t flsize)
 {
   if (mutt_bit_isset (idata->rights, aclbit))
     if (flag)
@@ -854,80 +814,71 @@ static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag,
  *         flag: enum of flag type on which to filter
  *         changed: include only changed messages in message set
  * Returns: number of messages in message set (0 if no matches) */
-int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed)
+int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag, int changed)
 {
-  HEADER** hdrs;       /* sorted local copy */
-  int count = 0;       /* number of messages in message set */
-  int match = 0;       /* whether current message matches flag condition */
-  unsigned int setstart = 0;   /* start of current message range */
+  HEADER **hdrs;                /* sorted local copy */
+  int count = 0;                /* number of messages in message set */
+  int match = 0;                /* whether current message matches flag condition */
+  unsigned int setstart = 0;    /* start of current message range */
   int n;
-  short oldsort;       /* we clobber reverse, must restore it */
+  short oldsort;                /* we clobber reverse, must restore it */
+
   /* assuming 32-bit UIDs */
   char uid[12];
   int started = 0;
 
   /* make copy of header pointers to sort in natural order */
-  hdrs = safe_calloc (idata->ctx->msgcount, sizeof (HEADER*));
-  memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER*));
+  hdrs = safe_calloc (idata->ctx->msgcount, sizeof (HEADER *));
+  memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER *));
 
-  if (Sort != SORT_ORDER)
-  {
+  if (Sort != SORT_ORDER) {
     oldsort = Sort;
     Sort = SORT_ORDER;
-    qsort ((void*) hdrs, idata->ctx->msgcount, sizeof (HEADER*),
-      mutt_get_sort_func (SORT_ORDER));
+    qsort ((void *) hdrs, idata->ctx->msgcount, sizeof (HEADER *),
+           mutt_get_sort_func (SORT_ORDER));
     Sort = oldsort;
   }
-  
-  for (n = 0; n < idata->ctx->msgcount; n++)
-  {
+
+  for (n = 0; n < idata->ctx->msgcount; n++) {
     match = 0;
     /* don't include pending expunged messages */
     if (hdrs[n]->active)
-      switch (flag)
-      {
-        case M_DELETE:
-         if (hdrs[n]->deleted)
-           match = 1;
-         break;
-        case M_TAG:
-         if (hdrs[n]->tagged)
-           match = 1;
-         break;
+      switch (flag) {
+      case M_DELETE:
+        if (hdrs[n]->deleted)
+          match = 1;
+        break;
+      case M_TAG:
+        if (hdrs[n]->tagged)
+          match = 1;
+        break;
       }
 
-    if (match && (!changed || hdrs[n]->changed))
-    {
+    if (match && (!changed || hdrs[n]->changed)) {
       count++;
-      if (setstart == 0)
-      {
+      if (setstart == 0) {
         setstart = HEADER_DATA (hdrs[n])->uid;
-        if (started == 0)
-       {
-         snprintf (uid, sizeof (uid), "%u", HEADER_DATA (hdrs[n])->uid);
-         mutt_buffer_addstr (buf, uid);
-         started = 1;
-       }
-        else
-        {
-         snprintf (uid, sizeof (uid), ",%u", HEADER_DATA (hdrs[n])->uid);
-         mutt_buffer_addstr (buf, uid);
+        if (started == 0) {
+          snprintf (uid, sizeof (uid), "%u", HEADER_DATA (hdrs[n])->uid);
+          mutt_buffer_addstr (buf, uid);
+          started = 1;
+        }
+        else {
+          snprintf (uid, sizeof (uid), ",%u", HEADER_DATA (hdrs[n])->uid);
+          mutt_buffer_addstr (buf, uid);
         }
       }
       /* tie up if the last message also matches */
-      else if (n == idata->ctx->msgcount-1)
-      {
-       snprintf (uid, sizeof (uid), ":%u", HEADER_DATA (hdrs[n])->uid);
-       mutt_buffer_addstr (buf, uid);
+      else if (n == idata->ctx->msgcount - 1) {
+        snprintf (uid, sizeof (uid), ":%u", HEADER_DATA (hdrs[n])->uid);
+        mutt_buffer_addstr (buf, uid);
       }
     }
     /* this message is not expunged and doesn't match. End current set. */
-    else if (setstart && hdrs[n]->active)
-    {
-      if (HEADER_DATA (hdrs[n-1])->uid > setstart)
-      {
-       snprintf (uid, sizeof (uid), ":%u", HEADER_DATA (hdrs[n-1])->uid);
-       mutt_buffer_addstr (buf, uid);
+    else if (setstart && hdrs[n]->active) {
+      if (HEADER_DATA (hdrs[n - 1])->uid > setstart) {
+        snprintf (uid, sizeof (uid), ":%u", HEADER_DATA (hdrs[n - 1])->uid);
+        mutt_buffer_addstr (buf, uid);
       }
       setstart = 0;
     }
@@ -944,22 +895,21 @@ int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed)
  *   expunge: 0 or 1 - do expunge? 
  */
 
-int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
+int imap_sync_mailbox (CONTEXT * ctx, int expunge, int *index_hint)
 {
-  IMAP_DATAidata;
-  CONTEXTappendctx = NULL;
+  IMAP_DATA *idata;
+  CONTEXT *appendctx = NULL;
   BUFFER cmd;
   char flags[LONG_STRING];
   char uid[11];
   int deleted;
   int n;
-  int err_continue = M_NO;     /* continue on error? */
+  int err_continue = M_NO;      /* continue on error? */
   int rc;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
-  if (idata->state != IMAP_SELECTED)
-  {
+  if (idata->state != IMAP_SELECTED) {
     dprint (2, (debugfile, "imap_sync_mailbox: no mailbox selected\n"));
     return -1;
   }
@@ -971,7 +921,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   else
     idata->noclose = 1;
 
-  /* This function is only called when the calling code        expects the context
+  /* This function is only called when the calling code expects the context
    * to be changed. */
   imap_allow_reopen (ctx);
 
@@ -981,42 +931,37 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   memset (&cmd, 0, sizeof (cmd));
 
   /* if we are expunging anyway, we can do deleted messages very quickly... */
-  if (expunge && mutt_bit_isset (idata->rights, IMAP_ACL_DELETE))
-  {
+  if (expunge && mutt_bit_isset (idata->rights, IMAP_ACL_DELETE)) {
     mutt_buffer_addstr (&cmd, "UID STORE ");
     deleted = imap_make_msg_set (idata, &cmd, M_DELETE, 1);
 
     /* if we have a message set, then let's delete */
-    if (deleted)
-    {
+    if (deleted) {
       mutt_message (_("Marking %d messages deleted..."), deleted);
       mutt_buffer_addstr (&cmd, " +FLAGS.SILENT (\\Deleted)");
       /* mark these messages as unchanged so second pass ignores them. Done
        * here so BOGUS UW-IMAP 4.7 SILENT FLAGS updates are ignored. */
       for (n = 0; n < ctx->msgcount; n++)
-       if (ctx->hdrs[n]->deleted && ctx->hdrs[n]->changed)
-         ctx->hdrs[n]->active = 0;
-      if (imap_exec (idata, cmd.data, 0) != 0)
-      {
-       mutt_error (_("Expunge failed"));
-       mutt_sleep (1);
-       rc = -1;
-       goto out;
+        if (ctx->hdrs[n]->deleted && ctx->hdrs[n]->changed)
+          ctx->hdrs[n]->active = 0;
+      if (imap_exec (idata, cmd.data, 0) != 0) {
+        mutt_error (_("Expunge failed"));
+        mutt_sleep (1);
+        rc = -1;
+        goto out;
       }
     }
   }
 
   /* save status changes */
-  for (n = 0; n < ctx->msgcount; n++)
-  {
-    if (ctx->hdrs[n]->active && ctx->hdrs[n]->changed)
-    {
+  for (n = 0; n < ctx->msgcount; n++) {
+    if (ctx->hdrs[n]->active && ctx->hdrs[n]->changed) {
       ctx->hdrs[n]->changed = 0;
 
-      mutt_message (_("Saving message status flags... [%d/%d]"), n+1,
-        ctx->msgcount);
+      mutt_message (_("Saving message status flags... [%d/%d]"), n + 1,
+                    ctx->msgcount);
 
-      snprintf (uid, sizeof (uid), "%u", HEADER_DATA(ctx->hdrs[n])->uid);
+      snprintf (uid, sizeof (uid), "%u", HEADER_DATA (ctx->hdrs[n])->uid);
       cmd.dptr = cmd.data;
       mutt_buffer_addstr (&cmd, "UID STORE ");
       mutt_buffer_addstr (&cmd, uid);
@@ -1025,51 +970,56 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
        * we delete the message and reupload it.
        * This works better if we're expunging, of course. */
       if (ctx->hdrs[n]->refs_changed || ctx->hdrs[n]->irt_changed ||
-         ctx->hdrs[n]->attach_del)
-      {
-       dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
-       if (!appendctx)
-         appendctx = mx_open_mailbox (ctx->path, M_APPEND | M_QUIET, NULL);
-       if (!appendctx)
-       {
-         dprint (1, (debugfile, "imap_sync_mailbox: Error opening mailbox in append mode\n"));
-       }
-       else
-         _mutt_save_message (ctx->hdrs[n], appendctx, 1, 0, 0);
+          ctx->hdrs[n]->attach_del) {
+        dprint (3,
+                (debugfile,
+                 "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
+        if (!appendctx)
+          appendctx = mx_open_mailbox (ctx->path, M_APPEND | M_QUIET, NULL);
+        if (!appendctx) {
+          dprint (1,
+                  (debugfile,
+                   "imap_sync_mailbox: Error opening mailbox in append mode\n"));
+        }
+        else
+          _mutt_save_message (ctx->hdrs[n], appendctx, 1, 0, 0);
       }
       flags[0] = '\0';
-      
+
       imap_set_flag (idata, IMAP_ACL_SEEN, ctx->hdrs[n]->read, "\\Seen ",
-        flags, sizeof (flags));
+                     flags, sizeof (flags));
       imap_set_flag (idata, IMAP_ACL_WRITE, ctx->hdrs[n]->flagged,
-        "\\Flagged ", flags, sizeof (flags));
+                     "\\Flagged ", flags, sizeof (flags));
       imap_set_flag (idata, IMAP_ACL_WRITE, ctx->hdrs[n]->replied,
-        "\\Answered ", flags, sizeof (flags));
+                     "\\Answered ", flags, sizeof (flags));
       imap_set_flag (idata, IMAP_ACL_DELETE, ctx->hdrs[n]->deleted,
-        "\\Deleted ", flags, sizeof (flags));
+                     "\\Deleted ", flags, sizeof (flags));
 
       /* now make sure we don't lose custom tags */
       if (mutt_bit_isset (idata->rights, IMAP_ACL_WRITE))
         imap_add_keywords (flags, ctx->hdrs[n], idata->flags, sizeof (flags));
-      
+
       mutt_remove_trailing_ws (flags);
-      
+
       /* UW-IMAP is OK with null flags, Cyrus isn't. The only solution is to
        * explicitly revoke all system flags (if we have permission) */
-      if (!*flags)
-      {
-        imap_set_flag (idata, IMAP_ACL_SEEN, 1, "\\Seen ", flags, sizeof (flags));
-        imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Flagged ", flags, sizeof (flags));
-        imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Answered ", flags, sizeof (flags));
-        imap_set_flag (idata, IMAP_ACL_DELETE, 1, "\\Deleted ", flags, sizeof (flags));
+      if (!*flags) {
+        imap_set_flag (idata, IMAP_ACL_SEEN, 1, "\\Seen ", flags,
+                       sizeof (flags));
+        imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Flagged ", flags,
+                       sizeof (flags));
+        imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Answered ", flags,
+                       sizeof (flags));
+        imap_set_flag (idata, IMAP_ACL_DELETE, 1, "\\Deleted ", flags,
+                       sizeof (flags));
 
         mutt_remove_trailing_ws (flags);
 
-       mutt_buffer_addstr (&cmd, " -FLAGS.SILENT (");
+        mutt_buffer_addstr (&cmd, " -FLAGS.SILENT (");
       }
       else
-       mutt_buffer_addstr (&cmd, " FLAGS.SILENT (");
-      
+        mutt_buffer_addstr (&cmd, " FLAGS.SILENT (");
+
       mutt_buffer_addstr (&cmd, flags);
       mutt_buffer_addstr (&cmd, ")");
 
@@ -1079,15 +1029,13 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
       /* after all this it's still possible to have no flags, if you
        * have no ACL rights */
       if (*flags && (imap_exec (idata, cmd.data, 0) != 0) &&
-        (err_continue != M_YES))
-      {
+          (err_continue != M_YES)) {
         err_continue = imap_continue ("imap_sync_mailbox: STORE failed",
-          idata->cmd.buf);
-        if (err_continue != M_YES)
-       {
-         rc = -1;
-         goto out;
-       }
+                                      idata->cmd.buf);
+        if (err_continue != M_YES) {
+          rc = -1;
+          goto out;
+        }
       }
 
       ctx->hdrs[n]->active = 1;
@@ -1097,13 +1045,12 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
 
   /* We must send an EXPUNGE command if we're not closing. */
   if (expunge && !(ctx->closing) &&
-      mutt_bit_isset(idata->rights, IMAP_ACL_DELETE))
-  {
+      mutt_bit_isset (idata->rights, IMAP_ACL_DELETE)) {
     mutt_message _("Expunging messages from server...");
+
     /* Set expunge bit so we don't get spurious reopened messages */
     idata->reopen |= IMAP_EXPUNGE_EXPECTED;
-    if (imap_exec (idata, "EXPUNGE", 0) != 0)
-    {
+    if (imap_exec (idata, "EXPUNGE", 0) != 0) {
       imap_error (_("imap_sync_mailbox: EXPUNGE failed"), idata->cmd.buf);
       rc = -1;
       goto out;
@@ -1111,11 +1058,10 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   }
 
   rc = 0;
- out:
+out:
   if (cmd.data)
     FREE (&cmd.data);
-  if (appendctx)
-  {
+  if (appendctx) {
     mx_fastclose_mailbox (appendctx);
     FREE (&appendctx);
   }
@@ -1123,20 +1069,18 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
 }
 
 /* imap_close_mailbox: issue close command if neccessary, reset IMAP_DATA */
-void imap_close_mailbox (CONTEXT* ctx)
+void imap_close_mailbox (CONTEXT * ctx)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   int i;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
   /* Check to see if the mailbox is actually open */
   if (!idata)
     return;
 
   if ((idata->status != IMAP_FATAL) &&
-      (idata->state == IMAP_SELECTED) &&
-      (ctx == idata->ctx))
-  {
+      (idata->state == IMAP_SELECTED) && (ctx == idata->ctx)) {
     if (!(idata->noclose) && imap_exec (idata, "CLOSE", 0))
       mutt_error (_("CLOSE failed"));
 
@@ -1151,10 +1095,8 @@ void imap_close_mailbox (CONTEXT* ctx)
   for (i = 0; i < ctx->msgcount; i++)
     imap_free_header_data (&(ctx->hdrs[i]->data));
 
-  for (i = 0; i < IMAP_CACHE_LEN; i++)
-  {
-    if (idata->cache[i].path)
-    {
+  for (i = 0; i < IMAP_CACHE_LEN; i++) {
+    if (idata->cache[i].path) {
       unlink (idata->cache[i].path);
       FREE (&idata->cache[i].path);
     }
@@ -1169,16 +1111,16 @@ void imap_close_mailbox (CONTEXT* ctx)
  *     0               no change
  *     -1              error
  */
-int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force)
+int imap_check_mailbox (CONTEXT * ctx, int *index_hint, int force)
 {
   /* overload keyboard timeout to avoid many mailbox checks in a row.
    * Most users don't like having to wait exactly when they press a key. */
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   int result = 0;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
-  if ((force || time(NULL) > idata->lastread + Timeout)
+  if ((force || time (NULL) > idata->lastread + Timeout)
       && imap_exec (idata, "NOOP", 0) != 0)
     return -1;
 
@@ -1204,7 +1146,7 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force)
  *   0+   number of messages in mailbox
  *  -1    error while polling mailboxes
  */
-int imap_mailbox_check (charpath, int new)
+int imap_mailbox_check (char *path, int new)
 {
   CONNECTION *conn;
   IMAP_DATA *idata;
@@ -1216,7 +1158,7 @@ int imap_mailbox_check (char* path, int new)
   int connflags = 0;
   IMAP_MBOX mx;
   int rc;
-  
+
   if (imap_parse_path (path, &mx))
     return -1;
 
@@ -1224,8 +1166,7 @@ int imap_mailbox_check (char* path, int new)
   if (option (OPTIMAPPASSIVE))
     connflags = M_IMAP_CONN_NONEW;
 
-  if (!(idata = imap_conn_find (&(mx.account), connflags)))
-  {
+  if (!(idata = imap_conn_find (&(mx.account), connflags))) {
     FREE (&mx.mbox);
     return -1;
   }
@@ -1234,7 +1175,7 @@ int imap_mailbox_check (char* path, int new)
   imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
   FREE (&mx.mbox);
 
-  imap_munge_mbox_name (mbox, sizeof(mbox), buf);
+  imap_munge_mbox_name (mbox, sizeof (mbox), buf);
   strfcpy (mbox_unquoted, buf, sizeof (mbox_unquoted));
 
   /* The draft IMAP implementor's guide warns againts using the STATUS
@@ -1243,15 +1184,13 @@ int imap_mailbox_check (char* path, int new)
 
   if (mutt_strcmp (mbox_unquoted, idata->mailbox) == 0
       || (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0
-         && mutt_strcasecmp (mbox_unquoted, idata->mailbox) == 0))
-  {
+          && mutt_strcasecmp (mbox_unquoted, idata->mailbox) == 0)) {
     strfcpy (buf, "NOOP", sizeof (buf));
   }
-  else if (mutt_bit_isset(idata->capabilities,IMAP4REV1) ||
-          mutt_bit_isset(idata->capabilities,STATUS))
-  {                            
+  else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) ||
+           mutt_bit_isset (idata->capabilities, STATUS)) {
     snprintf (buf, sizeof (buf), "STATUS %s (%s)", mbox,
-      new ? "RECENT" : "MESSAGES");
+              new ? "RECENT" : "MESSAGES");
   }
   else
     /* Server does not support STATUS, and this is not the current mailbox.
@@ -1260,34 +1199,32 @@ int imap_mailbox_check (char* path, int new)
 
   imap_cmd_start (idata, buf);
 
-  do 
-  {
+  do {
     if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
       break;
 
     s = imap_next_word (idata->cmd.buf);
-    if (ascii_strncasecmp ("STATUS", s, 6) == 0)
-    {
+    if (ascii_strncasecmp ("STATUS", s, 6) == 0) {
       s = imap_next_word (s);
       /* The mailbox name may or may not be quoted here. We could try to 
        * munge the server response and compare with quoted (or vise versa)
        * but it is probably more efficient to just strncmp against both. */
       if (mutt_strncmp (mbox_unquoted, s, mutt_strlen (mbox_unquoted)) == 0
-         || mutt_strncmp (mbox, s, mutt_strlen (mbox)) == 0)
-      {
-       s = imap_next_word (s);
-       s = imap_next_word (s);
-       if (isdigit ((unsigned char) *s))
-       {
-         if (*s != '0')
-         {
-           msgcount = atoi(s);
-           dprint (2, (debugfile, "%d new messages in %s\n", msgcount, path));
-         }
-       }
+          || mutt_strncmp (mbox, s, mutt_strlen (mbox)) == 0) {
+        s = imap_next_word (s);
+        s = imap_next_word (s);
+        if (isdigit ((unsigned char) *s)) {
+          if (*s != '0') {
+            msgcount = atoi (s);
+            dprint (2,
+                    (debugfile, "%d new messages in %s\n", msgcount, path));
+          }
+        }
       }
       else
-       dprint (1, (debugfile, "imap_mailbox_check: STATUS response doesn't match requested mailbox.\n"));
+        dprint (1,
+                (debugfile,
+                 "imap_mailbox_check: STATUS response doesn't match requested mailbox.\n"));
     }
   }
   while (rc == IMAP_CMD_CONTINUE);
@@ -1300,8 +1237,8 @@ int imap_mailbox_check (char* path, int new)
  *   as bad), nor do I like the fact that the fetch is done here. This
  *   code can't possibly handle non-LIST untagged responses properly.
  *   FIXME. ?! */
-int imap_parse_list_response(IMAP_DATA* idata, char **name, int *noselect,
-  int *noinferiors, char *delim)
+int imap_parse_list_response (IMAP_DATA * idata, char **name, int *noselect,
+                              int *noinferiors, char *delim)
 {
   char *s;
   long bytes;
@@ -1317,51 +1254,49 @@ int imap_parse_list_response(IMAP_DATA* idata, char **name, int *noselect,
 
   s = imap_next_word (idata->cmd.buf);
   if ((ascii_strncasecmp ("LIST", s, 4) == 0) ||
-      (ascii_strncasecmp ("LSUB", s, 4) == 0))
-  {
+      (ascii_strncasecmp ("LSUB", s, 4) == 0)) {
     *noselect = 0;
     *noinferiors = 0;
-      
-    s = imap_next_word (s); /* flags */
-    if (*s == '(')
-    {
+
+    s = imap_next_word (s);     /* flags */
+    if (*s == '(') {
       char *ep;
 
       s++;
       ep = s;
-      while (*ep && *ep != ')') ep++;
-      do
-      {
-       if (!ascii_strncasecmp (s, "\\NoSelect", 9))
-         *noselect = 1;
-       if (!ascii_strncasecmp (s, "\\NoInferiors", 12))
-         *noinferiors = 1;
-       /* See draft-gahrns-imap-child-mailbox-?? */
-       if (!ascii_strncasecmp (s, "\\HasNoChildren", 14))
-         *noinferiors = 1;
-       if (*s != ')')
-         s++;
-       while (*s && *s != '\\' && *s != ')') s++;
+      while (*ep && *ep != ')')
+        ep++;
+      do {
+        if (!ascii_strncasecmp (s, "\\NoSelect", 9))
+          *noselect = 1;
+        if (!ascii_strncasecmp (s, "\\NoInferiors", 12))
+          *noinferiors = 1;
+        /* See draft-gahrns-imap-child-mailbox-?? */
+        if (!ascii_strncasecmp (s, "\\HasNoChildren", 14))
+          *noinferiors = 1;
+        if (*s != ')')
+          s++;
+        while (*s && *s != '\\' && *s != ')')
+          s++;
       } while (s != ep);
     }
     else
       return 0;
-    s = imap_next_word (s); /* delim */
+    s = imap_next_word (s);     /* delim */
     /* Reset the delimiter, this can change */
-    if (ascii_strncasecmp (s, "NIL", 3))
-    {
+    if (ascii_strncasecmp (s, "NIL", 3)) {
       if (s && s[0] == '\"' && s[1] && s[2] == '\"')
-       *delim = s[1];
-      else if (s && s[0] == '\"' && s[1] && s[1] == '\\' && s[2] && s[3] == '\"')
-       *delim = s[2];
+        *delim = s[1];
+      else if (s && s[0] == '\"' && s[1] && s[1] == '\\' && s[2]
+               && s[3] == '\"')
+        *delim = s[2];
     }
-    s = imap_next_word (s); /* name */
-    if (s && *s == '{')        /* Literal */
-    { 
-      if (imap_get_literal_count(idata->cmd.buf, &bytes) < 0)
-       return -1;
+    s = imap_next_word (s);     /* name */
+    if (s && *s == '{') {       /* Literal */
+      if (imap_get_literal_count (idata->cmd.buf, &bytes) < 0)
+        return -1;
       if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE)
-       return -1;
+        return -1;
       *name = idata->cmd.buf;
     }
     else
@@ -1379,16 +1314,15 @@ int imap_subscribe (char *path, int subscribe)
   char mbox[LONG_STRING];
   IMAP_MBOX mx;
 
-  if (!mx_is_imap (path) || imap_parse_path (path, &mx))
-  {
+  if (!mx_is_imap (path) || imap_parse_path (path, &mx)) {
     mutt_error (_("Bad mailbox name"));
     return -1;
   }
-  
+
 
   if (!(idata = imap_conn_find (&(mx.account), 0)))
     goto fail;
-  
+
   conn = idata->conn;
 
   imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
@@ -1396,10 +1330,10 @@ int imap_subscribe (char *path, int subscribe)
     mutt_message (_("Subscribing to %s..."), buf);
   else
     mutt_message (_("Unsubscribing to %s..."), buf);
-  imap_munge_mbox_name (mbox, sizeof(mbox), buf);
+  imap_munge_mbox_name (mbox, sizeof (mbox), buf);
 
   snprintf (buf, sizeof (buf), "%s %s", subscribe ? "SUBSCRIBE" :
-    "UNSUBSCRIBE", mbox);
+            "UNSUBSCRIBE", mbox);
 
   if (imap_exec (idata, buf, 0) < 0)
     goto fail;
@@ -1407,19 +1341,20 @@ int imap_subscribe (char *path, int subscribe)
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
 /* imap_complete: given a partial IMAP folder path, return a string which
  *   adds as much to the path as is unique */
-int imap_complete(char* dest, size_t dlen, char* path) {
-  CONNECTION* conn;
-  IMAP_DATA* idata;
+int imap_complete (char *dest, size_t dlen, char *path)
+{
+  CONNECTION *conn;
+  IMAP_DATA *idata;
   char list[LONG_STRING];
   char buf[LONG_STRING];
-  charlist_word = NULL;
+  char *list_word = NULL;
   int noselect, noinferiors;
   char delim;
   char completion[LONG_STRING];
@@ -1429,9 +1364,8 @@ int imap_complete(char* dest, size_t dlen, char* path) {
   IMAP_MBOX mx;
 
   /* verify passed in path is an IMAP path */
-  if (imap_parse_path (path, &mx))
-  {
-    dprint(2, (debugfile, "imap_complete: bad path %s\n", path));
+  if (imap_parse_path (path, &mx)) {
+    dprint (2, (debugfile, "imap_complete: bad path %s\n", path));
     return -1;
   }
 
@@ -1443,41 +1377,37 @@ int imap_complete(char* dest, size_t dlen, char* path) {
   /* reformat path for IMAP list, and append wildcard */
   /* don't use INBOX in place of "" */
   if (mx.mbox && mx.mbox[0])
-    imap_fix_path (idata, mx.mbox, list, sizeof(list));
+    imap_fix_path (idata, mx.mbox, list, sizeof (list));
   else
     list[0] = '\0';
 
   /* fire off command */
-  snprintf (buf, sizeof(buf), "%s \"\" \"%s%%\"",
-    option (OPTIMAPLSUB) ? "LSUB" : "LIST", list);
+  snprintf (buf, sizeof (buf), "%s \"\" \"%s%%\"",
+            option (OPTIMAPLSUB) ? "LSUB" : "LIST", list);
 
   imap_cmd_start (idata, buf);
 
   /* and see what the results are */
-  strfcpy (completion, NONULL(mx.mbox), sizeof(completion));
-  do
-  {
-    if (imap_parse_list_response(idata, &list_word, &noselect, &noinferiors,
-        &delim))
+  strfcpy (completion, NONULL (mx.mbox), sizeof (completion));
+  do {
+    if (imap_parse_list_response (idata, &list_word, &noselect, &noinferiors,
+                                  &delim))
       break;
 
-    if (list_word)
-    {
+    if (list_word) {
       /* store unquoted */
       imap_unmunge_mbox_name (list_word);
 
       /* if the folder isn't selectable, append delimiter to force browse
        * to enter it on second tab. */
-      if (noselect)
-      {
-        clen = strlen(list_word);
+      if (noselect) {
+        clen = strlen (list_word);
         list_word[clen++] = delim;
         list_word[clen] = '\0';
       }
       /* copy in first word */
-      if (!completions)
-      {
-        strfcpy (completion, list_word, sizeof(completion));
+      if (!completions) {
+        strfcpy (completion, list_word, sizeof (completion));
         matchlen = strlen (completion);
         completions++;
         continue;
@@ -1485,7 +1415,7 @@ int imap_complete(char* dest, size_t dlen, char* path) {
 
       pos = 0;
       while (pos < matchlen && list_word[pos] &&
-          completion[pos] == list_word[pos])
+             completion[pos] == list_word[pos])
         pos++;
       completion[pos] = '\0';
       matchlen = pos;
@@ -1493,10 +1423,9 @@ int imap_complete(char* dest, size_t dlen, char* path) {
       completions++;
     }
   }
-  while (ascii_strncmp(idata->cmd.seq, idata->cmd.buf, SEQLEN));
+  while (ascii_strncmp (idata->cmd.seq, idata->cmd.buf, SEQLEN));
 
-  if (completions)
-  {
+  if (completions) {
     /* reformat output */
     imap_qualify_path (dest, dlen, &mx, completion);
     mutt_pretty_mailbox (dest);
@@ -1505,24 +1434,26 @@ int imap_complete(char* dest, size_t dlen, char* path) {
     return 0;
   }
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
 
 /* reconnect if connection was lost */
-int imap_reconnect(CONTEXT* ctx) {
-  IMAP_DATA* imap_data = (IMAP_DATA *)ctx->data;
+int imap_reconnect (CONTEXT * ctx)
+{
+  IMAP_DATA *imap_data = (IMAP_DATA *) ctx->data;
 
   if (imap_data) {
     if (imap_data->status == IMAP_CONNECTED)
       return -1;
   }
 
-  if (query_quadoption(OPT_IMAPRECONNECT,_("Connection lost. Reconnect to IMAP server?")) != M_YES)
+  if (query_quadoption
+      (OPT_IMAPRECONNECT,
+       _("Connection lost. Reconnect to IMAP server?")) != M_YES)
     return -1;
 
-  mx_open_mailbox(ctx->path,0,ctx);
+  mx_open_mailbox (ctx->path, 0, ctx);
   return 0;
 }
-
index 9ac7a95..77c07f5 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _IMAP_H
 #define _IMAP_H 1
 #include "mailbox.h"
 
 /* -- data structures -- */
-typedef struct
-{
+typedef struct {
   ACCOUNT account;
-  charmbox;
+  char *mbox;
 } IMAP_MBOX;
 
 /* imap.c */
-int imap_access (const char*, int);
-int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force);
-int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx);
-int imap_open_mailbox (CONTEXT *ctx);
-int imap_open_mailbox_append (CONTEXT *ctx);
-int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint);
-void imap_close_mailbox (CONTEXT *ctx);
+int imap_access (const char *, int);
+int imap_check_mailbox (CONTEXT * ctx, int *index_hint, int force);
+int imap_delete_mailbox (CONTEXT * idata, IMAP_MBOX mx);
+int imap_open_mailbox (CONTEXT * ctx);
+int imap_open_mailbox_append (CONTEXT * ctx);
+int imap_sync_mailbox (CONTEXT * ctx, int expunge, int *index_hint);
+void imap_close_mailbox (CONTEXT * ctx);
 int imap_buffy_check (char *path);
 int imap_mailbox_check (char *path, int new);
 int imap_subscribe (char *path, int subscribe);
-int imap_complete (char* dest, size_t dlen, char* path);
+int imap_complete (char *dest, size_t dlen, char *path);
 
-void imap_allow_reopen (CONTEXT *ctx);
-void imap_disallow_reopen (CONTEXT *ctx);
+void imap_allow_reopen (CONTEXT * ctx);
+void imap_disallow_reopen (CONTEXT * ctx);
 
 /* browse.c */
-int imap_browse (char* path, struct browser_state* state);
-int imap_mailbox_create (const charfolder);
-int imap_mailbox_rename (const charmailbox);
+int imap_browse (char *path, struct browser_state *state);
+int imap_mailbox_create (const char *folder);
+int imap_mailbox_rename (const char *mailbox);
 
 /* message.c */
-int imap_append_message (CONTEXT* ctx, MESSAGE* msg);
-int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete);
-int imap_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno);
+int imap_append_message (CONTEXT * ctx, MESSAGE * msg);
+int imap_copy_messages (CONTEXT * ctx, HEADER * h, char *dest, int delete);
+int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno);
 
 /* socket.c */
 void imap_logout_all (void);
 
 /* util.c */
-int imap_expand_path (charpath, size_t len);
-int imap_parse_path (const char* path, IMAP_MBOX* mx);
-void imap_pretty_mailbox (charpath);
+int imap_expand_path (char *path, size_t len);
+int imap_parse_path (const char *path, IMAP_MBOX * mx);
+void imap_pretty_mailbox (char *path);
 
 int imap_wait_keepalive (pid_t pid);
 void imap_keepalive (void);
index 14b7ce4..ed6832f 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _IMAP_PRIVATE_H
 #define _IMAP_PRIVATE_H 1
 #define IMAP_CMD_FAIL_OK (1<<0)
 #define IMAP_CMD_PASS    (1<<1)
 
-enum
-{
+enum {
   IMAP_FATAL = 1,
   IMAP_BYE,
   IMAP_REOPENED
 };
 
-enum
-{
+enum {
   /* States */
   IMAP_DISCONNECTED = 0,
   IMAP_CONNECTED,
@@ -77,8 +75,7 @@ enum
   IMAP_SELECTED
 };
 
-enum
-{
+enum {
   /* Namespace types */
   IMAP_NS_PERSONAL = 0,
   IMAP_NS_OTHER,
@@ -86,8 +83,7 @@ enum
 };
 
 /* ACL Rights */
-enum
-{
+enum {
   IMAP_ACL_LOOKUP = 0,
   IMAP_ACL_READ,
   IMAP_ACL_SEEN,
@@ -102,18 +98,17 @@ enum
 };
 
 /* Capabilities we are interested in */
-enum
-{
+enum {
   IMAP4 = 0,
   IMAP4REV1,
   STATUS,
-  ACL,                         /* RFC 2086: IMAP4 ACL extension */
-  NAMESPACE,                           /* RFC 2342: IMAP4 Namespace */
-  ACRAM_MD5,                   /* RFC 2195: CRAM-MD5 authentication */
-  AGSSAPI,                     /* RFC 1731: GSSAPI authentication */
-  AUTH_ANON,                   /* AUTH=ANONYMOUS */
-  STARTTLS,                    /* RFC 2595: STARTTLS */
-  LOGINDISABLED,               /*           LOGINDISABLED */
+  ACL,                          /* RFC 2086: IMAP4 ACL extension */
+  NAMESPACE,                    /* RFC 2342: IMAP4 Namespace */
+  ACRAM_MD5,                    /* RFC 2195: CRAM-MD5 authentication */
+  AGSSAPI,                      /* RFC 1731: GSSAPI authentication */
+  AUTH_ANON,                    /* AUTH=ANONYMOUS */
+  STARTTLS,                     /* RFC 2595: STARTTLS */
+  LOGINDISABLED,                /*           LOGINDISABLED */
 
   CAPMAX
 };
@@ -123,35 +118,31 @@ enum
 #define M_IMAP_CONN_NOSELECT (1<<1)
 
 /* -- data structures -- */
-typedef struct
-{
+typedef struct {
   unsigned int uid;
-  charpath;
+  char *path;
 } IMAP_CACHE;
 
-typedef struct 
-{
+typedef struct {
   int type;
   int listable;
   char *prefix;
   char delim;
   int home_namespace;
   /* We get these when we check if namespace exists - cache them */
-  int noselect;                        
+  int noselect;
   int noinferiors;
 } IMAP_NAMESPACE_INFO;
 
 /* IMAP command structure */
-typedef struct
-{
-  char seq[SEQLEN+1];
-  char* buf;
+typedef struct {
+  char seq[SEQLEN + 1];
+  char *buf;
   unsigned int blen;
   int state;
 } IMAP_COMMAND;
 
-typedef struct
-{
+typedef struct {
   /* This data is specific to a CONNECTION to an IMAP server */
   CONNECTION *conn;
   unsigned char state;
@@ -164,10 +155,10 @@ typedef struct
    * I've chosen (3) for now. (2) might not be too bad, but it involves
    * tracking all possible capabilities. bah. (1) I don't like because
    * it's just no fun to get the same information twice */
-  charcapstr;
-  unsigned char capabilities[(CAPMAX + 7)/8];
+  char *capstr;
+  unsigned char capabilities[(CAPMAX + 7) / 8];
   unsigned int seqno;
-  time_t lastread; /* last time we read a command for the server */
+  time_t lastread;              /* last time we read a command for the server */
   /* who knows, one day we may run multiple commands in parallel */
   IMAP_COMMAND cmd;
 
@@ -177,17 +168,18 @@ typedef struct
   char *mailbox;
   unsigned short check_status;
   unsigned char reopen;
-  unsigned char rights[(RIGHTSMAX + 7)/8];
+  unsigned char rights[(RIGHTSMAX + 7) / 8];
   unsigned int newMailCount;
   IMAP_CACHE cache[IMAP_CACHE_LEN];
-  int noclose : 1;
+  int noclose:1;
 #ifdef USE_HCACHE
   uint64_t uid_validity;
 #endif
-  
+
   /* all folder flags - system flags AND keywords */
   LIST *flags;
 } IMAP_DATA;
+
 /* I wish that were called IMAP_CONTEXT :( */
 
 /* -- macros -- */
@@ -195,51 +187,54 @@ typedef struct
 
 /* -- private IMAP functions -- */
 /* imap.c */
-int imap_create_mailbox (IMAP_DATA* idata, char* mailbox);
-int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname);
-int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed);
-int imap_open_connection (IMAP_DATA* idata);
-IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags);
-int imap_parse_list_response(IMAP_DATA* idata, char** name, int* noselect,
-  int* noinferiors, char* delim);
-int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes);
-void imap_expunge_mailbox (IMAP_DATA* idata);
-int imap_reconnect (CONTEXT* ctx);
-void imap_logout (IMAP_DATA* idata);
+int imap_create_mailbox (IMAP_DATA * idata, char *mailbox);
+int imap_rename_mailbox (IMAP_DATA * idata, IMAP_MBOX * mx,
+                         const char *newname);
+int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag,
+                       int changed);
+int imap_open_connection (IMAP_DATA * idata);
+IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags);
+int imap_parse_list_response (IMAP_DATA * idata, char **name, int *noselect,
+                              int *noinferiors, char *delim);
+int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes);
+void imap_expunge_mailbox (IMAP_DATA * idata);
+int imap_reconnect (CONTEXT * ctx);
+void imap_logout (IMAP_DATA * idata);
 
 /* auth.c */
-int imap_authenticate (IMAP_DATA* idata);
+int imap_authenticate (IMAP_DATA * idata);
 
 /* command.c */
-int imap_cmd_start (IMAP_DATA* idata, const char* cmd);
-int imap_cmd_step (IMAP_DATA* idata);
-void imap_cmd_finish (IMAP_DATA* idata);
-int imap_code (const chars);
-int imap_exec (IMAP_DATA* idata, const char* cmd, int flags);
+int imap_cmd_start (IMAP_DATA * idata, const char *cmd);
+int imap_cmd_step (IMAP_DATA * idata);
+void imap_cmd_finish (IMAP_DATA * idata);
+int imap_code (const char *s);
+int imap_exec (IMAP_DATA * idata, const char *cmd, int flags);
 
 /* message.c */
-void imap_add_keywords (char* s, HEADER* keywords, LIST* mailbox_flags, size_t slen);
-void imap_free_header_data (void** data);
-int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend);
-char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s);
+void imap_add_keywords (char *s, HEADER * keywords, LIST * mailbox_flags,
+                        size_t slen);
+void imap_free_header_data (void **data);
+int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend);
+char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s);
 
 /* util.c */
-int imap_continue (const char* msg, const char* resp);
-void imap_error (const char* where, const char* msg);
-IMAP_DATAimap_new_idata (void);
-void imap_free_idata (IMAP_DATA** idata);
-char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path, 
-  size_t plen);
-int imap_get_literal_count (const char* buf, long* bytes);
-char* imap_get_qualifier (char* buf);
-char* imap_next_word (char* s);
-time_t imap_parse_date (chars);
-void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path);
-void imap_quote_string (char* dest, size_t slen, const char* src);
-void imap_unquote_string (chars);
+int imap_continue (const char *msg, const char *resp);
+void imap_error (const char *where, const char *msg);
+IMAP_DATA *imap_new_idata (void);
+void imap_free_idata (IMAP_DATA ** idata);
+char *imap_fix_path (IMAP_DATA * idata, char *mailbox, char *path,
+                     size_t plen);
+int imap_get_literal_count (const char *buf, long *bytes);
+char *imap_get_qualifier (char *buf);
+char *imap_next_word (char *s);
+time_t imap_parse_date (char *s);
+void imap_qualify_path (char *dest, size_t len, IMAP_MBOX * mx, char *path);
+void imap_quote_string (char *dest, size_t slen, const char *src);
+void imap_unquote_string (char *s);
 void imap_munge_mbox_name (char *dest, size_t dlen, const char *src);
 void imap_unmunge_mbox_name (char *s);
-int imap_wordcasecmp(const char *a, const char *b);
+int imap_wordcasecmp (const char *a, const char *b);
 
 /* utf7.c */
 void imap_utf7_encode (char **s);
index e7e7a17..1d0db54 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* message parsing/updating functions */
 
 #include <inttypes.h>
 #endif
 
-static void flush_buffer(char* buf, size_t* len, CONNECTION* conn);
-static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf,
-  FILE* fp);
-static int msg_has_flag (LIST* flag_list, const char* flag);
-static int msg_parse_fetch (IMAP_HEADER* h, char* s);
-static char* msg_parse_flags (IMAP_HEADER* h, char* s);
+static void flush_buffer (char *buf, size_t * len, CONNECTION * conn);
+static int msg_fetch_header (CONTEXT * ctx, IMAP_HEADER * h, char *buf,
+                             FILE * fp);
+static int msg_has_flag (LIST * flag_list, const char *flag);
+static int msg_parse_fetch (IMAP_HEADER * h, char *s);
+static char *msg_parse_flags (IMAP_HEADER * h, char *s);
 
 #if USE_HCACHE
-static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf,
-  FILE* fp);
+static int msg_fetch_header_fetch (CONTEXT * ctx, IMAP_HEADER * h, char *buf,
+                                   FILE * fp);
 static size_t imap_hcache_keylen (const char *fn);
 #endif /* USE_HCACHE */
 
@@ -60,9 +60,9 @@ static size_t imap_hcache_keylen (const char *fn);
  * msgno of the last message read. It will return a value other than
  * msgend if mail comes in while downloading headers (in theory).
  */
-int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
+int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend)
 {
-  CONTEXTctx;
+  CONTEXT *ctx;
   char buf[LONG_STRING];
   char hdrreq[STRING];
   FILE *fp;
@@ -71,10 +71,11 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   IMAP_HEADER h;
   int rc, mfhrc, oldmsgcount;
   int fetchlast = 0;
-  const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL";
+  const char *want_headers =
+    "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL";
 
 #if USE_HCACHE
-  void *hc   = NULL;
+  void *hc = NULL;
   uint64_t *uid_validity = NULL;
   char uid_buf[64];
 #endif /* USE_HCACHE */
@@ -85,20 +86,20 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   hc = mutt_hcache_open (HeaderCache, ctx->path);
 #endif /* USE_HCACHE */
 
-  if (mutt_bit_isset (idata->capabilities,IMAP4REV1))
-  {
-    snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s%s%s)]", 
-             want_headers, ImapHeaders ? " " : "", ImapHeaders ? ImapHeaders : ""); 
-  } 
-  else if (mutt_bit_isset (idata->capabilities,IMAP4))
-  {
-    snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s%s%s)", 
-      want_headers, ImapHeaders ? " " : "", ImapHeaders ? ImapHeaders : "");
+  if (mutt_bit_isset (idata->capabilities, IMAP4REV1)) {
+    snprintf (hdrreq, sizeof (hdrreq), "BODY.PEEK[HEADER.FIELDS (%s%s%s)]",
+              want_headers, ImapHeaders ? " " : "",
+              ImapHeaders ? ImapHeaders : "");
+  }
+  else if (mutt_bit_isset (idata->capabilities, IMAP4)) {
+    snprintf (hdrreq, sizeof (hdrreq), "RFC822.HEADER.LINES (%s%s%s)",
+              want_headers, ImapHeaders ? " " : "",
+              ImapHeaders ? ImapHeaders : "");
   }
-  else
-  {    /* Unable to fetch headers for lower versions */
+  else {                        /* Unable to fetch headers for lower versions */
     mutt_error _("Unable to fetch headers from this IMAP server version.");
-    mutt_sleep (2);    /* pause a moment to let the user see the error */
+
+    mutt_sleep (2);             /* pause a moment to let the user see the error */
 #if USE_HCACHE
     mutt_hcache_close (hc);
 #endif /* USE_HCACHE */
@@ -108,8 +109,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   /* instead of downloading all headers and then parsing them, we parse them
    * as they come in. */
   mutt_mktemp (tempfile);
-  if (!(fp = safe_fopen (tempfile, "w+")))
-  {
+  if (!(fp = safe_fopen (tempfile, "w+"))) {
     mutt_error (_("Could not create temporary file %s"), tempfile);
     mutt_sleep (2);
 #if USE_HCACHE
@@ -129,72 +129,72 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
 
 #if USE_HCACHE
   snprintf (buf, sizeof (buf),
-    "FETCH %d:%d (UID FLAGS)", msgbegin + 1, msgend + 1);
+            "FETCH %d:%d (UID FLAGS)", msgbegin + 1, msgend + 1);
   fetchlast = msgend + 1;
 
   imap_cmd_start (idata, buf);
 
-  for (msgno = msgbegin; msgno <= msgend ; msgno++)
-  {
-    if (ReadInc && (!msgno || ((msgno+1) % ReadInc == 0)))
-      mutt_message (_("Evaluating cache... [%d/%d]"), msgno + 1,
-        msgend + 1);
+  for (msgno = msgbegin; msgno <= msgend; msgno++) {
+    if (ReadInc && (!msgno || ((msgno + 1) % ReadInc == 0)))
+      mutt_message (_("Evaluating cache... [%d/%d]"), msgno + 1, msgend + 1);
 
     rewind (fp);
     memset (&h, 0, sizeof (h));
     h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA));
-    do
-    {
+    do {
       mfhrc = 0;
 
       rc = imap_cmd_step (idata);
       if (rc != IMAP_CMD_CONTINUE)
-       break;
+        break;
 
-      if ((mfhrc = msg_fetch_header_fetch (idata->ctx, &h, idata->cmd.buf, fp)) == -1)
-       continue;
+      if ((mfhrc =
+           msg_fetch_header_fetch (idata->ctx, &h, idata->cmd.buf, fp)) == -1)
+        continue;
       else if (mfhrc < 0)
-       break;
+        break;
 
       /* make sure we don't get remnants from older larger message headers */
       fputs ("\n\n", fp);
 
-      sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */
-      uid_validity = (uint64_t *) mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen);
-
-      if (uid_validity != NULL
-      && *uid_validity == idata->uid_validity) {
-             ctx->hdrs[msgno] = mutt_hcache_restore((unsigned char *) uid_validity, 0);
-             ctx->hdrs[msgno]->index = h.sid - 1;
-             if (h.sid != ctx->msgcount + 1)
-                     dprint (1, (debugfile, "imap_read_headers: msgcount and sequence ID are inconsistent!"));
-             /* messages which have not been expunged are ACTIVE (borrowed from mh 
-              * folders) */
-             ctx->hdrs[msgno]->active = 1;
-             ctx->hdrs[msgno]->read = h.read;
-             ctx->hdrs[msgno]->old = h.old;
-             ctx->hdrs[msgno]->deleted = h.deleted;
-             ctx->hdrs[msgno]->flagged = h.flagged;
-             ctx->hdrs[msgno]->replied = h.replied;
-             ctx->hdrs[msgno]->changed = h.changed;
-             /*  ctx->hdrs[msgno]->received is restored from mutt_hcache_restore */
-             ctx->hdrs[msgno]->data = (void *) (h.data);
-
-             ctx->msgcount++;
+      sprintf (uid_buf, "/%u", h.data->uid);    /* XXX --tg 21:41 04-07-11 */
+      uid_validity =
+        (uint64_t *) mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen);
+
+      if (uid_validity != NULL && *uid_validity == idata->uid_validity) {
+        ctx->hdrs[msgno] =
+          mutt_hcache_restore ((unsigned char *) uid_validity, 0);
+        ctx->hdrs[msgno]->index = h.sid - 1;
+        if (h.sid != ctx->msgcount + 1)
+          dprint (1,
+                  (debugfile,
+                   "imap_read_headers: msgcount and sequence ID are inconsistent!"));
+        /* messages which have not been expunged are ACTIVE (borrowed from mh 
+         * folders) */
+        ctx->hdrs[msgno]->active = 1;
+        ctx->hdrs[msgno]->read = h.read;
+        ctx->hdrs[msgno]->old = h.old;
+        ctx->hdrs[msgno]->deleted = h.deleted;
+        ctx->hdrs[msgno]->flagged = h.flagged;
+        ctx->hdrs[msgno]->replied = h.replied;
+        ctx->hdrs[msgno]->changed = h.changed;
+        /*  ctx->hdrs[msgno]->received is restored from mutt_hcache_restore */
+        ctx->hdrs[msgno]->data = (void *) (h.data);
+
+        ctx->msgcount++;
       }
       rewind (fp);
 
-      FREE(&uid_validity);
+      FREE (&uid_validity);
 
     }
     while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) ||
-      ((msgno + 1) >= fetchlast)));
+                                   ((msgno + 1) >= fetchlast)));
 
-    if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
-    {
-      imap_free_header_data ((void**) &h.data);
+    if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
+      imap_free_header_data ((void **) &h.data);
       fclose (fp);
-  mutt_hcache_close (hc);
+      mutt_hcache_close (hc);
       return -1;
     }
   }
@@ -202,19 +202,17 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   fetchlast = msgbegin;
 #endif /* USE_HCACHE */
 
-  for (msgno = msgbegin; msgno <= msgend ; msgno++)
-  {
-    if (ReadInc && (!msgno || ((msgno+1) % ReadInc == 0)))
+  for (msgno = msgbegin; msgno <= msgend; msgno++) {
+    if (ReadInc && (!msgno || ((msgno + 1) % ReadInc == 0)))
       mutt_message (_("Fetching message headers... [%d/%d]"), msgno + 1,
-        msgend + 1);
+                    msgend + 1);
 
     if (ctx->hdrs[msgno])
       continue;
 
-    if (msgno + 1 > fetchlast)
-    {
+    if (msgno + 1 > fetchlast) {
       fetchlast = msgno + 1;
-      while((fetchlast <= msgend) && (! ctx->hdrs[fetchlast]))
+      while ((fetchlast <= msgend) && (!ctx->hdrs[fetchlast]))
         fetchlast++;
 
       /*
@@ -225,8 +223,8 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
        * request for all the new messages.
        */
       snprintf (buf, sizeof (buf),
-        "FETCH %d:%d (UID FLAGS INTERNALDATE RFC822.SIZE %s)", msgno + 1,
-        fetchlast, hdrreq);
+                "FETCH %d:%d (UID FLAGS INTERNALDATE RFC822.SIZE %s)",
+                msgno + 1, fetchlast, hdrreq);
 
       imap_cmd_start (idata, buf);
     }
@@ -240,18 +238,18 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
      * 1. handles untagged messages, so we can try again on the same msg
      * 2. fetches the tagged response at the end of the last message.
      */
-    do
-    {
+    do {
       mfhrc = 0;
 
       rc = imap_cmd_step (idata);
       if (rc != IMAP_CMD_CONTINUE)
-       break;
+        break;
 
-      if ((mfhrc = msg_fetch_header (idata->ctx, &h, idata->cmd.buf, fp)) == -1)
-       continue;
+      if ((mfhrc =
+           msg_fetch_header (idata->ctx, &h, idata->cmd.buf, fp)) == -1)
+        continue;
       else if (mfhrc < 0)
-       break;
+        break;
 
       /* make sure we don't get remnants from older larger message headers */
       fputs ("\n\n", fp);
@@ -261,7 +259,9 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
 
       ctx->hdrs[msgno]->index = h.sid - 1;
       if (h.sid != ctx->msgcount + 1)
-       dprint (1, (debugfile, "imap_read_headers: msgcount and sequence ID are inconsistent!"));
+        dprint (1,
+                (debugfile,
+                 "imap_read_headers: msgcount and sequence ID are inconsistent!"));
       /* messages which have not been expunged are ACTIVE (borrowed from mh 
        * folders) */
       ctx->hdrs[msgno]->active = 1;
@@ -278,36 +278,35 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
       /* NOTE: if Date: header is missing, mutt_read_rfc822_header depends
        *   on h.received being set */
       ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno],
-        0, 0);
+                                                       0, 0);
       /* content built as a side-effect of mutt_read_rfc822_header */
       ctx->hdrs[msgno]->content->length = h.content_length;
 
 #if USE_HCACHE
-      sprintf(uid_buf, "/%u", h.data->uid);
-      mutt_hcache_store(hc, uid_buf, ctx->hdrs[msgno], idata->uid_validity, &imap_hcache_keylen);
+      sprintf (uid_buf, "/%u", h.data->uid);
+      mutt_hcache_store (hc, uid_buf, ctx->hdrs[msgno], idata->uid_validity,
+                         &imap_hcache_keylen);
 #endif /* USE_HCACHE */
 
       ctx->msgcount++;
     }
     while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) ||
-      ((msgno + 1) >= fetchlast)));
+                                   ((msgno + 1) >= fetchlast)));
 
-    if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
-    {
-      imap_free_header_data ((void**) &h.data);
+    if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
+      imap_free_header_data ((void **) &h.data);
       fclose (fp);
 #if USE_HCACHE
-  mutt_hcache_close (hc);
+      mutt_hcache_close (hc);
 #endif /* USE_HCACHE */
       return -1;
     }
-       
+
     /* in case we get new mail while fetching the headers */
-    if (idata->reopen & IMAP_NEWMAIL_PENDING)
-    {
+    if (idata->reopen & IMAP_NEWMAIL_PENDING) {
       msgend = idata->newMailCount - 1;
       while ((msgend) >= ctx->hdrmax)
-       mx_alloc_memory (ctx);
+        mx_alloc_memory (ctx);
       idata->reopen &= ~IMAP_NEWMAIL_PENDING;
       idata->newMailCount = 0;
     }
@@ -317,7 +316,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   mutt_hcache_close (hc);
 #endif /* USE_HCACHE */
 
-  fclose(fp);
+  fclose (fp);
 
   if (ctx->msgcount > oldmsgcount)
     mx_update_context (ctx, ctx->msgcount - oldmsgcount);
@@ -325,10 +324,10 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
   return msgend;
 }
 
-int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
+int imap_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
 {
-  IMAP_DATAidata;
-  HEADERh;
+  IMAP_DATA *idata;
+  HEADER *h;
   char buf[LONG_STRING];
   char path[_POSIX_PATH_MAX];
   char *pc;
@@ -338,45 +337,41 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   IMAP_CACHE *cache;
   int read;
   int rc;
+
   /* Sam's weird courier server returns an OK response even when FETCH
    * fails. Thanks Sam. */
   short fetched = 0;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
   h = ctx->hdrs[msgno];
 
   /* see if we already have the message in our cache */
-  cacheno = HEADER_DATA(h)->uid % IMAP_CACHE_LEN;
+  cacheno = HEADER_DATA (h)->uid % IMAP_CACHE_LEN;
   cache = &idata->cache[cacheno];
 
-  if (cache->path)
-  {
-    if (cache->uid == HEADER_DATA(h)->uid)
-    {
+  if (cache->path) {
+    if (cache->uid == HEADER_DATA (h)->uid) {
       /* yes, so just return a pointer to the message */
-      if (!(msg->fp = fopen (cache->path, "r")))
-      {
-       mutt_perror (cache->path);
-       return (-1);
+      if (!(msg->fp = fopen (cache->path, "r"))) {
+        mutt_perror (cache->path);
+        return (-1);
       }
       return 0;
     }
-    else
-    {
+    else {
       /* clear the previous entry */
       unlink (cache->path);
       FREE (&cache->path);
     }
   }
 
-  if (!isendwin())
+  if (!isendwin ())
     mutt_message _("Fetching message...");
 
-  cache->uid = HEADER_DATA(h)->uid;
+  cache->uid = HEADER_DATA (h)->uid;
   mutt_mktemp (path);
   cache->path = safe_strdup (path);
-  if (!(msg->fp = safe_fopen (path, "w+")))
-  {
+  if (!(msg->fp = safe_fopen (path, "w+"))) {
     FREE (&cache->path);
     return -1;
   }
@@ -385,15 +380,13 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
    * also try to update it. HACK until all this code can be moved into the
    * command handler */
   h->active = 0;
-  
-  snprintf (buf, sizeof (buf), "UID FETCH %u %s", HEADER_DATA(h)->uid,
-           (mutt_bit_isset (idata->capabilities, IMAP4REV1) ?
-            (option (OPTIMAPPEEK) ? "BODY.PEEK[]" : "BODY[]") :
-            "RFC822"));
+
+  snprintf (buf, sizeof (buf), "UID FETCH %u %s", HEADER_DATA (h)->uid,
+            (mutt_bit_isset (idata->capabilities, IMAP4REV1) ?
+             (option (OPTIMAPPEEK) ? "BODY.PEEK[]" : "BODY[]") : "RFC822"));
 
   imap_cmd_start (idata, buf);
-  do
-  {
+  do {
     if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
       break;
 
@@ -401,47 +394,42 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
     pc = imap_next_word (pc);
     pc = imap_next_word (pc);
 
-    if (!ascii_strncasecmp ("FETCH", pc, 5))
-    {
-      while (*pc)
-      {
-       pc = imap_next_word (pc);
-       if (pc[0] == '(')
-         pc++;
-       if (ascii_strncasecmp ("UID", pc, 3) == 0)
-       {
-         pc = imap_next_word (pc);
-         uid = atoi (pc);
-         if (uid != HEADER_DATA(h)->uid)
-           mutt_error (_("The message index is incorrect. Try reopening the mailbox."));
-       }
-       else if ((ascii_strncasecmp ("RFC822", pc, 6) == 0) ||
-                (ascii_strncasecmp ("BODY[]", pc, 6) == 0))
-       {
-         pc = imap_next_word (pc);
-         if (imap_get_literal_count(pc, &bytes) < 0)
-         {
-           imap_error ("imap_fetch_message()", buf);
-           goto bail;
-         }
-         if (imap_read_literal (msg->fp, idata, bytes) < 0)
-           goto bail;
-         /* pick up trailing line */
-         if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
-           goto bail;
-         pc = idata->cmd.buf;
-
-         fetched = 1;
-       }
-       /* UW-IMAP will provide a FLAGS update here if the FETCH causes a
-        * change (eg from \Unseen to \Seen).
-        * Uncommitted changes in mutt take precedence. If we decide to
-        * incrementally update flags later, this won't stop us syncing */
-       else if ((ascii_strncasecmp ("FLAGS", pc, 5) == 0) && !h->changed)
-       {
-         if ((pc = imap_set_flags (idata, h, pc)) == NULL)
-           goto bail;
-       }
+    if (!ascii_strncasecmp ("FETCH", pc, 5)) {
+      while (*pc) {
+        pc = imap_next_word (pc);
+        if (pc[0] == '(')
+          pc++;
+        if (ascii_strncasecmp ("UID", pc, 3) == 0) {
+          pc = imap_next_word (pc);
+          uid = atoi (pc);
+          if (uid != HEADER_DATA (h)->uid)
+            mutt_error (_
+                        ("The message index is incorrect. Try reopening the mailbox."));
+        }
+        else if ((ascii_strncasecmp ("RFC822", pc, 6) == 0) ||
+                 (ascii_strncasecmp ("BODY[]", pc, 6) == 0)) {
+          pc = imap_next_word (pc);
+          if (imap_get_literal_count (pc, &bytes) < 0) {
+            imap_error ("imap_fetch_message()", buf);
+            goto bail;
+          }
+          if (imap_read_literal (msg->fp, idata, bytes) < 0)
+            goto bail;
+          /* pick up trailing line */
+          if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
+            goto bail;
+          pc = idata->cmd.buf;
+
+          fetched = 1;
+        }
+        /* UW-IMAP will provide a FLAGS update here if the FETCH causes a
+         * change (eg from \Unseen to \Seen).
+         * Uncommitted changes in mutt take precedence. If we decide to
+         * incrementally update flags later, this won't stop us syncing */
+        else if ((ascii_strncasecmp ("FLAGS", pc, 5) == 0) && !h->changed) {
+          if ((pc = imap_set_flags (idata, h, pc)) == NULL)
+            goto bail;
+        }
       }
     }
   }
@@ -455,7 +443,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
 
   if (!fetched || !imap_code (idata->cmd.buf))
     goto bail;
-    
+
   /* Update the header information.  Previously, we only downloaded a
    * portion of the headers, those required for the main display.
    */
@@ -484,16 +472,14 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
 
   /* see above. We want the new status in h->read, so we unset it manually
    * and let mutt_set_flag set it correctly, updating context. */
-  if (read != h->read)
-  {
+  if (read != h->read) {
     h->read = read;
     mutt_set_flag (ctx, h, M_NEW, read);
   }
 
   h->lines = 0;
   fgets (buf, sizeof (buf), msg->fp);
-  while (!feof (msg->fp))
-  {
+  while (!feof (msg->fp)) {
     h->lines++;
     fgets (buf, sizeof (buf), msg->fp);
   }
@@ -505,15 +491,14 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   h->security = crypt_query (h->content);
 #endif
 
-  mutt_clear_error();
+  mutt_clear_error ();
   rewind (msg->fp);
 
   return 0;
 
 bail:
   safe_fclose (&msg->fp);
-  if (cache->path)
-  {
+  if (cache->path) {
     unlink (cache->path);
     FREE (&cache->path);
   }
@@ -521,27 +506,26 @@ bail:
   return -1;
 }
 
-int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
+int imap_append_message (CONTEXT * ctx, MESSAGE * msg)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   FILE *fp;
   char buf[LONG_STRING];
   char mbox[LONG_STRING];
-  char mailbox[LONG_STRING]; 
+  char mailbox[LONG_STRING];
   size_t len;
   int c, last;
   IMAP_MBOX mx;
   int rc;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
   if (imap_parse_path (ctx->path, &mx))
     return -1;
 
   imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox));
-  
-  if ((fp = fopen (msg->path, "r")) == NULL)
-  {
+
+  if ((fp = fopen (msg->path, "r")) == NULL) {
     mutt_perror (msg->path);
     goto fail;
   }
@@ -552,23 +536,22 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
    * expensive (it'd be nice if we had the file size passed in already
    * by the code that writes the file, but that's a lot of changes.
    * Ideally we'd have a HEADER structure with flag info here... */
-  for (last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)
-  {
-    if(c == '\n' && last != '\r')
+  for (last = EOF, len = 0; (c = fgetc (fp)) != EOF; last = c) {
+    if (c == '\n' && last != '\r')
       len++;
 
     len++;
   }
   rewind (fp);
-  
+
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
   snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) {%lu}", mbox,
-           msg->flags.read    ? "\\Seen"      : "",
-           msg->flags.read && (msg->flags.replied || msg->flags.flagged) ? " " : "",
-           msg->flags.replied ? "\\Answered" : "",
-           msg->flags.replied && msg->flags.flagged ? " " : "",
-           msg->flags.flagged ? "\\Flagged"  : "",
-           (unsigned long) len);
+            msg->flags.read ? "\\Seen" : "",
+            msg->flags.read && (msg->flags.replied
+                                || msg->flags.flagged) ? " " : "",
+            msg->flags.replied ? "\\Answered" : "", msg->flags.replied
+            && msg->flags.flagged ? " " : "",
+            msg->flags.flagged ? "\\Flagged" : "", (unsigned long) len);
 
   imap_cmd_start (idata, buf);
 
@@ -576,12 +559,11 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (rc != IMAP_CMD_RESPOND)
-  {
+  if (rc != IMAP_CMD_RESPOND) {
     char *pc;
 
     dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
-               idata->cmd.buf));
+                idata->cmd.buf));
 
     pc = idata->cmd.buf + SEQLEN;
     SKIPWS (pc);
@@ -594,19 +576,18 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
 
   mutt_message _("Uploading message ...");
 
-  for (last = EOF, len = 0; (c = fgetc(fp)) != EOF; last = c)
-  {
+  for (last = EOF, len = 0; (c = fgetc (fp)) != EOF; last = c) {
     if (c == '\n' && last != '\r')
       buf[len++] = '\r';
 
     buf[len++] = c;
 
-    if (len > sizeof(buf) - 3)
-      flush_buffer(buf, &len, idata->conn);
+    if (len > sizeof (buf) - 3)
+      flush_buffer (buf, &len, idata->conn);
   }
-  
+
   if (len)
-    flush_buffer(buf, &len, idata->conn);
+    flush_buffer (buf, &len, idata->conn);
 
   mutt_socket_write (idata->conn, "\r\n");
   fclose (fp);
@@ -615,12 +596,11 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
     rc = imap_cmd_step (idata);
   while (rc == IMAP_CMD_CONTINUE);
 
-  if (!imap_code (idata->cmd.buf))
-  {
+  if (!imap_code (idata->cmd.buf)) {
     char *pc;
 
     dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
-               idata->cmd.buf));
+                idata->cmd.buf));
     pc = idata->cmd.buf + SEQLEN;
     SKIPWS (pc);
     pc = imap_next_word (pc);
@@ -632,7 +612,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   FREE (&mx.mbox);
   return -1;
 }
@@ -643,9 +623,9 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
  *      -1: error
  *       0: success
  *       1: non-fatal error - try fetch/append */
-int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
+int imap_copy_messages (CONTEXT * ctx, HEADER * h, char *dest, int delete)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   BUFFER cmd;
   char uid[11];
   char mbox[LONG_STRING];
@@ -654,59 +634,55 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
   int n;
   IMAP_MBOX mx;
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
-  if (imap_parse_path (dest, &mx))
-  {
+  if (imap_parse_path (dest, &mx)) {
     dprint (1, (debugfile, "imap_copy_messages: bad destination %s\n", dest));
     return -1;
   }
 
   /* check that the save-to folder is in the same account */
-  if (!mutt_account_match (&(CTX_DATA->conn->account), &(mx.account)))
-  {
+  if (!mutt_account_match (&(CTX_DATA->conn->account), &(mx.account))) {
     dprint (3, (debugfile, "imap_copy_messages: %s not same server as %s\n",
-      dest, ctx->path));
+                dest, ctx->path));
     return 1;
   }
 
-  if (h && h->attach_del)
-  {
-    dprint (3, (debugfile, "imap_copy_messages: Message contains attachments to be deleted\n"));
+  if (h && h->attach_del) {
+    dprint (3,
+            (debugfile,
+             "imap_copy_messages: Message contains attachments to be deleted\n"));
     return 1;
   }
-  
+
   imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
 
   memset (&cmd, 0, sizeof (cmd));
   mutt_buffer_addstr (&cmd, "UID COPY ");
 
   /* Null HEADER* means copy tagged messages */
-  if (!h)
-  {
+  if (!h) {
     /* if any messages have attachments to delete, fall through to FETCH
      * and APPEND. TODO: Copy what we can with COPY, fall through for the
      * remainder. */
-    for (n = 0; n < ctx->msgcount; n++)
-    {
-      if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->attach_del)
-      {
-       dprint (3, (debugfile, "imap_copy_messages: Message contains attachments to be deleted\n"));
-       return 1;
+    for (n = 0; n < ctx->msgcount; n++) {
+      if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->attach_del) {
+        dprint (3,
+                (debugfile,
+                 "imap_copy_messages: Message contains attachments to be deleted\n"));
+        return 1;
       }
     }
 
     rc = imap_make_msg_set (idata, &cmd, M_TAG, 0);
-    if (!rc)
-    {
+    if (!rc) {
       dprint (1, (debugfile, "imap_copy_messages: No messages tagged\n"));
       goto fail;
     }
     mutt_message (_("Copying %d messages to %s..."), rc, mbox);
   }
-  else
-  {
-    mutt_message (_("Copying message %d to %s..."), h->index+1, mbox);
+  else {
+    mutt_message (_("Copying message %d to %s..."), h->index + 1, mbox);
     snprintf (uid, sizeof (uid), "%u", HEADER_DATA (h)->uid);
     mutt_buffer_addstr (&cmd, uid);
   }
@@ -717,18 +693,17 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
   mutt_buffer_addstr (&cmd, mmbox);
 
   rc = imap_exec (idata, cmd.data, IMAP_CMD_FAIL_OK);
-  if (rc == -2)
-  {
+  if (rc == -2) {
     /* bail out if command failed for reasons other than nonexistent target */
-    if (ascii_strncasecmp (imap_get_qualifier (idata->cmd.buf), "[TRYCREATE]", 11))
-    {
+    if (ascii_strncasecmp
+        (imap_get_qualifier (idata->cmd.buf), "[TRYCREATE]", 11)) {
       imap_error ("imap_copy_messages", idata->cmd.buf);
       goto fail;
     }
-    dprint (2, (debugfile, "imap_copy_messages: server suggests TRYCREATE\n"));
+    dprint (2,
+            (debugfile, "imap_copy_messages: server suggests TRYCREATE\n"));
     snprintf (mmbox, sizeof (mmbox), _("Create %s?"), mbox);
-    if (option (OPTCONFIRMCREATE) && mutt_yesorno (mmbox, 1) < 1)
-    {
+    if (option (OPTCONFIRMCREATE) && mutt_yesorno (mmbox, 1) < 1) {
       mutt_clear_error ();
       goto fail;
     }
@@ -738,28 +713,23 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
     /* try again */
     rc = imap_exec (idata, cmd.data, 0);
   }
-  if (rc != 0)
-  {
+  if (rc != 0) {
     imap_error ("imap_copy_messages", idata->cmd.buf);
     goto fail;
   }
 
   /* cleanup */
-  if (delete)
-  {
+  if (delete) {
     if (!h)
-      for (n = 0; n < ctx->msgcount; n++)
-      {
-        if (ctx->hdrs[n]->tagged)
-        {
+      for (n = 0; n < ctx->msgcount; n++) {
+        if (ctx->hdrs[n]->tagged) {
           mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1);
-         mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1);
+          mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1);
           if (option (OPTDELETEUNTAG))
             mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0);
         }
       }
-    else
-    {
+    else {
       mutt_set_flag (ctx, h, M_DELETE, 1);
       mutt_set_flag (ctx, h, M_APPENDED, 1);
       if (option (OPTDELETEUNTAG))
@@ -772,7 +742,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
   FREE (&mx.mbox);
   return 0;
 
- fail:
+fail:
   if (cmd.data)
     FREE (&cmd.data);
   FREE (&mx.mbox);
@@ -781,19 +751,18 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
 
 /* imap_add_keywords: concatenate custom IMAP tags to list, if they
  *   appear in the folder flags list. Why wouldn't they? */
-void imap_add_keywords (char* s, HEADER* h, LIST* mailbox_flags, size_t slen)
+void imap_add_keywords (char *s, HEADER * h, LIST * mailbox_flags,
+                        size_t slen)
 {
   LIST *keywords;
 
-  if (!mailbox_flags || !HEADER_DATA(h) || !HEADER_DATA(h)->keywords)
+  if (!mailbox_flags || !HEADER_DATA (h) || !HEADER_DATA (h)->keywords)
     return;
 
-  keywords = HEADER_DATA(h)->keywords->next;
+  keywords = HEADER_DATA (h)->keywords->next;
 
-  while (keywords)
-  {
-    if (msg_has_flag (mailbox_flags, keywords->data))
-    {
+  while (keywords) {
+    if (msg_has_flag (mailbox_flags, keywords->data)) {
       safe_strcat (s, slen, keywords->data);
       safe_strcat (s, slen, " ");
     }
@@ -802,19 +771,19 @@ void imap_add_keywords (char* s, HEADER* h, LIST* mailbox_flags, size_t slen)
 }
 
 /* imap_free_header_data: free IMAP_HEADER structure */
-void imap_free_header_data (void** data)
+void imap_free_header_data (void **data)
 {
   /* this should be safe even if the list wasn't used */
-  mutt_free_list (&(((IMAP_HEADER_DATA*) *data)->keywords));
+  mutt_free_list (&(((IMAP_HEADER_DATA *) * data)->keywords));
 
   FREE (data);
 }
 
 /* imap_set_flags: fill out the message header according to the flags from
  *   the server. Expects a flags line of the form "FLAGS (flag flag ...)" */
-char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s)
+char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s)
 {
-  CONTEXTctx = idata->ctx;
+  CONTEXT *ctx = idata->ctx;
   IMAP_HEADER newh;
   unsigned char readonly;
 
@@ -822,19 +791,18 @@ char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s)
   newh.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA));
 
   dprint (2, (debugfile, "imap_fetch_message: parsing FLAGS\n"));
-  if ((s = msg_parse_flags (&newh, s)) == NULL)
-  {
+  if ((s = msg_parse_flags (&newh, s)) == NULL) {
     FREE (&newh.data);
     return NULL;
   }
-  
+
   /* YAUH (yet another ugly hack): temporarily set context to
    * read-write even if it's read-only, so *server* updates of
    * flags can be processed by mutt_set_flag. ctx->changed must
    * be restored afterwards */
   readonly = ctx->readonly;
   ctx->readonly = 0;
-           
+
   mutt_set_flag (ctx, h, M_NEW, !(newh.read || newh.old));
   mutt_set_flag (ctx, h, M_OLD, newh.old);
   mutt_set_flag (ctx, h, M_READ, newh.read);
@@ -848,9 +816,9 @@ char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s)
   ctx->changed &= ~readonly;
   ctx->readonly = readonly;
 
-  mutt_free_list (&(HEADER_DATA(h)->keywords));
-  HEADER_DATA(h)->keywords = newh.data->keywords;
-  FREE(&newh.data);
+  mutt_free_list (&(HEADER_DATA (h)->keywords));
+  HEADER_DATA (h)->keywords = newh.data->keywords;
+  FREE (&newh.data);
 
   return s;
 }
@@ -862,17 +830,18 @@ char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s)
  *      0 on success
  *     -1 if the string is not a fetch response
  *     -2 if the string is a corrupt fetch response */
-static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
+static int msg_fetch_header (CONTEXT * ctx, IMAP_HEADER * h, char *buf,
+                             FILE * fp)
 {
-  IMAP_DATAidata;
+  IMAP_DATA *idata;
   long bytes;
-  int rc = -1; /* default now is that string isn't FETCH response*/
+  int rc = -1;                  /* default now is that string isn't FETCH response */
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
   if (buf[0] != '*')
     return rc;
-  
+
   /* skip to message number */
   buf = imap_next_word (buf);
   h->sid = atoi (buf);
@@ -882,7 +851,7 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
   if (ascii_strncasecmp ("FETCH", buf, 5))
     return rc;
 
-  rc = -2; /* we've got a FETCH response, for better or worse */
+  rc = -2;                      /* we've got a FETCH response, for better or worse */
   if (!(buf = strchr (buf, '(')))
     return rc;
   buf++;
@@ -891,9 +860,8 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
    *   read header lines and call it again. Silly. */
   if (msg_parse_fetch (h, buf) != -2)
     return rc;
-  
-  if (imap_get_literal_count (buf, &bytes) == 0)
-  {
+
+  if (imap_get_literal_count (buf, &bytes) == 0) {
     imap_read_literal (fp, idata, bytes);
 
     /* we may have other fields of the FETCH _after_ the literal
@@ -902,13 +870,13 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
      * interchangeably at any time. */
     if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE)
       return rc;
-  
+
     if (msg_parse_fetch (h, idata->cmd.buf) == -1)
       return rc;
   }
 
-  rc = 0; /* success */
-  
+  rc = 0;                       /* success */
+
   /* subtract headers from message size - unfortunately only the subset of
    * headers we've requested. */
   h->content_length -= bytes;
@@ -919,7 +887,7 @@ static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
 #if USE_HCACHE
 static size_t imap_hcache_keylen (const char *fn)
 {
-  return mutt_strlen(fn);
+  return mutt_strlen (fn);
 }
 
 /* msg_fetch_header: import IMAP FETCH response into an IMAP_HEADER.
@@ -928,12 +896,13 @@ static size_t imap_hcache_keylen (const char *fn)
  *      0 on success
  *     -1 if the string is not a fetch response
  *     -2 if the string is a corrupt fetch response */
-static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
+static int msg_fetch_header_fetch (CONTEXT * ctx, IMAP_HEADER * h, char *buf,
+                                   FILE * fp)
 {
-  IMAP_DATAidata;
-  int rc = -1; /* default now is that string isn't FETCH response*/
+  IMAP_DATA *idata;
+  int rc = -1;                  /* default now is that string isn't FETCH response */
 
-  idata = (IMAP_DATA*) ctx->data;
+  idata = (IMAP_DATA *) ctx->data;
 
   if (buf[0] != '*')
     return rc;
@@ -947,13 +916,13 @@ static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE
   if (ascii_strncasecmp ("FETCH", buf, 5))
     return rc;
 
-  rc = -2; /* we've got a FETCH response, for better or worse */
+  rc = -2;                      /* we've got a FETCH response, for better or worse */
   if (!(buf = strchr (buf, '(')))
     return rc;
   buf++;
 
   if (msg_parse_fetch (h, buf) < 0) {
-         return -2;
+    return -2;
   }
 
   if (!(buf = strchr (buf, ')')))
@@ -967,14 +936,13 @@ static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE
 
 /* msg_has_flag: do a caseless comparison of the flag against a flag list,
  *   return 1 if found or flag list has '\*', 0 otherwise */
-static int msg_has_flag (LIST* flag_list, const char* flag)
+static int msg_has_flag (LIST * flag_list, const char *flag)
 {
   if (!flag_list)
     return 0;
 
   flag_list = flag_list->next;
-  while (flag_list)
-  {
+  while (flag_list) {
     if (!ascii_strncasecmp (flag_list->data, flag, strlen (flag_list->data)))
       return 1;
 
@@ -985,7 +953,7 @@ static int msg_has_flag (LIST* flag_list, const char* flag)
 }
 
 /* msg_parse_fetch: handle headers returned from header fetch */
-static int msg_parse_fetch (IMAP_HEADER *h, char *s)
+static int msg_parse_fetch (IMAP_HEADER * h, char *s)
 {
   char tmp[SHORT_STRING];
   char *ptmp;
@@ -993,30 +961,27 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
   if (!s)
     return -1;
 
-  while (*s)
-  {
+  while (*s) {
     SKIPWS (s);
 
-    if (ascii_strncasecmp ("FLAGS", s, 5) == 0)
-    {
+    if (ascii_strncasecmp ("FLAGS", s, 5) == 0) {
       if ((s = msg_parse_flags (h, s)) == NULL)
         return -1;
     }
-    else if (ascii_strncasecmp ("UID", s, 3) == 0)
-    {
+    else if (ascii_strncasecmp ("UID", s, 3) == 0) {
       s += 3;
       SKIPWS (s);
       h->data->uid = (unsigned int) atoi (s);
 
       s = imap_next_word (s);
     }
-    else if (ascii_strncasecmp ("INTERNALDATE", s, 12) == 0)
-    {
+    else if (ascii_strncasecmp ("INTERNALDATE", s, 12) == 0) {
       s += 12;
       SKIPWS (s);
-      if (*s != '\"')
-      {
-        dprint (1, (debugfile, "msg_parse_fetch(): bogus INTERNALDATE entry: %s\n", s));
+      if (*s != '\"') {
+        dprint (1,
+                (debugfile,
+                 "msg_parse_fetch(): bogus INTERNALDATE entry: %s\n", s));
         return -1;
       }
       s++;
@@ -1025,12 +990,11 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
         *ptmp++ = *s++;
       if (*s != '\"')
         return -1;
-      s++; /* skip past the trailing " */
+      s++;                      /* skip past the trailing " */
       *ptmp = 0;
       h->received = imap_parse_date (tmp);
     }
-    else if (ascii_strncasecmp ("RFC822.SIZE", s, 11) == 0)
-    {
+    else if (ascii_strncasecmp ("RFC822.SIZE", s, 11) == 0) {
       s += 11;
       SKIPWS (s);
       ptmp = tmp;
@@ -1040,15 +1004,13 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
       h->content_length = atoi (tmp);
     }
     else if (!ascii_strncasecmp ("BODY", s, 4) ||
-      !ascii_strncasecmp ("RFC822.HEADER", s, 13))
-    {
+             !ascii_strncasecmp ("RFC822.HEADER", s, 13)) {
       /* handle above, in msg_fetch_header */
       return -2;
     }
     else if (*s == ')')
-      s++; /* end of request */
-    else if (*s)
-    {
+      s++;                      /* end of request */
+    else if (*s) {
       /* got something i don't understand */
       imap_error ("msg_parse_fetch", s);
       return -1;
@@ -1059,60 +1021,49 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s)
 }
 
 /* msg_parse_flags: read a FLAGS token into an IMAP_HEADER */
-static char* msg_parse_flags (IMAP_HEADER* h, char* s)
+static char *msg_parse_flags (IMAP_HEADER * h, char *s)
 {
   int recent = 0;
 
   /* sanity-check string */
-  if (ascii_strncasecmp ("FLAGS", s, 5) != 0)
-  {
-    dprint (1, (debugfile, "msg_parse_flags: not a FLAGS response: %s\n",
-      s));
+  if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
+    dprint (1, (debugfile, "msg_parse_flags: not a FLAGS response: %s\n", s));
     return NULL;
   }
   s += 5;
-  SKIPWS(s);
-  if (*s != '(')
-  {
-    dprint (1, (debugfile, "msg_parse_flags: bogus FLAGS response: %s\n",
-      s));
+  SKIPWS (s);
+  if (*s != '(') {
+    dprint (1, (debugfile, "msg_parse_flags: bogus FLAGS response: %s\n", s));
     return NULL;
   }
   s++;
 
   /* start parsing */
-  while (*s && *s != ')')
-  {
-    if (ascii_strncasecmp ("\\deleted", s, 8) == 0)
-    {
+  while (*s && *s != ')') {
+    if (ascii_strncasecmp ("\\deleted", s, 8) == 0) {
       s += 8;
       h->deleted = 1;
     }
-    else if (ascii_strncasecmp ("\\flagged", s, 8) == 0)
-    {
+    else if (ascii_strncasecmp ("\\flagged", s, 8) == 0) {
       s += 8;
       h->flagged = 1;
     }
-    else if (ascii_strncasecmp ("\\answered", s, 9) == 0)
-    {
+    else if (ascii_strncasecmp ("\\answered", s, 9) == 0) {
       s += 9;
       h->replied = 1;
     }
-    else if (ascii_strncasecmp ("\\seen", s, 5) == 0)
-    {
+    else if (ascii_strncasecmp ("\\seen", s, 5) == 0) {
       s += 5;
       h->read = 1;
     }
-    else if (ascii_strncasecmp ("\\recent", s, 5) == 0)
-    {
+    else if (ascii_strncasecmp ("\\recent", s, 5) == 0) {
       s += 7;
       recent = 1;
     }
-    else
-    {
+    else {
       /* store custom flags as well */
       char ctmp;
-      charflag_word = s;
+      char *flag_word = s;
 
       if (!h->data->keywords)
         h->data->keywords = mutt_new_list ();
@@ -1124,30 +1075,28 @@ static char* msg_parse_flags (IMAP_HEADER* h, char* s)
       mutt_add_list (h->data->keywords, flag_word);
       *s = ctmp;
     }
-    SKIPWS(s);
+    SKIPWS (s);
   }
 
   /* wrap up, or note bad flags response */
-  if (*s == ')')
-  {
+  if (*s == ')') {
     /* if a message is neither seen nor recent, it is OLD. */
     if (option (OPTMARKOLD) && !recent && !(h->read))
       h->old = 1;
     s++;
   }
-  else
-  {
+  else {
     dprint (1, (debugfile,
-      "msg_parse_flags: Unterminated FLAGS response: %s\n", s));
+                "msg_parse_flags: Unterminated FLAGS response: %s\n", s));
     return NULL;
   }
 
   return s;
 }
 
-static void flush_buffer(char *buf, size_t *len, CONNECTION *conn)
+static void flush_buffer (char *buf, size_t * len, CONNECTION * conn)
 {
   buf[*len] = '\0';
-  mutt_socket_write(conn, buf);
+  mutt_socket_write (conn, buf);
   *len = 0;
 }
index 78c5dc3..525444f 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* message.c data structures */
 
 
 /* -- data structures -- */
 /* IMAP-specific header data, stored as HEADER->data */
-typedef struct imap_header_data
-{
-  unsigned int uid;    /* 32-bit Message UID */
+typedef struct imap_header_data {
+  unsigned int uid;             /* 32-bit Message UID */
   LIST *keywords;
 } IMAP_HEADER_DATA;
 
-typedef struct
-{
-  unsigned int read : 1;
-  unsigned int old : 1;
-  unsigned int deleted : 1;
-  unsigned int flagged : 1;
-  unsigned int replied : 1;
-  unsigned int changed : 1;
+typedef struct {
+  unsigned int read:1;
+  unsigned int old:1;
+  unsigned int deleted:1;
+  unsigned int flagged:1;
+  unsigned int replied:1;
+  unsigned int changed:1;
 
   unsigned int sid;
 
-  IMAP_HEADER_DATAdata;
+  IMAP_HEADER_DATA *data;
 
   time_t received;
   long content_length;
index b5b871c..690182b 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include "imap_private.h"
 
 static int Index_64[128] = {
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-    -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, 63,-1,-1,-1,
-    52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
-    -1, 0, 1, 2,  3, 4, 5, 6,  7, 8, 9,10, 11,12,13,14,
-    15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
-    -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
-    41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, 63, -1, -1, -1,
+  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+  -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+  15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+  -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
 };
 
 static char B64Chars[64] = {
@@ -54,70 +54,61 @@ static char B64Chars[64] = {
  * of &AMAAwA-).
  */
 static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
-  size_t *u8len)
+                           size_t * u8len)
 {
   char *buf, *p;
   int b, ch, k;
 
   p = buf = safe_malloc (u7len + u7len / 8 + 1);
 
-  for (; u7len; u7++, u7len--)
-  {
-    if (*u7 == '&')
-    {
+  for (; u7len; u7++, u7len--) {
+    if (*u7 == '&') {
       u7++, u7len--;
 
-      if (u7len && *u7 == '-')
-      {
-       *p++ = '&';
-       continue;
+      if (u7len && *u7 == '-') {
+        *p++ = '&';
+        continue;
       }
 
       ch = 0;
       k = 10;
-      for (; u7len; u7++, u7len--)
-      {
-       if ((*u7 & 0x80) || (b = Index_64[(int)*u7]) == -1)
-         break;
-       if (k > 0)
-       {
-         ch |= b << k;
-         k -= 6;
-       }
-       else
-       {
-         ch |= b >> (-k);
-         if (ch < 0x80)
-         {
-           if (0x20 <= ch && ch < 0x7f)
-             /* Printable US-ASCII */
-             goto bail;
-           *p++ = ch;
-         }
-         else if (ch < 0x800)
-         {
-           *p++ = 0xc0 | (ch >> 6);
-           *p++ = 0x80 | (ch & 0x3f);
-         }
-         else
-         {
-           *p++ = 0xe0 | (ch >> 12);
-           *p++ = 0x80 | ((ch >> 6) & 0x3f);
-           *p++ = 0x80 | (ch & 0x3f);
-         }
-         ch = (b << (16 + k)) & 0xffff;
-         k += 10;
-       }
+      for (; u7len; u7++, u7len--) {
+        if ((*u7 & 0x80) || (b = Index_64[(int) *u7]) == -1)
+          break;
+        if (k > 0) {
+          ch |= b << k;
+          k -= 6;
+        }
+        else {
+          ch |= b >> (-k);
+          if (ch < 0x80) {
+            if (0x20 <= ch && ch < 0x7f)
+              /* Printable US-ASCII */
+              goto bail;
+            *p++ = ch;
+          }
+          else if (ch < 0x800) {
+            *p++ = 0xc0 | (ch >> 6);
+            *p++ = 0x80 | (ch & 0x3f);
+          }
+          else {
+            *p++ = 0xe0 | (ch >> 12);
+            *p++ = 0x80 | ((ch >> 6) & 0x3f);
+            *p++ = 0x80 | (ch & 0x3f);
+          }
+          ch = (b << (16 + k)) & 0xffff;
+          k += 10;
+        }
       }
       if (ch || k < 6)
-       /* Non-zero or too many extra bits */
-       goto bail;
+        /* Non-zero or too many extra bits */
+        goto bail;
       if (!u7len || *u7 != '-')
-       /* BASE64 not properly terminated */
-       goto bail;
+        /* BASE64 not properly terminated */
+        goto bail;
       if (u7len > 2 && u7[1] == '&' && u7[2] != '-')
-       /* Adjacent BASE64 sections */
-       goto bail;
+        /* Adjacent BASE64 sections */
+        goto bail;
     }
     else if (*u7 < 0x20 || *u7 >= 0x7f)
       /* Not printable US-ASCII */
@@ -134,7 +125,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
     *u8 = buf;
   return buf;
 
- bail:
+bail:
   FREE (&buf);
   return 0;
 }
@@ -147,7 +138,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
  * If input data is invalid, return 0 and don't store anything.
  */
 static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
-  size_t *u7len)
+                           size_t * u7len)
 {
   char *buf, *p;
   int ch;
@@ -160,8 +151,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
    */
   p = buf = safe_malloc ((u8len / 2) * 7 + 6);
 
-  while (u8len)
-  {
+  while (u8len) {
     unsigned char c = *u8;
 
     if (c < 0x80)
@@ -184,57 +174,50 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
     u8++, u8len--;
     if (n > u8len)
       goto bail;
-    for (i = 0; i < n; i++)
-    {
+    for (i = 0; i < n; i++) {
       if ((u8[i] & 0xc0) != 0x80)
-       goto bail;
+        goto bail;
       ch = (ch << 6) | (u8[i] & 0x3f);
     }
     if (n > 1 && !(ch >> (n * 5 + 1)))
       goto bail;
     u8 += n, u8len -= n;
 
-    if (ch < 0x20 || ch >= 0x7f)
-    {
-      if (!base64)
-      {
-       *p++ = '&';
-       base64 = 1;
-       b = 0;
-       k = 10;
+    if (ch < 0x20 || ch >= 0x7f) {
+      if (!base64) {
+        *p++ = '&';
+        base64 = 1;
+        b = 0;
+        k = 10;
       }
       if (ch & ~0xffff)
-       ch = 0xfffe;
+        ch = 0xfffe;
       *p++ = B64Chars[b | ch >> k];
       k -= 6;
       for (; k >= 0; k -= 6)
-       *p++ = B64Chars[(ch >> k) & 0x3f];
+        *p++ = B64Chars[(ch >> k) & 0x3f];
       b = (ch << (-k)) & 0x3f;
       k += 16;
     }
-    else
-    {
-      if (base64)
-      {
-       if (k > 10)
-         *p++ = B64Chars[b];
-       *p++ = '-';
-       base64 = 0;
+    else {
+      if (base64) {
+        if (k > 10)
+          *p++ = B64Chars[b];
+        *p++ = '-';
+        base64 = 0;
       }
       *p++ = ch;
       if (ch == '&')
-       *p++ = '-';
+        *p++ = '-';
     }
   }
 
-  if (u8len)
-  {
+  if (u8len) {
     FREE (&buf);
     return 0;
   }
 
-  if (base64)
-  {
+  if (base64) {
     if (k > 10)
       *p++ = B64Chars[b];
     *p++ = '-';
@@ -244,19 +227,20 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
   if (u7len)
     *u7len = p - buf;
   safe_realloc (&buf, p - buf);
-  if (u7)  *u7 = buf;
+  if (u7)
+    *u7 = buf;
   return buf;
 
- bail:
+bail:
   FREE (&buf);
   return 0;
 }
 
 void imap_utf7_encode (char **s)
 {
-  if (Charset)
-  {
+  if (Charset) {
     char *t = safe_strdup (*s);
+
     if (!mutt_convert_string (&t, Charset, "UTF-8", 0))
       utf8_to_utf7 (t, strlen (t), s, 0);
     FREE (&t);
@@ -265,11 +249,10 @@ void imap_utf7_encode (char **s)
 
 void imap_utf7_decode (char **s)
 {
-  if (Charset)
-  {
+  if (Charset) {
     char *t = utf7_to_utf8 (*s, strlen (*s), 0, 0);
-    if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0))
-    {
+
+    if (t && !mutt_convert_string (&t, "UTF-8", Charset, 0)) {
       FREE (s);
       *s = t;
     }
index 5062786..8a2b3aa 100644 (file)
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* general IMAP utility functions */
 
 #include "config.h"
 
 #include "mutt.h"
-#include "mx.h"        /* for M_IMAP */
+#include "mx.h"                 /* for M_IMAP */
 #include "url.h"
 #include "imap_private.h"
 #include "mutt_ssl.h"
@@ -48,7 +48,7 @@
  * Outputs: The buffer is rewritten in place with the canonical IMAP path.
  * Returns 0 on success, or -1 if imap_parse_path chokes or url_ciss_tostring
  *   fails, which it might if there isn't enough room in the buffer. */
-int imap_expand_path (charpath, size_t len)
+int imap_expand_path (char *path, size_t len)
 {
   IMAP_MBOX mx;
   ciss_url_t url;
@@ -69,18 +69,17 @@ int imap_expand_path (char* path, size_t len)
 /* imap_parse_path: given an IMAP mailbox name, return host, port
  *   and a path IMAP servers will recognise.
  * mx.mbox is malloc'd, caller must free it */
-int imap_parse_path (const char* path, IMAP_MBOX* mx)
+int imap_parse_path (const char *path, IMAP_MBOX * mx)
 {
   static unsigned short ImapPort = 0;
   static unsigned short ImapsPort = 0;
-  struct serventservice;
+  struct servent *service;
   char tmp[128];
   ciss_url_t url;
   char *c;
   int n;
 
-  if (!ImapPort)
-  {
+  if (!ImapPort) {
     service = getservbyname ("imap", "tcp");
     if (service)
       ImapPort = ntohs (service->s_port);
@@ -88,8 +87,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
       ImapPort = IMAP_PORT;
     dprint (3, (debugfile, "Using default IMAP port %d\n", ImapPort));
   }
-  if (!ImapsPort)
-  {
+  if (!ImapsPort) {
     service = getservbyname ("imaps", "tcp");
     if (service)
       ImapsPort = ntohs (service->s_port);
@@ -105,10 +103,8 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
 
   c = safe_strdup (path);
   url_parse_ciss (&url, c);
-  if (url.scheme == U_IMAP || url.scheme == U_IMAPS)
-  {
-    if (mutt_account_fromurl (&mx->account, &url) < 0)
-    {
+  if (url.scheme == U_IMAP || url.scheme == U_IMAPS) {
+    if (mutt_account_fromurl (&mx->account, &url) < 0) {
       FREE (&c);
       return -1;
     }
@@ -121,8 +117,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
     FREE (&c);
   }
   /* old PINE-compatibility code */
-  else
-  {
+  else {
     FREE (&c);
     if (sscanf (path, "{%127[^}]}", tmp) != 1)
       return -1;
@@ -132,40 +127,38 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
       return -1;
     else
       /* walk past closing '}' */
-      mx->mbox = safe_strdup (c+1);
-  
-    if ((c = strrchr (tmp, '@')))
-    {
+      mx->mbox = safe_strdup (c + 1);
+
+    if ((c = strrchr (tmp, '@'))) {
       *c = '\0';
       strfcpy (mx->account.user, tmp, sizeof (mx->account.user));
-      strfcpy (tmp, c+1, sizeof (tmp));
+      strfcpy (tmp, c + 1, sizeof (tmp));
       mx->account.flags |= M_ACCT_USER;
     }
-  
-    if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1)
-    {
+
+    if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1) {
       dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path));
       FREE (&mx->mbox);
       return -1;
     }
-  
+
     if (n > 1) {
       if (sscanf (tmp, ":%hu%127s", &(mx->account.port), tmp) >= 1)
-       mx->account.flags |= M_ACCT_PORT;
-      if (sscanf (tmp, "/%s", tmp) == 1)
-      {
-       if (!ascii_strncmp (tmp, "ssl", 3))
-         mx->account.flags |= M_ACCT_SSL;
-       else
-       {
-         dprint (1, (debugfile, "imap_parse_path: Unknown connection type in %s\n", path));
-         FREE (&mx->mbox);
-         return -1;
-       }
+        mx->account.flags |= M_ACCT_PORT;
+      if (sscanf (tmp, "/%s", tmp) == 1) {
+        if (!ascii_strncmp (tmp, "ssl", 3))
+          mx->account.flags |= M_ACCT_SSL;
+        else {
+          dprint (1,
+                  (debugfile,
+                   "imap_parse_path: Unknown connection type in %s\n", path));
+          FREE (&mx->mbox);
+          return -1;
+        }
       }
     }
   }
-  
+
 #if defined(USE_SSL) || defined(USE_GNUTLS)
   if (option (OPTIMAPFORCESSL))
     mx->account.flags |= M_ACCT_SSL;
@@ -179,11 +172,11 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
 
 /* imap_pretty_mailbox: called by mutt_pretty_mailbox to make IMAP paths
  *   look nice. */
-void imap_pretty_mailbox (charpath)
+void imap_pretty_mailbox (char *path)
 {
   IMAP_MBOX home, target;
   ciss_url_t url;
-  chardelim;
+  char *delim;
   int tlen;
   int hlen = 0;
   char home_match = 0;
@@ -193,18 +186,16 @@ void imap_pretty_mailbox (char* path)
 
   tlen = mutt_strlen (target.mbox);
   /* check whether we can do '=' substitution */
-  if (mx_is_imap(Maildir) && !imap_parse_path (Maildir, &home))
-  {
+  if (mx_is_imap (Maildir) && !imap_parse_path (Maildir, &home)) {
     hlen = mutt_strlen (home.mbox);
     if (tlen && mutt_account_match (&home.account, &target.account) &&
-       !mutt_strncmp (home.mbox, target.mbox, hlen))
-    {
-      if (! hlen)
-       home_match = 1;
+        !mutt_strncmp (home.mbox, target.mbox, hlen)) {
+      if (!hlen)
+        home_match = 1;
       else
-       for (delim = ImapDelimChars; *delim != '\0'; delim++)
-         if (target.mbox[hlen] == *delim)
-           home_match = 1;
+        for (delim = ImapDelimChars; *delim != '\0'; delim++)
+          if (target.mbox[hlen] == *delim)
+            home_match = 1;
     }
     FREE (&home.mbox);
   }
@@ -213,13 +204,12 @@ void imap_pretty_mailbox (char* path)
   if (home_match) {
     *path++ = '=';
     /* copy remaining path, skipping delimiter */
-    if (! hlen)
+    if (!hlen)
       hlen = -1;
     memcpy (path, target.mbox + hlen + 1, tlen - hlen - 1);
     path[tlen - hlen - 1] = '\0';
   }
-  else
-  {
+  else {
     mutt_account_tourl (&target.account, &url);
     url.path = target.mbox;
     /* FIXME: That hard-coded constant is bogus. But we need the actual
@@ -235,7 +225,7 @@ void imap_pretty_mailbox (char* path)
 
 /* imap_continue: display a message and ask the user if she wants to
  *   go on. */
-int imap_continue (const char* msg, const char* resp)
+int imap_continue (const char *msg, const char *resp)
 {
   imap_error (msg, resp);
   return mutt_yesorno (_("Continue?"), 0);
@@ -250,12 +240,14 @@ void imap_error (const char *where, const char *msg)
 
 /* imap_new_idata: Allocate and initialise a new IMAP_DATA structure.
  *   Returns NULL on failure (no mem) */
-IMAP_DATA* imap_new_idata (void) {
+IMAP_DATA *imap_new_idata (void)
+{
   return safe_calloc (1, sizeof (IMAP_DATA));
 }
 
 /* imap_free_idata: Release and clear storage in an IMAP_DATA structure. */
-void imap_free_idata (IMAP_DATA** idata) {
+void imap_free_idata (IMAP_DATA ** idata)
+{
   if (!idata)
     return;
 
@@ -273,26 +265,23 @@ void imap_free_idata (IMAP_DATA** idata) {
  * are not required to do this.
  * Moreover, IMAP servers may dislike the path ending with the delimiter.
  */
-char *imap_fix_path (IMAP_DATA *idata, char *mailbox, char *path, 
-    size_t plen)
+char *imap_fix_path (IMAP_DATA * idata, char *mailbox, char *path,
+                     size_t plen)
 {
   int x = 0;
 
-  if (!mailbox || !*mailbox)
-  {
+  if (!mailbox || !*mailbox) {
     strfcpy (path, "INBOX", plen);
     return path;
   }
 
-  while (mailbox && *mailbox && (x < (plen - 1)))
-  {
-    if ((*mailbox == '/') || (*mailbox == idata->delim))
-    {
-      while ((*mailbox == '/') || (*mailbox == idata->delim)) mailbox++;
+  while (mailbox && *mailbox && (x < (plen - 1))) {
+    if ((*mailbox == '/') || (*mailbox == idata->delim)) {
+      while ((*mailbox == '/') || (*mailbox == idata->delim))
+        mailbox++;
       path[x] = idata->delim;
     }
-    else
-    {
+    else {
       path[x] = *mailbox;
       mailbox++;
     }
@@ -306,7 +295,7 @@ char *imap_fix_path (IMAP_DATA *idata, char *mailbox, char *path,
 
 /* imap_get_literal_count: write number of bytes in an IMAP literal into
  *   bytes, return 0 on success, -1 on failure. */
-int imap_get_literal_count(const char *buf, long *bytes)
+int imap_get_literal_count (const char *buf, long *bytes)
 {
   char *pc;
   char *pn;
@@ -318,13 +307,13 @@ int imap_get_literal_count(const char *buf, long *bytes)
   while (isdigit ((unsigned char) *pc))
     pc++;
   *pc = 0;
-  *bytes = atoi(pn);
+  *bytes = atoi (pn);
   return (0);
 }
 
 /* imap_get_qualifier: in a tagged response, skip tag and status for
  *   the qualifier message. Used by imap_copy_message for TRYCREATE */
-char* imap_get_qualifier (char* buf)
+char *imap_get_qualifier (char *buf)
 {
   char *s = buf;
 
@@ -345,7 +334,7 @@ char *imap_next_word (char *s)
     if (*s == '\\') {
       s++;
       if (*s)
-       s++;
+        s++;
       continue;
     }
     if (*s == '\"')
@@ -365,7 +354,7 @@ time_t imap_parse_date (char *s)
   struct tm t;
   time_t tz;
 
-  t.tm_mday = (s[0] == ' '? s[1] - '0' : (s[0] - '0') * 10 + (s[1] - '0'));  
+  t.tm_mday = (s[0] == ' ' ? s[1] - '0' : (s[0] - '0') * 10 + (s[1] - '0'));
   s += 2;
   if (*s != '-')
     return 0;
@@ -375,7 +364,10 @@ time_t imap_parse_date (char *s)
   if (*s != '-')
     return 0;
   s++;
-  t.tm_year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0') - 1900;
+  t.tm_year =
+    (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] -
+                                                                    '0') -
+    1900;
   s += 4;
   if (*s != ' ')
     return 0;
@@ -409,7 +401,7 @@ time_t imap_parse_date (char *s)
 
 /* imap_qualify_path: make an absolute IMAP folder target, given IMAP_MBOX
  *   and relative path. */
-void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path)
+void imap_qualify_path (char *dest, size_t len, IMAP_MBOX * mx, char *path)
 {
   ciss_url_t url;
 
@@ -428,24 +420,21 @@ void imap_quote_string (char *dest, size_t dlen, const char *src)
   const char *s;
 
   pt = dest;
-  s  = src;
+  s = src;
 
   *pt++ = '"';
   /* save room for trailing quote-char */
   dlen -= 2;
-  
-  for (; *s && dlen; s++)
-  {
-    if (strchr (quote, *s))
-    {
+
+  for (; *s && dlen; s++) {
+    if (strchr (quote, *s)) {
       dlen -= 2;
       if (!dlen)
-       break;
+        break;
       *pt++ = '\\';
       *pt++ = *s;
     }
-    else
-    {
+    else {
       *pt++ = *s;
       dlen--;
     }
@@ -464,19 +453,15 @@ void imap_unquote_string (char *s)
   else
     return;
 
-  while (*s)
-  {
-    if (*s == '\"')
-    {
+  while (*s) {
+    if (*s == '\"') {
       *d = '\0';
       return;
     }
-    if (*s == '\\')
-    {
+    if (*s == '\\') {
       s++;
     }
-    if (*s)
-    {
+    if (*s) {
       *d = *s;
       d++;
       s++;
@@ -505,38 +490,35 @@ void imap_unmunge_mbox_name (char *s)
 {
   char *buf;
 
-  imap_unquote_string(s);
+  imap_unquote_string (s);
 
   buf = safe_strdup (s);
-  if (buf)
-  {
+  if (buf) {
     imap_utf7_decode (&buf);
     strncpy (s, buf, strlen (s));
   }
-  
+
   FREE (&buf);
 }
 
 /* imap_wordcasecmp: find word a in word list b */
-int imap_wordcasecmp(const char *a, const char *b)
+int imap_wordcasecmp (const char *a, const char *b)
 {
   char tmp[SHORT_STRING];
-  char *s = (char *)b;
+  char *s = (char *) b;
   int i;
 
-  tmp[SHORT_STRING-1] = 0;
-  for(i=0;i < SHORT_STRING-2;i++,s++)
-  {
-    if (!*s || ISSPACE(*s))
-    {
+  tmp[SHORT_STRING - 1] = 0;
+  for (i = 0; i < SHORT_STRING - 2; i++, s++) {
+    if (!*s || ISSPACE (*s)) {
       tmp[i] = 0;
       break;
     }
     tmp[i] = *s;
   }
-  tmp[i+1] = 0;
+  tmp[i + 1] = 0;
 
-  return ascii_strcasecmp(a, tmp);
+  return ascii_strcasecmp (a, tmp);
 }
 
 /* 
@@ -557,25 +539,21 @@ void imap_keepalive (void)
   IMAP_DATA *idata;
 
   conn = mutt_socket_head ();
-  while (conn)
-  {
-    if (conn->account.type == M_ACCT_TYPE_IMAP)
-    {
-      idata = (IMAP_DATA*) conn->data;
+  while (conn) {
+    if (conn->account.type == M_ACCT_TYPE_IMAP) {
+      idata = (IMAP_DATA *) conn->data;
 
       if (idata->state >= IMAP_AUTHENTICATED
-         && time(NULL) >= idata->lastread + ImapKeepalive)
-      {
-       if (idata->ctx)
-         ctx = idata->ctx;
-       else
-       {
-         ctx = safe_calloc (1, sizeof (CONTEXT));
-         ctx->data = idata;
-       }
-       imap_check_mailbox (ctx, NULL, 1);
-       if (!idata->ctx)
-         FREE (&ctx);
+          && time (NULL) >= idata->lastread + ImapKeepalive) {
+        if (idata->ctx)
+          ctx = idata->ctx;
+        else {
+          ctx = safe_calloc (1, sizeof (CONTEXT));
+          ctx->data = idata;
+        }
+        imap_check_mailbox (ctx, NULL, 1);
+        if (!idata->ctx)
+          FREE (&ctx);
       }
     }
 
@@ -591,7 +569,7 @@ int imap_wait_keepalive (pid_t pid)
   int rc;
 
   short imap_passive = option (OPTIMAPPASSIVE);
-  
+
   set_option (OPTIMAPPASSIVE);
   set_option (OPTKEEPQUIET);
 
@@ -608,15 +586,14 @@ int imap_wait_keepalive (pid_t pid)
   sigaction (SIGALRM, &act, &oldalrm);
 
   alarm (ImapKeepalive);
-  while (waitpid (pid, &rc, 0) < 0 && errno == EINTR)
-  {
-    alarm (0); /* cancel a possibly pending alarm */
+  while (waitpid (pid, &rc, 0) < 0 && errno == EINTR) {
+    alarm (0);                  /* cancel a possibly pending alarm */
     imap_keepalive ();
     alarm (ImapKeepalive);
   }
 
-  alarm (0);   /* cancel a possibly pending alarm */
-  
+  alarm (0);                    /* cancel a possibly pending alarm */
+
   sigaction (SIGALRM, &oldalrm, NULL);
   sigprocmask (SIG_SETMASK, &oldmask, NULL);
 
@@ -629,13 +606,13 @@ int imap_wait_keepalive (pid_t pid)
 
 /* Allow/disallow re-opening a folder upon expunge. */
 
-void imap_allow_reopen (CONTEXT *ctx)
+void imap_allow_reopen (CONTEXT * ctx)
 {
   if (ctx && ctx->magic == M_IMAP && CTX_DATA->ctx == ctx)
     CTX_DATA->reopen |= IMAP_REOPEN_ALLOW;
 }
 
-void imap_disallow_reopen (CONTEXT *ctx)
+void imap_disallow_reopen (CONTEXT * ctx)
 {
   if (ctx && ctx->magic == M_IMAP && CTX_DATA->ctx == ctx)
     CTX_DATA->reopen &= ~IMAP_REOPEN_ALLOW;
diff --git a/init.c b/init.c
index 2bc7e2a..818a6bd 100644 (file)
--- a/init.c
+++ b/init.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -51,7 +51,7 @@
 
 void toggle_quadoption (int opt)
 {
-  int n = opt/4;
+  int n = opt / 4;
   int b = (opt % 4) * 2;
 
   QuadOptions[n] ^= (1 << b);
@@ -59,7 +59,7 @@ void toggle_quadoption (int opt)
 
 void set_quadoption (int opt, int flag)
 {
-  int n = opt/4;
+  int n = opt / 4;
   int b = (opt % 4) * 2;
 
   QuadOptions[n] &= ~(0x3 << b);
@@ -68,7 +68,7 @@ void set_quadoption (int opt, int flag)
 
 int quadoption (int opt)
 {
-  int n = opt/4;
+  int n = opt / 4;
   int b = (opt % 4) * 2;
 
   return (QuadOptions[n] >> b) & 0x3;
@@ -78,16 +78,15 @@ int query_quadoption (int opt, const char *prompt)
 {
   int v = quadoption (opt);
 
-  switch (v)
-  {
-    case M_YES:
-    case M_NO:
-      return (v);
+  switch (v) {
+  case M_YES:
+  case M_NO:
+    return (v);
 
-    default:
-      v = mutt_yesorno (prompt, (v == M_ASKYES));
-      CLEARLINE (LINES - 1);
-      return (v);
+  default:
+    v = mutt_yesorno (prompt, (v == M_ASKYES));
+    CLEARLINE (LINES - 1);
+    return (v);
   }
 
   /* not reached */
@@ -101,126 +100,120 @@ int mutt_option_index (char *s)
 
   for (i = 0; MuttVars[i].option; i++)
     if (mutt_strcmp (s, MuttVars[i].option) == 0)
-      return (MuttVars[i].type == DT_SYN ?  mutt_option_index ((char *) MuttVars[i].data) : i);
+      return (MuttVars[i].type ==
+              DT_SYN ? mutt_option_index ((char *) MuttVars[i].data) : i);
   return (-1);
 }
 
-int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
+int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags)
 {
-  char         ch;
-  char         qc = 0; /* quote char */
-  char         *pc;
+  char ch;
+  char qc = 0;                  /* quote char */
+  char *pc;
 
   /* reset the destination pointer to the beginning of the buffer */
   dest->dptr = dest->data;
 
   SKIPWS (tok->dptr);
-  while ((ch = *tok->dptr))
-  {
-    if (!qc)
-    {
+  while ((ch = *tok->dptr)) {
+    if (!qc) {
       if ((ISSPACE (ch) && !(flags & M_TOKEN_SPACE)) ||
-         (ch == '#' && !(flags & M_TOKEN_COMMENT)) ||
-         (ch == '=' && (flags & M_TOKEN_EQUAL)) ||
-         (ch == ';' && !(flags & M_TOKEN_SEMICOLON)) ||
-         ((flags & M_TOKEN_PATTERN) && strchr ("~!|", ch)))
-       break;
+          (ch == '#' && !(flags & M_TOKEN_COMMENT)) ||
+          (ch == '=' && (flags & M_TOKEN_EQUAL)) ||
+          (ch == ';' && !(flags & M_TOKEN_SEMICOLON)) ||
+          ((flags & M_TOKEN_PATTERN) && strchr ("~!|", ch)))
+        break;
     }
 
     tok->dptr++;
 
     if (ch == qc)
-      qc = 0; /* end of quote */
+      qc = 0;                   /* end of quote */
     else if (!qc && (ch == '\'' || ch == '"') && !(flags & M_TOKEN_QUOTE))
       qc = ch;
-    else if (ch == '\\' && qc != '\'')
-    {
-       if (!*tok->dptr)
-           return -1; /* premature end of token */
-      switch (ch = *tok->dptr++)
-      {
-       case 'c':
-       case 'C':
-           if (!*tok->dptr)
-               return -1; /* premature end of token */
-         mutt_buffer_addch (dest, (toupper ((unsigned char) *tok->dptr)
-                                    - '@') & 0x7f);
-         tok->dptr++;
-         break;
-       case 'r':
-         mutt_buffer_addch (dest, '\r');
-         break;
-       case 'n':
-         mutt_buffer_addch (dest, '\n');
-         break;
-       case 't':
-         mutt_buffer_addch (dest, '\t');
-         break;
-       case 'f':
-         mutt_buffer_addch (dest, '\f');
-         break;
-       case 'e':
-         mutt_buffer_addch (dest, '\033');
-         break;
-       default:
-         if (isdigit ((unsigned char) ch) &&
-             isdigit ((unsigned char) *tok->dptr) &&
-             isdigit ((unsigned char) *(tok->dptr + 1)))
-         {
-
-           mutt_buffer_addch (dest, (ch << 6) + (*tok->dptr << 3) + *(tok->dptr + 1) - 3504);
-           tok->dptr += 2;
-         }
-         else
-           mutt_buffer_addch (dest, ch);
+    else if (ch == '\\' && qc != '\'') {
+      if (!*tok->dptr)
+        return -1;              /* premature end of token */
+      switch (ch = *tok->dptr++) {
+      case 'c':
+      case 'C':
+        if (!*tok->dptr)
+          return -1;            /* premature end of token */
+        mutt_buffer_addch (dest, (toupper ((unsigned char) *tok->dptr)
+                                  - '@') & 0x7f);
+        tok->dptr++;
+        break;
+      case 'r':
+        mutt_buffer_addch (dest, '\r');
+        break;
+      case 'n':
+        mutt_buffer_addch (dest, '\n');
+        break;
+      case 't':
+        mutt_buffer_addch (dest, '\t');
+        break;
+      case 'f':
+        mutt_buffer_addch (dest, '\f');
+        break;
+      case 'e':
+        mutt_buffer_addch (dest, '\033');
+        break;
+      default:
+        if (isdigit ((unsigned char) ch) &&
+            isdigit ((unsigned char) *tok->dptr) &&
+            isdigit ((unsigned char) *(tok->dptr + 1))) {
+
+          mutt_buffer_addch (dest,
+                             (ch << 6) + (*tok->dptr << 3) + *(tok->dptr +
+                                                               1) - 3504);
+          tok->dptr += 2;
+        }
+        else
+          mutt_buffer_addch (dest, ch);
       }
     }
-    else if (ch == '^' && (flags & M_TOKEN_CONDENSE))
-    {
-       if (!*tok->dptr)
-           return -1; /* premature end of token */
+    else if (ch == '^' && (flags & M_TOKEN_CONDENSE)) {
+      if (!*tok->dptr)
+        return -1;              /* premature end of token */
       ch = *tok->dptr++;
       if (ch == '^')
-       mutt_buffer_addch (dest, ch);
+        mutt_buffer_addch (dest, ch);
       else if (ch == '[')
-       mutt_buffer_addch (dest, '\033');
+        mutt_buffer_addch (dest, '\033');
       else if (isalpha ((unsigned char) ch))
-       mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
-      else
-      {
-       mutt_buffer_addch (dest, '^');
-       mutt_buffer_addch (dest, ch);
+        mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
+      else {
+        mutt_buffer_addch (dest, '^');
+        mutt_buffer_addch (dest, ch);
       }
     }
-    else if (ch == '`' && (!qc || qc == '"'))
-    {
-      FILE     *fp;
-      pid_t    pid;
-      char     *cmd, *ptr;
-      size_t   expnlen;
-      BUFFER   expn;
-      int      line = 0;
+    else if (ch == '`' && (!qc || qc == '"')) {
+      FILE *fp;
+      pid_t pid;
+      char *cmd, *ptr;
+      size_t expnlen;
+      BUFFER expn;
+      int line = 0;
 
       pc = tok->dptr;
       do {
-       if ((pc = strpbrk (pc, "\\`")))
-       {
-         /* skip any quoted chars */
-         if (*pc == '\\')
-           pc += 2;
-       }
+        if ((pc = strpbrk (pc, "\\`"))) {
+          /* skip any quoted chars */
+          if (*pc == '\\')
+            pc += 2;
+        }
       } while (pc && *pc != '`');
-      if (!pc)
-      {
-       dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
-       return (-1);
+      if (!pc) {
+        dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
+        return (-1);
       }
       cmd = mutt_substrdup (tok->dptr, pc);
-      if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0)
-      {
-       dprint (1, (debugfile, "mutt_get_token: unable to fork command: %s", cmd));
-       FREE (&cmd);
-       return (-1);
+      if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
+        dprint (1,
+                (debugfile, "mutt_get_token: unable to fork command: %s",
+                 cmd));
+        FREE (&cmd);
+        return (-1);
       }
       FREE (&cmd);
 
@@ -233,63 +226,58 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
       mutt_wait_filter (pid);
 
       /* if we got output, make a new string consiting of the shell ouptput
-        plus whatever else was left on the original line */
+         plus whatever else was left on the original line */
       /* BUT: If this is inside a quoted string, directly add output to 
        * the token */
-      if (expn.data && qc)
-      {
-       mutt_buffer_addstr (dest, expn.data);
-       FREE (&expn.data);
+      if (expn.data && qc) {
+        mutt_buffer_addstr (dest, expn.data);
+        FREE (&expn.data);
       }
-      else if (expn.data)
-      {
-       expnlen = mutt_strlen (expn.data);
-       tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
-       ptr = safe_malloc (tok->dsize);
-       memcpy (ptr, expn.data, expnlen);
-       strcpy (ptr + expnlen, tok->dptr);      /* __STRCPY_CHECKED__ */
-       if (tok->destroy)
-         FREE (&tok->data);
-       tok->data = ptr;
-       tok->dptr = ptr;
-       tok->destroy = 1; /* mark that the caller should destroy this data */
-       ptr = NULL;
-       FREE (&expn.data);
+      else if (expn.data) {
+        expnlen = mutt_strlen (expn.data);
+        tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1;
+        ptr = safe_malloc (tok->dsize);
+        memcpy (ptr, expn.data, expnlen);
+        strcpy (ptr + expnlen, tok->dptr);      /* __STRCPY_CHECKED__ */
+        if (tok->destroy)
+          FREE (&tok->data);
+        tok->data = ptr;
+        tok->dptr = ptr;
+        tok->destroy = 1;       /* mark that the caller should destroy this data */
+        ptr = NULL;
+        FREE (&expn.data);
       }
     }
-    else if (ch == '$' && (!qc || qc == '"') && (*tok->dptr == '{' || isalpha ((unsigned char) *tok->dptr)))
-    {
+    else if (ch == '$' && (!qc || qc == '"')
+             && (*tok->dptr == '{' || isalpha ((unsigned char) *tok->dptr))) {
       char *env = NULL, *var = NULL;
 
-      if (*tok->dptr == '{')
-      {
-       tok->dptr++;
-       if ((pc = strchr (tok->dptr, '}')))
-       {
-         var = mutt_substrdup (tok->dptr, pc);
-         tok->dptr = pc + 1;
-       }
+      if (*tok->dptr == '{') {
+        tok->dptr++;
+        if ((pc = strchr (tok->dptr, '}'))) {
+          var = mutt_substrdup (tok->dptr, pc);
+          tok->dptr = pc + 1;
+        }
       }
-      else
-      {
-       for (pc = tok->dptr; isalpha ((unsigned char) *pc) || *pc == '_'; pc++)
-         ;
-       var = mutt_substrdup (tok->dptr, pc);
-       tok->dptr = pc;
+      else {
+        for (pc = tok->dptr; isalpha ((unsigned char) *pc) || *pc == '_';
+             pc++);
+        var = mutt_substrdup (tok->dptr, pc);
+        tok->dptr = pc;
       }
       if (var && (env = getenv (var)))
-       mutt_buffer_addstr (dest, env);
+        mutt_buffer_addstr (dest, env);
       FREE (&var);
     }
     else
       mutt_buffer_addch (dest, ch);
   }
-  mutt_buffer_addch (dest, 0); /* terminate the string */
+  mutt_buffer_addch (dest, 0);  /* terminate the string */
   SKIPWS (tok->dptr);
   return 0;
 }
 
-static void add_to_list (LIST **list, const char *str)
+static void add_to_list (LIST ** list, const char *str)
 {
   LIST *t, *last = NULL;
 
@@ -298,10 +286,8 @@ static void add_to_list (LIST **list, const char *str)
     return;
 
   /* check to make sure the item is not already on this list */
-  for (last = *list; last; last = last->next)
-  {
-    if (ascii_strcasecmp (str, last->data) == 0)
-    {
+  for (last = *list; last; last = last->next) {
+    if (ascii_strcasecmp (str, last->data) == 0) {
       /* already on the list, so just ignore it */
       last = NULL;
       break;
@@ -310,12 +296,10 @@ static void add_to_list (LIST **list, const char *str)
       break;
   }
 
-  if (!*list || last)
-  {
+  if (!*list || last) {
     t = (LIST *) safe_calloc (1, sizeof (LIST));
     t->data = safe_strdup (str);
-    if (last)
-    {
+    if (last) {
       last->next = t;
       last = last->next;
     }
@@ -324,7 +308,8 @@ static void add_to_list (LIST **list, const char *str)
   }
 }
 
-static int add_to_rx_list (RX_LIST **list, const char *s, int flags, BUFFER *err)
+static int add_to_rx_list (RX_LIST ** list, const char *s, int flags,
+                           BUFFER * err)
 {
   RX_LIST *t, *last = NULL;
   REGEXP *rx;
@@ -332,17 +317,14 @@ static int add_to_rx_list (RX_LIST **list, const char *s, int flags, BUFFER *err
   if (!s || !*s)
     return 0;
 
-  if (!(rx = mutt_compile_regexp (s, flags)))
-  {
+  if (!(rx = mutt_compile_regexp (s, flags))) {
     snprintf (err->data, err->dsize, "Bad regexp: %s\n", s);
     return -1;
   }
 
   /* check to make sure the item is not already on this list */
-  for (last = *list; last; last = last->next)
-  {
-    if (ascii_strcasecmp (rx->pattern, last->rx->pattern) == 0)
-    {
+  for (last = *list; last; last = last->next) {
+    if (ascii_strcasecmp (rx->pattern, last->rx->pattern) == 0) {
       /* already on the list, so just ignore it */
       last = NULL;
       break;
@@ -351,25 +333,24 @@ static int add_to_rx_list (RX_LIST **list, const char *s, int flags, BUFFER *err
       break;
   }
 
-  if (!*list || last)
-  {
-    t = mutt_new_rx_list();
+  if (!*list || last) {
+    t = mutt_new_rx_list ();
     t->rx = rx;
-    if (last)
-    {
+    if (last) {
       last->next = t;
       last = last->next;
     }
     else
       *list = last = t;
   }
-  else /* duplicate */
+  else                          /* duplicate */
     mutt_free_regexp (&rx);
 
   return 0;
 }
 
-static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char *templ, BUFFER *err)
+static int add_to_spam_list (SPAM_LIST ** list, const char *pat,
+                             const char *templ, BUFFER * err)
 {
   SPAM_LIST *t = NULL, *last = NULL;
   REGEXP *rx;
@@ -379,17 +360,14 @@ static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char *temp
   if (!pat || !*pat || !templ)
     return 0;
 
-  if (!(rx = mutt_compile_regexp (pat, REG_ICASE)))
-  {
+  if (!(rx = mutt_compile_regexp (pat, REG_ICASE))) {
     snprintf (err->data, err->dsize, _("Bad regexp: %s"), pat);
     return -1;
   }
 
   /* check to make sure the item is not already on this list */
-  for (last = *list; last; last = last->next)
-  {
-    if (ascii_strcasecmp (rx->pattern, last->rx->pattern) == 0)
-    {
+  for (last = *list; last; last = last->next) {
+    if (ascii_strcasecmp (rx->pattern, last->rx->pattern) == 0) {
       /* Already on the list. Formerly we just skipped this case, but
        * now we're supporting removals, which means we're supporting
        * re-adds conceptually. So we probably want this to imply a
@@ -397,7 +375,7 @@ static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char *temp
        * the template, and leaving t pointed at the current item.
        */
       t = last;
-      safe_free(&t->template);
+      safe_free (&t->template);
       break;
     }
     if (!last->next)
@@ -407,9 +385,8 @@ static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char *temp
   /* If t is set, it's pointing into an extant SPAM_LIST* that we want to
    * update. Otherwise we want to make a new one to link at the list's end.
    */
-  if (!t)
-  {
-    t = mutt_new_spam_list();
+  if (!t) {
+    t = mutt_new_spam_list ();
     t->rx = rx;
     if (last)
       last->next = t;
@@ -418,53 +395,48 @@ static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char *temp
   }
 
   /* Now t is the SPAM_LIST* that we want to modify. It is prepared. */
-  t->template = safe_strdup(templ);
+  t->template = safe_strdup (templ);
 
   /* Find highest match number in template string */
   t->nmatch = 0;
-  for (p = templ; *p;)
-  {
-    if (*p == '%')
-    {
-        n = atoi(++p);
-        if (n > t->nmatch)
-          t->nmatch = n;
-        while (*p && isdigit((int)*p))
-          ++p;
+  for (p = templ; *p;) {
+    if (*p == '%') {
+      n = atoi (++p);
+      if (n > t->nmatch)
+        t->nmatch = n;
+      while (*p && isdigit ((int) *p))
+        ++p;
     }
     else
-        ++p;
+      ++p;
   }
-  t->nmatch++;         /* match 0 is always the whole expr */
+  t->nmatch++;                  /* match 0 is always the whole expr */
 
   return 0;
 }
 
-static int remove_from_spam_list (SPAM_LIST **list, const char *pat)
+static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
 {
   SPAM_LIST *spam, *prev;
   int nremoved = 0;
 
   /* Being first is a special case. */
   spam = *list;
-  if (spam->rx && !mutt_strcmp(spam->rx->pattern, pat))
-  {
+  if (spam->rx && !mutt_strcmp (spam->rx->pattern, pat)) {
     *list = spam->next;
-    mutt_free_regexp(&spam->rx);
-    safe_free(&spam->template);
-    safe_free(&spam);
+    mutt_free_regexp (&spam->rx);
+    safe_free (&spam->template);
+    safe_free (&spam);
     return 1;
   }
 
   prev = spam;
-  for (spam = prev->next; spam;)
-  {
-    if (!mutt_strcmp(spam->rx->pattern, pat))
-    {
+  for (spam = prev->next; spam;) {
+    if (!mutt_strcmp (spam->rx->pattern, pat)) {
       prev->next = spam->next;
-      mutt_free_regexp(&spam->rx);
-      safe_free(&spam->template);
-      safe_free(&spam);
+      mutt_free_regexp (&spam->rx);
+      safe_free (&spam->template);
+      safe_free (&spam);
       spam = prev->next;
       ++nremoved;
     }
@@ -476,73 +448,65 @@ static int remove_from_spam_list (SPAM_LIST **list, const char *pat)
 }
 
 
-static void remove_from_list (LIST **l, const char *str)
+static void remove_from_list (LIST ** l, const char *str)
 {
   LIST *p, *last = NULL;
 
   if (mutt_strcmp ("*", str) == 0)
-    mutt_free_list (l);    /* ``unCMD *'' means delete all current entries */
-  else
-  {
+    mutt_free_list (l);         /* ``unCMD *'' means delete all current entries */
+  else {
     p = *l;
     last = NULL;
-    while (p)
-    {
-      if (ascii_strcasecmp (str, p->data) == 0)
-      {
-       FREE (&p->data);
-       if (last)
-         last->next = p->next;
-       else
-         (*l) = p->next;
-       FREE (&p);
+    while (p) {
+      if (ascii_strcasecmp (str, p->data) == 0) {
+        FREE (&p->data);
+        if (last)
+          last->next = p->next;
+        else
+          (*l) = p->next;
+        FREE (&p);
       }
-      else
-      {
-       last = p;
-       p = p->next;
+      else {
+        last = p;
+        p = p->next;
       }
     }
   }
 }
 
-static int remove_from_rx_list (RX_LIST **l, const char *str)
+static int remove_from_rx_list (RX_LIST ** l, const char *str)
 {
   RX_LIST *p, *last = NULL;
   int rv = -1;
 
-  if (mutt_strcmp ("*", str) == 0)
-  {
-    mutt_free_rx_list (l);    /* ``unCMD *'' means delete all current entries */
+  if (mutt_strcmp ("*", str) == 0) {
+    mutt_free_rx_list (l);      /* ``unCMD *'' means delete all current entries */
     rv = 0;
   }
-  else
-  {
+  else {
     p = *l;
     last = NULL;
-    while (p)
-    {
-      if (ascii_strcasecmp (str, p->rx->pattern) == 0)
-      {
-       mutt_free_regexp (&p->rx);
-       if (last)
-         last->next = p->next;
-       else
-         (*l) = p->next;
-       FREE (&p);
-       rv = 0;
+    while (p) {
+      if (ascii_strcasecmp (str, p->rx->pattern) == 0) {
+        mutt_free_regexp (&p->rx);
+        if (last)
+          last->next = p->next;
+        else
+          (*l) = p->next;
+        FREE (&p);
+        rv = 0;
       }
-      else
-      {
-       last = p;
-       p = p->next;
+      else {
+        last = p;
+        p = p->next;
       }
     }
   }
   return (rv);
 }
 
-static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_ifdef (BUFFER * tmp, BUFFER * s, unsigned long data,
+                        BUFFER * err)
 {
   int i, j, res = 0;
   BUFFER token;
@@ -552,24 +516,23 @@ static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
 
   /* is the item defined as a variable or a function? */
   if (!(res = (mutt_option_index (tmp->data) != -1)))
-    for (i = 0; !res && i < MENU_MAX; i++)
-    {
+    for (i = 0; !res && i < MENU_MAX; i++) {
       struct binding_t *b = km_get_table (Menus[i].value);
 
       if (!b)
-       continue;
+        continue;
 
       for (j = 0; b[j].name; j++)
-       if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
-             && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data)))
-       {
-         res = 1;
-         break;
-       }
+        if (!ascii_strncasecmp (tmp->data, b[j].name, mutt_strlen (tmp->data))
+            && (mutt_strlen (b[j].name) == mutt_strlen (tmp->data))) {
+          res = 1;
+          break;
+        }
     }
   /* check for feature_* */
   if (!res) {
-    char* p = NULL;
+    char *p = NULL;
+
     i = 0;
     j = mutt_strlen (tmp->data);
     /* need at least input of 'feature_X' */
@@ -587,8 +550,7 @@ static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
     }
   }
 
-  if (!MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     if (data)
       snprintf (err->data, err->dsize, _("ifdef: too few arguments"));
     else
@@ -597,10 +559,8 @@ static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
   }
   mutt_extract_token (tmp, s, M_TOKEN_SPACE);
 
-  if ((data && res) || (!data && !res))
-  {
-    if (mutt_parse_rc_line (tmp->data, &token, err) == -1)
-    {
+  if ((data && res) || (!data && !res)) {
+    if (mutt_parse_rc_line (tmp->data, &token, err) == -1) {
       mutt_error ("Error: %s", err->data);
       FREE (&token.data);
       return (-1);
@@ -610,14 +570,14 @@ static int parse_ifdef (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
   return 0;
 }
 
-static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_unignore (BUFFER * buf, BUFFER * s, unsigned long data,
+                           BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
 
     /* don't add "*" to the unignore list */
-    if (strcmp (buf->data, "*")) 
+    if (strcmp (buf->data, "*"))
       add_to_list (&UnIgnore, buf->data);
 
     remove_from_list (&Ignore, buf->data);
@@ -627,10 +587,10 @@ static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *e
   return 0;
 }
 
-static int parse_ignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_ignore (BUFFER * buf, BUFFER * s, unsigned long data,
+                         BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_list (&UnIgnore, buf->data);
     add_to_list (&Ignore, buf->data);
@@ -640,10 +600,10 @@ static int parse_ignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
   return 0;
 }
 
-static int parse_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_list (BUFFER * buf, BUFFER * s, unsigned long data,
+                       BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     add_to_list ((LIST **) data, buf->data);
   }
@@ -653,39 +613,39 @@ static int parse_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 }
 
 #if 0
-static int _parse_rx_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, int flags)
+static int _parse_rx_list (BUFFER * buf, BUFFER * s, unsigned long data,
+                           BUFFER * err, int flags)
 {
-  do 
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     if (add_to_rx_list ((RX_LIST **) data, buf->data, flags, err) != 0)
       return -1;
-       
+
   }
   while (MoreArgs (s));
-  
+
   return 0;
 }
 
-static int parse_rx_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_rx_list (BUFFER * buf, BUFFER * s, unsigned long data,
+                          BUFFER * err)
 {
   return _parse_rx_list (buf, s, data, err, REG_ICASE);
 }
 
-static int parse_rx_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_rx_unlist (BUFFER * buf, BUFFER * s, unsigned long data,
+                            BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
-    if (mutt_strcmp (buf->data, "*") == 0)
-    {
+    if (mutt_strcmp (buf->data, "*") == 0) {
       mutt_free_rx_list ((RX_LIST **) data);
       break;
     }
     remove_from_rx_list ((RX_LIST **) data, buf->data);
   }
   while (MoreArgs (s));
-  
+
   return 0;
 }
 #endif
@@ -693,18 +653,18 @@ static int parse_rx_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
 static void _alternates_clean (void)
 {
   int i;
-  if (Context && Context->msgcount) 
-  {
+
+  if (Context && Context->msgcount) {
     for (i = 0; i < Context->msgcount; i++)
       Context->hdrs[i]->recip_valid = 0;
   }
 }
 
-static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_alternates (BUFFER * buf, BUFFER * s, unsigned long data,
+                             BUFFER * err)
 {
-  _alternates_clean();
-  do
-  {
+  _alternates_clean ();
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&UnAlternates, buf->data);
 
@@ -716,16 +676,16 @@ static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
   return 0;
 }
 
-static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_unalternates (BUFFER * buf, BUFFER * s, unsigned long data,
+                               BUFFER * err)
 {
-  _alternates_clean();
-  do
-  {
+  _alternates_clean ();
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&Alternates, buf->data);
 
     if (mutt_strcmp (buf->data, "*") &&
-       add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
+        add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
       return -1;
 
   }
@@ -734,19 +694,19 @@ static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFE
   return 0;
 }
 
-static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data,
+                            BUFFER * err)
 {
   BUFFER templ;
 
-  memset(&templ, 0, sizeof(templ));
+  memset (&templ, 0, sizeof (templ));
 
   /* Insist on at least one parameter */
-  if (!MoreArgs(s))
-  {
+  if (!MoreArgs (s)) {
     if (data == M_SPAM)
-      strfcpy(err->data, _("spam: no matching pattern"), err->dsize);
+      strfcpy (err->data, _("spam: no matching pattern"), err->dsize);
     else
-      strfcpy(err->data, _("nospam: no matching pattern"), err->dsize);
+      strfcpy (err->data, _("nospam: no matching pattern"), err->dsize);
     return -1;
   }
 
@@ -754,45 +714,40 @@ static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
   mutt_extract_token (buf, s, 0);
 
   /* data should be either M_SPAM or M_NOSPAM. M_SPAM is for spam commands. */
-  if (data == M_SPAM)
-  {
+  if (data == M_SPAM) {
     /* If there's a second parameter, it's a template for the spam tag. */
-    if (MoreArgs(s))
-    {
+    if (MoreArgs (s)) {
       mutt_extract_token (&templ, s, 0);
 
       /* Add to the spam list. */
       if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) {
-         FREE(&templ.data);
-          return -1;
+        FREE (&templ.data);
+        return -1;
       }
-      FREE(&templ.data);
+      FREE (&templ.data);
     }
 
     /* If not, try to remove from the nospam list. */
-    else
-    {
-      remove_from_rx_list(&NoSpamList, buf->data);
+    else {
+      remove_from_rx_list (&NoSpamList, buf->data);
     }
 
     return 0;
   }
 
   /* M_NOSPAM is for nospam commands. */
-  else if (data == M_NOSPAM)
-  {
+  else if (data == M_NOSPAM) {
     /* nospam only ever has one parameter. */
 
     /* "*" is a special case. */
-    if (!mutt_strcmp(buf->data, "*"))
-    {
+    if (!mutt_strcmp (buf->data, "*")) {
       mutt_free_spam_list (&SpamList);
       mutt_free_rx_list (&NoSpamList);
       return 0;
     }
 
     /* If it's on the spam list, just remove it. */
-    if (remove_from_spam_list(&SpamList, buf->data) != 0)
+    if (remove_from_spam_list (&SpamList, buf->data) != 0)
       return 0;
 
     /* Otherwise, add it to the nospam list. */
@@ -803,20 +758,19 @@ static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
   }
 
   /* This should not happen. */
-  strfcpy(err->data, "This is no good at all.", err->dsize);
+  strfcpy (err->data, "This is no good at all.", err->dsize);
   return -1;
 }
 
-static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_unlist (BUFFER * buf, BUFFER * s, unsigned long data,
+                         BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     /*
      * Check for deletion of entire list
      */
-    if (mutt_strcmp (buf->data, "*") == 0)
-    {
+    if (mutt_strcmp (buf->data, "*") == 0) {
       mutt_free_list ((LIST **) data);
       break;
     }
@@ -827,13 +781,13 @@ static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
   return 0;
 }
 
-static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_lists (BUFFER * buf, BUFFER * s, unsigned long data,
+                        BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&UnMailLists, buf->data);
-    
+
     if (add_to_rx_list (&MailLists, buf->data, REG_ICASE, err) != 0)
       return -1;
   }
@@ -842,16 +796,16 @@ static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   return 0;
 }
 
-static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_unlists (BUFFER * buf, BUFFER * s, unsigned long data,
+                          BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&SubscribedLists, buf->data);
     remove_from_rx_list (&MailLists, buf->data);
-    
-    if (mutt_strcmp (buf->data, "*") && 
-       add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
+
+    if (mutt_strcmp (buf->data, "*") &&
+        add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
       return -1;
   }
   while (MoreArgs (s));
@@ -859,10 +813,10 @@ static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er
   return 0;
 }
 
-static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_subscribe (BUFFER * buf, BUFFER * s, unsigned long data,
+                            BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&UnMailLists, buf->data);
     remove_from_rx_list (&UnSubscribedLists, buf->data);
@@ -877,96 +831,88 @@ static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
   return 0;
 }
 
-static int parse_unsubscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_unsubscribe (BUFFER * buf, BUFFER * s, unsigned long data,
+                              BUFFER * err)
 {
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&SubscribedLists, buf->data);
-    
+
     if (mutt_strcmp (buf->data, "*") &&
-       add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
+        add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
       return -1;
   }
   while (MoreArgs (s));
 
   return 0;
 }
-  
-static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+
+static int parse_unalias (BUFFER * buf, BUFFER * s, unsigned long data,
+                          BUFFER * err)
 {
   ALIAS *tmp, *last = NULL;
 
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
 
-    if (mutt_strcmp ("*", buf->data) == 0)
-    {
-      if (CurrentMenu == MENU_ALIAS)
-      {
-       for (tmp = Aliases; tmp ; tmp = tmp->next)
-         tmp->del = 1;
-       set_option (OPTFORCEREDRAWINDEX);
+    if (mutt_strcmp ("*", buf->data) == 0) {
+      if (CurrentMenu == MENU_ALIAS) {
+        for (tmp = Aliases; tmp; tmp = tmp->next)
+          tmp->del = 1;
+        set_option (OPTFORCEREDRAWINDEX);
       }
       else
-       mutt_free_alias (&Aliases);
+        mutt_free_alias (&Aliases);
       break;
     }
     else
-      for (tmp = Aliases; tmp; tmp = tmp->next)
-      {
-       if (mutt_strcasecmp (buf->data, tmp->name) == 0)
-       {
-         if (CurrentMenu == MENU_ALIAS)
-         {
-           tmp->del = 1;
-           set_option (OPTFORCEREDRAWINDEX);
-           break;
-         }
-
-         if (last)
-           last->next = tmp->next;
-         else
-           Aliases = tmp->next;
-         tmp->next = NULL;
-         mutt_free_alias (&tmp);
-         break;
-       }
-       last = tmp;
+      for (tmp = Aliases; tmp; tmp = tmp->next) {
+        if (mutt_strcasecmp (buf->data, tmp->name) == 0) {
+          if (CurrentMenu == MENU_ALIAS) {
+            tmp->del = 1;
+            set_option (OPTFORCEREDRAWINDEX);
+            break;
+          }
+
+          if (last)
+            last->next = tmp->next;
+          else
+            Aliases = tmp->next;
+          tmp->next = NULL;
+          mutt_free_alias (&tmp);
+          break;
+        }
+        last = tmp;
       }
   }
   while (MoreArgs (s));
   return 0;
 }
 
-static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data,
+                        BUFFER * err)
 {
   ALIAS *tmp = Aliases;
   ALIAS *last = NULL;
   char *estr = NULL;
-  
-  if (!MoreArgs (s))
-  {
+
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("alias: no address"), err->dsize);
     return (-1);
   }
 
   mutt_extract_token (buf, s, 0);
 
-  dprint (2, (debugfile, "parse_alias: First token is '%s'.\n",
-             buf->data));
+  dprint (2, (debugfile, "parse_alias: First token is '%s'.\n", buf->data));
 
   /* check to see if an alias with this name already exists */
-  for (; tmp; tmp = tmp->next)
-  {
+  for (; tmp; tmp = tmp->next) {
     if (!mutt_strcasecmp (tmp->name, buf->data))
       break;
     last = tmp;
   }
 
-  if (!tmp)
-  {
+  if (!tmp) {
     /* create a new alias */
     tmp = (ALIAS *) safe_calloc (1, sizeof (ALIAS));
     tmp->self = tmp;
@@ -975,40 +921,35 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
     if (CurrentMenu == MENU_ALIAS)
       set_option (OPTMENUCALLER);
   }
-  else
-  {
+  else {
     /* override the previous value */
     rfc822_free_address (&tmp->addr);
     if (CurrentMenu == MENU_ALIAS)
       set_option (OPTFORCEREDRAWINDEX);
   }
 
-  mutt_extract_token (buf, s, M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
-  dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n",
-             buf->data));
+  mutt_extract_token (buf, s,
+                      M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
+  dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n", buf->data));
   tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data);
   if (last)
     last->next = tmp;
   else
     Aliases = tmp;
-  if (mutt_addrlist_to_idna (tmp->addr, &estr))
-  {
-    snprintf (err->data, err->dsize, _("Warning: Bad IDN '%s' in alias '%s'.\n"),
-             estr, tmp->name);
+  if (mutt_addrlist_to_idna (tmp->addr, &estr)) {
+    snprintf (err->data, err->dsize,
+              _("Warning: Bad IDN '%s' in alias '%s'.\n"), estr, tmp->name);
     return -1;
   }
 #ifdef DEBUG
-  if (debuglevel >= 2) 
-  {
+  if (debuglevel >= 2) {
     ADDRESS *a;
-    for (a = tmp->addr; a; a = a->next)
-    {
+
+    for (a = tmp->addr; a; a = a->next) {
       if (!a->group)
-       dprint (2, (debugfile, "parse_alias:   %s\n",
-                   a->mailbox));
+        dprint (2, (debugfile, "parse_alias:   %s\n", a->mailbox));
       else
-       dprint (2, (debugfile, "parse_alias:   Group %s\n",
-                   a->mailbox));
+        dprint (2, (debugfile, "parse_alias:   Group %s\n", a->mailbox));
     }
   }
 #endif
@@ -1016,45 +957,41 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 }
 
 static int
-parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+parse_unmy_hdr (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err)
 {
   LIST *last = NULL;
   LIST *tmp = UserHeader;
   LIST *ptr;
   size_t l;
 
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     if (mutt_strcmp ("*", buf->data) == 0)
       mutt_free_list (&UserHeader);
-    else
-    {
+    else {
       tmp = UserHeader;
       last = NULL;
 
       l = mutt_strlen (buf->data);
       if (buf->data[l - 1] == ':')
-       l--;
-
-      while (tmp)
-      {
-       if (ascii_strncasecmp (buf->data, tmp->data, l) == 0 && tmp->data[l] == ':')
-       {
-         ptr = tmp;
-         if (last)
-           last->next = tmp->next;
-         else
-           UserHeader = tmp->next;
-         tmp = tmp->next;
-         ptr->next = NULL;
-         mutt_free_list (&ptr);
-       }
-       else
-       {
-         last = tmp;
-         tmp = tmp->next;
-       }
+        l--;
+
+      while (tmp) {
+        if (ascii_strncasecmp (buf->data, tmp->data, l) == 0
+            && tmp->data[l] == ':') {
+          ptr = tmp;
+          if (last)
+            last->next = tmp->next;
+          else
+            UserHeader = tmp->next;
+          tmp = tmp->next;
+          ptr->next = NULL;
+          mutt_free_list (&ptr);
+        }
+        else {
+          last = tmp;
+          tmp = tmp->next;
+        }
       }
     }
   }
@@ -1062,41 +999,37 @@ parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   return 0;
 }
 
-static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_my_hdr (BUFFER * buf, BUFFER * s, unsigned long data,
+                         BUFFER * err)
 {
   LIST *tmp;
   size_t keylen;
   char *p;
 
   mutt_extract_token (buf, s, M_TOKEN_SPACE | M_TOKEN_QUOTE);
-  if ((p = strpbrk (buf->data, ": \t")) == NULL || *p != ':')
-  {
+  if ((p = strpbrk (buf->data, ": \t")) == NULL || *p != ':') {
     strfcpy (err->data, _("invalid header field"), err->dsize);
     return (-1);
   }
   keylen = p - buf->data + 1;
 
-  if (UserHeader)
-  {
-    for (tmp = UserHeader; ; tmp = tmp->next)
-    {
+  if (UserHeader) {
+    for (tmp = UserHeader;; tmp = tmp->next) {
       /* see if there is already a field by this name */
-      if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0)
-      {
-       /* replace the old value */
-       FREE (&tmp->data);
-       tmp->data = buf->data;
-       memset (buf, 0, sizeof (BUFFER));
-       return 0;
+      if (ascii_strncasecmp (buf->data, tmp->data, keylen) == 0) {
+        /* replace the old value */
+        FREE (&tmp->data);
+        tmp->data = buf->data;
+        memset (buf, 0, sizeof (BUFFER));
+        return 0;
       }
       if (!tmp->next)
-       break;
+        break;
     }
     tmp->next = mutt_new_list ();
     tmp = tmp->next;
   }
-  else
-  {
+  else {
     tmp = mutt_new_list ();
     UserHeader = tmp;
   }
@@ -1106,24 +1039,22 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
 }
 
 static int
-parse_sort (short *val, const char *s, const struct mapping_t *map, BUFFER *err)
+parse_sort (short *val, const char *s, const struct mapping_t *map,
+            BUFFER * err)
 {
   int i, flags = 0;
 
-  if (mutt_strncmp ("reverse-", s, 8) == 0)
-  {
+  if (mutt_strncmp ("reverse-", s, 8) == 0) {
     s += 8;
     flags = SORT_REVERSE;
   }
-  
-  if (mutt_strncmp ("last-", s, 5) == 0)
-  {
+
+  if (mutt_strncmp ("last-", s, 5) == 0) {
     s += 5;
     flags |= SORT_LAST;
   }
 
-  if ((i = mutt_getvaluebyname (s, map)) == -1)
-  {
+  if ((i = mutt_getvaluebyname (s, map)) == -1) {
     snprintf (err->data, err->dsize, _("%s: unknown sorting method"), s);
     return (-1);
   }
@@ -1135,34 +1066,34 @@ parse_sort (short *val, const char *s, const struct mapping_t *map, BUFFER *err)
 
 static void mutt_set_default (struct option_t *p)
 {
-  switch (p->type & DT_MASK)
-  {
-    case DT_STR:
-      if (!p->init && *((char **) p->data))
-        p->init = (unsigned long) safe_strdup (* ((char **) p->data));
-      break;
-    case DT_PATH:
-      if (!p->init && *((char **) p->data))
-      {
-       char *cp = safe_strdup (*((char **) p->data));
-       /* mutt_pretty_mailbox (cp); */
-        p->init = (unsigned long) cp;
-      }
-      break;
-    case DT_ADDR:
-      if (!p->init && *((ADDRESS **) p->data))
-      {
-       char tmp[HUGE_STRING];
-       *tmp = '\0';
-       rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data), 0);
-       p->init = (unsigned long) safe_strdup (tmp);
-      }
-      break;
-    case DT_RX:
+  switch (p->type & DT_MASK) {
+  case DT_STR:
+    if (!p->init && *((char **) p->data))
+      p->init = (unsigned long) safe_strdup (*((char **) p->data));
+    break;
+  case DT_PATH:
+    if (!p->init && *((char **) p->data)) {
+      char *cp = safe_strdup (*((char **) p->data));
+
+      /* mutt_pretty_mailbox (cp); */
+      p->init = (unsigned long) cp;
+    }
+    break;
+  case DT_ADDR:
+    if (!p->init && *((ADDRESS **) p->data)) {
+      char tmp[HUGE_STRING];
+
+      *tmp = '\0';
+      rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data), 0);
+      p->init = (unsigned long) safe_strdup (tmp);
+    }
+    break;
+  case DT_RX:
     {
       REGEXP *pp = (REGEXP *) p->data;
+
       if (!p->init && pp->pattern)
-       p->init = (unsigned long) safe_strdup (pp->pattern);
+        p->init = (unsigned long) safe_strdup (pp->pattern);
       break;
     }
   }
@@ -1170,79 +1101,74 @@ static void mutt_set_default (struct option_t *p)
 
 static void mutt_restore_default (struct option_t *p)
 {
-  switch (p->type & DT_MASK)
-  {
-    case DT_STR:
-      if (p->init)
-       mutt_str_replace ((char **) p->data, (char *) p->init); 
-      break;
-    case DT_PATH:
-      if (p->init)
-      {
-       char path[_POSIX_PATH_MAX];
-
-       strfcpy (path, (char *) p->init, sizeof (path));
-       mutt_expand_path (path, sizeof (path));
-       mutt_str_replace ((char **) p->data, path);
-      }
-      break;
-    case DT_ADDR:
-      if (p->init)
-      {
-       rfc822_free_address ((ADDRESS **) p->data);
-       *((ADDRESS **) p->data) = rfc822_parse_adrlist (NULL, (char *) p->init);
+  switch (p->type & DT_MASK) {
+  case DT_STR:
+    if (p->init)
+      mutt_str_replace ((char **) p->data, (char *) p->init);
+    break;
+  case DT_PATH:
+    if (p->init) {
+      char path[_POSIX_PATH_MAX];
+
+      strfcpy (path, (char *) p->init, sizeof (path));
+      mutt_expand_path (path, sizeof (path));
+      mutt_str_replace ((char **) p->data, path);
+    }
+    break;
+  case DT_ADDR:
+    if (p->init) {
+      rfc822_free_address ((ADDRESS **) p->data);
+      *((ADDRESS **) p->data) = rfc822_parse_adrlist (NULL, (char *) p->init);
+    }
+    break;
+  case DT_BOOL:
+    if (p->init)
+      set_option (p->data);
+    else
+      unset_option (p->data);
+    break;
+  case DT_QUAD:
+    set_quadoption (p->data, p->init);
+    break;
+  case DT_NUM:
+  case DT_SORT:
+  case DT_MAGIC:
+    *((short *) p->data) = p->init;
+    break;
+  case DT_RX:
+    {
+      REGEXP *pp = (REGEXP *) p->data;
+      int flags = 0;
+
+      FREE (&pp->pattern);
+      if (pp->rx) {
+        regfree (pp->rx);
+        FREE (&pp->rx);
       }
-      break;
-    case DT_BOOL:
-      if (p->init)
-       set_option (p->data);
-      else
-       unset_option (p->data);
-      break;
-    case DT_QUAD:
-      set_quadoption (p->data, p->init);
-      break;
-    case DT_NUM:
-    case DT_SORT:
-    case DT_MAGIC:
-      *((short *) p->data) = p->init;
-      break;
-    case DT_RX:
-      {
-       REGEXP *pp = (REGEXP *) p->data;
-       int flags = 0;
-
-       FREE (&pp->pattern);
-       if (pp->rx)
-       {
-         regfree (pp->rx);
-         FREE (&pp->rx);
-       }
-
-       if (p->init)
-       {
-         char *s = (char *) p->init;
-
-         pp->rx = safe_calloc (1, sizeof (regex_t));
-         if (mutt_strcmp (p->option, "mask") != 0)
-           flags |= mutt_which_case ((const char *) p->init);
-         if (mutt_strcmp (p->option, "mask") == 0 && *s == '!')
-         {
-           s++;
-           pp->not = 1;
-         }
-         if (REGCOMP (pp->rx, s, flags) != 0)
-         {
-           fprintf (stderr, _("mutt_restore_default(%s): error in regexp: %s\n"),
-                    p->option, pp->pattern);
-           FREE (&pp->pattern);
-           regfree (pp->rx);
-           FREE (&pp->rx);
-         } else
-            mutt_str_replace (&pp->pattern, (char*) p->init);
-       }
+
+      if (p->init) {
+        char *s = (char *) p->init;
+
+        pp->rx = safe_calloc (1, sizeof (regex_t));
+        if (mutt_strcmp (p->option, "mask") != 0)
+          flags |= mutt_which_case ((const char *) p->init);
+        if (mutt_strcmp (p->option, "mask") == 0 && *s == '!') {
+          s++;
+          pp->not = 1;
+        }
+        if (REGCOMP (pp->rx, s, flags) != 0) {
+          fprintf (stderr,
+                   _("mutt_restore_default(%s): error in regexp: %s\n"),
+                   p->option, pp->pattern);
+          FREE (&pp->pattern);
+          regfree (pp->rx);
+          FREE (&pp->rx);
+        }
+        else
+          mutt_str_replace (&pp->pattern, (char *) p->init);
       }
-      break;
+    }
+    break;
   }
 
   if (p->flags & R_INDEX)
@@ -1259,36 +1185,32 @@ static void mutt_restore_default (struct option_t *p)
     set_option (OPTREDRAWTREE);
 }
 
-static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
+                      BUFFER * err)
 {
   int idx, query, unset, inv, reset, r = 0;
   char *p, scratch[_POSIX_PATH_MAX];
 
-  while (MoreArgs (s))
-  {
+  while (MoreArgs (s)) {
     /* reset state variables */
     query = 0;
     unset = data & M_SET_UNSET;
     inv = data & M_SET_INV;
     reset = data & M_SET_RESET;
 
-    if (*s->dptr == '?')
-    {
+    if (*s->dptr == '?') {
       query = 1;
       s->dptr++;
     }
-    else if (mutt_strncmp ("no", s->dptr, 2) == 0)
-    {
+    else if (mutt_strncmp ("no", s->dptr, 2) == 0) {
       s->dptr += 2;
       unset = !unset;
     }
-    else if (mutt_strncmp ("inv", s->dptr, 3) == 0)
-    {
+    else if (mutt_strncmp ("inv", s->dptr, 3) == 0) {
       s->dptr += 3;
       inv = !inv;
     }
-    else if (*s->dptr == '&')
-    {
+    else if (*s->dptr == '&') {
       reset = 1;
       s->dptr++;
     }
@@ -1297,268 +1219,238 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
     mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
 
     if ((idx = mutt_option_index (tmp->data)) == -1 &&
-       !(reset && !mutt_strcmp ("all", tmp->data)))
-    {
+        !(reset && !mutt_strcmp ("all", tmp->data))) {
       snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data);
       return (-1);
     }
     SKIPWS (s->dptr);
 
-    if (reset)
-    {
-      if (query || unset || inv)
-      {
-       snprintf (err->data, err->dsize, _("prefix is illegal with reset"));
-       return (-1);
+    if (reset) {
+      if (query || unset || inv) {
+        snprintf (err->data, err->dsize, _("prefix is illegal with reset"));
+        return (-1);
       }
 
-      if (s && *s->dptr == '=')
-      {
-       snprintf (err->data, err->dsize, _("value is illegal with reset"));
-       return (-1);
+      if (s && *s->dptr == '=') {
+        snprintf (err->data, err->dsize, _("value is illegal with reset"));
+        return (-1);
       }
-     
-      if (!mutt_strcmp ("all", tmp->data))
-      {
-       for (idx = 0; MuttVars[idx].option; idx++)
-         mutt_restore_default (&MuttVars[idx]);
-       return 0;
+
+      if (!mutt_strcmp ("all", tmp->data)) {
+        for (idx = 0; MuttVars[idx].option; idx++)
+          mutt_restore_default (&MuttVars[idx]);
+        return 0;
       }
       else
-       mutt_restore_default (&MuttVars[idx]);
-    } 
-    else if (DTYPE (MuttVars[idx].type) == DT_BOOL)
-    { 
-      if (s && *s->dptr == '=')
-      {
-       if (unset || inv || query)
-       {
-         snprintf (err->data, err->dsize, "Usage: set variable=yes|no");
-         return (-1);
-       }
-
-       s->dptr++;
-       mutt_extract_token (tmp, s, 0);
-       if (ascii_strcasecmp ("yes", tmp->data) == 0)
-         unset = inv = 0;
-       else if (ascii_strcasecmp ("no", tmp->data) == 0)
-         unset = 1;
-       else
-       {
-         snprintf (err->data, err->dsize, "Usage: set variable=yes|no");
-         return (-1);
-       }
+        mutt_restore_default (&MuttVars[idx]);
+    }
+    else if (DTYPE (MuttVars[idx].type) == DT_BOOL) {
+      if (s && *s->dptr == '=') {
+        if (unset || inv || query) {
+          snprintf (err->data, err->dsize, "Usage: set variable=yes|no");
+          return (-1);
+        }
+
+        s->dptr++;
+        mutt_extract_token (tmp, s, 0);
+        if (ascii_strcasecmp ("yes", tmp->data) == 0)
+          unset = inv = 0;
+        else if (ascii_strcasecmp ("no", tmp->data) == 0)
+          unset = 1;
+        else {
+          snprintf (err->data, err->dsize, "Usage: set variable=yes|no");
+          return (-1);
+        }
       }
 
-      if (query)
-      {
-       snprintf (err->data, err->dsize, option (MuttVars[idx].data)
-                       ? _("%s is set") : _("%s is unset"), tmp->data);
-       return 0;
+      if (query) {
+        snprintf (err->data, err->dsize, option (MuttVars[idx].data)
+                  ? _("%s is set") : _("%s is unset"), tmp->data);
+        return 0;
       }
 
       if (unset)
-       unset_option (MuttVars[idx].data);
+        unset_option (MuttVars[idx].data);
       else if (inv)
-       toggle_option (MuttVars[idx].data);
+        toggle_option (MuttVars[idx].data);
       else
-       set_option (MuttVars[idx].data);
+        set_option (MuttVars[idx].data);
     }
     else if (DTYPE (MuttVars[idx].type) == DT_STR ||
-            DTYPE (MuttVars[idx].type) == DT_PATH ||
-            DTYPE (MuttVars[idx].type) == DT_ADDR)
-    {
-      if (unset)
-      {
-       if (DTYPE (MuttVars[idx].type) == DT_ADDR)
-         rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
-       else
-         FREE ((void *)MuttVars[idx].data);
+             DTYPE (MuttVars[idx].type) == DT_PATH ||
+             DTYPE (MuttVars[idx].type) == DT_ADDR) {
+      if (unset) {
+        if (DTYPE (MuttVars[idx].type) == DT_ADDR)
+          rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
+        else
+          FREE ((void *) MuttVars[idx].data);
       }
-      else if (query || *s->dptr != '=')
-      {
-       char _tmp[STRING];
-       char *val = NULL;
-       
-       if (DTYPE (MuttVars[idx].type) == DT_ADDR)
-       {
-         _tmp[0] = '\0';
-         rfc822_write_address (_tmp, sizeof (_tmp), *((ADDRESS **) MuttVars[idx].data), 0);
-         val = _tmp;
-       }
-       else
-         val = *((char **) MuttVars[idx].data);
-       
-       /* user requested the value of this variable */
-       snprintf (err->data, err->dsize, "%s=\"%s\"", MuttVars[idx].option,
-                 NONULL (val));
-       break;
+      else if (query || *s->dptr != '=') {
+        char _tmp[STRING];
+        char *val = NULL;
+
+        if (DTYPE (MuttVars[idx].type) == DT_ADDR) {
+          _tmp[0] = '\0';
+          rfc822_write_address (_tmp, sizeof (_tmp),
+                                *((ADDRESS **) MuttVars[idx].data), 0);
+          val = _tmp;
+        }
+        else
+          val = *((char **) MuttVars[idx].data);
+
+        /* user requested the value of this variable */
+        snprintf (err->data, err->dsize, "%s=\"%s\"", MuttVars[idx].option,
+                  NONULL (val));
+        break;
       }
-      else
-      {
+      else {
         s->dptr++;
 
         /* copy the value of the string */
         if (DTYPE (MuttVars[idx].type) == DT_ADDR)
-         rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
+          rfc822_free_address ((ADDRESS **) MuttVars[idx].data);
         else
-         FREE ((void *)MuttVars[idx].data);
+          FREE ((void *) MuttVars[idx].data);
 
         mutt_extract_token (tmp, s, 0);
-        if (DTYPE (MuttVars[idx].type) == DT_PATH)
-        {
-         strfcpy (scratch, tmp->data, sizeof (scratch));
-         mutt_expand_path (scratch, sizeof (scratch));
-         *((char **) MuttVars[idx].data) = safe_strdup (scratch);
+        if (DTYPE (MuttVars[idx].type) == DT_PATH) {
+          strfcpy (scratch, tmp->data, sizeof (scratch));
+          mutt_expand_path (scratch, sizeof (scratch));
+          *((char **) MuttVars[idx].data) = safe_strdup (scratch);
         }
-        else if (DTYPE (MuttVars[idx].type) == DT_STR)
-        {
-         *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
-         if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
-           mutt_set_charset (Charset);
+        else if (DTYPE (MuttVars[idx].type) == DT_STR) {
+          *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
+          if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
+            mutt_set_charset (Charset);
         }
-        else
-        {
-         *((ADDRESS **) MuttVars[idx].data) = rfc822_parse_adrlist (NULL, tmp->data);
+        else {
+          *((ADDRESS **) MuttVars[idx].data) =
+            rfc822_parse_adrlist (NULL, tmp->data);
         }
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_RX)
-    {
+    else if (DTYPE (MuttVars[idx].type) == DT_RX) {
       REGEXP *ptr = (REGEXP *) MuttVars[idx].data;
       regex_t *rx;
       int e, flags = 0;
 
-      if (query || *s->dptr != '=')
-      {
-       /* user requested the value of this variable */
-       snprintf (err->data, err->dsize, "%s=\"%s\"", MuttVars[idx].option,
-                 NONULL (ptr->pattern));
-       break;
+      if (query || *s->dptr != '=') {
+        /* user requested the value of this variable */
+        snprintf (err->data, err->dsize, "%s=\"%s\"", MuttVars[idx].option,
+                  NONULL (ptr->pattern));
+        break;
       }
 
-      if (option(OPTATTACHMSG) && !mutt_strcmp(MuttVars[idx].option, "reply_regexp"))
-      {
-       snprintf (err->data, err->dsize, "Operation not permitted when in attach-message mode.");
-       r = -1;
-       break;
+      if (option (OPTATTACHMSG)
+          && !mutt_strcmp (MuttVars[idx].option, "reply_regexp")) {
+        snprintf (err->data, err->dsize,
+                  "Operation not permitted when in attach-message mode.");
+        r = -1;
+        break;
       }
-      
+
       s->dptr++;
 
       /* copy the value of the string */
       mutt_extract_token (tmp, s, 0);
 
-      if (!ptr->pattern || mutt_strcmp (ptr->pattern, tmp->data) != 0)
-      {
-       int not = 0;
-
-       /* $mask is case-sensitive */
-       if (mutt_strcmp (MuttVars[idx].option, "mask") != 0)
-         flags |= mutt_which_case (tmp->data);
-
-       p = tmp->data;
-       if (mutt_strcmp (MuttVars[idx].option, "mask") == 0)
-       {
-         if (*p == '!')
-         {
-           not = 1;
-           p++;
-         }
-       }
-         
-       rx = (regex_t *) safe_malloc (sizeof (regex_t));
-       if ((e = REGCOMP (rx, p, flags)) != 0)
-       {
-         regerror (e, rx, err->data, err->dsize);
-         regfree (rx);
-         FREE (&rx);
-         break;
-       }
-
-       /* get here only if everything went smootly */
-       if (ptr->pattern)
-       {
-         FREE (&ptr->pattern);
-         regfree ((regex_t *) ptr->rx);
-         FREE (&ptr->rx);
-       }
-
-       ptr->pattern = safe_strdup (tmp->data);
-       ptr->rx = rx;
-       ptr->not = not;
-
-       /* $reply_regexp and $alterantes require special treatment */
-       
-       if (Context && Context->msgcount &&
-           mutt_strcmp (MuttVars[idx].option, "reply_regexp") == 0)
-       {
-         regmatch_t pmatch[1];
-         int i;
-         
+      if (!ptr->pattern || mutt_strcmp (ptr->pattern, tmp->data) != 0) {
+        int not = 0;
+
+        /* $mask is case-sensitive */
+        if (mutt_strcmp (MuttVars[idx].option, "mask") != 0)
+          flags |= mutt_which_case (tmp->data);
+
+        p = tmp->data;
+        if (mutt_strcmp (MuttVars[idx].option, "mask") == 0) {
+          if (*p == '!') {
+            not = 1;
+            p++;
+          }
+        }
+
+        rx = (regex_t *) safe_malloc (sizeof (regex_t));
+        if ((e = REGCOMP (rx, p, flags)) != 0) {
+          regerror (e, rx, err->data, err->dsize);
+          regfree (rx);
+          FREE (&rx);
+          break;
+        }
+
+        /* get here only if everything went smootly */
+        if (ptr->pattern) {
+          FREE (&ptr->pattern);
+          regfree ((regex_t *) ptr->rx);
+          FREE (&ptr->rx);
+        }
+
+        ptr->pattern = safe_strdup (tmp->data);
+        ptr->rx = rx;
+        ptr->not = not;
+
+        /* $reply_regexp and $alterantes require special treatment */
+
+        if (Context && Context->msgcount &&
+            mutt_strcmp (MuttVars[idx].option, "reply_regexp") == 0) {
+          regmatch_t pmatch[1];
+          int i;
+
 #define CUR_ENV Context->hdrs[i]->env
-         for (i = 0; i < Context->msgcount; i++)
-         {
-           if (CUR_ENV && CUR_ENV->subject)
-           {
-             CUR_ENV->real_subj = (regexec (ReplyRegexp.rx,
-                                   CUR_ENV->subject, 1, pmatch, 0)) ?
-                                   CUR_ENV->subject : 
-                                   CUR_ENV->subject + pmatch[0].rm_eo;
-           }
-         }
+          for (i = 0; i < Context->msgcount; i++) {
+            if (CUR_ENV && CUR_ENV->subject) {
+              CUR_ENV->real_subj = (regexec (ReplyRegexp.rx,
+                                             CUR_ENV->subject, 1, pmatch,
+                                             0)) ? CUR_ENV->
+                subject : CUR_ENV->subject + pmatch[0].rm_eo;
+            }
+          }
 #undef CUR_ENV
-       }
+        }
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_MAGIC)
-    {
-      if (query || *s->dptr != '=')
-      {
-       switch (DefaultMagic)
-       {
-         case M_MBOX:
-           p = "mbox";
-           break;
-         case M_MMDF:
-           p = "MMDF";
-           break;
-         case M_MH:
-           p = "MH";
-           break;
-         case M_MAILDIR:
-           p = "Maildir";
-           break;
-         default:
-           p = "unknown";
-           break;
-       }
-       snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option, p);
-       break;
+    else if (DTYPE (MuttVars[idx].type) == DT_MAGIC) {
+      if (query || *s->dptr != '=') {
+        switch (DefaultMagic) {
+        case M_MBOX:
+          p = "mbox";
+          break;
+        case M_MMDF:
+          p = "MMDF";
+          break;
+        case M_MH:
+          p = "MH";
+          break;
+        case M_MAILDIR:
+          p = "Maildir";
+          break;
+        default:
+          p = "unknown";
+          break;
+        }
+        snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option, p);
+        break;
       }
 
       s->dptr++;
 
       /* copy the value of the string */
       mutt_extract_token (tmp, s, 0);
-      if (mx_set_magic (tmp->data))
-      {
-       snprintf (err->data, err->dsize, _("%s: invalid mailbox type"), tmp->data);
-       r = -1;
-       break;
+      if (mx_set_magic (tmp->data)) {
+        snprintf (err->data, err->dsize, _("%s: invalid mailbox type"),
+                  tmp->data);
+        r = -1;
+        break;
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_NUM)
-    {
+    else if (DTYPE (MuttVars[idx].type) == DT_NUM) {
       short *ptr = (short *) MuttVars[idx].data;
       int val;
       char *t;
 
-      if (query || *s->dptr != '=')
-      {
-       /* user requested the value of this variable */
-       snprintf (err->data, err->dsize, "%s=%d", MuttVars[idx].option, *ptr);
-       break;
+      if (query || *s->dptr != '=') {
+        /* user requested the value of this variable */
+        snprintf (err->data, err->dsize, "%s=%d", MuttVars[idx].option, *ptr);
+        break;
       }
 
       s->dptr++;
@@ -1566,121 +1458,113 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
       mutt_extract_token (tmp, s, 0);
       val = strtol (tmp->data, &t, 0);
 
-      if (!*tmp->data || *t || (short) val != val)
-      {
-       snprintf (err->data, err->dsize, _("%s: invalid value"), tmp->data);
-       r = -1;
-       break;
+      if (!*tmp->data || *t || (short) val != val) {
+        snprintf (err->data, err->dsize, _("%s: invalid value"), tmp->data);
+        r = -1;
+        break;
       }
       else
-       *ptr = (short) val;
+        *ptr = (short) val;
 
       /* these ones need a sanity check */
-      if (mutt_strcmp (MuttVars[idx].option, "history") == 0)
-      {
-       if (*ptr < 0)
-         *ptr = 0;
-       mutt_init_history ();
+      if (mutt_strcmp (MuttVars[idx].option, "history") == 0) {
+        if (*ptr < 0)
+          *ptr = 0;
+        mutt_init_history ();
       }
-      else if (mutt_strcmp (MuttVars[idx].option, "pager_index_lines") == 0)
-      {
-       if (*ptr < 0)
-         *ptr = 0;
+      else if (mutt_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) {
+        if (*ptr < 0)
+          *ptr = 0;
       }
     }
-    else if (DTYPE (MuttVars[idx].type) == DT_QUAD)
-    {
-      if (query)
-      {
-       char *vals[] = { "no", "yes", "ask-no", "ask-yes" };
+    else if (DTYPE (MuttVars[idx].type) == DT_QUAD) {
+      if (query) {
+        char *vals[] = { "no", "yes", "ask-no", "ask-yes" };
 
-       snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option,
-                 vals [ quadoption (MuttVars[idx].data) ]);
-       break;
+        snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option,
+                  vals[quadoption (MuttVars[idx].data)]);
+        break;
       }
 
-      if (*s->dptr == '=')
-      {
-       s->dptr++;
-       mutt_extract_token (tmp, s, 0);
-       if (ascii_strcasecmp ("yes", tmp->data) == 0)
-         set_quadoption (MuttVars[idx].data, M_YES);
-       else if (ascii_strcasecmp ("no", tmp->data) == 0)
-         set_quadoption (MuttVars[idx].data, M_NO);
-       else if (ascii_strcasecmp ("ask-yes", tmp->data) == 0)
-         set_quadoption (MuttVars[idx].data, M_ASKYES);
-       else if (ascii_strcasecmp ("ask-no", tmp->data) == 0)
-         set_quadoption (MuttVars[idx].data, M_ASKNO);
-       else
-       {
-         snprintf (err->data, err->dsize, _("%s: invalid value"), tmp->data);
-         r = -1;
-         break;
-       }
+      if (*s->dptr == '=') {
+        s->dptr++;
+        mutt_extract_token (tmp, s, 0);
+        if (ascii_strcasecmp ("yes", tmp->data) == 0)
+          set_quadoption (MuttVars[idx].data, M_YES);
+        else if (ascii_strcasecmp ("no", tmp->data) == 0)
+          set_quadoption (MuttVars[idx].data, M_NO);
+        else if (ascii_strcasecmp ("ask-yes", tmp->data) == 0)
+          set_quadoption (MuttVars[idx].data, M_ASKYES);
+        else if (ascii_strcasecmp ("ask-no", tmp->data) == 0)
+          set_quadoption (MuttVars[idx].data, M_ASKNO);
+        else {
+          snprintf (err->data, err->dsize, _("%s: invalid value"), tmp->data);
+          r = -1;
+          break;
+        }
       }
-      else
-      {
-       if (inv)
-         toggle_quadoption (MuttVars[idx].data);
-       else if (unset)
-         set_quadoption (MuttVars[idx].data, M_NO);
-       else
-         set_quadoption (MuttVars[idx].data, M_YES);
+      else {
+        if (inv)
+          toggle_quadoption (MuttVars[idx].data);
+        else if (unset)
+          set_quadoption (MuttVars[idx].data, M_NO);
+        else
+          set_quadoption (MuttVars[idx].data, M_YES);
       }
     }
-    else if (DTYPE (MuttVars[idx].type) == DT_SORT)
-    {
+    else if (DTYPE (MuttVars[idx].type) == DT_SORT) {
       const struct mapping_t *map = NULL;
 
-      switch (MuttVars[idx].type & DT_SUBTYPE_MASK)
-      {
-       case DT_SORT_ALIAS:
-         map = SortAliasMethods;
-         break;
-       case DT_SORT_BROWSER:
-         map = SortBrowserMethods;
-         break;
-       case DT_SORT_KEYS:
-          if ((WithCrypto & APPLICATION_PGP))
-            map = SortKeyMethods;
-         break;
-       case DT_SORT_AUX:
-         map = SortAuxMethods;
-         break;
-       default:
-         map = SortMethods;
-         break;
+      switch (MuttVars[idx].type & DT_SUBTYPE_MASK) {
+      case DT_SORT_ALIAS:
+        map = SortAliasMethods;
+        break;
+      case DT_SORT_BROWSER:
+        map = SortBrowserMethods;
+        break;
+      case DT_SORT_KEYS:
+        if ((WithCrypto & APPLICATION_PGP))
+          map = SortKeyMethods;
+        break;
+      case DT_SORT_AUX:
+        map = SortAuxMethods;
+        break;
+      default:
+        map = SortMethods;
+        break;
       }
 
-      if (!map)
-      {
-       snprintf (err->data, err->dsize, _("%s: Unknown type."), MuttVars[idx].option);
-       r = -1;
-       break;
+      if (!map) {
+        snprintf (err->data, err->dsize, _("%s: Unknown type."),
+                  MuttVars[idx].option);
+        r = -1;
+        break;
       }
-      
-      if (query || *s->dptr != '=')
-      {
-       p = mutt_getnamebyvalue (*((short *) MuttVars[idx].data) & SORT_MASK, map);
-
-       snprintf (err->data, err->dsize, "%s=%s%s%s", MuttVars[idx].option,
-                 (*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
-                 (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" : "",
-                 p);
-       return 0;
+
+      if (query || *s->dptr != '=') {
+        p =
+          mutt_getnamebyvalue (*((short *) MuttVars[idx].data) & SORT_MASK,
+                               map);
+
+        snprintf (err->data, err->dsize, "%s=%s%s%s", MuttVars[idx].option,
+                  (*((short *) MuttVars[idx].data) & SORT_REVERSE) ?
+                  "reverse-" : "",
+                  (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" :
+                  "", p);
+        return 0;
       }
       s->dptr++;
-      mutt_extract_token (tmp, s , 0);
+      mutt_extract_token (tmp, s, 0);
 
-      if (parse_sort ((short *) MuttVars[idx].data, tmp->data, map, err) == -1)
-      {
-       r = -1;
-       break;
+      if (parse_sort ((short *) MuttVars[idx].data, tmp->data, map, err) ==
+          -1) {
+        r = -1;
+        break;
       }
     }
-    else
-    {
-      snprintf (err->data, err->dsize, _("%s: unknown type"), MuttVars[idx].option);
+    else {
+      snprintf (err->data, err->dsize, _("%s: unknown type"),
+                MuttVars[idx].option);
       r = -1;
       break;
     }
@@ -1705,7 +1589,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
 
 /* reads the specified initialization file.  returns -1 if errors were found
    so that we can pause to let the user know...  */
-static int source_rc (const char *rcfile, BUFFER *err)
+static int source_rc (const char *rcfile, BUFFER * err)
 {
   FILE *f;
   int line = 0, rc = 0, conv = 0;
@@ -1715,55 +1599,51 @@ static int source_rc (const char *rcfile, BUFFER *err)
   size_t buflen;
   pid_t pid;
 
-  dprint (2, (debugfile, "Reading configuration file '%s'.\n",
-         rcfile));
-  
-  if ((f = mutt_open_read (rcfile, &pid)) == NULL)
-  {
+  dprint (2, (debugfile, "Reading configuration file '%s'.\n", rcfile));
+
+  if ((f = mutt_open_read (rcfile, &pid)) == NULL) {
     snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno));
     return (-1);
   }
 
   memset (&token, 0, sizeof (token));
-  while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL)
-  {
-    conv=ConfigCharset && (*ConfigCharset) && Charset;
-    if (conv) 
-    {
-      currentline=safe_strdup(linebuf);
-      if (!currentline) continue;
-      mutt_convert_string(&currentline, ConfigCharset, Charset, 0);
-    } 
-    else 
-      currentline=linebuf;
-
-    if (mutt_parse_rc_line (currentline, &token, err) == -1)
-    {
+  while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL) {
+    conv = ConfigCharset && (*ConfigCharset) && Charset;
+    if (conv) {
+      currentline = safe_strdup (linebuf);
+      if (!currentline)
+        continue;
+      mutt_convert_string (&currentline, ConfigCharset, Charset, 0);
+    }
+    else
+      currentline = linebuf;
+
+    if (mutt_parse_rc_line (currentline, &token, err) == -1) {
       mutt_error (_("Error in %s, line %d: %s"), rcfile, line, err->data);
-      if (--rc < -MAXERRS) 
-      {
-        if (conv) FREE(&currentline);
+      if (--rc < -MAXERRS) {
+        if (conv)
+          FREE (&currentline);
         break;
       }
     }
-    else
-    {
+    else {
       if (rc < 0)
         rc = -1;
     }
     if (conv)
-      FREE(&currentline);
+      FREE (&currentline);
   }
   FREE (&token.data);
   FREE (&linebuf);
   fclose (f);
   if (pid != -1)
     mutt_wait_filter (pid);
-  if (rc)
-  {
+  if (rc) {
     /* the muttrc source keyword */
-    snprintf (err->data, err->dsize, rc >= -MAXERRS ? _("source: errors in %s")
-      : _("source: reading aborted due too many errors in %s"), rcfile);
+    snprintf (err->data, err->dsize,
+              rc >= -MAXERRS ? _("source: errors in %s")
+              : _("source: reading aborted due too many errors in %s"),
+              rcfile);
     rc = -1;
   }
   return (rc);
@@ -1771,15 +1651,14 @@ static int source_rc (const char *rcfile, BUFFER *err)
 
 #undef MAXERRS
 
-static int parse_source (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
+static int parse_source (BUFFER * tmp, BUFFER * s, unsigned long data,
+                         BUFFER * err)
 {
   char path[_POSIX_PATH_MAX];
   int rc = 0;
 
-  do
-  {
-    if (mutt_extract_token (tmp, s, 0) != 0)
-    {
+  do {
+    if (mutt_extract_token (tmp, s, 0) != 0) {
       snprintf (err->data, err->dsize, _("source: error at %s"), s->dptr);
       return (-1);
     }
@@ -1804,7 +1683,7 @@ static int parse_source (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err
                every call to this function.
 
    err         where to write error messages */
-int mutt_parse_rc_line (/* const */ char *line, BUFFER *token, BUFFER *err)
+int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err)
 {
   int i, r = -1;
   BUFFER expn;
@@ -1816,28 +1695,24 @@ int mutt_parse_rc_line (/* const */ char *line, BUFFER *token, BUFFER *err)
   *err->data = 0;
 
   SKIPWS (expn.dptr);
-  while (*expn.dptr)
-  {
+  while (*expn.dptr) {
     if (*expn.dptr == '#')
-      break; /* rest of line is a comment */
-    if (*expn.dptr == ';')
-    {
+      break;                    /* rest of line is a comment */
+    if (*expn.dptr == ';') {
       expn.dptr++;
       continue;
     }
     mutt_extract_token (token, &expn, 0);
-    for (i = 0; Commands[i].name; i++)
-    {
-      if (!mutt_strcmp (token->data, Commands[i].name))
-      {
-       if (Commands[i].func (token, &expn, Commands[i].data, err) != 0)
-         goto finish;
+    for (i = 0; Commands[i].name; i++) {
+      if (!mutt_strcmp (token->data, Commands[i].name)) {
+        if (Commands[i].func (token, &expn, Commands[i].data, err) != 0)
+          goto finish;
         break;
       }
     }
-    if (!Commands[i].name)
-    {
-      snprintf (err->data, err->dsize, _("%s: unknown command"), NONULL (token->data));
+    if (!Commands[i].name) {
+      snprintf (err->data, err->dsize, _("%s: unknown command"),
+                NONULL (token->data));
       goto finish;
     }
   }
@@ -1853,11 +1728,11 @@ finish:
 #define NUMCOMMANDS (sizeof (Commands)/sizeof (Commands[0]))
 /* initial string that starts completion. No telling how much crap 
  * the user has typed so far. Allocate LONG_STRING just to be sure! */
-char User_typed [LONG_STRING] = {0}; 
+char User_typed[LONG_STRING] = { 0 };
 
-int  Num_matched = 0; /* Number of matches for completion */
-char Completed [STRING] = {0}; /* completed string (command or variable) */
-char *Matches[MAX(NUMVARS,NUMCOMMANDS) + 1]; /* all the matches + User_typed */
+int Num_matched = 0;            /* Number of matches for completion */
+char Completed[STRING] = { 0 }; /* completed string (command or variable) */
+char *Matches[MAX (NUMVARS, NUMCOMMANDS) + 1];  /* all the matches + User_typed */
 
 /* helper function for completion.  Changes the dest buffer if
    necessary/possible to aid completion.
@@ -1870,13 +1745,11 @@ static void candidate (char *dest, char *try, char *src, int len)
 {
   int l;
 
-  if (strstr (src, try) == src)
-  {
+  if (strstr (src, try) == src) {
     Matches[Num_matched++] = src;
     if (dest[0] == 0)
       strfcpy (dest, src, len);
-    else
-    {
+    else {
       for (l = 0; src[l] && src[l] == dest[l]; l++);
       dest[l] = 0;
     }
@@ -1887,7 +1760,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
 {
   char *pt = buffer;
   int num;
-  int spaces; /* keep track of the number of leading spaces on the line */
+  int spaces;                   /* keep track of the number of leading spaces on the line */
 
   SKIPWS (buffer);
   spaces = buffer - pt;
@@ -1896,76 +1769,71 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
   while ((pt > buffer) && !isspace ((unsigned char) *pt))
     pt--;
 
-  if (pt == buffer) /* complete cmd */
-  {
+  if (pt == buffer) {           /* complete cmd */
     /* first TAB. Collect all the matches */
-    if (numtabs == 1)
-    {
+    if (numtabs == 1) {
       Num_matched = 0;
       strfcpy (User_typed, pt, sizeof (User_typed));
       memset (Matches, 0, sizeof (Matches));
       memset (Completed, 0, sizeof (Completed));
       for (num = 0; Commands[num].name; num++)
-       candidate (Completed, User_typed, Commands[num].name, sizeof (Completed));
+        candidate (Completed, User_typed, Commands[num].name,
+                   sizeof (Completed));
       Matches[Num_matched++] = User_typed;
 
       /* All matches are stored. Longest non-ambiguous string is ""
        * i.e. dont change 'buffer'. Fake successful return this time */
       if (User_typed[0] == 0)
-       return 1;
+        return 1;
     }
 
     if (Completed[0] == 0 && User_typed[0])
       return 0;
 
-     /* Num_matched will _always_ be atleast 1 since the initial
-      * user-typed string is always stored */
+    /* Num_matched will _always_ be atleast 1 since the initial
+     * user-typed string is always stored */
     if (numtabs == 1 && Num_matched == 2)
-      snprintf(Completed, sizeof(Completed),"%s", Matches[0]);
+      snprintf (Completed, sizeof (Completed), "%s", Matches[0]);
     else if (numtabs > 1 && Num_matched > 2)
       /* cycle thru all the matches */
-      snprintf(Completed, sizeof(Completed), "%s", 
-              Matches[(numtabs - 2) % Num_matched]);
+      snprintf (Completed, sizeof (Completed), "%s",
+                Matches[(numtabs - 2) % Num_matched]);
 
     /* return the completed command */
     strncpy (buffer, Completed, len - spaces);
   }
   else if (!mutt_strncmp (buffer, "set", 3)
-          || !mutt_strncmp (buffer, "unset", 5)
-          || !mutt_strncmp (buffer, "reset", 5)
-          || !mutt_strncmp (buffer, "toggle", 6))
-  {            /* complete variables */
+           || !mutt_strncmp (buffer, "unset", 5)
+           || !mutt_strncmp (buffer, "reset", 5)
+           || !mutt_strncmp (buffer, "toggle", 6)) {    /* complete variables */
     char *prefixes[] = { "no", "inv", "?", "&", 0 };
-    
+
     pt++;
     /* loop through all the possible prefixes (no, inv, ...) */
-    if (!mutt_strncmp (buffer, "set", 3))
-    {
-      for (num = 0; prefixes[num]; num++)
-      {
-       if (!mutt_strncmp (pt, prefixes[num], mutt_strlen (prefixes[num])))
-       {
-         pt += mutt_strlen (prefixes[num]);
-         break;
-       }
+    if (!mutt_strncmp (buffer, "set", 3)) {
+      for (num = 0; prefixes[num]; num++) {
+        if (!mutt_strncmp (pt, prefixes[num], mutt_strlen (prefixes[num]))) {
+          pt += mutt_strlen (prefixes[num]);
+          break;
+        }
       }
     }
-    
+
     /* first TAB. Collect all the matches */
-    if (numtabs == 1)
-    {
+    if (numtabs == 1) {
       Num_matched = 0;
       strfcpy (User_typed, pt, sizeof (User_typed));
       memset (Matches, 0, sizeof (Matches));
       memset (Completed, 0, sizeof (Completed));
       for (num = 0; MuttVars[num].option; num++)
-       candidate (Completed, User_typed, MuttVars[num].option, sizeof (Completed));
+        candidate (Completed, User_typed, MuttVars[num].option,
+                   sizeof (Completed));
       Matches[Num_matched++] = User_typed;
 
       /* All matches are stored. Longest non-ambiguous string is ""
        * i.e. dont change 'buffer'. Fake successful return this time */
       if (User_typed[0] == 0)
-       return 1;
+        return 1;
     }
 
     if (Completed[0] == 0 && User_typed[0])
@@ -1974,44 +1842,42 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
     /* Num_matched will _always_ be atleast 1 since the initial
      * user-typed string is always stored */
     if (numtabs == 1 && Num_matched == 2)
-      snprintf(Completed, sizeof(Completed),"%s", Matches[0]);
+      snprintf (Completed, sizeof (Completed), "%s", Matches[0]);
     else if (numtabs > 1 && Num_matched > 2)
-    /* cycle thru all the matches */
-      snprintf(Completed, sizeof(Completed), "%s", 
-              Matches[(numtabs - 2) % Num_matched]);
+      /* cycle thru all the matches */
+      snprintf (Completed, sizeof (Completed), "%s",
+                Matches[(numtabs - 2) % Num_matched]);
 
     strncpy (pt, Completed, buffer + len - pt - spaces);
   }
-  else if (!mutt_strncmp (buffer, "exec", 4))
-  {
+  else if (!mutt_strncmp (buffer, "exec", 4)) {
     struct binding_t *menu = km_get_table (CurrentMenu);
 
     if (!menu && CurrentMenu != MENU_PAGER)
       menu = OpGeneric;
-    
+
     pt++;
     /* first TAB. Collect all the matches */
-    if (numtabs == 1)
-    {
+    if (numtabs == 1) {
       Num_matched = 0;
       strfcpy (User_typed, pt, sizeof (User_typed));
       memset (Matches, 0, sizeof (Matches));
       memset (Completed, 0, sizeof (Completed));
       for (num = 0; menu[num].name; num++)
-       candidate (Completed, User_typed, menu[num].name, sizeof (Completed));
+        candidate (Completed, User_typed, menu[num].name, sizeof (Completed));
       /* try the generic menu */
-      if (Completed[0] == 0 && CurrentMenu != MENU_PAGER) 
-      {
-       menu = OpGeneric;
-       for (num = 0; menu[num].name; num++)
-         candidate (Completed, User_typed, menu[num].name, sizeof (Completed));
+      if (Completed[0] == 0 && CurrentMenu != MENU_PAGER) {
+        menu = OpGeneric;
+        for (num = 0; menu[num].name; num++)
+          candidate (Completed, User_typed, menu[num].name,
+                     sizeof (Completed));
       }
       Matches[Num_matched++] = User_typed;
 
       /* All matches are stored. Longest non-ambiguous string is ""
        * i.e. dont change 'buffer'. Fake successful return this time */
       if (User_typed[0] == 0)
-       return 1;
+        return 1;
     }
 
     if (Completed[0] == 0 && User_typed[0])
@@ -2020,11 +1886,11 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
     /* Num_matched will _always_ be atleast 1 since the initial
      * user-typed string is always stored */
     if (numtabs == 1 && Num_matched == 2)
-      snprintf(Completed, sizeof(Completed),"%s", Matches[0]);
+      snprintf (Completed, sizeof (Completed), "%s", Matches[0]);
     else if (numtabs > 1 && Num_matched > 2)
-    /* cycle thru all the matches */
-      snprintf(Completed, sizeof(Completed), "%s", 
-              Matches[(numtabs - 2) % Num_matched]);
+      /* cycle thru all the matches */
+      snprintf (Completed, sizeof (Completed), "%s",
+                Matches[(numtabs - 2) % Num_matched]);
 
     strncpy (pt, Completed, buffer + len - pt - spaces);
   }
@@ -2038,7 +1904,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
 {
   char var[STRING], *pt = buffer;
   int spaces;
-  
+
   if (buffer[0] == 0)
     return 0;
 
@@ -2048,88 +1914,87 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
   pt = buffer + pos - spaces;
   while ((pt > buffer) && !isspace ((unsigned char) *pt))
     pt--;
-  pt++; /* move past the space */
-  if (*pt == '=') /* abort if no var before the '=' */
+  pt++;                         /* move past the space */
+  if (*pt == '=')               /* abort if no var before the '=' */
     return 0;
 
-  if (mutt_strncmp (buffer, "set", 3) == 0)
-  {
+  if (mutt_strncmp (buffer, "set", 3) == 0) {
     int idx;
+
     strfcpy (var, pt, sizeof (var));
     /* ignore the trailing '=' when comparing */
     var[mutt_strlen (var) - 1] = 0;
-    if ((idx = mutt_option_index (var)) == -1) 
-      return 0; /* no such variable. */
-    else
-    {
-      char tmp [LONG_STRING], tmp2[LONG_STRING];
+    if ((idx = mutt_option_index (var)) == -1)
+      return 0;                 /* no such variable. */
+    else {
+      char tmp[LONG_STRING], tmp2[LONG_STRING];
       char *s, *d;
       size_t dlen = buffer + len - pt - spaces;
       char *vals[] = { "no", "yes", "ask-no", "ask-yes" };
 
       tmp[0] = '\0';
 
-      if ((DTYPE(MuttVars[idx].type) == DT_STR) || 
-         (DTYPE(MuttVars[idx].type) == DT_PATH) ||
-         (DTYPE(MuttVars[idx].type) == DT_RX))
-      {
-       strfcpy (tmp, NONULL (*((char **) MuttVars[idx].data)), sizeof (tmp));
-       if (DTYPE (MuttVars[idx].type) == DT_PATH)
-         mutt_pretty_mailbox (tmp);
+      if ((DTYPE (MuttVars[idx].type) == DT_STR) ||
+          (DTYPE (MuttVars[idx].type) == DT_PATH) ||
+          (DTYPE (MuttVars[idx].type) == DT_RX)) {
+        strfcpy (tmp, NONULL (*((char **) MuttVars[idx].data)), sizeof (tmp));
+        if (DTYPE (MuttVars[idx].type) == DT_PATH)
+          mutt_pretty_mailbox (tmp);
       }
-      else if (DTYPE (MuttVars[idx].type) == DT_ADDR)
-      {
-       rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) MuttVars[idx].data), 0);
+      else if (DTYPE (MuttVars[idx].type) == DT_ADDR) {
+        rfc822_write_address (tmp, sizeof (tmp),
+                              *((ADDRESS **) MuttVars[idx].data), 0);
       }
       else if (DTYPE (MuttVars[idx].type) == DT_QUAD)
-       strfcpy (tmp, vals[quadoption (MuttVars[idx].data)], sizeof (tmp));
+        strfcpy (tmp, vals[quadoption (MuttVars[idx].data)], sizeof (tmp));
       else if (DTYPE (MuttVars[idx].type) == DT_NUM)
-       snprintf (tmp, sizeof (tmp), "%d", (*((short *) MuttVars[idx].data)));
-      else if (DTYPE (MuttVars[idx].type) == DT_SORT)
-      {
-       const struct mapping_t *map;
-       char *p;
-
-       switch (MuttVars[idx].type & DT_SUBTYPE_MASK)
-       {
-         case DT_SORT_ALIAS:
-           map = SortAliasMethods;
-           break;
-         case DT_SORT_BROWSER:
-           map = SortBrowserMethods;
-           break;
-         case DT_SORT_KEYS:
-            if ((WithCrypto & APPLICATION_PGP))
-              map = SortKeyMethods;
-            else
-              map = SortMethods;
-           break;
-         default:
-           map = SortMethods;
-           break;
-       }
-       p = mutt_getnamebyvalue (*((short *) MuttVars[idx].data) & SORT_MASK, map);
-       snprintf (tmp, sizeof (tmp), "%s%s%s",
-                 (*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
-                 (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" : "",
-                 p);
+        snprintf (tmp, sizeof (tmp), "%d", (*((short *) MuttVars[idx].data)));
+      else if (DTYPE (MuttVars[idx].type) == DT_SORT) {
+        const struct mapping_t *map;
+        char *p;
+
+        switch (MuttVars[idx].type & DT_SUBTYPE_MASK) {
+        case DT_SORT_ALIAS:
+          map = SortAliasMethods;
+          break;
+        case DT_SORT_BROWSER:
+          map = SortBrowserMethods;
+          break;
+        case DT_SORT_KEYS:
+          if ((WithCrypto & APPLICATION_PGP))
+            map = SortKeyMethods;
+          else
+            map = SortMethods;
+          break;
+        default:
+          map = SortMethods;
+          break;
+        }
+        p =
+          mutt_getnamebyvalue (*((short *) MuttVars[idx].data) & SORT_MASK,
+                               map);
+        snprintf (tmp, sizeof (tmp), "%s%s%s",
+                  (*((short *) MuttVars[idx].data) & SORT_REVERSE) ?
+                  "reverse-" : "",
+                  (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" :
+                  "", p);
       }
       else if (DTYPE (MuttVars[idx].type) == DT_BOOL)
-       strfcpy (tmp, option (MuttVars[idx].data) ? "yes" : "no", sizeof (tmp));
+        strfcpy (tmp, option (MuttVars[idx].data) ? "yes" : "no",
+                 sizeof (tmp));
       else
-       return 0;
-      
-      for (s = tmp, d = tmp2; *s && (d - tmp2) < sizeof (tmp2) - 2;)
-      {
-       if (*s == '\\' || *s == '"')
-         *d++ = '\\';
-       *d++ = *s++;
+        return 0;
+
+      for (s = tmp, d = tmp2; *s && (d - tmp2) < sizeof (tmp2) - 2;) {
+        if (*s == '\\' || *s == '"')
+          *d++ = '\\';
+        *d++ = *s++;
       }
       *d = '\0';
-      
+
       strfcpy (tmp, pt, sizeof (tmp));
       snprintf (pt, dlen, "%s\"%s\"", tmp, tmp2);
-         
+
       return 1;
     }
   }
@@ -2137,33 +2002,31 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
 }
 
 /* Implement the -Q command line flag */
-int mutt_query_variables (LIST *queries)
+int mutt_query_variables (LIST * queries)
 {
   LIST *p;
-  
+
   char errbuff[STRING];
   char command[STRING];
-  
+
   BUFFER err, token;
-  
+
   memset (&err, 0, sizeof (err));
   memset (&token, 0, sizeof (token));
-  
+
   err.data = errbuff;
   err.dsize = sizeof (errbuff);
-  
-  for (p = queries; p; p = p->next)
-  {
+
+  for (p = queries; p; p = p->next) {
     snprintf (command, sizeof (command), "set ?%s\n", p->data);
-    if (mutt_parse_rc_line (command, &token, &err) == -1)
-    {
+    if (mutt_parse_rc_line (command, &token, &err) == -1) {
       fprintf (stderr, "%s\n", err.data);
       FREE (&token.data);
       return 1;
     }
     printf ("%s\n", err.data);
   }
-  
+
   FREE (&token.data);
   return 0;
 }
@@ -2172,7 +2035,7 @@ char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
 {
   int i;
 
-  for (i=0; map[i].name; i++)
+  for (i = 0; map[i].name; i++)
     if (map[i].value == val)
       return (map[i].name);
   return NULL;
@@ -2197,23 +2060,23 @@ static void start_debug (void)
   char buf2[_POSIX_PATH_MAX];
 
   /* rotate the old debug logs */
-  for (i=3; i>=0; i--)
-  {
-    snprintf (buf, sizeof(buf), "%s/.muttdebug%d", NONULL(Homedir), i);
-    snprintf (buf2, sizeof(buf2), "%s/.muttdebug%d", NONULL(Homedir), i+1);
+  for (i = 3; i >= 0; i--) {
+    snprintf (buf, sizeof (buf), "%s/.muttdebug%d", NONULL (Homedir), i);
+    snprintf (buf2, sizeof (buf2), "%s/.muttdebug%d", NONULL (Homedir),
+              i + 1);
     rename (buf, buf2);
   }
-  if ((debugfile = safe_fopen(buf, "w")) != NULL)
-  {
+  if ((debugfile = safe_fopen (buf, "w")) != NULL) {
     t = time (0);
-    setbuf (debugfile, NULL); /* don't buffer the debugging output! */
-    fprintf (debugfile, "Mutt-ng %s started at %s.\nDebugging at level %d.\n\n",
-            MUTT_VERSION, asctime (localtime (&t)), debuglevel);
+    setbuf (debugfile, NULL);   /* don't buffer the debugging output! */
+    fprintf (debugfile,
+             "Mutt-ng %s started at %s.\nDebugging at level %d.\n\n",
+             MUTT_VERSION, asctime (localtime (&t)), debuglevel);
   }
 }
 #endif
 
-static int mutt_execute_commands (LIST *p)
+static int mutt_execute_commands (LIST * p)
 {
   BUFFER err, token;
   char errstr[SHORT_STRING];
@@ -2222,10 +2085,8 @@ static int mutt_execute_commands (LIST *p)
   err.data = errstr;
   err.dsize = sizeof (errstr);
   memset (&token, 0, sizeof (token));
-  for (; p; p = p->next)
-  {
-    if (mutt_parse_rc_line (p->data, &token, &err) != 0)
-    {
+  for (; p; p = p->next) {
+    if (mutt_parse_rc_line (p->data, &token, &err) != 0) {
       fprintf (stderr, _("Error in command line: %s\n"), err.data);
       FREE (&token.data);
       return (-1);
@@ -2235,7 +2096,7 @@ static int mutt_execute_commands (LIST *p)
   return 0;
 }
 
-void mutt_init (int skip_sys_rc, LIST *commands)
+void mutt_init (int skip_sys_rc, LIST * commands)
 {
   struct passwd *pw;
   struct utsname utsname;
@@ -2251,16 +2112,15 @@ void mutt_init (int skip_sys_rc, LIST *commands)
    * XXX - use something even more difficult to predict?
    */
   snprintf (AttachmentMarker, sizeof (AttachmentMarker),
-           "\033]9;%ld\a", (long) time (NULL));
-  
+            "\033]9;%ld\a", (long) time (NULL));
+
   /* on one of the systems I use, getcwd() does not return the same prefix
      as is listed in the passwd file */
   if ((p = getenv ("HOME")))
     Homedir = safe_strdup (p);
 
   /* Get some information about the user */
-  if ((pw = getpwuid (getuid ())))
-  {
+  if ((pw = getpwuid (getuid ()))) {
     char rnbuf[STRING];
 
     Username = safe_strdup (pw->pw_name);
@@ -2270,18 +2130,15 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     Realname = safe_strdup (mutt_gecos_name (rnbuf, sizeof (rnbuf), pw));
     Shell = safe_strdup (pw->pw_shell);
   }
-  else 
-  {
-    if (!Homedir)
-    {
+  else {
+    if (!Homedir) {
       mutt_endwin (NULL);
       fputs (_("unable to determine home directory"), stderr);
       exit (1);
     }
     if ((p = getenv ("USER")))
       Username = safe_strdup (p);
-    else
-    {
+    else {
       mutt_endwin (NULL);
       fputs (_("unable to determine username"), stderr);
       exit (1);
@@ -2298,11 +2155,10 @@ void mutt_init (int skip_sys_rc, LIST *commands)
   /* And about the host... */
   uname (&utsname);
   /* some systems report the FQDN instead of just the hostname */
-  if ((p = strchr (utsname.nodename, '.')))
-  {
+  if ((p = strchr (utsname.nodename, '.'))) {
     Hostname = mutt_substrdup (utsname.nodename, p);
     p++;
-    strfcpy (buffer, p, sizeof (buffer)); /* save the domain for below */
+    strfcpy (buffer, p, sizeof (buffer));       /* save the domain for below */
   }
   else
     Hostname = safe_strdup (utsname.nodename);
@@ -2313,27 +2169,27 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     Fqdn = safe_strdup ("@");
   else
 #endif /* DOMAIN */
-    if (*DOMAIN != '@')
-  {
+  if (*DOMAIN != '@') {
     Fqdn = safe_malloc (mutt_strlen (DOMAIN) + mutt_strlen (Hostname) + 2);
-    sprintf (Fqdn, "%s.%s", NONULL(Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
+    sprintf (Fqdn, "%s.%s", NONULL (Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
   }
   else
-    Fqdn = safe_strdup(NONULL(Hostname));
+    Fqdn = safe_strdup (NONULL (Hostname));
 
 #ifdef USE_NNTP
   {
     FILE *f;
     char *i;
 
-    if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r")))
-    {
+    if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) {
       buffer[0] = '\0';
       fgets (buffer, sizeof (buffer), f);
       p = &buffer;
       SKIPWS (p);
       i = p;
-      while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r') && (*i != '\n')) i++;
+      while (*i && (*i != ' ') && (*i != '\t') && (*i != '\r')
+             && (*i != '\n'))
+        i++;
       *i = '\0';
       NewsServer = safe_strdup (p);
       fclose (f);
@@ -2347,29 +2203,28 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     Spoolfile = safe_strdup (p);
   else if ((p = getenv ("MAILDIR")))
     Spoolfile = safe_strdup (p);
-  else
-  {
+  else {
 #ifdef HOMESPOOL
     mutt_concat_path (buffer, NONULL (Homedir), MAILPATH, sizeof (buffer));
 #else
-    mutt_concat_path (buffer, MAILPATH, NONULL(Username), sizeof (buffer));
+    mutt_concat_path (buffer, MAILPATH, NONULL (Username), sizeof (buffer));
 #endif
     Spoolfile = safe_strdup (buffer);
   }
 
   if ((p = getenv ("MAILCAPS")))
     MailcapPath = safe_strdup (p);
-  else
-  {
+  else {
     /* Default search path from RFC1524 */
-    MailcapPath = safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
+    MailcapPath =
+      safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
+                   "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
   }
 
   Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
 
   p = getenv ("VISUAL");
-  if (!p)
-  {
+  if (!p) {
     p = getenv ("EDITOR");
     if (!p)
       p = "vi";
@@ -2377,8 +2232,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
   Editor = safe_strdup (p);
   Visual = safe_strdup (p);
 
-  if ((p = getenv ("REPLYTO")) != NULL)
-  {
+  if ((p = getenv ("REPLYTO")) != NULL) {
     BUFFER buf, token;
 
     snprintf (buffer, sizeof (buffer), "Reply-To: %s", p);
@@ -2394,14 +2248,13 @@ void mutt_init (int skip_sys_rc, LIST *commands)
 
   if ((p = getenv ("EMAIL")) != NULL)
     From = rfc822_parse_adrlist (NULL, p);
-  
+
   mutt_set_langinfo_charset ();
   mutt_set_charset (Charset);
-  
-  
+
+
   /* Set standard defaults */
-  for (i = 0; MuttVars[i].option; i++)
-  {
+  for (i = 0; MuttVars[i].option; i++) {
     mutt_set_default (&MuttVars[i]);
     mutt_restore_default (&MuttVars[i]);
   }
@@ -2419,87 +2272,84 @@ void mutt_init (int skip_sys_rc, LIST *commands)
 
 #ifdef HAVE_GETSID
   /* Unset suspend by default if we're the session leader */
-  if (getsid(0) == getpid())
+  if (getsid (0) == getpid ())
     unset_option (OPTSUSPEND);
 #endif
 
   mutt_init_history ();
 
-  
-  
-  
+
+
+
   /*
    * 
-   *                      BIG FAT WARNING
+   *                       BIG FAT WARNING
    * 
    * When changing the code which looks for a configuration file,
    * please also change the corresponding code in muttbug.sh.in.
    * 
    * 
    */
-  
-  
-  
-  
-  if (!Muttrc)
-  {
-    snprintf (buffer, sizeof(buffer), "%s/.muttngrc-%s", NONULL(Homedir), MUTT_VERSION);
-    if (access(buffer, F_OK) == -1)
-      snprintf (buffer, sizeof(buffer), "%s/.muttngrc", NONULL(Homedir));
-    if (access(buffer, F_OK) == -1)
-      snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc-%s", NONULL(Homedir), MUTT_VERSION);
-    if (access(buffer, F_OK) == -1)
-      snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc", NONULL(Homedir));
-    
+
+
+
+
+  if (!Muttrc) {
+    snprintf (buffer, sizeof (buffer), "%s/.muttngrc-%s", NONULL (Homedir),
+              MUTT_VERSION);
+    if (access (buffer, F_OK) == -1)
+      snprintf (buffer, sizeof (buffer), "%s/.muttngrc", NONULL (Homedir));
+    if (access (buffer, F_OK) == -1)
+      snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc-%s",
+                NONULL (Homedir), MUTT_VERSION);
+    if (access (buffer, F_OK) == -1)
+      snprintf (buffer, sizeof (buffer), "%s/.muttng/muttngrc",
+                NONULL (Homedir));
+
     default_rc = 1;
     Muttrc = safe_strdup (buffer);
   }
-  else
-  {
+  else {
     strfcpy (buffer, Muttrc, sizeof (buffer));
     FREE (&Muttrc);
     mutt_expand_path (buffer, sizeof (buffer));
     Muttrc = safe_strdup (buffer);
   }
   FREE (&AliasFile);
-  AliasFile = safe_strdup (NONULL(Muttrc));
+  AliasFile = safe_strdup (NONULL (Muttrc));
 
   /* Process the global rc file if it exists and the user hasn't explicity
      requested not to via "-n".  */
-  if (!skip_sys_rc)
-  {
-    snprintf (buffer, sizeof(buffer), "%s/Muttngrc-%s", SYSCONFDIR, MUTT_VERSION);
+  if (!skip_sys_rc) {
+    snprintf (buffer, sizeof (buffer), "%s/Muttngrc-%s", SYSCONFDIR,
+              MUTT_VERSION);
     if (access (buffer, F_OK) == -1)
-      snprintf (buffer, sizeof(buffer), "%s/Muttngrc", SYSCONFDIR);
+      snprintf (buffer, sizeof (buffer), "%s/Muttngrc", SYSCONFDIR);
     if (access (buffer, F_OK) == -1)
-      snprintf (buffer, sizeof (buffer), "%s/Muttngrc-%s", PKGDATADIR, MUTT_VERSION);
+      snprintf (buffer, sizeof (buffer), "%s/Muttngrc-%s", PKGDATADIR,
+                MUTT_VERSION);
     if (access (buffer, F_OK) == -1)
       snprintf (buffer, sizeof (buffer), "%s/Muttngrc", PKGDATADIR);
-    if (access (buffer, F_OK) != -1)
-    {
-      if (source_rc (buffer, &err) != 0)
-      {
-       fputs (err.data, stderr);
-       fputc ('\n', stderr);
-       need_pause = 1;
+    if (access (buffer, F_OK) != -1) {
+      if (source_rc (buffer, &err) != 0) {
+        fputs (err.data, stderr);
+        fputc ('\n', stderr);
+        need_pause = 1;
       }
     }
   }
 
   /* Read the user's initialization file.  */
-  if (access (Muttrc, F_OK) != -1)
-  {
+  if (access (Muttrc, F_OK) != -1) {
     if (!option (OPTNOCURSES))
       endwin ();
-    if (source_rc (Muttrc, &err) != 0)
-    {
+    if (source_rc (Muttrc, &err) != 0) {
       fputs (err.data, stderr);
       fputc ('\n', stderr);
       need_pause = 1;
     }
   }
-  else if (!default_rc)
-  {
+  else if (!default_rc) {
     /* file specified by -F does not exist */
     snprintf (buffer, sizeof (buffer), "%s: %s", Muttrc, strerror (errno));
     mutt_endwin (buffer);
@@ -2509,14 +2359,13 @@ void mutt_init (int skip_sys_rc, LIST *commands)
   if (mutt_execute_commands (commands) != 0)
     need_pause = 1;
 
-  if (need_pause && !option (OPTNOCURSES))
-  {
+  if (need_pause && !option (OPTNOCURSES)) {
     if (mutt_any_key_to_continue (NULL) == -1)
-      mutt_exit(1);
+      mutt_exit (1);
   }
 
 #if 0
-  set_option (OPTWEED); /* turn weeding on by default */
+  set_option (OPTWEED);         /* turn weeding on by default */
 #endif
 }
 
@@ -2524,7 +2373,7 @@ int mutt_get_hook_type (const char *name)
 {
   struct command_t *c;
 
-  for (c = Commands ; c->name ; c++)
+  for (c = Commands; c->name; c++)
     if (c->func == mutt_parse_hook && ascii_strcasecmp (c->name, name) == 0)
       return c->data;
   return 0;
diff --git a/init.h b/init.h
index 912839a..4a443f8 100644 (file)
--- a/init.h
+++ b/init.h
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifdef _MAKEDOC
 # include "config.h"
 
 #ifndef _MAKEDOC
 #define DT_MASK                0x0f
-#define DT_BOOL                1 /* boolean option */
-#define DT_NUM         2 /* a number */
-#define DT_STR         3 /* a string */
-#define DT_PATH                4 /* a pathname */
-#define DT_QUAD                5 /* quad-option (yes/no/ask-yes/ask-no) */
-#define DT_SORT                6 /* sorting methods */
-#define DT_RX          7 /* regular expressions */
-#define DT_MAGIC       8 /* mailbox type */
-#define DT_SYN         9 /* synonym for another variable */
-#define DT_ADDR               10 /* e-mail address */
+#define DT_BOOL                1       /* boolean option */
+#define DT_NUM         2       /* a number */
+#define DT_STR         3       /* a string */
+#define DT_PATH                4       /* a pathname */
+#define DT_QUAD                5       /* quad-option (yes/no/ask-yes/ask-no) */
+#define DT_SORT                6       /* sorting methods */
+#define DT_RX          7       /* regular expressions */
+#define DT_MAGIC       8       /* mailbox type */
+#define DT_SYN         9       /* synonym for another variable */
+#define DT_ADDR               10       /* e-mail address */
 
 #define DTYPE(x) ((x) & DT_MASK)
 
 #define DT_SORT_AUX    0x80
 
 /* flags to parse_set() */
-#define M_SET_INV      (1<<0)  /* default is to invert all vars */
-#define M_SET_UNSET    (1<<1)  /* default is to unset all vars */
-#define M_SET_RESET    (1<<2)  /* default is to reset all vars to default */
+#define M_SET_INV      (1<<0)  /* default is to invert all vars */
+#define M_SET_UNSET    (1<<1)  /* default is to unset all vars */
+#define M_SET_RESET    (1<<2)  /* default is to reset all vars to default */
 
 /* forced redraw/resort types */
 #define R_NONE         0
 #define R_INDEX                (1<<0)
 #define R_PAGER                (1<<1)
-#define R_RESORT       (1<<2)  /* resort the mailbox */
-#define R_RESORT_SUB   (1<<3)  /* resort subthreads */
+#define R_RESORT       (1<<2)  /* resort the mailbox */
+#define R_RESORT_SUB   (1<<3)  /* resort subthreads */
 #define R_RESORT_INIT  (1<<4)  /* resort from scratch */
 #define R_TREE         (1<<5)  /* redraw the thread tree */
 #define R_BOTH         (R_INDEX | R_PAGER)
 #define R_RESORT_BOTH  (R_RESORT | R_RESORT_SUB)
 
-struct option_t
-{
+struct option_t {
   char *option;
   short type;
   short flags;
   unsigned long data;
-  unsigned long init; /* initial value */
+  unsigned long init;           /* initial value */
 };
 
-struct feature_t
-{
-  char* name;
+struct feature_t {
+  char *name;
   short builtin;
 };
 
@@ -116,3568 +114,3605 @@ struct feature_t
 #endif
 
 struct option_t MuttVars[] = {
-  /*++*/
-  { "abort_nosubject", DT_QUAD, R_NONE, OPT_SUBJECT, M_ASKYES },
+  /*++ */
+  {"abort_nosubject", DT_QUAD, R_NONE, OPT_SUBJECT, M_ASKYES},
+  /*
+   ** .pp
+   ** If set to \fIyes\fP, when composing messages and no subject is given
+   ** at the subject prompt, composition will be aborted.  If set to
+   ** \fIno\fP, composing messages with no subject given at the subject
+   ** prompt will never be aborted.
+   */
+  {"abort_unmodified", DT_QUAD, R_NONE, OPT_ABORT, M_YES},
   /*
-  ** .pp
-  ** If set to \fIyes\fP, when composing messages and no subject is given
-  ** at the subject prompt, composition will be aborted.  If set to
-  ** \fIno\fP, composing messages with no subject given at the subject
-  ** prompt will never be aborted.
-  */
-  { "abort_unmodified",        DT_QUAD, R_NONE, OPT_ABORT, M_YES },
+   ** .pp
+   ** If set to \fIyes\fP, composition will automatically abort after
+   ** editing the message body if no changes are made to the file (this
+   ** check only happens after the \fIfirst\fP edit of the file).  When set
+   ** to \fIno\fP, composition will never be aborted.
+   */
+  {"alias_file", DT_PATH, R_NONE, UL & AliasFile, UL "~/.muttngrc"},
+  /*
+   ** .pp
+   ** The default file in which to save aliases created by the 
+   ** ``$create-alias'' function.
+   ** .pp
+   ** \fBNote:\fP Mutt-ng will not automatically source this file; you must
+   ** explicitly use the ``$source'' command for it to be executed.
+   */
+  {"alias_format", DT_STR, R_NONE, UL & AliasFmt, UL "%4n %2f %t %-10a   %r"},
+  /*
+   ** .pp
+   ** Specifies the format of the data displayed for the `alias' menu.  The
+   ** following printf(3)-style sequences are available:
+   ** .pp
+   ** .dl
+   ** .dt %a .dd alias name
+   ** .dt %f .dd flags - currently, a "d" for an alias marked for deletion
+   ** .dt %n .dd index number
+   ** .dt %r .dd address which alias expands to
+   ** .dt %t .dd character which indicates if the alias is tagged for inclusion
+   ** .de
+   */
+  {"allow_8bit", DT_BOOL, R_NONE, OPTALLOW8BIT, 1},
   /*
-  ** .pp
-  ** If set to \fIyes\fP, composition will automatically abort after
-  ** editing the message body if no changes are made to the file (this
-  ** check only happens after the \fIfirst\fP edit of the file).  When set
-  ** to \fIno\fP, composition will never be aborted.
-  */
-  { "alias_file",      DT_PATH, R_NONE, UL &AliasFile, UL "~/.muttngrc" },
+   ** .pp
+   ** Controls whether 8-bit data is converted to 7-bit using either Quoted-
+   ** Printable or Base64 encoding when sending mail.
+   */
+  {"allow_ansi", DT_BOOL, R_NONE, OPTALLOWANSI, 0},
+  /*
+   ** .pp
+   ** Controls whether ANSI color codes in messages (and color tags in 
+   ** rich text messages) are to be interpreted.
+   ** Messages containing these codes are rare, but if this option is set,
+   ** their text will be colored accordingly. Note that this may override
+   ** your color choices, and even present a security problem, since a
+   ** message could include a line like "[-- PGP output follows ..." and
+   ** give it the same color as your attachment color.
+   */
+  {"arrow_cursor", DT_BOOL, R_BOTH, OPTARROWCURSOR, 0},
+  /*
+   ** .pp
+   ** When set, an arrow (``->'') will be used to indicate the current entry
+   ** in menus instead of highlighting the whole line.  On slow network or modem
+   ** links this will make response faster because there is less that has to
+   ** be redrawn on the screen when moving to the next or previous entries
+   ** in the menu.
+   */
+  {"ascii_chars", DT_BOOL, R_BOTH, OPTASCIICHARS, 0},
   /*
-  ** .pp
-  ** The default file in which to save aliases created by the 
-  ** ``$create-alias'' function.
-  ** .pp
-  ** \fBNote:\fP Mutt-ng will not automatically source this file; you must
-  ** explicitly use the ``$source'' command for it to be executed.
-  */
-  { "alias_format",    DT_STR,  R_NONE, UL &AliasFmt, UL "%4n %2f %t %-10a   %r" },
+   ** .pp
+   ** If set, Mutt-ng will use plain ASCII characters when displaying thread
+   ** and attachment trees, instead of the default \fIACS\fP characters.
+   */
+  {"askbcc", DT_BOOL, R_NONE, OPTASKBCC, 0},
   /*
-  ** .pp
-  ** Specifies the format of the data displayed for the `alias' menu.  The
-  ** following printf(3)-style sequences are available:
-  ** .pp
-  ** .dl
-  ** .dt %a .dd alias name
-  ** .dt %f .dd flags - currently, a "d" for an alias marked for deletion
-  ** .dt %n .dd index number
-  ** .dt %r .dd address which alias expands to
-  ** .dt %t .dd character which indicates if the alias is tagged for inclusion
-  ** .de
-  */
-  { "allow_8bit",      DT_BOOL, R_NONE, OPTALLOW8BIT, 1 },
+   ** .pp
+   ** If set, Mutt-ng will prompt you for blind-carbon-copy (Bcc) recipients
+   ** before editing an outgoing message.
+   */
+  {"askcc", DT_BOOL, R_NONE, OPTASKCC, 0},
   /*
-  ** .pp
-  ** Controls whether 8-bit data is converted to 7-bit using either Quoted-
-  ** Printable or Base64 encoding when sending mail.
-  */
-  { "allow_ansi",      DT_BOOL, R_NONE, OPTALLOWANSI, 0 },
+   ** .pp
+   ** If set, Mutt-ng will prompt you for carbon-copy (Cc) recipients before
+   ** editing the body of an outgoing message.
+   */
+  {"assumed_charset", DT_STR, R_NONE, UL & AssumedCharset, UL "us-ascii"},
+  /*
+   ** .pp
+   ** This variable is a colon-separated list of character encoding
+   ** schemes for messages without character encoding indication.
+   ** Header field values and message body content without character encoding
+   ** indication would be assumed that they are written in one of this list.
+   ** By default, all the header fields and message body without any charset
+   ** indication are assumed to be in "us-ascii".
+   ** .pp
+   ** For example, Japanese users might prefer this:
+   ** .pp
+   **   set assumed_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
+   ** .pp
+   ** However, only the first content is valid for the message body.
+   ** This variable is valid only if $$strict_mime is unset.
+   */
+#ifdef USE_NNTP
+  {"ask_follow_up", DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If set, Mutt-ng will prompt you for follow-up groups before editing
+   ** the body of an outgoing message.
+   */
+  {"ask_x_comment_to", DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If set, Mutt-ng will prompt you for x-comment-to field before editing
+   ** the body of an outgoing message.
+   */
+#endif
+  {"attach_format", DT_STR, R_NONE, UL & AttachFormat,
+   UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "},
+  /*
+   ** .pp
+   ** This variable describes the format of the `attachment' menu.  The
+   ** following printf-style sequences are understood:
+   ** .pp
+   ** .dl
+   ** .dt %C  .dd charset
+   ** .dt %c  .dd requires charset conversion (n or c)
+   ** .dt %D  .dd deleted flag
+   ** .dt %d  .dd description
+   ** .dt %e  .dd MIME content-transfer-encoding
+   ** .dt %f  .dd filename
+   ** .dt %I  .dd disposition (I=inline, A=attachment)
+   ** .dt %m  .dd major MIME type
+   ** .dt %M  .dd MIME subtype
+   ** .dt %n  .dd attachment number
+   ** .dt %s  .dd size
+   ** .dt %t  .dd tagged flag
+   ** .dt %T  .dd graphic tree characters
+   ** .dt %u  .dd unlink (=to delete) flag
+   ** .dt %>X .dd right justify the rest of the string and pad with character "X"
+   ** .dt %|X .dd pad to the end of the line with character "X"
+   ** .de
+   */
+  {"attach_sep", DT_STR, R_NONE, UL & AttachSep, UL "\n"},
   /*
-  ** .pp
-  ** Controls whether ANSI color codes in messages (and color tags in 
-  ** rich text messages) are to be interpreted.
-  ** Messages containing these codes are rare, but if this option is set,
-  ** their text will be colored accordingly. Note that this may override
-  ** your color choices, and even present a security problem, since a
-  ** message could include a line like "[-- PGP output follows ..." and
-  ** give it the same color as your attachment color.
-  */
-  { "arrow_cursor",    DT_BOOL, R_BOTH, OPTARROWCURSOR, 0 },
+   ** .pp
+   ** The separator to add between attachments when operating (saving,
+   ** printing, piping, etc) on a list of tagged attachments.
+   */
+  {"attach_split", DT_BOOL, R_NONE, OPTATTACHSPLIT, 1},
+  /*
+   ** .pp
+   ** If this variable is unset, when operating (saving, printing, piping,
+   ** etc) on a list of tagged attachments, Mutt-ng will concatenate the
+   ** attachments and will operate on them as a single attachment. The
+   ** ``$$attach_sep'' separator is added after each attachment. When set,
+   ** Mutt-ng will operate on the attachments one by one.
+   */
+  {"attribution", DT_STR, R_NONE, UL & Attribution, UL "On %d, %n wrote:"},
   /*
-  ** .pp
-  ** When set, an arrow (``->'') will be used to indicate the current entry
-  ** in menus instead of highlighting the whole line.  On slow network or modem
-  ** links this will make response faster because there is less that has to
-  ** be redrawn on the screen when moving to the next or previous entries
-  ** in the menu.
-  */
-  { "ascii_chars",     DT_BOOL, R_BOTH, OPTASCIICHARS, 0 },
+   ** .pp
+   ** This is the string that will precede a message which has been included
+   ** in a reply.  For a full listing of defined printf()-like sequences see
+   ** the section on ``$$index_format''.
+   */
+  {"autoedit", DT_BOOL, R_NONE, OPTAUTOEDIT, 0},
+  /*
+   ** .pp
+   ** When set along with ``$$edit_headers'', Mutt-ng will skip the initial
+   ** send-menu and allow you to immediately begin editing the body of your
+   ** message.  The send-menu may still be accessed once you have finished
+   ** editing the body of your message.
+   ** .pp
+   ** Also see ``$$fast_reply''.
+   */
+  {"auto_tag", DT_BOOL, R_NONE, OPTAUTOTAG, 0},
   /*
-  ** .pp
-  ** If set, Mutt-ng will use plain ASCII characters when displaying thread
-  ** and attachment trees, instead of the default \fIACS\fP characters.
-  */
-  { "askbcc",          DT_BOOL, R_NONE, OPTASKBCC, 0 },
+   ** .pp
+   ** When set, functions in the \fIindex\fP menu which affect a message
+   ** will be applied to all tagged messages (if there are any).  When
+   ** unset, you must first use the tag-prefix function (default: ";") to
+   ** make the next function apply to all tagged messages.
+   */
+  {"beep", DT_BOOL, R_NONE, OPTBEEP, 1},
   /*
-  ** .pp
-  ** If set, Mutt-ng will prompt you for blind-carbon-copy (Bcc) recipients
-  ** before editing an outgoing message.
-  */
-  { "askcc",           DT_BOOL, R_NONE, OPTASKCC, 0 },
+   ** .pp
+   ** When this variable is set, Mutt-ng will beep when an error occurs.
+   */
+  {"beep_new", DT_BOOL, R_NONE, OPTBEEPNEW, 0},
   /*
-  ** .pp
-  ** If set, Mutt-ng will prompt you for carbon-copy (Cc) recipients before
-  ** editing the body of an outgoing message.
-  */  
-  { "assumed_charset", DT_STR, R_NONE, UL &AssumedCharset, UL "us-ascii"},
+   ** .pp
+   ** When this variable is set, Mutt-ng will beep whenever it prints a message
+   ** notifying you of new mail.  This is independent of the setting of the
+   ** ``$$beep'' variable.
+   */
+  {"bounce", DT_QUAD, R_NONE, OPT_BOUNCE, M_ASKYES},
   /*
-  ** .pp
-  ** This variable is a colon-separated list of character encoding
-  ** schemes for messages without character encoding indication.
-  ** Header field values and message body content without character encoding
-  ** indication would be assumed that they are written in one of this list.
-  ** By default, all the header fields and message body without any charset
-  ** indication are assumed to be in "us-ascii".
-  ** .pp
-  ** For example, Japanese users might prefer this:
-  ** .pp
-  **   set assumed_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
-  ** .pp
-  ** However, only the first content is valid for the message body.
-  ** This variable is valid only if $$strict_mime is unset.
-  */
+   ** .pp
+   ** Controls whether you will be asked to confirm bouncing messages.
+   ** If set to \fIyes\fP you don't get asked if you want to bounce a
+   ** message. Setting this variable to \fIno\fP is not generally useful,
+   ** and thus not recommended, because you are unable to bounce messages.
+   */
+  {"bounce_delivered", DT_BOOL, R_NONE, OPTBOUNCEDELIVERED, 1},
+  /*
+   ** .pp
+   ** When this variable is set, Mutt-ng will include Delivered-To headers when
+   ** bouncing messages.  Postfix users may wish to unset this variable.
+   */
 #ifdef USE_NNTP
-  { "ask_follow_up",   DT_BOOL, R_NONE, OPTASKFOLLOWUP, 0 },
+  {"catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If this variable is \fIset\fP, Mutt-ng will mark all articles in newsgroup
+   ** as read when you quit the newsgroup (catchup newsgroup).
+   */
+#endif
+  {"charset", DT_STR, R_NONE, UL & Charset, UL 0},
   /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If set, Mutt-ng will prompt you for follow-up groups before editing
-  ** the body of an outgoing message.
-  */  
-  { "ask_x_comment_to",        DT_BOOL, R_NONE, OPTASKXCOMMENTTO, 0 },
+   ** .pp
+   ** Character set your terminal uses to display and enter textual data.
+   */
+  {"check_new", DT_BOOL, R_NONE, OPTCHECKNEW, 1},
+  /*
+   ** .pp
+   ** \fBNote:\fP this option only affects \fImaildir\fP and \fIMH\fP style
+   ** mailboxes.
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will check for new mail delivered while the
+   ** mailbox is open.  Especially with MH mailboxes, this operation can
+   ** take quite some time since it involves scanning the directory and
+   ** checking each file to see if it has already been looked at.  If
+   ** \fIcheck_new\fP is \fIunset\fP, no check for new mail is performed
+   ** while the mailbox is open.
+   */
+  {"collapse_unread", DT_BOOL, R_NONE, OPTCOLLAPSEUNREAD, 1},
   /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If set, Mutt-ng will prompt you for x-comment-to field before editing
-  ** the body of an outgoing message.
-  */  
-#endif
-  { "attach_format",   DT_STR,  R_NONE, UL &AttachFormat, UL "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] " },
+   ** .pp
+   ** When \fIunset\fP, Mutt-ng will not collapse a thread if it contains any
+   ** unread messages.
+   */
+  {"uncollapse_jump", DT_BOOL, R_NONE, OPTUNCOLLAPSEJUMP, 0},
   /*
-  ** .pp
-  ** This variable describes the format of the `attachment' menu.  The
-  ** following printf-style sequences are understood:
-  ** .pp
-  ** .dl
-  ** .dt %C  .dd charset
-  ** .dt %c  .dd requires charset conversion (n or c)
-  ** .dt %D  .dd deleted flag
-  ** .dt %d  .dd description
-  ** .dt %e  .dd MIME content-transfer-encoding
-  ** .dt %f  .dd filename
-  ** .dt %I  .dd disposition (I=inline, A=attachment)
-  ** .dt %m  .dd major MIME type
-  ** .dt %M  .dd MIME subtype
-  ** .dt %n  .dd attachment number
-  ** .dt %s  .dd size
-  ** .dt %t  .dd tagged flag
-  ** .dt %T  .dd graphic tree characters
-  ** .dt %u  .dd unlink (=to delete) flag
-  ** .dt %>X .dd right justify the rest of the string and pad with character "X"
-  ** .dt %|X .dd pad to the end of the line with character "X"
-  ** .de
-  */
-  { "attach_sep",      DT_STR,  R_NONE, UL &AttachSep, UL "\n" },
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will jump to the next unread message, if any,
+   ** when the current thread is \fIun\fPcollapsed.
+   */
+  {"compose_format", DT_STR, R_BOTH, UL & ComposeFormat,
+   UL "-- Mutt-ng: Compose  [Approx. msg size: %l   Atts: %a]%>-"},
+  /*
+   ** .pp
+   ** Controls the format of the status line displayed in the \fICompose\fP
+   ** menu.  This string is similar to ``$$status_format'', but has its own
+   ** set of printf()-like sequences:
+   ** .pp
+   ** .dl
+   ** .dt %a .dd total number of attachments 
+   ** .dt %h .dd local hostname
+   ** .dt %l .dd approximate size (in bytes) of the current message
+   ** .dt %v .dd Mutt-ng version string
+   ** .de
+   ** .pp
+   ** See the text describing the ``$$status_format'' option for more 
+   ** information on how to set ``$$compose_format''.
+   */
+  {"config_charset", DT_STR, R_NONE, UL & ConfigCharset, UL 0},
   /*
-  ** .pp
-  ** The separator to add between attachments when operating (saving,
-  ** printing, piping, etc) on a list of tagged attachments.
-  */
-  { "attach_split",    DT_BOOL, R_NONE, OPTATTACHSPLIT, 1 },
+   ** .pp
+   ** When defined, Mutt-ng will recode commands in rc files from this
+   ** encoding.
+   */
+  {"confirmappend", DT_BOOL, R_NONE, OPTCONFIRMAPPEND, 1},
   /*
-  ** .pp
-  ** If this variable is unset, when operating (saving, printing, piping,
-  ** etc) on a list of tagged attachments, Mutt-ng will concatenate the
-  ** attachments and will operate on them as a single attachment. The
-  ** ``$$attach_sep'' separator is added after each attachment. When set,
-  ** Mutt-ng will operate on the attachments one by one.
-  */
-  { "attribution",     DT_STR,  R_NONE, UL &Attribution, UL "On %d, %n wrote:" },
+   ** .pp
+   ** When set, Mutt-ng will prompt for confirmation when appending messages to
+   ** an existing mailbox.
+   */
+  {"confirmcreate", DT_BOOL, R_NONE, OPTCONFIRMCREATE, 1},
   /*
-  ** .pp
-  ** This is the string that will precede a message which has been included
-  ** in a reply.  For a full listing of defined printf()-like sequences see
-  ** the section on ``$$index_format''.
-  */
-  { "autoedit",                DT_BOOL, R_NONE, OPTAUTOEDIT, 0 },
+   ** .pp
+   ** When set, Mutt-ng will prompt for confirmation when saving messages to a
+   ** mailbox which does not yet exist before creating it.
+   */
+  {"connect_timeout", DT_NUM, R_NONE, UL & ConnectTimeout, 30},
   /*
-  ** .pp
-  ** When set along with ``$$edit_headers'', Mutt-ng will skip the initial
-  ** send-menu and allow you to immediately begin editing the body of your
-  ** message.  The send-menu may still be accessed once you have finished
-  ** editing the body of your message.
-  ** .pp
-  ** Also see ``$$fast_reply''.
-  */
-  { "auto_tag",                DT_BOOL, R_NONE, OPTAUTOTAG, 0 },
+   ** .pp
+   ** Causes Mutt-ng to timeout a network connection (for IMAP or POP) after this
+   ** many seconds if the connection is not able to be established.  A negative
+   ** value causes Mutt-ng to wait indefinitely for the connection to succeed.
+   */
+  {"content_type", DT_STR, R_NONE, UL & ContentType, UL "text/plain"},
   /*
-  ** .pp
-  ** When set, functions in the \fIindex\fP menu which affect a message
-  ** will be applied to all tagged messages (if there are any).  When
-  ** unset, you must first use the tag-prefix function (default: ";") to
-  ** make the next function apply to all tagged messages.
-  */
-  { "beep",            DT_BOOL, R_NONE, OPTBEEP, 1 },
+   ** .pp
+   ** Sets the default Content-Type for the body of newly composed messages.
+   */
+  {"copy", DT_QUAD, R_NONE, OPT_COPY, M_YES},
   /*
-  ** .pp
-  ** When this variable is set, Mutt-ng will beep when an error occurs.
-  */
-  { "beep_new",                DT_BOOL, R_NONE, OPTBEEPNEW, 0 },
+   ** .pp
+   ** This variable controls whether or not copies of your outgoing messages
+   ** will be saved for later references.  Also see ``$$record'',
+   ** ``$$save_name'', ``$$force_name'' and ``$fcc-hook''.
+   */
+
+  {"crypt_use_gpgme", DT_BOOL, R_NONE, OPTCRYPTUSEGPGME, 0},
+  /*
+   ** .pp
+   ** This variable controls the use the GPGME enabled crypto backends.
+   ** If it is set and Mutt-ng was build with gpgme support, the gpgme code for
+   ** S/MIME and PGP will be used instead of the classic code.  Note, that
+   ** you need to use this option in .muttrc as it won't have any effect when 
+   ** used interactively.
+   */
+
+  {"crypt_autopgp", DT_BOOL, R_NONE, OPTCRYPTAUTOPGP, 1},
   /*
-  ** .pp
-  ** When this variable is set, Mutt-ng will beep whenever it prints a message
-  ** notifying you of new mail.  This is independent of the setting of the
-  ** ``$$beep'' variable.
-  */
-  { "bounce",  DT_QUAD, R_NONE, OPT_BOUNCE, M_ASKYES },
+   ** .pp
+   ** This variable controls whether or not Mutt-ng may automatically enable
+   ** PGP encryption/signing for messages.  See also ``$$crypt_autoencrypt'',
+   ** ``$$crypt_replyencrypt'',
+   ** ``$$crypt_autosign'', ``$$crypt_replysign'' and ``$$smime_is_default''.
+   */
+  {"crypt_autosmime", DT_BOOL, R_NONE, OPTCRYPTAUTOSMIME, 1},
   /*
-  ** .pp
-  ** Controls whether you will be asked to confirm bouncing messages.
-  ** If set to \fIyes\fP you don't get asked if you want to bounce a
-  ** message. Setting this variable to \fIno\fP is not generally useful,
-  ** and thus not recommended, because you are unable to bounce messages.
-  */
-  { "bounce_delivered", DT_BOOL, R_NONE, OPTBOUNCEDELIVERED, 1 },
+   ** .pp
+   ** This variable controls whether or not Mutt-ng may automatically enable
+   ** S/MIME encryption/signing for messages. See also ``$$crypt_autoencrypt'',
+   ** ``$$crypt_replyencrypt'',
+   ** ``$$crypt_autosign'', ``$$crypt_replysign'' and ``$$smime_is_default''.
+   */
+  {"date_format", DT_STR, R_BOTH, UL & DateFmt,
+   UL "!%a, %b %d, %Y at %I:%M:%S%p %Z"},
+  /*
+   ** .pp
+   ** This variable controls the format of the date printed by the ``%d''
+   ** sequence in ``$$index_format''.  This is passed to the \fIstrftime\fP
+   ** call to process the date. See the man page for \fIstrftime(3)\fP for
+   ** the proper syntax.
+   ** .pp
+   ** Unless the first character in the string is a bang (``!''), the month
+   ** and week day names are expanded according to the locale specified in
+   ** the variable ``$$locale''. If the first character in the string is a
+   ** bang, the bang is discarded, and the month and week day names in the
+   ** rest of the string are expanded in the \fIC\fP locale (that is in US
+   ** English).
+   */
+  {"default_hook", DT_STR, R_NONE, UL & DefaultHook,
+   UL "~f %s !~P | (~P ~C %s)"},
+  /*
+   ** .pp
+   ** This variable controls how send-hooks, message-hooks, save-hooks,
+   ** and fcc-hooks will
+   ** be interpreted if they are specified with only a simple regexp,
+   ** instead of a matching pattern.  The hooks are expanded when they are
+   ** declared, so a hook will be interpreted according to the value of this
+   ** variable at the time the hook is declared.  The default value matches
+   ** if the message is either from a user matching the regular expression
+   ** given, or if it is from you (if the from address matches
+   ** ``alternates'') and is to or cc'ed to a user matching the given
+   ** regular expression.
+   */
+  {"delete", DT_QUAD, R_NONE, OPT_DELETE, M_ASKYES},
   /*
-  ** .pp
-  ** When this variable is set, Mutt-ng will include Delivered-To headers when
-  ** bouncing messages.  Postfix users may wish to unset this variable.
-  */
-#ifdef USE_NNTP
-  { "catchup_newsgroup", DT_QUAD, R_NONE, OPT_CATCHUP, M_ASKYES },
+   ** .pp
+   ** Controls whether or not messages are really deleted when closing or
+   ** synchronizing a mailbox.  If set to \fIyes\fP, messages marked for
+   ** deleting will automatically be purged without prompting.  If set to
+   ** \fIno\fP, messages marked for deletion will be kept in the mailbox.
+   */
+  {"delete_untag", DT_BOOL, R_NONE, OPTDELETEUNTAG, 1},
   /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If this variable is \fIset\fP, Mutt-ng will mark all articles in newsgroup
-  ** as read when you quit the newsgroup (catchup newsgroup).
-  */
-#endif
-  { "charset",         DT_STR,  R_NONE, UL &Charset, UL 0 },
+   ** .pp
+   ** If this option is \fIset\fP, Mutt-ng will untag messages when marking them
+   ** for deletion.  This applies when you either explicitly delete a message,
+   ** or when you save it to another folder.
+   */
+  {"digest_collapse", DT_BOOL, R_NONE, OPTDIGESTCOLLAPSE, 1},
   /*
-  ** .pp
-  ** Character set your terminal uses to display and enter textual data.
-  */
-  { "check_new",       DT_BOOL, R_NONE, OPTCHECKNEW, 1 },
+   ** .pp
+   ** If this option is \fIset\fP, Mutt-ng's received-attachments menu will not show the subparts of
+   ** individual messages in a multipart/digest.  To see these subparts, press 'v' on that menu.
+   */
+  {"display_filter", DT_PATH, R_PAGER, UL & DisplayFilter, UL ""},
   /*
-  ** .pp
-  ** \fBNote:\fP this option only affects \fImaildir\fP and \fIMH\fP style
-  ** mailboxes.
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will check for new mail delivered while the
-  ** mailbox is open.  Especially with MH mailboxes, this operation can
-  ** take quite some time since it involves scanning the directory and
-  ** checking each file to see if it has already been looked at.  If
-  ** \fIcheck_new\fP is \fIunset\fP, no check for new mail is performed
-  ** while the mailbox is open.
-  */
-  { "collapse_unread", DT_BOOL, R_NONE, OPTCOLLAPSEUNREAD, 1 },
+   ** .pp
+   ** When set, specifies a command used to filter messages.  When a message
+   ** is viewed it is passed as standard input to $$display_filter, and the
+   ** filtered message is read from the standard output.
+   */
+#if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
+  {"dotlock_program", DT_PATH, R_NONE, UL & MuttDotlock,
+   UL BINDIR "/muttng_dotlock"},
+  /*
+   ** .pp
+   ** Availability: Standalone and Dotlock
+   **
+   ** .pp
+   ** Contains the path of the muttng_dotlock (1) binary to be used by
+   ** Mutt-ng.
+   */
+#endif
+  {"dsn_notify", DT_STR, R_NONE, UL & DsnNotify, UL ""},
+  /*
+   ** .pp
+   ** \fBNote:\fP you should not enable this unless you are using Sendmail
+   ** 8.8.x or greater.
+   ** .pp
+   ** This variable sets the request for when notification is returned.  The
+   ** string consists of a comma separated list (no spaces!) of one or more
+   ** of the following: \fInever\fP, to never request notification,
+   ** \fIfailure\fP, to request notification on transmission failure,
+   ** \fIdelay\fP, to be notified of message delays, \fIsuccess\fP, to be
+   ** notified of successful transmission.
+   ** .pp
+   ** Example: set dsn_notify="failure,delay"
+   */
+  {"dsn_return", DT_STR, R_NONE, UL & DsnReturn, UL ""},
+  /*
+   ** .pp
+   ** \fBNote:\fP you should not enable this unless you are using Sendmail
+   ** 8.8.x or greater.
+   ** .pp
+   ** This variable controls how much of your message is returned in DSN
+   ** messages.  It may be set to either \fIhdrs\fP to return just the
+   ** message header, or \fIfull\fP to return the full message.
+   ** .pp
+   ** Example: set dsn_return=hdrs
+   */
+  {"duplicate_threads", DT_BOOL, R_RESORT | R_RESORT_INIT | R_INDEX,
+   OPTDUPTHREADS, 1},
+  /*
+   ** .pp
+   ** This variable controls whether Mutt-ng, when sorting by threads, threads
+   ** messages with the same message-id together.  If it is set, it will indicate
+   ** that it thinks they are duplicates of each other with an equals sign
+   ** in the thread diagram.
+   */
+  {"edit_headers", DT_BOOL, R_NONE, OPTEDITHDRS, 0},
   /*
-  ** .pp
-  ** When \fIunset\fP, Mutt-ng will not collapse a thread if it contains any
-  ** unread messages.
-  */
-  { "uncollapse_jump",         DT_BOOL, R_NONE, OPTUNCOLLAPSEJUMP, 0 },
+   ** .pp
+   ** This option allows you to edit the header of your outgoing messages
+   ** along with the body of your message.
+   */
+  {"edit_hdrs", DT_SYN, R_NONE, UL "edit_headers", 0},
   /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will jump to the next unread message, if any,
-  ** when the current thread is \fIun\fPcollapsed.
-  */
-  { "compose_format",  DT_STR,  R_BOTH, UL &ComposeFormat, UL "-- Mutt-ng: Compose  [Approx. msg size: %l   Atts: %a]%>-" },
+   */
+  {"editor", DT_PATH, R_NONE, UL & Editor, 0},
   /*
-  ** .pp
-  ** Controls the format of the status line displayed in the \fICompose\fP
-  ** menu.  This string is similar to ``$$status_format'', but has its own
-  ** set of printf()-like sequences:
-  ** .pp
-  ** .dl
-  ** .dt %a .dd total number of attachments 
-  ** .dt %h .dd local hostname
-  ** .dt %l .dd approximate size (in bytes) of the current message
-  ** .dt %v .dd Mutt-ng version string
-  ** .de
-  ** .pp
-  ** See the text describing the ``$$status_format'' option for more 
-  ** information on how to set ``$$compose_format''.
-  */
-  { "config_charset",  DT_STR,  R_NONE, UL &ConfigCharset, UL 0 },
+   ** .pp
+   ** This variable specifies which editor is used by Mutt-ng.
+   ** It defaults to the value of the VISUAL, or EDITOR, environment
+   ** variable, or to the string "vi" if neither of those are set.
+   */
+  {"encode_from", DT_BOOL, R_NONE, OPTENCODEFROM, 0},
   /*
-  ** .pp
-  ** When defined, Mutt-ng will recode commands in rc files from this
-  ** encoding.
-  */
-  { "confirmappend",   DT_BOOL, R_NONE, OPTCONFIRMAPPEND, 1 },
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will quoted-printable encode messages when
+   ** they contain the string "From " in the beginning of a line.
+   ** Useful to avoid the tampering certain mail delivery and transport
+   ** agents tend to do with messages.
+   */
+  {"envelope_from", DT_BOOL, R_NONE, OPTENVFROM, 0},
+  /*
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will try to derive the message's \fIenvelope\fP
+   ** sender from the "From:" header.  Note that this information is passed 
+   ** to sendmail command using the "-f" command line switch, so don't set this
+   ** option if you are using that switch in $$sendmail yourself,
+   ** or if the sendmail on your machine doesn't support that command
+   ** line switch.
+   */
+  {"escape", DT_STR, R_NONE, UL & EscChar, UL "~"},
   /*
-  ** .pp
-  ** When set, Mutt-ng will prompt for confirmation when appending messages to
-  ** an existing mailbox.
-  */
-  { "confirmcreate",   DT_BOOL, R_NONE, OPTCONFIRMCREATE, 1 },
+   ** .pp
+   ** Escape character to use for functions in the builtin editor.
+   */
+  {"fast_reply", DT_BOOL, R_NONE, OPTFASTREPLY, 0},
+  /*
+   ** .pp
+   ** When set, the initial prompt for recipients and subject are skipped
+   ** when replying to messages, and the initial prompt for subject is
+   ** skipped when forwarding messages.
+   ** .pp
+   ** \fBNote:\fP this variable has no effect when the ``$$autoedit''
+   ** variable is set.
+   */
+  {"fcc_attach", DT_BOOL, R_NONE, OPTFCCATTACH, 1},
   /*
-  ** .pp
-  ** When set, Mutt-ng will prompt for confirmation when saving messages to a
-  ** mailbox which does not yet exist before creating it.
-  */
-  { "connect_timeout", DT_NUM, R_NONE, UL &ConnectTimeout, 30 },
+   ** .pp
+   ** This variable controls whether or not attachments on outgoing messages
+   ** are saved along with the main body of your message.
+   */
+  {"fcc_clear", DT_BOOL, R_NONE, OPTFCCCLEAR, 0},
   /*
-  ** .pp
-  ** Causes Mutt-ng to timeout a network connection (for IMAP or POP) after this
-  ** many seconds if the connection is not able to be established.  A negative
-  ** value causes Mutt-ng to wait indefinitely for the connection to succeed.
-  */
-  { "content_type",    DT_STR, R_NONE, UL &ContentType, UL "text/plain" },
+   ** .pp
+   ** When this variable is set, FCCs will be stored unencrypted and
+   ** unsigned, even when the actual message is encrypted and/or
+   ** signed.
+   ** (PGP only)
+   */
+  {"file_charset", DT_STR, R_NONE, UL & FileCharset, UL 0},
+  /*
+   ** .pp
+   ** This variable is a colon-separated list of character encoding
+   ** schemes for text file attatchments.
+   ** If unset, $$charset value will be used instead.
+   ** For example, the following configuration would work for Japanese
+   ** text handling:
+   ** .pp
+   **   set file_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
+   ** .pp
+   ** Note: "iso-2022-*" must be put at the head of the value as shown above
+   ** if included.
+   */
+  {"folder", DT_PATH, R_NONE, UL & Maildir, UL "~/Mail"},
+  /*
+   ** .pp
+   ** Specifies the default location of your mailboxes.  A `+' or `=' at the
+   ** beginning of a pathname will be expanded to the value of this
+   ** variable.  Note that if you change this variable from the default
+   ** value you need to make sure that the assignment occurs \fIbefore\fP
+   ** you use `+' or `=' for any other variables since expansion takes place
+   ** during the `set' command.
+   */
+  {"folder_format", DT_STR, R_INDEX, UL & FolderFormat,
+   UL "%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %f"},
+  /*
+   ** .pp
+   ** This variable allows you to customize the file browser display to your
+   ** personal taste.  This string is similar to ``$$index_format'', but has
+   ** its own set of printf()-like sequences:
+   ** .pp
+   ** .dl
+   ** .dt %C  .dd current file number
+   ** .dt %d  .dd date/time folder was last modified
+   ** .dt %f  .dd filename
+   ** .dt %F  .dd file permissions
+   ** .dt %g  .dd group name (or numeric gid, if missing)
+   ** .dt %l  .dd number of hard links
+   ** .dt %N  .dd N if folder has new mail, blank otherwise
+   ** .dt %s  .dd size in bytes
+   ** .dt %t  .dd * if the file is tagged, blank otherwise
+   ** .dt %u  .dd owner name (or numeric uid, if missing)
+   ** .dt %>X .dd right justify the rest of the string and pad with character "X"
+   ** .dt %|X .dd pad to the end of the line with character "X"
+   ** .de
+   */
+  {"followup_to", DT_BOOL, R_NONE, OPTFOLLOWUPTO, 1},
+  /*
+   ** .pp
+   ** Controls whether or not the \fIMail-Followup-To\fP header field is
+   ** generated when sending mail.  When \fIset\fP, Mutt-ng will generate this
+   ** field when you are replying to a known mailing list, specified with
+   ** the ``subscribe'' or ``$lists'' commands.
+   ** .pp
+   ** This field has two purposes.  First, preventing you from
+   ** receiving duplicate copies of replies to messages which you send
+   ** to mailing lists, and second, ensuring that you do get a reply
+   ** separately for any messages sent to known lists to which you are
+   ** not subscribed.  The header will contain only the list's address
+   ** for subscribed lists, and both the list address and your own
+   ** email address for unsubscribed lists.  Without this header, a
+   ** group reply to your message sent to a subscribed list will be
+   ** sent to both the list and your address, resulting in two copies
+   ** of the same email for you.
+   */
+#ifdef USE_NNTP
+  {"followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If this variable is \fIset\fP and the keyword "poster" is present in
+   ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
+   ** permitted.  The message will be mailed to the submitter of the
+   ** message via mail.
+   */
+#endif
+  {"force_name", DT_BOOL, R_NONE, OPTFORCENAME, 0},
+  /*
+   ** .pp
+   ** This variable is similar to ``$$save_name'', except that Mutt-ng will
+   ** store a copy of your outgoing message by the username of the address
+   ** you are sending to even if that mailbox does not exist.
+   ** .pp
+   ** Also see the ``$$record'' variable.
+   */
+  {"force_buffy_check", DT_BOOL, R_NONE, OPTFORCEBUFFYCHECK, 0},
+  /*
+   ** .pp
+   ** When \fIset\fP, it causes Mutt-ng to check for new mail when the
+   ** \fIbuffy-list\fP command is invoked. When \fIunset\fP, \fIbuffy_list\fP
+   ** will just list all mailboxes which are already known to have new mail.
+   ** .pp
+   ** Also see the following variables: ``$$timeout'', ``$$mail_check'' and
+   ** ``$$imap_mail_check''.
+   */
+  {"forward_decode", DT_BOOL, R_NONE, OPTFORWDECODE, 1},
   /*
-  ** .pp
-  ** Sets the default Content-Type for the body of newly composed messages.
-  */
-  { "copy",            DT_QUAD, R_NONE, OPT_COPY, M_YES },
+   ** .pp
+   ** Controls the decoding of complex MIME messages into text/plain when
+   ** forwarding a message.  The message header is also RFC2047 decoded.
+   ** This variable is only used, if ``$$mime_forward'' is \fIunset\fP,
+   ** otherwise ``$$mime_forward_decode'' is used instead.
+   */
+  {"forw_decode", DT_SYN, R_NONE, UL "forward_decode", 0},
   /*
-  ** .pp
-  ** This variable controls whether or not copies of your outgoing messages
-  ** will be saved for later references.  Also see ``$$record'',
-  ** ``$$save_name'', ``$$force_name'' and ``$fcc-hook''.
-  */
-  
-  { "crypt_use_gpgme",  DT_BOOL, R_NONE, OPTCRYPTUSEGPGME, 0 },
+   */
+  {"forward_edit", DT_QUAD, R_NONE, OPT_FORWEDIT, M_YES},
   /*
-  ** .pp
-  ** This variable controls the use the GPGME enabled crypto backends.
-  ** If it is set and Mutt-ng was build with gpgme support, the gpgme code for
-  ** S/MIME and PGP will be used instead of the classic code.  Note, that
-  ** you need to use this option in .muttrc as it won't have any effect when 
-  ** used interactively.
-  */
-  
-  { "crypt_autopgp",   DT_BOOL, R_NONE, OPTCRYPTAUTOPGP, 1 },
+   ** .pp
+   ** This quadoption controls whether or not the user is automatically
+   ** placed in the editor when forwarding messages.  For those who always want
+   ** to forward with no modification, use a setting of ``no''.
+   */
+  {"forward_format", DT_STR, R_NONE, UL & ForwFmt, UL "[%a: %s]"},
   /*
-  ** .pp
-  ** This variable controls whether or not Mutt-ng may automatically enable
-  ** PGP encryption/signing for messages.  See also ``$$crypt_autoencrypt'',
-  ** ``$$crypt_replyencrypt'',
-  ** ``$$crypt_autosign'', ``$$crypt_replysign'' and ``$$smime_is_default''.
-  */
-  { "crypt_autosmime", DT_BOOL, R_NONE, OPTCRYPTAUTOSMIME, 1 },
+   ** .pp
+   ** This variable controls the default subject when forwarding a message.
+   ** It uses the same format sequences as the ``$$index_format'' variable.
+   */
+  {"forw_format", DT_SYN, R_NONE, UL "forward_format", 0},
   /*
-  ** .pp
-  ** This variable controls whether or not Mutt-ng may automatically enable
-  ** S/MIME encryption/signing for messages. See also ``$$crypt_autoencrypt'',
-  ** ``$$crypt_replyencrypt'',
-  ** ``$$crypt_autosign'', ``$$crypt_replysign'' and ``$$smime_is_default''.
-  */
-  { "date_format",     DT_STR,  R_BOTH, UL &DateFmt, UL "!%a, %b %d, %Y at %I:%M:%S%p %Z" },
+   */
+  {"forward_quote", DT_BOOL, R_NONE, OPTFORWQUOTE, 0},
   /*
-  ** .pp
-  ** This variable controls the format of the date printed by the ``%d''
-  ** sequence in ``$$index_format''.  This is passed to the \fIstrftime\fP
-  ** call to process the date. See the man page for \fIstrftime(3)\fP for
-  ** the proper syntax.
-  ** .pp
-  ** Unless the first character in the string is a bang (``!''), the month
-  ** and week day names are expanded according to the locale specified in
-  ** the variable ``$$locale''. If the first character in the string is a
-  ** bang, the bang is discarded, and the month and week day names in the
-  ** rest of the string are expanded in the \fIC\fP locale (that is in US
-  ** English).
-  */  
-  { "default_hook",    DT_STR,  R_NONE, UL &DefaultHook, UL "~f %s !~P | (~P ~C %s)" },
+   ** .pp
+   ** When \fIset\fP forwarded messages included in the main body of the
+   ** message (when ``$$mime_forward'' is \fIunset\fP) will be quoted using
+   ** ``$$indent_string''.
+   */
+  {"forw_quote", DT_SYN, R_NONE, UL "forward_quote", 0},
   /*
-  ** .pp
-  ** This variable controls how send-hooks, message-hooks, save-hooks,
-  ** and fcc-hooks will
-  ** be interpreted if they are specified with only a simple regexp,
-  ** instead of a matching pattern.  The hooks are expanded when they are
-  ** declared, so a hook will be interpreted according to the value of this
-  ** variable at the time the hook is declared.  The default value matches
-  ** if the message is either from a user matching the regular expression
-  ** given, or if it is from you (if the from address matches
-  ** ``alternates'') and is to or cc'ed to a user matching the given
-  ** regular expression.
-  */
-  { "delete",          DT_QUAD, R_NONE, OPT_DELETE, M_ASKYES },
+   */
+  {"from", DT_ADDR, R_NONE, UL & From, UL 0},
+  /*
+   ** .pp
+   ** This variable contains a default from address.  It
+   ** can be overridden using my_hdr (including from send-hooks) and
+   ** ``$$reverse_name''.  This variable is ignored if ``$$use_from''
+   ** is unset.
+   ** E.g. you can use 
+   ** send-hook Mutt-ng-devel@lists.berlios.de 'my_hdr From: Foo Bar <foo@bar.fb>'
+   ** when replying to Mutt-ng-devel and Mutt-ng takes this email address.
+   ** .pp
+   ** Defaults to the contents of the environment variable EMAIL.
+   */
+  {"gecos_mask", DT_RX, R_NONE, UL & GecosMask, UL "^[^,]*"},
+  /*
+   ** .pp
+   ** A regular expression used by Mutt-ng to parse the GECOS field of a password
+   ** entry when expanding the alias.  By default the regular expression is set
+   ** to "^[^,]*" which will return the string up to the first "," encountered.
+   ** If the GECOS field contains a string like "lastname, firstname" then you
+   ** should set the gecos_mask=".*".
+   ** .pp
+   ** This can be useful if you see the following behavior: you address a e-mail
+   ** to user ID stevef whose full name is Steve Franklin.  If Mutt-ng expands 
+   ** stevef to "Franklin" stevef@foo.bar then you should set the gecos_mask to
+   ** a regular expression that will match the whole name so Mutt-ng will expand
+   ** "Franklin" to "Franklin, Steve".
+   */
+#ifdef USE_NNTP
+  {"group_index_format", DT_STR, R_BOTH, UL & GroupFormat,
+   UL "%4C %M%N %5s  %-45.45f %d"},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** This variable allows you to customize the newsgroup browser display to
+   ** your personal taste.  This string is similar to ``$index_format'', but
+   ** has its own set of printf()-like sequences:
+   ** .pp
+   ** .ts
+   ** %C      current newsgroup number
+   ** %d      description of newsgroup (becomes from server)
+   ** %f      newsgroup name
+   ** %M      - if newsgroup not allowed for direct post (moderated for example)
+   ** %N      N if newsgroup is new, u if unsubscribed, blank otherwise
+   ** %n      number of new articles in newsgroup
+   ** %s      number of unread articles in newsgroup
+   ** %>X     right justify the rest of the string and pad with character "X"
+   ** %|X     pad to the end of the line with character "X"
+   ** .te
+   */
+#endif
+  {"hdr_format", DT_SYN, R_NONE, UL "index_format", 0},
   /*
-  ** .pp
-  ** Controls whether or not messages are really deleted when closing or
-  ** synchronizing a mailbox.  If set to \fIyes\fP, messages marked for
-  ** deleting will automatically be purged without prompting.  If set to
-  ** \fIno\fP, messages marked for deletion will be kept in the mailbox.
-  */
-  { "delete_untag",    DT_BOOL, R_NONE, OPTDELETEUNTAG, 1 },
+   */
+  {"hdrs", DT_BOOL, R_NONE, OPTHDRS, 1},
   /*
-  ** .pp
-  ** If this option is \fIset\fP, Mutt-ng will untag messages when marking them
-  ** for deletion.  This applies when you either explicitly delete a message,
-  ** or when you save it to another folder.
-  */
-  { "digest_collapse", DT_BOOL, R_NONE, OPTDIGESTCOLLAPSE, 1},
+   ** .pp
+   ** When unset, the header fields normally added by the ``$my_hdr''
+   ** command are not created.  This variable \fImust\fP be unset before
+   ** composing a new message or replying in order to take effect.  If set,
+   ** the user defined header fields are added to every new message.
+   */
+  {"header", DT_BOOL, R_NONE, OPTHEADER, 0},
   /*
-  ** .pp
-  ** If this option is \fIset\fP, Mutt-ng's received-attachments menu will not show the subparts of
-  ** individual messages in a multipart/digest.  To see these subparts, press 'v' on that menu.
-  */
-  { "display_filter",  DT_PATH, R_PAGER, UL &DisplayFilter, UL "" },
+   ** .pp
+   ** When set, this variable causes Mutt-ng to include the header
+   ** of the message you are replying to into the edit buffer.
+   ** The ``$$weed'' setting applies.
+   */
+  {"help", DT_BOOL, R_BOTH, OPTHELP, 1},
+  /*
+   ** .pp
+   ** When set, help lines describing the bindings for the major functions
+   ** provided by each menu are displayed on the first line of the screen.
+   ** .pp
+   ** \fBNote:\fP The binding will not be displayed correctly if the
+   ** function is bound to a sequence rather than a single keystroke.  Also,
+   ** the help line may not be updated if a binding is changed while Mutt-ng is
+   ** running.  Since this variable is primarily aimed at new users, neither
+   ** of these should present a major problem.
+   */
+  {"hidden_host", DT_BOOL, R_NONE, OPTHIDDENHOST, 0},
   /*
-  ** .pp
-  ** When set, specifies a command used to filter messages.  When a message
-  ** is viewed it is passed as standard input to $$display_filter, and the
-  ** filtered message is read from the standard output.
-  */
-#if defined(DL_STANDALONE) && defined(USE_DOTLOCK)
-  { "dotlock_program",  DT_PATH, R_NONE, UL &MuttDotlock, UL BINDIR "/muttng_dotlock" },
+   ** .pp
+   ** When set, Mutt-ng will skip the host name part of ``$$hostname'' variable
+   ** when adding the domain part to addresses.  This variable does not
+   ** affect the generation of Message-IDs, and it will not lead to the 
+   ** cut-off of first-level domains.
+   */
+  {"hide_limited", DT_BOOL, R_TREE | R_INDEX, OPTHIDELIMITED, 0},
   /*
-  ** .pp
-  ** Availability: Standalone and Dotlock
-  **
-  ** .pp
-  ** Contains the path of the muttng_dotlock (1) binary to be used by
-  ** Mutt-ng.
-  */
-#endif
-  { "dsn_notify",      DT_STR,  R_NONE, UL &DsnNotify, UL "" },
+   ** .pp
+   ** When set, Mutt-ng will not show the presence of messages that are hidden
+   ** by limiting, in the thread tree.
+   */
+  {"hide_missing", DT_BOOL, R_TREE | R_INDEX, OPTHIDEMISSING, 1},
   /*
-  ** .pp
-  ** \fBNote:\fP you should not enable this unless you are using Sendmail
-  ** 8.8.x or greater.
-  ** .pp
-  ** This variable sets the request for when notification is returned.  The
-  ** string consists of a comma separated list (no spaces!) of one or more
-  ** of the following: \fInever\fP, to never request notification,
-  ** \fIfailure\fP, to request notification on transmission failure,
-  ** \fIdelay\fP, to be notified of message delays, \fIsuccess\fP, to be
-  ** notified of successful transmission.
-  ** .pp
-  ** Example: set dsn_notify="failure,delay"
-  */
-  { "dsn_return",      DT_STR,  R_NONE, UL &DsnReturn, UL "" },
+   ** .pp
+   ** When set, Mutt-ng will not show the presence of missing messages in the
+   ** thread tree.
+   */
+  {"hide_thread_subject", DT_BOOL, R_TREE | R_INDEX, OPTHIDETHREADSUBJECT, 1},
   /*
-  ** .pp
-  ** \fBNote:\fP you should not enable this unless you are using Sendmail
-  ** 8.8.x or greater.
-  ** .pp
-  ** This variable controls how much of your message is returned in DSN
-  ** messages.  It may be set to either \fIhdrs\fP to return just the
-  ** message header, or \fIfull\fP to return the full message.
-  ** .pp
-  ** Example: set dsn_return=hdrs
-  */
-  { "duplicate_threads",       DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTDUPTHREADS, 1 },
+   ** .pp
+   ** When set, Mutt-ng will not show the subject of messages in the thread
+   ** tree that have the same subject as their parent or closest previously
+   ** displayed sibling.
+   */
+  {"hide_top_limited", DT_BOOL, R_TREE | R_INDEX, OPTHIDETOPLIMITED, 0},
   /*
-  ** .pp
-  ** This variable controls whether Mutt-ng, when sorting by threads, threads
-  ** messages with the same message-id together.  If it is set, it will indicate
-  ** that it thinks they are duplicates of each other with an equals sign
-  ** in the thread diagram.
-  */
-  { "edit_headers",    DT_BOOL, R_NONE, OPTEDITHDRS, 0 },
+   ** .pp
+   ** When set, Mutt-ng will not show the presence of messages that are hidden
+   ** by limiting, at the top of threads in the thread tree.  Note that when
+   ** $$hide_missing is set, this option will have no effect.
+   */
+  {"hide_top_missing", DT_BOOL, R_TREE | R_INDEX, OPTHIDETOPMISSING, 1},
   /*
-  ** .pp
-  ** This option allows you to edit the header of your outgoing messages
-  ** along with the body of your message.
-  */
-  { "edit_hdrs",       DT_SYN,  R_NONE, UL "edit_headers", 0 },
+   ** .pp
+   ** When set, Mutt-ng will not show the presence of missing messages at the
+   ** top of threads in the thread tree.  Note that when $$hide_limited is
+   ** set, this option will have no effect.
+   */
+  {"history", DT_NUM, R_NONE, UL & HistSize, 10},
   /*
-  */  
-  { "editor",          DT_PATH, R_NONE, UL &Editor, 0 },
+   ** .pp
+   ** This variable controls the size (in number of strings remembered) of
+   ** the string history buffer. The buffer is cleared each time the
+   ** variable is set.
+   */
+  {"honor_followup_to", DT_QUAD, R_NONE, OPT_MFUPTO, M_YES},
   /*
-  ** .pp
-  ** This variable specifies which editor is used by Mutt-ng.
-  ** It defaults to the value of the VISUAL, or EDITOR, environment
-  ** variable, or to the string "vi" if neither of those are set.
-  */
-  { "encode_from",     DT_BOOL, R_NONE, OPTENCODEFROM, 0 },
+   ** .pp
+   ** This variable controls whether or not a Mail-Followup-To header is
+   ** honored when group-replying to a message.
+   */
+  {"hostname", DT_STR, R_NONE, UL & Fqdn, 0},
   /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will quoted-printable encode messages when
-  ** they contain the string "From " in the beginning of a line.
-  ** Useful to avoid the tampering certain mail delivery and transport
-  ** agents tend to do with messages.
-  */
-  { "envelope_from",   DT_BOOL, R_NONE, OPTENVFROM, 0 },
+   ** .pp
+   ** Specifies the hostname to use after the ``@'' in local e-mail
+   ** addresses.  This overrides the compile time definition obtained from
+   ** /etc/resolv.conf.
+   */
+  {"ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0},
+  /*
+   ** .pp
+   ** Affects the behaviour of the \fIreply\fP function when replying to
+   ** messages from mailing lists.  When set, if the ``Reply-To:'' field is
+   ** set to the same value as the ``To:'' field, Mutt-ng assumes that the
+   ** ``Reply-To:'' field was set by the mailing list to automate responses
+   ** to the list, and will ignore this field.  To direct a response to the
+   ** mailing list when this option is set, use the \fIlist-reply\fP
+   ** function; \fIgroup-reply\fP will reply to both the sender and the
+   ** list.
+   */
+#ifdef USE_IMAP
+  {"imap_authenticators", DT_STR, R_NONE, UL & ImapAuthenticators, UL 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** This is a colon-delimited list of authentication methods Mutt-ng may
+   ** attempt to use to log in to an IMAP server, in the order Mutt-ng should
+   ** try them.  Authentication methods are either 'login' or the right
+   ** side of an IMAP 'AUTH=xxx' capability string, eg 'digest-md5', 'gssapi'
+   ** or 'cram-md5'. This parameter is case-insensitive. If this
+   ** parameter is unset (the default) Mutt-ng will try all available methods,
+   ** in order from most-secure to least-secure.
+   ** .pp
+   ** Example: set imap_authenticators="gssapi:cram-md5:login"
+   ** .pp
+   ** \fBNote:\fP Mutt-ng will only fall back to other authentication methods if
+   ** the previous methods are unavailable. If a method is available but
+   ** authentication fails, Mutt-ng will not connect to the IMAP server.
+   */
+  {"imap_delim_chars", DT_STR, R_NONE, UL & ImapDelimChars, UL "/."},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** This contains the list of characters which you would like to treat
+   ** as folder separators for displaying IMAP paths. In particular it
+   ** helps in using the '=' shortcut for your \fIfolder\fP variable.
+   */
+# if defined(USE_SSL) || defined(USE_GNUTLS)
+  {"imap_force_ssl", DT_BOOL, R_NONE, OPTIMAPFORCESSL, 0},
+  /*
+   ** .pp
+   ** Availability: IMAP and SSL or IMAP and GNUTLS
+   **
+   ** .pp
+   ** If this variable is set, Mutt-ng will always use SSL when
+   ** connecting to IMAP servers.
+   */
+# endif
+  {"imap_headers", DT_STR, R_INDEX, UL & ImapHeaders, UL 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** Mutt-ng requests these header fields in addition to the default headers
+   ** ("DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE
+   ** CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES X-LABEL") from IMAP
+   ** servers before displaying the index menu. You may want to add more
+   ** headers for spam detection. \fBNote:\fP This is a space separated list.
+   */
+  {"imap_home_namespace", DT_STR, R_NONE, UL & ImapHomeNamespace, UL 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** You normally want to see your personal folders alongside
+   ** your INBOX in the IMAP browser. If you see something else, you may set
+   ** this variable to the IMAP path to your folders.
+   */
+  {"imap_keepalive", DT_NUM, R_NONE, UL & ImapKeepalive, 900},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** This variable specifies the maximum amount of time in seconds that Mutt-ng
+   ** will wait before polling open IMAP connections, to prevent the server
+   ** from closing them before Mutt-ng has finished with them. The default is
+   ** well within the RFC-specified minimum amount of time (30 minutes) before
+   ** a server is allowed to do this, but in practice the RFC does get
+   ** violated every now and then. Reduce this number if you find yourself
+   ** getting disconnected from your IMAP server due to inactivity.
+   */
+  {"imap_list_subscribed", DT_BOOL, R_NONE, OPTIMAPLSUB, 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** This variable configures whether IMAP folder browsing will look for
+   ** only subscribed folders or all folders.  This can be toggled in the
+   ** IMAP browser with the \fItoggle-subscribed\fP function.
+   */
+  {"imap_mail_check", DT_NUM, R_NONE, UL & ImapBuffyTimeout, 5},
+  /*
+   ** .pp
+   ** This variable configures how often (in seconds) Mutt-ng should look for
+   ** new mail in IMAP folders. This is split from the ``$mail_check'' variable
+   ** to generate less traffic and get more accurate information for local folders.
+   ** .pp
+   ** It defaults to the default value of ``$mail_check'' which is 5 seconds. But
+   ** you may want to increase it.
+   */
+  {"imap_pass", DT_STR, R_NONE, UL & ImapPass, UL 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** Specifies the password for your IMAP account.  If unset, Mutt-ng will
+   ** prompt you for your password when you invoke the fetch-mail function.
+   ** \fBWarning\fP: you should only use this option when you are on a
+   ** fairly secure machine, because the superuser can read your muttngrc even
+   ** if you are the only one who can read the file.
+   */
+  {"imap_passive", DT_BOOL, R_NONE, OPTIMAPPASSIVE, 1},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** When set, Mutt-ng will not open new IMAP connections to check for new
+   ** mail.  Mutt-ng will only check for new mail over existing IMAP
+   ** connections.  This is useful if you don't want to be prompted to
+   ** user/password pairs on Mutt-ng invocation, or if opening the connection
+   ** is slow.
+   */
+  {"imap_peek", DT_BOOL, R_NONE, OPTIMAPPEEK, 1},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** If set, Mutt-ng will avoid implicitly marking your mail as read whenever
+   ** you fetch a message from the server. This is generally a good thing,
+   ** but can make closing an IMAP folder somewhat slower. This option
+   ** exists to appease speed freaks.
+   */
+  {"imap_reconnect", DT_QUAD, R_NONE, OPT_IMAPRECONNECT, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** Controls whether or not Mutt-ng will try to reconnect to IMAP server when
+   ** the connection is lost.
+   */
+  {"imap_servernoise", DT_BOOL, R_NONE, OPTIMAPSERVERNOISE, 1},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** When set, Mutt-ng will display warning messages from the IMAP
+   ** server as error messages. Since these messages are often
+   ** harmless, or generated due to configuration problems on the
+   ** server which are out of the users' hands, you may wish to suppress
+   ** them at some point.
+   */
+  {"imap_user", DT_STR, R_NONE, UL & ImapUser, UL 0},
+  /*
+   ** .pp
+   ** Availability: IMAP
+   **
+   ** .pp
+   ** Your login name on the IMAP server.
+   ** .pp
+   ** This variable defaults to your user name on the local machine.
+   */
+#endif
+  {"implicit_autoview", DT_BOOL, R_NONE, OPTIMPLICITAUTOVIEW, 0},
+  /*
+   ** .pp
+   ** If set to ``yes'', Mutt-ng will look for a mailcap entry with the
+   ** copiousoutput flag set for \fIevery\fP MIME attachment it doesn't have
+   ** an internal viewer defined for.  If such an entry is found, Mutt-ng will
+   ** use the viewer defined in that entry to convert the body part to text
+   ** form.
+   */
+  {"include", DT_QUAD, R_NONE, OPT_INCLUDE, M_ASKYES},
   /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will try to derive the message's \fIenvelope\fP
-  ** sender from the "From:" header.  Note that this information is passed 
-  ** to sendmail command using the "-f" command line switch, so don't set this
-  ** option if you are using that switch in $$sendmail yourself,
-  ** or if the sendmail on your machine doesn't support that command
-  ** line switch.
-  */
-  { "escape",          DT_STR,  R_NONE, UL &EscChar, UL "~" },
+   ** .pp
+   ** Controls whether or not a copy of the message(s) you are replying to
+   ** is included in your reply.
+   */
+  {"include_onlyfirst", DT_BOOL, R_NONE, OPTINCLUDEONLYFIRST, 0},
   /*
-  ** .pp
-  ** Escape character to use for functions in the builtin editor.
-  */
-  { "fast_reply",      DT_BOOL, R_NONE, OPTFASTREPLY, 0 },
+   ** .pp
+   ** Controls whether or not Mutt-ng includes only the first attachment
+   ** of the message you are replying.
+   */
+  {"indent_string", DT_STR, R_NONE, UL & Prefix, UL "> "},
   /*
-  ** .pp
-  ** When set, the initial prompt for recipients and subject are skipped
-  ** when replying to messages, and the initial prompt for subject is
-  ** skipped when forwarding messages.
-  ** .pp
-  ** \fBNote:\fP this variable has no effect when the ``$$autoedit''
-  ** variable is set.
-  */
-  { "fcc_attach",      DT_BOOL, R_NONE, OPTFCCATTACH, 1 },
+   ** .pp
+   ** Specifies the string to prepend to each line of text quoted in a
+   ** message to which you are replying.  You are strongly encouraged not to
+   ** change this value, as it tends to agitate the more fanatical netizens.
+   */
+  {"indent_str", DT_SYN, R_NONE, UL "indent_string", 0},
   /*
-  ** .pp
-  ** This variable controls whether or not attachments on outgoing messages
-  ** are saved along with the main body of your message.
-  */
-  { "fcc_clear",       DT_BOOL, R_NONE, OPTFCCCLEAR, 0 },
+   */
+  {"index_format", DT_STR, R_BOTH, UL & HdrFmt,
+   UL "%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s"},
+  /*
+   ** .pp
+   ** This variable allows you to customize the message index display to
+   ** your personal taste.
+   ** .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-ng:
+   ** .pp
+   ** .dl
+   ** .dt %a .dd address of the author
+   ** .dt %A .dd reply-to address (if present; otherwise: address of author)
+   ** .dt %b .dd filename of the original message folder (think mailBox)
+   ** .dt %B .dd the list to which the letter was sent, or else the folder name (%b).
+   ** .dt %c .dd number of characters (bytes) in the message
+   ** .dt %C .dd current message number
+   ** .dt %d .dd date and time of the message in the format specified by
+   **            ``date_format'' converted to sender's time zone
+   ** .dt %D .dd date and time of the message in the format specified by
+   **            ``date_format'' converted to the local time zone
+   ** .dt %e .dd current message number in thread
+   ** .dt %E .dd number of messages in current thread
+   ** .dt %f .dd entire From: line (address + real name)
+   ** .dt %F .dd author name, or recipient name if the message is from you
+   ** .dt %H .dd spam attribute(s) of this message
+   ** .dt %g .dd newsgroup name (if compiled with nntp support)
+   ** .dt %i .dd message-id of the current message
+   ** .dt %l .dd number of lines in the message (does not work with maildir,
+   **            mh, and possibly IMAP folders)
+   ** .dt %L .dd If an address in the To or CC header field matches an address
+   **            defined by the users ``subscribe'' command, this displays
+   **            "To <list-name>", otherwise the same as %F.
+   ** .dt %m .dd total number of message in the mailbox
+   ** .dt %M .dd number of hidden messages if the thread is collapsed.
+   ** .dt %N .dd message score
+   ** .dt %n .dd author's real name (or address if missing)
+   ** .dt %O .dd (_O_riginal save folder)  Where Mutt-ng would formerly have
+   **            stashed the message: list name or recipient name if no list
+   ** .dt %s .dd subject of the message
+   ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
+   ** .dt %t .dd `to:' field (recipients)
+   ** .dt %T .dd the appropriate character from the $$to_chars string
+   ** .dt %u .dd user (login) name of the author
+   ** .dt %v .dd first name of the author, or the recipient if the message is from you
+   ** .dt %W .dd name of organization of author (`organization:' field)
+   ** .dt %y .dd `x-label:' field, if present
+   ** .dt %Y .dd `x-label' field, if present, and (1) not at part of a thread tree,
+   **            (2) at the top of a thread, or (3) `x-label' is different from
+   **            preceding message's `x-label'.
+   ** .dt %Z .dd message status flags
+   ** .dt %{fmt} .dd the date and time of the message is converted to sender's
+   **                time zone, and ``fmt'' is expanded by the library function
+   **                ``strftime''; a leading bang disables locales
+   ** .dt %[fmt] .dd the date and time of the message is converted to the local
+   **                time zone, and ``fmt'' is expanded by the library function
+   **                ``strftime''; a leading bang disables locales
+   ** .dt %(fmt) .dd the local date and time when the message was received.
+   **                ``fmt'' is expanded by the library function ``strftime'';
+   **                a leading bang disables locales
+   ** .dt %<fmt> .dd the current local time. ``fmt'' is expanded by the library
+   **                function ``strftime''; a leading bang disables locales.
+   ** .dt %>X    .dd right justify the rest of the string and pad with character "X"
+   ** .dt %|X    .dd pad to the end of the line with character "X"
+   ** .de
+   ** .pp
+   ** See also: ``$$to_chars''.
+   */
+#ifdef USE_NNTP
+  {"inews", DT_PATH, R_NONE, UL & Inews, UL ""},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If set, specifies the program and arguments used to deliver news posted
+   ** by Mutt-ng.  Otherwise, Mutt-ng posts article using current connection to
+   ** news server.  The following printf-style sequence is understood:
+   ** .pp
+   ** .ts
+   ** %s      newsserver name
+   ** .te
+   ** .pp
+   ** Example: set inews="/usr/local/bin/inews -hS"
+   */
+#endif
+  {"ispell", DT_PATH, R_NONE, UL & Ispell, UL ISPELL},
   /*
-  ** .pp
-  ** When this variable is set, FCCs will be stored unencrypted and
-  ** unsigned, even when the actual message is encrypted and/or
-  ** signed.
-  ** (PGP only)
-  */
-  { "file_charset",    DT_STR,  R_NONE, UL &FileCharset, UL 0 },
+   ** .pp
+   ** How to invoke ispell (GNU's spell-checking software).
+   */
+  {"keep_flagged", DT_BOOL, R_NONE, OPTKEEPFLAGGED, 0},
   /*
-  ** .pp
-  ** This variable is a colon-separated list of character encoding
-  ** schemes for text file attatchments.
-  ** If unset, $$charset value will be used instead.
-  ** For example, the following configuration would work for Japanese
-  ** text handling:
-  ** .pp
-  **   set file_charset="iso-2022-jp:euc-jp:shift_jis:utf-8"
-  ** .pp
-  ** Note: "iso-2022-*" must be put at the head of the value as shown above
-  ** if included.
-  */
-  { "folder",          DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
+   ** .pp
+   ** If set, read messages marked as flagged will not be moved
+   ** from your spool mailbox to your ``$$mbox'' mailbox, or as a result of
+   ** a ``$mbox-hook'' command.
+   */
+  {"locale", DT_STR, R_BOTH, UL & Locale, UL "C"},
   /*
-  ** .pp
-  ** Specifies the default location of your mailboxes.  A `+' or `=' at the
-  ** beginning of a pathname will be expanded to the value of this
-  ** variable.  Note that if you change this variable from the default
-  ** value you need to make sure that the assignment occurs \fIbefore\fP
-  ** you use `+' or `=' for any other variables since expansion takes place
-  ** during the `set' command.
-  */
-  { "folder_format",   DT_STR,  R_INDEX, UL &FolderFormat, UL "%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %f" },
+   ** .pp
+   ** The locale used by \fIstrftime(3)\fP to format dates. Legal values are
+   ** the strings your system accepts for the locale variable \fILC_TIME\fP.
+   */
+  {"list_reply", DT_QUAD, R_NONE, OPT_LISTREPLY, M_NO},
   /*
-  ** .pp
-  ** This variable allows you to customize the file browser display to your
-  ** personal taste.  This string is similar to ``$$index_format'', but has
-  ** its own set of printf()-like sequences:
-  ** .pp
-  ** .dl
-  ** .dt %C  .dd current file number
-  ** .dt %d  .dd date/time folder was last modified
-  ** .dt %f  .dd filename
-  ** .dt %F  .dd file permissions
-  ** .dt %g  .dd group name (or numeric gid, if missing)
-  ** .dt %l  .dd number of hard links
-  ** .dt %N  .dd N if folder has new mail, blank otherwise
-  ** .dt %s  .dd size in bytes
-  ** .dt %t  .dd * if the file is tagged, blank otherwise
-  ** .dt %u  .dd owner name (or numeric uid, if missing)
-  ** .dt %>X .dd right justify the rest of the string and pad with character "X"
-  ** .dt %|X .dd pad to the end of the line with character "X"
-  ** .de
-  */
-  { "followup_to",     DT_BOOL, R_NONE, OPTFOLLOWUPTO, 1 },
+   ** .pp
+   ** When set, address replies to the mailing list the original message came
+   ** from (instead to the author only). Setting this option to ``ask-yes'' or
+   ** ``ask-no'' will ask if you really intended to reply to the author only.
+   */
+  {"max_line_length", DT_NUM, R_NONE, UL & MaxLineLength, 0},
   /*
-  ** .pp
-  ** Controls whether or not the \fIMail-Followup-To\fP header field is
-  ** generated when sending mail.  When \fIset\fP, Mutt-ng will generate this
-  ** field when you are replying to a known mailing list, specified with
-  ** the ``subscribe'' or ``$lists'' commands.
-  ** .pp
-  ** This field has two purposes.  First, preventing you from
-  ** receiving duplicate copies of replies to messages which you send
-  ** to mailing lists, and second, ensuring that you do get a reply
-  ** separately for any messages sent to known lists to which you are
-  ** not subscribed.  The header will contain only the list's address
-  ** for subscribed lists, and both the list address and your own
-  ** email address for unsubscribed lists.  Without this header, a
-  ** group reply to your message sent to a subscribed list will be
-  ** sent to both the list and your address, resulting in two copies
-  ** of the same email for you.
-  */
-#ifdef USE_NNTP
-  { "followup_to_poster", DT_QUAD, R_NONE, OPT_FOLLOWUPTOPOSTER, M_ASKYES },
+   ** .pp
+   ** When set, the maximum line length for displaying f=f messages is limited
+   ** to this length. A value of 0 (which is also the default) means that the
+   ** maximum line length is determined by the terminal width and $$wrapmargin.
+   */
+  {"mail_check", DT_NUM, R_NONE, UL & BuffyTimeout, 5},
   /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If this variable is \fIset\fP and the keyword "poster" is present in
-  ** \fIFollowup-To\fP header, follow-up to newsgroup function is not
-  ** permitted.  The message will be mailed to the submitter of the
-  ** message via mail.
-  */
-#endif
-  { "force_name",      DT_BOOL, R_NONE, OPTFORCENAME, 0 },
+   ** .pp
+   ** This variable configures how often (in seconds) Mutt-ng should look for
+   ** new mail.
+   */
+  {"mailcap_path", DT_STR, R_NONE, UL & MailcapPath, 0},
   /*
-  ** .pp
-  ** This variable is similar to ``$$save_name'', except that Mutt-ng will
-  ** store a copy of your outgoing message by the username of the address
-  ** you are sending to even if that mailbox does not exist.
-  ** .pp
-  ** Also see the ``$$record'' variable.
-  */
-  { "force_buffy_check", DT_BOOL, R_NONE, OPTFORCEBUFFYCHECK, 0 },
+   ** .pp
+   ** This variable specifies which files to consult when attempting to
+   ** display MIME bodies not directly supported by Mutt-ng.
+   */
+  {"mailcap_sanitize", DT_BOOL, R_NONE, OPTMAILCAPSANITIZE, 1},
+  /*
+   ** .pp
+   ** If set, Mutt-ng will restrict possible characters in mailcap % expandos
+   ** to a well-defined set of safe characters.  This is the safe setting,
+   ** but we are not sure it doesn't break some more advanced MIME stuff.
+   ** .pp
+   ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
+   ** DOING!\fP
+   */
+#if USE_HCACHE
+
+  {"header_cache", DT_PATH, R_NONE, UL & HeaderCache, 0},
+  /*
+   ** .pp
+   ** Availability: Header Cache
+   **
+   ** .pp
+   ** The header_cache variable points to the header cache database.
+   ** If header_cache points to a directory it will contain a header cache
+   ** database  per folder. If header_cache points to a file that file will
+   ** be a single global header cache. By default it is unset and so no
+   ** header caching will be used.
+   */
+  {"maildir_header_cache_verify", DT_BOOL, R_NONE, OPTHCACHEVERIFY, 1},
+  /*
+   ** .pp
+   ** Availability: Header Cache
+   **
+   ** .pp
+   ** Check for Maildir unaware programs other than Mutt-ng having modified maildir
+   ** files when the header cache is in use.  This incurs one stat(2) per
+   ** message every time the folder is opened.
+   */
+  {"header_cache_pagesize", DT_STR, R_NONE, UL & HeaderCachePageSize,
+   UL "16384"},
+  /*
+   ** .pp
+   ** Availability: Header Cache
+   **
+   ** .pp
+   ** Change the maildir header cache database page size.  Too large
+   ** or too small of a page size for the common header can waste
+   ** space, memory effectiveness, or CPU time. The default should be more or
+   ** less the best you can get. For details google after Mutt-ng maildir header
+   ** cache (first hit).
+   */
+#endif /* USE_HCACHE */
+  {"maildir_trash", DT_BOOL, R_NONE, OPTMAILDIRTRASH, 0},
+  /*
+   ** .pp
+   ** If set, messages marked as deleted will be saved with the maildir
+   ** (T)rashed flag instead of unlinked.  \fBNOTE:\fP this only applies
+   ** to maildir-style mailboxes.  Setting it will have no effect on other
+   ** mailbox types.
+   ** It is similiar to the trash option.
+   */
+  {"mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1},
+  /*
+   ** .pp
+   ** Controls whether or not Mutt-ng marks \fInew\fP \fBunread\fP
+   ** messages as \fIold\fP if you exit a mailbox without reading them.
+   ** With this option set, the next time you start Mutt-ng, the messages
+   ** will show up with an "O" next to them in the index menu,
+   ** indicating that they are old.
+   */
+  {"markers", DT_BOOL, R_PAGER, OPTMARKERS, 1},
   /*
-  ** .pp
-  ** When \fIset\fP, it causes Mutt-ng to check for new mail when the
-  ** \fIbuffy-list\fP command is invoked. When \fIunset\fP, \fIbuffy_list\fP
-  ** will just list all mailboxes which are already known to have new mail.
-  ** .pp
-  ** Also see the following variables: ``$$timeout'', ``$$mail_check'' and
-  ** ``$$imap_mail_check''.
-  */
-  { "forward_decode",  DT_BOOL, R_NONE, OPTFORWDECODE, 1 },
+   ** .pp
+   ** Controls the display of wrapped lines in the internal pager. If set, a
+   ** ``+'' marker is displayed at the beginning of wrapped lines. Also see
+   ** the ``$$smart_wrap'' variable.
+   */
+  {"mask", DT_RX, R_NONE, UL & Mask, UL "!^\\.[^.]"},
   /*
-  ** .pp
-  ** Controls the decoding of complex MIME messages into text/plain when
-  ** forwarding a message.  The message header is also RFC2047 decoded.
-  ** This variable is only used, if ``$$mime_forward'' is \fIunset\fP,
-  ** otherwise ``$$mime_forward_decode'' is used instead.
-  */
-  { "forw_decode",     DT_SYN,  R_NONE, UL "forward_decode", 0 },
+   ** .pp
+   ** A regular expression used in the file browser, optionally preceded by
+   ** the \fInot\fP operator ``!''.  Only files whose names match this mask
+   ** will be shown. The match is always case-sensitive.
+   */
+  {"mbox", DT_PATH, R_BOTH, UL & Inbox, UL "~/mbox"},
   /*
-  */
-  { "forward_edit",    DT_QUAD, R_NONE, OPT_FORWEDIT, M_YES },
+   ** .pp
+   ** This specifies the folder into which read mail in your ``$$spoolfile''
+   ** folder will be appended.
+   */
+  {"operating_system", DT_STR, R_NONE, UL & OperatingSystem, 0},
   /*
-  ** .pp
-  ** This quadoption controls whether or not the user is automatically
-  ** placed in the editor when forwarding messages.  For those who always want
-  ** to forward with no modification, use a setting of ``no''.
-  */
-  { "forward_format",  DT_STR,  R_NONE, UL &ForwFmt, UL "[%a: %s]" },
+   ** .pp
+   ** This specifies the operating system name for the User-Agent header. If
+   ** this is unset, it will be set to the operating system name that uname(2)
+   ** returns. If uname(2) fails, "UNIX" will be used.
+   ** It looks like this Mutt-ng version (specified string)
+   */
+  {"sidebar_delim", DT_STR, R_BOTH, UL & SidebarDelim, UL "|"},
   /*
-  ** .pp
-  ** This variable controls the default subject when forwarding a message.
-  ** It uses the same format sequences as the ``$$index_format'' variable.
-  */
-  { "forw_format",     DT_SYN,  R_NONE, UL "forward_format", 0 },  
+   ** .pp
+   ** This specifies the delimiter between the sidebar (if visible) and 
+   ** other screens.
+   */
+  {"sidebar_visible", DT_BOOL, R_BOTH, OPTMBOXPANE, 0},
   /*
-  */
-  { "forward_quote",   DT_BOOL, R_NONE, OPTFORWQUOTE, 0 },
+   ** .pp
+   ** This specifies whether or not to show the mailbox list pane (left sidebar).
+   */
+  {"sidebar_width", DT_NUM, R_BOTH, UL & SidebarWidth, 0},
   /*
-  ** .pp
-  ** When \fIset\fP forwarded messages included in the main body of the
-  ** message (when ``$$mime_forward'' is \fIunset\fP) will be quoted using
-  ** ``$$indent_string''.
-  */
-  { "forw_quote",      DT_SYN,  R_NONE, UL "forward_quote", 0 },
+   ** .pp
+   ** The width of the mailbox list pane (left sidebar like in GUIs).
+   */
+  {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0},
   /*
-  */
-  { "from",            DT_ADDR, R_NONE, UL &From, UL 0 },
+   ** .pp
+   ** If set, only folders with new mail will be shown in the sidebar.
+   */
+  {"mbox_type", DT_MAGIC, R_NONE, UL & DefaultMagic, M_MBOX},
   /*
-  ** .pp
-  ** This variable contains a default from address.  It
-  ** can be overridden using my_hdr (including from send-hooks) and
-  ** ``$$reverse_name''.  This variable is ignored if ``$$use_from''
-  ** is unset.
-  ** E.g. you can use 
-  ** send-hook Mutt-ng-devel@lists.berlios.de 'my_hdr From: Foo Bar <foo@bar.fb>'
-  ** when replying to Mutt-ng-devel and Mutt-ng takes this email address.
-  ** .pp
-  ** Defaults to the contents of the environment variable EMAIL.
-  */
-  { "gecos_mask",      DT_RX,   R_NONE, UL &GecosMask, UL "^[^,]*" },
+   ** .pp
+   ** The default mailbox type used when creating new folders. May be any of
+   ** mbox, MMDF, MH and Maildir.
+   */
+  {"metoo", DT_BOOL, R_NONE, OPTMETOO, 0},
   /*
-  ** .pp
-  ** A regular expression used by Mutt-ng to parse the GECOS field of a password
-  ** entry when expanding the alias.  By default the regular expression is set
-  ** to "^[^,]*" which will return the string up to the first "," encountered.
-  ** If the GECOS field contains a string like "lastname, firstname" then you
-  ** should set the gecos_mask=".*".
-  ** .pp
-  ** This can be useful if you see the following behavior: you address a e-mail
-  ** to user ID stevef whose full name is Steve Franklin.  If Mutt-ng expands 
-  ** stevef to "Franklin" stevef@foo.bar then you should set the gecos_mask to
-  ** a regular expression that will match the whole name so Mutt-ng will expand
-  ** "Franklin" to "Franklin, Steve".
-  */
-#ifdef USE_NNTP
-  { "group_index_format", DT_STR, R_BOTH, UL &GroupFormat, UL "%4C %M%N %5s  %-45.45f %d" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** This variable allows you to customize the newsgroup browser display to
-  ** your personal taste.  This string is similar to ``$index_format'', but
-  ** has its own set of printf()-like sequences:
-  ** .pp
-  ** .ts
-  ** %C      current newsgroup number
-  ** %d      description of newsgroup (becomes from server)
-  ** %f      newsgroup name
-  ** %M      - if newsgroup not allowed for direct post (moderated for example)
-  ** %N      N if newsgroup is new, u if unsubscribed, blank otherwise
-  ** %n      number of new articles in newsgroup
-  ** %s      number of unread articles in newsgroup
-  ** %>X     right justify the rest of the string and pad with character "X"
-  ** %|X     pad to the end of the line with character "X"
-  ** .te
-  */
-#endif
-  { "hdr_format",      DT_SYN,  R_NONE, UL "index_format", 0 },
-  /*
-  */
-  { "hdrs",            DT_BOOL, R_NONE, OPTHDRS, 1 },
-  /*
-  ** .pp
-  ** When unset, the header fields normally added by the ``$my_hdr''
-  ** command are not created.  This variable \fImust\fP be unset before
-  ** composing a new message or replying in order to take effect.  If set,
-  ** the user defined header fields are added to every new message.
-  */
-  { "header",          DT_BOOL, R_NONE, OPTHEADER, 0 },
-  /*
-  ** .pp
-  ** When set, this variable causes Mutt-ng to include the header
-  ** of the message you are replying to into the edit buffer.
-  ** The ``$$weed'' setting applies.
-  */  
-  { "help",            DT_BOOL, R_BOTH, OPTHELP, 1 },
-  /*
-  ** .pp
-  ** When set, help lines describing the bindings for the major functions
-  ** provided by each menu are displayed on the first line of the screen.
-  ** .pp
-  ** \fBNote:\fP The binding will not be displayed correctly if the
-  ** function is bound to a sequence rather than a single keystroke.  Also,
-  ** the help line may not be updated if a binding is changed while Mutt-ng is
-  ** running.  Since this variable is primarily aimed at new users, neither
-  ** of these should present a major problem.
-  */
-  { "hidden_host",     DT_BOOL, R_NONE, OPTHIDDENHOST, 0 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will skip the host name part of ``$$hostname'' variable
-  ** when adding the domain part to addresses.  This variable does not
-  ** affect the generation of Message-IDs, and it will not lead to the 
-  ** cut-off of first-level domains.
-  */
-  { "hide_limited",    DT_BOOL, R_TREE|R_INDEX, OPTHIDELIMITED, 0 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will not show the presence of messages that are hidden
-  ** by limiting, in the thread tree.
-  */
-  { "hide_missing",    DT_BOOL, R_TREE|R_INDEX, OPTHIDEMISSING, 1 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will not show the presence of missing messages in the
-  ** thread tree.
-  */
-  { "hide_thread_subject", DT_BOOL, R_TREE|R_INDEX, OPTHIDETHREADSUBJECT, 1 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will not show the subject of messages in the thread
-  ** tree that have the same subject as their parent or closest previously
-  ** displayed sibling.
-  */
-  { "hide_top_limited",        DT_BOOL, R_TREE|R_INDEX, OPTHIDETOPLIMITED, 0 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will not show the presence of messages that are hidden
-  ** by limiting, at the top of threads in the thread tree.  Note that when
-  ** $$hide_missing is set, this option will have no effect.
-  */
-  { "hide_top_missing",        DT_BOOL, R_TREE|R_INDEX, OPTHIDETOPMISSING, 1 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will not show the presence of missing messages at the
-  ** top of threads in the thread tree.  Note that when $$hide_limited is
-  ** set, this option will have no effect.
-  */
-  { "history",         DT_NUM,  R_NONE, UL &HistSize, 10 },
-  /*
-  ** .pp
-  ** This variable controls the size (in number of strings remembered) of
-  ** the string history buffer. The buffer is cleared each time the
-  ** variable is set.
-  */
-  { "honor_followup_to", DT_QUAD, R_NONE, OPT_MFUPTO, M_YES },
-  /*
-  ** .pp
-  ** This variable controls whether or not a Mail-Followup-To header is
-  ** honored when group-replying to a message.
-  */
-  { "hostname",                DT_STR,  R_NONE, UL &Fqdn, 0 },
-  /*
-  ** .pp
-  ** Specifies the hostname to use after the ``@'' in local e-mail
-  ** addresses.  This overrides the compile time definition obtained from
-  ** /etc/resolv.conf.
-  */
-  { "ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0 },
-  /*
-  ** .pp
-  ** Affects the behaviour of the \fIreply\fP function when replying to
-  ** messages from mailing lists.  When set, if the ``Reply-To:'' field is
-  ** set to the same value as the ``To:'' field, Mutt-ng assumes that the
-  ** ``Reply-To:'' field was set by the mailing list to automate responses
-  ** to the list, and will ignore this field.  To direct a response to the
-  ** mailing list when this option is set, use the \fIlist-reply\fP
-  ** function; \fIgroup-reply\fP will reply to both the sender and the
-  ** list.
-  */
-#ifdef USE_IMAP
-  { "imap_authenticators", DT_STR, R_NONE, UL &ImapAuthenticators, UL 0 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** This is a colon-delimited list of authentication methods Mutt-ng may
-  ** attempt to use to log in to an IMAP server, in the order Mutt-ng should
-  ** try them.  Authentication methods are either 'login' or the right
-  ** side of an IMAP 'AUTH=xxx' capability string, eg 'digest-md5', 'gssapi'
-  ** or 'cram-md5'. This parameter is case-insensitive. If this
-  ** parameter is unset (the default) Mutt-ng will try all available methods,
-  ** in order from most-secure to least-secure.
-  ** .pp
-  ** Example: set imap_authenticators="gssapi:cram-md5:login"
-  ** .pp
-  ** \fBNote:\fP Mutt-ng will only fall back to other authentication methods if
-  ** the previous methods are unavailable. If a method is available but
-  ** authentication fails, Mutt-ng will not connect to the IMAP server.
-  */
-  { "imap_delim_chars",                DT_STR, R_NONE, UL &ImapDelimChars, UL "/." },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** This contains the list of characters which you would like to treat
-  ** as folder separators for displaying IMAP paths. In particular it
-  ** helps in using the '=' shortcut for your \fIfolder\fP variable.
-  */
-# if defined(USE_SSL) || defined(USE_GNUTLS)
-  { "imap_force_ssl",          DT_BOOL, R_NONE, OPTIMAPFORCESSL, 0 },
-  /*
-  ** .pp
-  ** Availability: IMAP and SSL or IMAP and GNUTLS
-  **
-  ** .pp
-  ** If this variable is set, Mutt-ng will always use SSL when
-  ** connecting to IMAP servers.
-  */
-# endif
-  { "imap_headers",    DT_STR, R_INDEX, UL &ImapHeaders, UL 0},
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** Mutt-ng requests these header fields in addition to the default headers
-  ** ("DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE
-  ** CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES X-LABEL") from IMAP
-  ** servers before displaying the index menu. You may want to add more
-  ** headers for spam detection. \fBNote:\fP This is a space separated list.
-  */
-  { "imap_home_namespace",     DT_STR, R_NONE, UL &ImapHomeNamespace, UL 0},
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** You normally want to see your personal folders alongside
-  ** your INBOX in the IMAP browser. If you see something else, you may set
-  ** this variable to the IMAP path to your folders.
-  */
-  { "imap_keepalive",           DT_NUM,  R_NONE, UL &ImapKeepalive, 900 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** This variable specifies the maximum amount of time in seconds that Mutt-ng
-  ** will wait before polling open IMAP connections, to prevent the server
-  ** from closing them before Mutt-ng has finished with them. The default is
-  ** well within the RFC-specified minimum amount of time (30 minutes) before
-  ** a server is allowed to do this, but in practice the RFC does get
-  ** violated every now and then. Reduce this number if you find yourself
-  ** getting disconnected from your IMAP server due to inactivity.
-  */
-  { "imap_list_subscribed",    DT_BOOL, R_NONE, OPTIMAPLSUB, 0 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** This variable configures whether IMAP folder browsing will look for
-  ** only subscribed folders or all folders.  This can be toggled in the
-  ** IMAP browser with the \fItoggle-subscribed\fP function.
-  */
-  { "imap_mail_check", DT_NUM,  R_NONE, UL &ImapBuffyTimeout, 5 },
-  /*
-  ** .pp
-  ** This variable configures how often (in seconds) Mutt-ng should look for
-  ** new mail in IMAP folders. This is split from the ``$mail_check'' variable
-  ** to generate less traffic and get more accurate information for local folders.
-  ** .pp
-  ** It defaults to the default value of ``$mail_check'' which is 5 seconds. But
-  ** you may want to increase it.
-  */
-  { "imap_pass",       DT_STR,  R_NONE, UL &ImapPass, UL 0 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** Specifies the password for your IMAP account.  If unset, Mutt-ng will
-  ** prompt you for your password when you invoke the fetch-mail function.
-  ** \fBWarning\fP: you should only use this option when you are on a
-  ** fairly secure machine, because the superuser can read your muttngrc even
-  ** if you are the only one who can read the file.
-  */
-  { "imap_passive",            DT_BOOL, R_NONE, OPTIMAPPASSIVE, 1 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** When set, Mutt-ng will not open new IMAP connections to check for new
-  ** mail.  Mutt-ng will only check for new mail over existing IMAP
-  ** connections.  This is useful if you don't want to be prompted to
-  ** user/password pairs on Mutt-ng invocation, or if opening the connection
-  ** is slow.
-  */
-  { "imap_peek", DT_BOOL, R_NONE, OPTIMAPPEEK, 1 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** If set, Mutt-ng will avoid implicitly marking your mail as read whenever
-  ** you fetch a message from the server. This is generally a good thing,
-  ** but can make closing an IMAP folder somewhat slower. This option
-  ** exists to appease speed freaks.
-  */
-  { "imap_reconnect",  DT_QUAD, R_NONE, OPT_IMAPRECONNECT, M_ASKYES },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** Controls whether or not Mutt-ng will try to reconnect to IMAP server when
-  ** the connection is lost.
-  */
-  { "imap_servernoise",                DT_BOOL, R_NONE, OPTIMAPSERVERNOISE, 1 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** When set, Mutt-ng will display warning messages from the IMAP
-  ** server as error messages. Since these messages are often
-  ** harmless, or generated due to configuration problems on the
-  ** server which are out of the users' hands, you may wish to suppress
-  ** them at some point.
-  */
-  { "imap_user",       DT_STR,  R_NONE, UL &ImapUser, UL 0 },
-  /*
-  ** .pp
-  ** Availability: IMAP
-  **
-  ** .pp
-  ** Your login name on the IMAP server.
-  ** .pp
-  ** This variable defaults to your user name on the local machine.
-  */
-#endif
-  { "implicit_autoview", DT_BOOL,R_NONE, OPTIMPLICITAUTOVIEW, 0},
-  /*
-  ** .pp
-  ** If set to ``yes'', Mutt-ng will look for a mailcap entry with the
-  ** copiousoutput flag set for \fIevery\fP MIME attachment it doesn't have
-  ** an internal viewer defined for.  If such an entry is found, Mutt-ng will
-  ** use the viewer defined in that entry to convert the body part to text
-  ** form.
-  */
-  { "include",         DT_QUAD, R_NONE, OPT_INCLUDE, M_ASKYES },
-  /*
-  ** .pp
-  ** Controls whether or not a copy of the message(s) you are replying to
-  ** is included in your reply.
-  */
-  { "include_onlyfirst",       DT_BOOL, R_NONE, OPTINCLUDEONLYFIRST, 0},
-  /*
-  ** .pp
-  ** Controls whether or not Mutt-ng includes only the first attachment
-  ** of the message you are replying.
-  */
-  { "indent_string",   DT_STR,  R_NONE, UL &Prefix, UL "> " },
-  /*
-  ** .pp
-  ** Specifies the string to prepend to each line of text quoted in a
-  ** message to which you are replying.  You are strongly encouraged not to
-  ** change this value, as it tends to agitate the more fanatical netizens.
-  */
-  { "indent_str",      DT_SYN,  R_NONE, UL "indent_string", 0 },
-  /*
-  */
-  { "index_format",    DT_STR,  R_BOTH, UL &HdrFmt, UL "%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s" },
-  /*
-  ** .pp
-  ** This variable allows you to customize the message index display to
-  ** your personal taste.
-  ** .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-ng:
-  ** .pp
-  ** .dl
-  ** .dt %a .dd address of the author
-  ** .dt %A .dd reply-to address (if present; otherwise: address of author)
-  ** .dt %b .dd filename of the original message folder (think mailBox)
-  ** .dt %B .dd the list to which the letter was sent, or else the folder name (%b).
-  ** .dt %c .dd number of characters (bytes) in the message
-  ** .dt %C .dd current message number
-  ** .dt %d .dd date and time of the message in the format specified by
-  **            ``date_format'' converted to sender's time zone
-  ** .dt %D .dd date and time of the message in the format specified by
-  **            ``date_format'' converted to the local time zone
-  ** .dt %e .dd current message number in thread
-  ** .dt %E .dd number of messages in current thread
-  ** .dt %f .dd entire From: line (address + real name)
-  ** .dt %F .dd author name, or recipient name if the message is from you
-  ** .dt %H .dd spam attribute(s) of this message
-  ** .dt %g .dd newsgroup name (if compiled with nntp support)
-  ** .dt %i .dd message-id of the current message
-  ** .dt %l .dd number of lines in the message (does not work with maildir,
-  **            mh, and possibly IMAP folders)
-  ** .dt %L .dd If an address in the To or CC header field matches an address
-  **            defined by the users ``subscribe'' command, this displays
-  **            "To <list-name>", otherwise the same as %F.
-  ** .dt %m .dd total number of message in the mailbox
-  ** .dt %M .dd number of hidden messages if the thread is collapsed.
-  ** .dt %N .dd message score
-  ** .dt %n .dd author's real name (or address if missing)
-  ** .dt %O .dd (_O_riginal save folder)  Where Mutt-ng would formerly have
-  **            stashed the message: list name or recipient name if no list
-  ** .dt %s .dd subject of the message
-  ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
-  ** .dt %t .dd `to:' field (recipients)
-  ** .dt %T .dd the appropriate character from the $$to_chars string
-  ** .dt %u .dd user (login) name of the author
-  ** .dt %v .dd first name of the author, or the recipient if the message is from you
-  ** .dt %W .dd name of organization of author (`organization:' field)
-  ** .dt %y .dd `x-label:' field, if present
-  ** .dt %Y .dd `x-label' field, if present, and (1) not at part of a thread tree,
-  **            (2) at the top of a thread, or (3) `x-label' is different from
-  **            preceding message's `x-label'.
-  ** .dt %Z .dd message status flags
-  ** .dt %{fmt} .dd the date and time of the message is converted to sender's
-  **                time zone, and ``fmt'' is expanded by the library function
-  **                ``strftime''; a leading bang disables locales
-  ** .dt %[fmt] .dd the date and time of the message is converted to the local
-  **                time zone, and ``fmt'' is expanded by the library function
-  **                ``strftime''; a leading bang disables locales
-  ** .dt %(fmt) .dd the local date and time when the message was received.
-  **                ``fmt'' is expanded by the library function ``strftime'';
-  **                a leading bang disables locales
-  ** .dt %<fmt> .dd the current local time. ``fmt'' is expanded by the library
-  **                function ``strftime''; a leading bang disables locales.
-  ** .dt %>X    .dd right justify the rest of the string and pad with character "X"
-  ** .dt %|X    .dd pad to the end of the line with character "X"
-  ** .de
-  ** .pp
-  ** See also: ``$$to_chars''.
-  */
-#ifdef USE_NNTP
-  { "inews",          DT_PATH, R_NONE, UL &Inews, UL "" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If set, specifies the program and arguments used to deliver news posted
-  ** by Mutt-ng.  Otherwise, Mutt-ng posts article using current connection to
-  ** news server.  The following printf-style sequence is understood:
-  ** .pp
-  ** .ts
-  ** %s      newsserver name
-  ** .te
-  ** .pp
-  ** Example: set inews="/usr/local/bin/inews -hS"
-  */
-#endif
-  { "ispell",          DT_PATH, R_NONE, UL &Ispell, UL ISPELL },
-  /*
-  ** .pp
-  ** How to invoke ispell (GNU's spell-checking software).
-  */
-  { "keep_flagged", DT_BOOL, R_NONE, OPTKEEPFLAGGED, 0 },
-  /*
-  ** .pp
-  ** If set, read messages marked as flagged will not be moved
-  ** from your spool mailbox to your ``$$mbox'' mailbox, or as a result of
-  ** a ``$mbox-hook'' command.
-  */
-  { "locale",          DT_STR,  R_BOTH, UL &Locale, UL "C" },
-  /*
-  ** .pp
-  ** The locale used by \fIstrftime(3)\fP to format dates. Legal values are
-  ** the strings your system accepts for the locale variable \fILC_TIME\fP.
-  */
-  { "list_reply",      DT_QUAD, R_NONE, OPT_LISTREPLY, M_NO },
-  /*
-  ** .pp
-  ** When set, address replies to the mailing list the original message came
-  ** from (instead to the author only). Setting this option to ``ask-yes'' or
-  ** ``ask-no'' will ask if you really intended to reply to the author only.
-  */
-  { "max_line_length", DT_NUM, R_NONE, UL &MaxLineLength, 0 },
-  /*
-  ** .pp
-  ** When set, the maximum line length for displaying f=f messages is limited
-  ** to this length. A value of 0 (which is also the default) means that the
-  ** maximum line length is determined by the terminal width and $$wrapmargin.
-  */
-  { "mail_check",      DT_NUM,  R_NONE, UL &BuffyTimeout, 5 },
-  /*
-  ** .pp
-  ** This variable configures how often (in seconds) Mutt-ng should look for
-  ** new mail.
-  */
-  { "mailcap_path",    DT_STR,  R_NONE, UL &MailcapPath, 0 },
-  /*
-  ** .pp
-  ** This variable specifies which files to consult when attempting to
-  ** display MIME bodies not directly supported by Mutt-ng.
-  */
-  { "mailcap_sanitize",        DT_BOOL, R_NONE, OPTMAILCAPSANITIZE, 1 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will restrict possible characters in mailcap % expandos
-  ** to a well-defined set of safe characters.  This is the safe setting,
-  ** but we are not sure it doesn't break some more advanced MIME stuff.
-  ** .pp
-  ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
-  ** DOING!\fP
-  */
-#if USE_HCACHE
-
-  { "header_cache", DT_PATH, R_NONE, UL &HeaderCache, 0 },
-  /*
-  ** .pp
-  ** Availability: Header Cache
-  **
-  ** .pp
-  ** The header_cache variable points to the header cache database.
-  ** If header_cache points to a directory it will contain a header cache
-  ** database  per folder. If header_cache points to a file that file will
-  ** be a single global header cache. By default it is unset and so no
-  ** header caching will be used.
-  */
-  { "maildir_header_cache_verify", DT_BOOL, R_NONE, OPTHCACHEVERIFY, 1 },
-  /*
-  ** .pp
-  ** Availability: Header Cache
-  **
-  ** .pp
-  ** Check for Maildir unaware programs other than Mutt-ng having modified maildir
-  ** files when the header cache is in use.  This incurs one stat(2) per
-  ** message every time the folder is opened.
-  */
-  { "header_cache_pagesize", DT_STR, R_NONE, UL &HeaderCachePageSize, UL "16384" },
-  /*
-  ** .pp
-  ** Availability: Header Cache
-  **
-  ** .pp
-  ** Change the maildir header cache database page size.  Too large
-  ** or too small of a page size for the common header can waste
-  ** space, memory effectiveness, or CPU time. The default should be more or
-  ** less the best you can get. For details google after Mutt-ng maildir header
-  ** cache (first hit).
-  */
-#endif /* USE_HCACHE */
-  { "maildir_trash", DT_BOOL, R_NONE, OPTMAILDIRTRASH, 0 },
-  /*
-  ** .pp
-  ** If set, messages marked as deleted will be saved with the maildir
-  ** (T)rashed flag instead of unlinked.  \fBNOTE:\fP this only applies
-  ** to maildir-style mailboxes.  Setting it will have no effect on other
-  ** mailbox types.
-  ** It is similiar to the trash option.
-  */
-  { "mark_old",                DT_BOOL, R_BOTH, OPTMARKOLD, 1 },
-  /*
-  ** .pp
-  ** Controls whether or not Mutt-ng marks \fInew\fP \fBunread\fP
-  ** messages as \fIold\fP if you exit a mailbox without reading them.
-  ** With this option set, the next time you start Mutt-ng, the messages
-  ** will show up with an "O" next to them in the index menu,
-  ** indicating that they are old.
-  */
-  { "markers",         DT_BOOL, R_PAGER, OPTMARKERS, 1 },
-  /*
-  ** .pp
-  ** Controls the display of wrapped lines in the internal pager. If set, a
-  ** ``+'' marker is displayed at the beginning of wrapped lines. Also see
-  ** the ``$$smart_wrap'' variable.
-  */
-  { "mask",            DT_RX,   R_NONE, UL &Mask, UL "!^\\.[^.]" },
-  /*
-  ** .pp
-  ** A regular expression used in the file browser, optionally preceded by
-  ** the \fInot\fP operator ``!''.  Only files whose names match this mask
-  ** will be shown. The match is always case-sensitive.
-  */
-  { "mbox",            DT_PATH, R_BOTH, UL &Inbox, UL "~/mbox" },
-  /*
-  ** .pp
-  ** This specifies the folder into which read mail in your ``$$spoolfile''
-  ** folder will be appended.
-  */
-  { "operating_system",  DT_STR, R_NONE, UL&OperatingSystem, 0 },
-  /*
-  ** .pp
-  ** This specifies the operating system name for the User-Agent header. If
-  ** this is unset, it will be set to the operating system name that uname(2)
-  ** returns. If uname(2) fails, "UNIX" will be used.
-  ** It looks like this Mutt-ng version (specified string)
-  */
-  { "sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|" },
-  /*
-  ** .pp
-  ** This specifies the delimiter between the sidebar (if visible) and 
-  ** other screens.
-  */
-  { "sidebar_visible", DT_BOOL, R_BOTH, OPTMBOXPANE, 0 },
-  /*
-  ** .pp
-  ** This specifies whether or not to show the mailbox list pane (left sidebar).
-  */
-  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
-  /*
-  ** .pp
-  ** The width of the mailbox list pane (left sidebar like in GUIs).
-  */
-  { "sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 },
-  /*
-  ** .pp
-  ** If set, only folders with new mail will be shown in the sidebar.
-  */
-  { "mbox_type",       DT_MAGIC,R_NONE, UL &DefaultMagic, M_MBOX },
-  /*
-  ** .pp
-  ** The default mailbox type used when creating new folders. May be any of
-  ** mbox, MMDF, MH and Maildir.
-  */
-  { "metoo",           DT_BOOL, R_NONE, OPTMETOO, 0 },
-  /*
-  ** .pp
-  ** If unset, Mutt-ng will remove your address (see the ``alternates''
-  ** command) from the list of recipients when replying to a message.
-  */
-  { "menu_context",    DT_NUM,  R_NONE, UL &MenuContext, 0 },
-  /*
-  ** .pp
-  ** This variable controls the number of lines of context that are given
-  ** when scrolling through menus. (Similar to ``$$pager_context''.)
-  */
-  { "menu_move_off",   DT_BOOL, R_NONE, OPTMENUMOVEOFF, 0 },
-  /*
-  ** .pp
-  ** When \fIunset\fP, the bottom entry of menus will never scroll up past
-  ** the bottom of the screen, unless there are less entries than lines.
-  ** When \fIset\fP, the bottom entry may move off the bottom.
-  */
-  { "menu_scroll",     DT_BOOL, R_NONE, OPTMENUSCROLL, 0 },
-  /*
-  ** .pp
-  ** When \fIset\fP, menus will be scrolled up or down one line when you
-  ** attempt to move across a screen boundary.  If \fIunset\fP, the screen
-  ** is cleared and the next or previous page of the menu is displayed
-  ** (useful for slow links to avoid many redraws).
-  */
-  { "meta_key",                DT_BOOL, R_NONE, OPTMETAKEY, 0 },
-  /*
-  ** .pp
-  ** If set, forces Mutt-ng to interpret keystrokes with the high bit (bit 8)
-  ** set as if the user had pressed the ESC key and whatever key remains
-  ** after having the high bit removed.  For example, if the key pressed
-  ** has an ASCII value of 0xf4, then this is treated as if the user had
-  ** pressed ESC then ``x''.  This is because the result of removing the
-  ** high bit from ``0xf4'' is ``0x74'', which is the ASCII character
-  ** ``x''.
-  */
-  { "mh_purge",                DT_BOOL, R_NONE, OPTMHPURGE, 0 },
-  /*
-  ** .pp
-  ** When unset, Mutt-ng will mimic mh's behaviour and rename deleted messages
-  ** to \fI,<old file name>\fP in mh folders instead of really deleting
-  ** them.  If the variable is set, the message files will simply be
-  ** deleted.
-  */
-  { "mh_seq_flagged",  DT_STR, R_NONE, UL &MhFlagged, UL "flagged" },
-  /*
-  ** .pp
-  ** The name of the MH sequence used for flagged messages.
-  */
-  { "mh_seq_replied",  DT_STR, R_NONE, UL &MhReplied, UL "replied" },
-  /*
-  ** .pp
-  ** The name of the MH sequence used to tag replied messages.
-  */
-  { "mh_seq_unseen",   DT_STR, R_NONE, UL &MhUnseen, UL "unseen" },
-  /*
-  ** .pp
-  ** The name of the MH sequence used for unseen messages.
-  */
-  { "mime_forward",    DT_QUAD, R_NONE, OPT_MIMEFWD, M_NO },
-  /*
-  ** .pp
-  ** When set, the message you are forwarding will be attached as a
-  ** separate MIME part instead of included in the main body of the
-  ** message.  This is useful for forwarding MIME messages so the receiver
-  ** can properly view the message as it was delivered to you. If you like
-  ** to switch between MIME and not MIME from mail to mail, set this
-  ** variable to ask-no or ask-yes.
-  ** .pp
-  ** Also see ``$$forward_decode'' and ``$$mime_forward_decode''.
-  */
-  { "mime_forward_decode", DT_BOOL, R_NONE, OPTMIMEFORWDECODE, 0 },
-  /*
-  ** .pp
-  ** Controls the decoding of complex MIME messages into text/plain when
-  ** forwarding a message while ``$$mime_forward'' is \fIset\fP. Otherwise
-  ** ``$$forward_decode'' is used instead.
-  */
-  { "mime_fwd",                DT_SYN,  R_NONE, UL "mime_forward", 0 },
-  /*
-  */
-
-  { "mime_forward_rest", DT_QUAD, R_NONE, OPT_MIMEFWDREST, M_YES },
-  /*
-  ** .pp
-  ** When forwarding multiple attachments of a MIME message from the recvattach
-  ** menu, attachments which cannot be decoded in a reasonable manner will
-  ** be attached to the newly composed message if this option is set.
-  */
-
-#ifdef USE_NNTP
-  { "mime_subject",   DT_BOOL, R_NONE, OPTMIMESUBJECT, 1 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
-  ** encoded according to RFC2047 to base64.  This is useful when message
-  ** is Usenet article, because MIME for news is nonstandard feature.
-  */
-#endif
-
-#ifdef MIXMASTER
-  { "mix_entry_format", DT_STR,  R_NONE, UL &MixEntryFormat, UL "%4n %c %-16s %a" },
-  /*
-  ** .pp
-  ** Availability: Mixmaster
-  **
-  ** .pp
-  ** This variable describes the format of a remailer line on the mixmaster
-  ** chain selection screen.  The following printf-like sequences are 
-  ** supported:
-  ** .pp
-  ** .dl
-  ** .dt %n .dd The running number on the menu.
-  ** .dt %c .dd Remailer capabilities.
-  ** .dt %s .dd The remailer's short name.
-  ** .dt %a .dd The remailer's e-mail address.
-  ** .de
-  */
-  { "mixmaster",       DT_PATH, R_NONE, UL &Mixmaster, UL MIXMASTER },
-  /*
-  ** .pp
-  ** Availability: Mixmaster
-  **
-  ** .pp
-  ** This variable contains the path to the Mixmaster binary on your
-  ** system.  It is used with various sets of parameters to gather the
-  ** list of known remailers, and to finally send a message through the
-  ** mixmaster chain.
-  */
-#endif
-  { "move",            DT_QUAD, R_NONE, OPT_MOVE, M_ASKNO },
-  /*
-  ** .pp
-  ** Controls whether or not Mutt-ng will move read messages
-  ** from your spool mailbox to your ``$$mbox'' mailbox, or as a result of
-  ** a ``$mbox-hook'' command.
-  */
-  { "message_format",  DT_STR,  R_NONE, UL &MsgFmt, UL "%s" },
-  /*
-  ** .pp
-  ** This is the string displayed in the ``attachment'' menu for
-  ** attachments of type message/rfc822.  For a full listing of defined
-  ** printf()-like sequences see the section on ``$$index_format''.
-  */
-  { "msg_format",      DT_SYN,  R_NONE, UL "message_format", 0 },
-  /*
-  */
-  { "msgid_format",    DT_STR, R_NONE, UL &MsgIdFormat, UL "%Y%m%d%h%M%s.G%P%p" },
-  /*
-  ** .pp
-  ** This is the format for the ``local part'' of the message-IDs generated
-  ** by Mutt-ng. The format string contains of one or more characters. The '%'
-  ** character marks that certain data will be added to the string, similar to
-  ** printf(). The following characters are allowed:
-  ** .pp
-  ** .dl
-  ** .dt %d .dd the current day of month
-  ** .dt %h .dd the current hour
-  ** .dt %m .dd the current month
-  ** .dt %M .dd the current minute
-  ** .dt %O .dd the current UNIX timestamp (octal)
-  ** .dt %p .dd the process ID
-  ** .dt %P .dd the current message-ID prefix (a character rotating with 
-  **            every message-ID being generated)
-  ** .dt %r .dd a random integer value (decimal)
-  ** .dt %R .dd a random integer value (hexadecimal)
-  ** .dt %s .dd the current second
-  ** .dt %T .dd the current UNIX timestamp (decimal)
-  ** .dt %X .dd the current UNIX timestamp (hexadecimal)
-  ** .dt %Y .dd the current year (Y2K compliant)
-  ** .dt %% .dd the '%' character
-  ** .de
-  */
-  { "narrow_tree",     DT_BOOL, R_TREE|R_INDEX, OPTNARROWTREE, 0 },
-  /*
-  ** .pp
-  ** This variable, when set, makes the thread tree narrower, allowing
-  ** deeper threads to fit on the screen.
-  */
-#ifdef USE_NNTP
-  { "news_cache_dir", DT_PATH, R_NONE, UL &NewsCacheDir, UL "~/.mutt" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** This variable pointing to directory where Mutt-ng will save cached news
-  ** articles headers in. If \fIunset\fP, headers will not be saved at all
-  ** and will be reloaded each time when you enter to newsgroup.
-  */
-  { "news_server",    DT_STR,  R_NONE, UL &NewsServer, 0 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** This variable specifies domain name or address of NNTP server. It
-  ** defaults to the newsserver specified in the environment variable
-  ** $$$NNTPSERVER or contained in the file /etc/nntpserver.  You can also
-  ** specify username and an alternative port for each newsserver, ie:
-  ** .pp
-  ** [nntp[s]://][username[:password]@]newsserver[:port]
-  */
-  { "newsrc",         DT_PATH, R_NONE, UL &NewsRc, UL "~/.newsrc" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** The file, containing info about subscribed newsgroups - names and
-  ** indexes of read articles.  The following printf-style sequence
-  ** is understood:
-  ** .pp
-  ** .ts
-  ** %s      newsserver name
-  ** .te
-  */
-  { "nntp_context",   DT_NUM,  R_NONE, UL &NntpContext, 1000 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** This variable defines number of articles which will be in index when
-  ** newsgroup entered.  If active newsgroup have more articles than this
-  ** number, oldest articles will be ignored.  Also controls how many
-  ** articles headers will be saved in cache when you quit newsgroup.
-  */
-  { "nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** This variable controls whether or not descriptions for each newsgroup
-  ** must be loaded when newsgroup is added to list (first time list
-  ** loading or new newsgroup adding).
-  */
-  { "nntp_user",      DT_STR,  R_NONE, UL &NntpUser, UL "" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** Your login name on the NNTP server.  If \fIunset\fP and NNTP server requires
-  ** authentification, Mutt-ng will prompt you for your account name when you
-  ** connect to newsserver.
-  */
-  { "nntp_pass",      DT_STR,  R_NONE, UL &NntpPass, UL "" },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** Your password for NNTP account.
-  */
-  { "nntp_poll",      DT_NUM,  R_NONE, UL &NewsPollTimeout, 60 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** The time in seconds until any operations on newsgroup except post new
-  ** article will cause recheck for new news.  If set to 0, Mutt-ng will
-  ** recheck newsgroup on each operation in index (stepping, read article,
-  ** etc.).
-  */
-  { "nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** Controls whether or not Mutt-ng will try to reconnect to newsserver when
-  ** connection lost.
-  */
-#endif
-  { "pager",           DT_PATH, R_NONE, UL &Pager, UL "builtin" },
-  /*
-  ** .pp
-  ** This variable specifies which pager you would like to use to view
-  ** messages.  builtin means to use the builtin pager, otherwise this
-  ** variable should specify the pathname of the external pager you would
-  ** like to use.
-  ** .pp
-  ** Using an external pager may have some disadvantages: Additional
-  ** keystrokes are necessary because you can't call Mutt-ng functions
-  ** directly from the pager, and screen resizes cause lines longer than
-  ** the screen width to be badly formatted in the help menu.
-  */
-  { "pager_context",   DT_NUM,  R_NONE, UL &PagerContext, 0 },
-  /*
-  ** .pp
-  ** This variable controls the number of lines of context that are given
-  ** when displaying the next or previous page in the internal pager.  By
-  ** default, Mutt-ng will display the line after the last one on the screen
-  ** at the top of the next page (0 lines of context).
-  */
-  { "pager_format",    DT_STR,  R_PAGER, UL &PagerFmt, UL "-%Z- %C/%m: %-20.20n   %s" },
-  /*
-  ** .pp
-  ** This variable controls the format of the one-line message ``status''
-  ** displayed before each message in either the internal or an external
-  ** pager.  The valid sequences are listed in the ``$$index_format''
-  ** section.
-  */
-  { "pager_index_lines",DT_NUM,         R_PAGER, UL &PagerIndexLines, 0 },
-  /*
-  ** .pp
-  ** Determines the number of lines of a mini-index which is shown when in
-  ** the pager.  The current message, unless near the top or bottom of the
-  ** folder, will be roughly one third of the way down this mini-index,
-  ** giving the reader the context of a few messages before and after the
-  ** message.  This is useful, for example, to determine how many messages
-  ** remain to be read in the current thread.  One of the lines is reserved
-  ** for the status bar from the index, so a \fIpager_index_lines\fP of 6
-  ** will only show 5 lines of the actual index.  A value of 0 results in
-  ** no index being shown.  If the number of messages in the current folder
-  ** is less than \fIpager_index_lines\fP, then the index will only use as
-  ** many lines as it needs.
-  */
-  { "pager_stop",      DT_BOOL, R_NONE, OPTPAGERSTOP, 0 },
-  /*
-  ** .pp
-  ** When set, the internal-pager will \fBnot\fP move to the next message
-  ** when you are at the end of a message and invoke the \fInext-page\fP
-  ** function.
-  */
-  { "pgp_autosign",    DT_SYN,  R_NONE, UL "crypt_autosign", 0 },
-  { "crypt_autosign",  DT_BOOL, R_NONE, OPTCRYPTAUTOSIGN, 0 },
-  /*
-  ** .pp
-  ** Setting this variable will cause Mutt-ng to always attempt to
-  ** cryptographically sign outgoing messages.  This can be overridden
-  ** by use of the \fIpgp-menu\fP, when signing is not required or
-  ** encryption is requested as well. If ``$$smime_is_default'' is set,
-  ** then OpenSSL is used instead to create S/MIME messages and settings can
-  ** be overridden by use of the \fIsmime-menu\fP.
-  ** (Crypto only)
-  */
-  { "pgp_autoencrypt",         DT_SYN,  R_NONE, UL "crypt_autoencrypt", 0 },
-  { "crypt_autoencrypt",       DT_BOOL, R_NONE, OPTCRYPTAUTOENCRYPT, 0 },
-  /*
-  ** .pp
-  ** Setting this variable will cause Mutt-ng to always attempt to PGP
-  ** encrypt outgoing messages.  This is probably only useful in
-  ** connection to the \fIsend-hook\fP command.  It can be overridden
-  ** by use of the \fIpgp-menu\fP, when encryption is not required or
-  ** signing is requested as well.  IF ``$$smime_is_default'' is set,
-  ** then OpenSSL is used instead to create S/MIME messages and
-  ** settings can be overridden by use of the \fIsmime-menu\fP.
-  ** (Crypto only)
-  */
-  { "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
-  /*
-  ** .pp
-  ** Setting this variable will cause Mutt-ng to ignore OpenPGP subkeys. Instead,
-  ** the principal key will inherit the subkeys' capabilities.  Unset this
-  ** if you want to play interesting key selection games.
-  ** (PGP only)
-  */
-  { "pgp_replyencrypt",                DT_SYN,  R_NONE, UL "crypt_replyencrypt", 1  },
-  { "crypt_replyencrypt",      DT_BOOL, R_NONE, OPTCRYPTREPLYENCRYPT, 1 },
-  /*
-  ** .pp
-  ** If set, automatically PGP or OpenSSL encrypt replies to messages which are
-  ** encrypted.
-  ** (Crypto only)
-  */
-  { "pgp_replysign",   DT_SYN, R_NONE, UL "crypt_replysign", 0 },
-  { "crypt_replysign", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGN, 0 },
-  /*
-  ** .pp
-  ** If set, automatically PGP or OpenSSL sign replies to messages which are
-  ** signed.
-  ** .pp
-  ** \fBNote:\fP this does not work on messages that are encrypted
-  ** \fBand\fP signed!
-  ** (Crypto only)
-  */
-  { "pgp_replysignencrypted",   DT_SYN,  R_NONE, UL "crypt_replysignencrypted", 0},
-  { "crypt_replysignencrypted", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGNENCRYPTED, 0 },
-  /*
-  ** .pp
-  ** If set, automatically PGP or OpenSSL sign replies to messages
-  ** which are encrypted. This makes sense in combination with
-  ** ``$$crypt_replyencrypt'', because it allows you to sign all
-  ** messages which are automatically encrypted.  This works around
-  ** the problem noted in ``$$crypt_replysign'', that Mutt-ng is not able
-  ** to find out whether an encrypted message is also signed.
-  ** (Crypto only)
-  */
-  { "crypt_timestamp", DT_BOOL, R_NONE, OPTCRYPTTIMESTAMP, 1 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will include a time stamp in the lines surrounding
-  ** PGP or S/MIME output, so spoofing such lines is more difficult.
-  ** If you are using colors to mark these lines, and rely on these,
-  ** you may unset this setting.
-  ** (Crypto only)
-  */
-  { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
-  /*
-  ** .pp
-  ** If set, Mutt-ng will use a possibly-running gpg-agent process.
-  ** (PGP only)
-  */
-  { "pgp_verify_sig",   DT_SYN,  R_NONE, UL "crypt_verify_sig", 0},
-  { "crypt_verify_sig",        DT_QUAD, R_NONE, OPT_VERIFYSIG, M_YES },
-  /*
-  ** .pp
-  ** If ``yes'', always attempt to verify PGP or S/MIME signatures.
-  ** If ``ask'', ask whether or not to verify the signature. 
-  ** If ``no'', never attempt to verify cryptographic signatures.
-  ** (Crypto only)
-  */
-  { "smime_is_default", DT_BOOL,  R_NONE, OPTSMIMEISDEFAULT, 0},
-  /*
-  ** .pp
-  ** The default behaviour of Mutt-ng is to use PGP on all auto-sign/encryption
-  ** operations. To override and to use OpenSSL instead this must be set.
-  ** However, this has no effect while replying, since Mutt-ng will automatically 
-  ** select the same application that was used to sign/encrypt the original
-  ** message.  (Note that this variable can be overridden by unsetting $$crypt_autosmime.)
-  ** (S/MIME only)
-  */
-  { "smime_ask_cert_label",    DT_BOOL, R_NONE, OPTASKCERTLABEL, 1 },
-  /*
-  ** .pp
-  ** This flag controls whether you want to be asked to enter a label
-  ** for a certificate about to be added to the database or not. It is
-  ** set by default.
-  ** (S/MIME only)
-  */
-  { "smime_decrypt_use_default_key",   DT_BOOL, R_NONE, OPTSDEFAULTDECRYPTKEY, 1 },
-  /*
-  ** .pp
-  ** If set (default) this tells Mutt-ng to use the default key for decryption. Otherwise,
-  ** if manage multiple certificate-key-pairs, Mutt-ng will try to use the mailbox-address
-  ** to determine the key to use. It will ask you to supply a key, if it can't find one.
-  ** (S/MIME only)
-  */
-  { "pgp_entry_format", DT_STR,  R_NONE, UL &PgpEntryFormat, UL "%4n %t%f %4l/0x%k %-4a %2c %u" },
-  /*
-  ** .pp
-  ** This variable allows you to customize the PGP key selection menu to
-  ** your personal taste. This string is similar to ``$$index_format'', but
-  ** has its own set of printf()-like sequences:
-  ** .pp
-  ** .dl
-  ** .dt %n     .dd number
-  ** .dt %k     .dd key id
-  ** .dt %u     .dd user id
-  ** .dt %a     .dd algorithm
-  ** .dt %l     .dd key length
-  ** .dt %f     .dd flags
-  ** .dt %c     .dd capabilities
-  ** .dt %t     .dd trust/validity of the key-uid association
-  ** .dt %[<s>] .dd date of the key where <s> is an strftime(3) expression
-  ** .de
-  ** .pp
-  ** (PGP only)
-  */
-  { "pgp_good_sign",   DT_RX,  R_NONE, UL &PgpGoodSign, 0 },
-  /*
-  ** .pp
-  ** If you assign a text to this variable, then a PGP signature is only
-  ** considered verified if the output from $$pgp_verify_command contains
-  ** the text. Use this variable if the exit code from the command is 0
-  ** even for bad signatures.
-  ** (PGP only)
-  */ 
-  { "pgp_check_exit",  DT_BOOL, R_NONE, OPTPGPCHECKEXIT, 1 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will check the exit code of the PGP subprocess when
-  ** signing or encrypting.  A non-zero exit code means that the
-  ** subprocess failed.
-  ** (PGP only)
-  */
-  { "pgp_long_ids",    DT_BOOL, R_NONE, OPTPGPLONGIDS, 0 },
-  /*
-  ** .pp
-  ** If set, use 64 bit PGP key IDs. Unset uses the normal 32 bit Key IDs.
-  ** (PGP only)
-  */
-  { "pgp_retainable_sigs", DT_BOOL, R_NONE, OPTPGPRETAINABLESIG, 0 },
-  /*
-  ** .pp
-  ** If set, signed and encrypted messages will consist of nested
-  ** multipart/signed and multipart/encrypted body parts.
-  ** .pp
-  ** This is useful for applications like encrypted and signed mailing
-  ** lists, where the outer layer (multipart/encrypted) can be easily
-  ** removed, while the inner multipart/signed part is retained.
-  ** (PGP only)
-  */
-  { "pgp_create_traditional",  DT_SYN, R_NONE, UL "pgp_autoinline", 0 },
-  { "pgp_autoinline",          DT_BOOL, R_NONE, OPTPGPAUTOINLINE, 0 },
-  /*
-  ** .pp
-  ** This option controls whether Mutt-ng generates old-style inline
-  ** (traditional) PGP encrypted or signed messages under certain
-  ** circumstances.  This can be overridden by use of the \fIpgp-menu\fP,
-  ** when inline is not required.
-  ** .pp
-  ** Note that Mutt-ng might automatically use PGP/MIME for messages
-  ** which consist of more than a single MIME part.  Mutt-ng can be
-  ** configured to ask before sending PGP/MIME messages when inline
-  ** (traditional) would not work.
-  ** See also: ``$$pgp_mime_auto''.
-  ** .pp
-  ** Also note that using the old-style PGP message format is \fBstrongly\fP
-  ** \fBdeprecated\fP.
-  ** (PGP only)
-  */
-  { "pgp_auto_traditional",    DT_SYN, R_NONE, UL "pgp_replyinline", 0 },
-  { "pgp_replyinline",         DT_BOOL, R_NONE, OPTPGPREPLYINLINE, 0 },
-  /*
-  ** .pp
-  ** Setting this variable will cause Mutt-ng to always attempt to
-  ** create an inline (traditional) message when replying to a
-  ** message which is PGP encrypted/signed inline.  This can be
-  ** overridden by use of the \fIpgp-menu\fP, when inline is not
-  ** required.  This option does not automatically detect if the
-  ** (replied-to) message is inline; instead it relies on Mutt-ng
-  ** internals for previously checked/flagged messages.
-  ** .pp
-  ** Note that Mutt-ng might automatically use PGP/MIME for messages
-  ** which consist of more than a single MIME part.  Mutt-ng can be
-  ** configured to ask before sending PGP/MIME messages when inline
-  ** (traditional) would not work.
-  ** See also: ``$$pgp_mime_auto''.
-  ** .pp
-  ** Also note that using the old-style PGP message format is \fBstrongly\fP
-  ** \fBdeprecated\fP.
-  ** (PGP only)
-  ** 
-  */
-  { "pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will display non-usable keys on the PGP key selection
-  ** menu.  This includes keys which have been revoked, have expired, or
-  ** have been marked as ``disabled'' by the user.
-  ** (PGP only)
-  */
-  { "pgp_sign_as",     DT_STR,  R_NONE, UL &PgpSignAs, 0 },
-  /*
-  ** .pp
-  ** If you have more than one key pair, this option allows you to specify
-  ** which of your private keys to use.  It is recommended that you use the
-  ** keyid form to specify your key (e.g., ``0x00112233'').
-  ** (PGP only)
-  */
-  { "pgp_strict_enc",  DT_BOOL, R_NONE, OPTPGPSTRICTENC, 1 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will automatically encode PGP/MIME signed messages as
-  ** \fIquoted-printable\fP.  Please note that unsetting this variable may
-  ** lead to problems with non-verifyable PGP signatures, so only change
-  ** this if you know what you are doing.
-  ** (PGP only)
-  */
-  { "pgp_timeout",     DT_NUM,  R_NONE, UL &PgpTimeout, 300 },
-  /*
-  ** .pp
-  ** The number of seconds after which a cached passphrase will expire if
-  ** not used. Default: 300.
-  ** (PGP only)
-  */
-  { "pgp_sort_keys",   DT_SORT|DT_SORT_KEYS, R_NONE, UL &PgpSortKeys, SORT_ADDRESS },
-  /*
-  ** .pp
-  ** Specifies how the entries in the `pgp keys' menu are sorted. The
-  ** following are legal values:
-  ** .pp
-  ** .dl
-  ** .dt address .dd sort alphabetically by user id
-  ** .dt keyid   .dd sort alphabetically by key id
-  ** .dt date    .dd sort by key creation date
-  ** .dt trust   .dd sort by the trust of the key
-  ** .de
-  ** .pp
-  ** If you prefer reverse order of the above values, prefix it with
-  ** `reverse-'.
-  ** (PGP only)
-  */
-  { "pgp_mime_auto", DT_QUAD, R_NONE, OPT_PGPMIMEAUTO, M_ASKYES },
-  /*
-  ** .pp
-  ** This option controls whether Mutt-ng will prompt you for
-  ** automatically sending a (signed/encrypted) message using
-  ** PGP/MIME when inline (traditional) fails (for any reason).
-  ** .pp
-  ** Also note that using the old-style PGP message format is \fBstrongly\fP
-  ** \fBdeprecated\fP.
-  ** (PGP only)
-  */
-  { "pgp_auto_decode", DT_BOOL, R_NONE, OPTPGPAUTODEC, 0 },
-  /*
-  ** .pp
-  ** If set, Mutt-ng will automatically attempt to decrypt traditional PGP
-  ** messages whenever the user performs an operation which ordinarily would
-  ** result in the contents of the message being operated on.  For example,
-  ** if the user displays a pgp-traditional message which has not been manually
-  ** checked with the check-traditional-pgp function, Mutt-ng will automatically
-  ** check the message for traditional pgp.
-  */
-
-
-  /* XXX Default values! */
-  
-  { "pgp_decode_command",      DT_STR, R_NONE, UL &PgpDecodeCommand, 0},
-  /*
-  ** .pp
-  ** This format strings specifies a command which is used to decode 
-  ** application/pgp attachments.
-  ** .pp
-  ** The PGP command formats have their own set of printf-like sequences:
-  ** .pp
-  ** .dl
-  ** .dt %p .dd Expands to PGPPASSFD=0 when a pass phrase is needed, to an empty
-  **            string otherwise. Note: This may be used with a %? construct.
-  ** .dt %f .dd Expands to the name of a file containing a message.
-  ** .dt %s .dd Expands to the name of a file containing the signature part
-  ** .          of a multipart/signed attachment when verifying it.
-  ** .dt %a .dd The value of $$pgp_sign_as.
-  ** .dt %r .dd One or more key IDs.
-  ** .de
-  ** .pp
-  ** For examples on how to configure these formats for the various versions
-  ** of PGP which are floating around, see the pgp*.rc and gpg.rc files in
-  ** the samples/ subdirectory which has been installed on your system
-  ** alongside the documentation.
-  ** (PGP only)
-  */
-  { "pgp_getkeys_command",     DT_STR, R_NONE, UL &PgpGetkeysCommand, 0},
-  /*
-  ** .pp
-  ** This command is invoked whenever Mutt-ng will need public key information.
-  ** %r is the only printf-like sequence used with this format.
-  ** (PGP only)
-  */
-  { "pgp_verify_command",      DT_STR, R_NONE, UL &PgpVerifyCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to verify PGP signatures.
-  ** (PGP only)
-  */
-  { "pgp_decrypt_command",     DT_STR, R_NONE, UL &PgpDecryptCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to decrypt a PGP encrypted message.
-  ** (PGP only)
-  */  
-  { "pgp_clearsign_command",   DT_STR, R_NONE, UL &PgpClearSignCommand, 0 },
-  /*
-  ** .pp
-  ** This format is used to create a old-style "clearsigned" PGP
-  ** message.  Note that the use of this format is \fBstrongly\fP
-  ** \fBdeprecated\fP.
-  ** (PGP only)
-  */
-  { "pgp_sign_command",                DT_STR, R_NONE, UL &PgpSignCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to create the detached PGP signature for a 
-  ** multipart/signed PGP/MIME body part.
-  ** (PGP only)
-  */  
-  { "pgp_encrypt_sign_command",        DT_STR, R_NONE, UL &PgpEncryptSignCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to both sign and encrypt a body part.
-  ** (PGP only)
-  */  
-  { "pgp_encrypt_only_command", DT_STR, R_NONE, UL &PgpEncryptOnlyCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to encrypt a body part without signing it.
-  ** (PGP only)
-  */  
-  { "pgp_import_command",      DT_STR, R_NONE, UL &PgpImportCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to import a key from a message into 
-  ** the user's public key ring.
-  ** (PGP only)
-  */  
-  { "pgp_export_command",      DT_STR, R_NONE, UL &PgpExportCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to export a public key from the user's
-  ** key ring.
-  ** (PGP only)
-  */  
-  { "pgp_verify_key_command",  DT_STR, R_NONE, UL &PgpVerifyKeyCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to verify key information from the key selection
-  ** menu.
-  ** (PGP only)
-  */  
-  { "pgp_list_secring_command",        DT_STR, R_NONE, UL &PgpListSecringCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to list the secret key ring's contents.  The
-  ** output format must be analogous to the one used by 
-  ** gpg --list-keys --with-colons.
-  ** .pp
-  ** This format is also generated by the pgpring utility which comes 
-  ** with Mutt-ng.
-  ** (PGP only)
-  */  
-  { "pgp_list_pubring_command", DT_STR, R_NONE, UL &PgpListPubringCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to list the public key ring's contents.  The
-  ** output format must be analogous to the one used by 
-  ** gpg --list-keys --with-colons.
-  ** .pp
-  ** This format is also generated by the pgpring utility which comes 
-  ** with Mutt-ng.
-  ** (PGP only)
-  */  
-  { "forward_decrypt", DT_BOOL, R_NONE, OPTFORWDECRYPT, 1 },
-  /*
-  ** .pp
-  ** Controls the handling of encrypted messages when forwarding a message.
-  ** When set, the outer layer of encryption is stripped off.  This
-  ** variable is only used if ``$$mime_forward'' is \fIset\fP and
-  ** ``$$mime_forward_decode'' is \fIunset\fP.
-  ** (PGP only)
-  */
-  { "forw_decrypt",    DT_SYN,  R_NONE, UL "forward_decrypt", 0 },
-  /*
-  */
-  
-  { "smime_timeout",           DT_NUM,  R_NONE, UL &SmimeTimeout, 300 },
-  /*
-  ** .pp
-  ** The number of seconds after which a cached passphrase will expire if
-  ** not used.
-  ** (S/MIME only)
-  */
-  { "smime_encrypt_with",      DT_STR,  R_NONE, UL &SmimeCryptAlg, 0 },
-  /*
-  ** .pp
-  ** This sets the algorithm that should be used for encryption.
-  ** Valid choices are "des", "des3", "rc2-40", "rc2-64", "rc2-128".
-  ** If unset "3des" (TripleDES) is used.
-  ** (S/MIME only)
-  */
-  { "smime_keys",              DT_PATH, R_NONE, UL &SmimeKeys, 0 },
-  /*
-  ** .pp
-  ** Since there is no pubring/secring as with PGP, Mutt-ng has to handle
-  ** storage ad retrieval of keys/certs by itself. This is very basic right now,
-  ** and stores keys and certificates in two different directories, both
-  ** named as the hash-value retrieved from OpenSSL. There is an index file
-  ** which contains mailbox-address keyid pair, and which can be manually
-  ** edited. This one points to the location of the private keys.
-  ** (S/MIME only)
-  */
-  { "smime_ca_location",       DT_PATH, R_NONE, UL &SmimeCALocation, 0 },
-  /*
-  ** .pp
-  ** This variable contains the name of either a directory, or a file which
-  ** contains trusted certificates for use with OpenSSL.
-  ** (S/MIME only)
-  */
-  { "smime_certificates",      DT_PATH, R_NONE, UL &SmimeCertificates, 0 },
-  /*
-  ** .pp
-  ** Since there is no pubring/secring as with PGP, Mutt-ng has to handle
-  ** storage and retrieval of keys by itself. This is very basic right
-  ** now, and keys and certificates are stored in two different
-  ** directories, both named as the hash-value retrieved from
-  ** OpenSSL. There is an index file which contains mailbox-address
-  ** keyid pairs, and which can be manually edited. This one points to
-  ** the location of the certificates.
-  ** (S/MIME only)
-  */
-  { "smime_decrypt_command",   DT_STR, R_NONE, UL &SmimeDecryptCommand, 0},
-  /*
-  ** .pp
-  ** This format string specifies a command which is used to decrypt
-  ** application/x-pkcs7-mime attachments.
-  ** .pp
-  ** The OpenSSL command formats have their own set of printf-like sequences
-  ** similar to PGP's:
-  ** .pp
-  ** .dl
-  ** .dt %f .dd Expands to the name of a file containing a message.
-  ** .dt %s .dd Expands to the name of a file containing the signature part
-  ** .          of a multipart/signed attachment when verifying it.
-  ** .dt %k .dd The key-pair specified with $$smime_default_key
-  ** .dt %c .dd One or more certificate IDs.
-  ** .dt %a .dd The algorithm used for encryption.
-  ** .dt %C .dd CA location:  Depending on whether $$smime_ca_location
-  ** .          points to a directory or file, this expands to 
-  ** .          "-CApath $$smime_ca_location" or "-CAfile $$smime_ca_location".
-  ** .de
-  ** .pp
-  ** For examples on how to configure these formats, see the smime.rc in
-  ** the samples/ subdirectory which has been installed on your system
-  ** alongside the documentation.
-  ** (S/MIME only)
-  */
-  { "smime_verify_command",    DT_STR, R_NONE, UL &SmimeVerifyCommand, 0},
-  /*
-  ** .pp
-  ** This command is used to verify S/MIME signatures of type multipart/signed.
-  ** (S/MIME only)
-  */
-  { "smime_verify_opaque_command",     DT_STR, R_NONE, UL &SmimeVerifyOpaqueCommand, 0},
+   ** .pp
+   ** If unset, Mutt-ng will remove your address (see the ``alternates''
+   ** command) from the list of recipients when replying to a message.
+   */
+  {"menu_context", DT_NUM, R_NONE, UL & MenuContext, 0},
   /*
-  ** .pp
-  ** This command is used to verify S/MIME signatures of type
-  ** application/x-pkcs7-mime.
-  ** (S/MIME only)
-  */
-  { "smime_sign_command",      DT_STR, R_NONE, UL &SmimeSignCommand, 0},
+   ** .pp
+   ** This variable controls the number of lines of context that are given
+   ** when scrolling through menus. (Similar to ``$$pager_context''.)
+   */
+  {"menu_move_off", DT_BOOL, R_NONE, OPTMENUMOVEOFF, 0},
   /*
-  ** .pp
-  ** This command is used to created S/MIME signatures of type
-  ** multipart/signed, which can be read by all mail clients.
-  ** (S/MIME only)
-  */
-  { "smime_sign_opaque_command",       DT_STR, R_NONE, UL &SmimeSignOpaqueCommand, 0},
+   ** .pp
+   ** When \fIunset\fP, the bottom entry of menus will never scroll up past
+   ** the bottom of the screen, unless there are less entries than lines.
+   ** When \fIset\fP, the bottom entry may move off the bottom.
+   */
+  {"menu_scroll", DT_BOOL, R_NONE, OPTMENUSCROLL, 0},
   /*
-  ** .pp
-  ** This command is used to created S/MIME signatures of type
-  ** application/x-pkcs7-signature, which can only be handled by mail
-  ** clients supporting the S/MIME extension.
-  ** (S/MIME only)
-  */
-  { "smime_encrypt_command",   DT_STR, R_NONE, UL &SmimeEncryptCommand, 0},
+   ** .pp
+   ** When \fIset\fP, menus will be scrolled up or down one line when you
+   ** attempt to move across a screen boundary.  If \fIunset\fP, the screen
+   ** is cleared and the next or previous page of the menu is displayed
+   ** (useful for slow links to avoid many redraws).
+   */
+  {"meta_key", DT_BOOL, R_NONE, OPTMETAKEY, 0},
+  /*
+   ** .pp
+   ** If set, forces Mutt-ng to interpret keystrokes with the high bit (bit 8)
+   ** set as if the user had pressed the ESC key and whatever key remains
+   ** after having the high bit removed.  For example, if the key pressed
+   ** has an ASCII value of 0xf4, then this is treated as if the user had
+   ** pressed ESC then ``x''.  This is because the result of removing the
+   ** high bit from ``0xf4'' is ``0x74'', which is the ASCII character
+   ** ``x''.
+   */
+  {"mh_purge", DT_BOOL, R_NONE, OPTMHPURGE, 0},
   /*
-  ** .pp
-  ** This command is used to create encrypted S/MIME messages.
-  ** (S/MIME only)
-  */
-  { "smime_pk7out_command",    DT_STR, R_NONE, UL &SmimePk7outCommand, 0},
+   ** .pp
+   ** When unset, Mutt-ng will mimic mh's behaviour and rename deleted messages
+   ** to \fI,<old file name>\fP in mh folders instead of really deleting
+   ** them.  If the variable is set, the message files will simply be
+   ** deleted.
+   */
+  {"mh_seq_flagged", DT_STR, R_NONE, UL & MhFlagged, UL "flagged"},
   /*
-  ** .pp
-  ** This command is used to extract PKCS7 structures of S/MIME signatures,
-  ** in order to extract the public X509 certificate(s).
-  ** (S/MIME only)
-  */
-  { "smime_get_cert_command",  DT_STR, R_NONE, UL &SmimeGetCertCommand, 0},
+   ** .pp
+   ** The name of the MH sequence used for flagged messages.
+   */
+  {"mh_seq_replied", DT_STR, R_NONE, UL & MhReplied, UL "replied"},
   /*
-  ** .pp
-  ** This command is used to extract X509 certificates from a PKCS7 structure.
-  ** (S/MIME only)
-  */
-  { "smime_get_signer_cert_command",   DT_STR, R_NONE, UL &SmimeGetSignerCertCommand, 0},
+   ** .pp
+   ** The name of the MH sequence used to tag replied messages.
+   */
+  {"mh_seq_unseen", DT_STR, R_NONE, UL & MhUnseen, UL "unseen"},
   /*
-  ** .pp
-  ** This command is used to extract only the signers X509 certificate from a S/MIME
-  ** signature, so that the certificate's owner may get compared to the
-  ** email's 'From'-field.
-  ** (S/MIME only)
-  */
-  { "smime_import_cert_command",       DT_STR, R_NONE, UL &SmimeImportCertCommand, 0},
+   ** .pp
+   ** The name of the MH sequence used for unseen messages.
+   */
+  {"mime_forward", DT_QUAD, R_NONE, OPT_MIMEFWD, M_NO},
+  /*
+   ** .pp
+   ** When set, the message you are forwarding will be attached as a
+   ** separate MIME part instead of included in the main body of the
+   ** message.  This is useful for forwarding MIME messages so the receiver
+   ** can properly view the message as it was delivered to you. If you like
+   ** to switch between MIME and not MIME from mail to mail, set this
+   ** variable to ask-no or ask-yes.
+   ** .pp
+   ** Also see ``$$forward_decode'' and ``$$mime_forward_decode''.
+   */
+  {"mime_forward_decode", DT_BOOL, R_NONE, OPTMIMEFORWDECODE, 0},
   /*
-  ** .pp
-  ** This command is used to import a certificate via smime_keys.
-  ** (S/MIME only)
-  */
-  { "smime_get_cert_email_command",    DT_STR, R_NONE, UL &SmimeGetCertEmailCommand, 0},
+   ** .pp
+   ** Controls the decoding of complex MIME messages into text/plain when
+   ** forwarding a message while ``$$mime_forward'' is \fIset\fP. Otherwise
+   ** ``$$forward_decode'' is used instead.
+   */
+  {"mime_fwd", DT_SYN, R_NONE, UL "mime_forward", 0},
   /*
-  ** .pp
-  ** This command is used to extract the mail address(es) used for storing
-  ** X509 certificates, and for verification purposes (to check whether the
-  ** certificate was issued for the sender's mailbox).
-  ** (S/MIME only)
-  */
-  { "smime_sign_as",                   DT_SYN,  R_NONE, UL "smime_default_key", 0 },
-  { "smime_default_key",               DT_STR,  R_NONE, UL &SmimeDefaultKey, 0 },
+   */
+
+  {"mime_forward_rest", DT_QUAD, R_NONE, OPT_MIMEFWDREST, M_YES},
   /*
-  ** .pp
-  ** This is the default key-pair to use for signing. This must be set to the
-  ** keyid (the hash-value that OpenSSL generates) to work properly
-  ** (S/MIME only)
-  */
-#if defined(USE_LIBESMTP)
-  { "smtp_auth_username", DT_STR, R_NONE, UL &SmtpAuthUser, 0 },
+   ** .pp
+   ** When forwarding multiple attachments of a MIME message from the recvattach
+   ** menu, attachments which cannot be decoded in a reasonable manner will
+   ** be attached to the newly composed message if this option is set.
+   */
+
+#ifdef USE_NNTP
+  {"mime_subject", DT_BOOL, R_NONE, OPTMIMESUBJECT, 1},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If \fIunset\fP, 8-bit ``subject:'' line in article header will not be
+   ** encoded according to RFC2047 to base64.  This is useful when message
+   ** is Usenet article, because MIME for news is nonstandard feature.
+   */
+#endif
+
+#ifdef MIXMASTER
+  {"mix_entry_format", DT_STR, R_NONE, UL & MixEntryFormat,
+   UL "%4n %c %-16s %a"},
+  /*
+   ** .pp
+   ** Availability: Mixmaster
+   **
+   ** .pp
+   ** This variable describes the format of a remailer line on the mixmaster
+   ** chain selection screen.  The following printf-like sequences are 
+   ** supported:
+   ** .pp
+   ** .dl
+   ** .dt %n .dd The running number on the menu.
+   ** .dt %c .dd Remailer capabilities.
+   ** .dt %s .dd The remailer's short name.
+   ** .dt %a .dd The remailer's e-mail address.
+   ** .de
+   */
+  {"mixmaster", DT_PATH, R_NONE, UL & Mixmaster, UL MIXMASTER},
+  /*
+   ** .pp
+   ** Availability: Mixmaster
+   **
+   ** .pp
+   ** This variable contains the path to the Mixmaster binary on your
+   ** system.  It is used with various sets of parameters to gather the
+   ** list of known remailers, and to finally send a message through the
+   ** mixmaster chain.
+   */
+#endif
+  {"move", DT_QUAD, R_NONE, OPT_MOVE, M_ASKNO},
   /*
-  ** .pp
-  ** Availability: SMTP
-  **
-  ** .pp
-  ** Defines the username to use with SMTP AUTH.  Setting this variable will
-  ** cause Mutt-ng to attempt to use SMTP AUTH when sending.
-  */
-  { "smtp_auth_password", DT_STR, R_NONE, UL &SmtpAuthPass, 0 },
+   ** .pp
+   ** Controls whether or not Mutt-ng will move read messages
+   ** from your spool mailbox to your ``$$mbox'' mailbox, or as a result of
+   ** a ``$mbox-hook'' command.
+   */
+  {"message_format", DT_STR, R_NONE, UL & MsgFmt, UL "%s"},
   /*
-  ** .pp
-  ** Availability: SMTP
-  **
-  ** .pp
-  ** Defines the password to use with SMTP AUTH.  If ``$$smtp_auth_username''
-  ** is set, but this variable is not, you will be prompted for a password
-  ** when sending.
-  */
-  { "smtp_host", DT_STR, R_NONE, UL &SmtpHost, 0 },
+   ** .pp
+   ** This is the string displayed in the ``attachment'' menu for
+   ** attachments of type message/rfc822.  For a full listing of defined
+   ** printf()-like sequences see the section on ``$$index_format''.
+   */
+  {"msg_format", DT_SYN, R_NONE, UL "message_format", 0},
   /*
-  ** .pp
-  ** Availability: SMTP
-  **
-  ** .pp
-  ** Defines the SMTP host which will be used to deliver mail, as opposed
-  ** to invoking the sendmail binary.  Setting this variable overrides the
-  ** value of ``$$sendmail'', and any associated variables.
-  */
-  { "smtp_port", DT_NUM, R_NONE, UL &SmtpPort, 25 },
+   */
+  {"msgid_format", DT_STR, R_NONE, UL & MsgIdFormat, UL "%Y%m%d%h%M%s.G%P%p"},
+  /*
+   ** .pp
+   ** This is the format for the ``local part'' of the message-IDs generated
+   ** by Mutt-ng. The format string contains of one or more characters. The '%'
+   ** character marks that certain data will be added to the string, similar to
+   ** printf(). The following characters are allowed:
+   ** .pp
+   ** .dl
+   ** .dt %d .dd the current day of month
+   ** .dt %h .dd the current hour
+   ** .dt %m .dd the current month
+   ** .dt %M .dd the current minute
+   ** .dt %O .dd the current UNIX timestamp (octal)
+   ** .dt %p .dd the process ID
+   ** .dt %P .dd the current message-ID prefix (a character rotating with 
+   **            every message-ID being generated)
+   ** .dt %r .dd a random integer value (decimal)
+   ** .dt %R .dd a random integer value (hexadecimal)
+   ** .dt %s .dd the current second
+   ** .dt %T .dd the current UNIX timestamp (decimal)
+   ** .dt %X .dd the current UNIX timestamp (hexadecimal)
+   ** .dt %Y .dd the current year (Y2K compliant)
+   ** .dt %% .dd the '%' character
+   ** .de
+   */
+  {"narrow_tree", DT_BOOL, R_TREE | R_INDEX, OPTNARROWTREE, 0},
   /*
-  ** .pp
-  ** Availability: SMTP
-  **
-  ** .pp
-  ** Defines the port that the SMTP host is listening on for mail delivery.
-  ** Must be specified as a number.
-  ** .pp
-  ** Defaults to 25, the standard SMTP port, but RFC 2476-compliant SMTP
-  ** servers will probably desire 587, the mail submission port.
-  */
-#endif
-#if defined(USE_SSL)||defined(USE_NSS)||defined(USE_GNUTLS)
-#ifdef USE_SSL
-  { "ssl_client_cert", DT_PATH, R_NONE, UL &SslClientCert, 0 },
+   ** .pp
+   ** This variable, when set, makes the thread tree narrower, allowing
+   ** deeper threads to fit on the screen.
+   */
+#ifdef USE_NNTP
+  {"news_cache_dir", DT_PATH, R_NONE, UL & NewsCacheDir, UL "~/.mutt"},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** This variable pointing to directory where Mutt-ng will save cached news
+   ** articles headers in. If \fIunset\fP, headers will not be saved at all
+   ** and will be reloaded each time when you enter to newsgroup.
+   */
+  {"news_server", DT_STR, R_NONE, UL & NewsServer, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** This variable specifies domain name or address of NNTP server. It
+   ** defaults to the newsserver specified in the environment variable
+   ** $$$NNTPSERVER or contained in the file /etc/nntpserver.  You can also
+   ** specify username and an alternative port for each newsserver, ie:
+   ** .pp
+   ** [nntp[s]://][username[:password]@]newsserver[:port]
+   */
+  {"newsrc", DT_PATH, R_NONE, UL & NewsRc, UL "~/.newsrc"},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** The file, containing info about subscribed newsgroups - names and
+   ** indexes of read articles.  The following printf-style sequence
+   ** is understood:
+   ** .pp
+   ** .ts
+   ** %s      newsserver name
+   ** .te
+   */
+  {"nntp_context", DT_NUM, R_NONE, UL & NntpContext, 1000},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** This variable defines number of articles which will be in index when
+   ** newsgroup entered.  If active newsgroup have more articles than this
+   ** number, oldest articles will be ignored.  Also controls how many
+   ** articles headers will be saved in cache when you quit newsgroup.
+   */
+  {"nntp_load_description", DT_BOOL, R_NONE, OPTLOADDESC, 1},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** This variable controls whether or not descriptions for each newsgroup
+   ** must be loaded when newsgroup is added to list (first time list
+   ** loading or new newsgroup adding).
+   */
+  {"nntp_user", DT_STR, R_NONE, UL & NntpUser, UL ""},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** Your login name on the NNTP server.  If \fIunset\fP and NNTP server requires
+   ** authentification, Mutt-ng will prompt you for your account name when you
+   ** connect to newsserver.
+   */
+  {"nntp_pass", DT_STR, R_NONE, UL & NntpPass, UL ""},
   /*
-  ** .pp
-  ** Availability: SSL
-  **
-  ** .pp
-  ** The file containing a client certificate and its associated private
-  ** key.
-  */
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** Your password for NNTP account.
+   */
+  {"nntp_poll", DT_NUM, R_NONE, UL & NewsPollTimeout, 60},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** The time in seconds until any operations on newsgroup except post new
+   ** article will cause recheck for new news.  If set to 0, Mutt-ng will
+   ** recheck newsgroup on each operation in index (stepping, read article,
+   ** etc.).
+   */
+  {"nntp_reconnect", DT_QUAD, R_NONE, OPT_NNTPRECONNECT, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** Controls whether or not Mutt-ng will try to reconnect to newsserver when
+   ** connection lost.
+   */
 #endif
-# if defined(USE_SSL)||defined(USE_GNUTLS)
-  { "ssl_starttls", DT_QUAD, R_NONE, OPT_SSLSTARTTLS, M_YES },
-  /*
-  ** .pp
-  ** Availability: SSL or GNUTLS
-  **
-  ** .pp
-  ** If set (the default), Mutt-ng will attempt to use STARTTLS on servers
-  ** advertising the capability. When unset, Mutt-ng will not attempt to
-  ** use STARTTLS regardless of the server's capabilities.
-  */
-# endif  
-  { "certificate_file",        DT_PATH, R_NONE, UL &SslCertFile, UL "~/.mutt_certificates" },
-  /*
-  ** .pp
-  ** Availability: SSL or NSS or GNUTLS
-  **
-  ** .pp
-  ** This variable specifies the file where the certificates you trust
-  ** are saved. When an unknown certificate is encountered, you are asked
-  ** if you accept it or not. If you accept it, the certificate can also 
-  ** be saved in this file and further connections are automatically 
-  ** accepted.
-  ** .pp
-  ** You can also manually add CA certificates in this file. Any server
-  ** certificate that is signed with one of these CA certificates are 
-  ** also automatically accepted.
-  ** .pp
-  ** Example: set certificate_file=~/.mutt/certificates
-  */
-# ifndef USE_GNUTLS
-  { "ssl_usesystemcerts", DT_BOOL, R_NONE, OPTSSLSYSTEMCERTS, 1 },
+  {"pager", DT_PATH, R_NONE, UL & Pager, UL "builtin"},
+  /*
+   ** .pp
+   ** This variable specifies which pager you would like to use to view
+   ** messages.  builtin means to use the builtin pager, otherwise this
+   ** variable should specify the pathname of the external pager you would
+   ** like to use.
+   ** .pp
+   ** Using an external pager may have some disadvantages: Additional
+   ** keystrokes are necessary because you can't call Mutt-ng functions
+   ** directly from the pager, and screen resizes cause lines longer than
+   ** the screen width to be badly formatted in the help menu.
+   */
+  {"pager_context", DT_NUM, R_NONE, UL & PagerContext, 0},
   /*
-  ** .pp
-  ** Availability: SSL or NSS
-  **
-  ** .pp
-  ** If set to \fIyes\fP, Mutt-ng will use CA certificates in the
-  ** system-wide certificate store when checking if server certificate 
-  ** is signed by a trusted CA.
-  */
-  { "entropy_file",    DT_PATH, R_NONE, UL &SslEntropyFile, 0 },
+   ** .pp
+   ** This variable controls the number of lines of context that are given
+   ** when displaying the next or previous page in the internal pager.  By
+   ** default, Mutt-ng will display the line after the last one on the screen
+   ** at the top of the next page (0 lines of context).
+   */
+  {"pager_format", DT_STR, R_PAGER, UL & PagerFmt,
+   UL "-%Z- %C/%m: %-20.20n   %s"},
+  /*
+   ** .pp
+   ** This variable controls the format of the one-line message ``status''
+   ** displayed before each message in either the internal or an external
+   ** pager.  The valid sequences are listed in the ``$$index_format''
+   ** section.
+   */
+  {"pager_index_lines", DT_NUM, R_PAGER, UL & PagerIndexLines, 0},
+  /*
+   ** .pp
+   ** Determines the number of lines of a mini-index which is shown when in
+   ** the pager.  The current message, unless near the top or bottom of the
+   ** folder, will be roughly one third of the way down this mini-index,
+   ** giving the reader the context of a few messages before and after the
+   ** message.  This is useful, for example, to determine how many messages
+   ** remain to be read in the current thread.  One of the lines is reserved
+   ** for the status bar from the index, so a \fIpager_index_lines\fP of 6
+   ** will only show 5 lines of the actual index.  A value of 0 results in
+   ** no index being shown.  If the number of messages in the current folder
+   ** is less than \fIpager_index_lines\fP, then the index will only use as
+   ** many lines as it needs.
+   */
+  {"pager_stop", DT_BOOL, R_NONE, OPTPAGERSTOP, 0},
   /*
-  ** .pp
-  ** Availability: SSL or NSS
-  **
-  ** .pp
-  ** The file which includes random data that is used to initialize SSL
-  ** library functions.
+   ** .pp
+   ** When set, the internal-pager will \fBnot\fP move to the next message
+   ** when you are at the end of a message and invoke the \fInext-page\fP
+   ** function.
+   */
+  {"pgp_autosign", DT_SYN, R_NONE, UL "crypt_autosign", 0},
+  {"crypt_autosign", DT_BOOL, R_NONE, OPTCRYPTAUTOSIGN, 0},
+  /*
+   ** .pp
+   ** Setting this variable will cause Mutt-ng to always attempt to
+   ** cryptographically sign outgoing messages.  This can be overridden
+   ** by use of the \fIpgp-menu\fP, when signing is not required or
+   ** encryption is requested as well. If ``$$smime_is_default'' is set,
+   ** then OpenSSL is used instead to create S/MIME messages and settings can
+   ** be overridden by use of the \fIsmime-menu\fP.
+   ** (Crypto only)
    */
-  { "ssl_use_sslv2", DT_BOOL, R_NONE, OPTSSLV2, 1 },
+  {"pgp_autoencrypt", DT_SYN, R_NONE, UL "crypt_autoencrypt", 0},
+  {"crypt_autoencrypt", DT_BOOL, R_NONE, OPTCRYPTAUTOENCRYPT, 0},
+  /*
+   ** .pp
+   ** Setting this variable will cause Mutt-ng to always attempt to PGP
+   ** encrypt outgoing messages.  This is probably only useful in
+   ** connection to the \fIsend-hook\fP command.  It can be overridden
+   ** by use of the \fIpgp-menu\fP, when encryption is not required or
+   ** signing is requested as well.  IF ``$$smime_is_default'' is set,
+   ** then OpenSSL is used instead to create S/MIME messages and
+   ** settings can be overridden by use of the \fIsmime-menu\fP.
+   ** (Crypto only)
+   */
+  {"pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
   /*
-  ** .pp
-  ** Availability: SSL or NSS
-  **
-  ** .pp
-  ** This variables specifies whether to attempt to use SSLv2 in the
-  ** SSL authentication process.
-  */
-# endif
-  { "ssl_use_sslv3", DT_BOOL, R_NONE, OPTSSLV3, 1 },
+   ** .pp
+   ** Setting this variable will cause Mutt-ng to ignore OpenPGP subkeys. Instead,
+   ** the principal key will inherit the subkeys' capabilities.  Unset this
+   ** if you want to play interesting key selection games.
+   ** (PGP only)
+   */
+  {"pgp_replyencrypt", DT_SYN, R_NONE, UL "crypt_replyencrypt", 1},
+  {"crypt_replyencrypt", DT_BOOL, R_NONE, OPTCRYPTREPLYENCRYPT, 1},
   /*
-  ** .pp
-  ** Availability: SSL or NSS or GNUTLS
-  **
-  ** .pp
-  ** This variables specifies whether to attempt to use SSLv3 in the
-  ** SSL authentication process.
-  */
-  { "ssl_use_tlsv1", DT_BOOL, R_NONE, OPTTLSV1, 1 },
+   ** .pp
+   ** If set, automatically PGP or OpenSSL encrypt replies to messages which are
+   ** encrypted.
+   ** (Crypto only)
+   */
+  {"pgp_replysign", DT_SYN, R_NONE, UL "crypt_replysign", 0},
+  {"crypt_replysign", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGN, 0},
+  /*
+   ** .pp
+   ** If set, automatically PGP or OpenSSL sign replies to messages which are
+   ** signed.
+   ** .pp
+   ** \fBNote:\fP this does not work on messages that are encrypted
+   ** \fBand\fP signed!
+   ** (Crypto only)
+   */
+  {"pgp_replysignencrypted", DT_SYN, R_NONE, UL "crypt_replysignencrypted",
+   0},
+  {"crypt_replysignencrypted", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGNENCRYPTED,
+   0},
+  /*
+   ** .pp
+   ** If set, automatically PGP or OpenSSL sign replies to messages
+   ** which are encrypted. This makes sense in combination with
+   ** ``$$crypt_replyencrypt'', because it allows you to sign all
+   ** messages which are automatically encrypted.  This works around
+   ** the problem noted in ``$$crypt_replysign'', that Mutt-ng is not able
+   ** to find out whether an encrypted message is also signed.
+   ** (Crypto only)
+   */
+  {"crypt_timestamp", DT_BOOL, R_NONE, OPTCRYPTTIMESTAMP, 1},
+  /*
+   ** .pp
+   ** If set, Mutt-ng will include a time stamp in the lines surrounding
+   ** PGP or S/MIME output, so spoofing such lines is more difficult.
+   ** If you are using colors to mark these lines, and rely on these,
+   ** you may unset this setting.
+   ** (Crypto only)
+   */
+  {"pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
   /*
-  ** .pp
-  ** Availability: SSL or NSS or GNUTLS
-  **
-  ** .pp
-  ** This variables specifies whether to attempt to use TLSv1 in the
-  ** SSL authentication process.
-  */
-#ifdef USE_GNUTLS
-  { "ssl_min_dh_prime_bits", DT_NUM, R_NONE, UL &SslDHPrimeBits, 0 },
+   ** .pp
+   ** If set, Mutt-ng will use a possibly-running gpg-agent process.
+   ** (PGP only)
+   */
+  {"pgp_verify_sig", DT_SYN, R_NONE, UL "crypt_verify_sig", 0},
+  {"crypt_verify_sig", DT_QUAD, R_NONE, OPT_VERIFYSIG, M_YES},
+  /*
+   ** .pp
+   ** If ``yes'', always attempt to verify PGP or S/MIME signatures.
+   ** If ``ask'', ask whether or not to verify the signature. 
+   ** If ``no'', never attempt to verify cryptographic signatures.
+   ** (Crypto only)
+   */
+  {"smime_is_default", DT_BOOL, R_NONE, OPTSMIMEISDEFAULT, 0},
+  /*
+   ** .pp
+   ** The default behaviour of Mutt-ng is to use PGP on all auto-sign/encryption
+   ** operations. To override and to use OpenSSL instead this must be set.
+   ** However, this has no effect while replying, since Mutt-ng will automatically 
+   ** select the same application that was used to sign/encrypt the original
+   ** message.  (Note that this variable can be overridden by unsetting $$crypt_autosmime.)
+   ** (S/MIME only)
+   */
+  {"smime_ask_cert_label", DT_BOOL, R_NONE, OPTASKCERTLABEL, 1},
   /*
-  ** .pp
-  ** Availability: GNUTLS
-  **
-  ** .pp
-  ** This variable specifies the minimum acceptable prime size (in bits)
-  ** for use in any Diffie-Hellman key exchange. A value of 0 will use
-  ** the default from the GNUTLS library.
-  */
-  { "ssl_ca_certificates_file", DT_PATH, R_NONE, UL &SslCACertFile, 0 },
+   ** .pp
+   ** This flag controls whether you want to be asked to enter a label
+   ** for a certificate about to be added to the database or not. It is
+   ** set by default.
+   ** (S/MIME only)
+   */
+  {"smime_decrypt_use_default_key", DT_BOOL, R_NONE, OPTSDEFAULTDECRYPTKEY,
+   1},
+  /*
+   ** .pp
+   ** If set (default) this tells Mutt-ng to use the default key for decryption. Otherwise,
+   ** if manage multiple certificate-key-pairs, Mutt-ng will try to use the mailbox-address
+   ** to determine the key to use. It will ask you to supply a key, if it can't find one.
+   ** (S/MIME only)
+   */
+  {"pgp_entry_format", DT_STR, R_NONE, UL & PgpEntryFormat,
+   UL "%4n %t%f %4l/0x%k %-4a %2c %u"},
+  /*
+   ** .pp
+   ** This variable allows you to customize the PGP key selection menu to
+   ** your personal taste. This string is similar to ``$$index_format'', but
+   ** has its own set of printf()-like sequences:
+   ** .pp
+   ** .dl
+   ** .dt %n     .dd number
+   ** .dt %k     .dd key id
+   ** .dt %u     .dd user id
+   ** .dt %a     .dd algorithm
+   ** .dt %l     .dd key length
+   ** .dt %f     .dd flags
+   ** .dt %c     .dd capabilities
+   ** .dt %t     .dd trust/validity of the key-uid association
+   ** .dt %[<s>] .dd date of the key where <s> is an strftime(3) expression
+   ** .de
+   ** .pp
+   ** (PGP only)
+   */
+  {"pgp_good_sign", DT_RX, R_NONE, UL & PgpGoodSign, 0},
+  /*
+   ** .pp
+   ** If you assign a text to this variable, then a PGP signature is only
+   ** considered verified if the output from $$pgp_verify_command contains
+   ** the text. Use this variable if the exit code from the command is 0
+   ** even for bad signatures.
+   ** (PGP only)
+   */
+  {"pgp_check_exit", DT_BOOL, R_NONE, OPTPGPCHECKEXIT, 1},
   /*
-  ** .pp
-  ** This variable specifies a file containing trusted CA certificates.
-  ** Any server certificate that is signed with one of these CA
-  ** certificates are also automatically accepted.
-  ** .pp
-  ** Example: set ssl_ca_certificates_file=/etc/ssl/certs/ca-certificates.crt
-  */
-#endif
-#endif
-  { "pipe_split",      DT_BOOL, R_NONE, OPTPIPESPLIT, 0 },
+   ** .pp
+   ** If set, Mutt-ng will check the exit code of the PGP subprocess when
+   ** signing or encrypting.  A non-zero exit code means that the
+   ** subprocess failed.
+   ** (PGP only)
+   */
+  {"pgp_long_ids", DT_BOOL, R_NONE, OPTPGPLONGIDS, 0},
   /*
-  ** .pp
-  ** Used in connection with the \fIpipe-message\fP command and the ``tag-
-  ** prefix'' operator.  If this variable is unset, when piping a list of
-  ** tagged messages Mutt-ng will concatenate the messages and will pipe them
-  ** as a single folder.  When set, Mutt-ng will pipe the messages one by one.
-  ** In both cases the messages are piped in the current sorted order,
-  ** and the ``$$pipe_sep'' separator is added after each message.
-  */
-  { "pipe_decode",     DT_BOOL, R_NONE, OPTPIPEDECODE, 0 },
+   ** .pp
+   ** If set, use 64 bit PGP key IDs. Unset uses the normal 32 bit Key IDs.
+   ** (PGP only)
+   */
+  {"pgp_retainable_sigs", DT_BOOL, R_NONE, OPTPGPRETAINABLESIG, 0},
+  /*
+   ** .pp
+   ** If set, signed and encrypted messages will consist of nested
+   ** multipart/signed and multipart/encrypted body parts.
+   ** .pp
+   ** This is useful for applications like encrypted and signed mailing
+   ** lists, where the outer layer (multipart/encrypted) can be easily
+   ** removed, while the inner multipart/signed part is retained.
+   ** (PGP only)
+   */
+  {"pgp_create_traditional", DT_SYN, R_NONE, UL "pgp_autoinline", 0},
+  {"pgp_autoinline", DT_BOOL, R_NONE, OPTPGPAUTOINLINE, 0},
+  /*
+   ** .pp
+   ** This option controls whether Mutt-ng generates old-style inline
+   ** (traditional) PGP encrypted or signed messages under certain
+   ** circumstances.  This can be overridden by use of the \fIpgp-menu\fP,
+   ** when inline is not required.
+   ** .pp
+   ** Note that Mutt-ng might automatically use PGP/MIME for messages
+   ** which consist of more than a single MIME part.  Mutt-ng can be
+   ** configured to ask before sending PGP/MIME messages when inline
+   ** (traditional) would not work.
+   ** See also: ``$$pgp_mime_auto''.
+   ** .pp
+   ** Also note that using the old-style PGP message format is \fBstrongly\fP
+   ** \fBdeprecated\fP.
+   ** (PGP only)
+   */
+  {"pgp_auto_traditional", DT_SYN, R_NONE, UL "pgp_replyinline", 0},
+  {"pgp_replyinline", DT_BOOL, R_NONE, OPTPGPREPLYINLINE, 0},
+  /*
+   ** .pp
+   ** Setting this variable will cause Mutt-ng to always attempt to
+   ** create an inline (traditional) message when replying to a
+   ** message which is PGP encrypted/signed inline.  This can be
+   ** overridden by use of the \fIpgp-menu\fP, when inline is not
+   ** required.  This option does not automatically detect if the
+   ** (replied-to) message is inline; instead it relies on Mutt-ng
+   ** internals for previously checked/flagged messages.
+   ** .pp
+   ** Note that Mutt-ng might automatically use PGP/MIME for messages
+   ** which consist of more than a single MIME part.  Mutt-ng can be
+   ** configured to ask before sending PGP/MIME messages when inline
+   ** (traditional) would not work.
+   ** See also: ``$$pgp_mime_auto''.
+   ** .pp
+   ** Also note that using the old-style PGP message format is \fBstrongly\fP
+   ** \fBdeprecated\fP.
+   ** (PGP only)
+   ** 
+   */
+  {"pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1},
   /*
-  ** .pp
-  ** Used in connection with the \fIpipe-message\fP command.  When unset,
-  ** Mutt-ng will pipe the messages without any preprocessing. When set, Mutt-ng
-  ** will weed headers and will attempt to PGP/MIME decode the messages
-  ** first.
-  */
-  { "pipe_sep",                DT_STR,  R_NONE, UL &PipeSep, UL "\n" },
+   ** .pp
+   ** If set, Mutt-ng will display non-usable keys on the PGP key selection
+   ** menu.  This includes keys which have been revoked, have expired, or
+   ** have been marked as ``disabled'' by the user.
+   ** (PGP only)
+   */
+  {"pgp_sign_as", DT_STR, R_NONE, UL & PgpSignAs, 0},
   /*
-  ** .pp
-  ** The separator to add between messages when piping a list of tagged
-  ** messages to an external Unix command.
-  */
-#ifdef USE_POP
-  { "pop_authenticators", DT_STR, R_NONE, UL &PopAuthenticators, UL 0 },
+   ** .pp
+   ** If you have more than one key pair, this option allows you to specify
+   ** which of your private keys to use.  It is recommended that you use the
+   ** keyid form to specify your key (e.g., ``0x00112233'').
+   ** (PGP only)
+   */
+  {"pgp_strict_enc", DT_BOOL, R_NONE, OPTPGPSTRICTENC, 1},
+  /*
+   ** .pp
+   ** If set, Mutt-ng will automatically encode PGP/MIME signed messages as
+   ** \fIquoted-printable\fP.  Please note that unsetting this variable may
+   ** lead to problems with non-verifyable PGP signatures, so only change
+   ** this if you know what you are doing.
+   ** (PGP only)
+   */
+  {"pgp_timeout", DT_NUM, R_NONE, UL & PgpTimeout, 300},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** This is a colon-delimited list of authentication methods Mutt-ng may
-  ** attempt to use to log in to an POP server, in the order Mutt-ng should
-  ** try them.  Authentication methods are either 'user', 'apop' or any
-  ** SASL mechanism, eg 'digest-md5', 'gssapi' or 'cram-md5'.
-  ** This parameter is case-insensitive. If this parameter is unset
-  ** (the default) Mutt-ng will try all available methods, in order from
-  ** most-secure to least-secure.
-  ** .pp
-  ** Example: set pop_authenticators="digest-md5:apop:user"
-  */
-  { "pop_auth_try_all",        DT_BOOL, R_NONE, OPTPOPAUTHTRYALL, 1 },
+   ** .pp
+   ** The number of seconds after which a cached passphrase will expire if
+   ** not used. Default: 300.
+   ** (PGP only)
+   */
+  {"pgp_sort_keys", DT_SORT | DT_SORT_KEYS, R_NONE, UL & PgpSortKeys,
+   SORT_ADDRESS},
+  /*
+   ** .pp
+   ** Specifies how the entries in the `pgp keys' menu are sorted. The
+   ** following are legal values:
+   ** .pp
+   ** .dl
+   ** .dt address .dd sort alphabetically by user id
+   ** .dt keyid   .dd sort alphabetically by key id
+   ** .dt date    .dd sort by key creation date
+   ** .dt trust   .dd sort by the trust of the key
+   ** .de
+   ** .pp
+   ** If you prefer reverse order of the above values, prefix it with
+   ** `reverse-'.
+   ** (PGP only)
+   */
+  {"pgp_mime_auto", DT_QUAD, R_NONE, OPT_PGPMIMEAUTO, M_ASKYES},
+  /*
+   ** .pp
+   ** This option controls whether Mutt-ng will prompt you for
+   ** automatically sending a (signed/encrypted) message using
+   ** PGP/MIME when inline (traditional) fails (for any reason).
+   ** .pp
+   ** Also note that using the old-style PGP message format is \fBstrongly\fP
+   ** \fBdeprecated\fP.
+   ** (PGP only)
+   */
+  {"pgp_auto_decode", DT_BOOL, R_NONE, OPTPGPAUTODEC, 0},
+  /*
+   ** .pp
+   ** If set, Mutt-ng will automatically attempt to decrypt traditional PGP
+   ** messages whenever the user performs an operation which ordinarily would
+   ** result in the contents of the message being operated on.  For example,
+   ** if the user displays a pgp-traditional message which has not been manually
+   ** checked with the check-traditional-pgp function, Mutt-ng will automatically
+   ** check the message for traditional pgp.
+   */
+
+
+  /* XXX Default values! */
+
+  {"pgp_decode_command", DT_STR, R_NONE, UL & PgpDecodeCommand, 0},
+  /*
+   ** .pp
+   ** This format strings specifies a command which is used to decode 
+   ** application/pgp attachments.
+   ** .pp
+   ** The PGP command formats have their own set of printf-like sequences:
+   ** .pp
+   ** .dl
+   ** .dt %p .dd Expands to PGPPASSFD=0 when a pass phrase is needed, to an empty
+   **            string otherwise. Note: This may be used with a %? construct.
+   ** .dt %f .dd Expands to the name of a file containing a message.
+   ** .dt %s .dd Expands to the name of a file containing the signature part
+   ** .          of a multipart/signed attachment when verifying it.
+   ** .dt %a .dd The value of $$pgp_sign_as.
+   ** .dt %r .dd One or more key IDs.
+   ** .de
+   ** .pp
+   ** For examples on how to configure these formats for the various versions
+   ** of PGP which are floating around, see the pgp*.rc and gpg.rc files in
+   ** the samples/ subdirectory which has been installed on your system
+   ** alongside the documentation.
+   ** (PGP only)
+   */
+  {"pgp_getkeys_command", DT_STR, R_NONE, UL & PgpGetkeysCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** If set, Mutt-ng will try all available methods. When unset, Mutt-ng will
-  ** only fall back to other authentication methods if the previous
-  ** methods are unavailable. If a method is available but authentication
-  ** fails, Mutt-ng will not connect to the POP server.
-  */
-  { "pop_checkinterval", DT_NUM, R_NONE, UL &PopCheckTimeout, 60 },
+   ** .pp
+   ** This command is invoked whenever Mutt-ng will need public key information.
+   ** %r is the only printf-like sequence used with this format.
+   ** (PGP only)
+   */
+  {"pgp_verify_command", DT_STR, R_NONE, UL & PgpVerifyCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** This variable configures how often (in seconds) POP should look for
-  ** new mail.
-  */
-  { "pop_delete",      DT_QUAD, R_NONE, OPT_POPDELETE, M_ASKNO },
+   ** .pp
+   ** This command is used to verify PGP signatures.
+   ** (PGP only)
+   */
+  {"pgp_decrypt_command", DT_STR, R_NONE, UL & PgpDecryptCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** If set, Mutt-ng will delete successfully downloaded messages from the POP
-  ** server when using the fetch-mail function.  When unset, Mutt-ng will
-  ** download messages but also leave them on the POP server.
-  */
-  { "pop_host",                DT_STR,  R_NONE, UL &PopHost, UL "" },
+   ** .pp
+   ** This command is used to decrypt a PGP encrypted message.
+   ** (PGP only)
+   */
+  {"pgp_clearsign_command", DT_STR, R_NONE, UL & PgpClearSignCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** The name of your POP server for the fetch-mail function.  You
-  ** can also specify an alternative port, username and password, ie:
-  ** .pp
-  ** [pop[s]://][username[:password]@]popserver[:port]
-  */
-  { "pop_last",                DT_BOOL, R_NONE, OPTPOPLAST, 0 },
+   ** .pp
+   ** This format is used to create a old-style "clearsigned" PGP
+   ** message.  Note that the use of this format is \fBstrongly\fP
+   ** \fBdeprecated\fP.
+   ** (PGP only)
+   */
+  {"pgp_sign_command", DT_STR, R_NONE, UL & PgpSignCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** If this variable is set, Mutt-ng will try to use the "LAST" POP command
-  ** for retrieving only unread messages from the POP server when using
-  ** the fetch-mail function.
-  */
-  { "pop_reconnect",   DT_QUAD, R_NONE, OPT_POPRECONNECT, M_ASKYES },
+   ** .pp
+   ** This command is used to create the detached PGP signature for a 
+   ** multipart/signed PGP/MIME body part.
+   ** (PGP only)
+   */
+  {"pgp_encrypt_sign_command", DT_STR, R_NONE, UL & PgpEncryptSignCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** Controls whether or not Mutt-ng will try to reconnect to POP server when
-  ** connection lost.
-  */
-  { "pop_user",                DT_STR,  R_NONE, UL &PopUser, 0 },
+   ** .pp
+   ** This command is used to both sign and encrypt a body part.
+   ** (PGP only)
+   */
+  {"pgp_encrypt_only_command", DT_STR, R_NONE, UL & PgpEncryptOnlyCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** Your login name on the POP server.
-  ** .pp
-  ** This variable defaults to your user name on the local machine.
-  */
-  { "pop_pass",                DT_STR,  R_NONE, UL &PopPass, UL "" },
+   ** .pp
+   ** This command is used to encrypt a body part without signing it.
+   ** (PGP only)
+   */
+  {"pgp_import_command", DT_STR, R_NONE, UL & PgpImportCommand, 0},
   /*
-  ** .pp
-  ** Availability: POP
-  **
-  ** .pp
-  ** Specifies the password for your POP account.  If unset, Mutt-ng will
-  ** prompt you for your password when you open POP mailbox.
-  ** \fBWarning\fP: you should only use this option when you are on a
-  ** fairly secure machine, because the superuser can read your muttngrc
-  ** even if you are the only one who can read the file.
-  */
-#endif /* USE_POP */
-  { "post_indent_string",DT_STR, R_NONE, UL &PostIndentString, UL "" },
+   ** .pp
+   ** This command is used to import a key from a message into 
+   ** the user's public key ring.
+   ** (PGP only)
+   */
+  {"pgp_export_command", DT_STR, R_NONE, UL & PgpExportCommand, 0},
   /*
-  ** .pp
-  ** Similar to the ``$$attribution'' variable, Mutt-ng will append this
-  ** string after the inclusion of a message which is being replied to.
-  */
-  { "post_indent_str",  DT_SYN,  R_NONE, UL "post_indent_string", 0 },
+   ** .pp
+   ** This command is used to export a public key from the user's
+   ** key ring.
+   ** (PGP only)
+   */
+  {"pgp_verify_key_command", DT_STR, R_NONE, UL & PgpVerifyKeyCommand, 0},
   /*
-  */
-#ifdef USE_NNTP
-  { "post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES },
+   ** .pp
+   ** This command is used to verify key information from the key selection
+   ** menu.
+   ** (PGP only)
+   */
+  {"pgp_list_secring_command", DT_STR, R_NONE, UL & PgpListSecringCommand, 0},
+  /*
+   ** .pp
+   ** This command is used to list the secret key ring's contents.  The
+   ** output format must be analogous to the one used by 
+   ** gpg --list-keys --with-colons.
+   ** .pp
+   ** This format is also generated by the pgpring utility which comes 
+   ** with Mutt-ng.
+   ** (PGP only)
+   */
+  {"pgp_list_pubring_command", DT_STR, R_NONE, UL & PgpListPubringCommand, 0},
+  /*
+   ** .pp
+   ** This command is used to list the public key ring's contents.  The
+   ** output format must be analogous to the one used by 
+   ** gpg --list-keys --with-colons.
+   ** .pp
+   ** This format is also generated by the pgpring utility which comes 
+   ** with Mutt-ng.
+   ** (PGP only)
+   */
+  {"forward_decrypt", DT_BOOL, R_NONE, OPTFORWDECRYPT, 1},
+  /*
+   ** .pp
+   ** Controls the handling of encrypted messages when forwarding a message.
+   ** When set, the outer layer of encryption is stripped off.  This
+   ** variable is only used if ``$$mime_forward'' is \fIset\fP and
+   ** ``$$mime_forward_decode'' is \fIunset\fP.
+   ** (PGP only)
+   */
+  {"forw_decrypt", DT_SYN, R_NONE, UL "forward_decrypt", 0},
   /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If set to \fIyes\fP, Mutt-ng will post article to newsgroup that have
-  ** not permissions to posting (e.g. moderated).  \fBNote:\fP if newsserver
-  ** does not support posting to that newsgroup or totally read-only, that
-  ** posting will not have an effect.
-  */
-#endif
-  { "postpone",                DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES },
+   */
+
+  {"smime_timeout", DT_NUM, R_NONE, UL & SmimeTimeout, 300},
   /*
-  ** .pp
-  ** Controls whether or not messages are saved in the ``$$postponed''
-  ** mailbox when you elect not to send immediately.
-  */
-  { "postponed",       DT_PATH, R_NONE, UL &Postponed, UL "~/postponed" },
+   ** .pp
+   ** The number of seconds after which a cached passphrase will expire if
+   ** not used.
+   ** (S/MIME only)
+   */
+  {"smime_encrypt_with", DT_STR, R_NONE, UL & SmimeCryptAlg, 0},
   /*
-  ** .pp
-  ** Mutt-ng allows you to indefinitely ``$postpone sending a message'' which
-  ** you are editing.  When you choose to postpone a message, Mutt-ng saves it
-  ** in the mailbox specified by this variable.  Also see the ``$$postpone''
-  ** variable.
-  */
-#ifdef USE_SOCKET
-  { "preconnect",      DT_STR, R_NONE, UL &Preconnect, UL 0},
+   ** .pp
+   ** This sets the algorithm that should be used for encryption.
+   ** Valid choices are "des", "des3", "rc2-40", "rc2-64", "rc2-128".
+   ** If unset "3des" (TripleDES) is used.
+   ** (S/MIME only)
+   */
+  {"smime_keys", DT_PATH, R_NONE, UL & SmimeKeys, 0},
+  /*
+   ** .pp
+   ** Since there is no pubring/secring as with PGP, Mutt-ng has to handle
+   ** storage ad retrieval of keys/certs by itself. This is very basic right now,
+   ** and stores keys and certificates in two different directories, both
+   ** named as the hash-value retrieved from OpenSSL. There is an index file
+   ** which contains mailbox-address keyid pair, and which can be manually
+   ** edited. This one points to the location of the private keys.
+   ** (S/MIME only)
+   */
+  {"smime_ca_location", DT_PATH, R_NONE, UL & SmimeCALocation, 0},
   /*
-  ** .pp
-  ** If set, a shell command to be executed if Mutt-ng fails to establish
-  ** a connection to the server. This is useful for setting up secure
-  ** connections, e.g. with ssh(1). If the command returns a  nonzero
-  ** status, Mutt-ng gives up opening the server. Example:
-  ** .pp
-  ** preconnect="ssh -f -q -L 1234:mailhost.net:143 mailhost.net
-  **                   sleep 20 < /dev/null > /dev/null"
-  ** .pp
-  ** Mailbox 'foo' on mailhost.net can now be reached
-  ** as '{localhost:1234}foo'.
-  ** .pp
-  ** NOTE: For this example to work, you must be able to log in to the
-  ** remote machine without having to enter a password.
-  */
-#endif /* USE_SOCKET */
-  { "print",           DT_QUAD, R_NONE, OPT_PRINT, M_ASKNO },
+   ** .pp
+   ** This variable contains the name of either a directory, or a file which
+   ** contains trusted certificates for use with OpenSSL.
+   ** (S/MIME only)
+   */
+  {"smime_certificates", DT_PATH, R_NONE, UL & SmimeCertificates, 0},
+  /*
+   ** .pp
+   ** Since there is no pubring/secring as with PGP, Mutt-ng has to handle
+   ** storage and retrieval of keys by itself. This is very basic right
+   ** now, and keys and certificates are stored in two different
+   ** directories, both named as the hash-value retrieved from
+   ** OpenSSL. There is an index file which contains mailbox-address
+   ** keyid pairs, and which can be manually edited. This one points to
+   ** the location of the certificates.
+   ** (S/MIME only)
+   */
+  {"smime_decrypt_command", DT_STR, R_NONE, UL & SmimeDecryptCommand, 0},
+  /*
+   ** .pp
+   ** This format string specifies a command which is used to decrypt
+   ** application/x-pkcs7-mime attachments.
+   ** .pp
+   ** The OpenSSL command formats have their own set of printf-like sequences
+   ** similar to PGP's:
+   ** .pp
+   ** .dl
+   ** .dt %f .dd Expands to the name of a file containing a message.
+   ** .dt %s .dd Expands to the name of a file containing the signature part
+   ** .          of a multipart/signed attachment when verifying it.
+   ** .dt %k .dd The key-pair specified with $$smime_default_key
+   ** .dt %c .dd One or more certificate IDs.
+   ** .dt %a .dd The algorithm used for encryption.
+   ** .dt %C .dd CA location:  Depending on whether $$smime_ca_location
+   ** .          points to a directory or file, this expands to 
+   ** .          "-CApath $$smime_ca_location" or "-CAfile $$smime_ca_location".
+   ** .de
+   ** .pp
+   ** For examples on how to configure these formats, see the smime.rc in
+   ** the samples/ subdirectory which has been installed on your system
+   ** alongside the documentation.
+   ** (S/MIME only)
+   */
+  {"smime_verify_command", DT_STR, R_NONE, UL & SmimeVerifyCommand, 0},
   /*
-  ** .pp
-  ** Controls whether or not Mutt-ng really prints messages.
-  ** This is set to \fIask-no\fP by default, because some people
-  ** accidentally hit ``p'' often (like me).
-  */
-  { "print_command",   DT_PATH, R_NONE, UL &PrintCmd, UL "lpr" },
+   ** .pp
+   ** This command is used to verify S/MIME signatures of type multipart/signed.
+   ** (S/MIME only)
+   */
+  {"smime_verify_opaque_command", DT_STR, R_NONE,
+   UL & SmimeVerifyOpaqueCommand, 0},
   /*
-  ** .pp
-  ** This specifies the command pipe that should be used to print messages.
-  */
-  { "print_cmd",       DT_SYN,  R_NONE, UL "print_command", 0 },
+   ** .pp
+   ** This command is used to verify S/MIME signatures of type
+   ** application/x-pkcs7-mime.
+   ** (S/MIME only)
+   */
+  {"smime_sign_command", DT_STR, R_NONE, UL & SmimeSignCommand, 0},
   /*
-  */
-  { "print_decode",    DT_BOOL, R_NONE, OPTPRINTDECODE, 1 },
+   ** .pp
+   ** This command is used to created S/MIME signatures of type
+   ** multipart/signed, which can be read by all mail clients.
+   ** (S/MIME only)
+   */
+  {"smime_sign_opaque_command", DT_STR, R_NONE, UL & SmimeSignOpaqueCommand,
+   0},
+  /*
+   ** .pp
+   ** This command is used to created S/MIME signatures of type
+   ** application/x-pkcs7-signature, which can only be handled by mail
+   ** clients supporting the S/MIME extension.
+   ** (S/MIME only)
+   */
+  {"smime_encrypt_command", DT_STR, R_NONE, UL & SmimeEncryptCommand, 0},
   /*
-  ** .pp
-  ** Used in connection with the print-message command.  If this
-  ** option is set, the message is decoded before it is passed to the
-  ** external command specified by $$print_command.  If this option
-  ** is unset, no processing will be applied to the message when
-  ** printing it.  The latter setting may be useful if you are using
-  ** some advanced printer filter which is able to properly format
-  ** e-mail messages for printing.
-  */
-  { "print_split",     DT_BOOL, R_NONE, OPTPRINTSPLIT,  0 },
+   ** .pp
+   ** This command is used to create encrypted S/MIME messages.
+   ** (S/MIME only)
+   */
+  {"smime_pk7out_command", DT_STR, R_NONE, UL & SmimePk7outCommand, 0},
   /*
-  ** .pp
-  ** Used in connection with the print-message command.  If this option
-  ** is set, the command specified by $$print_command is executed once for
-  ** each message which is to be printed.  If this option is unset, 
-  ** the command specified by $$print_command is executed only once, and
-  ** all the messages are concatenated, with a form feed as the message
-  ** separator.
-  ** .pp
-  ** Those who use the \fBenscript\fP(1) program's mail-printing mode will
-  ** most likely want to set this option.
-  */
-  { "prompt_after",    DT_BOOL, R_NONE, OPTPROMPTAFTER, 1 },
+   ** .pp
+   ** This command is used to extract PKCS7 structures of S/MIME signatures,
+   ** in order to extract the public X509 certificate(s).
+   ** (S/MIME only)
+   */
+  {"smime_get_cert_command", DT_STR, R_NONE, UL & SmimeGetCertCommand, 0},
   /*
-  ** .pp
-  ** If you use an \fIexternal\fP ``$$pager'', setting this variable will
-  ** cause Mutt-ng to prompt you for a command when the pager exits rather
-  ** than returning to the index menu.  If unset, Mutt-ng will return to the
-  ** index menu when the external pager exits.
-  */
-  { "query_command",   DT_PATH, R_NONE, UL &QueryCmd, UL "" },
+   ** .pp
+   ** This command is used to extract X509 certificates from a PKCS7 structure.
+   ** (S/MIME only)
+   */
+  {"smime_get_signer_cert_command", DT_STR, R_NONE,
+   UL & SmimeGetSignerCertCommand, 0},
+  /*
+   ** .pp
+   ** This command is used to extract only the signers X509 certificate from a S/MIME
+   ** signature, so that the certificate's owner may get compared to the
+   ** email's 'From'-field.
+   ** (S/MIME only)
+   */
+  {"smime_import_cert_command", DT_STR, R_NONE, UL & SmimeImportCertCommand,
+   0},
   /*
-  ** .pp
-  ** This specifies the command that Mutt-ng will use to make external address
-  ** queries.  The string should contain a %s, which will be substituted
-  ** with the query string the user types.  See ``$query'' for more
-  ** information.
-  */
-  { "quit",            DT_QUAD, R_NONE, OPT_QUIT, M_YES },
+   ** .pp
+   ** This command is used to import a certificate via smime_keys.
+   ** (S/MIME only)
+   */
+  {"smime_get_cert_email_command", DT_STR, R_NONE,
+   UL & SmimeGetCertEmailCommand, 0},
+  /*
+   ** .pp
+   ** This command is used to extract the mail address(es) used for storing
+   ** X509 certificates, and for verification purposes (to check whether the
+   ** certificate was issued for the sender's mailbox).
+   ** (S/MIME only)
+   */
+  {"smime_sign_as", DT_SYN, R_NONE, UL "smime_default_key", 0},
+  {"smime_default_key", DT_STR, R_NONE, UL & SmimeDefaultKey, 0},
   /*
-  ** .pp
-  ** This variable controls whether ``quit'' and ``exit'' actually quit
-  ** from Mutt-ng.  If it set to yes, they do quit, if it is set to no, they
-  ** have no effect, and if it is set to ask-yes or ask-no, you are
-  ** prompted for confirmation when you try to quit.
-  */
-  { "quote_empty",     DT_BOOL, R_NONE, OPTQUOTEEMPTY, 1 },
+   ** .pp
+   ** This is the default key-pair to use for signing. This must be set to the
+   ** keyid (the hash-value that OpenSSL generates) to work properly
+   ** (S/MIME only)
+   */
+#if defined(USE_LIBESMTP)
+  {"smtp_auth_username", DT_STR, R_NONE, UL & SmtpAuthUser, 0},
+  /*
+   ** .pp
+   ** Availability: SMTP
+   **
+   ** .pp
+   ** Defines the username to use with SMTP AUTH.  Setting this variable will
+   ** cause Mutt-ng to attempt to use SMTP AUTH when sending.
+   */
+  {"smtp_auth_password", DT_STR, R_NONE, UL & SmtpAuthPass, 0},
+  /*
+   ** .pp
+   ** Availability: SMTP
+   **
+   ** .pp
+   ** Defines the password to use with SMTP AUTH.  If ``$$smtp_auth_username''
+   ** is set, but this variable is not, you will be prompted for a password
+   ** when sending.
+   */
+  {"smtp_host", DT_STR, R_NONE, UL & SmtpHost, 0},
+  /*
+   ** .pp
+   ** Availability: SMTP
+   **
+   ** .pp
+   ** Defines the SMTP host which will be used to deliver mail, as opposed
+   ** to invoking the sendmail binary.  Setting this variable overrides the
+   ** value of ``$$sendmail'', and any associated variables.
+   */
+  {"smtp_port", DT_NUM, R_NONE, UL & SmtpPort, 25},
+  /*
+   ** .pp
+   ** Availability: SMTP
+   **
+   ** .pp
+   ** Defines the port that the SMTP host is listening on for mail delivery.
+   ** Must be specified as a number.
+   ** .pp
+   ** Defaults to 25, the standard SMTP port, but RFC 2476-compliant SMTP
+   ** servers will probably desire 587, the mail submission port.
+   */
+#endif
+#if defined(USE_SSL)||defined(USE_NSS)||defined(USE_GNUTLS)
+#ifdef USE_SSL
+  {"ssl_client_cert", DT_PATH, R_NONE, UL & SslClientCert, 0},
+  /*
+   ** .pp
+   ** Availability: SSL
+   **
+   ** .pp
+   ** The file containing a client certificate and its associated private
+   ** key.
+   */
+#endif
+# if defined(USE_SSL)||defined(USE_GNUTLS)
+  {"ssl_starttls", DT_QUAD, R_NONE, OPT_SSLSTARTTLS, M_YES},
+  /*
+   ** .pp
+   ** Availability: SSL or GNUTLS
+   **
+   ** .pp
+   ** If set (the default), Mutt-ng will attempt to use STARTTLS on servers
+   ** advertising the capability. When unset, Mutt-ng will not attempt to
+   ** use STARTTLS regardless of the server's capabilities.
+   */
+# endif
+  {"certificate_file", DT_PATH, R_NONE, UL & SslCertFile,
+   UL "~/.mutt_certificates"},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS or GNUTLS
+   **
+   ** .pp
+   ** This variable specifies the file where the certificates you trust
+   ** are saved. When an unknown certificate is encountered, you are asked
+   ** if you accept it or not. If you accept it, the certificate can also 
+   ** be saved in this file and further connections are automatically 
+   ** accepted.
+   ** .pp
+   ** You can also manually add CA certificates in this file. Any server
+   ** certificate that is signed with one of these CA certificates are 
+   ** also automatically accepted.
+   ** .pp
+   ** Example: set certificate_file=~/.mutt/certificates
+   */
+# ifndef USE_GNUTLS
+  {"ssl_usesystemcerts", DT_BOOL, R_NONE, OPTSSLSYSTEMCERTS, 1},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS
+   **
+   ** .pp
+   ** If set to \fIyes\fP, Mutt-ng will use CA certificates in the
+   ** system-wide certificate store when checking if server certificate 
+   ** is signed by a trusted CA.
+   */
+  {"entropy_file", DT_PATH, R_NONE, UL & SslEntropyFile, 0},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS
+   **
+   ** .pp
+   ** The file which includes random data that is used to initialize SSL
+   ** library functions.
+   */
+  {"ssl_use_sslv2", DT_BOOL, R_NONE, OPTSSLV2, 1},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS
+   **
+   ** .pp
+   ** This variables specifies whether to attempt to use SSLv2 in the
+   ** SSL authentication process.
+   */
+# endif
+  {"ssl_use_sslv3", DT_BOOL, R_NONE, OPTSSLV3, 1},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS or GNUTLS
+   **
+   ** .pp
+   ** This variables specifies whether to attempt to use SSLv3 in the
+   ** SSL authentication process.
+   */
+  {"ssl_use_tlsv1", DT_BOOL, R_NONE, OPTTLSV1, 1},
+  /*
+   ** .pp
+   ** Availability: SSL or NSS or GNUTLS
+   **
+   ** .pp
+   ** This variables specifies whether to attempt to use TLSv1 in the
+   ** SSL authentication process.
+   */
+#ifdef USE_GNUTLS
+  {"ssl_min_dh_prime_bits", DT_NUM, R_NONE, UL & SslDHPrimeBits, 0},
+  /*
+   ** .pp
+   ** Availability: GNUTLS
+   **
+   ** .pp
+   ** This variable specifies the minimum acceptable prime size (in bits)
+   ** for use in any Diffie-Hellman key exchange. A value of 0 will use
+   ** the default from the GNUTLS library.
+   */
+  {"ssl_ca_certificates_file", DT_PATH, R_NONE, UL & SslCACertFile, 0},
+  /*
+   ** .pp
+   ** This variable specifies a file containing trusted CA certificates.
+   ** Any server certificate that is signed with one of these CA
+   ** certificates are also automatically accepted.
+   ** .pp
+   ** Example: set ssl_ca_certificates_file=/etc/ssl/certs/ca-certificates.crt
+   */
+#endif
+#endif
+  {"pipe_split", DT_BOOL, R_NONE, OPTPIPESPLIT, 0},
+  /*
+   ** .pp
+   ** Used in connection with the \fIpipe-message\fP command and the ``tag-
+   ** prefix'' operator.  If this variable is unset, when piping a list of
+   ** tagged messages Mutt-ng will concatenate the messages and will pipe them
+   ** as a single folder.  When set, Mutt-ng will pipe the messages one by one.
+   ** In both cases the messages are piped in the current sorted order,
+   ** and the ``$$pipe_sep'' separator is added after each message.
+   */
+  {"pipe_decode", DT_BOOL, R_NONE, OPTPIPEDECODE, 0},
   /*
-  ** .pp
-  ** Controls whether or not empty lines will be quoted using
-  ** ``$indent_string''.
-  */
-  { "quote_quoted",    DT_BOOL, R_NONE, OPTQUOTEQUOTED, 0 },
+   ** .pp
+   ** Used in connection with the \fIpipe-message\fP command.  When unset,
+   ** Mutt-ng will pipe the messages without any preprocessing. When set, Mutt-ng
+   ** will weed headers and will attempt to PGP/MIME decode the messages
+   ** first.
+   */
+  {"pipe_sep", DT_STR, R_NONE, UL & PipeSep, UL "\n"},
   /*
-  ** .pp
-  ** Controls how quoted lines will be quoted. If set, one quote
-  ** character will be added to the end of existing prefix.  Otherwise,
-  ** quoted lines will be prepended by ``$indent_string''.
-  */
-  { "quote_regexp",    DT_RX,   R_PAGER, UL &QuoteRegexp, UL "^([ \t]*[|>:}#])+" },
+   ** .pp
+   ** The separator to add between messages when piping a list of tagged
+   ** messages to an external Unix command.
+   */
+#ifdef USE_POP
+  {"pop_authenticators", DT_STR, R_NONE, UL & PopAuthenticators, UL 0},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** This is a colon-delimited list of authentication methods Mutt-ng may
+   ** attempt to use to log in to an POP server, in the order Mutt-ng should
+   ** try them.  Authentication methods are either 'user', 'apop' or any
+   ** SASL mechanism, eg 'digest-md5', 'gssapi' or 'cram-md5'.
+   ** This parameter is case-insensitive. If this parameter is unset
+   ** (the default) Mutt-ng will try all available methods, in order from
+   ** most-secure to least-secure.
+   ** .pp
+   ** Example: set pop_authenticators="digest-md5:apop:user"
+   */
+  {"pop_auth_try_all", DT_BOOL, R_NONE, OPTPOPAUTHTRYALL, 1},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** If set, Mutt-ng will try all available methods. When unset, Mutt-ng will
+   ** only fall back to other authentication methods if the previous
+   ** methods are unavailable. If a method is available but authentication
+   ** fails, Mutt-ng will not connect to the POP server.
+   */
+  {"pop_checkinterval", DT_NUM, R_NONE, UL & PopCheckTimeout, 60},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** This variable configures how often (in seconds) POP should look for
+   ** new mail.
+   */
+  {"pop_delete", DT_QUAD, R_NONE, OPT_POPDELETE, M_ASKNO},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** If set, Mutt-ng will delete successfully downloaded messages from the POP
+   ** server when using the fetch-mail function.  When unset, Mutt-ng will
+   ** download messages but also leave them on the POP server.
+   */
+  {"pop_host", DT_STR, R_NONE, UL & PopHost, UL ""},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** The name of your POP server for the fetch-mail function.  You
+   ** can also specify an alternative port, username and password, ie:
+   ** .pp
+   ** [pop[s]://][username[:password]@]popserver[:port]
+   */
+  {"pop_last", DT_BOOL, R_NONE, OPTPOPLAST, 0},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** If this variable is set, Mutt-ng will try to use the "LAST" POP command
+   ** for retrieving only unread messages from the POP server when using
+   ** the fetch-mail function.
+   */
+  {"pop_reconnect", DT_QUAD, R_NONE, OPT_POPRECONNECT, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** Controls whether or not Mutt-ng will try to reconnect to POP server when
+   ** connection lost.
+   */
+  {"pop_user", DT_STR, R_NONE, UL & PopUser, 0},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** Your login name on the POP server.
+   ** .pp
+   ** This variable defaults to your user name on the local machine.
+   */
+  {"pop_pass", DT_STR, R_NONE, UL & PopPass, UL ""},
+  /*
+   ** .pp
+   ** Availability: POP
+   **
+   ** .pp
+   ** Specifies the password for your POP account.  If unset, Mutt-ng will
+   ** prompt you for your password when you open POP mailbox.
+   ** \fBWarning\fP: you should only use this option when you are on a
+   ** fairly secure machine, because the superuser can read your muttngrc
+   ** even if you are the only one who can read the file.
+   */
+#endif /* USE_POP */
+  {"post_indent_string", DT_STR, R_NONE, UL & PostIndentString, UL ""},
   /*
-  ** .pp
-  ** A regular expression used in the internal-pager to determine quoted
-  ** sections of text in the body of a message.
-  ** .pp
-  ** \fBNote:\fP In order to use the \fIquoted\fP\fBx\fP patterns in the
-  ** internal pager, you need to set this to a regular expression that
-  ** matches \fIexactly\fP the quote characters at the beginning of quoted
-  ** lines.
-  */
-  { "read_inc",                DT_NUM,  R_NONE, UL &ReadInc, 10 },
+   ** .pp
+   ** Similar to the ``$$attribution'' variable, Mutt-ng will append this
+   ** string after the inclusion of a message which is being replied to.
+   */
+  {"post_indent_str", DT_SYN, R_NONE, UL "post_indent_string", 0},
   /*
-  ** .pp
-  ** If set to a value greater than 0, Mutt-ng will display which message it
-  ** is currently on when reading a mailbox.  The message is printed after
-  ** \fIread_inc\fP messages have been read (e.g., if set to 25, Mutt-ng will
-  ** print a message when it reads message 25, and then again when it gets
-  ** to message 50).  This variable is meant to indicate progress when
-  ** reading large mailboxes which may take some time.
-  ** When set to 0, only a single message will appear before the reading
-  ** the mailbox.
-  ** .pp
-  ** Also see the ``$$write_inc'' variable.
-  */
-  { "read_only",       DT_BOOL, R_NONE, OPTREADONLY, 0 },
+   */
+#ifdef USE_NNTP
+  {"post_moderated", DT_QUAD, R_NONE, OPT_TOMODERATED, M_ASKYES},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If set to \fIyes\fP, Mutt-ng will post article to newsgroup that have
+   ** not permissions to posting (e.g. moderated).  \fBNote:\fP if newsserver
+   ** does not support posting to that newsgroup or totally read-only, that
+   ** posting will not have an effect.
+   */
+#endif
+  {"postpone", DT_QUAD, R_NONE, OPT_POSTPONE, M_ASKYES},
   /*
-  ** .pp
-  ** If set, all folders are opened in read-only mode.
-  */
-  { "realname",                DT_STR,  R_BOTH, UL &Realname, 0 },
+   ** .pp
+   ** Controls whether or not messages are saved in the ``$$postponed''
+   ** mailbox when you elect not to send immediately.
+   */
+  {"postponed", DT_PATH, R_NONE, UL & Postponed, UL "~/postponed"},
   /*
-  ** .pp
-  ** This variable specifies what "real" or "personal" name should be used
-  ** when sending messages.
-  ** .pp
-  ** By default, this is the GECOS field from /etc/passwd.  Note that this
-  ** variable will \fInot\fP be used when the user has set a real name
-  ** in the $$from variable.
-  */
-  { "recall",          DT_QUAD, R_NONE, OPT_RECALL, M_ASKYES },
+   ** .pp
+   ** Mutt-ng allows you to indefinitely ``$postpone sending a message'' which
+   ** you are editing.  When you choose to postpone a message, Mutt-ng saves it
+   ** in the mailbox specified by this variable.  Also see the ``$$postpone''
+   ** variable.
+   */
+#ifdef USE_SOCKET
+  {"preconnect", DT_STR, R_NONE, UL & Preconnect, UL 0},
+  /*
+   ** .pp
+   ** If set, a shell command to be executed if Mutt-ng fails to establish
+   ** a connection to the server. This is useful for setting up secure
+   ** connections, e.g. with ssh(1). If the command returns a  nonzero
+   ** status, Mutt-ng gives up opening the server. Example:
+   ** .pp
+   ** preconnect="ssh -f -q -L 1234:mailhost.net:143 mailhost.net
+   **                   sleep 20 < /dev/null > /dev/null"
+   ** .pp
+   ** Mailbox 'foo' on mailhost.net can now be reached
+   ** as '{localhost:1234}foo'.
+   ** .pp
+   ** NOTE: For this example to work, you must be able to log in to the
+   ** remote machine without having to enter a password.
+   */
+#endif /* USE_SOCKET */
+  {"print", DT_QUAD, R_NONE, OPT_PRINT, M_ASKNO},
   /*
-  ** .pp
-  ** Controls whether or not Mutt-ng recalls postponed messages
-  ** when composing a new message.  Also see ``$$postponed''.
-  ** .pp
-  ** Setting this variable to ``yes'' is not generally useful, and thus not
-  ** recommended.
-  */
-  { "record",          DT_PATH, R_NONE, UL &Outbox, UL "" },
+   ** .pp
+   ** Controls whether or not Mutt-ng really prints messages.
+   ** This is set to \fIask-no\fP by default, because some people
+   ** accidentally hit ``p'' often (like me).
+   */
+  {"print_command", DT_PATH, R_NONE, UL & PrintCmd, UL "lpr"},
   /*
-  ** .pp
-  ** This specifies the file into which your outgoing messages should be
-  ** appended.  (This is meant as the primary method for saving a copy of
-  ** your messages, but another way to do this is using the ``$my_hdr''
-  ** command to create a \fIBcc:\fP field with your email address in it.)
-  ** .pp
-  ** The value of \fI$$record\fP is overridden by the ``$$force_name'' and
-  ** ``$$save_name'' variables, and the ``$fcc-hook'' command.
-  */
-  { "reply_regexp",    DT_RX,   R_INDEX|R_RESORT, UL &ReplyRegexp, UL "^(re([\\[0-9\\]+])*|aw):[ \t]*" },
+   ** .pp
+   ** This specifies the command pipe that should be used to print messages.
+   */
+  {"print_cmd", DT_SYN, R_NONE, UL "print_command", 0},
   /*
-  ** .pp
-  ** A regular expression used to recognize reply messages when threading
-  ** and replying. The default value corresponds to the English "Re:" and
-  ** the German "Aw:".
-  */
-  { "reply_self",      DT_BOOL, R_NONE, OPTREPLYSELF, 0 },
+   */
+  {"print_decode", DT_BOOL, R_NONE, OPTPRINTDECODE, 1},
+  /*
+   ** .pp
+   ** Used in connection with the print-message command.  If this
+   ** option is set, the message is decoded before it is passed to the
+   ** external command specified by $$print_command.  If this option
+   ** is unset, no processing will be applied to the message when
+   ** printing it.  The latter setting may be useful if you are using
+   ** some advanced printer filter which is able to properly format
+   ** e-mail messages for printing.
+   */
+  {"print_split", DT_BOOL, R_NONE, OPTPRINTSPLIT, 0},
+  /*
+   ** .pp
+   ** Used in connection with the print-message command.  If this option
+   ** is set, the command specified by $$print_command is executed once for
+   ** each message which is to be printed.  If this option is unset, 
+   ** the command specified by $$print_command is executed only once, and
+   ** all the messages are concatenated, with a form feed as the message
+   ** separator.
+   ** .pp
+   ** Those who use the \fBenscript\fP(1) program's mail-printing mode will
+   ** most likely want to set this option.
+   */
+  {"prompt_after", DT_BOOL, R_NONE, OPTPROMPTAFTER, 1},
   /*
-  ** .pp
-  ** If unset and you are replying to a message sent by you, Mutt-ng will
-  ** assume that you want to reply to the recipients of that message rather
-  ** than to yourself.
-  */
-  { "reply_to",                DT_QUAD, R_NONE, OPT_REPLYTO, M_ASKYES },
+   ** .pp
+   ** If you use an \fIexternal\fP ``$$pager'', setting this variable will
+   ** cause Mutt-ng to prompt you for a command when the pager exits rather
+   ** than returning to the index menu.  If unset, Mutt-ng will return to the
+   ** index menu when the external pager exits.
+   */
+  {"query_command", DT_PATH, R_NONE, UL & QueryCmd, UL ""},
   /*
-  ** .pp
-  ** If set, when replying to a message, Mutt-ng will use the address listed
-  ** in the Reply-to: header as the recipient of the reply.  If unset,
-  ** it will use the address in the From: header field instead.  This
-  ** option is useful for reading a mailing list that sets the Reply-To:
-  ** header field to the list address and you want to send a private
-  ** message to the author of a message.
-  */
-  { "resolve",         DT_BOOL, R_NONE, OPTRESOLVE, 1 },
+   ** .pp
+   ** This specifies the command that Mutt-ng will use to make external address
+   ** queries.  The string should contain a %s, which will be substituted
+   ** with the query string the user types.  See ``$query'' for more
+   ** information.
+   */
+  {"quit", DT_QUAD, R_NONE, OPT_QUIT, M_YES},
   /*
-  ** .pp
-  ** When set, the cursor will be automatically advanced to the next
-  ** (possibly undeleted) message whenever a command that modifies the
-  ** current message is executed.
-  */
-  { "reverse_alias",   DT_BOOL, R_BOTH, OPTREVALIAS, 0 },
+   ** .pp
+   ** This variable controls whether ``quit'' and ``exit'' actually quit
+   ** from Mutt-ng.  If it set to yes, they do quit, if it is set to no, they
+   ** have no effect, and if it is set to ask-yes or ask-no, you are
+   ** prompted for confirmation when you try to quit.
+   */
+  {"quote_empty", DT_BOOL, R_NONE, OPTQUOTEEMPTY, 1},
   /*
-  ** .pp
-  ** This variable controls whether or not Mutt-ng will display the "personal"
-  ** name from your aliases in the index menu if it finds an alias that
-  ** matches the message's sender.  For example, if you have the following
-  ** alias:
-  ** .pp
-  ** .ts
-  **  alias juser abd30425@somewhere.net (Joe User)
-  ** .te
-  ** .pp
-  ** and then you receive mail which contains the following header:
-  ** .pp
-  ** .ts
-  **  From: abd30425@somewhere.net
-  ** .te
-  ** .pp
-  ** It would be displayed in the index menu as ``Joe User'' instead of
-  ** ``abd30425@somewhere.net.''  This is useful when the person's e-mail
-  ** address is not human friendly (like CompuServe addresses).
-  */
-  { "reverse_name",    DT_BOOL, R_BOTH, OPTREVNAME, 0 },
+   ** .pp
+   ** Controls whether or not empty lines will be quoted using
+   ** ``$indent_string''.
+   */
+  {"quote_quoted", DT_BOOL, R_NONE, OPTQUOTEQUOTED, 0},
   /*
-  ** .pp
-  ** It may sometimes arrive that you receive mail to a certain machine,
-  ** move the messages to another machine, and reply to some the messages
-  ** from there.  If this variable is set, the default \fIFrom:\fP line of
-  ** the reply messages is built using the address where you received the
-  ** messages you are replying to \fBif\fP that address matches your
-  ** alternates.  If the variable is unset, or the address that would be
-  ** used doesn't match your alternates, the \fIFrom:\fP line will use
-  ** your address on the current machine.
-  */
-  { "reverse_realname",        DT_BOOL, R_BOTH, OPTREVREAL, 1 },
+   ** .pp
+   ** Controls how quoted lines will be quoted. If set, one quote
+   ** character will be added to the end of existing prefix.  Otherwise,
+   ** quoted lines will be prepended by ``$indent_string''.
+   */
+  {"quote_regexp", DT_RX, R_PAGER, UL & QuoteRegexp, UL "^([ \t]*[|>:}#])+"},
+  /*
+   ** .pp
+   ** A regular expression used in the internal-pager to determine quoted
+   ** sections of text in the body of a message.
+   ** .pp
+   ** \fBNote:\fP In order to use the \fIquoted\fP\fBx\fP patterns in the
+   ** internal pager, you need to set this to a regular expression that
+   ** matches \fIexactly\fP the quote characters at the beginning of quoted
+   ** lines.
+   */
+  {"read_inc", DT_NUM, R_NONE, UL & ReadInc, 10},
+  /*
+   ** .pp
+   ** If set to a value greater than 0, Mutt-ng will display which message it
+   ** is currently on when reading a mailbox.  The message is printed after
+   ** \fIread_inc\fP messages have been read (e.g., if set to 25, Mutt-ng will
+   ** print a message when it reads message 25, and then again when it gets
+   ** to message 50).  This variable is meant to indicate progress when
+   ** reading large mailboxes which may take some time.
+   ** When set to 0, only a single message will appear before the reading
+   ** the mailbox.
+   ** .pp
+   ** Also see the ``$$write_inc'' variable.
+   */
+  {"read_only", DT_BOOL, R_NONE, OPTREADONLY, 0},
   /*
-  ** .pp
-  ** This variable fine-tunes the behaviour of the $reverse_name feature.
-  ** When it is set, Mutt-ng will use the address from incoming messages as-is,
-  ** possibly including eventual real names.  When it is unset, Mutt-ng will
-  ** override any such real names with the setting of the $realname variable.
-  */
-  { "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
+   ** .pp
+   ** If set, all folders are opened in read-only mode.
+   */
+  {"realname", DT_STR, R_BOTH, UL & Realname, 0},
+  /*
+   ** .pp
+   ** This variable specifies what "real" or "personal" name should be used
+   ** when sending messages.
+   ** .pp
+   ** By default, this is the GECOS field from /etc/passwd.  Note that this
+   ** variable will \fInot\fP be used when the user has set a real name
+   ** in the $$from variable.
+   */
+  {"recall", DT_QUAD, R_NONE, OPT_RECALL, M_ASKYES},
+  /*
+   ** .pp
+   ** Controls whether or not Mutt-ng recalls postponed messages
+   ** when composing a new message.  Also see ``$$postponed''.
+   ** .pp
+   ** Setting this variable to ``yes'' is not generally useful, and thus not
+   ** recommended.
+   */
+  {"record", DT_PATH, R_NONE, UL & Outbox, UL ""},
+  /*
+   ** .pp
+   ** This specifies the file into which your outgoing messages should be
+   ** appended.  (This is meant as the primary method for saving a copy of
+   ** your messages, but another way to do this is using the ``$my_hdr''
+   ** command to create a \fIBcc:\fP field with your email address in it.)
+   ** .pp
+   ** The value of \fI$$record\fP is overridden by the ``$$force_name'' and
+   ** ``$$save_name'' variables, and the ``$fcc-hook'' command.
+   */
+  {"reply_regexp", DT_RX, R_INDEX | R_RESORT, UL & ReplyRegexp,
+   UL "^(re([\\[0-9\\]+])*|aw):[ \t]*"},
   /*
-  ** .pp
-  ** When this variable is set, Mutt-ng will decode RFC-2047-encoded MIME 
-  ** parameters. You want to set this variable when Mutt-ng suggests you
-  ** to save attachments to files named like this: 
-  ** =?iso-8859-1?Q?file=5F=E4=5F991116=2Ezip?=
-  ** .pp
-  ** When this variable is set interactively, the change doesn't have
-  ** the desired effect before you have changed folders.
-  ** .pp
-  ** Note that this use of RFC 2047's encoding is explicitly,
-  ** prohibited by the standard, but nevertheless encountered in the
-  ** wild.
-  ** Also note that setting this parameter will \fInot\fP have the effect 
-  ** that Mutt-ng \fIgenerates\fP this kind of encoding.  Instead, Mutt-ng will
-  ** unconditionally use the encoding specified in RFC 2231.
-  */
-  { "save_address",    DT_BOOL, R_NONE, OPTSAVEADDRESS, 0 },
+   ** .pp
+   ** A regular expression used to recognize reply messages when threading
+   ** and replying. The default value corresponds to the English "Re:" and
+   ** the German "Aw:".
+   */
+  {"reply_self", DT_BOOL, R_NONE, OPTREPLYSELF, 0},
   /*
-  ** .pp
-  ** If set, Mutt-ng will take the sender's full address when choosing a
-  ** default folder for saving a mail. If ``$$save_name'' or ``$$force_name''
-  ** is set too, the selection of the fcc folder will be changed as well.
-  */
-  { "save_empty",      DT_BOOL, R_NONE, OPTSAVEEMPTY, 1 },
+   ** .pp
+   ** If unset and you are replying to a message sent by you, Mutt-ng will
+   ** assume that you want to reply to the recipients of that message rather
+   ** than to yourself.
+   */
+  {"reply_to", DT_QUAD, R_NONE, OPT_REPLYTO, M_ASKYES},
+  /*
+   ** .pp
+   ** If set, when replying to a message, Mutt-ng will use the address listed
+   ** in the Reply-to: header as the recipient of the reply.  If unset,
+   ** it will use the address in the From: header field instead.  This
+   ** option is useful for reading a mailing list that sets the Reply-To:
+   ** header field to the list address and you want to send a private
+   ** message to the author of a message.
+   */
+  {"resolve", DT_BOOL, R_NONE, OPTRESOLVE, 1},
   /*
-  ** .pp
-  ** When unset, mailboxes which contain no saved messages will be removed
-  ** when closed (the exception is ``$$spoolfile'' which is never removed).
-  ** If set, mailboxes are never removed.
-  ** .pp
-  ** \fBNote:\fP This only applies to mbox and MMDF folders, Mutt-ng does not
-  ** delete MH and Maildir directories.
-  */
-  { "save_name",       DT_BOOL, R_NONE, OPTSAVENAME, 0 },
+   ** .pp
+   ** When set, the cursor will be automatically advanced to the next
+   ** (possibly undeleted) message whenever a command that modifies the
+   ** current message is executed.
+   */
+  {"reverse_alias", DT_BOOL, R_BOTH, OPTREVALIAS, 0},
+  /*
+   ** .pp
+   ** This variable controls whether or not Mutt-ng will display the "personal"
+   ** name from your aliases in the index menu if it finds an alias that
+   ** matches the message's sender.  For example, if you have the following
+   ** alias:
+   ** .pp
+   ** .ts
+   **  alias juser abd30425@somewhere.net (Joe User)
+   ** .te
+   ** .pp
+   ** and then you receive mail which contains the following header:
+   ** .pp
+   ** .ts
+   **  From: abd30425@somewhere.net
+   ** .te
+   ** .pp
+   ** It would be displayed in the index menu as ``Joe User'' instead of
+   ** ``abd30425@somewhere.net.''  This is useful when the person's e-mail
+   ** address is not human friendly (like CompuServe addresses).
+   */
+  {"reverse_name", DT_BOOL, R_BOTH, OPTREVNAME, 0},
+  /*
+   ** .pp
+   ** It may sometimes arrive that you receive mail to a certain machine,
+   ** move the messages to another machine, and reply to some the messages
+   ** from there.  If this variable is set, the default \fIFrom:\fP line of
+   ** the reply messages is built using the address where you received the
+   ** messages you are replying to \fBif\fP that address matches your
+   ** alternates.  If the variable is unset, or the address that would be
+   ** used doesn't match your alternates, the \fIFrom:\fP line will use
+   ** your address on the current machine.
+   */
+  {"reverse_realname", DT_BOOL, R_BOTH, OPTREVREAL, 1},
   /*
-  ** .pp
-  ** This variable controls how copies of outgoing messages are saved.
-  ** When set, a check is made to see if a mailbox specified by the
-  ** recipient address exists (this is done by searching for a mailbox in
-  ** the ``$$folder'' directory with the \fIusername\fP part of the
-  ** recipient address).  If the mailbox exists, the outgoing message will
-  ** be saved to that mailbox, otherwise the message is saved to the
-  ** ``$$record'' mailbox.
-  ** .pp
-  ** Also see the ``$$force_name'' variable.
-  */
-  { "score",           DT_BOOL, R_NONE, OPTSCORE, 1 },
+   ** .pp
+   ** This variable fine-tunes the behaviour of the $reverse_name feature.
+   ** When it is set, Mutt-ng will use the address from incoming messages as-is,
+   ** possibly including eventual real names.  When it is unset, Mutt-ng will
+   ** override any such real names with the setting of the $realname variable.
+   */
+  {"rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0},
+  /*
+   ** .pp
+   ** When this variable is set, Mutt-ng will decode RFC-2047-encoded MIME 
+   ** parameters. You want to set this variable when Mutt-ng suggests you
+   ** to save attachments to files named like this: 
+   ** =?iso-8859-1?Q?file=5F=E4=5F991116=2Ezip?=
+   ** .pp
+   ** When this variable is set interactively, the change doesn't have
+   ** the desired effect before you have changed folders.
+   ** .pp
+   ** Note that this use of RFC 2047's encoding is explicitly,
+   ** prohibited by the standard, but nevertheless encountered in the
+   ** wild.
+   ** Also note that setting this parameter will \fInot\fP have the effect 
+   ** that Mutt-ng \fIgenerates\fP this kind of encoding.  Instead, Mutt-ng will
+   ** unconditionally use the encoding specified in RFC 2231.
+   */
+  {"save_address", DT_BOOL, R_NONE, OPTSAVEADDRESS, 0},
   /*
-  ** .pp
-  ** When this variable is \fIunset\fP, scoring is turned off.  This can
-  ** be useful to selectively disable scoring for certain folders when the
-  ** ``$$score_threshold_delete'' variable and friends are used.
-  **
-  */
-  { "score_threshold_delete", DT_NUM, R_NONE, UL &ScoreThresholdDelete, UL -1 },
+   ** .pp
+   ** If set, Mutt-ng will take the sender's full address when choosing a
+   ** default folder for saving a mail. If ``$$save_name'' or ``$$force_name''
+   ** is set too, the selection of the fcc folder will be changed as well.
+   */
+  {"save_empty", DT_BOOL, R_NONE, OPTSAVEEMPTY, 1},
+  /*
+   ** .pp
+   ** When unset, mailboxes which contain no saved messages will be removed
+   ** when closed (the exception is ``$$spoolfile'' which is never removed).
+   ** If set, mailboxes are never removed.
+   ** .pp
+   ** \fBNote:\fP This only applies to mbox and MMDF folders, Mutt-ng does not
+   ** delete MH and Maildir directories.
+   */
+  {"save_name", DT_BOOL, R_NONE, OPTSAVENAME, 0},
+  /*
+   ** .pp
+   ** This variable controls how copies of outgoing messages are saved.
+   ** When set, a check is made to see if a mailbox specified by the
+   ** recipient address exists (this is done by searching for a mailbox in
+   ** the ``$$folder'' directory with the \fIusername\fP part of the
+   ** recipient address).  If the mailbox exists, the outgoing message will
+   ** be saved to that mailbox, otherwise the message is saved to the
+   ** ``$$record'' mailbox.
+   ** .pp
+   ** Also see the ``$$force_name'' variable.
+   */
+  {"score", DT_BOOL, R_NONE, OPTSCORE, 1},
   /*
-  ** .pp
-  ** Messages which have been assigned a score equal to or lower than the value
-  ** of this variable are automatically marked for deletion by Mutt-ng.  Since
-  ** Mutt-ng scores are always greater than or equal to zero, the default setting
-  ** of this variable will never mark a message for deletion.
-  */
-  { "score_threshold_flag", DT_NUM, R_NONE, UL &ScoreThresholdFlag, 9999 },
+   ** .pp
+   ** When this variable is \fIunset\fP, scoring is turned off.  This can
+   ** be useful to selectively disable scoring for certain folders when the
+   ** ``$$score_threshold_delete'' variable and friends are used.
+   **
+   */
+  {"score_threshold_delete", DT_NUM, R_NONE, UL & ScoreThresholdDelete,
+   UL - 1},
+  /*
+   ** .pp
+   ** Messages which have been assigned a score equal to or lower than the value
+   ** of this variable are automatically marked for deletion by Mutt-ng.  Since
+   ** Mutt-ng scores are always greater than or equal to zero, the default setting
+   ** of this variable will never mark a message for deletion.
+   */
+  {"score_threshold_flag", DT_NUM, R_NONE, UL & ScoreThresholdFlag, 9999},
   /* 
-  ** .pp
-  ** Messages which have been assigned a score greater than or equal to this 
-  ** variable's value are automatically marked "flagged".
-  */
-  { "score_threshold_read", DT_NUM, R_NONE, UL &ScoreThresholdRead, UL -1 },
-  /*
-  ** .pp
-  ** Messages which have been assigned a score equal to or lower than the value
-  ** of this variable are automatically marked as read by Mutt-ng.  Since
-  ** Mutt-ng scores are always greater than or equal to zero, the default setting
-  ** of this variable will never mark a message read.
-  */
-  { "send_charset",    DT_STR,  R_NONE, UL &SendCharset, UL "us-ascii:iso-8859-1:utf-8" },
-  /*
-  ** .pp
-  ** A list of character sets for outgoing messages. Mutt-ng will use the
-  ** first character set into which the text can be converted exactly.
-  ** If your ``$$charset'' is not iso-8859-1 and recipients may not
-  ** understand UTF-8, it is advisable to include in the list an
-  ** appropriate widely used standard character set (such as
-  ** iso-8859-2, koi8-r or iso-2022-jp) either instead of or after
-  ** "iso-8859-1".
-  */
-  { "sendmail",                DT_PATH, R_NONE, UL &Sendmail, UL SENDMAIL " -oem -oi" },
+   ** .pp
+   ** Messages which have been assigned a score greater than or equal to this 
+   ** variable's value are automatically marked "flagged".
+   */
+  {"score_threshold_read", DT_NUM, R_NONE, UL & ScoreThresholdRead, UL - 1},
   /*
-  ** .pp
-  ** Specifies the program and arguments used to deliver mail sent by Mutt-ng.
-  ** Mutt-ng expects that the specified program interprets additional
-  ** arguments as recipient addresses.
-  */
-  { "sendmail_wait",   DT_NUM,  R_NONE, UL &SendmailWait, 0 },
+   ** .pp
+   ** Messages which have been assigned a score equal to or lower than the value
+   ** of this variable are automatically marked as read by Mutt-ng.  Since
+   ** Mutt-ng scores are always greater than or equal to zero, the default setting
+   ** of this variable will never mark a message read.
+   */
+  {"send_charset", DT_STR, R_NONE, UL & SendCharset,
+   UL "us-ascii:iso-8859-1:utf-8"},
+  /*
+   ** .pp
+   ** A list of character sets for outgoing messages. Mutt-ng will use the
+   ** first character set into which the text can be converted exactly.
+   ** If your ``$$charset'' is not iso-8859-1 and recipients may not
+   ** understand UTF-8, it is advisable to include in the list an
+   ** appropriate widely used standard character set (such as
+   ** iso-8859-2, koi8-r or iso-2022-jp) either instead of or after
+   ** "iso-8859-1".
+   */
+  {"sendmail", DT_PATH, R_NONE, UL & Sendmail, UL SENDMAIL " -oem -oi"},
   /*
-  ** .pp
-  ** Specifies the number of seconds to wait for the ``$$sendmail'' process
-  ** to finish before giving up and putting delivery in the background.
-  ** .pp
-  ** Mutt-ng interprets the value of this variable as follows:
-  ** .dl
-  ** .dt >0 .dd number of seconds to wait for sendmail to finish before continuing
-  ** .dt 0  .dd wait forever for sendmail to finish
-  ** .dt <0 .dd always put sendmail in the background without waiting
-  ** .de
-  ** .pp
-  ** Note that if you specify a value other than 0, the output of the child
-  ** process will be put in a temporary file.  If there is some error, you
-  ** will be informed as to where to find the output.
-  */
-  { "shell",           DT_PATH, R_NONE, UL &Shell, 0 },
+   ** .pp
+   ** Specifies the program and arguments used to deliver mail sent by Mutt-ng.
+   ** Mutt-ng expects that the specified program interprets additional
+   ** arguments as recipient addresses.
+   */
+  {"sendmail_wait", DT_NUM, R_NONE, UL & SendmailWait, 0},
+  /*
+   ** .pp
+   ** Specifies the number of seconds to wait for the ``$$sendmail'' process
+   ** to finish before giving up and putting delivery in the background.
+   ** .pp
+   ** Mutt-ng interprets the value of this variable as follows:
+   ** .dl
+   ** .dt >0 .dd number of seconds to wait for sendmail to finish before continuing
+   ** .dt 0  .dd wait forever for sendmail to finish
+   ** .dt <0 .dd always put sendmail in the background without waiting
+   ** .de
+   ** .pp
+   ** Note that if you specify a value other than 0, the output of the child
+   ** process will be put in a temporary file.  If there is some error, you
+   ** will be informed as to where to find the output.
+   */
+  {"shell", DT_PATH, R_NONE, UL & Shell, 0},
   /*
-  ** .pp
-  ** Command to use when spawning a subshell.  By default, the user's login
-  ** shell from /etc/passwd is used.
-  */
+   ** .pp
+   ** Command to use when spawning a subshell.  By default, the user's login
+   ** shell from /etc/passwd is used.
+   */
 #ifdef USE_NNTP
-  { "save_unsubscribed",DT_BOOL, R_NONE, OPTSAVEUNSUB, 0 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
-  ** ``newsrc'' file and into cache.
-  */
+  {"save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** When \fIset\fP, info about unsubscribed newsgroups will be saved into
+   ** ``newsrc'' file and into cache.
+   */
 #endif
-  { "shorten_hierarchy", DT_BOOL, R_NONE, OPTSHORTENHIERARCHY, 0 },
-  /*
-  ** .pp
-  ** When \fIset\fP, the "hierarchy" of the sidebar entries will be shortened
-  ** only if they cannot be printed in full length (because ``$$sidebar_width''
-  ** is set to a too low value). For example, if the newsgroup name 
-  ** ``de.alt.sysadmin.recovery'' doesn't fit on the screen, it'll get shortened
-  ** ``d.a.s.recovery'' while ``de.alt.d0'' still would and thus will not get 
-  ** shortened.
-  */
+  {"shorten_hierarchy", DT_BOOL, R_NONE, OPTSHORTENHIERARCHY, 0},
+  /*
+   ** .pp
+   ** When \fIset\fP, the "hierarchy" of the sidebar entries will be shortened
+   ** only if they cannot be printed in full length (because ``$$sidebar_width''
+   ** is set to a too low value). For example, if the newsgroup name 
+   ** ``de.alt.sysadmin.recovery'' doesn't fit on the screen, it'll get shortened
+   ** ``d.a.s.recovery'' while ``de.alt.d0'' still would and thus will not get 
+   ** shortened.
+   */
 #ifdef USE_NNTP
-  { "show_new_news",  DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
-  ** the browser.  Otherwise, it will be done only once for a newsserver.
-  ** Also controls whether or not number of new articles of subscribed
-  ** newsgroups will be then checked.
-  */
-  { "show_only_unread",  DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If \fIset\fP, only subscribed newsgroups that contain unread articles
-  ** will be displayed in browser.
-  */
+  {"show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, 1},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If \fIset\fP, newsserver will be asked for new newsgroups on entering
+   ** the browser.  Otherwise, it will be done only once for a newsserver.
+   ** Also controls whether or not number of new articles of subscribed
+   ** newsgroups will be then checked.
+   */
+  {"show_only_unread", DT_BOOL, R_NONE, OPTSHOWONLYUNREAD, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If \fIset\fP, only subscribed newsgroups that contain unread articles
+   ** will be displayed in browser.
+   */
 #endif
-  { "sig_dashes",      DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
-  /*
-  ** .pp
-  ** If set, a line containing ``-- '' will be inserted before your
-  ** ``$$signature''.  It is \fBstrongly\fP recommended that you not unset
-  ** this variable unless your ``signature'' contains just your name.  The
-  ** reason for this is because many software packages use ``-- \n'' to
-  ** detect your signature.  For example, Mutt-ng has the ability to highlight
-  ** the signature in a different color in the builtin pager.
-  */
-  { "sig_on_top",      DT_BOOL, R_NONE, OPTSIGONTOP, 0},
-  /*
-  ** .pp
-  ** If set, the signature will be included before any quoted or forwarded
-  ** text.  It is \fBstrongly\fP recommended that you do not set this variable
-  ** unless you really know what you are doing, and are prepared to take
-  ** some heat from netiquette guardians.
-  */
-  { "signature",       DT_PATH, R_NONE, UL &Signature, UL "~/.signature" },
-  /*
-  ** .pp
-  ** Specifies the filename of your signature, which is appended to all
-  ** outgoing messages.   If the filename ends with a pipe (``|''), it is
-  ** assumed that filename is a shell command and input should be read from
-  ** its stdout.
-  */
-  { "signoff_string",  DT_STR, R_NONE, UL &SignOffString, UL 0 },
-  /*
-  ** .pp
-  ** If set, this string will be inserted before the signature. This is useful
-  ** for people that want to sign off every message they send with their name.
-  ** .pp
-  ** If you want to insert your website's URL, additional contact information or 
-  ** witty quotes into your mails, better use a signature file instead of
-  ** the signoff string.
-  */
-  { "simple_search",   DT_STR,  R_NONE, UL &SimpleSearch, UL "~f %s | ~s %s" },
-  /*
-  ** .pp
-  ** Specifies how Mutt-ng should expand a simple search into a real search
-  ** pattern.  A simple search is one that does not contain any of the ~
-  ** operators.  See ``$patterns'' for more information on search patterns.
-  ** .pp
-  ** For example, if you simply type joe at a search or limit prompt, Mutt-ng
-  ** will automatically expand it to the value specified by this variable.
-  ** For the default value it would be:
-  ** .pp
-  ** ~f joe | ~s joe
-  */
-  { "smart_wrap",      DT_BOOL, R_PAGER, OPTWRAP, 1 },
-  /*
-  ** .pp
-  ** Controls the display of lines longer than the screen width in the
-  ** internal pager. If set, long lines are wrapped at a word boundary.  If
-  ** unset, lines are simply wrapped at the screen edge. Also see the
-  ** ``$$markers'' variable.
-  */
-  { "smileys",         DT_RX,   R_PAGER, UL &Smileys, UL "(>From )|(:[-^]?[][)(><}{|/DP])" },
-  /*
-  ** .pp
-  ** The \fIpager\fP uses this variable to catch some common false
-  ** positives of ``$$quote_regexp'', most notably smileys in the beginning
-  ** of a line
-  */
-  { "sleep_time",      DT_NUM, R_NONE, UL &SleepTime, 1 },
-  /*
-  ** .pp
-  ** Specifies time, in seconds, to pause while displaying certain informational
-  ** messages, while moving from folder to folder and after expunging
-  ** messages from the current folder.  The default is to pause one second, so 
-  ** a value of zero for this option suppresses the pause.
-  */
-  { "sort",            DT_SORT, R_INDEX|R_RESORT, UL &Sort, SORT_DATE },
-  /*
-  ** .pp
-  ** Specifies how to sort messages in the \fIindex\fP menu.  Valid values
-  ** are:
-  ** .pp
-  ** .ts
-  ** .  date or date-sent
-  ** .  date-received
-  ** .  from
-  ** .  mailbox-order (unsorted)
-  ** .  score
-  ** .  size
-  ** .  spam
-  ** .  subject
-  ** .  threads
-  ** .  to
-  ** .te
-  ** .pp
-  ** You may optionally use the reverse- prefix to specify reverse sorting
-  ** order (example: set sort=reverse-date-sent).
-  */
-  { "sort_alias",      DT_SORT|DT_SORT_ALIAS,  R_NONE, UL &SortAlias, SORT_ALIAS },
-  /*
-  ** .pp
-  ** Specifies how the entries in the `alias' menu are sorted.  The
-  ** following are legal values:
-  ** .pp
-  ** .ts
-  ** .  address (sort alphabetically by email address)
-  ** .  alias (sort alphabetically by alias name)
-  ** .  unsorted (leave in order specified in .muttrc)
-  ** .te
-  */
-  { "sort_aux",                DT_SORT|DT_SORT_AUX, R_INDEX|R_RESORT_BOTH, UL &SortAux, SORT_DATE },
-  /*
-  ** .pp
-  ** When sorting by threads, this variable controls how threads are sorted
-  ** in relation to other threads, and how the branches of the thread trees
-  ** are sorted.  This can be set to any value that ``$$sort'' can, except
-  ** threads (in that case, Mutt-ng will just use date-sent).  You can also
-  ** specify the last- prefix in addition to the reverse- prefix, but last-
-  ** must come after reverse-.  The last- prefix causes messages to be
-  ** sorted against its siblings by which has the last descendant, using
-  ** the rest of sort_aux as an ordering.  For instance, set sort_aux=last-
-  ** date-received would mean that if a new message is received in a
-  ** thread, that thread becomes the last one displayed (or the first, if
-  ** you have set sort=reverse-threads.) Note: For reversed ``$$sort''
-  ** order $$sort_aux is reversed again (which is not the right thing to do,
-  ** but kept to not break any existing configuration setting).
-  */
-  { "sort_browser",    DT_SORT|DT_SORT_BROWSER, R_NONE, UL &BrowserSort, SORT_ALPHA },
-  /*
-  ** .pp
-  ** Specifies how to sort entries in the file browser.  By default, the
-  ** entries are sorted alphabetically.  Valid values:
-  ** .pp
-  ** .ts
-  ** .  alpha (alphabetically)
-  ** .  date
-  ** .  size
-  ** .  unsorted
-  ** .te
-  ** .pp
-  ** You may optionally use the reverse- prefix to specify reverse sorting
-  ** order (example: set sort_browser=reverse-date).
-  */
-  { "sort_re",         DT_BOOL, R_INDEX|R_RESORT|R_RESORT_INIT, OPTSORTRE, 1 },
-  /*
-  ** .pp
-  ** This variable is only useful when sorting by threads with
-  ** ``$$strict_threads'' unset.  In that case, it changes the heuristic
-  ** Mutt-ng uses to thread messages by subject.  With sort_re set, Mutt-ng will
-  ** only attach a message as the child of another message by subject if
-  ** the subject of the child message starts with a substring matching the
-  ** setting of ``$$reply_regexp''.  With sort_re unset, Mutt-ng will attach
-  ** the message whether or not this is the case, as long as the
-  ** non-``$$reply_regexp'' parts of both messages are identical.
-  */
-  { "spam_separator",   DT_STR, R_NONE, UL &SpamSep, UL "," },
+  {"sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1},
+  /*
+   ** .pp
+   ** If set, a line containing ``-- '' will be inserted before your
+   ** ``$$signature''.  It is \fBstrongly\fP recommended that you not unset
+   ** this variable unless your ``signature'' contains just your name.  The
+   ** reason for this is because many software packages use ``-- \n'' to
+   ** detect your signature.  For example, Mutt-ng has the ability to highlight
+   ** the signature in a different color in the builtin pager.
+   */
+  {"sig_on_top", DT_BOOL, R_NONE, OPTSIGONTOP, 0},
   /*
-  ** .pp
-  ** ``$spam_separator'' controls what happens when multiple spam headers
-  ** are matched: if unset, each successive header will overwrite any
-  ** previous matches value for the spam label. If set, each successive
-  ** match will append to the previous, using ``$spam_separator'' as a
-  ** separator.
-  */
-  { "spoolfile",       DT_PATH, R_NONE, UL &Spoolfile, 0 },
+   ** .pp
+   ** If set, the signature will be included before any quoted or forwarded
+   ** text.  It is \fBstrongly\fP recommended that you do not set this variable
+   ** unless you really know what you are doing, and are prepared to take
+   ** some heat from netiquette guardians.
+   */
+  {"signature", DT_PATH, R_NONE, UL & Signature, UL "~/.signature"},
   /*
-  ** .pp
-  ** If your spool mailbox is in a non-default place where Mutt-ng cannot find
-  ** it, you can specify its location with this variable.  Mutt-ng will
-  ** automatically set this variable to the value of the environment
-  ** variable $$$MAIL if it is not set.
-  */
-  { "status_chars",    DT_STR,  R_BOTH, UL &StChars, UL "-*%A" },
+   ** .pp
+   ** Specifies the filename of your signature, which is appended to all
+   ** outgoing messages.   If the filename ends with a pipe (``|''), it is
+   ** assumed that filename is a shell command and input should be read from
+   ** its stdout.
+   */
+  {"signoff_string", DT_STR, R_NONE, UL & SignOffString, UL 0},
+  /*
+   ** .pp
+   ** If set, this string will be inserted before the signature. This is useful
+   ** for people that want to sign off every message they send with their name.
+   ** .pp
+   ** If you want to insert your website's URL, additional contact information or 
+   ** witty quotes into your mails, better use a signature file instead of
+   ** the signoff string.
+   */
+  {"simple_search", DT_STR, R_NONE, UL & SimpleSearch, UL "~f %s | ~s %s"},
+  /*
+   ** .pp
+   ** Specifies how Mutt-ng should expand a simple search into a real search
+   ** pattern.  A simple search is one that does not contain any of the ~
+   ** operators.  See ``$patterns'' for more information on search patterns.
+   ** .pp
+   ** For example, if you simply type joe at a search or limit prompt, Mutt-ng
+   ** will automatically expand it to the value specified by this variable.
+   ** For the default value it would be:
+   ** .pp
+   ** ~f joe | ~s joe
+   */
+  {"smart_wrap", DT_BOOL, R_PAGER, OPTWRAP, 1},
   /*
-  ** .pp
-  ** Controls the characters used by the "%r" indicator in
-  ** ``$$status_format''. The first character is used when the mailbox is
-  ** unchanged. The second is used when the mailbox has been changed, and
-  ** it needs to be resynchronized. The third is used if the mailbox is in
-  ** read-only mode, or if the mailbox will not be written when exiting
-  ** that mailbox (You can toggle whether to write changes to a mailbox
-  ** with the toggle-write operation, bound by default to "%"). The fourth
-  ** is used to indicate that the current folder has been opened in attach-
-  ** message mode (Certain operations like composing a new mail, replying,
-  ** forwarding, etc. are not permitted in this mode).
-  */
-  { "status_format",   DT_STR,  R_BOTH, UL &Status, UL "-%r-Mutt-ng: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---" },
+   ** .pp
+   ** Controls the display of lines longer than the screen width in the
+   ** internal pager. If set, long lines are wrapped at a word boundary.  If
+   ** unset, lines are simply wrapped at the screen edge. Also see the
+   ** ``$$markers'' variable.
+   */
+  {"smileys", DT_RX, R_PAGER, UL & Smileys,
+   UL "(>From )|(:[-^]?[][)(><}{|/DP])"},
   /*
-  ** .pp
-  ** Controls the format of the status line displayed in the \fIindex\fP
-  ** menu.  This string is similar to ``$$index_format'', but has its own
-  ** set of printf()-like sequences:
-  ** .pp
-  ** .dl
-  ** .dt %b  .dd number of mailboxes with new mail *
-  ** .dt %B  .dd the short pathname of the current mailbox
-  ** .dt %d  .dd number of deleted messages *
-  ** .dt %f  .dd the full pathname of the current mailbox
-  ** .dt %F  .dd number of flagged messages *
-  ** .dt %h  .dd local hostname
-  ** .dt %l  .dd size (in bytes) of the current mailbox *
-  ** .dt %L  .dd size (in bytes) of the messages shown 
-  **             (i.e., which match the current limit) *
-  ** .dt %m  .dd the number of messages in the mailbox *
-  ** .dt %M  .dd the number of messages shown (i.e., which match the current limit) *
-  ** .dt %n  .dd number of new messages in the mailbox *
-  ** .dt %o  .dd number of old unread messages *
-  ** .dt %p  .dd number of postponed messages *
-  ** .dt %P  .dd percentage of the way through the index
-  ** .dt %r  .dd modified/read-only/won't-write/attach-message indicator,
-  **             according to $$status_chars
-  ** .dt %s  .dd current sorting mode ($$sort)
-  ** .dt %S  .dd current aux sorting method ($$sort_aux)
-  ** .dt %t  .dd number of tagged messages *
-  ** .dt %u  .dd number of unread messages *
-  ** .dt %v  .dd Mutt-ng version string
-  ** .dt %V  .dd currently active limit pattern, if any *
-  ** .dt %>X .dd right justify the rest of the string and pad with "X"
-  ** .dt %|X .dd pad to the end of the line with "X"
-  ** .de
-  ** .pp
-  ** * = can be optionally printed if nonzero
-  ** .pp
-  ** Some of the above sequences can be used to optionally print a string
-  ** if their value is nonzero.  For example, you may only want to see the
-  ** number of flagged messages if such messages exist, since zero is not
-  ** particularly meaningful.  To optionally print a string based upon one
-  ** of the above sequences, the following construct is used
-  ** .pp
-  **  %?<sequence_char>?<optional_string>?
-  ** .pp
-  ** where \fIsequence_char\fP is a character from the table above, and
-  ** \fIoptional_string\fP is the string you would like printed if
-  ** \fIsequence_char\fP is nonzero.  \fIoptional_string\fP \fBmay\fP contain
-  ** other sequences as well as normal text, but you may \fBnot\fP nest
-  ** optional strings.
-  ** .pp
-  ** Here is an example illustrating how to optionally print the number of
-  ** new messages in a mailbox:
-  ** %?n?%n new messages.?
-  ** .pp
-  ** Additionally you can switch between two strings, the first one, if a
-  ** value is zero, the second one, if the value is nonzero, by using the
-  ** following construct:
-  ** %?<sequence_char>?<if_string>&<else_string>?
-  ** .pp
-  ** You can additionally force the result of any printf-like sequence to
-  ** be lowercase by prefixing the sequence character with an underscore
-  ** (_) sign.  For example, if you want to display the local hostname in
-  ** lowercase, you would use:
-  ** %_h
-  ** .pp
-  ** If you prefix the sequence character with a colon (:) character, Mutt-ng
-  ** will replace any dots in the expansion by underscores. This might be helpful 
-  ** with IMAP folders that don't like dots in folder names.
-  */
-  { "status_on_top",   DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0 },
+   ** .pp
+   ** The \fIpager\fP uses this variable to catch some common false
+   ** positives of ``$$quote_regexp'', most notably smileys in the beginning
+   ** of a line
+   */
+  {"sleep_time", DT_NUM, R_NONE, UL & SleepTime, 1},
   /*
-  ** .pp
-  ** Setting this variable causes the ``status bar'' to be displayed on
-  ** the first line of the screen rather than near the bottom.
-  */
-  { "strict_mime",    DT_BOOL, R_NONE, OPTSTRICTMIME, 1 },
+   ** .pp
+   ** Specifies time, in seconds, to pause while displaying certain informational
+   ** messages, while moving from folder to folder and after expunging
+   ** messages from the current folder.  The default is to pause one second, so 
+   ** a value of zero for this option suppresses the pause.
+   */
+  {"sort", DT_SORT, R_INDEX | R_RESORT, UL & Sort, SORT_DATE},
+  /*
+   ** .pp
+   ** Specifies how to sort messages in the \fIindex\fP menu.  Valid values
+   ** are:
+   ** .pp
+   ** .ts
+   ** .  date or date-sent
+   ** .  date-received
+   ** .  from
+   ** .  mailbox-order (unsorted)
+   ** .  score
+   ** .  size
+   ** .  spam
+   ** .  subject
+   ** .  threads
+   ** .  to
+   ** .te
+   ** .pp
+   ** You may optionally use the reverse- prefix to specify reverse sorting
+   ** order (example: set sort=reverse-date-sent).
+   */
+  {"sort_alias", DT_SORT | DT_SORT_ALIAS, R_NONE, UL & SortAlias, SORT_ALIAS},
+  /*
+   ** .pp
+   ** Specifies how the entries in the `alias' menu are sorted.  The
+   ** following are legal values:
+   ** .pp
+   ** .ts
+   ** .  address (sort alphabetically by email address)
+   ** .  alias (sort alphabetically by alias name)
+   ** .  unsorted (leave in order specified in .muttrc)
+   ** .te
+   */
+  {"sort_aux", DT_SORT | DT_SORT_AUX, R_INDEX | R_RESORT_BOTH, UL & SortAux,
+   SORT_DATE},
+  /*
+   ** .pp
+   ** When sorting by threads, this variable controls how threads are sorted
+   ** in relation to other threads, and how the branches of the thread trees
+   ** are sorted.  This can be set to any value that ``$$sort'' can, except
+   ** threads (in that case, Mutt-ng will just use date-sent).  You can also
+   ** specify the last- prefix in addition to the reverse- prefix, but last-
+   ** must come after reverse-.  The last- prefix causes messages to be
+   ** sorted against its siblings by which has the last descendant, using
+   ** the rest of sort_aux as an ordering.  For instance, set sort_aux=last-
+   ** date-received would mean that if a new message is received in a
+   ** thread, that thread becomes the last one displayed (or the first, if
+   ** you have set sort=reverse-threads.) Note: For reversed ``$$sort''
+   ** order $$sort_aux is reversed again (which is not the right thing to do,
+   ** but kept to not break any existing configuration setting).
+   */
+  {"sort_browser", DT_SORT | DT_SORT_BROWSER, R_NONE, UL & BrowserSort,
+   SORT_ALPHA},
+  /*
+   ** .pp
+   ** Specifies how to sort entries in the file browser.  By default, the
+   ** entries are sorted alphabetically.  Valid values:
+   ** .pp
+   ** .ts
+   ** .  alpha (alphabetically)
+   ** .  date
+   ** .  size
+   ** .  unsorted
+   ** .te
+   ** .pp
+   ** You may optionally use the reverse- prefix to specify reverse sorting
+   ** order (example: set sort_browser=reverse-date).
+   */
+  {"sort_re", DT_BOOL, R_INDEX | R_RESORT | R_RESORT_INIT, OPTSORTRE, 1},
+  /*
+   ** .pp
+   ** This variable is only useful when sorting by threads with
+   ** ``$$strict_threads'' unset.  In that case, it changes the heuristic
+   ** Mutt-ng uses to thread messages by subject.  With sort_re set, Mutt-ng will
+   ** only attach a message as the child of another message by subject if
+   ** the subject of the child message starts with a substring matching the
+   ** setting of ``$$reply_regexp''.  With sort_re unset, Mutt-ng will attach
+   ** the message whether or not this is the case, as long as the
+   ** non-``$$reply_regexp'' parts of both messages are identical.
+   */
+  {"spam_separator", DT_STR, R_NONE, UL & SpamSep, UL ","},
+  /*
+   ** .pp
+   ** ``$spam_separator'' controls what happens when multiple spam headers
+   ** are matched: if unset, each successive header will overwrite any
+   ** previous matches value for the spam label. If set, each successive
+   ** match will append to the previous, using ``$spam_separator'' as a
+   ** separator.
+   */
+  {"spoolfile", DT_PATH, R_NONE, UL & Spoolfile, 0},
   /*
-  ** .pp
-  ** When unset, non MIME-compliant messages that doesn't have any
-  ** charset indication in ``Content-Type'' field can be displayed
-  ** (non MIME-compliant messages are often generated by old mailers
-  ** or buggy mailers like MS Outlook Express).
-  ** See also $$assumed_charset.
-  ** .pp
-  ** This option also replaces linear-white-space between encoded-word
-  ** and *text to a single space to prevent the display of MIME-encoded
-  ** ``Subject'' field from being devided into multiple lines.
-  */
-  { "strict_threads",  DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTSTRICTTHREADS, 0 },
+   ** .pp
+   ** If your spool mailbox is in a non-default place where Mutt-ng cannot find
+   ** it, you can specify its location with this variable.  Mutt-ng will
+   ** automatically set this variable to the value of the environment
+   ** variable $$$MAIL if it is not set.
+   */
+  {"status_chars", DT_STR, R_BOTH, UL & StChars, UL "-*%A"},
+  /*
+   ** .pp
+   ** Controls the characters used by the "%r" indicator in
+   ** ``$$status_format''. The first character is used when the mailbox is
+   ** unchanged. The second is used when the mailbox has been changed, and
+   ** it needs to be resynchronized. The third is used if the mailbox is in
+   ** read-only mode, or if the mailbox will not be written when exiting
+   ** that mailbox (You can toggle whether to write changes to a mailbox
+   ** with the toggle-write operation, bound by default to "%"). The fourth
+   ** is used to indicate that the current folder has been opened in attach-
+   ** message mode (Certain operations like composing a new mail, replying,
+   ** forwarding, etc. are not permitted in this mode).
+   */
+  {"status_format", DT_STR, R_BOTH, UL & Status,
+   UL
+   "-%r-Mutt-ng: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"},
+  /*
+   ** .pp
+   ** Controls the format of the status line displayed in the \fIindex\fP
+   ** menu.  This string is similar to ``$$index_format'', but has its own
+   ** set of printf()-like sequences:
+   ** .pp
+   ** .dl
+   ** .dt %b  .dd number of mailboxes with new mail *
+   ** .dt %B  .dd the short pathname of the current mailbox
+   ** .dt %d  .dd number of deleted messages *
+   ** .dt %f  .dd the full pathname of the current mailbox
+   ** .dt %F  .dd number of flagged messages *
+   ** .dt %h  .dd local hostname
+   ** .dt %l  .dd size (in bytes) of the current mailbox *
+   ** .dt %L  .dd size (in bytes) of the messages shown 
+   **             (i.e., which match the current limit) *
+   ** .dt %m  .dd the number of messages in the mailbox *
+   ** .dt %M  .dd the number of messages shown (i.e., which match the current limit) *
+   ** .dt %n  .dd number of new messages in the mailbox *
+   ** .dt %o  .dd number of old unread messages *
+   ** .dt %p  .dd number of postponed messages *
+   ** .dt %P  .dd percentage of the way through the index
+   ** .dt %r  .dd modified/read-only/won't-write/attach-message indicator,
+   **             according to $$status_chars
+   ** .dt %s  .dd current sorting mode ($$sort)
+   ** .dt %S  .dd current aux sorting method ($$sort_aux)
+   ** .dt %t  .dd number of tagged messages *
+   ** .dt %u  .dd number of unread messages *
+   ** .dt %v  .dd Mutt-ng version string
+   ** .dt %V  .dd currently active limit pattern, if any *
+   ** .dt %>X .dd right justify the rest of the string and pad with "X"
+   ** .dt %|X .dd pad to the end of the line with "X"
+   ** .de
+   ** .pp
+   ** * = can be optionally printed if nonzero
+   ** .pp
+   ** Some of the above sequences can be used to optionally print a string
+   ** if their value is nonzero.  For example, you may only want to see the
+   ** number of flagged messages if such messages exist, since zero is not
+   ** particularly meaningful.  To optionally print a string based upon one
+   ** of the above sequences, the following construct is used
+   ** .pp
+   **  %?<sequence_char>?<optional_string>?
+   ** .pp
+   ** where \fIsequence_char\fP is a character from the table above, and
+   ** \fIoptional_string\fP is the string you would like printed if
+   ** \fIsequence_char\fP is nonzero.  \fIoptional_string\fP \fBmay\fP contain
+   ** other sequences as well as normal text, but you may \fBnot\fP nest
+   ** optional strings.
+   ** .pp
+   ** Here is an example illustrating how to optionally print the number of
+   ** new messages in a mailbox:
+   ** %?n?%n new messages.?
+   ** .pp
+   ** Additionally you can switch between two strings, the first one, if a
+   ** value is zero, the second one, if the value is nonzero, by using the
+   ** following construct:
+   ** %?<sequence_char>?<if_string>&<else_string>?
+   ** .pp
+   ** You can additionally force the result of any printf-like sequence to
+   ** be lowercase by prefixing the sequence character with an underscore
+   ** (_) sign.  For example, if you want to display the local hostname in
+   ** lowercase, you would use:
+   ** %_h
+   ** .pp
+   ** If you prefix the sequence character with a colon (:) character, Mutt-ng
+   ** will replace any dots in the expansion by underscores. This might be helpful 
+   ** with IMAP folders that don't like dots in folder names.
+   */
+  {"status_on_top", DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0},
   /*
-  ** .pp
-  ** If set, threading will only make use of the ``In-Reply-To'' and
-  ** ``References'' fields when you ``$$sort'' by message threads.  By
-  ** default, messages with the same subject are grouped together in
-  ** ``pseudo threads.''  This may not always be desirable, such as in a
-  ** personal mailbox where you might have several unrelated messages with
-  ** the subject ``hi'' which will get grouped together.
-  */
-  { "strip_was",       DT_BOOL, R_NONE, OPTSTRIPWAS,   0 },
+   ** .pp
+   ** Setting this variable causes the ``status bar'' to be displayed on
+   ** the first line of the screen rather than near the bottom.
+   */
+  {"strict_mime", DT_BOOL, R_NONE, OPTSTRICTMIME, 1},
+  /*
+   ** .pp
+   ** When unset, non MIME-compliant messages that doesn't have any
+   ** charset indication in ``Content-Type'' field can be displayed
+   ** (non MIME-compliant messages are often generated by old mailers
+   ** or buggy mailers like MS Outlook Express).
+   ** See also $$assumed_charset.
+   ** .pp
+   ** This option also replaces linear-white-space between encoded-word
+   ** and *text to a single space to prevent the display of MIME-encoded
+   ** ``Subject'' field from being devided into multiple lines.
+   */
+  {"strict_threads", DT_BOOL, R_RESORT | R_RESORT_INIT | R_INDEX,
+   OPTSTRICTTHREADS, 0},
+  /*
+   ** .pp
+   ** If set, threading will only make use of the ``In-Reply-To'' and
+   ** ``References'' fields when you ``$$sort'' by message threads.  By
+   ** default, messages with the same subject are grouped together in
+   ** ``pseudo threads.''  This may not always be desirable, such as in a
+   ** personal mailbox where you might have several unrelated messages with
+   ** the subject ``hi'' which will get grouped together.
+   */
+  {"strip_was", DT_BOOL, R_NONE, OPTSTRIPWAS, 0},
   /**
   ** .pp
   ** When \fIset\fP, mutt-ng will remove the trailing part of the ``Subject''
   ** line which matches $$strip_was_regex when replying.
   **/
-  { "strip_was_regex", DT_RX,   R_NONE, UL &StripWasRegexp, UL "\\([Ww][Aa][RrSs]: .*\\)[ ]*$" },
+  {"strip_was_regex", DT_RX, R_NONE, UL & StripWasRegexp,
+   UL "\\([Ww][Aa][RrSs]: .*\\)[ ]*$"},
   /**
   ** .pp
   ** When non-empty and $$strip_was is \fIset\fP, mutt-ng will remove this
   ** trailing part of the ``Subject'' line when replying if it won't be empty
   ** afterwards.
   **/
-  { "stuff_quoted",    DT_BOOL, R_BOTH, OPTSTUFFQUOTED, 0 },
+  {"stuff_quoted", DT_BOOL, R_BOTH, OPTSTUFFQUOTED, 0},
   /*
-  ** .pp
-  ** If set, attachments with flowed format will have their quoting ``stuffed'',
-  ** i.e. a space will be inserted between the quote characters and the actual
-  ** text.
-  */
-  { "suspend",         DT_BOOL, R_NONE, OPTSUSPEND, 1 },
-  /*
-  ** .pp
-  ** When \fIunset\fP, Mutt-ng won't stop when the user presses the terminal's
-  ** \fIsusp\fP key, usually ``control-Z''. This is useful if you run Mutt-ng
-  ** inside an xterm using a command like xterm -e Mutt-ng.
-  */
-  { "text_flowed",     DT_BOOL, R_NONE, OPTTEXTFLOWED,  0 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng will generate text/plain; format=flowed attachments.
-  ** This format is easier to handle for some mailing software, and generally
-  ** just looks like ordinary text.  To actually make use of this format's 
-  ** features, you'll need support in your editor.
-  ** .pp
-  ** Note that $$indent_string is ignored when this option is set.
-  */
-  { "thread_received", DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTTHREADRECEIVED, 0 },
-  /*
-  ** .pp
-  ** When set, Mutt-ng uses the date received rather than the date sent
-  ** to thread messages by subject.
-  */
-  { "thorough_search", DT_BOOL, R_NONE, OPTTHOROUGHSRC, 0 },
+   ** .pp
+   ** If set, attachments with flowed format will have their quoting ``stuffed'',
+   ** i.e. a space will be inserted between the quote characters and the actual
+   ** text.
+   */
+  {"suspend", DT_BOOL, R_NONE, OPTSUSPEND, 1},
   /*
-  ** .pp
-  ** Affects the \fI~b\fP and \fI~h\fP search operations described in
-  ** section ``$patterns'' above.  If set, the headers and attachments of
-  ** messages to be searched are decoded before searching.  If unset,
-  ** messages are searched as they appear in the folder.
-  */
-  { "tilde",           DT_BOOL, R_PAGER, OPTTILDE, 0 },
+   ** .pp
+   ** When \fIunset\fP, Mutt-ng won't stop when the user presses the terminal's
+   ** \fIsusp\fP key, usually ``control-Z''. This is useful if you run Mutt-ng
+   ** inside an xterm using a command like xterm -e Mutt-ng.
+   */
+  {"text_flowed", DT_BOOL, R_NONE, OPTTEXTFLOWED, 0},
+  /*
+   ** .pp
+   ** When set, Mutt-ng will generate text/plain; format=flowed attachments.
+   ** This format is easier to handle for some mailing software, and generally
+   ** just looks like ordinary text.  To actually make use of this format's 
+   ** features, you'll need support in your editor.
+   ** .pp
+   ** Note that $$indent_string is ignored when this option is set.
+   */
+  {"thread_received", DT_BOOL, R_RESORT | R_RESORT_INIT | R_INDEX,
+   OPTTHREADRECEIVED, 0},
   /*
-  ** .pp
-  ** When set, the internal-pager will pad blank lines to the bottom of the
-  ** screen with a tilde (~).
-  */
-  { "timeout",         DT_NUM,  R_NONE, UL &Timeout, 600 },
+   ** .pp
+   ** When set, Mutt-ng uses the date received rather than the date sent
+   ** to thread messages by subject.
+   */
+  {"thorough_search", DT_BOOL, R_NONE, OPTTHOROUGHSRC, 0},
   /*
-  ** .pp
-  ** This variable controls the \fInumber of seconds\fP Mutt-ng will wait
-  ** for a key to be pressed in the main menu before timing out and
-  ** checking for new mail.  A value of zero or less will cause Mutt-ng
-  ** to never time out.
-  */
-  { "tmpdir",          DT_PATH, R_NONE, UL &Tempdir, 0 },
+   ** .pp
+   ** Affects the \fI~b\fP and \fI~h\fP search operations described in
+   ** section ``$patterns'' above.  If set, the headers and attachments of
+   ** messages to be searched are decoded before searching.  If unset,
+   ** messages are searched as they appear in the folder.
+   */
+  {"tilde", DT_BOOL, R_PAGER, OPTTILDE, 0},
   /*
-  ** .pp
-  ** This variable allows you to specify where Mutt-ng will place its
-  ** temporary files needed for displaying and composing messages.  If
-  ** this variable is not set, the environment variable TMPDIR is
-  ** used.  If TMPDIR is not set then "/tmp" is used.
-  */
-  { "to_chars",                DT_STR,  R_BOTH, UL &Tochars, UL " +TCFL" },
+   ** .pp
+   ** When set, the internal-pager will pad blank lines to the bottom of the
+   ** screen with a tilde (~).
+   */
+  {"timeout", DT_NUM, R_NONE, UL & Timeout, 600},
   /*
-  ** .pp
-  ** Controls the character used to indicate mail addressed to you.  The
-  ** first character is the one used when the mail is NOT addressed to your
-  ** address (default: space).  The second is used when you are the only
-  ** recipient of the message (default: +).  The third is when your address
-  ** appears in the TO header field, but you are not the only recipient of
-  ** the message (default: T).  The fourth character is used when your
-  ** address is specified in the CC header field, but you are not the only
-  ** recipient.  The fifth character is used to indicate mail that was sent
-  ** by \fIyou\fP.  The sixth character is used to indicate when a mail
-  ** was sent to a mailing-list you subscribe to (default: L).
-  */
-  { "trash",           DT_PATH, R_NONE, UL &TrashPath, 0 },
+   ** .pp
+   ** This variable controls the \fInumber of seconds\fP Mutt-ng will wait
+   ** for a key to be pressed in the main menu before timing out and
+   ** checking for new mail.  A value of zero or less will cause Mutt-ng
+   ** to never time out.
+   */
+  {"tmpdir", DT_PATH, R_NONE, UL & Tempdir, 0},
   /*
-  ** .pp
-  ** If set, this variable specifies the path of the trash folder where the
-  ** mails marked for deletion will be moved, instead of being irremediably
-  ** purged.
-  ** .pp
-  ** NOTE: When you delete a message in the trash folder, it is really
-  ** deleted, so that there is no way to recover mail.
-  */
+   ** .pp
+   ** This variable allows you to specify where Mutt-ng will place its
+   ** temporary files needed for displaying and composing messages.  If
+   ** this variable is not set, the environment variable TMPDIR is
+   ** used.  If TMPDIR is not set then "/tmp" is used.
+   */
+  {"to_chars", DT_STR, R_BOTH, UL & Tochars, UL " +TCFL"},
+  /*
+   ** .pp
+   ** Controls the character used to indicate mail addressed to you.  The
+   ** first character is the one used when the mail is NOT addressed to your
+   ** address (default: space).  The second is used when you are the only
+   ** recipient of the message (default: +).  The third is when your address
+   ** appears in the TO header field, but you are not the only recipient of
+   ** the message (default: T).  The fourth character is used when your
+   ** address is specified in the CC header field, but you are not the only
+   ** recipient.  The fifth character is used to indicate mail that was sent
+   ** by \fIyou\fP.  The sixth character is used to indicate when a mail
+   ** was sent to a mailing-list you subscribe to (default: L).
+   */
+  {"trash", DT_PATH, R_NONE, UL & TrashPath, 0},
+  /*
+   ** .pp
+   ** If set, this variable specifies the path of the trash folder where the
+   ** mails marked for deletion will be moved, instead of being irremediably
+   ** purged.
+   ** .pp
+   ** NOTE: When you delete a message in the trash folder, it is really
+   ** deleted, so that there is no way to recover mail.
+   */
 #ifdef USE_SOCKET
-  { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
-  /*
-  ** .pp
-  ** Setting this variable will cause Mutt-ng to open a pipe to a command
-  ** instead of a raw socket. You may be able to use this to set up
-  ** preauthenticated connections to your IMAP/POP3 server. Example:
-  ** .pp
-  ** tunnel="ssh -q mailhost.net /usr/local/libexec/imapd"
-  ** .pp
-  ** NOTE: For this example to work you must be able to log in to the remote
-  ** machine without having to enter a password.
-  */
+  {"tunnel", DT_STR, R_NONE, UL & Tunnel, UL 0},
+  /*
+   ** .pp
+   ** Setting this variable will cause Mutt-ng to open a pipe to a command
+   ** instead of a raw socket. You may be able to use this to set up
+   ** preauthenticated connections to your IMAP/POP3 server. Example:
+   ** .pp
+   ** tunnel="ssh -q mailhost.net /usr/local/libexec/imapd"
+   ** .pp
+   ** NOTE: For this example to work you must be able to log in to the remote
+   ** machine without having to enter a password.
+   */
 #endif
-  { "umask",   DT_NUM, R_NONE, UL &Umask, 0077 },
-  /*
-  ** .pp
-  ** This sets the umask that will be used by Mutt-ng when creating all
-  ** kinds of files. If unset, the default value is 077.
-  */
-  { "use_8bitmime",    DT_BOOL, R_NONE, OPTUSE8BITMIME, 0 },
+  {"umask", DT_NUM, R_NONE, UL & Umask, 0077},
   /*
-  ** .pp
-  ** \fBWarning:\fP do not set this variable unless you are using a version
-  ** of sendmail which supports the -B8BITMIME flag (such as sendmail
-  ** 8.8.x) or you may not be able to send mail.
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will invoke ``$$sendmail'' with the -B8BITMIME
-  ** flag when sending 8-bit messages to enable ESMTP negotiation.
-  */
-  { "use_domain",      DT_BOOL, R_NONE, OPTUSEDOMAIN, 1 },
+   ** .pp
+   ** This sets the umask that will be used by Mutt-ng when creating all
+   ** kinds of files. If unset, the default value is 077.
+   */
+  {"use_8bitmime", DT_BOOL, R_NONE, OPTUSE8BITMIME, 0},
+  /*
+   ** .pp
+   ** \fBWarning:\fP do not set this variable unless you are using a version
+   ** of sendmail which supports the -B8BITMIME flag (such as sendmail
+   ** 8.8.x) or you may not be able to send mail.
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will invoke ``$$sendmail'' with the -B8BITMIME
+   ** flag when sending 8-bit messages to enable ESMTP negotiation.
+   */
+  {"use_domain", DT_BOOL, R_NONE, OPTUSEDOMAIN, 1},
   /*
-  ** .pp
-  ** When set, Mutt-ng will qualify all local addresses (ones without the
-  ** @host portion) with the value of ``$$hostname''.  If \fIunset\fP, no
-  ** addresses will be qualified.
-  */
-  { "use_from",                DT_BOOL, R_NONE, OPTUSEFROM, 1 },
+   ** .pp
+   ** When set, Mutt-ng will qualify all local addresses (ones without the
+   ** @host portion) with the value of ``$$hostname''.  If \fIunset\fP, no
+   ** addresses will be qualified.
+   */
+  {"use_from", DT_BOOL, R_NONE, OPTUSEFROM, 1},
   /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will generate the `From:' header field when
-  ** sending messages.  If \fIunset\fP, no `From:' header field will be
-  ** generated unless the user explicitly sets one using the ``$my_hdr''
-  ** command.
-  */
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will generate the `From:' header field when
+   ** sending messages.  If \fIunset\fP, no `From:' header field will be
+   ** generated unless the user explicitly sets one using the ``$my_hdr''
+   ** command.
+   */
 #ifdef HAVE_LIBIDN
-  { "use_idn",         DT_BOOL, R_BOTH, OPTUSEIDN, 1},
-  /*
-  ** .pp
-  ** Availability: IDN
-  **
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will show you international domain names decoded.
-  ** Note: You can use IDNs for addresses even if this is \fIunset\fP.
-  ** This variable only affects decoding.
-  */
+  {"use_idn", DT_BOOL, R_BOTH, OPTUSEIDN, 1},
+  /*
+   ** .pp
+   ** Availability: IDN
+   **
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will show you international domain names decoded.
+   ** Note: You can use IDNs for addresses even if this is \fIunset\fP.
+   ** This variable only affects decoding.
+   */
 #endif /* HAVE_LIBIDN */
 #ifdef HAVE_GETADDRINFO
-  { "use_ipv6",                DT_BOOL, R_NONE, OPTUSEIPV6, 1},
+  {"use_ipv6", DT_BOOL, R_NONE, OPTUSEIPV6, 1},
   /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will look for IPv6 addresses of hosts it tries to
-  ** contact.  If this option is unset, Mutt-ng will restrict itself to IPv4 addresses.
-  ** Normally, the default should work.
-  */
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will look for IPv6 addresses of hosts it tries to
+   ** contact.  If this option is unset, Mutt-ng will restrict itself to IPv4 addresses.
+   ** Normally, the default should work.
+   */
 #endif /* HAVE_GETADDRINFO */
-  { "user_agent",      DT_BOOL, R_NONE, OPTXMAILER, 1},
-  /*
-  ** .pp
-  ** When \fIset\fP, Mutt-ng will add a "User-Agent" header to outgoing
-  ** messages, indicating which version of Mutt-ng was used for composing
-  ** them.
-  */
-  { "visual",          DT_PATH, R_NONE, UL &Visual, 0 },
+  {"user_agent", DT_BOOL, R_NONE, OPTXMAILER, 1},
   /*
-  ** .pp
-  ** Specifies the visual editor to invoke when the \fI~v\fP command is
-  ** given in the builtin editor.
-  */
-  { "wait_key",                DT_BOOL, R_NONE, OPTWAITKEY, 1 },
-  /*
-  ** .pp
-  ** Controls whether Mutt-ng will ask you to press a key after \fIshell-
-  ** escape\fP, \fIpipe-message\fP, \fIpipe-entry\fP, \fIprint-message\fP,
-  ** and \fIprint-entry\fP commands.
-  ** .pp
-  ** It is also used when viewing attachments with ``$auto_view'', provided
-  ** that the corresponding mailcap entry has a \fIneedsterminal\fP flag,
-  ** and the external program is interactive.
-  ** .pp
-  ** When set, Mutt-ng will always ask for a key. When unset, Mutt-ng will wait
-  ** for a key only if the external command returned a non-zero status.
-  */
-  { "weed",            DT_BOOL, R_NONE, OPTWEED, 1 },
+   ** .pp
+   ** When \fIset\fP, Mutt-ng will add a "User-Agent" header to outgoing
+   ** messages, indicating which version of Mutt-ng was used for composing
+   ** them.
+   */
+  {"visual", DT_PATH, R_NONE, UL & Visual, 0},
   /*
-  ** .pp
-  ** When set, Mutt-ng will weed headers when displaying, forwarding,
-  ** printing, or replying to messages.
-  */
-  { "wrap_search",     DT_BOOL, R_NONE, OPTWRAPSEARCH, 1 },
+   ** .pp
+   ** Specifies the visual editor to invoke when the \fI~v\fP command is
+   ** given in the builtin editor.
+   */
+  {"wait_key", DT_BOOL, R_NONE, OPTWAITKEY, 1},
+  /*
+   ** .pp
+   ** Controls whether Mutt-ng will ask you to press a key after \fIshell-
+   ** escape\fP, \fIpipe-message\fP, \fIpipe-entry\fP, \fIprint-message\fP,
+   ** and \fIprint-entry\fP commands.
+   ** .pp
+   ** It is also used when viewing attachments with ``$auto_view'', provided
+   ** that the corresponding mailcap entry has a \fIneedsterminal\fP flag,
+   ** and the external program is interactive.
+   ** .pp
+   ** When set, Mutt-ng will always ask for a key. When unset, Mutt-ng will wait
+   ** for a key only if the external command returned a non-zero status.
+   */
+  {"weed", DT_BOOL, R_NONE, OPTWEED, 1},
   /*
-  ** .pp
-  ** Controls whether searches wrap around the end of the mailbox.
-  ** .pp
-  ** When set, searches will wrap around the first (or last) message. When
-  ** unset, searches will not wrap.
-  */
-  { "wrapmargin",      DT_NUM,  R_PAGER, UL &WrapMargin, 0 },
+   ** .pp
+   ** When set, Mutt-ng will weed headers when displaying, forwarding,
+   ** printing, or replying to messages.
+   */
+  {"wrap_search", DT_BOOL, R_NONE, OPTWRAPSEARCH, 1},
   /*
-  ** .pp
-  ** Controls the size of the margin remaining at the right side of
-  ** the terminal when Mutt-ng's pager does smart wrapping.
-  */
-  { "write_inc",       DT_NUM,  R_NONE, UL &WriteInc, 10 },
+   ** .pp
+   ** Controls whether searches wrap around the end of the mailbox.
+   ** .pp
+   ** When set, searches will wrap around the first (or last) message. When
+   ** unset, searches will not wrap.
+   */
+  {"wrapmargin", DT_NUM, R_PAGER, UL & WrapMargin, 0},
   /*
-  ** .pp
-  ** When writing a mailbox, a message will be printed every
-  ** \fIwrite_inc\fP messages to indicate progress.  If set to 0, only a
-  ** single message will be displayed before writing a mailbox.
-  ** .pp
-  ** Also see the ``$$read_inc'' variable.
-  */
-  { "write_bcc",       DT_BOOL, R_NONE, OPTWRITEBCC, 1},
+   ** .pp
+   ** Controls the size of the margin remaining at the right side of
+   ** the terminal when Mutt-ng's pager does smart wrapping.
+   */
+  {"write_inc", DT_NUM, R_NONE, UL & WriteInc, 10},
+  /*
+   ** .pp
+   ** When writing a mailbox, a message will be printed every
+   ** \fIwrite_inc\fP messages to indicate progress.  If set to 0, only a
+   ** single message will be displayed before writing a mailbox.
+   ** .pp
+   ** Also see the ``$$read_inc'' variable.
+   */
+  {"write_bcc", DT_BOOL, R_NONE, OPTWRITEBCC, 1},
   /*
-  ** .pp
-  ** Controls whether Mutt-ng writes out the Bcc header when preparing
-  ** messages to be sent.  Exim users may wish to unset this.
-  */
-  {"xterm_icon",       DT_STR,   R_BOTH, UL &XtermIcon,  UL "M%?n?AIL&ail?"},
+   ** .pp
+   ** Controls whether Mutt-ng writes out the Bcc header when preparing
+   ** messages to be sent.  Exim users may wish to unset this.
+   */
+  {"xterm_icon", DT_STR, R_BOTH, UL & XtermIcon, UL "M%?n?AIL&ail?"},
   /*
-  ** .pp
-  ** Controls the format of the icon title, as long as xterm_set_titles
-  ** is enabled. This string is identical in formatting to the one used by
-  ** ``$$status_format''.
-  */
-  {"xterm_set_titles", DT_BOOL,  R_BOTH, OPTXTERMSETTITLES, 0},
+   ** .pp
+   ** Controls the format of the icon title, as long as xterm_set_titles
+   ** is enabled. This string is identical in formatting to the one used by
+   ** ``$$status_format''.
+   */
+  {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
   /*
-  ** .pp
-  ** Controls whether Mutt-ng sets the xterm title bar and icon name
-  ** (as long as you're in an appropriate terminal). The default must
-  ** be off to force in the validity checking.
-  */
-  {"xterm_title",      DT_STR,   R_BOTH, UL &XtermTitle, UL "Mutt-ng with %?m?%m messages&no messages?%?n? [%n New]?"},
+   ** .pp
+   ** Controls whether Mutt-ng sets the xterm title bar and icon name
+   ** (as long as you're in an appropriate terminal). The default must
+   ** be off to force in the validity checking.
+   */
+  {"xterm_title", DT_STR, R_BOTH, UL & XtermTitle,
+   UL "Mutt-ng with %?m?%m messages&no messages?%?n? [%n New]?"},
   /*
-  ** .pp
-  ** Controls the format of the title bar of the xterm provided that
-  ** xterm_set_titles has been set. This string is identical in formatting
-  ** to the one used by ``$$status_format''.
-  */
+   ** .pp
+   ** Controls the format of the title bar of the xterm provided that
+   ** xterm_set_titles has been set. This string is identical in formatting
+   ** to the one used by ``$$status_format''.
+   */
 #ifdef USE_NNTP
-  { "x_comment_to",   DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
-  /*
-  ** .pp
-  ** Availability: NNTP
-  **
-  ** .pp
-  ** If \fIset\fP, Mutt-ng will add ``X-Comment-To:'' field (that contains full
-  ** name of original article author) to article that followuped to newsgroup.
-  */
+  {"x_comment_to", DT_BOOL, R_NONE, OPTXCOMMENTTO, 0},
+  /*
+   ** .pp
+   ** Availability: NNTP
+   **
+   ** .pp
+   ** If \fIset\fP, Mutt-ng will add ``X-Comment-To:'' field (that contains full
+   ** name of original article author) to article that followuped to newsgroup.
+   */
 #endif
   /*--*/
-  { NULL }
+  {NULL}
 };
 
 const struct feature_t Features[] = {
-  { "ncurses", 
+  {"ncurses",
 #ifdef NCURSES_VERSION
-    1
+   1
 #else
-    0
+   0
 #endif
-  }, { "slang",
+   }, {"slang",
 #ifdef USE_SLANG_CURSES
-    1
+       1
 #else
-    0
+       0
 #endif
-  }, { "iconv",
+       }, {"iconv",
 #ifdef _LIBICONV_VERSION
-    1
+           1
 #else
-    0
+           0
 #endif
-  }, { "idn",
+           }, {"idn",
 #ifdef HAVE_LIBIDN
-    1
+               1
 #else
-    0
+               0
 #endif
-  }, { "dotlock",
+               }, {"dotlock",
 #ifdef USE_DOTLOCK
-    1
+                   1
 #else
-    0
+                   0
 #endif
-  }, { "standalone",
+                   }, {"standalone",
 #ifdef DL_STANDALONE
-    1
+                       1
 #else
-    0
+                       0
 #endif
-  }, { "pop",
+                       }, {"pop",
 #ifdef USE_POP
-    1
+                           1
 #else
-    0
+                           0
 #endif
-  }, { "nntp",
+                           }, {"nntp",
 #ifdef USE_NNTP
-    1
+                               1
 #else
-    0
+                               0
 #endif
-  }, { "imap",
+                               }, {"imap",
 #ifdef USE_IMAP
-    1
+                                   1
 #else
-    0
+                                   0
 #endif
-  }, { "ssl",
+                                   }, {"ssl",
 #ifdef USE_SSL
-    1
+                                       1
 #else
-    0
+                                       0
 #endif
-  }, { "gnutls",
+                                       }, {"gnutls",
 #ifdef USE_GNUTLS
-    1
+                                           1
 #else
-    0
+                                           0
 #endif
-  }, { "sasl",
+                                           }, {"sasl",
 #ifdef USE_SASL
-    1
+                                               1
 #else
-    0
+                                               0
 #endif
-  }, { "sasl2",
+                                               }, {"sasl2",
 #ifdef USE_SASL2
-    1
+                                                   1
 #else
-    0
+                                                   0
 #endif
-  }, { "libesmtp",
+                                                   }, {"libesmtp",
 #ifdef USE_LIBESMTP
-    1
+                                                       1
 #else
-    0
+                                                       0
 #endif
-  }, { "compressed",
+                                                       }, {"compressed",
 #ifdef USE_COMPRESSED
-    1
+                                                           1
 #else
-    0
+                                                           0
 #endif
-  }, { "color",
+                                                           }, {"color",
 #ifdef HAVE_COLOR
-    1
+                                                               1
 #else
-    0
+                                                               0
 #endif
-  }, { "classic_pgp",
+                                                               },
+    {"classic_pgp",
 #ifdef CRYPT_BACKEND_CLASSIC_PGP
-    1
+     1
 #else
-    0
+     0
 #endif
-  }, { "classic_smime",
+     }, {"classic_smime",
 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
-    1
+         1
 #else
-    0
+         0
 #endif
-  }, { "gpgme",
+         }, {"gpgme",
 #ifdef CRYPT_BACKEND_GPGME
-    1
+             1
 #else
-    0
+             0
 #endif
-  }, { "header_cache",
+             }, {"header_cache",
 #ifdef USE_HCACHE
-    1
+                 1
 #else
-    0
+                 0
 #endif
-  },
+                 },
   /* last */
-  { NULL,       0 }
+  {NULL, 0}
 };
 
 const struct mapping_t SortMethods[] = {
-  { "date",            SORT_DATE },
-  { "date-sent",       SORT_DATE },
-  { "date-received",   SORT_RECEIVED },
-  { "mailbox-order",   SORT_ORDER },
-  { "subject",         SORT_SUBJECT },
-  { "from",            SORT_FROM },
-  { "size",            SORT_SIZE },
-  { "threads",         SORT_THREADS },
-  { "to",              SORT_TO },
-  { "score",           SORT_SCORE },
-  { "spam",            SORT_SPAM },
-  { NULL,              0 }
+  {"date", SORT_DATE},
+  {"date-sent", SORT_DATE},
+  {"date-received", SORT_RECEIVED},
+  {"mailbox-order", SORT_ORDER},
+  {"subject", SORT_SUBJECT},
+  {"from", SORT_FROM},
+  {"size", SORT_SIZE},
+  {"threads", SORT_THREADS},
+  {"to", SORT_TO},
+  {"score", SORT_SCORE},
+  {"spam", SORT_SPAM},
+  {NULL, 0}
 };
 
 /* same as SortMethods, but with "threads" replaced by "date" */
 
 const struct mapping_t SortAuxMethods[] = {
-  { "date",            SORT_DATE },
-  { "date-sent",       SORT_DATE },
-  { "date-received",   SORT_RECEIVED },
-  { "mailbox-order",   SORT_ORDER },
-  { "subject",         SORT_SUBJECT },
-  { "from",            SORT_FROM },
-  { "size",            SORT_SIZE },
-  { "threads",         SORT_DATE },    /* note: sort_aux == threads
-                                        * isn't possible. 
-                                        */
-  { "to",              SORT_TO },
-  { "score",           SORT_SCORE },
-  { "spam",            SORT_SPAM },
-  { NULL,              0 }
+  {"date", SORT_DATE},
+  {"date-sent", SORT_DATE},
+  {"date-received", SORT_RECEIVED},
+  {"mailbox-order", SORT_ORDER},
+  {"subject", SORT_SUBJECT},
+  {"from", SORT_FROM},
+  {"size", SORT_SIZE},
+  {"threads", SORT_DATE},       /* note: sort_aux == threads
+                                 * isn't possible. 
+                                 */
+  {"to", SORT_TO},
+  {"score", SORT_SCORE},
+  {"spam", SORT_SPAM},
+  {NULL, 0}
 };
-  
+
 
 const struct mapping_t SortBrowserMethods[] = {
-  { "alpha",   SORT_SUBJECT },
-  { "date",    SORT_DATE },
-  { "size",    SORT_SIZE },
-  { "unsorted",        SORT_ORDER },
-  { NULL }
+  {"alpha", SORT_SUBJECT},
+  {"date", SORT_DATE},
+  {"size", SORT_SIZE},
+  {"unsorted", SORT_ORDER},
+  {NULL}
 };
 
 const struct mapping_t SortAliasMethods[] = {
-  { "alias",   SORT_ALIAS },
-  { "address", SORT_ADDRESS },
-  { "unsorted", SORT_ORDER },
-  { NULL }
+  {"alias", SORT_ALIAS},
+  {"address", SORT_ADDRESS},
+  {"unsorted", SORT_ORDER},
+  {NULL}
 };
 
 const struct mapping_t SortKeyMethods[] = {
-  { "address", SORT_ADDRESS },
-  { "date",    SORT_DATE },
-  { "keyid",   SORT_KEYID },
-  { "trust",   SORT_TRUST },
-  { NULL }
+  {"address", SORT_ADDRESS},
+  {"date", SORT_DATE},
+  {"keyid", SORT_KEYID},
+  {"trust", SORT_TRUST},
+  {NULL}
 };
 
 
 /* functions used to parse commands in a rc file */
 
 static int parse_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
+
 #if 0
 static int parse_rx_list (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_rx_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *);
@@ -3702,8 +3737,7 @@ static int parse_unsubscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 
-struct command_t
-{
+struct command_t {
   char *name;
   int (*func) (BUFFER *, BUFFER *, unsigned long, BUFFER *);
   unsigned long data;
@@ -3711,72 +3745,72 @@ struct command_t
 };
 
 struct command_t Commands[] = {
-  { "alternates",      parse_alternates,       0 },
-  { "unalternates",    parse_unalternates,     0 },
+  {"alternates", parse_alternates, 0},
+  {"unalternates", parse_unalternates, 0},
 #ifdef USE_SOCKET
-  { "account-hook",     mutt_parse_hook,        M_ACCOUNTHOOK },
+  {"account-hook", mutt_parse_hook, M_ACCOUNTHOOK},
 #endif
-  { "alias",           parse_alias,            0 },
-  { "auto_view",       parse_list,             UL &AutoViewList },
-  { "alternative_order",       parse_list,     UL &AlternativeOrderList},
-  { "bind",            mutt_parse_bind,        0 },
-  { "charset-hook",    mutt_parse_hook,        M_CHARSETHOOK },
+  {"alias", parse_alias, 0},
+  {"auto_view", parse_list, UL & AutoViewList},
+  {"alternative_order", parse_list, UL & AlternativeOrderList},
+  {"bind", mutt_parse_bind, 0},
+  {"charset-hook", mutt_parse_hook, M_CHARSETHOOK},
 #ifdef HAVE_COLOR
-  { "color",           mutt_parse_color,       0 },
-  { "uncolor",         mutt_parse_uncolor,     0 },
+  {"color", mutt_parse_color, 0},
+  {"uncolor", mutt_parse_uncolor, 0},
 #endif
-  { "exec",            mutt_parse_exec,        0 },
-  { "fcc-hook",                mutt_parse_hook,        M_FCCHOOK },
-  { "fcc-save-hook",   mutt_parse_hook,        M_FCCHOOK | M_SAVEHOOK },
-  { "folder-hook",     mutt_parse_hook,        M_FOLDERHOOK },
+  {"exec", mutt_parse_exec, 0},
+  {"fcc-hook", mutt_parse_hook, M_FCCHOOK},
+  {"fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK},
+  {"folder-hook", mutt_parse_hook, M_FOLDERHOOK},
 #ifdef USE_COMPRESSED
-  { "open-hook",       mutt_parse_hook,        M_OPENHOOK },
-  { "close-hook",      mutt_parse_hook,        M_CLOSEHOOK },
-  { "append-hook",     mutt_parse_hook,        M_APPENDHOOK },
+  {"open-hook", mutt_parse_hook, M_OPENHOOK},
+  {"close-hook", mutt_parse_hook, M_CLOSEHOOK},
+  {"append-hook", mutt_parse_hook, M_APPENDHOOK},
 #endif
-  { "hdr_order",       parse_list,             UL &HeaderOrderList },
-  { "ifdef",           parse_ifdef,            1 },
-  { "ifndef",          parse_ifdef,            0 },
+  {"hdr_order", parse_list, UL & HeaderOrderList},
+  {"ifdef", parse_ifdef, 1},
+  {"ifndef", parse_ifdef, 0},
 #ifdef HAVE_ICONV
-  { "iconv-hook",      mutt_parse_hook,        M_ICONVHOOK }, 
+  {"iconv-hook", mutt_parse_hook, M_ICONVHOOK},
 #endif
-  { "ignore",          parse_ignore,           0 },
-  { "lists",           parse_lists,            0 },
-  { "macro",           mutt_parse_macro,       0 },
-  { "mailboxes",       mutt_parse_mailboxes,   M_MAILBOXES },
-  { "unmailboxes",     mutt_parse_mailboxes,   M_UNMAILBOXES },
-  { "message-hook",    mutt_parse_hook,        M_MESSAGEHOOK },
-  { "mbox-hook",       mutt_parse_hook,        M_MBOXHOOK },
-  { "mime_lookup",     parse_list,     UL &MimeLookupList },
-  { "unmime_lookup",   parse_unlist,   UL &MimeLookupList },
-  { "mono",            mutt_parse_mono,        0 },
-  { "my_hdr",          parse_my_hdr,           0 },
-  { "pgp-hook",                mutt_parse_hook,        M_CRYPTHOOK },
-  { "crypt-hook",      mutt_parse_hook,        M_CRYPTHOOK },
-  { "push",            mutt_parse_push,        0 },
-  { "reply-hook",      mutt_parse_hook,        M_REPLYHOOK },
-  { "reset",           parse_set,              M_SET_RESET },
-  { "save-hook",       mutt_parse_hook,        M_SAVEHOOK },
-  { "score",           mutt_parse_score,       0 },
-  { "send-hook",       mutt_parse_hook,        M_SENDHOOK },
-  { "send2-hook",      mutt_parse_hook,        M_SEND2HOOK },
-  { "set",             parse_set,              0 },
-  { "source",          parse_source,           0 },
-  { "spam",            parse_spam_list,        M_SPAM },
-  { "nospam",          parse_spam_list,        M_NOSPAM },
-  { "subscribe",       parse_subscribe,        0 },
-  { "toggle",          parse_set,              M_SET_INV },
-  { "unalias",         parse_unalias,          0 },
-  { "unalternative_order",parse_unlist,                UL &AlternativeOrderList },
-  { "unauto_view",     parse_unlist,           UL &AutoViewList },
-  { "unhdr_order",     parse_unlist,           UL &HeaderOrderList },
-  { "unhook",          mutt_parse_unhook,      0 },
-  { "unignore",                parse_unignore,         0 },
-  { "unlists",         parse_unlists,          0 },
-  { "unmono",          mutt_parse_unmono,      0 },
-  { "unmy_hdr",                parse_unmy_hdr,         0 },
-  { "unscore",         mutt_parse_unscore,     0 },
-  { "unset",           parse_set,              M_SET_UNSET },
-  { "unsubscribe",     parse_unsubscribe,      0 },
-  { NULL }
+  {"ignore", parse_ignore, 0},
+  {"lists", parse_lists, 0},
+  {"macro", mutt_parse_macro, 0},
+  {"mailboxes", mutt_parse_mailboxes, M_MAILBOXES},
+  {"unmailboxes", mutt_parse_mailboxes, M_UNMAILBOXES},
+  {"message-hook", mutt_parse_hook, M_MESSAGEHOOK},
+  {"mbox-hook", mutt_parse_hook, M_MBOXHOOK},
+  {"mime_lookup", parse_list, UL & MimeLookupList},
+  {"unmime_lookup", parse_unlist, UL & MimeLookupList},
+  {"mono", mutt_parse_mono, 0},
+  {"my_hdr", parse_my_hdr, 0},
+  {"pgp-hook", mutt_parse_hook, M_CRYPTHOOK},
+  {"crypt-hook", mutt_parse_hook, M_CRYPTHOOK},
+  {"push", mutt_parse_push, 0},
+  {"reply-hook", mutt_parse_hook, M_REPLYHOOK},
+  {"reset", parse_set, M_SET_RESET},
+  {"save-hook", mutt_parse_hook, M_SAVEHOOK},
+  {"score", mutt_parse_score, 0},
+  {"send-hook", mutt_parse_hook, M_SENDHOOK},
+  {"send2-hook", mutt_parse_hook, M_SEND2HOOK},
+  {"set", parse_set, 0},
+  {"source", parse_source, 0},
+  {"spam", parse_spam_list, M_SPAM},
+  {"nospam", parse_spam_list, M_NOSPAM},
+  {"subscribe", parse_subscribe, 0},
+  {"toggle", parse_set, M_SET_INV},
+  {"unalias", parse_unalias, 0},
+  {"unalternative_order", parse_unlist, UL & AlternativeOrderList},
+  {"unauto_view", parse_unlist, UL & AutoViewList},
+  {"unhdr_order", parse_unlist, UL & HeaderOrderList},
+  {"unhook", mutt_parse_unhook, 0},
+  {"unignore", parse_unignore, 0},
+  {"unlists", parse_unlists, 0},
+  {"unmono", mutt_parse_unmono, 0},
+  {"unmy_hdr", parse_unmy_hdr, 0},
+  {"unscore", mutt_parse_unscore, 0},
+  {"unset", parse_set, M_SET_UNSET},
+  {"unsubscribe", parse_unsubscribe, 0},
+  {NULL}
 };
index e41d6d7..b76c948 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include "functions.h"
 
 struct mapping_t Menus[] = {
{ "alias",        MENU_ALIAS },
{ "attach",        MENU_ATTACH },
{ "browser",        MENU_FOLDER },
{ "compose",        MENU_COMPOSE },
{ "editor",        MENU_EDITOR },
{ "index",        MENU_MAIN },
{ "pager",        MENU_PAGER },
{ "postpone",        MENU_POST },
{ "pgp",        MENU_PGP },
{ "smime",        MENU_SMIME },
 {"alias", MENU_ALIAS},
 {"attach", MENU_ATTACH},
 {"browser", MENU_FOLDER},
 {"compose", MENU_COMPOSE},
 {"editor", MENU_EDITOR},
 {"index", MENU_MAIN},
 {"pager", MENU_PAGER},
 {"postpone", MENU_POST},
 {"pgp", MENU_PGP},
 {"smime", MENU_SMIME},
 
 #ifdef HAVE_GPGME
{ "key_select_pgp",   MENU_KEY_SELECT_PGP },
{ "key_select_smime", MENU_KEY_SELECT_SMIME },
 {"key_select_pgp", MENU_KEY_SELECT_PGP},
 {"key_select_smime", MENU_KEY_SELECT_SMIME},
 #endif
 
+
 #ifdef MIXMASTER
-  { "mix",         MENU_MIX },
+  {"mix", MENU_MIX},
 #endif
-  
 
- { "query",        MENU_QUERY },
- { "generic",        MENU_GENERIC },
- { NULL,        0 }
+
+  {"query", MENU_QUERY},
+  {"generic", MENU_GENERIC},
+  {NULL, 0}
 };
 
 #define mutt_check_menu(s) mutt_getvaluebyname(s, Menus)
 
 static struct mapping_t KeyNames[] = {
-  { "<PageUp>",        KEY_PPAGE },
-  { "<PageDown>",        KEY_NPAGE },
-  { "<Up>",        KEY_UP },
-  { "<Down>",        KEY_DOWN },
-  { "<Right>",        KEY_RIGHT },
-  { "<Left>",        KEY_LEFT },
-  { "<Delete>",        KEY_DC },
-  { "<BackSpace>",KEY_BACKSPACE },
-  { "<Insert>",        KEY_IC },
-  { "<Home>",        KEY_HOME },
-  { "<End>",        KEY_END },
+  {"<PageUp>", KEY_PPAGE},
+  {"<PageDown>", KEY_NPAGE},
+  {"<Up>", KEY_UP},
+  {"<Down>", KEY_DOWN},
+  {"<Right>", KEY_RIGHT},
+  {"<Left>", KEY_LEFT},
+  {"<Delete>", KEY_DC},
+  {"<BackSpace>", KEY_BACKSPACE},
+  {"<Insert>", KEY_IC},
+  {"<Home>", KEY_HOME},
+  {"<End>", KEY_END},
 #ifdef KEY_ENTER
-  { "<Enter>",        KEY_ENTER },
+  {"<Enter>", KEY_ENTER},
 #endif
-  { "<Return>",        M_ENTER_C },
-  { "<Esc>",        '\033' },
-  { "<Tab>",        '\t' },
-  { "<Space>",        ' ' },
+  {"<Return>", M_ENTER_C},
+  {"<Esc>", '\033'},
+  {"<Tab>", '\t'},
+  {"<Space>", ' '},
 #ifdef KEY_BTAB
-  { "<BackTab>", KEY_BTAB },
+  {"<BackTab>", KEY_BTAB},
 #endif
-  { NULL,        0 }
+  {NULL, 0}
 };
 
 /* contains the last key the user pressed */
@@ -93,7 +93,7 @@ int LastKey;
 
 struct keymap_t *Keymaps[MENU_MAX];
 
-static struct keymap_t *allocKeys (int len, keycode_t *keys)
+static struct keymap_t *allocKeys (int len, keycode_t * keys)
 {
   struct keymap_t *p;
 
@@ -104,21 +104,20 @@ static struct keymap_t *allocKeys (int len, keycode_t *keys)
   return (p);
 }
 
-static int parse_fkey(char *s)
+static int parse_fkey (char *s)
 {
   char *t;
   int n = 0;
 
-  if(s[0] != '<' || ascii_tolower(s[1]) != 'f')
+  if (s[0] != '<' || ascii_tolower (s[1]) != 'f')
     return -1;
 
-  for(t = s + 2; *t && isdigit((unsigned char) *t); t++)
-  {
+  for (t = s + 2; *t && isdigit ((unsigned char) *t); t++) {
     n *= 10;
     n += *t - '0';
   }
 
-  if(*t != '>')
+  if (*t != '>')
     return -1;
   else
     return n;
@@ -132,53 +131,47 @@ static int parse_keycode (const char *s)
 {
   if (isdigit ((unsigned char) s[1]) &&
       isdigit ((unsigned char) s[2]) &&
-      isdigit ((unsigned char) s[3]) &&
-      s[4] == '>')
-  {
+      isdigit ((unsigned char) s[3]) && s[4] == '>') {
     return (s[3] - '0') + (s[2] - '0') * 8 + (s[1] - '0') * 64;
   }
   return -1;
 }
 
-static int parsekeys (char *str, keycode_t *d, int max)
+static int parsekeys (char *str, keycode_t * d, int max)
 {
   int n, len = max;
   char buff[SHORT_STRING];
   char c;
   char *s, *t;
 
-  strfcpy(buff, str, sizeof(buff));
+  strfcpy (buff, str, sizeof (buff));
   s = buff;
-  
-  while (*s && len)
-  {
+
+  while (*s && len) {
     *d = '\0';
-    if(*s == '<' && (t = strchr(s, '>')))
-    {
-      t++; c = *t; *t = '\0';
-      
-      if ((n = mutt_getvaluebyname (s, KeyNames)) != -1)
-      {
+    if (*s == '<' && (t = strchr (s, '>'))) {
+      t++;
+      c = *t;
+      *t = '\0';
+
+      if ((n = mutt_getvaluebyname (s, KeyNames)) != -1) {
         s = t;
         *d = n;
       }
-      else if ((n = parse_fkey(s)) > 0)
-      {
+      else if ((n = parse_fkey (s)) > 0) {
         s = t;
         *d = KEY_F (n);
       }
-      else if ((n = parse_keycode(s)) > 0)
-      {
+      else if ((n = parse_keycode (s)) > 0) {
         s = t;
         *d = n;
       }
-      
+
       *t = c;
     }
 
-    if(!*d)
-    {
-      *d = (unsigned char)*s;
+    if (!*d) {
+      *d = (unsigned char) *s;
       s++;
     }
     d++;
@@ -206,13 +199,10 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr)
 
   tmp = Keymaps[menu];
 
-  while (tmp)
-  {
-    if (pos >= len || pos >= tmp->len)
-    {
+  while (tmp) {
+    if (pos >= len || pos >= tmp->len) {
       /* map and tmp match, but have different lengths, so overwrite */
-      do
-      {
+      do {
         len = tmp->eq;
         next = tmp->next;
         FREE (&tmp->macro);
@@ -227,14 +217,13 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr)
     }
     else if (buf[pos] == tmp->keys[pos])
       pos++;
-    else if (buf[pos] < tmp->keys[pos])
-    {
+    else if (buf[pos] < tmp->keys[pos]) {
       /* found location to insert between last and tmp */
       map->eq = pos;
       break;
     }
-    else /* buf[pos] > tmp->keys[pos] */
-    {
+    else {                      /* buf[pos] > tmp->keys[pos] */
+
       last = tmp;
       lastpos = pos;
       if (pos > tmp->eq)
@@ -244,8 +233,7 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr)
   }
 
   map->next = tmp;
-  if (last)
-  {
+  if (last) {
     last->next = map;
     last->eq = lastpos;
   }
@@ -262,9 +250,8 @@ static int get_op (struct binding_t *bindings, const char *start, size_t len)
 {
   int i;
 
-  for (i = 0; bindings[i].name; i++)
-  {
-    if (!ascii_strncasecmp (start, bindings[i].name, len) &&   
+  for (i = 0; bindings[i].name; i++) {
+    if (!ascii_strncasecmp (start, bindings[i].name, len) &&
         mutt_strlen (bindings[i].name) == len)
       return bindings[i].op;
   }
@@ -276,8 +263,7 @@ static char *get_func (struct binding_t *bindings, int op)
 {
   int i;
 
-  for (i = 0; bindings[i].name; i++)
-  {
+  for (i = 0; bindings[i].name; i++) {
     if (bindings[i].op == op) {
       return bindings[i].name;
     }
@@ -292,31 +278,24 @@ static void push_string (char *s)
   size_t l;
   int i, op = OP_NULL;
 
-  while (p >= s)
-  {
+  while (p >= s) {
     /* if we see something like "<PageUp>", look to see if it is a real
        function name and return the corresponding value */
-    if (*p == '>')
-    {
-      for (pp = p - 1; pp >= s && *pp != '<'; pp--)
-        ;
-      if (pp >= s)
-      {
-        if ((i = parse_fkey (pp)) > 0)
-        {
+    if (*p == '>') {
+      for (pp = p - 1; pp >= s && *pp != '<'; pp--);
+      if (pp >= s) {
+        if ((i = parse_fkey (pp)) > 0) {
           mutt_ungetch (KEY_F (i), 0);
           p = pp - 1;
           continue;
         }
 
         l = p - pp + 1;
-        for (i = 0; KeyNames[i].name; i++)
-        {
+        for (i = 0; KeyNames[i].name; i++) {
           if (!ascii_strncasecmp (pp, KeyNames[i].name, l))
             break;
         }
-        if (KeyNames[i].name)
-        {
+        if (KeyNames[i].name) {
           /* found a match */
           mutt_ungetch (KeyNames[i].value, 0);
           p = pp - 1;
@@ -325,19 +304,17 @@ static void push_string (char *s)
 
         /* See if it is a valid command
          * skip the '<' and the '>' when comparing */
-        for (i = 0; Menus[i].name; i++)
-        {
+        for (i = 0; Menus[i].name; i++) {
           struct binding_t *binding = km_get_table (Menus[i].value);
-          if (binding)
-          {
+
+          if (binding) {
             op = get_op (binding, pp + 1, l - 2);
             if (op != OP_NULL)
               break;
           }
         }
 
-        if (op != OP_NULL)
-        {
+        if (op != OP_NULL) {
           mutt_ungetch (0, op);
           p = pp - 1;
           continue;
@@ -348,18 +325,17 @@ static void push_string (char *s)
   }
 }
 
-static int retry_generic (int menu, keycode_t *keys, int keyslen, int lastkey)
+static int retry_generic (int menu, keycode_t * keys, int keyslen,
+                          int lastkey)
 {
-  if (menu != MENU_EDITOR && menu != MENU_GENERIC && menu != MENU_PAGER)
-  {
+  if (menu != MENU_EDITOR && menu != MENU_GENERIC && menu != MENU_PAGER) {
     if (lastkey)
       mutt_ungetch (lastkey, 0);
     for (; keyslen; keyslen--)
       mutt_ungetch (keys[keyslen - 1], 0);
     return (km_dokey (MENU_GENERIC));
   }
-  if (menu != MENU_EDITOR)
-  {
+  if (menu != MENU_EDITOR) {
     /* probably a good idea to flush input here so we can abort macros */
     mutt_flushinp ();
   }
@@ -383,24 +359,22 @@ int km_dokey (int menu)
   if (!map)
     return (retry_generic (menu, NULL, 0, 0));
 
-  FOREVER
-  {
+  FOREVER {
     /* ncurses doesn't return on resized screen when timeout is set to zero */
     if (menu != MENU_EDITOR)
       timeout ((Timeout > 0 ? Timeout : 60) * 1000);
 
-    tmp = mutt_getch();
+    tmp = mutt_getch ();
 
     if (menu != MENU_EDITOR)
-      timeout (-1); /* restore blocking operation */
+      timeout (-1);             /* restore blocking operation */
 
     LastKey = tmp.ch;
     if (LastKey == -1)
       return -1;
 
     /* do we have an op already? */
-    if (tmp.op)
-    {
+    if (tmp.op) {
       char *func = NULL;
       struct binding_t *bindings;
 
@@ -412,26 +386,22 @@ int km_dokey (int menu)
       if (menu == MENU_EDITOR && get_func (OpEditor, tmp.op))
         return tmp.op;
 
-      if (menu != MENU_EDITOR && menu != MENU_PAGER)
-      {
+      if (menu != MENU_EDITOR && menu != MENU_PAGER) {
         /* check generic menu */
-        bindings = OpGeneric; 
+        bindings = OpGeneric;
         if ((func = get_func (bindings, tmp.op)))
           return tmp.op;
       }
 
       /* Sigh. Valid function but not in this context.
        * Find the literal string and push it back */
-      for (i = 0; Menus[i].name; i++)
-      {
+      for (i = 0; Menus[i].name; i++) {
         bindings = km_get_table (Menus[i].value);
-        if (bindings)
-        {
+        if (bindings) {
           func = get_func (bindings, tmp.op);
-          if (func)
-          {
+          if (func) {
             /* careful not to feed the <..> as one token. otherwise 
-            * push_string() will push the bogus op right back! */
+             * push_string() will push the bogus op right back! */
             mutt_ungetch ('>', 0);
             push_string (func);
             mutt_ungetch ('<', 0);
@@ -445,8 +415,7 @@ int km_dokey (int menu)
     }
 
     /* Nope. Business as usual */
-    while (LastKey > map->keys[pos])
-    {
+    while (LastKey > map->keys[pos]) {
       if (pos > map->eq || !map->next)
         return (retry_generic (menu, map->keys, pos, LastKey));
       map = map->next;
@@ -455,16 +424,15 @@ int km_dokey (int menu)
     if (LastKey != map->keys[pos])
       return (retry_generic (menu, map->keys, pos, LastKey));
 
-    if (++pos == map->len)
-    {
+    if (++pos == map->len) {
 
       if (map->op != OP_MACRO)
         return map->op;
 
-      if (n++ == 10)
-      {
+      if (n++ == 10) {
         mutt_flushinp ();
         mutt_error _("Macro loop detected.");
+
         return -1;
       }
 
@@ -481,7 +449,7 @@ static void create_bindings (struct binding_t *map, int menu)
 {
   int i;
 
-  for (i = 0 ; map[i].name ; i++)
+  for (i = 0; map[i].name; i++)
     if (map[i].seq)
       km_bindkey (map[i].seq, menu, map[i].op);
 }
@@ -494,13 +462,11 @@ char *km_keyname (int c)
   if ((p = mutt_getnamebyvalue (c, KeyNames)))
     return p;
 
-  if (c < 256 && c > -128 && iscntrl ((unsigned char) c))
-  {
+  if (c < 256 && c > -128 && iscntrl ((unsigned char) c)) {
     if (c < 0)
       c += 256;
 
-    if (c < 128)
-    {
+    if (c < 128) {
       buf[0] = '^';
       buf[1] = (c + '@') & 0x7f;
       buf[2] = 0;
@@ -508,7 +474,7 @@ char *km_keyname (int c)
     else
       snprintf (buf, sizeof (buf), "\\%d%d%d", c >> 6, (c >> 3) & 7, c & 7);
   }
-  else if (c >= KEY_F0 && c < KEY_F(256)) /* this maximum is just a guess */
+  else if (c >= KEY_F0 && c < KEY_F (256))      /* this maximum is just a guess */
     sprintf (buf, "<F%d>", c - KEY_F0);
   else if (IsPrint (c))
     snprintf (buf, sizeof (buf), "%c", (unsigned char) c);
@@ -525,8 +491,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map)
   if (!map)
     return (0);
 
-  FOREVER
-  {
+  FOREVER {
     strfcpy (s, km_keyname (map->keys[p]), len);
     len -= (l = mutt_strlen (s));
 
@@ -576,15 +541,15 @@ void km_init (void)
 
 #ifdef MIXMASTER
   create_bindings (OpMix, MENU_MIX);
-  
+
   km_bindkey ("<space>", MENU_MIX, OP_GENERIC_SELECT_ENTRY);
   km_bindkey ("h", MENU_MIX, OP_MIX_CHAIN_PREV);
   km_bindkey ("l", MENU_MIX, OP_MIX_CHAIN_NEXT);
 #endif
-  
+
   /* bindings for the line editor */
   create_bindings (OpEditor, MENU_EDITOR);
-  
+
   km_bindkey ("<up>", MENU_EDITOR, OP_EDITOR_HISTORY_UP);
   km_bindkey ("<down>", MENU_EDITOR, OP_EDITOR_HISTORY_DOWN);
   km_bindkey ("<left>", MENU_EDITOR, OP_EDITOR_BACKWARD_CHAR);
@@ -594,10 +559,10 @@ void km_init (void)
   km_bindkey ("<backspace>", MENU_EDITOR, OP_EDITOR_BACKSPACE);
   km_bindkey ("<delete>", MENU_EDITOR, OP_EDITOR_BACKSPACE);
   km_bindkey ("\177", MENU_EDITOR, OP_EDITOR_BACKSPACE);
-  
+
   /* generic menu keymap */
   create_bindings (OpGeneric, MENU_GENERIC);
-  
+
   km_bindkey ("<home>", MENU_GENERIC, OP_FIRST_ENTRY);
   km_bindkey ("<end>", MENU_GENERIC, OP_LAST_ENTRY);
   km_bindkey ("<pagedown>", MENU_GENERIC, OP_NEXT_PAGE);
@@ -619,7 +584,7 @@ void km_init (void)
   km_bindkey ("<enter>", MENU_GENERIC, OP_GENERIC_SELECT_ENTRY);
 
   /* Miscellaneous extra bindings */
-  
+
   km_bindkey (" ", MENU_MAIN, OP_DISPLAY_MESSAGE);
   km_bindkey ("<up>", MENU_MAIN, OP_MAIN_PREV_UNDELETED);
   km_bindkey ("<down>", MENU_MAIN, OP_MAIN_NEXT_UNDELETED);
@@ -650,9 +615,9 @@ void km_init (void)
   km_bindkey ("9", MENU_PAGER, OP_JUMP);
 
   km_bindkey ("<enter>", MENU_PAGER, OP_NEXT_LINE);
-  
+
   km_bindkey ("<return>", MENU_ALIAS, OP_GENERIC_SELECT_ENTRY);
-  km_bindkey ("<enter>",  MENU_ALIAS, OP_GENERIC_SELECT_ENTRY);
+  km_bindkey ("<enter>", MENU_ALIAS, OP_GENERIC_SELECT_ENTRY);
   km_bindkey ("<space>", MENU_ALIAS, OP_TAG);
 
   km_bindkey ("<enter>", MENU_ATTACH, OP_VIEW_ATTACH);
@@ -668,20 +633,20 @@ void km_error_key (int menu)
   char buf[SHORT_STRING];
   struct keymap_t *key;
 
-  if(!(key = km_find_func(menu, OP_HELP)))
-    key = km_find_func(MENU_GENERIC, OP_HELP);
-  
-  if(!(km_expand_key(buf, sizeof(buf), key)))
-  {
+  if (!(key = km_find_func (menu, OP_HELP)))
+    key = km_find_func (MENU_GENERIC, OP_HELP);
+
+  if (!(km_expand_key (buf, sizeof (buf), key))) {
     mutt_error _("Key is not bound.");
+
     return;
   }
 
   /* make sure the key is really the help key in this menu */
   push_string (buf);
-  if (km_dokey (menu) != OP_HELP)
-  {
+  if (km_dokey (menu) != OP_HELP) {
     mutt_error _("Key is not bound.");
+
     return;
   }
 
@@ -689,13 +654,13 @@ void km_error_key (int menu)
   return;
 }
 
-int mutt_parse_push (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_push (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err)
 {
   int r = 0;
 
   mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
-  if (MoreArgs (s))
-  {
+  if (MoreArgs (s)) {
     strfcpy (err->data, _("push: too many arguments"), err->dsize);
     r = -1;
   }
@@ -705,10 +670,11 @@ int mutt_parse_push (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 }
 
 /* expects to see: <menu-string>,<menu-string>,... <key-string> */
-static char *parse_keymap (int *menu, BUFFER *s, int maxmenus, int *nummenus, BUFFER *err)
+static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus,
+                           BUFFER * err)
 {
   BUFFER buf;
-  int i=0;
+  int i = 0;
   char *p, *q;
 
   memset (&buf, 0, sizeof (buf));
@@ -716,38 +682,33 @@ static char *parse_keymap (int *menu, BUFFER *s, int maxmenus, int *nummenus, BU
   /* menu name */
   mutt_extract_token (&buf, s, 0);
   p = buf.data;
-  if (MoreArgs (s))
-  {
-    while (i < maxmenus)
-    {
-      q = strchr(p,',');
+  if (MoreArgs (s)) {
+    while (i < maxmenus) {
+      q = strchr (p, ',');
       if (q)
         *q = '\0';
 
-      if ((menu[i] = mutt_check_menu (p)) == -1)
-      {
-         snprintf (err->data, err->dsize, _("%s: no such menu"), p);
-         goto error;
+      if ((menu[i] = mutt_check_menu (p)) == -1) {
+        snprintf (err->data, err->dsize, _("%s: no such menu"), p);
+        goto error;
       }
       ++i;
       if (q)
-        p = q+1;
+        p = q + 1;
       else
         break;
     }
-    *nummenus=i;
+    *nummenus = i;
     /* key sequence */
     mutt_extract_token (&buf, s, 0);
 
-    if (!*buf.data)
-    {
+    if (!*buf.data) {
       strfcpy (err->data, _("null key sequence"), err->dsize);
     }
     else if (MoreArgs (s))
       return (buf.data);
   }
-  else
-  {
+  else {
     strfcpy (err->data, _("too few arguments"), err->dsize);
   }
 error:
@@ -759,10 +720,9 @@ static int
 try_bind (char *key, int menu, char *func, struct binding_t *bindings)
 {
   int i;
-  
+
   for (i = 0; bindings[i].name; i++)
-    if (mutt_strcmp (func, bindings[i].name) == 0)
-    {
+    if (mutt_strcmp (func, bindings[i].name) == 0) {
       km_bindkey (key, menu, bindings[i].op);
       return (0);
     }
@@ -771,42 +731,41 @@ try_bind (char *key, int menu, char *func, struct binding_t *bindings)
 
 struct binding_t *km_get_table (int menu)
 {
-  switch (menu)
-  {
-    case MENU_MAIN:
-      return OpMain;
-    case MENU_GENERIC:
-      return OpGeneric;
-    case MENU_COMPOSE:
-      return OpCompose;
-    case MENU_PAGER:
-      return OpPager;
-    case MENU_POST:
-      return OpPost;
-    case MENU_FOLDER:
-      return OpBrowser;
-    case MENU_ALIAS:
-      return OpAlias;
-    case MENU_ATTACH:
-      return OpAttach;
-    case MENU_EDITOR:
-      return OpEditor;
-    case MENU_QUERY:
-      return OpQuery;
-
-    case MENU_PGP:
-      return (WithCrypto & APPLICATION_PGP)? OpPgp:NULL;
+  switch (menu) {
+  case MENU_MAIN:
+    return OpMain;
+  case MENU_GENERIC:
+    return OpGeneric;
+  case MENU_COMPOSE:
+    return OpCompose;
+  case MENU_PAGER:
+    return OpPager;
+  case MENU_POST:
+    return OpPost;
+  case MENU_FOLDER:
+    return OpBrowser;
+  case MENU_ALIAS:
+    return OpAlias;
+  case MENU_ATTACH:
+    return OpAttach;
+  case MENU_EDITOR:
+    return OpEditor;
+  case MENU_QUERY:
+    return OpQuery;
+
+  case MENU_PGP:
+    return (WithCrypto & APPLICATION_PGP) ? OpPgp : NULL;
 
 #ifdef CRYPT_BACKEND_GPGME
-    case MENU_KEY_SELECT_PGP:
-      return OpPgp;
-    case MENU_KEY_SELECT_SMIME:
-      return OpSmime;
+  case MENU_KEY_SELECT_PGP:
+    return OpPgp;
+  case MENU_KEY_SELECT_SMIME:
+    return OpSmime;
 #endif
 
 #ifdef MIXMASTER
-    case MENU_MIX:
-      return OpMix;
+  case MENU_MIX:
+    return OpMix;
 #endif
 
   }
@@ -814,44 +773,40 @@ struct binding_t *km_get_table (int menu)
 }
 
 /* bind menu-name '<key_sequence>' function-name */
-int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_bind (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err)
 {
   struct binding_t *bindings = NULL;
   char *key;
-  int menu[sizeof(Menus)/sizeof(struct mapping_t)-1], r = 0, nummenus, i;
+  int menu[sizeof (Menus) / sizeof (struct mapping_t) - 1], r =
+    0, nummenus, i;
 
-  if ((key = parse_keymap (menu, s, sizeof (menu)/sizeof (menu[0]),
-                          &nummenus, err)) == NULL)
+  if ((key = parse_keymap (menu, s, sizeof (menu) / sizeof (menu[0]),
+                           &nummenus, err)) == NULL)
     return (-1);
 
   /* function to execute */
   mutt_extract_token (buf, s, 0);
-  if (MoreArgs (s))
-  {
+  if (MoreArgs (s)) {
     strfcpy (err->data, _("bind: too many arguments"), err->dsize);
     r = -1;
   }
-  else if (ascii_strcasecmp ("noop", buf->data) == 0)
-  {
-    for (i = 0; i < nummenus; ++i)
-    {
-      km_bindkey (key, menu[i], OP_NULL); /* the `unbind' command */
+  else if (ascii_strcasecmp ("noop", buf->data) == 0) {
+    for (i = 0; i < nummenus; ++i) {
+      km_bindkey (key, menu[i], OP_NULL);       /* the `unbind' command */
     }
   }
-  else
-  {
-    for (i = 0; i < nummenus; ++i)
-    {
+  else {
+    for (i = 0; i < nummenus; ++i) {
       /* First check the "generic" list of commands */
       if (menu[i] == MENU_PAGER || menu[i] == MENU_EDITOR ||
-      menu[i] == MENU_GENERIC ||
-         try_bind (key, menu[i], buf->data, OpGeneric) != 0)
-      {
+          menu[i] == MENU_GENERIC ||
+          try_bind (key, menu[i], buf->data, OpGeneric) != 0) {
         /* Now check the menu-specific list of commands (if they exist) */
         bindings = km_get_table (menu[i]);
-        if (bindings && try_bind (key, menu[i], buf->data, bindings) != 0)
-        {
-          snprintf (err->data, err->dsize, _("%s: no such function in map"), buf->data);
+        if (bindings && try_bind (key, menu[i], buf->data, bindings) != 0) {
+          snprintf (err->data, err->dsize, _("%s: no such function in map"),
+                    buf->data);
           r = -1;
         }
       }
@@ -862,36 +817,34 @@ int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 }
 
 /* macro <menu> <key> <macro> <description> */
-int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data,
+                      BUFFER * err)
 {
-  int menu[sizeof(Menus)/sizeof(struct mapping_t)-1], r = -1, nummenus, i;
+  int menu[sizeof (Menus) / sizeof (struct mapping_t) - 1], r =
+    -1, nummenus, i;
   char *seq = NULL;
   char *key;
 
-  if ((key = parse_keymap (menu, s, sizeof (menu) / sizeof (menu[0]), &nummenus, err)) == NULL)
+  if ((key =
+       parse_keymap (menu, s, sizeof (menu) / sizeof (menu[0]), &nummenus,
+                     err)) == NULL)
     return (-1);
 
   mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
   /* make sure the macro sequence is not an empty string */
-  if (!*buf->data)
-  {
+  if (!*buf->data) {
     strfcpy (err->data, _("macro: empty key sequence"), err->dsize);
   }
-  else
-  {
-    if (MoreArgs (s))
-    {
+  else {
+    if (MoreArgs (s)) {
       seq = safe_strdup (buf->data);
       mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
 
-      if (MoreArgs (s))
-      {
+      if (MoreArgs (s)) {
         strfcpy (err->data, _("macro: too many arguments"), err->dsize);
       }
-      else
-      {
-        for (i = 0; i < nummenus; ++i)
-        {
+      else {
+        for (i = 0; i < nummenus; ++i) {
           km_bind (key, menu[i], OP_MACRO, seq, buf->data);
           r = 0;
         }
@@ -899,10 +852,8 @@ int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 
       FREE (&seq);
     }
-    else
-    {
-      for (i = 0; i < nummenus; ++i)
-      {
+    else {
+      for (i = 0; i < nummenus; ++i) {
         km_bind (key, menu[i], OP_MACRO, buf->data, NULL);
         r = 0;
       }
@@ -913,44 +864,42 @@ int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
 }
 
 /* exec function-name */
-int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data,
+                     BUFFER * err)
 {
-  int ops[128]; 
+  int ops[128];
   int nops = 0;
   struct binding_t *bindings = NULL;
   char *function;
 
-  if (!MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("exec: no arguments"), err->dsize);
     return (-1);
   }
 
-  do
-  {
+  do {
     mutt_extract_token (buf, s, 0);
     function = buf->data;
 
-    if ((bindings = km_get_table (CurrentMenu)) == NULL 
+    if ((bindings = km_get_table (CurrentMenu)) == NULL
         && CurrentMenu != MENU_PAGER)
       bindings = OpGeneric;
 
-    ops[nops] = get_op (bindings, function, mutt_strlen(function));
+    ops[nops] = get_op (bindings, function, mutt_strlen (function));
     if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER)
-      ops[nops] = get_op (OpGeneric, function, mutt_strlen(function));
+      ops[nops] = get_op (OpGeneric, function, mutt_strlen (function));
 
-    if (ops[nops] == OP_NULL)
-    {
+    if (ops[nops] == OP_NULL) {
       mutt_flushinp ();
       mutt_error (_("%s: no such function"), function);
       return (-1);
     }
     nops++;
   }
-  while(MoreArgs(s) && nops < sizeof(ops)/sizeof(ops[0]));
+  while (MoreArgs (s) && nops < sizeof (ops) / sizeof (ops[0]));
 
-  while(nops)
-    mutt_ungetch(0, ops[--nops]);
+  while (nops)
+    mutt_ungetch (0, ops[--nops]);
 
   return 0;
 }
@@ -963,16 +912,15 @@ void mutt_what_key (void)
 {
   int ch;
 
-  mvprintw(LINES-1,0, _("Enter keys (^G to abort): "));
+  mvprintw (LINES - 1, 0, _("Enter keys (^G to abort): "));
   do {
-    ch = getch();
-    if (ch != ERR && ch != ctrl ('G'))
-    {
-      mutt_message(_("Char = %s, Octal = %o, Decimal = %d"),
-               km_keyname(ch), ch, ch);
+    ch = getch ();
+    if (ch != ERR && ch != ctrl ('G')) {
+      mutt_message (_("Char = %s, Octal = %o, Decimal = %d"),
+                    km_keyname (ch), ch, ch);
     }
   }
   while (ch != ERR && ch != ctrl ('G'));
 
-  mutt_flushinp();
+  mutt_flushinp ();
 }
index 4a75c6a..9c7fecb 100644 (file)
--- a/keymap.h
+++ b/keymap.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef KEYMAP_H
 #define KEYMAP_H
@@ -32,15 +32,14 @@ void km_bindkey (char *, int, int);
 int km_dokey (int);
 
 /* entry in the keymap tree */
-struct keymap_t
-{
-  char *macro;           /* macro expansion (op == OP_MACRO) */
-  char *descr;           /* description of a macro for the help menu */
-  struct keymap_t *next; /* next key in map */
-  short op;              /* operation to perform */
-  short eq;              /* number of leading keys equal to next entry */
-  short len;             /* length of key sequence (unit: sizeof (keycode_t)) */
-  keycode_t *keys;       /* key sequence */
+struct keymap_t {
+  char *macro;                  /* macro expansion (op == OP_MACRO) */
+  char *descr;                  /* description of a macro for the help menu */
+  struct keymap_t *next;        /* next key in map */
+  short op;                     /* operation to perform */
+  short eq;                     /* number of leading keys equal to next entry */
+  short len;                    /* length of key sequence (unit: sizeof (keycode_t)) */
+  keycode_t *keys;              /* key sequence */
 };
 
 char *km_keyname (int);
@@ -50,8 +49,7 @@ void km_init (void);
 void km_error_key (int);
 void mutt_what_key (void);
 
-enum
-{
+enum {
   MENU_ALIAS,
   MENU_ATTACH,
   MENU_COMPOSE,
@@ -63,7 +61,7 @@ enum
   MENU_POST,
   MENU_QUERY,
 
-  
+
   MENU_PGP,
   MENU_SMIME,
 
@@ -71,7 +69,7 @@ enum
   MENU_KEY_SELECT_PGP,
   MENU_KEY_SELECT_SMIME,
 #endif
-  
+
 #ifdef MIXMASTER
   MENU_MIX,
 #endif
@@ -89,11 +87,10 @@ extern int LastKey;
 
 extern struct mapping_t Menus[];
 
-struct binding_t
-{
-  char *name;  /* name of the function */
-  int op;      /* function id number */
-  char *seq;   /* default key binding */
+struct binding_t {
+  char *name;                   /* name of the function */
+  int op;                       /* function id number */
+  char *seq;                    /* default key binding */
 };
 
 struct binding_t *km_get_table (int menu);
diff --git a/lib.c b/lib.c
index 28162b6..96e3e65 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -18,7 +18,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * This file used to contain some more functions, namely those
@@ -61,16 +61,16 @@ void *safe_calloc (size_t nmemb, size_t size)
   if (!nmemb || !size)
     return NULL;
 
-  if (((size_t) -1) / nmemb <= size)
-  {
+  if (((size_t) - 1) / nmemb <= size) {
     mutt_error _("Integer overflow -- can't allocate memory!");
+
     sleep (1);
     mutt_exit (1);
   }
-  
-  if (!(p = calloc (nmemb, size)))
-  {
+
+  if (!(p = calloc (nmemb, size))) {
     mutt_error _("Out of memory!");
+
     sleep (1);
     mutt_exit (1);
   }
@@ -83,9 +83,9 @@ void *safe_malloc (size_t siz)
 
   if (siz == 0)
     return 0;
-  if ((p = (void *) malloc (siz)) == 0)        /* __MEM_CHECKED__ */
-  {
+  if ((p = (void *) malloc (siz)) == 0) {       /* __MEM_CHECKED__ */
     mutt_error _("Out of memory!");
+
     sleep (1);
     mutt_exit (1);
   }
@@ -95,29 +95,26 @@ void *safe_malloc (size_t siz)
 void safe_realloc (void *ptr, size_t siz)
 {
   void *r;
-  void **p = (void **)ptr;
+  void **p = (void **) ptr;
 
-  if (siz == 0)
-  {
-    if (*p)
-    {
-      free (*p);                       /* __MEM_CHECKED__ */
+  if (siz == 0) {
+    if (*p) {
+      free (*p);                /* __MEM_CHECKED__ */
       *p = NULL;
     }
     return;
   }
 
   if (*p)
-    r = (void *) realloc (*p, siz);    /* __MEM_CHECKED__ */
-  else
-  {
+    r = (void *) realloc (*p, siz);     /* __MEM_CHECKED__ */
+  else {
     /* realloc(NULL, nbytes) doesn't seem to work under SunOS 4.1.x  --- __MEM_CHECKED__ */
-    r = (void *) malloc (siz);         /* __MEM_CHECKED__ */
+    r = (void *) malloc (siz);  /* __MEM_CHECKED__ */
   }
 
-  if (!r)
-  {
+  if (!r) {
     mutt_error _("Out of memory!");
+
     sleep (1);
     mutt_exit (1);
   }
@@ -127,21 +124,21 @@ void safe_realloc (void *ptr, size_t siz)
 
 void safe_free (void *ptr)
 {
-  void **p = (void **)ptr;
-  if (*p)
-  {
-    free (*p);                         /* __MEM_CHECKED__ */
+  void **p = (void **) ptr;
+
+  if (*p) {
+    free (*p);                  /* __MEM_CHECKED__ */
     *p = 0;
   }
 }
 
-int safe_fclose (FILE **f)
+int safe_fclose (FILE ** f)
 {
   int r = 0;
-  
+
   if (*f)
     r = fclose (*f);
-      
+
   *f = NULL;
   return r;
 }
@@ -154,7 +151,7 @@ char *safe_strdup (const char *s)
   if (!s || !*s)
     return 0;
   l = strlen (s) + 1;
-  p = (char *)safe_malloc (l);
+  p = (char *) safe_malloc (l);
   memcpy (p, s, l);
   return (p);
 }
@@ -163,18 +160,18 @@ char *safe_strcat (char *d, size_t l, const char *s)
 {
   char *p = d;
 
-  if (!l) 
+  if (!l)
     return d;
 
-  l--; /* Space for the trailing '\0'. */
-  
+  l--;                          /* Space for the trailing '\0'. */
+
   for (; *d && l; l--)
     d++;
   for (; *s && l; l--)
     *d++ = *s++;
 
   *d = '\0';
-  
+
   return p;
 }
 
@@ -184,16 +181,16 @@ char *safe_strncat (char *d, size_t l, const char *s, size_t sl)
 
   if (!l)
     return d;
-  
-  l--; /* Space for the trailing '\0'. */
-  
+
+  l--;                          /* Space for the trailing '\0'. */
+
   for (; *d && l; l--)
     d++;
   for (; *s && l && sl; l--, sl--)
     *d++ = *s++;
 
   *d = '\0';
-  
+
   return p;
 }
 
@@ -206,7 +203,8 @@ void mutt_str_replace (char **p, const char *s)
 
 void mutt_str_adjust (char **p)
 {
-  if (!p || !*p) return;
+  if (!p || !*p)
+    return;
   safe_realloc (p, strlen (*p) + 1);
 }
 
@@ -215,8 +213,7 @@ char *mutt_strlower (char *s)
 {
   char *p = s;
 
-  while (*p)
-  {
+  while (*p) {
     *p = tolower ((unsigned char) *p);
     p++;
   }
@@ -233,51 +230,45 @@ void mutt_unlink (const char *s)
   char buf[2048];
 
   /* Defend against symlink attacks */
-  
-#ifdef O_NOFOLLOW 
+
+#ifdef O_NOFOLLOW
   flags = O_RDWR | O_NOFOLLOW;
 #else
   flags = O_RDWR;
 #endif
-  
-  if (lstat (s, &sb) == 0 && S_ISREG(sb.st_mode))
-  {
+
+  if (lstat (s, &sb) == 0 && S_ISREG (sb.st_mode)) {
     if ((fd = open (s, flags)) < 0)
       return;
-    
-    if ((fstat (fd, &sb2) != 0) || !S_ISREG (sb2.st_mode) 
-       || (sb.st_dev != sb2.st_dev) || (sb.st_ino != sb2.st_ino))
-    {
+
+    if ((fstat (fd, &sb2) != 0) || !S_ISREG (sb2.st_mode)
+        || (sb.st_dev != sb2.st_dev) || (sb.st_ino != sb2.st_ino)) {
       close (fd);
       return;
     }
-    
-    if ((f = fdopen (fd, "r+")))
-    {
+
+    if ((f = fdopen (fd, "r+"))) {
       unlink (s);
       memset (buf, 0, sizeof (buf));
-      while (sb.st_size > 0)
-      {
-       fwrite (buf, 1, MIN (sizeof (buf), sb.st_size), f);
-       sb.st_size -= MIN (sizeof (buf), sb.st_size);
+      while (sb.st_size > 0) {
+        fwrite (buf, 1, MIN (sizeof (buf), sb.st_size), f);
+        sb.st_size -= MIN (sizeof (buf), sb.st_size);
       }
       fclose (f);
     }
   }
 }
 
-int mutt_copy_bytes (FILE *in, FILE *out, size_t size)
+int mutt_copy_bytes (FILE * in, FILE * out, size_t size)
 {
   char buf[2048];
   size_t chunk;
 
-  while (size > 0)
-  {
+  while (size > 0) {
     chunk = (size > sizeof (buf)) ? sizeof (buf) : size;
     if ((chunk = fread (buf, 1, chunk, in)) < 1)
       break;
-    if (fwrite (buf, 1, chunk, out) != chunk)
-    {
+    if (fwrite (buf, 1, chunk, out) != chunk) {
       /* dprint (1, (debugfile, "mutt_copy_bytes(): fwrite() returned short byte count\n")); */
       return (-1);
     }
@@ -287,13 +278,12 @@ int mutt_copy_bytes (FILE *in, FILE *out, size_t size)
   return 0;
 }
 
-int mutt_copy_stream (FILE *fin, FILE *fout)
+int mutt_copy_stream (FILE * fin, FILE * fout)
 {
   size_t l;
   char buf[LONG_STRING];
 
-  while ((l = fread (buf, 1, sizeof (buf), fin)) > 0)
-  {
+  while ((l = fread (buf, 1, sizeof (buf), fin)) > 0) {
     if (fwrite (buf, 1, l, fout) != l)
       return (-1);
   }
@@ -301,54 +291,50 @@ int mutt_copy_stream (FILE *fin, FILE *fout)
   return 0;
 }
 
-static int 
-compare_stat (struct stat *osb, struct stat *nsb)
+static int compare_stat (struct stat *osb, struct stat *nsb)
 {
   if (osb->st_dev != nsb->st_dev || osb->st_ino != nsb->st_ino ||
-      osb->st_rdev != nsb->st_rdev)
-  {
+      osb->st_rdev != nsb->st_rdev) {
     return -1;
   }
 
   return 0;
 }
 
-int safe_symlink(const char *oldpath, const char *newpath)
+int safe_symlink (const char *oldpath, const char *newpath)
 {
   struct stat osb, nsb;
 
-  if(!oldpath || !newpath)
+  if (!oldpath || !newpath)
     return -1;
-  
-  if(unlink(newpath) == -1 && errno != ENOENT)
+
+  if (unlink (newpath) == -1 && errno != ENOENT)
     return -1;
-  
-  if (oldpath[0] == '/')
-  {
+
+  if (oldpath[0] == '/') {
     if (symlink (oldpath, newpath) == -1)
       return -1;
   }
-  else
-  {
+  else {
     char abs_oldpath[_POSIX_PATH_MAX];
 
     if ((getcwd (abs_oldpath, sizeof abs_oldpath) == NULL) ||
-       (strlen (abs_oldpath) + 1 + strlen (oldpath) + 1 > sizeof abs_oldpath))
-    return -1;
-  
-    strcat (abs_oldpath, "/");         /* __STRCAT_CHECKED__ */
-    strcat (abs_oldpath, oldpath);     /* __STRCAT_CHECKED__ */
+        (strlen (abs_oldpath) + 1 + strlen (oldpath) + 1 >
+         sizeof abs_oldpath))
+      return -1;
+
+    strcat (abs_oldpath, "/");  /* __STRCAT_CHECKED__ */
+    strcat (abs_oldpath, oldpath);      /* __STRCAT_CHECKED__ */
     if (symlink (abs_oldpath, newpath) == -1)
       return -1;
   }
 
-  if(stat(oldpath, &osb) == -1 || stat(newpath, &nsb) == -1
-     || compare_stat(&osb, &nsb) == -1)
-  {
-    unlink(newpath);
+  if (stat (oldpath, &osb) == -1 || stat (newpath, &nsb) == -1
+      || compare_stat (&osb, &nsb) == -1) {
+    unlink (newpath);
     return -1;
   }
-  
+
   return 0;
 }
 
@@ -365,8 +351,7 @@ int safe_rename (const char *src, const char *target)
   if (!src || !target)
     return -1;
 
-  if (link (src, target) != 0)
-  {
+  if (link (src, target) != 0) {
 
     /*
      * Coda does not allow cross-directory links, but tells
@@ -382,21 +367,19 @@ int safe_rename (const char *src, const char *target)
 
     if (errno == EXDEV)
       return rename (src, target);
-    
+
     return -1;
   }
 
   /*
    * Stat both links and check if they are equal.
    */
-  
-  if (stat (src, &ssb) == -1)
-  {
+
+  if (stat (src, &ssb) == -1) {
     return -1;
   }
-  
-  if (stat (target, &tsb) == -1)
-  {
+
+  if (stat (target, &tsb) == -1) {
     return -1;
   }
 
@@ -405,8 +388,7 @@ int safe_rename (const char *src, const char *target)
    * did already exist.
    */
 
-  if (compare_stat (&ssb, &tsb) == -1)
-  {
+  if (compare_stat (&ssb, &tsb) == -1) {
     errno = EEXIST;
     return -1;
   }
@@ -426,14 +408,13 @@ int safe_open (const char *path, int flags)
   struct stat osb, nsb;
   int fd;
 
-  umask(Umask);
+  umask (Umask);
   if ((fd = open (path, flags, 0666)) < 0)
     return fd;
 
   /* make sure the file is not symlink */
   if (lstat (path, &osb) < 0 || fstat (fd, &nsb) < 0 ||
-      compare_stat(&osb, &nsb) == -1)
-  {
+      compare_stat (&osb, &nsb) == -1) {
 /*    dprint (1, (debugfile, "safe_open(): %s is a symlink!\n", path)); */
     close (fd);
     return (-1);
@@ -448,9 +429,8 @@ int safe_open (const char *path, int flags)
 FILE *safe_fopen (const char *path, const char *mode)
 {
   /* first set the current umask */
-  umask(Umask);
-  if (mode[0] == 'w')
-  {
+  umask (Umask);
+  if (mode[0] == 'w') {
     int fd;
     int flags = O_CREAT | O_EXCL;
 
@@ -472,14 +452,15 @@ FILE *safe_fopen (const char *path, const char *mode)
     return (fopen (path, mode));
 }
 
-static char safe_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/";
+static char safe_chars[] =
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/";
 
 void mutt_sanitize_filename (char *f, short slash)
 {
-  if (!f) return;
+  if (!f)
+    return;
 
-  for (; *f; f++)
-  {
+  for (; *f; f++) {
     if ((slash && *f == '/') || !strchr (safe_chars, *f))
       *f = '_';
   }
@@ -491,18 +472,16 @@ static char rx_special_chars[] = "^.[$()|*+?{\\";
 
 int mutt_rx_sanitize_string (char *dest, size_t destlen, const char *src)
 {
-  while (*src && --destlen > 2)
-  {
-    if (strchr (rx_special_chars, *src))
-    {
+  while (*src && --destlen > 2) {
+    if (strchr (rx_special_chars, *src)) {
       *dest++ = '\\';
       destlen--;
     }
     *dest++ = *src++;
   }
-  
+
   *dest = '\0';
-  
+
   if (*src)
     return -1;
   else
@@ -514,53 +493,47 @@ int mutt_rx_sanitize_string (char *dest, size_t destlen, const char *src)
  * If a line ends with "\", this char and the linefeed is removed,
  * and the next line is read too.
  */
-char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line)
+char *mutt_read_line (char *s, size_t * size, FILE * fp, int *line)
 {
   size_t offset = 0;
   char *ch;
 
-  if (!s)
-  {
+  if (!s) {
     s = safe_malloc (STRING);
     *size = STRING;
   }
 
-  FOREVER
-  {
-    if (fgets (s + offset, *size - offset, fp) == NULL)
-    {
+  FOREVER {
+    if (fgets (s + offset, *size - offset, fp) == NULL) {
       FREE (&s);
       return NULL;
     }
-    if ((ch = strchr (s + offset, '\n')) != NULL)
-    {
+    if ((ch = strchr (s + offset, '\n')) != NULL) {
       (*line)++;
       *ch = 0;
       if (ch > s && *(ch - 1) == '\r')
-       *--ch = 0;
+        *--ch = 0;
       if (ch == s || *(ch - 1) != '\\')
-       return s;
+        return s;
       offset = ch - s - 1;
     }
-    else
-    {
+    else {
       int c;
-      c = getc (fp); /* This is kind of a hack. We want to know if the
-                        char at the current point in the input stream is EOF.
-                        feof() will only tell us if we've already hit EOF, not
-                        if the next character is EOF. So, we need to read in
-                        the next character and manually check if it is EOF. */
-      if (c == EOF)
-      {
+
+      c = getc (fp);            /* This is kind of a hack. We want to know if the
+                                   char at the current point in the input stream is EOF.
+                                   feof() will only tell us if we've already hit EOF, not
+                                   if the next character is EOF. So, we need to read in
+                                   the next character and manually check if it is EOF. */
+      if (c == EOF) {
         /* The last line of fp isn't \n terminated */
         (*line)++;
         return s;
       }
-      else
-      {
-        ungetc (c, fp); /* undo our dammage */
+      else {
+        ungetc (c, fp);         /* undo our dammage */
         /* There wasn't room for the line -- increase ``s'' */
-        offset = *size - 1; /* overwrite the terminating 0 */
+        offset = *size - 1;     /* overwrite the terminating 0 */
         *size += STRING;
         safe_realloc (&s, *size);
       }
@@ -568,8 +541,8 @@ char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line)
   }
 }
 
-char *
-mutt_substrcpy (char *dest, const char *beg, const char *end, size_t destlen)
+char *mutt_substrcpy (char *dest, const char *beg, const char *end,
+                      size_t destlen)
 {
   size_t len;
 
@@ -605,21 +578,18 @@ size_t mutt_quote_filename (char *d, size_t l, const char *f)
 {
   size_t i, j = 0;
 
-  if(!f) 
-  {
+  if (!f) {
     *d = '\0';
     return 0;
   }
 
   /* leave some space for the trailing characters. */
   l -= 6;
-  
+
   d[j++] = '\'';
-  
-  for(i = 0; j < l && f[i]; i++)
-  {
-    if(f[i] == '\'' || f[i] == '`')
-    {
+
+  for (i = 0; j < l && f[i]; i++) {
+    if (f[i] == '\'' || f[i] == '`') {
       d[j++] = '\'';
       d[j++] = '\\';
       d[j++] = f[i];
@@ -628,43 +598,43 @@ size_t mutt_quote_filename (char *d, size_t l, const char *f)
     else
       d[j++] = f[i];
   }
-  
+
   d[j++] = '\'';
-  d[j]   = '\0';
-  
+  d[j] = '\0';
+
   return j;
 }
 
 /* NULL-pointer aware string comparison functions */
 
-int mutt_strcmp(const char *a, const char *b)
+int mutt_strcmp (const char *a, const char *b)
 {
-  return strcmp(NONULL(a), NONULL(b));
+  return strcmp (NONULL (a), NONULL (b));
 }
 
-int mutt_strcasecmp(const char *a, const char *b)
+int mutt_strcasecmp (const char *a, const char *b)
 {
-  return strcasecmp(NONULL(a), NONULL(b));
+  return strcasecmp (NONULL (a), NONULL (b));
 }
 
-int mutt_strncmp(const char *a, const char *b, size_t l)
+int mutt_strncmp (const char *a, const char *b, size_t l)
 {
-  return strncmp(NONULL(a), NONULL(b), l);
+  return strncmp (NONULL (a), NONULL (b), l);
 }
 
-int mutt_strncasecmp(const char *a, const char *b, size_t l)
+int mutt_strncasecmp (const char *a, const char *b, size_t l)
 {
-  return strncasecmp(NONULL(a), NONULL(b), l);
+  return strncasecmp (NONULL (a), NONULL (b), l);
 }
 
-size_t mutt_strlen(const char *a)
+size_t mutt_strlen (const char *a)
 {
   return a ? strlen (a) : 0;
 }
 
-int mutt_strcoll(const char *a, const char *b)
+int mutt_strcoll (const char *a, const char *b)
 {
-  return strcoll(NONULL(a), NONULL(b));
+  return strcoll (NONULL (a), NONULL (b));
 }
 
 const char *mutt_stristr (const char *haystack, const char *needle)
@@ -676,13 +646,11 @@ const char *mutt_stristr (const char *haystack, const char *needle)
   if (!needle)
     return (haystack);
 
-  while (*(p = haystack))
-  {
+  while (*(p = haystack)) {
     for (q = needle;
          *p && *q &&
-           tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
-         p++, q++)
-      ;
+         tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
+         p++, q++);
     if (!*q)
       return (haystack);
     haystack++;
@@ -699,18 +667,18 @@ char *mutt_skip_whitespace (char *p)
 void mutt_remove_trailing_ws (char *s)
 {
   char *p;
-  
-  for (p = s + mutt_strlen (s) - 1 ; p >= s && ISSPACE (*p) ; p--)
+
+  for (p = s + mutt_strlen (s) - 1; p >= s && ISSPACE (*p); p--)
     *p = 0;
 }
 
 char *mutt_concat_path (char *d, const char *dir, const char *fname, size_t l)
 {
   const char *fmt = "%s/%s";
-  
-  if (!*fname || (*dir && dir[strlen(dir)-1] == '/'))
+
+  if (!*fname || (*dir && dir[strlen (dir) - 1] == '/'))
     fmt = "%s%s";
-  
+
   snprintf (d, l, fmt, dir, fname);
   return d;
 }
@@ -718,6 +686,7 @@ char *mutt_concat_path (char *d, const char *dir, const char *fname, size_t l)
 const char *mutt_basename (const char *f)
 {
   const char *p = strrchr (f, '/');
+
   if (p)
     return p + 1;
   else
diff --git a/lib.h b/lib.h
index b496e04..a5b2001 100644 (file)
--- a/lib.h
+++ b/lib.h
@@ -18,7 +18,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /* mutt functions which are generally useful. */
 
@@ -28,7 +28,7 @@
 # include <stdio.h>
 # include <string.h>
 # ifdef HAVE_UNISTD_H
-#  include <unistd.h> /* needed for SEEK_SET */
+#  include <unistd.h>           /* needed for SEEK_SET */
 # endif
 # include <sys/types.h>
 # include <sys/stat.h>
index ab20060..2193cb4 100644 (file)
@@ -1,8 +1,6 @@
-# Makefile.in generated by automake 1.7.6 from Makefile.am.
-# @configure_input@
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-# Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-@SET_MAKE@
+
+SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+
 top_builddir = ..
 
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
 INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+host_alias = @host_alias@
 host_triplet = @host@
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
 AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BUILD_IMAP_FALSE = @BUILD_IMAP_FALSE@
-BUILD_IMAP_TRUE = @BUILD_IMAP_TRUE@
 BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
 CATALOGS = @CATALOGS@
 CATOBJEXT = @CATOBJEXT@
 CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
 CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
 DATADIRNAME = @DATADIRNAME@
 DBX = @DBX@
 DEBUGGER = @DEBUGGER@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
 DOTLOCK_GROUP = @DOTLOCK_GROUP@
 DOTLOCK_PERMISSION = @DOTLOCK_PERMISSION@
 DOTLOCK_TARGET = @DOTLOCK_TARGET@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
 GDB = @GDB@
 GENCAT = @GENCAT@
 GLIBC21 = @GLIBC21@
 GMOFILES = @GMOFILES@
 GMSGFMT = @GMSGFMT@
 GPGME_CONFIG = @GPGME_CONFIG@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+HAVE_LIB = @HAVE_LIB@
 INSTOBJEXT = @INSTOBJEXT@
 INTLBISON = @INTLBISON@
 INTLLIBS = @INTLLIBS@
@@ -87,7 +85,7 @@ INTLOBJS = @INTLOBJS@
 INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
 ISPELL = @ISPELL@
 KRB5CFGPATH = @KRB5CFGPATH@
-LDFLAGS = @LDFLAGS@
+LIB = @LIB@
 LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
 LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
 LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
@@ -96,235 +94,131 @@ LIBGPGME_LIBS = @LIBGPGME_LIBS@
 LIBICONV = @LIBICONV@
 LIBIMAP = @LIBIMAP@
 LIBIMAPDEPS = @LIBIMAPDEPS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LTLIBOBJS = @LTLIBOBJS@
+LTLIB = @LTLIB@
 MAKEINFO = @MAKEINFO@
 MKINSTALLDIRS = @MKINSTALLDIRS@
 MSGFMT = @MSGFMT@
 MUTTLIBS = @MUTTLIBS@
 MUTT_LIB_OBJECTS = @MUTT_LIB_OBJECTS@
-OBJEXT = @OBJEXT@
 OPS = @OPS@
 PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
 PGPAUX_TARGET = @PGPAUX_TARGET@
 POFILES = @POFILES@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SDB = @SDB@
 SENDMAIL = @SENDMAIL@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
+SGML2HTML_CMD = @SGML2HTML_CMD@
+SGML2PS_CMD = @SGML2PS_CMD@
+SGML2TXT_CMD = @SGML2TXT_CMD@
 SMIMEAUX_TARGET = @SMIMEAUX_TARGET@
-STRIP = @STRIP@
 SUBVERSION = @SUBVERSION@
 U = @U@
-USE_GSS_FALSE = @USE_GSS_FALSE@
-USE_GSS_TRUE = @USE_GSS_TRUE@
 USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 USE_NLS = @USE_NLS@
-USE_SASL_FALSE = @USE_SASL_FALSE@
-USE_SASL_TRUE = @USE_SASL_TRUE@
-USE_SSL_FALSE = @USE_SSL_FALSE@
-USE_SSL_TRUE = @USE_SSL_TRUE@
 VERSION = @VERSION@
-XGETTEXT = @XGETTEXT@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
 docdir = @docdir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
 mutt_libesmtp_config_path = @mutt_libesmtp_config_path@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-
-EXTRA_DIST = README Makefile.am.in \
-codeset.m4 \
-curslib.m4 \
-funcdecl.m4 \
-gettext.m4 \
-glibc21.m4 \
-gssapi.m4 \
-iconv.m4 \
-lcmessage.m4 \
-libesmtp.m4 \
-libgnutls.m4 \
-progtest.m4 \
-types.m4
 
-subdir = m4
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+EXTRA_DIST = README Makefile.am.in codeset.m4 curslib.m4 funcdecl.m4 gettext.m4 glibc21.m4 gssapi.m4 iconv.m4 lcmessage.m4 libesmtp.m4 libgnutls.m4 progtest.m4 types.m4
+
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-depcomp =
-am__depfiles_maybe =
-DIST_SOURCES =
-DIST_COMMON = README Makefile.am Makefile.in
-all: all-am
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES = 
+DIST_COMMON =  README Makefile.am Makefile.in
+
 
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+all: all-redirect
 .SUFFIXES:
-$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
-       cd $(top_srcdir) && \
-         $(AUTOMAKE) --gnu  --ignore-deps m4/Makefile
-Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
-       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
-uninstall-info-am:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+       cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps m4/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+       cd $(top_builddir) \
+         && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
 tags: TAGS
 TAGS:
 
-ctags: CTAGS
-CTAGS:
 
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 
-top_distdir = ..
-distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+subdir = m4
 
 distdir: $(DISTFILES)
-       @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-       list='$(DISTFILES)'; for file in $$list; do \
-         case $$file in \
-           $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-           $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-         esac; \
-         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-           dir="/$$dir"; \
-           $(mkinstalldirs) "$(distdir)$$dir"; \
-         else \
-           dir=''; \
-         fi; \
+       @for file in $(DISTFILES); do \
+         d=$(srcdir); \
          if test -d $$d/$$file; then \
-           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-           fi; \
-           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+           cp -pr $$d/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
-           || cp -p $$d/$$file $(distdir)/$$file \
-           || exit 1; \
+           || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+           || cp -p $$d/$$file $(distdir)/$$file || :; \
          fi; \
        done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
 check-am: all-am
 check: check-am
-all-am: Makefile
-
-installdirs:
-install: install-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
 install-exec: install-exec-am
+
+install-data-am:
 install-data: install-data-am
-uninstall: uninstall-am
 
 install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile
+all-redirect: all-am
 install-strip:
-       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         INSTALL_STRIP_FLAG=-s \
-         `test -z '$(STRIP)' || \
-           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+       $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
        -rm -f Makefile $(CONFIG_CLEAN_FILES)
+       -rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-       @echo "This command is intended for maintainers to use"
-       @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic mostlyclean-am
-
-distclean: distclean-am
-
-distclean-am: clean-am distclean-generic
-
-dvi: dvi-am
-
-dvi-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-exec-am:
-
-install-info: install-info-am
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-
-maintainer-clean-am: distclean-am maintainer-clean-generic
+mostlyclean-am:  mostlyclean-generic
 
 mostlyclean: mostlyclean-am
 
-mostlyclean-am: mostlyclean-generic
+clean-am:  clean-generic mostlyclean-am
 
-pdf: pdf-am
+clean: clean-am
 
-pdf-am:
+distclean-am:  distclean-generic clean-am
 
-ps: ps-am
+distclean: distclean-am
 
-ps-am:
+maintainer-clean-am:  maintainer-clean-generic distclean-am
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
 
-uninstall-am: uninstall-info-am
+maintainer-clean: maintainer-clean-am
 
-.PHONY: all all-am check check-am clean clean-generic distclean \
-       distclean-generic distdir dvi dvi-am info info-am install \
-       install-am install-data install-data-am install-exec \
-       install-exec-am install-info install-info-am install-man \
-       install-strip installcheck installcheck-am installdirs \
-       maintainer-clean maintainer-clean-generic mostlyclean \
-       mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
-       uninstall-info-am
+.PHONY: tags distdir info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
 
 
 Makefile.am: Makefile.am.in
@@ -337,6 +231,7 @@ Makefile.am: Makefile.am.in
        sed -n '/^##m4-files-end/,$$p' Makefile.am.in >> $@t
        chmod a-w $@t
        mv $@t $@
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
index 45e3f83..003e7df 100644 (file)
--- a/mailbox.h
+++ b/mailbox.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _MAILBOX_H
 #define _MAILBOX_H
 
 /* flags for mutt_open_mailbox() */
-#define M_NOSORT       (1<<0) /* do not sort the mailbox after opening it */
-#define M_APPEND       (1<<1) /* open mailbox for appending messages */
-#define M_READONLY     (1<<2) /* open in read-only mode */
-#define M_QUIET                (1<<3) /* do not print any messages */
-#define M_NEWFOLDER    (1<<4) /* create a new folder - same as M_APPEND, but uses
-                               * safe_fopen() for mbox-style folders.
-                               */
+#define M_NOSORT       (1<<0)  /* do not sort the mailbox after opening it */
+#define M_APPEND       (1<<1)  /* open mailbox for appending messages */
+#define M_READONLY     (1<<2)  /* open in read-only mode */
+#define M_QUIET                (1<<3)  /* do not print any messages */
+#define M_NEWFOLDER    (1<<4)  /* create a new folder - same as M_APPEND, but uses
+                                 * safe_fopen() for mbox-style folders.
+                                 */
 
 /* mx_open_new_message() */
-#define M_ADD_FROM     1       /* add a From_ line */
+#define M_ADD_FROM     1       /* add a From_ line */
 
 /* return values from mx_check_mailbox() */
-enum
-{
-  M_NEW_MAIL = 1,      /* new mail received in mailbox */
-  M_LOCKED,            /* couldn't lock the mailbox */
-  M_REOPENED,          /* mailbox was reopened */
-  M_FLAGS               /* nondestructive flags change (IMAP) */
+enum {
+  M_NEW_MAIL = 1,               /* new mail received in mailbox */
+  M_LOCKED,                     /* couldn't lock the mailbox */
+  M_REOPENED,                   /* mailbox was reopened */
+  M_FLAGS                       /* nondestructive flags change (IMAP) */
 };
 
-typedef struct
-{
-  FILE *fp;    /* pointer to the message data */
-  char *path;  /* path to temp file */
-  short magic; /* type of mailbox this message belongs to */
-  short write; /* nonzero if message is open for writing */
+typedef struct {
+  FILE *fp;                     /* pointer to the message data */
+  char *path;                   /* path to temp file */
+  short magic;                  /* type of mailbox this message belongs to */
+  short write;                  /* nonzero if message is open for writing */
   struct {
-    unsigned read : 1;
-    unsigned flagged : 1;
-    unsigned replied : 1;
+    unsigned read:1;
+    unsigned flagged:1;
+    unsigned replied:1;
   } flags;
-  time_t received;     /* the time at which this message was received */
+  time_t received;              /* the time at which this message was received */
 } MESSAGE;
 
 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
@@ -68,6 +66,7 @@ int mx_close_message (MESSAGE **);
 int mx_get_magic (const char *);
 int mx_set_magic (const char *);
 int mx_check_mailbox (CONTEXT *, int *, int);
+
 #ifdef USE_IMAP
 int mx_is_imap (const char *);
 #endif
@@ -78,7 +77,7 @@ int mx_is_pop (const char *);
 int mx_is_nntp (const char *);
 #endif
 
-int mx_access (const char*, int);
+int mx_access (const char *, int);
 int mx_check_empty (const char *);
 
 #endif
diff --git a/main.c b/main.c
index 8f8ca9d..dd6c1ed 100644 (file)
--- a/main.c
+++ b/main.c
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #define MAIN_C 1
 
@@ -101,8 +101,9 @@ static void mutt_usage (void)
 {
   puts (mutt_make_version ());
 
-  puts _(
-"usage: muttng [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]\n\
+  puts
+    _
+    ("usage: muttng [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]\n\
        muttng [ -nR ] [ -e <cmd> ] [ -F <file> ] -Q <query> [ -Q <query> ] [...]\n\
        muttng [ -nR ] [ -e <cmd> ] [ -F <file> ] -A <alias> [ -A <alias> ] [...]\n\
        muttng [ -nx ] [ -e <cmd> ] [ -a <file> ] [ -F <file> ] [ -H <file> ] [ -i <file> ] [ -s <subj> ] [ -b <addr> ] [ -c <addr> ] <addr> [ ... ]\n\
@@ -141,7 +142,7 @@ static void show_version (void)
 {
   struct utsname uts;
 
-  puts (mutt_make_version());
+  puts (mutt_make_version ());
   puts (_(Notice));
 
   uname (&uts);
@@ -164,14 +165,14 @@ static void show_version (void)
 
 #ifdef _LIBICONV_VERSION
   printf (" [using libiconv %d.%d]", _LIBICONV_VERSION >> 8,
-         _LIBICONV_VERSION & 0xff);
+          _LIBICONV_VERSION & 0xff);
 #endif
 
 #ifdef HAVE_LIBIDN
-  printf (" [using libidn %s (compiled with %s)]", stringprep_check_version (NULL), 
-         STRINGPREP_VERSION);
+  printf (" [using libidn %s (compiled with %s)]",
+          stringprep_check_version (NULL), STRINGPREP_VERSION);
 #endif
-  
+
   puts (_("\nCompile options:"));
 
 #ifdef DOMAIN
@@ -185,300 +186,252 @@ static void show_version (void)
 #else
   puts ("-DEBUG");
 #endif
-  
 
-  
-  puts (
 
+
+  puts (
 #ifdef HOMESPOOL
-       "+HOMESPOOL  "
+         "+HOMESPOOL  "
 #else
-       "-HOMESPOOL  "
+         "-HOMESPOOL  "
 #endif
-
 #ifdef USE_SETGID
-       "+USE_SETGID  "
+         "+USE_SETGID  "
 #else
-       "-USE_SETGID  "
+         "-USE_SETGID  "
 #endif
-
 #ifdef USE_DOTLOCK
-       "+USE_DOTLOCK  "
+         "+USE_DOTLOCK  "
 #else
-       "-USE_DOTLOCK  "
+         "-USE_DOTLOCK  "
 #endif
-
 #ifdef DL_STANDALONE
-       "+DL_STANDALONE  "
+         "+DL_STANDALONE  "
 #else
-       "-DL_STANDALONE  "
+         "-DL_STANDALONE  "
 #endif
-
-       "\n"
-       
+         "\n"
 #ifdef USE_FCNTL
-       "+USE_FCNTL  "
+         "+USE_FCNTL  "
 #else
-       "-USE_FCNTL  "
+         "-USE_FCNTL  "
 #endif
-
 #ifdef USE_FLOCK
-       "+USE_FLOCK   "
+         "+USE_FLOCK   "
 #else
-       "-USE_FLOCK   "
+         "-USE_FLOCK   "
 #endif
-       
 #ifdef USE_INODESORT
-       "+USE_INODESORT   "
+         "+USE_INODESORT   "
 #else
-       "-USE_INODESORT   "
+         "-USE_INODESORT   "
 #endif
-       );
+    );
   puts (
 #ifdef USE_POP
-       "+USE_POP  "
+         "+USE_POP  "
 #else
-       "-USE_POP  "
+         "-USE_POP  "
 #endif
-
 #ifdef USE_NNTP
-       "+USE_NNTP  "
+         "+USE_NNTP  "
 #else
-       "-USE_NNTP  "
+         "-USE_NNTP  "
 #endif
-
 #ifdef USE_IMAP
-        "+USE_IMAP  "
+         "+USE_IMAP  "
 #else
-        "-USE_IMAP  "
+         "-USE_IMAP  "
 #endif
-
 #ifdef IMAP_EDIT_THREADS
-        "+IMAP_EDIT_THREADS  "
+         "+IMAP_EDIT_THREADS  "
 #else
-        "-IMAP_EDIT_THREADS  "
+         "-IMAP_EDIT_THREADS  "
 #endif
-
 #ifdef USE_GSS
-       "+USE_GSS  "
+         "+USE_GSS  "
 #else
-       "-USE_GSS  "
+         "-USE_GSS  "
 #endif
-
-       
 #ifdef USE_SSL
-       "+USE_SSL  "
+         "+USE_SSL  "
 #else
-       "-USE_SSL  "
+         "-USE_SSL  "
 #endif
-
 #ifdef USE_GNUTLS
-       "+USE_GNUTLS  "
+         "+USE_GNUTLS  "
 #else
-       "-USE_GNUTLS  "
+         "-USE_GNUTLS  "
 #endif
-
 #ifdef USE_GNUTLS
-       "+USE_GNUTLS  "
+         "+USE_GNUTLS  "
 #else
-       "-USE_GNUTLS  "
+         "-USE_GNUTLS  "
 #endif
-
 #ifdef USE_SASL
-       "+USE_SASL  "
+         "+USE_SASL  "
 #else
-       "-USE_SASL  "
+         "-USE_SASL  "
 #endif
 #ifdef USE_SASL2
-       "+USE_SASL2  "
+         "+USE_SASL2  "
 #else
-       "-USE_SASL2  "
+         "-USE_SASL2  "
 #endif
-
 #ifdef USE_LIBESMTP
-    "+USE_LIBESMTP  "
+         "+USE_LIBESMTP  "
 #else
-    "-USE_LIBESMTP  "
+         "-USE_LIBESMTP  "
 #endif
-       "\n"
-       
+         "\n"
 #ifdef HAVE_REGCOMP
-       "+HAVE_REGCOMP  "
+         "+HAVE_REGCOMP  "
 #else
-       "-HAVE_REGCOMP  "
+         "-HAVE_REGCOMP  "
 #endif
-
 #ifdef USE_GNU_REGEX
-       "+USE_GNU_REGEX  "
+         "+USE_GNU_REGEX  "
 #else
-       "-USE_GNU_REGEX  "
+         "-USE_GNU_REGEX  "
 #endif
-
 #ifdef USE_COMPRESSED
-       "+COMPRESSED  "
+         "+COMPRESSED  "
 #else
-       "-COMPRESSED  "
+         "-COMPRESSED  "
 #endif
-
-       "\n"
-       
+         "\n"
 #ifdef HAVE_COLOR
-       "+HAVE_COLOR  "
+         "+HAVE_COLOR  "
 #else
-       "-HAVE_COLOR  "
+         "-HAVE_COLOR  "
 #endif
-       
 #ifdef HAVE_START_COLOR
-       "+HAVE_START_COLOR  "
+         "+HAVE_START_COLOR  "
 #else
-       "-HAVE_START_COLOR  "
+         "-HAVE_START_COLOR  "
 #endif
-       
 #ifdef HAVE_TYPEAHEAD
-       "+HAVE_TYPEAHEAD  "
+         "+HAVE_TYPEAHEAD  "
 #else
-       "-HAVE_TYPEAHEAD  "
+         "-HAVE_TYPEAHEAD  "
 #endif
-       
 #ifdef HAVE_BKGDSET
-       "+HAVE_BKGDSET  "
+         "+HAVE_BKGDSET  "
 #else
-       "-HAVE_BKGDSET  "
+         "-HAVE_BKGDSET  "
 #endif
-
-       "\n"
-       
+         "\n"
 #ifdef HAVE_CURS_SET
-       "+HAVE_CURS_SET  "
+         "+HAVE_CURS_SET  "
 #else
-       "-HAVE_CURS_SET  "
+         "-HAVE_CURS_SET  "
 #endif
-       
 #ifdef HAVE_META
-       "+HAVE_META  "
+         "+HAVE_META  "
 #else
-       "-HAVE_META  "
+         "-HAVE_META  "
 #endif
-       
 #ifdef HAVE_RESIZETERM
-       "+HAVE_RESIZETERM  "
+         "+HAVE_RESIZETERM  "
 #else
-       "-HAVE_RESIZETERM  "
+         "-HAVE_RESIZETERM  "
 #endif
-        );     
-  
+    );
+
   puts (
 #ifdef CRYPT_BACKEND_CLASSIC_PGP
-        "+CRYPT_BACKEND_CLASSIC_PGP  "
+         "+CRYPT_BACKEND_CLASSIC_PGP  "
 #else
-        "-CRYPT_BACKEND_CLASSIC_PGP  "
+         "-CRYPT_BACKEND_CLASSIC_PGP  "
 #endif
 #ifdef CRYPT_BACKEND_CLASSIC_SMIME
-        "+CRYPT_BACKEND_CLASSIC_SMIME  "
+         "+CRYPT_BACKEND_CLASSIC_SMIME  "
 #else
-        "-CRYPT_BACKEND_CLASSIC_SMIME  "
+         "-CRYPT_BACKEND_CLASSIC_SMIME  "
 #endif
 #ifdef CRYPT_BACKEND_GPGME
-        "+CRYPT_BACKEND_GPGME  "
+         "+CRYPT_BACKEND_GPGME  "
 #else
-        "-CRYPT_BACKEND_GPGME  "
+         "-CRYPT_BACKEND_GPGME  "
 #endif
-
 #ifdef BUFFY_SIZE
-       "+BUFFY_SIZE "
+         "+BUFFY_SIZE "
 #else
-       "-BUFFY_SIZE "
+         "-BUFFY_SIZE "
 #endif
 #ifdef EXACT_ADDRESS
-       "+EXACT_ADDRESS  "
+         "+EXACT_ADDRESS  "
 #else
-       "-EXACT_ADDRESS  "
+         "-EXACT_ADDRESS  "
 #endif
-
 #ifdef SUN_ATTACHMENT
-       "+SUN_ATTACHMENT  "
+         "+SUN_ATTACHMENT  "
 #else
-       "-SUN_ATTACHMENT  "
+         "-SUN_ATTACHMENT  "
 #endif
-
-       "\n"
-       
+         "\n"
 #ifdef ENABLE_NLS
-       "+ENABLE_NLS  "
+         "+ENABLE_NLS  "
 #else
-       "-ENABLE_NLS  "
+         "-ENABLE_NLS  "
 #endif
-
 #ifdef LOCALES_HACK
-       "+LOCALES_HACK  "
+         "+LOCALES_HACK  "
 #else
-       "-LOCALES_HACK  "
+         "-LOCALES_HACK  "
 #endif
-             
 #ifdef HAVE_WC_FUNCS
-       "+HAVE_WC_FUNCS  "
+         "+HAVE_WC_FUNCS  "
 #else
-       "-HAVE_WC_FUNCS  "
+         "-HAVE_WC_FUNCS  "
 #endif
-       
 #ifdef HAVE_LANGINFO_CODESET
-       "+HAVE_LANGINFO_CODESET  "
+         "+HAVE_LANGINFO_CODESET  "
 #else
-       "-HAVE_LANGINFO_CODESET  "
+         "-HAVE_LANGINFO_CODESET  "
 #endif
-
-       
 #ifdef HAVE_LANGINFO_YESEXPR
-       "+HAVE_LANGINFO_YESEXPR  "
+         "+HAVE_LANGINFO_YESEXPR  "
 #else
-       "-HAVE_LANGINFO_YESEXPR  "
+         "-HAVE_LANGINFO_YESEXPR  "
 #endif
-       
-       "\n"
-
+         "\n"
 #if HAVE_ICONV
-       "+HAVE_ICONV  "
+         "+HAVE_ICONV  "
 #else
-       "-HAVE_ICONV  "
+         "-HAVE_ICONV  "
 #endif
-
 #if ICONV_NONTRANS
-       "+ICONV_NONTRANS  "
+         "+ICONV_NONTRANS  "
 #else
-       "-ICONV_NONTRANS  "
+         "-ICONV_NONTRANS  "
 #endif
-
 #if HAVE_LIBIDN
-       "+HAVE_LIBIDN  "
+         "+HAVE_LIBIDN  "
 #else
-       "-HAVE_LIBIDN  "
+         "-HAVE_LIBIDN  "
 #endif
-       
 #if HAVE_GETSID
-       "+HAVE_GETSID  "
+         "+HAVE_GETSID  "
 #else
-       "-HAVE_GETSID  "
+         "-HAVE_GETSID  "
 #endif
-
 #if HAVE_GETADDRINFO
-       "+HAVE_GETADDRINFO  "
+         "+HAVE_GETADDRINFO  "
 #else
-       "-HAVE_GETADDRINFO  "
+         "-HAVE_GETADDRINFO  "
 #endif
-
 #if USE_HCACHE
-       "+USE_HCACHE  "
+         "+USE_HCACHE  "
 #else
-       "-USE_HCACHE  "
+         "-USE_HCACHE  "
 #endif
-
 #if USE_HCACHE
-       "+USE_HCACHE  "
+         "+USE_HCACHE  "
 #else
-       "-USE_HCACHE  "
+         "-USE_HCACHE  "
 #endif
-
-       );
+    );
 
 #ifdef ISPELL
   printf ("ISPELL=\"%s\"\n", ISPELL);
@@ -497,32 +450,32 @@ static void show_version (void)
   puts ("-MIXMASTER");
 #endif
 
-  puts(_(ReachingUs));
+  puts (_(ReachingUs));
+
+  mutt_print_patchlist ();
 
-  mutt_print_patchlist();
-  
   exit (0);
 }
 
 static void start_curses (void)
 {
-  km_init (); /* must come before mutt_init */
+  km_init ();                   /* must come before mutt_init */
 
 #ifdef USE_SLANG_CURSES
-  SLtt_Ignore_Beep = 1; /* don't do that #*$@^! annoying visual beep! */
-  SLsmg_Display_Eight_Bit = 128; /* characters above this are printable */
-  SLtt_set_color(0, NULL, "default", "default");
+  SLtt_Ignore_Beep = 1;         /* don't do that #*$@^! annoying visual beep! */
+  SLsmg_Display_Eight_Bit = 128;        /* characters above this are printable */
+  SLtt_set_color (0, NULL, "default", "default");
 #else
   /* should come before initscr() so that ncurses 4.2 doesn't try to install
      its own SIGWINCH handler */
   mutt_signal_init ();
 #endif
-  if (initscr () == NULL)
-  {
+  if (initscr () == NULL) {
     puts _("Error initializing terminal.");
+
     exit (1);
   }
-#if 1 /* USE_SLANG_CURSES  - commenting out suggested in #455. */
+#if 1                           /* USE_SLANG_CURSES  - commenting out suggested in #455. */
   /* slang requires the signal handlers to be set after initializing */
   mutt_signal_init ();
 #endif
@@ -531,20 +484,20 @@ static void start_curses (void)
   cbreak ();
   noecho ();
 #if HAVE_TYPEAHEAD
-  typeahead (-1);       /* simulate smooth scrolling */
+  typeahead (-1);               /* simulate smooth scrolling */
 #endif
 #if HAVE_META
   meta (stdscr, TRUE);
 #endif
 }
 
-#define M_IGNORE  (1<<0)       /* -z */
-#define M_BUFFY   (1<<1)       /* -Z */
-#define M_NOSYSRC (1<<2)       /* -n */
-#define M_RO      (1<<3)       /* -R */
-#define M_SELECT  (1<<4)       /* -y */
+#define M_IGNORE  (1<<0)        /* -z */
+#define M_BUFFY   (1<<1)        /* -Z */
+#define M_NOSYSRC (1<<2)        /* -n */
+#define M_RO      (1<<3)        /* -R */
+#define M_SELECT  (1<<4)        /* -y */
 #ifdef USE_NNTP
-#define M_NEWS    (1<<5)       /* -g and -G */
+#define M_NEWS    (1<<5)        /* -g and -G */
 #endif
 
 int main (int argc, char **argv)
@@ -568,12 +521,10 @@ int main (int argc, char **argv)
   extern int optind;
 
   /* sanity check against stupid administrators */
-  
-  if(getegid() != getgid())
-  {
-    fprintf(stderr, "%s: I don't want to run with privileges!\n",
-           argv[0]);
-    exit(1);
+
+  if (getegid () != getgid ()) {
+    fprintf (stderr, "%s: I don't want to run with privileges!\n", argv[0]);
+    exit (1);
   }
 
 #ifdef ENABLE_NLS
@@ -592,143 +543,143 @@ int main (int argc, char **argv)
 
   memset (Options, 0, sizeof (Options));
   memset (QuadOptions, 0, sizeof (QuadOptions));
-  
+
 #ifdef USE_NNTP
-  while ((i = getopt (argc, argv, "A:a:b:F:f:c:d:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
+  while ((i =
+          getopt (argc, argv,
+                  "A:a:b:F:f:c:d:e:g:GH:s:i:hm:npQ:RvxyzZ")) != EOF)
 #else
-  while ((i = getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
-#endif
-    switch (i)
-    {
-      case 'A':
-        alias_queries = mutt_add_list (alias_queries, optarg);
-        break;
-      case 'a':
-       attach = mutt_add_list (attach, optarg);
-       break;
-
-      case 'F':
-       mutt_str_replace (&Muttrc, optarg);
-       break;
-
-      case 'f':
-       strfcpy (folder, optarg, sizeof (folder));
-        explicit_folder = 1;
-       break;
-
-      case 'b':
-      case 'c':
-       if (!msg)
-         msg = mutt_new_header ();
-       if (!msg->env)
-         msg->env = mutt_new_envelope ();
-       if (i == 'b')
-         msg->env->bcc = rfc822_parse_adrlist (msg->env->bcc, optarg);
-       else
-         msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg);
-       break;
-
-      case 'd':
+  while ((i =
+          getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
+#endif
+    switch (i) {
+    case 'A':
+      alias_queries = mutt_add_list (alias_queries, optarg);
+      break;
+    case 'a':
+      attach = mutt_add_list (attach, optarg);
+      break;
+
+    case 'F':
+      mutt_str_replace (&Muttrc, optarg);
+      break;
+
+    case 'f':
+      strfcpy (folder, optarg, sizeof (folder));
+      explicit_folder = 1;
+      break;
+
+    case 'b':
+    case 'c':
+      if (!msg)
+        msg = mutt_new_header ();
+      if (!msg->env)
+        msg->env = mutt_new_envelope ();
+      if (i == 'b')
+        msg->env->bcc = rfc822_parse_adrlist (msg->env->bcc, optarg);
+      else
+        msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg);
+      break;
+
+    case 'd':
 #ifdef DEBUG
-       debuglevel = atoi (optarg);
-       printf (_("Debugging at level %d.\n"), debuglevel);
+      debuglevel = atoi (optarg);
+      printf (_("Debugging at level %d.\n"), debuglevel);
 #else
-       printf _("DEBUG was not defined during compilation.  Ignored.\n");
+      printf _("DEBUG was not defined during compilation.  Ignored.\n");
 #endif
-       break;
+      break;
 
-      case 'e':
-       commands = mutt_add_list (commands, optarg);
-       break;
+    case 'e':
+      commands = mutt_add_list (commands, optarg);
+      break;
 
-      case 'H':
-       draftFile = optarg;
-       break;
+    case 'H':
+      draftFile = optarg;
+      break;
 
-      case 'i':
-       includeFile = optarg;
-       break;
+    case 'i':
+      includeFile = optarg;
+      break;
 
-      case 'm':
-       /* should take precedence over .muttrc setting, so save it for later */
-       newMagic = optarg; 
-       break;
+    case 'm':
+      /* should take precedence over .muttrc setting, so save it for later */
+      newMagic = optarg;
+      break;
 
-      case 'n':
-       flags |= M_NOSYSRC;
-       break;
+    case 'n':
+      flags |= M_NOSYSRC;
+      break;
 
-      case 'p':
-       sendflags |= SENDPOSTPONED;
-       break;
+    case 'p':
+      sendflags |= SENDPOSTPONED;
+      break;
 
-      case 'Q':
-        queries = mutt_add_list (queries, optarg);
-        break;
-      
-      case 'R':
-       flags |= M_RO; /* read-only mode */
-       break;
+    case 'Q':
+      queries = mutt_add_list (queries, optarg);
+      break;
 
-      case 's':
-       subject = optarg;
-       break;
+    case 'R':
+      flags |= M_RO;            /* read-only mode */
+      break;
 
-      case 'v':
-       version++;
-       break;
+    case 's':
+      subject = optarg;
+      break;
 
-      case 'x': /* mailx compatible send mode */
-       sendflags |= SENDMAILX;
-       break;
+    case 'v':
+      version++;
+      break;
+
+    case 'x':                  /* mailx compatible send mode */
+      sendflags |= SENDMAILX;
+      break;
 
-      case 'y': /* My special hack mode */
-       flags |= M_SELECT;
-       break;
+    case 'y':                  /* My special hack mode */
+      flags |= M_SELECT;
+      break;
 
 #ifdef USE_NNTP
-      case 'g': /* Specify a newsserver */
-       {
-         char buf[LONG_STRING];
+    case 'g':                  /* Specify a newsserver */
+      {
+        char buf[LONG_STRING];
 
-         snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
-         commands = mutt_add_list (commands, buf);
-       }
+        snprintf (buf, sizeof (buf), "set news_server=%s", optarg);
+        commands = mutt_add_list (commands, buf);
+      }
 
-      case 'G': /* List of newsgroups */
-       flags |= M_SELECT | M_NEWS;
-       break;
+    case 'G':                  /* List of newsgroups */
+      flags |= M_SELECT | M_NEWS;
+      break;
 #endif
 
-      case 'z':
-       flags |= M_IGNORE;
-       break;
+    case 'z':
+      flags |= M_IGNORE;
+      break;
 
-      case 'Z':
-       flags |= M_BUFFY | M_IGNORE;
-       break;
+    case 'Z':
+      flags |= M_BUFFY | M_IGNORE;
+      break;
 
-      default:
-       mutt_usage ();
+    default:
+      mutt_usage ();
     }
 
-  switch (version)
-  {
-    case 0:
-      break;
-    case 1:
-      show_version ();
-      break;
-    default:
-      puts (mutt_make_version ());
-      puts (_(Copyright));
-      puts (_(ReachingUs));
-      exit (0);
+  switch (version) {
+  case 0:
+    break;
+  case 1:
+    show_version ();
+    break;
+  default:
+    puts (mutt_make_version ());
+    puts (_(Copyright));
+    puts (_(ReachingUs));
+    exit (0);
   }
 
   /* Check for a batch send. */
-  if (!isatty (0) || queries || alias_queries)
-  {
+  if (!isatty (0) || queries || alias_queries) {
     set_option (OPTNOCURSES);
     sendflags = SENDBATCH;
   }
@@ -748,32 +699,28 @@ int main (int argc, char **argv)
   if (queries)
     return mutt_query_variables (queries);
 
-  if (alias_queries)
-  {
+  if (alias_queries) {
     int rv = 0;
     ADDRESS *a;
-    for (; alias_queries; alias_queries = alias_queries->next)
-    {
-      if ((a = mutt_lookup_alias (alias_queries->data)))
-      {        
-       /* output in machine-readable form */
-       mutt_addrlist_to_idna (a, NULL);
-       mutt_write_address_list (a, stdout, 0, 0);
+
+    for (; alias_queries; alias_queries = alias_queries->next) {
+      if ((a = mutt_lookup_alias (alias_queries->data))) {
+        /* output in machine-readable form */
+        mutt_addrlist_to_idna (a, NULL);
+        mutt_write_address_list (a, stdout, 0, 0);
       }
-      else
-      {
-       rv = 1;
-       printf ("%s\n", alias_queries->data);
+      else {
+        rv = 1;
+        printf ("%s\n", alias_queries->data);
       }
     }
     return rv;
   }
-  
+
   if (newMagic)
     mx_set_magic (newMagic);
 
-  if (!option (OPTNOCURSES))
-  {
+  if (!option (OPTNOCURSES)) {
     SETCOLOR (MT_COLOR_NORMAL);
     clear ();
     mutt_error = mutt_curses_error;
@@ -781,8 +728,7 @@ int main (int argc, char **argv)
   }
 
   /* Create the Maildir directory if it doesn't exist. */
-  if (!option (OPTNOCURSES) && Maildir)
-  {
+  if (!option (OPTNOCURSES) && Maildir) {
     struct stat sb;
     char fpath[_POSIX_PATH_MAX];
     char msg[STRING];
@@ -793,32 +739,29 @@ int main (int argc, char **argv)
     /* we're not connected yet - skip mail folder creation */
     if (!mx_is_imap (fpath))
 #endif
-    if (stat (fpath, &sb) == -1 && errno == ENOENT)
-    {
-      snprintf (msg, sizeof (msg), _("%s does not exist. Create it?"), Maildir);
-      if (mutt_yesorno (msg, M_YES) == M_YES)
-      {
-       if (mkdir (fpath, 0700) == -1 && errno != EEXIST)
-         mutt_error ( _("Can't create %s: %s."), Maildir, strerror (errno));
+      if (stat (fpath, &sb) == -1 && errno == ENOENT) {
+        snprintf (msg, sizeof (msg), _("%s does not exist. Create it?"),
+                  Maildir);
+        if (mutt_yesorno (msg, M_YES) == M_YES) {
+          if (mkdir (fpath, 0700) == -1 && errno != EEXIST)
+            mutt_error (_("Can't create %s: %s."), Maildir, strerror (errno));
+        }
       }
-    }
   }
 
-  if (sendflags & SENDPOSTPONED)
-  {
+  if (sendflags & SENDPOSTPONED) {
     if (!option (OPTNOCURSES))
       mutt_flushinp ();
     ci_send_message (SENDPOSTPONED, NULL, NULL, NULL, NULL);
     mutt_endwin (NULL);
   }
-  else if (subject || msg || sendflags || draftFile || includeFile || attach ||
-          optind < argc)
-  {
+  else if (subject || msg || sendflags || draftFile || includeFile || attach
+           || optind < argc) {
     FILE *fin = NULL;
     char buf[LONG_STRING];
     char *tempfile = NULL, *infile = NULL;
     char *bodytext = NULL;
-    
+
     if (!option (OPTNOCURSES))
       mutt_flushinp ();
 
@@ -827,114 +770,101 @@ int main (int argc, char **argv)
 
     if (draftFile)
       infile = draftFile;
-    else
-    {
+    else {
       if (!msg->env)
-       msg->env = mutt_new_envelope ();
+        msg->env = mutt_new_envelope ();
 
-      for (i = optind; i < argc; i++)
-      {
-       if (url_check_scheme (argv[i]) == U_MAILTO)
-         url_parse_mailto (msg->env, &bodytext, argv[i]);
-       else
-         msg->env->to = rfc822_parse_adrlist (msg->env->to, argv[i]);
+      for (i = optind; i < argc; i++) {
+        if (url_check_scheme (argv[i]) == U_MAILTO)
+          url_parse_mailto (msg->env, &bodytext, argv[i]);
+        else
+          msg->env->to = rfc822_parse_adrlist (msg->env->to, argv[i]);
       }
 
-      if (option (OPTAUTOEDIT) && !msg->env->to && !msg->env->cc)
-      {
-       if (!option (OPTNOCURSES))
-         mutt_endwin (NULL);
-       fputs (_("No recipients specified.\n"), stderr);
-       exit (1);
+      if (option (OPTAUTOEDIT) && !msg->env->to && !msg->env->cc) {
+        if (!option (OPTNOCURSES))
+          mutt_endwin (NULL);
+        fputs (_("No recipients specified.\n"), stderr);
+        exit (1);
       }
 
       if (subject)
-       msg->env->subject = safe_strdup (subject);
+        msg->env->subject = safe_strdup (subject);
 
       if (includeFile)
-       infile = includeFile;
+        infile = includeFile;
     }
 
-    if (infile || bodytext)
-    {
-      if (infile)
-      {
-       if (mutt_strcmp ("-", infile) == 0)
-         fin = stdin;
-       else 
-       {
-         char path[_POSIX_PATH_MAX];
-         
-         strfcpy (path, infile, sizeof (path));
-         mutt_expand_path (path, sizeof (path));
-         if ((fin = fopen (path, "r")) == NULL)
-         {
-           if (!option (OPTNOCURSES))
-             mutt_endwin (NULL);
-           perror (path);
-           exit (1);
-         }
-       }
+    if (infile || bodytext) {
+      if (infile) {
+        if (mutt_strcmp ("-", infile) == 0)
+          fin = stdin;
+        else {
+          char path[_POSIX_PATH_MAX];
+
+          strfcpy (path, infile, sizeof (path));
+          mutt_expand_path (path, sizeof (path));
+          if ((fin = fopen (path, "r")) == NULL) {
+            if (!option (OPTNOCURSES))
+              mutt_endwin (NULL);
+            perror (path);
+            exit (1);
+          }
+        }
       }
       else
-       fin = NULL;
+        fin = NULL;
 
       mutt_mktemp (buf);
       tempfile = safe_strdup (buf);
 
       if (draftFile)
-       msg->env = mutt_read_rfc822_header (fin, NULL, 1, 0);
+        msg->env = mutt_read_rfc822_header (fin, NULL, 1, 0);
 
       /* is the following if still needed? */
-      
-      if (tempfile)
-      {
-       FILE *fout;
-
-       if ((fout = safe_fopen (tempfile, "w")) == NULL)
-       {
-         if (!option (OPTNOCURSES))
-           mutt_endwin (NULL);
-         perror (tempfile);
-         fclose (fin);
-         FREE (&tempfile);
-         exit (1);
-       }
-       if (fin)
-         mutt_copy_stream (fin, fout);
-       else if (bodytext)
-         fputs (bodytext, fout);
-       fclose (fout);
-       if (fin && fin != stdin)
-         fclose (fin);
+
+      if (tempfile) {
+        FILE *fout;
+
+        if ((fout = safe_fopen (tempfile, "w")) == NULL) {
+          if (!option (OPTNOCURSES))
+            mutt_endwin (NULL);
+          perror (tempfile);
+          fclose (fin);
+          FREE (&tempfile);
+          exit (1);
+        }
+        if (fin)
+          mutt_copy_stream (fin, fout);
+        else if (bodytext)
+          fputs (bodytext, fout);
+        fclose (fout);
+        if (fin && fin != stdin)
+          fclose (fin);
       }
     }
 
     FREE (&bodytext);
-    
-    if (attach)
-    {
+
+    if (attach) {
       LIST *t = attach;
       BODY *a = NULL;
 
-      while (t)
-      {
-       if (a)
-       {
-         a->next = mutt_make_file_attach (t->data);
-         a = a->next;
-       }
-       else
-         msg->content = a = mutt_make_file_attach (t->data);
-       if (!a)
-       {
-         if (!option (OPTNOCURSES))
-           mutt_endwin (NULL);
-         fprintf (stderr, _("%s: unable to attach file.\n"), t->data);
-         mutt_free_list (&attach);
-         exit (1);
-       }
-       t = t->next;
+      while (t) {
+        if (a) {
+          a->next = mutt_make_file_attach (t->data);
+          a = a->next;
+        }
+        else
+          msg->content = a = mutt_make_file_attach (t->data);
+        if (!a) {
+          if (!option (OPTNOCURSES))
+            mutt_endwin (NULL);
+          fprintf (stderr, _("%s: unable to attach file.\n"), t->data);
+          mutt_free_list (&attach);
+          exit (1);
+        }
+        t = t->next;
       }
       mutt_free_list (&attach);
     }
@@ -944,83 +874,77 @@ int main (int argc, char **argv)
     if (!option (OPTNOCURSES))
       mutt_endwin (NULL);
   }
-  else
-  {
-    if (flags & M_BUFFY)
-    {
-      if (!mutt_buffy_check (0))
-      {
-       mutt_endwin _("No mailbox with new mail.");
-       exit (1);
+  else {
+    if (flags & M_BUFFY) {
+      if (!mutt_buffy_check (0)) {
+        mutt_endwin _("No mailbox with new mail.");
+
+        exit (1);
       }
       folder[0] = 0;
       mutt_buffy (folder, sizeof (folder));
     }
-    else if (flags & M_SELECT)
-    {
+    else if (flags & M_SELECT) {
 #ifdef USE_NNTP
-      if (flags & M_NEWS)
-      {
-       set_option (OPTNEWS);
-       if(!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)))
-       {
-         mutt_endwin (Errorbuf);
-         exit (1);
-       }
+      if (flags & M_NEWS) {
+        set_option (OPTNEWS);
+        if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) {
+          mutt_endwin (Errorbuf);
+          exit (1);
+        }
       }
       else
 #endif
       if (!Incoming) {
-       mutt_endwin _("No incoming mailboxes defined.");
-       exit (1);
+        mutt_endwin _("No incoming mailboxes defined.");
+
+        exit (1);
       }
       folder[0] = 0;
       mutt_select_file (folder, sizeof (folder), M_SEL_FOLDER | M_SEL_BUFFY);
-      if (!folder[0])
-      {
-       mutt_endwin (NULL);
-       exit (0);
+      if (!folder[0]) {
+        mutt_endwin (NULL);
+        exit (0);
       }
     }
 
     if (!folder[0])
-      strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
+      strfcpy (folder, NONULL (Spoolfile), sizeof (folder));
 
 #ifdef USE_NNTP
-    if (option (OPTNEWS))
-    {
+    if (option (OPTNEWS)) {
       unset_option (OPTNEWS);
-      nntp_expand_path (folder, sizeof (folder), &CurrentNewsSrv->conn->account);
+      nntp_expand_path (folder, sizeof (folder),
+                        &CurrentNewsSrv->conn->account);
     }
     else
 #endif
-    mutt_expand_path (folder, sizeof (folder));
-    
+      mutt_expand_path (folder, sizeof (folder));
+
     mutt_str_replace (&CurrentFolder, folder);
     mutt_str_replace (&LastFolder, folder);
 
-    if (flags & M_IGNORE)
-    {
+    if (flags & M_IGNORE) {
       /* check to see if there are any messages in the folder */
-      switch (mx_check_empty (folder))
-      {
-       case -1:
-         mutt_endwin (strerror (errno));
-         exit (1);
-       case 1:
-         mutt_endwin _("Mailbox is empty.");
-         exit (1);
+      switch (mx_check_empty (folder)) {
+      case -1:
+        mutt_endwin (strerror (errno));
+        exit (1);
+      case 1:
+        mutt_endwin _("Mailbox is empty.");
+        exit (1);
       }
     }
 
     mutt_folder_hook (folder);
 
-    if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
-       || !explicit_folder)
-    {
+    if ((Context = mx_open_mailbox (folder, ((flags & M_RO)
+                                             || option (OPTREADONLY)) ?
+                                    M_READONLY : 0, NULL))
+        || !explicit_folder) {
       mutt_index_menu ();
       if (Context)
-       FREE (&Context);
+        FREE (&Context);
     }
     mutt_endwin (Errorbuf);
   }
index 0ac67a3..92c3221 100644 (file)
--- a/makedoc.c
+++ b/makedoc.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /**
  ** This program parses mutt's init.h and generates documentation in
@@ -63,19 +63,19 @@ extern int optind;
 
 typedef struct {
   short seen;
-  charname;
-  chardescr;
+  char *name;
+  char *descr;
 } var_t;
 
 static int outcount = 0;
-static var_toutbuf = NULL;
+static var_t *outbuf = NULL;
 
-static int var_cmp (const void* a, const void* b) {
-  return (strcmp (((var_t*) a)->name, ((var_t*) b)->name));
+static int var_cmp (const void *a, const void *b)
+{
+  return (strcmp (((var_t *) a)->name, ((var_t *) b)->name));
 }
 
-enum output_formats_t
-{
+enum output_formats_t {
   F_CONF, F_MAN, F_SGML, F_NONE
 };
 
@@ -88,8 +88,7 @@ enum output_formats_t
 #define D_DL            (1 << 6)
 #define D_DT            (1 << 7)
 
-enum
-{
+enum {
   SP_START_EM,
   SP_START_BF,
   SP_END_FT,
@@ -122,8 +121,8 @@ static void makedoc (FILE *, FILE *);
 static void pretty_default (char *, size_t, const char *, int);
 static int sgml_fputc (int);
 static int sgml_fputs (const char *);
-static void add_var (const char*);
-static int add_s (const char*);
+static void add_var (const char *);
+static int add_s (const char *);
 static int add_c (int);
 
 int main (int argc, char *argv[])
@@ -135,16 +134,22 @@ int main (int argc, char *argv[])
     Progname++;
   else
     Progname = argv[0];
-  
-  while ((c = getopt (argc, argv, "cmsd")) != EOF)
-  {
-    switch (c)
-    {
-      case 'c': OutputFormat = F_CONF; break;
-      case 'm': OutputFormat = F_MAN; break;
-      case 's': OutputFormat = F_SGML; break;
-      case 'd': Debug++; break;
-      default: 
+
+  while ((c = getopt (argc, argv, "cmsd")) != EOF) {
+    switch (c) {
+    case 'c':
+      OutputFormat = F_CONF;
+      break;
+    case 'm':
+      OutputFormat = F_MAN;
+      break;
+    case 's':
+      OutputFormat = F_SGML;
+      break;
+    case 'd':
+      Debug++;
+      break;
+    default:
       {
         fprintf (stderr, "%s: bad command line parameter.\n", Progname);
         exit (1);
@@ -152,71 +157,74 @@ int main (int argc, char *argv[])
     }
   }
 
-  if (optind != argc)
-  {
-    if ((f = fopen (argv[optind], "r")) == NULL)
-    {
+  if (optind != argc) {
+    if ((f = fopen (argv[optind], "r")) == NULL) {
       fprintf (stderr, "%s: Can't open %s (%s).\n",
                Progname, argv[optind], strerror (errno));
       exit (1);
     }
   }
-  else 
+  else
     f = stdin;
 
-  switch (OutputFormat)
-  {
-    case F_CONF: 
-    case F_MAN:  
-    case F_SGML: makedoc (f, stdout); break;
-    default:
+  switch (OutputFormat) {
+  case F_CONF:
+  case F_MAN:
+  case F_SGML:
+    makedoc (f, stdout);
+    break;
+  default:
     {
-      fprintf (stderr, "%s: No output format specified.\n",
-               Progname);
+      fprintf (stderr, "%s: No output format specified.\n", Progname);
       exit (1);
     }
   }
-  
+
   if (f != stdin)
     fclose (f);
-  
+
   exit (1);
 }
 
-static void add_var (const char* name) {
-  outbuf = realloc (outbuf, (++outcount) * sizeof(var_t));
-  outbuf[outcount-1].seen = 0;
-  outbuf[outcount-1].name = strdup (name);
-  outbuf[outcount-1].descr = NULL;
+static void add_var (const char *name)
+{
+  outbuf = realloc (outbuf, (++outcount) * sizeof (var_t));
+  outbuf[outcount - 1].seen = 0;
+  outbuf[outcount - 1].name = strdup (name);
+  outbuf[outcount - 1].descr = NULL;
 }
 
-static int add (const char* s) {
-  size_t lnew = STRLEN(s), lold = STRLEN(outbuf[outcount-1].descr);
+static int add (const char *s)
+{
+  size_t lnew = STRLEN (s), lold = STRLEN (outbuf[outcount - 1].descr);
 
   if (lnew == 0)
     return (0);
-  if (!outbuf[outcount-1].seen) {
+  if (!outbuf[outcount - 1].seen) {
     lold = 0;
-    outbuf[outcount-1].seen = 1;
+    outbuf[outcount - 1].seen = 1;
   }
 
   if (lold == 0)
-    outbuf[outcount-1].descr = strdup (s);
+    outbuf[outcount - 1].descr = strdup (s);
   else {
-    outbuf[outcount-1].descr = realloc (outbuf[outcount-1].descr, lold + lnew + 1);
-    memcpy (&(outbuf[outcount-1].descr[lold-1])+1, s, lnew);
+    outbuf[outcount - 1].descr =
+      realloc (outbuf[outcount - 1].descr, lold + lnew + 1);
+    memcpy (&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew);
   }
-  outbuf[outcount-1].descr[lold+lnew] = '\0';
+  outbuf[outcount - 1].descr[lold + lnew] = '\0';
   return (1);
 }
 
-static int add_c (int c) {
+static int add_c (int c)
+{
   char buf[2] = "\0\0";
+
   buf[0] = c;
   return (add (buf));
 }
 
-static void makedoc (FILE *in, FILE *out)
+static void makedoc (FILE * in, FILE * out)
 {
   char buffer[BUFFSIZE];
   char token[BUFFSIZE];
@@ -225,13 +233,11 @@ static void makedoc (FILE *in, FILE *out)
   int line = 0;
   int docstat = D_INIT;
 
-  while ((fgets (buffer, sizeof (buffer), in)))
-  {
+  while ((fgets (buffer, sizeof (buffer), in))) {
     line++;
-    if ((p = strchr (buffer, '\n')) == NULL)
-    {
+    if ((p = strchr (buffer, '\n')) == NULL) {
       fprintf (stderr, "%s: Line %d too long.  Ask a wizard to enlarge\n"
-                       "%s: my buffer size.\n", Progname, line, Progname);
+               "%s: my buffer size.\n", Progname, line, Progname);
       exit (1);
     }
     else
@@ -240,23 +246,20 @@ static void makedoc (FILE *in, FILE *out)
     if (!(p = get_token (token, sizeof (token), buffer)))
       continue;
 
-    if (Debug)
-    {
+    if (Debug) {
       fprintf (stderr, "%s: line %d.  first token: \"%s\".\n",
                Progname, line, token);
     }
-    
+
     if (!strcmp (token, "/*++*/"))
       active = 1;
-    else if (!strcmp (token, "/*--*/"))
-    {
+    else if (!strcmp (token, "/*--*/")) {
       docstat = flush_doc (docstat);
       active = 0;
     }
     else if (active && (!strcmp (token, "/**") || !strcmp (token, "**")))
       docstat = handle_docline (p, docstat);
-    else if (active && !strcmp (token, "{"))
-    {
+    else if (active && !strcmp (token, "{")) {
       docstat = flush_doc (docstat);
       handle_confline (p);
     }
@@ -295,26 +298,21 @@ static char *get_token (char *d, size_t l, char *s)
   char *dd = d;
 
   if (Debug)
-     fprintf (stderr, "%s: get_token called for `%s'.\n",
-              Progname, s);
-  
+    fprintf (stderr, "%s: get_token called for `%s'.\n", Progname, s);
+
   s = skip_ws (s);
 
   if (Debug > 1)
-    fprintf (stderr, "%s: argumet after skip_ws():  `%s'.\n",
-             Progname, s);
+    fprintf (stderr, "%s: argumet after skip_ws():  `%s'.\n", Progname, s);
 
-  if (!*s)
-  {
+  if (!*s) {
     if (Debug)
       fprintf (stderr, "%s: no more tokens on this line.\n", Progname);
     return NULL;
   }
 
-  if (strchr (single_char_tokens, *s))
-  {
-    if (Debug)
-    {
+  if (strchr (single_char_tokens, *s)) {
+    if (Debug) {
       fprintf (stderr, "%s: found single character token `%c'.\n",
                Progname, *s);
     }
@@ -323,38 +321,40 @@ static char *get_token (char *d, size_t l, char *s)
     return s;
   }
 
-  if (*s == '"')
-  {
-    if (Debug)
-    {
+  if (*s == '"') {
+    if (Debug) {
       fprintf (stderr, "%s: found quote character.\n", Progname);
     }
-      
+
     s++;
     is_quoted = 1;
   }
 
-  for (t = s; *t && --l > 0; t++)
-  {
+  for (t = s; *t && --l > 0; t++) {
     if (*t == '\\' && !t[1])
       break;
 
-    if (is_quoted && *t == '\\')
-    {
-      switch ((*d = *++t))
-      {
-        case 'n': *d = '\n'; break;
-        case 't': *d = '\t'; break;
-        case 'r': *d = '\r'; break;
-        case 'a': *d = '\a'; break;
+    if (is_quoted && *t == '\\') {
+      switch ((*d = *++t)) {
+      case 'n':
+        *d = '\n';
+        break;
+      case 't':
+        *d = '\t';
+        break;
+      case 'r':
+        *d = '\r';
+        break;
+      case 'a':
+        *d = '\a';
+        break;
       }
 
       d++;
       continue;
     }
 
-    if (is_quoted && *t == '"')
-    {
+    if (is_quoted && *t == '"') {
       t++;
       break;
     }
@@ -368,14 +368,12 @@ static char *get_token (char *d, size_t l, char *s)
 
   *d = '\0';
 
-  if (Debug)
-  {
+  if (Debug) {
     fprintf (stderr, "%s: Got %stoken: `%s'.\n",
              Progname, is_quoted ? "quoted " : "", dd);
-    fprintf (stderr, "%s: Remainder: `%s'.\n",
-             Progname, t);
+    fprintf (stderr, "%s: Remainder: `%s'.\n", Progname, t);
   }
-  
+
   return t;
 }
 
@@ -392,8 +390,7 @@ static char *get_token (char *d, size_t l, char *s)
  * following string definitions!
  */
 
-enum 
-{
+enum {
   DT_NONE = 0,
   DT_BOOL,
   DT_NUM,
@@ -407,36 +404,34 @@ enum
   DT_ADDR
 };
 
-struct 
-{
+struct {
   char *machine;
   char *human;
-}
-types[] = 
-{
-  { "DT_NONE",  "-none-" },
-  { "DT_BOOL",  "boolean" },
-  { "DT_NUM",   "number" },
-  { "DT_STR",   "string" },
-  { "DT_PATH",  "path" },
-  { "DT_QUAD",  "quadoption" },
-  { "DT_SORT",  "sort order" },
-  { "DT_RX",    "regular expression" },
-  { "DT_MAGIC", "folder magic" },
-  { "DT_SYN",   NULL },
-  { "DT_ADDR",  "e-mail address" },
-  { NULL, NULL }
+} types[] = {
+  {
+  "DT_NONE", "-none-"}, {
+  "DT_BOOL", "boolean"}, {
+  "DT_NUM", "number"}, {
+  "DT_STR", "string"}, {
+  "DT_PATH", "path"}, {
+  "DT_QUAD", "quadoption"}, {
+  "DT_SORT", "sort order"}, {
+  "DT_RX", "regular expression"}, {
+  "DT_MAGIC", "folder magic"}, {
+  "DT_SYN", NULL}, {
+  "DT_ADDR", "e-mail address"}, {
+  NULL, NULL}
 };
-    
+
 
 static int buff2type (const char *s)
 {
   int type;
-  
+
   for (type = DT_NONE; types[type].machine; type++)
     if (!strcmp (types[type].machine, s))
-        return type;
-  
+      return type;
+
   return DT_NONE;
 }
 
@@ -450,68 +445,79 @@ static void handle_confline (char *s)
   char buff[BUFFSIZE];
   char tmp[BUFFSIZE];
   int type;
-  
+
   char val[BUFFSIZE];
 
   /* xxx - put this into an actual state machine? */
 
   /* variable name */
-  if (!(s = get_token (varname, sizeof (varname), s))) return;
-  
+  if (!(s = get_token (varname, sizeof (varname), s)))
+    return;
+
   /* comma */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
-    
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
+
   /* type */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
 
   type = buff2type (buff);
 
   /* possibly a "|" or comma */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
 
-  if (!strcmp (buff, "|"))
-  {
-    if (Debug) fprintf (stderr, "%s: Expecting <subtype> <comma>.\n", Progname);
+  if (!strcmp (buff, "|")) {
+    if (Debug)
+      fprintf (stderr, "%s: Expecting <subtype> <comma>.\n", Progname);
     /* ignore subtype and comma */
-    if (!(s = get_token (buff, sizeof (buff), s))) return;
-    if (!(s = get_token (buff, sizeof (buff), s))) return;
+    if (!(s = get_token (buff, sizeof (buff), s)))
+      return;
+    if (!(s = get_token (buff, sizeof (buff), s)))
+      return;
   }
 
   /* redraw, comma */
-  
-  while (1)
-  {
-    if (!(s = get_token (buff, sizeof (buff), s))) return;
+
+  while (1) {
+    if (!(s = get_token (buff, sizeof (buff), s)))
+      return;
     if (!strcmp (buff, ","))
       break;
   }
 
   /* option name or UL &address */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
   if (!strcmp (buff, "UL"))
-    if (!(s = get_token (buff, sizeof (buff), s))) return;
+    if (!(s = get_token (buff, sizeof (buff), s)))
+      return;
 
   /* comma */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
+
+  if (Debug)
+    fprintf (stderr, "%s: Expecting default value.\n", Progname);
 
-  if (Debug) fprintf (stderr, "%s: Expecting default value.\n", Progname);
-  
   /* <default value> or UL <default value> */
-  if (!(s = get_token (buff, sizeof (buff), s))) return;
-  if (!strcmp (buff, "UL"))
-  {
-    if (Debug) fprintf (stderr, "%s: Skipping UL.\n", Progname);
-    if (!(s = get_token (buff, sizeof (buff), s))) return;
+  if (!(s = get_token (buff, sizeof (buff), s)))
+    return;
+  if (!strcmp (buff, "UL")) {
+    if (Debug)
+      fprintf (stderr, "%s: Skipping UL.\n", Progname);
+    if (!(s = get_token (buff, sizeof (buff), s)))
+      return;
   }
 
   memset (tmp, 0, sizeof (tmp));
 
-  do 
-  {
+  do {
     if (!strcmp (buff, "}"))
       break;
 
-    strncpy (tmp + STRLEN(tmp), buff, sizeof (tmp) - STRLEN(tmp));
+    strncpy (tmp + STRLEN (tmp), buff, sizeof (tmp) - STRLEN (tmp));
   }
   while ((s = get_token (buff, sizeof (buff), s)));
 
@@ -525,17 +531,20 @@ static void pretty_default (char *t, size_t l, const char *s, int type)
   memset (t, 0, l);
   l--;
 
-  switch (type)
-  {
-    case DT_QUAD:
-    {    
-      if (!strcasecmp (s, "M_YES")) strncpy (t, "yes", l);
-      else if (!strcasecmp (s, "M_NO")) strncpy (t, "no", l);
-      else if (!strcasecmp (s, "M_ASKYES")) strncpy (t, "ask-yes", l);
-      else if (!strcasecmp (s, "M_ASKNO")) strncpy (t, "ask-no", l);
+  switch (type) {
+  case DT_QUAD:
+    {
+      if (!strcasecmp (s, "M_YES"))
+        strncpy (t, "yes", l);
+      else if (!strcasecmp (s, "M_NO"))
+        strncpy (t, "no", l);
+      else if (!strcasecmp (s, "M_ASKYES"))
+        strncpy (t, "ask-yes", l);
+      else if (!strcasecmp (s, "M_ASKNO"))
+        strncpy (t, "ask-no", l);
       break;
     }
-    case DT_BOOL:
+  case DT_BOOL:
     {
       if (atoi (s))
         strncpy (t, "yes", l);
@@ -543,30 +552,32 @@ static void pretty_default (char *t, size_t l, const char *s, int type)
         strncpy (t, "no", l);
       break;
     }
-    case DT_SORT:
+  case DT_SORT:
     {
       /* heuristic! */
       strncpy (t, s + 5, l);
-      for (; *t; t++) *t = tolower ((unsigned char) *t);
+      for (; *t; t++)
+        *t = tolower ((unsigned char) *t);
       break;
     }
-    case DT_MAGIC:
+  case DT_MAGIC:
     {
       /* heuristic! */
       strncpy (t, s + 2, l);
-      for (; *t; t++) *t = tolower ((unsigned char) *t);
+      for (; *t; t++)
+        *t = tolower ((unsigned char) *t);
       break;
     }
-    case DT_STR:
-    case DT_RX:
-    case DT_ADDR:
-    case DT_PATH:
+  case DT_STR:
+  case DT_RX:
+  case DT_ADDR:
+  case DT_PATH:
     {
       if (!strcmp (s, "0"))
         break;
       /* fallthrough */
     }
-    default:
+  default:
     {
       strncpy (t, s, l);
       break;
@@ -576,33 +587,41 @@ static void pretty_default (char *t, size_t l, const char *s, int type)
 
 static void char_to_escape (char *dest, unsigned int c)
 {
-  switch (c)
-  {
-    case '\r': strcpy (dest, "\\r"); break;        /* __STRCPY_CHECKED__ */
-    case '\n': strcpy (dest, "\\n"); break;        /* __STRCPY_CHECKED__ */
-    case '\t': strcpy (dest, "\\t"); break;        /* __STRCPY_CHECKED__ */
-    case '\f': strcpy (dest, "\\f"); break;        /* __STRCPY_CHECKED__ */
-    default: sprintf (dest, "\\%03o", c); break;
+  switch (c) {
+  case '\r':
+    strcpy (dest, "\\r");
+    break;                      /* __STRCPY_CHECKED__ */
+  case '\n':
+    strcpy (dest, "\\n");
+    break;                      /* __STRCPY_CHECKED__ */
+  case '\t':
+    strcpy (dest, "\\t");
+    break;                      /* __STRCPY_CHECKED__ */
+  case '\f':
+    strcpy (dest, "\\f");
+    break;                      /* __STRCPY_CHECKED__ */
+  default:
+    sprintf (dest, "\\%03o", c);
+    break;
   }
 }
 static void conf_char_to_escape (unsigned int c)
 {
   char buff[16];
+
   char_to_escape (buff, c);
   add (buff);
 }
 
 static void conf_print_strval (const char *v)
 {
-  for (; *v; v++)
-  {
-    if (*v < ' ' || *v & 0x80)
-    {
+  for (; *v; v++) {
+    if (*v < ' ' || *v & 0x80) {
       conf_char_to_escape ((unsigned int) *v);
       continue;
     }
 
-    if (*v == '"'  || *v == '\\')
+    if (*v == '"' || *v == '\\')
       add_c ('\\');
     add_c (*v);
   }
@@ -610,15 +629,13 @@ static void conf_print_strval (const char *v)
 
 static void man_print_strval (const char *v)
 {
-  for (; *v; v++)
-  {
-    if (*v < ' ' || *v & 0x80)
-    {
+  for (; *v; v++) {
+    if (*v < ' ' || *v & 0x80) {
       add_c ('\\');
       conf_char_to_escape ((unsigned int) *v);
       continue;
     }
-    
+
     if (*v == '"')
       add ("\\(rq");
     else if (*v == '\\')
@@ -631,10 +648,9 @@ static void man_print_strval (const char *v)
 static void sgml_print_strval (const char *v)
 {
   char buff[16];
-  for (; *v; v++)
-  {
-    if (*v <  ' ' || *v & 0x80)
-    {
+
+  for (; *v; v++) {
+    if (*v < ' ' || *v & 0x80) {
       char_to_escape (buff, (unsigned int) *v);
       sgml_fputs (buff);
       continue;
@@ -645,20 +661,31 @@ static void sgml_print_strval (const char *v)
 
 static int sgml_fputc (int c)
 {
-  switch (c)
-  {
-    case '<': return add ("&lt;");
-    case '>': return add ("&gt;");
-    case '$': return add ("&dollar;");
-    case '_': return add ("&lowbar;");
-    case '%': return add ("&percnt;");
-    case '&': return add ("&amp;");
-    case '\\': return add ("&bsol;");
-    case '"': return add ("&dquot;");
-    case '[': return add ("&lsqb;");
-    case ']': return add ("&rsqb;");
-    case '~': return add ("&tilde;");
-    default:  return add_c (c);
+  switch (c) {
+  case '<':
+    return add ("&lt;");
+  case '>':
+    return add ("&gt;");
+  case '$':
+    return add ("&dollar;");
+  case '_':
+    return add ("&lowbar;");
+  case '%':
+    return add ("&percnt;");
+  case '&':
+    return add ("&amp;");
+  case '\\':
+    return add ("&bsol;");
+  case '"':
+    return add ("&dquot;");
+  case '[':
+    return add ("&lsqb;");
+  case ']':
+    return add ("&rsqb;");
+  case '~':
+    return add ("&tilde;");
+  default:
+    return add_c (c);
   }
 }
 
@@ -667,47 +694,45 @@ static int sgml_fputs (const char *s)
   for (; *s; s++)
     if (sgml_fputc ((unsigned int) *s) == EOF)
       return EOF;
-  
+
   return 0;
 }
 
 static void print_confline (const char *varname, int type, const char *val)
 {
-  if (type == DT_SYN) return;
-  
-  switch (OutputFormat)
-  {
+  if (type == DT_SYN)
+    return;
+
+  switch (OutputFormat) {
     /* configuration file */
-    case F_CONF:
+  case F_CONF:
     {
-      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)
-      {
+      if (type == DT_STR || type == DT_RX || type == DT_ADDR
+          || type == DT_PATH) {
         add ("\n# set ");
         add (varname);
         add ("\"");
         conf_print_strval (val);
         add ("\"");
       }
-      else if (type != DT_SYN)
-      {
+      else if (type != DT_SYN) {
         add ("\n# set ");
         add (varname);
         add ("=");
         add (val);
       }
-      
+
       add ("\n#\n# Name: ");
       add (varname);
       add ("\n# Type: ");
       add (type2human (type));
-      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)
-      {
+      if (type == DT_STR || type == DT_RX || type == DT_ADDR
+          || type == DT_PATH) {
         add ("\n# Default: \"");
         conf_print_strval (val);
         add ("\"");
       }
-      else
-      {
+      else {
         add ("\n# Default: ");
         add (val);
       }
@@ -717,7 +742,7 @@ static void print_confline (const char *varname, int type, const char *val)
     }
 
     /* manual page */
-    case F_MAN:
+  case F_MAN:
     {
       add (".TP\n.B ");
       add (varname);
@@ -725,8 +750,8 @@ static void print_confline (const char *varname, int type, const char *val)
       add ("Type: ");
       add (type2human (type));
       add_c ('\n');
-      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)
-      {
+      if (type == DT_STR || type == DT_RX || type == DT_ADDR
+          || type == DT_PATH) {
         add ("Default: \\(lq");
         man_print_strval (val);
         add ("\\(rq\n");
@@ -740,9 +765,9 @@ static void print_confline (const char *varname, int type, const char *val)
 
       break;
     }
-    
+
     /* SGML based manual */
-    case F_SGML:
+  case F_SGML:
     {
       add ("\n<sect2>");
       sgml_fputs (varname);
@@ -753,14 +778,13 @@ static void print_confline (const char *varname, int type, const char *val)
       add (type2human (type));
       add ("</tt>\n\n");
 
-      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)
-      {
+      if (type == DT_STR || type == DT_RX || type == DT_ADDR
+          || type == DT_PATH) {
         add ("<p>\nDefault: <tt>&dquot;");
         sgml_print_strval (val);
         add ("&dquot;</tt>");
       }
-      else
-      {
+      else {
         add ("<p>\nDefault: <tt>");
         add (val);
         add ("</tt>");
@@ -768,8 +792,8 @@ static void print_confline (const char *varname, int type, const char *val)
       break;
     }
     /* make gcc happy */
-    default:
-      break;
+  default:
+    break;
   }
 }
 
@@ -808,9 +832,9 @@ static int flush_doc (int docstat)
   if (docstat & D_INIT)
     return D_INIT;
 
-  if (fd_recurse++)
-  {
-    fprintf (stderr, "%s: Internal error, recursion in flush_doc()!\n", Progname);
+  if (fd_recurse++) {
+    fprintf (stderr, "%s: Internal error, recursion in flush_doc()!\n",
+             Progname);
     exit (1);
   }
 
@@ -833,39 +857,41 @@ static int flush_doc (int docstat)
 
 static int print_it (int special, char *str, int docstat)
 {
-  int onl = docstat & (D_NL|D_NP);
-  
-  docstat &= ~(D_NL|D_NP|D_INIT);
+  int onl = docstat & (D_NL | D_NP);
 
-  switch (OutputFormat)
-  {
+  docstat &= ~(D_NL | D_NP | D_INIT);
+
+  switch (OutputFormat) {
     /* configuration file */
-    case F_CONF:
+  case F_CONF:
     {
-      switch (special)
-      {
+      switch (special) {
         static int Continuation = 0;
 
-        case SP_END_FT: docstat &= ~(D_EM|D_BF); break;
-        case SP_START_BF: docstat |= D_BF; break;
-        case SP_START_EM: docstat |= D_EM; break;
-        case SP_NEWLINE: 
+      case SP_END_FT:
+        docstat &= ~(D_EM | D_BF);
+        break;
+      case SP_START_BF:
+        docstat |= D_BF;
+        break;
+      case SP_START_EM:
+        docstat |= D_EM;
+        break;
+      case SP_NEWLINE:
         {
           if (onl)
             docstat |= onl;
-          else
-          {
+          else {
             add ("\n# ");
             docstat |= D_NL;
           }
           if (docstat & D_DL)
-            ++ Continuation;
+            ++Continuation;
           break;
         }
-        case SP_NEWPAR:
+      case SP_NEWPAR:
         {
-          if (onl & D_NP)
-          {
+          if (onl & D_NP) {
             docstat |= onl;
             break;
           }
@@ -876,54 +902,52 @@ static int print_it (int special, char *str, int docstat)
           docstat |= D_NP;
           break;
         }
-        case SP_START_TAB: 
+      case SP_START_TAB:
         {
-          if (!onl) 
+          if (!onl)
             add ("\n# ");
           docstat |= D_TAB;
           break;
         }
-        case SP_END_TAB:
+      case SP_END_TAB:
         {
           docstat &= ~D_TAB;
           docstat |= D_NL;
           break;
         }
-        case SP_START_DL:
+      case SP_START_DL:
         {
           docstat |= D_DL;
           break;
         }
-        case SP_DT:
+      case SP_DT:
         {
           Continuation = 0;
           docstat |= D_DT;
           break;
         }
-        case SP_DD:
+      case SP_DD:
         {
           Continuation = 0;
           break;
         }
-        case SP_END_DL:
+      case SP_END_DL:
         {
           Continuation = 0;
           docstat &= ~D_DL;
           break;
         }
-        case SP_STR:
+      case SP_STR:
         {
-          if (Continuation)
-          {
+          if (Continuation) {
             Continuation = 0;
             add ("        ");
           }
           add (str);
-          if (docstat & D_DT)
-          { 
+          if (docstat & D_DT) {
             int i;
 
-            for (i = STRLEN(str) ; i < 8 ; i++)
+            for (i = STRLEN (str); i < 8; i++)
               add_c (' ');
             docstat &= ~D_DT;
             docstat |= D_NL;
@@ -935,45 +959,42 @@ static int print_it (int special, char *str, int docstat)
     }
 
     /* manual page */
-    case F_MAN:
+  case F_MAN:
     {
-      switch (special)
-      {
-        case SP_END_FT: 
+      switch (special) {
+      case SP_END_FT:
         {
           add ("\\fP");
-          docstat &= ~(D_EM|D_BF);
+          docstat &= ~(D_EM | D_BF);
           break;
         }
-        case SP_START_BF: 
+      case SP_START_BF:
         {
           add ("\\fB");
           docstat |= D_BF;
           docstat &= ~D_EM;
           break;
         }
-        case SP_START_EM:
+      case SP_START_EM:
         {
           add ("\\fI");
           docstat |= D_EM;
           docstat &= ~D_BF;
           break;
         }
-        case SP_NEWLINE:
+      case SP_NEWLINE:
         {
           if (onl)
             docstat |= onl;
-          else
-          {
+          else {
             add_c ('\n');
             docstat |= D_NL;
           }
           break;
         }
-        case SP_NEWPAR:
+      case SP_NEWPAR:
         {
-          if (onl & D_NP)
-          {
+          if (onl & D_NP) {
             docstat |= onl;
             break;
           }
@@ -985,58 +1006,54 @@ static int print_it (int special, char *str, int docstat)
           docstat |= D_NP;
           break;
         }
-        case SP_START_TAB:
+      case SP_START_TAB:
         {
           add ("\n.IP\n.DS\n.sp\n.ft CR\n.nf\n");
           docstat |= D_TAB | D_NL;
           break;
         }
-        case SP_END_TAB:
+      case SP_END_TAB:
         {
           add ("\n.fi\n.ec\n.ft P\n.sp\n");
           docstat &= ~D_TAB;
           docstat |= D_NL;
           break;
         }
-        case SP_START_DL:
+      case SP_START_DL:
         {
           add ("\n.RS");
           docstat |= D_DL;
           break;
         }
-        case SP_DT:
+      case SP_DT:
         {
           add ("\n.IP ");
           break;
         }
-        case SP_DD:
+      case SP_DD:
         {
           add ("\n");
           break;
         }
-        case SP_END_DL:
+      case SP_END_DL:
         {
           add ("\n.RE");
           docstat &= ~D_DL;
           break;
         }
-        case SP_STR:
+      case SP_STR:
         {
-          while (*str)
-          {
-            for (; *str; str++)
-            {
+          while (*str) {
+            for (; *str; str++) {
               if (*str == '"')
                 add ("\\(rq");
               else if (*str == '\\')
                 add ("\\\\");
-              else if (!strncmp (str, "``", 2))
-              {
+              else if (!strncmp (str, "``", 2)) {
                 add ("\\(lq");
                 str++;
               }
-              else if (!strncmp (str, "''", 2))
-              {
+              else if (!strncmp (str, "''", 2)) {
                 add ("\\(rq");
                 str++;
               }
@@ -1051,46 +1068,45 @@ static int print_it (int special, char *str, int docstat)
     }
 
     /* SGML based manual */
-    case F_SGML:
+  case F_SGML:
     {
-      switch (special)
-      {
-        case SP_END_FT: 
+      switch (special) {
+      case SP_END_FT:
         {
-          if (docstat & D_EM) add("</em>");
-          if (docstat & D_BF) add("</bf>");
-          docstat &= ~(D_EM|D_BF);
+          if (docstat & D_EM)
+            add ("</em>");
+          if (docstat & D_BF)
+            add ("</bf>");
+          docstat &= ~(D_EM | D_BF);
           break;
         }
-        case SP_START_BF: 
+      case SP_START_BF:
         {
           add ("<bf>");
           docstat |= D_BF;
           docstat &= ~D_EM;
           break;
         }
-        case SP_START_EM:
+      case SP_START_EM:
         {
           add ("<em>");
           docstat |= D_EM;
           docstat &= ~D_BF;
           break;
         }
-        case SP_NEWLINE:
+      case SP_NEWLINE:
         {
           if (onl)
             docstat |= onl;
-          else
-          {
+          else {
             add ("\n");
-                   docstat |= D_NL;
+            docstat |= D_NL;
           }
           break;
         }
-        case SP_NEWPAR:
+      case SP_NEWPAR:
         {
-          if (onl & D_NP)
-          {
+          if (onl & D_NP) {
             docstat |= onl;
             break;
           }
@@ -1102,42 +1118,42 @@ static int print_it (int special, char *str, int docstat)
           docstat |= D_NP;
           break;
         }
-        case SP_START_TAB:
+      case SP_START_TAB:
         {
           add ("\n<tscreen><verb>\n");
           docstat |= D_TAB | D_NL;
           break;
         }
-        case SP_END_TAB:
+      case SP_END_TAB:
         {
           add ("\n</verb></tscreen>");
           docstat &= ~D_TAB;
           docstat |= D_NL;
           break;
         }
-        case SP_START_DL:
+      case SP_START_DL:
         {
           add ("\n<descrip>\n");
           docstat |= D_DL;
           break;
         }
-        case SP_DT:
+      case SP_DT:
         {
           add ("<tag>");
           break;
         }
-        case SP_DD:
+      case SP_DD:
         {
           add ("</tag>");
           break;
         }
-        case SP_END_DL:
+      case SP_END_DL:
         {
           add ("</descrip>\n");
           docstat &= ~D_DL;
           break;
         }
-        case SP_STR:
+      case SP_STR:
         {
           if (docstat & D_TAB)
             add (str);
@@ -1149,8 +1165,8 @@ static int print_it (int special, char *str, int docstat)
       break;
     }
     /* make gcc happy (unreached) */
-    default:
-      break;
+  default:
+    break;
   }
 
   return docstat;
@@ -1158,8 +1174,7 @@ static int print_it (int special, char *str, int docstat)
 
 void print_ref (int output_dollar, const char *ref)
 {
-  switch (OutputFormat)
-  {
+  switch (OutputFormat) {
   case F_CONF:
   case F_MAN:
     if (output_dollar)
@@ -1184,8 +1199,7 @@ void print_ref (int output_dollar, const char *ref)
 
 static int commit_buff (char *buff, char **d, int docstat)
 {
-  if (*d > buff)
-  {
+  if (*d > buff) {
     **d = '\0';
     docstat = print_it (SP_STR, buff, docstat);
     *d = buff;
@@ -1198,11 +1212,12 @@ static int handle_docline (char *l, int docstat)
 {
   char buff[BUFFSIZE];
   char *s, *d;
+
   l = skip_ws (l);
 
   if (Debug)
     fprintf (stderr, "%s: handle_docline `%s'\n", Progname, l);
-  
+
   if (!strncmp (l, ".pp", 3))
     return print_it (SP_NEWPAR, NULL, docstat);
   else if (!strncmp (l, ".ts", 3))
@@ -1216,66 +1231,54 @@ static int handle_docline (char *l, int docstat)
   else if (!strncmp (l, ". ", 2))
     *l = ' ';
 
-  for (s = l, d = buff; *s; s++)
-  {
-    if (!strncmp (s, "\\(as", 4))
-    {
+  for (s = l, d = buff; *s; s++) {
+    if (!strncmp (s, "\\(as", 4)) {
       *d++ = '*';
       s += 3;
     }
-    else if (!strncmp (s, "\\(rs", 4))
-    {
+    else if (!strncmp (s, "\\(rs", 4)) {
       *d++ = '\\';
       s += 3;
     }
-    else if (!strncmp (s, "\\fI", 3))
-    {
+    else if (!strncmp (s, "\\fI", 3)) {
       docstat = commit_buff (buff, &d, docstat);
       docstat = print_it (SP_START_EM, NULL, docstat);
       s += 2;
     }
-    else if (!strncmp (s, "\\fB", 3))
-    {
+    else if (!strncmp (s, "\\fB", 3)) {
       docstat = commit_buff (buff, &d, docstat);
       docstat = print_it (SP_START_BF, NULL, docstat);
       s += 2;
     }
-    else if (!strncmp (s, "\\fP", 3))
-    {
+    else if (!strncmp (s, "\\fP", 3)) {
       docstat = commit_buff (buff, &d, docstat);
       docstat = print_it (SP_END_FT, NULL, docstat);
       s += 2;
     }
-    else if (!strncmp (s, ".dt", 3))
-    {
+    else if (!strncmp (s, ".dt", 3)) {
       docstat = commit_buff (buff, &d, docstat);
       docstat = print_it (SP_DT, NULL, docstat);
       s += 3;
     }
-    else if (!strncmp (s, ".dd", 3))
-    {
+    else if (!strncmp (s, ".dd", 3)) {
       docstat = commit_buff (buff, &d, docstat);
       docstat = print_it (SP_DD, NULL, docstat);
       s += 3;
     }
-    else if (*s == '$')
-    {
+    else if (*s == '$') {
       int output_dollar = 0;
       char *ref;
       char save;
 
       ++s;
-      if (*s == '$')
-      {
+      if (*s == '$') {
         output_dollar = 1;
         ++s;
       }
-      if (*s == '$')
-      {
+      if (*s == '$') {
         *d++ = '$';
       }
-      else
-      {
+      else {
         ref = s;
         while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_')
           ++s;
index b944e2a..4424a93 100644 (file)
--- a/mapping.h
+++ b/mapping.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef MAPPING_H
 #define MAPPING_H
 
-struct mapping_t
-{
+struct mapping_t {
   char *name;
   int value;
 };
diff --git a/mbox.c b/mbox.c
index b459f4e..64d86b8 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* This file contains code to parse ``mbox'' and ``mmdf'' style mailboxes */
 
@@ -42,8 +42,7 @@
 #include <fcntl.h>
 
 /* struct used by mutt_sync_mailbox() to store new offsets */
-struct m_update_t
-{
+struct m_update_t {
   short valid;
   long hdr;
   long body;
@@ -56,25 +55,23 @@ struct m_update_t
  * excl - exclusive lock?
  * retry - should retry if unable to lock?
  */
-int mbox_lock_mailbox (CONTEXT *ctx, int excl, int retry)
+int mbox_lock_mailbox (CONTEXT * ctx, int excl, int retry)
 {
   int r;
 
   if ((r = mx_lock_file (ctx->path, fileno (ctx->fp), excl, 1, retry)) == 0)
     ctx->locked = 1;
-  else if (retry && !excl)
-  {
+  else if (retry && !excl) {
     ctx->readonly = 1;
     return 0;
   }
-  
+
   return (r);
 }
 
-void mbox_unlock_mailbox (CONTEXT *ctx)
+void mbox_unlock_mailbox (CONTEXT * ctx)
 {
-  if (ctx->locked)
-  {
+  if (ctx->locked) {
     fflush (ctx->fp);
 
     mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
@@ -82,7 +79,7 @@ void mbox_unlock_mailbox (CONTEXT *ctx)
   }
 }
 
-int mmdf_parse_mailbox (CONTEXT *ctx)
+int mmdf_parse_mailbox (CONTEXT * ctx)
 {
   char buf[HUGE_STRING];
   char return_path[LONG_STRING];
@@ -92,12 +89,12 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
   long loc, tmploc;
   HEADER *hdr;
   struct stat sb;
+
 #ifdef NFS_ATTRIBUTE_HACK
   struct utimbuf newtime;
 #endif
 
-  if (stat (ctx->path, &sb) == -1)
-  {
+  if (stat (ctx->path, &sb) == -1) {
     mutt_perror (ctx->path);
     return (-1);
   }
@@ -105,8 +102,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
   ctx->size = sb.st_size;
 
 #ifdef NFS_ATTRIBUTE_HACK
-  if (sb.st_mtime > sb.st_atime)
-  {
+  if (sb.st_mtime > sb.st_atime) {
     newtime.modtime = sb.st_mtime;
     newtime.actime = time (NULL);
     utime (ctx->path, &newtime);
@@ -118,100 +114,93 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
   tz = mutt_local_tz (0);
 
   buf[sizeof (buf) - 1] = 0;
-  
-  FOREVER
-  {
+
+  FOREVER {
     if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
       break;
 
-    if (mutt_strcmp (buf, MMDF_SEP) == 0)
-    {
+    if (mutt_strcmp (buf, MMDF_SEP) == 0) {
       loc = ftell (ctx->fp);
-      
+
       count++;
       if (!ctx->quiet && ReadInc && ((count % ReadInc == 0) || count == 1))
-       mutt_message (_("Reading %s... %d (%d%%)"), ctx->path, count,
-                     (int)(loc / (ctx->size / 100 + 1)));
+        mutt_message (_("Reading %s... %d (%d%%)"), ctx->path, count,
+                      (int) (loc / (ctx->size / 100 + 1)));
 
 
       if (ctx->msgcount == ctx->hdrmax)
-       mx_alloc_memory (ctx);
+        mx_alloc_memory (ctx);
       ctx->hdrs[ctx->msgcount] = hdr = mutt_new_header ();
       hdr->offset = loc;
       hdr->index = ctx->msgcount;
 
-      if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
-      {
-       /* TODO: memory leak??? */
-       dprint (1, (debugfile, "mmdf_parse_mailbox: unexpected EOF\n"));
-       break;
+      if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) {
+        /* TODO: memory leak??? */
+        dprint (1, (debugfile, "mmdf_parse_mailbox: unexpected EOF\n"));
+        break;
       }
 
       return_path[0] = 0;
 
-      if (!is_from (buf, return_path, sizeof (return_path), &t))
-      {
-       if (fseek (ctx->fp, loc, SEEK_SET) != 0)
-       {
-         dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
-         mutt_error _("Mailbox is corrupt!");
-         return (-1);
-       }
-      } 
+      if (!is_from (buf, return_path, sizeof (return_path), &t)) {
+        if (fseek (ctx->fp, loc, SEEK_SET) != 0) {
+          dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
+          mutt_error _("Mailbox is corrupt!");
+
+          return (-1);
+        }
+      }
       else
-       hdr->received = t - tz;
+        hdr->received = t - tz;
 
       hdr->env = mutt_read_rfc822_header (ctx->fp, hdr, 0, 0);
 
       loc = ftell (ctx->fp);
 
-      if (hdr->content->length > 0 && hdr->lines > 0)
-      {
-       tmploc = loc + hdr->content->length;
-
-       if (0 < tmploc && tmploc < ctx->size)
-       {
-         if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
-             fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
-             mutt_strcmp (MMDF_SEP, buf) != 0)
-         {
-           if (fseek (ctx->fp, loc, SEEK_SET) != 0)
-             dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
-           hdr->content->length = -1;
-         }
-       }
-       else
-         hdr->content->length = -1;
+      if (hdr->content->length > 0 && hdr->lines > 0) {
+        tmploc = loc + hdr->content->length;
+
+        if (0 < tmploc && tmploc < ctx->size) {
+          if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
+              fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
+              mutt_strcmp (MMDF_SEP, buf) != 0) {
+            if (fseek (ctx->fp, loc, SEEK_SET) != 0)
+              dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
+            hdr->content->length = -1;
+          }
+        }
+        else
+          hdr->content->length = -1;
       }
       else
-       hdr->content->length = -1;
-
-      if (hdr->content->length < 0)
-      {
-       lines = -1;
-       do {
-         loc = ftell (ctx->fp);
-         if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
-           break;
-         lines++;
-       } while (mutt_strcmp (buf, MMDF_SEP) != 0);
-
-       hdr->lines = lines;
-       hdr->content->length = loc - hdr->content->offset;
+        hdr->content->length = -1;
+
+      if (hdr->content->length < 0) {
+        lines = -1;
+        do {
+          loc = ftell (ctx->fp);
+          if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
+            break;
+          lines++;
+        } while (mutt_strcmp (buf, MMDF_SEP) != 0);
+
+        hdr->lines = lines;
+        hdr->content->length = loc - hdr->content->offset;
       }
 
       if (!hdr->env->return_path && return_path[0])
-       hdr->env->return_path = rfc822_parse_adrlist (hdr->env->return_path, return_path);
+        hdr->env->return_path =
+          rfc822_parse_adrlist (hdr->env->return_path, return_path);
 
       if (!hdr->env->from)
-       hdr->env->from = rfc822_cpy_adr (hdr->env->return_path);
+        hdr->env->from = rfc822_cpy_adr (hdr->env->return_path);
 
       ctx->msgcount++;
     }
-    else
-    {
+    else {
       dprint (1, (debugfile, "mmdf_parse_mailbox: corrupt mailbox!\n"));
       mutt_error _("Mailbox is corrupt!");
+
       return (-1);
     }
   }
@@ -228,7 +217,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
  * NOTE: it is assumed that the mailbox being read has been locked before
  * this routine gets called.  Strange things could happen if it's not!
  */
-int mbox_parse_mailbox (CONTEXT *ctx)
+int mbox_parse_mailbox (CONTEXT * ctx)
 {
   struct stat sb;
   char buf[HUGE_STRING], return_path[STRING];
@@ -236,13 +225,13 @@ int mbox_parse_mailbox (CONTEXT *ctx)
   time_t t, tz;
   int count = 0, lines = 0;
   long loc;
+
 #ifdef NFS_ATTRIBUTE_HACK
   struct utimbuf newtime;
 #endif
 
   /* Save information about the folder at the time we opened it. */
-  if (stat (ctx->path, &sb) == -1)
-  {
+  if (stat (ctx->path, &sb) == -1) {
     mutt_perror (ctx->path);
     return (-1);
   }
@@ -251,8 +240,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
   ctx->mtime = sb.st_mtime;
 
 #ifdef NFS_ATTRIBUTE_HACK
-  if (sb.st_mtime > sb.st_atime)
-  {
+  if (sb.st_mtime > sb.st_atime) {
     newtime.modtime = sb.st_mtime;
     newtime.actime = time (NULL);
     utime (ctx->path, &newtime);
@@ -267,133 +255,123 @@ int mbox_parse_mailbox (CONTEXT *ctx)
   tz = mutt_local_tz (0);
 
   loc = ftell (ctx->fp);
-  while (fgets (buf, sizeof (buf), ctx->fp) != NULL)
-  {
-    if (is_from (buf, return_path, sizeof (return_path), &t))
-    {
+  while (fgets (buf, sizeof (buf), ctx->fp) != NULL) {
+    if (is_from (buf, return_path, sizeof (return_path), &t)) {
       /* Save the Content-Length of the previous message */
-      if (count > 0)
-      {
+      if (count > 0) {
 #define PREV ctx->hdrs[ctx->msgcount-1]
 
-       if (PREV->content->length < 0)
-       {
-         PREV->content->length = loc - PREV->content->offset - 1;
-         if (PREV->content->length < 0)
-           PREV->content->length = 0;
-       }
-       if (!PREV->lines)
-         PREV->lines = lines ? lines - 1 : 0;
+        if (PREV->content->length < 0) {
+          PREV->content->length = loc - PREV->content->offset - 1;
+          if (PREV->content->length < 0)
+            PREV->content->length = 0;
+        }
+        if (!PREV->lines)
+          PREV->lines = lines ? lines - 1 : 0;
       }
 
       count++;
 
       if (!ctx->quiet && ReadInc && ((count % ReadInc == 0) || count == 1))
-       mutt_message (_("Reading %s... %d (%d%%)"), ctx->path, count,
-                     (int)(ftell (ctx->fp) / (ctx->size / 100 + 1)));
+        mutt_message (_("Reading %s... %d (%d%%)"), ctx->path, count,
+                      (int) (ftell (ctx->fp) / (ctx->size / 100 + 1)));
 
       if (ctx->msgcount == ctx->hdrmax)
-       mx_alloc_memory (ctx);
-      
+        mx_alloc_memory (ctx);
+
       curhdr = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
       curhdr->received = t - tz;
       curhdr->offset = loc;
       curhdr->index = ctx->msgcount;
-       
+
       curhdr->env = mutt_read_rfc822_header (ctx->fp, curhdr, 0, 0);
 
       /* if we know how long this message is, either just skip over the body,
        * or if we don't know how many lines there are, count them now (this will
        * save time by not having to search for the next message marker).
        */
-      if (curhdr->content->length > 0)
-      {
-       long tmploc;
-
-       loc = ftell (ctx->fp);
-       tmploc = loc + curhdr->content->length + 1;
-
-       if (0 < tmploc && tmploc < ctx->size)
-       {
-         /*
-          * check to see if the content-length looks valid.  we expect to
-          * to see a valid message separator at this point in the stream
-          */
-         if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
-             fgets (buf, sizeof (buf), ctx->fp) == NULL ||
-             mutt_strncmp ("From ", buf, 5) != 0)
-         {
-           dprint (1, (debugfile, "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n", curhdr->index, curhdr->content->length));
-           dprint (1, (debugfile, "\tLINE: %s", buf));
-           if (fseek (ctx->fp, loc, SEEK_SET) != 0) /* nope, return the previous position */
-           {
-             dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
-           }
-           curhdr->content->length = -1;
-         }
-       }
-       else if (tmploc != ctx->size)
-       {
-         /* content-length would put us past the end of the file, so it
-          * must be wrong
-          */
-         curhdr->content->length = -1;
-       }
-
-       if (curhdr->content->length != -1)
-       {
-         /* good content-length.  check to see if we know how many lines
-          * are in this message.
-          */
-         if (curhdr->lines == 0)
-         {
-           int cl = curhdr->content->length;
-
-           /* count the number of lines in this message */
-           if (fseek (ctx->fp, loc, SEEK_SET) != 0)
-             dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
-           while (cl-- > 0)
-           {
-             if (fgetc (ctx->fp) == '\n')
-               curhdr->lines++;
-           }
-         }
-
-         /* return to the offset of the next message separator */
-         if (fseek (ctx->fp, tmploc, SEEK_SET) != 0)
-           dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
-       }
+      if (curhdr->content->length > 0) {
+        long tmploc;
+
+        loc = ftell (ctx->fp);
+        tmploc = loc + curhdr->content->length + 1;
+
+        if (0 < tmploc && tmploc < ctx->size) {
+          /*
+           * check to see if the content-length looks valid.  we expect to
+           * to see a valid message separator at this point in the stream
+           */
+          if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
+              fgets (buf, sizeof (buf), ctx->fp) == NULL ||
+              mutt_strncmp ("From ", buf, 5) != 0) {
+            dprint (1,
+                    (debugfile,
+                     "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n",
+                     curhdr->index, curhdr->content->length));
+            dprint (1, (debugfile, "\tLINE: %s", buf));
+            if (fseek (ctx->fp, loc, SEEK_SET) != 0) {  /* nope, return the previous position */
+              dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+            }
+            curhdr->content->length = -1;
+          }
+        }
+        else if (tmploc != ctx->size) {
+          /* content-length would put us past the end of the file, so it
+           * must be wrong
+           */
+          curhdr->content->length = -1;
+        }
+
+        if (curhdr->content->length != -1) {
+          /* good content-length.  check to see if we know how many lines
+           * are in this message.
+           */
+          if (curhdr->lines == 0) {
+            int cl = curhdr->content->length;
+
+            /* count the number of lines in this message */
+            if (fseek (ctx->fp, loc, SEEK_SET) != 0)
+              dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+            while (cl-- > 0) {
+              if (fgetc (ctx->fp) == '\n')
+                curhdr->lines++;
+            }
+          }
+
+          /* return to the offset of the next message separator */
+          if (fseek (ctx->fp, tmploc, SEEK_SET) != 0)
+            dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+        }
       }
 
       ctx->msgcount++;
 
       if (!curhdr->env->return_path && return_path[0])
-       curhdr->env->return_path = rfc822_parse_adrlist (curhdr->env->return_path, return_path);
+        curhdr->env->return_path =
+          rfc822_parse_adrlist (curhdr->env->return_path, return_path);
 
       if (!curhdr->env->from)
-       curhdr->env->from = rfc822_cpy_adr (curhdr->env->return_path);
+        curhdr->env->from = rfc822_cpy_adr (curhdr->env->return_path);
 
       lines = 0;
     }
     else
       lines++;
-    
+
     loc = ftell (ctx->fp);
   }
-  
+
   /*
    * Only set the content-length of the previous message if we have read more
    * than one message during _this_ invocation.  If this routine is called
    * when new mail is received, we need to make sure not to clobber what
    * previously was the last message since the headers may be sorted.
    */
-  if (count > 0)
-  {
-    if (PREV->content->length < 0)
-    {
+  if (count > 0) {
+    if (PREV->content->length < 0) {
       PREV->content->length = ftell (ctx->fp) - PREV->content->offset - 1;
       if (PREV->content->length < 0)
-       PREV->content->length = 0;
+        PREV->content->length = 0;
     }
 
     if (!PREV->lines)
@@ -408,18 +386,16 @@ int mbox_parse_mailbox (CONTEXT *ctx)
 #undef PREV
 
 /* open a mbox or mmdf style mailbox */
-int mbox_open_mailbox (CONTEXT *ctx)
+int mbox_open_mailbox (CONTEXT * ctx)
 {
   int rc;
 
-  if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
-  {
+  if ((ctx->fp = fopen (ctx->path, "r")) == NULL) {
     mutt_perror (ctx->path);
     return (-1);
   }
   mutt_block_signals ();
-  if (mbox_lock_mailbox (ctx, 0, 1) == -1)
-  {
+  if (mbox_lock_mailbox (ctx, 0, 1) == -1) {
     mutt_unblock_signals ();
     return (-1);
   }
@@ -437,12 +413,11 @@ int mbox_open_mailbox (CONTEXT *ctx)
 }
 
 /* return 1 if address lists are strictly identical */
-static int strict_addrcmp (const ADDRESS *a, const ADDRESS *b)
+static int strict_addrcmp (const ADDRESS * a, const ADDRESS * b)
 {
-  while (a && b)
-  {
+  while (a && b) {
     if (mutt_strcmp (a->mailbox, b->mailbox) ||
-       mutt_strcmp (a->personal, b->personal))
+        mutt_strcmp (a->personal, b->personal))
       return (0);
 
     a = a->next;
@@ -454,10 +429,9 @@ static int strict_addrcmp (const ADDRESS *a, const ADDRESS *b)
   return (1);
 }
 
-static int strict_cmp_lists (const LIST *a, const LIST *b)
+static int strict_cmp_lists (const LIST * a, const LIST * b)
 {
-  while (a && b)
-  {
+  while (a && b) {
     if (mutt_strcmp (a->data, b->data))
       return (0);
 
@@ -470,25 +444,23 @@ static int strict_cmp_lists (const LIST *a, const LIST *b)
   return (1);
 }
 
-static int strict_cmp_envelopes (const ENVELOPE *e1, const ENVELOPE *e2)
+static int strict_cmp_envelopes (const ENVELOPE * e1, const ENVELOPE * e2)
 {
-  if (e1 && e2)
-  {
+  if (e1 && e2) {
     if (mutt_strcmp (e1->message_id, e2->message_id) ||
-       mutt_strcmp (e1->subject, e2->subject) ||
-       !strict_cmp_lists (e1->references, e2->references) ||
-       !strict_addrcmp (e1->from, e2->from) ||
-       !strict_addrcmp (e1->sender, e2->sender) ||
-       !strict_addrcmp (e1->reply_to, e2->reply_to) ||
-       !strict_addrcmp (e1->to, e2->to) ||
-       !strict_addrcmp (e1->cc, e2->cc) ||
-       !strict_addrcmp (e1->return_path, e2->return_path))
+        mutt_strcmp (e1->subject, e2->subject) ||
+        !strict_cmp_lists (e1->references, e2->references) ||
+        !strict_addrcmp (e1->from, e2->from) ||
+        !strict_addrcmp (e1->sender, e2->sender) ||
+        !strict_addrcmp (e1->reply_to, e2->reply_to) ||
+        !strict_addrcmp (e1->to, e2->to) ||
+        !strict_addrcmp (e1->cc, e2->cc) ||
+        !strict_addrcmp (e1->return_path, e2->return_path))
       return (0);
     else
       return (1);
   }
-  else
-  {
+  else {
     if (e1 == NULL && e2 == NULL)
       return (1);
     else
@@ -496,12 +468,11 @@ static int strict_cmp_envelopes (const ENVELOPE *e1, const ENVELOPE *e2)
   }
 }
 
-static int strict_cmp_parameters (const PARAMETER *p1, const PARAMETER *p2)
+static int strict_cmp_parameters (const PARAMETER * p1, const PARAMETER * p2)
 {
-  while (p1 && p2)
-  {
+  while (p1 && p2) {
     if (mutt_strcmp (p1->attribute, p2->attribute) ||
-       mutt_strcmp (p1->value, p2->value))
+        mutt_strcmp (p1->value, p2->value))
       return (0);
 
     p1 = p1->next;
@@ -513,7 +484,7 @@ static int strict_cmp_parameters (const PARAMETER *p1, const PARAMETER *p2)
   return (1);
 }
 
-static int strict_cmp_bodies (const BODY *b1, const BODY *b2)
+static int strict_cmp_bodies (const BODY * b1, const BODY * b2)
 {
   if (b1->type != b2->type ||
       b1->encoding != b2->encoding ||
@@ -526,26 +497,24 @@ static int strict_cmp_bodies (const BODY *b1, const BODY *b2)
 }
 
 /* return 1 if headers are strictly identical */
-int mbox_strict_cmp_headers (const HEADER *h1, const HEADER *h2)
+int mbox_strict_cmp_headers (const HEADER * h1, const HEADER * h2)
 {
-  if (h1 && h2)
-  {
+  if (h1 && h2) {
     if (h1->received != h2->received ||
-       h1->date_sent != h2->date_sent ||
-       h1->content->length != h2->content->length ||
-       h1->lines != h2->lines ||
-       h1->zhours != h2->zhours ||
-       h1->zminutes != h2->zminutes ||
-       h1->zoccident != h2->zoccident ||
-       h1->mime != h2->mime ||
-       !strict_cmp_envelopes (h1->env, h2->env) ||
-       !strict_cmp_bodies (h1->content, h2->content))
+        h1->date_sent != h2->date_sent ||
+        h1->content->length != h2->content->length ||
+        h1->lines != h2->lines ||
+        h1->zhours != h2->zhours ||
+        h1->zminutes != h2->zminutes ||
+        h1->zoccident != h2->zoccident ||
+        h1->mime != h2->mime ||
+        !strict_cmp_envelopes (h1->env, h2->env) ||
+        !strict_cmp_bodies (h1->content, h2->content))
       return (0);
     else
       return (1);
   }
-  else
-  {
+  else {
     if (h1 == NULL && h2 == NULL)
       return (1);
     else
@@ -562,41 +531,36 @@ int mbox_strict_cmp_headers (const HEADER *h1, const HEADER *h2)
  *     0               no change
  *     -1              error
  */
-int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
+int mbox_check_mailbox (CONTEXT * ctx, int *index_hint)
 {
   struct stat st;
   char buffer[LONG_STRING];
   int unlock = 0;
   int modified = 0;
 
-  if (stat (ctx->path, &st) == 0)
-  {
+  if (stat (ctx->path, &st) == 0) {
     if (st.st_mtime == ctx->mtime && st.st_size == ctx->size)
       return (0);
 
-    if (st.st_size == ctx->size)
-    {
+    if (st.st_size == ctx->size) {
       /* the file was touched, but it is still the same length, so just exit */
       ctx->mtime = st.st_mtime;
       return (0);
     }
 
-    if (st.st_size > ctx->size)
-    {
+    if (st.st_size > ctx->size) {
       /* lock the file if it isn't already */
-      if (!ctx->locked)
-      {
-       mutt_block_signals ();
-       if (mbox_lock_mailbox (ctx, 0, 0) == -1)
-       {
-         mutt_unblock_signals ();
-         /* we couldn't lock the mailbox, but nothing serious happened:
-          * probably the new mail arrived: no reason to wait till we can
-          * parse it: we'll get it on the next pass
-          */
-         return (M_LOCKED);
-       }
-       unlock = 1;
+      if (!ctx->locked) {
+        mutt_block_signals ();
+        if (mbox_lock_mailbox (ctx, 0, 0) == -1) {
+          mutt_unblock_signals ();
+          /* we couldn't lock the mailbox, but nothing serious happened:
+           * probably the new mail arrived: no reason to wait till we can
+           * parse it: we'll get it on the next pass
+           */
+          return (M_LOCKED);
+        }
+        unlock = 1;
       }
 
       /*
@@ -606,53 +570,46 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
        * folder.
        */
       if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
-       dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
-      if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL)
-      {
-       if ((ctx->magic == M_MBOX && mutt_strncmp ("From ", buffer, 5) == 0) ||
-           (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buffer) == 0))
-       {
-         if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
-           dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
-         if (ctx->magic == M_MBOX)
-           mbox_parse_mailbox (ctx);
-         else
-           mmdf_parse_mailbox (ctx);
-
-         /* Only unlock the folder if it was locked inside of this routine.
-          * It may have been locked elsewhere, like in
-          * mutt_checkpoint_mailbox().
-          */
-
-         if (unlock)
-         {
-           mbox_unlock_mailbox (ctx);
-           mutt_unblock_signals ();
-         }
-
-         return (M_NEW_MAIL); /* signal that new mail arrived */
-       }
-       else
-         modified = 1;
+        dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
+      if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) {
+        if ((ctx->magic == M_MBOX && mutt_strncmp ("From ", buffer, 5) == 0)
+            || (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buffer) == 0)) {
+          if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
+            dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
+          if (ctx->magic == M_MBOX)
+            mbox_parse_mailbox (ctx);
+          else
+            mmdf_parse_mailbox (ctx);
+
+          /* Only unlock the folder if it was locked inside of this routine.
+           * It may have been locked elsewhere, like in
+           * mutt_checkpoint_mailbox().
+           */
+
+          if (unlock) {
+            mbox_unlock_mailbox (ctx);
+            mutt_unblock_signals ();
+          }
+
+          return (M_NEW_MAIL);  /* signal that new mail arrived */
+        }
+        else
+          modified = 1;
       }
-      else
-      {
-       dprint (1, (debugfile, "mbox_check_mailbox: fgets returned NULL.\n"));
-       modified = 1;
+      else {
+        dprint (1, (debugfile, "mbox_check_mailbox: fgets returned NULL.\n"));
+        modified = 1;
       }
     }
     else
       modified = 1;
   }
 
-  if (modified)
-  {
-    if (mutt_reopen_mailbox (ctx, index_hint) != -1)
-    {
-      if (unlock)
-      {
-       mbox_unlock_mailbox (ctx);
-       mutt_unblock_signals ();
+  if (modified) {
+    if (mutt_reopen_mailbox (ctx, index_hint) != -1) {
+      if (unlock) {
+        mbox_unlock_mailbox (ctx);
+        mutt_unblock_signals ();
       }
       return (M_REOPENED);
     }
@@ -664,6 +621,7 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
   mx_fastclose_mailbox (ctx);
   mutt_unblock_signals ();
   mutt_error _("Mailbox was corrupted!");
+
   return (-1);
 }
 
@@ -671,15 +629,15 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
  *     0       success
  *     -1      failure
  */
-int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
+int mbox_sync_mailbox (CONTEXT * ctx, int *index_hint)
 {
   char tempfile[_POSIX_PATH_MAX];
   char buf[32];
   int i, j, save_sort = SORT_ORDER;
   int rc = -1;
-  int need_sort = 0; /* flag to resort mailbox if new mail arrives */
-  int first = -1;      /* first message to be written */
-  long offset; /* location in mailbox to write changed messages */
+  int need_sort = 0;            /* flag to resort mailbox if new mail arrives */
+  int first = -1;               /* first message to be written */
+  long offset;                  /* location in mailbox to write changed messages */
   struct stat statbuf;
   struct utimbuf utimebuf;
   struct m_update_t *newOffset = NULL;
@@ -687,8 +645,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   FILE *fp = NULL;
 
   /* sort message by their position in the mailbox on disk */
-  if (Sort != SORT_ORDER)
-  {
+  if (Sort != SORT_ORDER) {
     save_sort = Sort;
     Sort = SORT_ORDER;
     mutt_sort_headers (ctx, 0);
@@ -697,32 +654,31 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   /* need to open the file for writing in such a way that it does not truncate
    * the file, so use read-write mode.
    */
-  if ((ctx->fp = freopen (ctx->path, "r+", ctx->fp)) == NULL)
-  {
+  if ((ctx->fp = freopen (ctx->path, "r+", ctx->fp)) == NULL) {
     mx_fastclose_mailbox (ctx);
     mutt_error _("Fatal error!  Could not reopen mailbox!");
+
     return (-1);
   }
 
   mutt_block_signals ();
 
-  if (mbox_lock_mailbox (ctx, 1, 1) == -1)
-  {
+  if (mbox_lock_mailbox (ctx, 1, 1) == -1) {
     mutt_unblock_signals ();
     mutt_error _("Unable to lock mailbox!");
+
     goto bail;
   }
 
   /* Check to make sure that the file hasn't changed on disk */
-  if ((i = mbox_check_mailbox (ctx, index_hint)) == M_NEW_MAIL ||  i == M_REOPENED)
-  {
+  if ((i = mbox_check_mailbox (ctx, index_hint)) == M_NEW_MAIL
+      || i == M_REOPENED) {
     /* new mail arrived, or mailbox reopened */
     need_sort = i;
     rc = i;
     goto bail;
   }
-  else if (i < 0)
-  {
+  else if (i < 0) {
     /* fatal error */
     Sort = save_sort;
     return (-1);
@@ -731,14 +687,13 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   /* Create a temporary file to write the new version of the mailbox in. */
   mutt_mktemp (tempfile);
   if ((i = open (tempfile, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1 ||
-      (fp = fdopen (i, "w")) == NULL)
-  {
-    if (-1 != i)
-    {
+      (fp = fdopen (i, "w")) == NULL) {
+    if (-1 != i) {
       close (i);
       unlink (tempfile);
     }
     mutt_error _("Could not create temporary file!");
+
     mutt_sleep (5);
     goto bail;
   }
@@ -746,67 +701,62 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   /* find the first deleted/changed message.  we save a lot of time by only
    * rewriting the mailbox from the point where it has actually changed.
    */
-  for (i = 0 ; i < ctx->msgcount && !ctx->hdrs[i]->deleted && 
-               !ctx->hdrs[i]->changed && !ctx->hdrs[i]->attach_del; i++)
-    ;
-  if (i == ctx->msgcount)
-  { 
+  for (i = 0; i < ctx->msgcount && !ctx->hdrs[i]->deleted &&
+       !ctx->hdrs[i]->changed && !ctx->hdrs[i]->attach_del; i++);
+  if (i == ctx->msgcount) {
     /* this means ctx->changed or ctx->deleted was set, but no
      * messages were found to be changed or deleted.  This should
      * never happen, is we presume it is a bug in mutt.
      */
-    mutt_error _("sync: mbox modified, but no modified messages! (report this bug)");
-    mutt_sleep(5); /* the mutt_error /will/ get cleared! */
-    dprint(1, (debugfile, "mbox_sync_mailbox(): no modified messages.\n"));
+    mutt_error
+      _("sync: mbox modified, but no modified messages! (report this bug)");
+    mutt_sleep (5);             /* the mutt_error /will/ get cleared! */
+    dprint (1, (debugfile, "mbox_sync_mailbox(): no modified messages.\n"));
     unlink (tempfile);
     goto bail;
   }
 
-    /* save the index of the first changed/deleted message */
-  first = i; 
+  /* save the index of the first changed/deleted message */
+  first = i;
   /* where to start overwriting */
-  offset = ctx->hdrs[i]->offset; 
+  offset = ctx->hdrs[i]->offset;
 
   /* the offset stored in the header does not include the MMDF_SEP, so make
    * sure we seek to the correct location
    */
   if (ctx->magic == M_MMDF)
     offset -= (sizeof MMDF_SEP - 1);
-  
+
   /* allocate space for the new offsets */
   newOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t));
   oldOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t));
 
-  for (i = first, j = 0; i < ctx->msgcount; i++)
-  {
+  for (i = first, j = 0; i < ctx->msgcount; i++) {
     /*
      * back up some information which is needed to restore offsets when
      * something fails.
      */
-    
-    oldOffset[i-first].valid  = 1;
-    oldOffset[i-first].hdr    = ctx->hdrs[i]->offset;
-    oldOffset[i-first].body   = ctx->hdrs[i]->content->offset;
-    oldOffset[i-first].lines  = ctx->hdrs[i]->lines;
-    oldOffset[i-first].length = ctx->hdrs[i]->content->length;
-    
-    if (! ctx->hdrs[i]->deleted)
-    {
+
+    oldOffset[i - first].valid = 1;
+    oldOffset[i - first].hdr = ctx->hdrs[i]->offset;
+    oldOffset[i - first].body = ctx->hdrs[i]->content->offset;
+    oldOffset[i - first].lines = ctx->hdrs[i]->lines;
+    oldOffset[i - first].length = ctx->hdrs[i]->content->length;
+
+    if (!ctx->hdrs[i]->deleted) {
       j++;
       if (!ctx->quiet && WriteInc && ((i % WriteInc) == 0 || j == 1))
-       mutt_message (_("Writing messages... %d (%d%%)"), i,
-                     (int)(ftell (ctx->fp) / (ctx->size / 100 + 1)));
-
-      if (ctx->magic == M_MMDF)
-      {
-       if (fputs (MMDF_SEP, fp) == EOF)
-       {
-         mutt_perror (tempfile);
-         mutt_sleep (5);
-         unlink (tempfile);
-         goto bail;
-       }
-         
+        mutt_message (_("Writing messages... %d (%d%%)"), i,
+                      (int) (ftell (ctx->fp) / (ctx->size / 100 + 1)));
+
+      if (ctx->magic == M_MMDF) {
+        if (fputs (MMDF_SEP, fp) == EOF) {
+          mutt_perror (tempfile);
+          mutt_sleep (5);
+          unlink (tempfile);
+          goto bail;
+        }
+
       }
 
       /* save the new offset for this message.  we add `offset' because the
@@ -815,12 +765,13 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
        */
       newOffset[i - first].hdr = ftell (fp) + offset;
 
-      if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1)
-      {
-       mutt_perror (tempfile);
-       mutt_sleep (5);
-       unlink (tempfile);
-       goto bail;
+      if (mutt_copy_message
+          (fp, ctx, ctx->hdrs[i], M_CM_UPDATE,
+           CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1) {
+        mutt_perror (tempfile);
+        mutt_sleep (5);
+        unlink (tempfile);
+        goto bail;
       }
 
       /* Since messages could have been deleted, the offsets stored in memory
@@ -829,36 +780,34 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
        * we just flush the in memory cache so that the message will be reparsed
        * if the user accesses it later.
        */
-      newOffset[i - first].body = ftell (fp) - ctx->hdrs[i]->content->length + offset;
+      newOffset[i - first].body =
+        ftell (fp) - ctx->hdrs[i]->content->length + offset;
       mutt_free_body (&ctx->hdrs[i]->content->parts);
 
-      switch(ctx->magic)
-      {
-       case M_MMDF: 
-         if(fputs(MMDF_SEP, fp) == EOF) 
-         {
-           mutt_perror (tempfile);
-           mutt_sleep (5);
-           unlink (tempfile);
-           goto bail; 
-         }
-         break;
-       default:
-         if(fputs("\n", fp) == EOF) 
-         {
-           mutt_perror (tempfile);
-           mutt_sleep (5);
-           unlink (tempfile);
-           goto bail;
-         }
+      switch (ctx->magic) {
+      case M_MMDF:
+        if (fputs (MMDF_SEP, fp) == EOF) {
+          mutt_perror (tempfile);
+          mutt_sleep (5);
+          unlink (tempfile);
+          goto bail;
+        }
+        break;
+      default:
+        if (fputs ("\n", fp) == EOF) {
+          mutt_perror (tempfile);
+          mutt_sleep (5);
+          unlink (tempfile);
+          goto bail;
+        }
       }
     }
   }
-  
-  if (fclose (fp) != 0)
-  {
+
+  if (fclose (fp) != 0) {
     fp = NULL;
-    dprint(1, (debugfile, "mbox_sync_mailbox: fclose() returned non-zero.\n"));
+    dprint (1,
+            (debugfile, "mbox_sync_mailbox: fclose() returned non-zero.\n"));
     unlink (tempfile);
     mutt_perror (tempfile);
     mutt_sleep (5);
@@ -867,55 +816,53 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   fp = NULL;
 
   /* Save the state of this folder. */
-  if (stat (ctx->path, &statbuf) == -1)
-  {
+  if (stat (ctx->path, &statbuf) == -1) {
     mutt_perror (ctx->path);
     mutt_sleep (5);
     unlink (tempfile);
     goto bail;
   }
 
-  if ((fp = fopen (tempfile, "r")) == NULL)
-  {
+  if ((fp = fopen (tempfile, "r")) == NULL) {
     mutt_unblock_signals ();
     mx_fastclose_mailbox (ctx);
-    dprint (1, (debugfile, "mbox_sync_mailbox: unable to reopen temp copy of mailbox!\n"));
+    dprint (1,
+            (debugfile,
+             "mbox_sync_mailbox: unable to reopen temp copy of mailbox!\n"));
     mutt_perror (tempfile);
     mutt_sleep (5);
     return (-1);
   }
 
-  if (fseek (ctx->fp, offset, SEEK_SET) != 0 ||  /* seek the append location */
+  if (fseek (ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */
       /* do a sanity check to make sure the mailbox looks ok */
       fgets (buf, sizeof (buf), ctx->fp) == NULL ||
       (ctx->magic == M_MBOX && mutt_strncmp ("From ", buf, 5) != 0) ||
-      (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buf) != 0))
-  {
-    dprint (1, (debugfile, "mbox_sync_mailbox: message not in expected position."));
+      (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buf) != 0)) {
+    dprint (1,
+            (debugfile,
+             "mbox_sync_mailbox: message not in expected position."));
     dprint (1, (debugfile, "\tLINE: %s\n", buf));
     i = -1;
   }
-  else
-  {
-    if (fseek (ctx->fp, offset, SEEK_SET) != 0) /* return to proper offset */
-    {
+  else {
+    if (fseek (ctx->fp, offset, SEEK_SET) != 0) {       /* return to proper offset */
       i = -1;
       dprint (1, (debugfile, "mbox_sync_mailbox: fseek() failed\n"));
     }
-    else
-    {
+    else {
       /* copy the temp mailbox back into place starting at the first
        * change/deleted message
        */
       mutt_message _("Committing changes...");
+
       i = mutt_copy_stream (fp, ctx->fp);
 
       if (ferror (ctx->fp))
         i = -1;
     }
-    if (i == 0)
-    {
-      ctx->size = ftell (ctx->fp); /* update the size of the mailbox */
+    if (i == 0) {
+      ctx->size = ftell (ctx->fp);      /* update the size of the mailbox */
       ftruncate (fileno (ctx->fp), ctx->size);
     }
   }
@@ -924,16 +871,16 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   fp = NULL;
   mbox_unlock_mailbox (ctx);
 
-  if (fclose (ctx->fp) != 0 || i == -1)
-  {
+  if (fclose (ctx->fp) != 0 || i == -1) {
     /* error occured while writing the mailbox back, so keep the temp copy
      * around
      */
-    
+
     char savefile[_POSIX_PATH_MAX];
-    
+
     snprintf (savefile, sizeof (savefile), "%s/mutt.%s-%s-%u",
-             NONULL (Tempdir), NONULL(Username), NONULL(Hostname), (unsigned int)getpid ());
+              NONULL (Tempdir), NONULL (Username), NONULL (Hostname),
+              (unsigned int) getpid ());
     rename (tempfile, savefile);
     mutt_unblock_signals ();
     mx_fastclose_mailbox (ctx);
@@ -949,21 +896,19 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   utime (ctx->path, &utimebuf);
 
   /* reopen the mailbox in read-only mode */
-  if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
-  {
+  if ((ctx->fp = fopen (ctx->path, "r")) == NULL) {
     unlink (tempfile);
     mutt_unblock_signals ();
     mx_fastclose_mailbox (ctx);
     mutt_error _("Fatal error!  Could not reopen mailbox!");
+
     Sort = save_sort;
     return (-1);
   }
 
   /* update the offsets of the rewritten messages */
-  for (i = first, j = first; i < ctx->msgcount; i++)
-  {
-    if (!ctx->hdrs[i]->deleted)
-    {
+  for (i = first, j = first; i < ctx->msgcount; i++) {
+    if (!ctx->hdrs[i]->deleted) {
       ctx->hdrs[i]->offset = newOffset[i - first].hdr;
       ctx->hdrs[i]->content->hdr_offset = newOffset[i - first].hdr;
       ctx->hdrs[i]->content->offset = newOffset[i - first].body;
@@ -972,29 +917,27 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   }
   FREE (&newOffset);
   FREE (&oldOffset);
-  unlink (tempfile); /* remove partial copy of the mailbox */
+  unlink (tempfile);            /* remove partial copy of the mailbox */
   mutt_unblock_signals ();
-  Sort = save_sort; /* Restore the default value. */
+  Sort = save_sort;             /* Restore the default value. */
 
-  return (0); /* signal success */
+  return (0);                   /* signal success */
 
-bail:  /* Come here in case of disaster */
+bail:                          /* Come here in case of disaster */
 
   safe_fclose (&fp);
 
   /* restore offsets, as far as they are valid */
-  if (first >= 0 && oldOffset)
-  {
-    for (i = first; i < ctx->msgcount && oldOffset[i-first].valid; i++)
-    {
-      ctx->hdrs[i]->offset = oldOffset[i-first].hdr;
-      ctx->hdrs[i]->content->hdr_offset = oldOffset[i-first].hdr;
-      ctx->hdrs[i]->content->offset = oldOffset[i-first].body;
-      ctx->hdrs[i]->lines = oldOffset[i-first].lines;
-      ctx->hdrs[i]->content->length = oldOffset[i-first].length;
+  if (first >= 0 && oldOffset) {
+    for (i = first; i < ctx->msgcount && oldOffset[i - first].valid; i++) {
+      ctx->hdrs[i]->offset = oldOffset[i - first].hdr;
+      ctx->hdrs[i]->content->hdr_offset = oldOffset[i - first].hdr;
+      ctx->hdrs[i]->content->offset = oldOffset[i - first].body;
+      ctx->hdrs[i]->lines = oldOffset[i - first].lines;
+      ctx->hdrs[i]->content->length = oldOffset[i - first].length;
     }
   }
-  
+
   /* this is ok to call even if we haven't locked anything */
   mbox_unlock_mailbox (ctx);
 
@@ -1002,15 +945,14 @@ bail:  /* Come here in case of disaster */
   FREE (&newOffset);
   FREE (&oldOffset);
 
-  if ((ctx->fp = freopen (ctx->path, "r", ctx->fp)) == NULL)
-  {
+  if ((ctx->fp = freopen (ctx->path, "r", ctx->fp)) == NULL) {
     mutt_error _("Could not reopen mailbox!");
+
     mx_fastclose_mailbox (ctx);
     return (-1);
   }
 
-  if (need_sort || save_sort != Sort)
-  {
+  if (need_sort || save_sort != Sort) {
     Sort = save_sort;
     /* if the mailbox was reopened, the thread tree will be invalid so make
      * sure to start threading from scratch.  */
@@ -1021,7 +963,7 @@ bail:  /* Come here in case of disaster */
 }
 
 /* close a mailbox opened in write-mode */
-int mbox_close_mailbox (CONTEXT *ctx)
+int mbox_close_mailbox (CONTEXT * ctx)
 {
   mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
 
@@ -1035,7 +977,7 @@ int mbox_close_mailbox (CONTEXT *ctx)
   return 0;
 }
 
-int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
+int mutt_reopen_mailbox (CONTEXT * ctx, int *index_hint)
 {
   int (*cmp_headers) (const HEADER *, const HEADER *) = NULL;
   HEADER **old_hdrs;
@@ -1047,12 +989,11 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
 
   /* silent operations */
   ctx->quiet = 1;
-  
+
   mutt_message _("Reopening mailbox...");
-  
+
   /* our heuristics require the old mailbox to be unsorted */
-  if (Sort != SORT_ORDER)
-  {
+  if (Sort != SORT_ORDER) {
     short old_sort;
 
     old_sort = Sort;
@@ -1063,7 +1004,7 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
 
   old_hdrs = NULL;
   old_msgcount = 0;
-  
+
   /* simulate a close */
   if (ctx->id_hash)
     hash_destroy (&ctx->id_hash, NULL);
@@ -1071,21 +1012,19 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
     hash_destroy (&ctx->subj_hash, NULL);
   mutt_clear_threads (ctx);
   FREE (&ctx->v2r);
-  if (ctx->readonly)
-  {
+  if (ctx->readonly) {
     for (i = 0; i < ctx->msgcount; i++)
-      mutt_free_header (&(ctx->hdrs[i])); /* nothing to do! */
+      mutt_free_header (&(ctx->hdrs[i]));       /* nothing to do! */
     FREE (&ctx->hdrs);
   }
-  else
-  {
-      /* save the old headers */
+  else {
+    /* save the old headers */
     old_msgcount = ctx->msgcount;
     old_hdrs = ctx->hdrs;
     ctx->hdrs = NULL;
   }
 
-  ctx->hdrmax = 0;     /* force allocation of new headers */
+  ctx->hdrmax = 0;              /* force allocation of new headers */
   ctx->msgcount = 0;
   ctx->vcount = 0;
   ctx->tagged = 0;
@@ -1097,32 +1036,28 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
   ctx->id_hash = NULL;
   ctx->subj_hash = NULL;
 
-  switch (ctx->magic)
-  {
-    case M_MBOX:
-    case M_MMDF:
-      if (fseek (ctx->fp, 0, SEEK_SET) != 0)
-      {
-        dprint (1, (debugfile, "mutt_reopen_mailbox: fseek() failed\n"));
-        rc = -1;
-      } 
-      else 
-      {
-        cmp_headers = mbox_strict_cmp_headers;
-        if (ctx->magic == M_MBOX)
-          rc = mbox_parse_mailbox(ctx);
-        else
-          rc = mmdf_parse_mailbox(ctx);
-      }
-      break;
-
-    default:
+  switch (ctx->magic) {
+  case M_MBOX:
+  case M_MMDF:
+    if (fseek (ctx->fp, 0, SEEK_SET) != 0) {
+      dprint (1, (debugfile, "mutt_reopen_mailbox: fseek() failed\n"));
       rc = -1;
-      break;
+    }
+    else {
+      cmp_headers = mbox_strict_cmp_headers;
+      if (ctx->magic == M_MBOX)
+        rc = mbox_parse_mailbox (ctx);
+      else
+        rc = mmdf_parse_mailbox (ctx);
+    }
+    break;
+
+  default:
+    rc = -1;
+    break;
   }
-  
-  if (rc == -1)
-  {
+
+  if (rc == -1) {
     /* free the old headers */
     for (j = 0; j < old_msgcount; j++)
       mutt_free_header (&(old_hdrs[j]));
@@ -1136,10 +1071,8 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
 
   index_hint_set = (index_hint == NULL);
 
-  if (!ctx->readonly)
-  {
-    for (i = 0; i < ctx->msgcount; i++)
-    {
+  if (!ctx->readonly) {
+    for (i = 0; i < ctx->msgcount; i++) {
       int found = 0;
 
       /* some messages have been deleted, and new  messages have been
@@ -1147,62 +1080,53 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
        * "advanced" towards the beginning of the folder, so we begin the
        * search at index "i"
        */
-      for (j = i; j < old_msgcount; j++)
-      {
-       if (old_hdrs[j] == NULL)
-         continue;
-       if (cmp_headers (ctx->hdrs[i], old_hdrs[j]))
-       {
-         found = 1;
-         break;
-       }
+      for (j = i; j < old_msgcount; j++) {
+        if (old_hdrs[j] == NULL)
+          continue;
+        if (cmp_headers (ctx->hdrs[i], old_hdrs[j])) {
+          found = 1;
+          break;
+        }
       }
-      if (!found)
-      {
-       for (j = 0; j < i && j < old_msgcount; j++)
-       {
-         if (old_hdrs[j] == NULL)
-           continue;
-         if (cmp_headers (ctx->hdrs[i], old_hdrs[j]))
-         {
-           found = 1;
-           break;
-         }
-       }
+      if (!found) {
+        for (j = 0; j < i && j < old_msgcount; j++) {
+          if (old_hdrs[j] == NULL)
+            continue;
+          if (cmp_headers (ctx->hdrs[i], old_hdrs[j])) {
+            found = 1;
+            break;
+          }
+        }
       }
 
-      if (found)
-      {
-       /* this is best done here */
-       if (!index_hint_set && *index_hint == j)
-         *index_hint = i;
-
-       if (old_hdrs[j]->changed)
-       {
-         /* Only update the flags if the old header was changed;
-          * otherwise, the header may have been modified externally,
-          * and we don't want to lose _those_ changes
-          */
-         mutt_set_flag (ctx, ctx->hdrs[i], M_FLAG, old_hdrs[j]->flagged);
-         mutt_set_flag (ctx, ctx->hdrs[i], M_REPLIED, old_hdrs[j]->replied);
-         mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, old_hdrs[j]->old);
-         mutt_set_flag (ctx, ctx->hdrs[i], M_READ, old_hdrs[j]->read);
-       }
-       mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, old_hdrs[j]->deleted);
-       mutt_set_flag (ctx, ctx->hdrs[i], M_TAG, old_hdrs[j]->tagged);
-
-       /* we don't need this header any more */
-       mutt_free_header (&(old_hdrs[j]));
+      if (found) {
+        /* this is best done here */
+        if (!index_hint_set && *index_hint == j)
+          *index_hint = i;
+
+        if (old_hdrs[j]->changed) {
+          /* Only update the flags if the old header was changed;
+           * otherwise, the header may have been modified externally,
+           * and we don't want to lose _those_ changes
+           */
+          mutt_set_flag (ctx, ctx->hdrs[i], M_FLAG, old_hdrs[j]->flagged);
+          mutt_set_flag (ctx, ctx->hdrs[i], M_REPLIED, old_hdrs[j]->replied);
+          mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, old_hdrs[j]->old);
+          mutt_set_flag (ctx, ctx->hdrs[i], M_READ, old_hdrs[j]->read);
+        }
+        mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, old_hdrs[j]->deleted);
+        mutt_set_flag (ctx, ctx->hdrs[i], M_TAG, old_hdrs[j]->tagged);
+
+        /* we don't need this header any more */
+        mutt_free_header (&(old_hdrs[j]));
       }
     }
 
     /* free the remaining old headers */
-    for (j = 0; j < old_msgcount; j++)
-    {
-      if (old_hdrs[j])
-      {
-       mutt_free_header (&(old_hdrs[j]));
-       msg_mod = 1;
+    for (j = 0; j < old_msgcount; j++) {
+      if (old_hdrs[j]) {
+        mutt_free_header (&(old_hdrs[j]));
+        msg_mod = 1;
       }
     }
     FREE (&old_hdrs);
diff --git a/mbyte.c b/mbyte.c
index 77df1fd..4750581 100644 (file)
--- a/mbyte.c
+++ b/mbyte.c
 #endif
 
 int Charset_is_utf8 = 0;
+
 #ifndef HAVE_WC_FUNCS
 static int charset_is_ja = 0;
-static iconv_t charset_to_utf8 = (iconv_t)(-1);
-static iconv_t charset_from_utf8 = (iconv_t)(-1);
+static iconv_t charset_to_utf8 = (iconv_t) (-1);
+static iconv_t charset_from_utf8 = (iconv_t) (-1);
 #endif
 
 void mutt_set_charset (char *charset)
@@ -52,24 +53,23 @@ void mutt_set_charset (char *charset)
   Charset_is_utf8 = 0;
 #ifndef HAVE_WC_FUNCS
   charset_is_ja = 0;
-  if (charset_to_utf8 != (iconv_t)(-1))
-  {
+  if (charset_to_utf8 != (iconv_t) (-1)) {
     iconv_close (charset_to_utf8);
-    charset_to_utf8 = (iconv_t)(-1);
+    charset_to_utf8 = (iconv_t) (-1);
   }
-  if (charset_from_utf8 != (iconv_t)(-1))
-  {
+  if (charset_from_utf8 != (iconv_t) (-1)) {
     iconv_close (charset_from_utf8);
-    charset_from_utf8 = (iconv_t)(-1);
+    charset_from_utf8 = (iconv_t) (-1);
   }
 #endif
 
-  if (!strcmp(buffer, "utf-8"))
+  if (!strcmp (buffer, "utf-8"))
     Charset_is_utf8 = 1;
 #ifndef HAVE_WC_FUNCS
-  else if (!ascii_strcasecmp(buffer, "euc-jp") || !ascii_strcasecmp(buffer, "shift_jis")
-       || !ascii_strcasecmp(buffer, "cp932") || !ascii_strcasecmp(buffer, "eucJP-ms"))
-  {
+  else if (!ascii_strcasecmp (buffer, "euc-jp")
+           || !ascii_strcasecmp (buffer, "shift_jis")
+           || !ascii_strcasecmp (buffer, "cp932")
+           || !ascii_strcasecmp (buffer, "eucJP-ms")) {
     charset_is_ja = 1;
     charset_to_utf8 = iconv_open ("UTF-8", charset);
     charset_from_utf8 = iconv_open (charset, "UTF-8");
@@ -77,7 +77,7 @@ void mutt_set_charset (char *charset)
 #endif
 
 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
-  bind_textdomain_codeset(PACKAGE, buffer);
+  bind_textdomain_codeset (PACKAGE, buffer);
 #endif
 }
 
@@ -102,18 +102,16 @@ static size_t wcrtomb_iconv (char *s, wchar_t wc, iconv_t cd)
   char *ob;
   size_t ibl, obl, r;
 
-  if (s)
-  {
+  if (s) {
     ibl = mutt_wctoutf8 (buf, wc);
-    if (ibl == (size_t)(-1))
-      return (size_t)(-1);
+    if (ibl == (size_t) (-1))
+      return (size_t) (-1);
     ib = buf;
     ob = s;
     obl = MB_LEN_MAX;
     r = iconv (cd, &ib, &ibl, &ob, &obl);
   }
-  else
-  {
+  else {
     ib = "";
     ibl = 1;
     ob = buf;
@@ -123,30 +121,28 @@ static size_t wcrtomb_iconv (char *s, wchar_t wc, iconv_t cd)
   return ob - s;
 }
 
-size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+size_t wcrtomb (char *s, wchar_t wc, mbstate_t * ps)
 {
   /* We only handle stateless encodings, so we can ignore ps. */
 
   if (Charset_is_utf8)
     return mutt_wctoutf8 (s, wc);
-  else if (charset_from_utf8 != (iconv_t)(-1))
+  else if (charset_from_utf8 != (iconv_t) (-1))
     return wcrtomb_iconv (s, wc, charset_from_utf8);
-  else
-  {
+  else {
     if (!s)
       return 1;
-    if (wc < 0x100)
-    {
+    if (wc < 0x100) {
       *s = wc;
       return 1;
     }
     errno = EILSEQ;
-    return (size_t)(-1);
+    return (size_t) (-1);
   }
 }
 
-size_t mbrtowc_iconv (wchar_t *pwc, const char *s, size_t n,
-                     mbstate_t *ps, iconv_t cd)
+size_t mbrtowc_iconv (wchar_t * pwc, const char *s, size_t n,
+                      mbstate_t * ps, iconv_t cd)
 {
   static mbstate_t mbstate;
   ICONV_CONST char *ib, *ibmax;
@@ -155,22 +151,20 @@ size_t mbrtowc_iconv (wchar_t *pwc, const char *s, size_t n,
   char bufi[8], bufo[6];
 
   if (!n)
-    return (size_t)(-2);
+    return (size_t) (-2);
 
   t = memchr (ps, 0, sizeof (*ps));
-  k = t ? (t - (char *)ps) : sizeof (*ps);
+  k = t ? (t - (char *) ps) : sizeof (*ps);
   if (k > sizeof (bufi))
     k = 0;
-  if (k)
-  {
+  if (k) {
     /* use the buffer for input */
     memcpy (bufi, ps, k);
     ib = bufi;
     ibmax = bufi + (k + n < sizeof (bufi) ? k + n : sizeof (bufi));
     memcpy (bufi + k, s, ibmax - bufi - k);
   }
-  else
-  {
+  else {
     /* use the real input */
     ib = s;
     ibmax = s + n;
@@ -180,48 +174,42 @@ size_t mbrtowc_iconv (wchar_t *pwc, const char *s, size_t n,
   obl = sizeof (bufo);
   ibl = 1;
 
-  for (;;)
-  {
+  for (;;) {
     r = iconv (cd, &ib, &ibl, &ob, &obl);
-    if (ob > bufo && (!k || ib > bufi + k))
-    {
+    if (ob > bufo && (!k || ib > bufi + k)) {
       /* we have a character */
       memset (ps, 0, sizeof (*ps));
       utf8rtowc (pwc, bufo, ob - bufo, &mbstate);
       return (pwc && *pwc) ? (ib - (k ? bufi + k : s)) : 0;
     }
-    else if (!r || (r == (size_t)(-1) && errno == EINVAL))
-    {
+    else if (!r || (r == (size_t) (-1) && errno == EINVAL)) {
       if (ib + ibl < ibmax)
-       /* try using more input */
-       ++ibl;
-      else if (k && ib > bufi + k && bufi + k + n > ibmax)
-      {
-       /* switch to using real input */
-       ib = s + (ib - bufi - k);
-       ibmax = s + n;
-       k = 0;
-       ++ibl;
+        /* try using more input */
+        ++ibl;
+      else if (k && ib > bufi + k && bufi + k + n > ibmax) {
+        /* switch to using real input */
+        ib = s + (ib - bufi - k);
+        ibmax = s + n;
+        k = 0;
+        ++ibl;
       }
-      else
-      {
-       /* save the state and give up */
-       memset (ps, 0, sizeof (*ps));
-       if (ibl <= sizeof (mbstate_t)) /* need extra condition here! */
-         memcpy (ps, ib, ibl);
-       return (size_t)(-2);
+      else {
+        /* save the state and give up */
+        memset (ps, 0, sizeof (*ps));
+        if (ibl <= sizeof (mbstate_t))  /* need extra condition here! */
+          memcpy (ps, ib, ibl);
+        return (size_t) (-2);
       }
     }
-    else
-    {
+    else {
       /* bad input */
       errno = EILSEQ;
-      return (size_t)(-1);
+      return (size_t) (-1);
     }
   }
 }
 
-size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+size_t mbrtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * ps)
 {
   static mbstate_t mbstate;
 
@@ -230,19 +218,17 @@ size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 
   if (Charset_is_utf8)
     return utf8rtowc (pwc, s, n, ps);
-  else if (charset_to_utf8 != (iconv_t)(-1))
+  else if (charset_to_utf8 != (iconv_t) (-1))
     return mbrtowc_iconv (pwc, s, n, ps, charset_to_utf8);
-  else
-  {
-    if (!s)
-    {
-      memset(ps, 0, sizeof(*ps));
+  else {
+    if (!s) {
+      memset (ps, 0, sizeof (*ps));
       return 0;
     }
     if (!n)
-      return (size_t)-2;
+      return (size_t) - 2;
     if (pwc)
-      *pwc = (wchar_t)(unsigned char)*s;
+      *pwc = (wchar_t) (unsigned char) *s;
     return (*s != 0);
   }
 }
@@ -338,48 +324,46 @@ int iswalnum (wint_t wc)
 int wcwidth_ja (wchar_t ucs)
 {
   if (ucs >= 0x3021)
-    return -1; /* continue with the normal check */
+    return -1;                  /* continue with the normal check */
   /* a rough range for quick check */
-  if ((ucs >= 0x00a1 && ucs <= 0x00fe) || /* Latin-1 Supplement */
-      (ucs >= 0x0391 && ucs <= 0x0451) || /* Greek and Cyrillic */
-      (ucs >= 0x2010 && ucs <= 0x266f) || /* Symbols */
-      (ucs >= 0x3000 && ucs <= 0x3020))   /* CJK Symbols and Punctuation */
+  if ((ucs >= 0x00a1 && ucs <= 0x00fe) ||       /* Latin-1 Supplement */
+      (ucs >= 0x0391 && ucs <= 0x0451) ||       /* Greek and Cyrillic */
+      (ucs >= 0x2010 && ucs <= 0x266f) ||       /* Symbols */
+      (ucs >= 0x3000 && ucs <= 0x3020)) /* CJK Symbols and Punctuation */
     return 2;
   else
     return -1;
 }
 
-int wcwidth_ucs(wchar_t ucs);
+int wcwidth_ucs (wchar_t ucs);
 
 int wcwidth (wchar_t wc)
 {
-  if (!Charset_is_utf8)
-  {
-    if (!charset_is_ja)
-    {
+  if (!Charset_is_utf8) {
+    if (!charset_is_ja) {
       /* 8-bit case */
       if (!wc)
-       return 0;
+        return 0;
       else if ((0 <= wc && wc < 256) && IsPrint (wc))
-       return 1;
+        return 1;
       else
-       return -1;
+        return -1;
     }
-    else
-    {
+    else {
       /* Japanese */
       int k = wcwidth_ja (wc);
+
       if (k != -1)
-       return k;
+        return k;
     }
   }
   return wcwidth_ucs (wc);
 }
 
-size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps)
+size_t utf8rtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * _ps)
 {
   static wchar_t mbstate;
-  wchar_t *ps = (wchar_t *)_ps;
+  wchar_t *ps = (wchar_t *) _ps;
   size_t k = 1;
   unsigned char c;
   wchar_t wc;
@@ -388,27 +372,23 @@ size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps)
   if (!ps)
     ps = &mbstate;
 
-  if (!s)
-  {
+  if (!s) {
     *ps = 0;
     return 0;
   }
   if (!n)
-    return (size_t)-2;
+    return (size_t) - 2;
 
-  if (!*ps)
-  {
-    c = (unsigned char)*s;
-    if (c < 0x80)
-    {
+  if (!*ps) {
+    c = (unsigned char) *s;
+    if (c < 0x80) {
       if (pwc)
-       *pwc = c;
+        *pwc = c;
       return (c != 0);
     }
-    else if (c < 0xc2)
-    {
+    else if (c < 0xc2) {
       errno = EILSEQ;
-      return (size_t)-1;
+      return (size_t) - 1;
     }
     else if (c < 0xe0)
       wc = ((c & 0x1f) << 6) + (count = 0);
@@ -420,47 +400,40 @@ size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps)
       wc = ((c & 0x03) << 24) + (count = 3);
     else if (c < 0xfe)
       wc = ((c & 0x01) << 30) + (count = 4);
-    else
-    {
+    else {
       errno = EILSEQ;
-      return (size_t)-1;
+      return (size_t) - 1;
     }
     ++s, --n, ++k;
   }
-  else
-  {
+  else {
     wc = *ps & 0x7fffffff;
-    count = wc & 7; /* if count > 4 it will be caught below */
+    count = wc & 7;             /* if count > 4 it will be caught below */
   }
 
-  for (; n; ++s, --n, ++k)
-  {
-    c = (unsigned char)*s;
-    if (0x80 <= c && c < 0xc0)
-    {
+  for (; n; ++s, --n, ++k) {
+    c = (unsigned char) *s;
+    if (0x80 <= c && c < 0xc0) {
       wc |= (c & 0x3f) << (6 * count);
-      if (!count)
-      {
-       if (pwc)
-         *pwc = wc;
-       *ps = 0;
-       return wc ? k : 0;
+      if (!count) {
+        if (pwc)
+          *pwc = wc;
+        *ps = 0;
+        return wc ? k : 0;
       }
       --count, --wc;
-      if (!(wc >> (11+count*5)))
-      {
-       errno = count < 4 ? EILSEQ : EINVAL;
-       return (size_t)-1;
+      if (!(wc >> (11 + count * 5))) {
+        errno = count < 4 ? EILSEQ : EINVAL;
+        return (size_t) - 1;
       }
     }
-    else
-    {
+    else {
       errno = EILSEQ;
-      return (size_t)-1;
+      return (size_t) - 1;
     }
   }
   *ps = wc;
-  return (size_t)-2;
+  return (size_t) - 2;
 }
 
 #endif /* !HAVE_WC_FUNCS */
diff --git a/mbyte.h b/mbyte.h
index 3eeed04..72180fc 100644 (file)
--- a/mbyte.h
+++ b/mbyte.h
@@ -13,8 +13,8 @@
 # endif
 
 #ifndef HAVE_WC_FUNCS
-size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
-size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+size_t wcrtomb (char *s, wchar_t wc, mbstate_t * ps);
+size_t mbrtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * ps);
 int iswprint (wint_t wc);
 int iswspace (wint_t wc);
 int iswalnum (wint_t wc);
@@ -26,7 +26,7 @@ int wcwidth (wchar_t wc);
 
 void mutt_set_charset (char *charset);
 extern int Charset_is_utf8;
-size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps);
+size_t utf8rtowc (wchar_t * pwc, const char *s, size_t n, mbstate_t * _ps);
 wchar_t replacement_char (void);
 
 #endif /* _MBYTE_H */
diff --git a/md5.h b/md5.h
index 521f3f5..b6aa699 100644 (file)
--- a/md5.h
+++ b/md5.h
@@ -30,13 +30,13 @@ documentation and/or software.
 
 /* MD5 context. */
 typedef struct {
-  uint32_t state[4];                                   /* state (ABCD) */
-  uint32_t count[2];        /* number of bits, modulo 2^64 (lsb first) */
-  unsigned char buffer[64];                         /* input buffer */
+  uint32_t state[4];            /* state (ABCD) */
+  uint32_t count[2];            /* number of bits, modulo 2^64 (lsb first) */
+  unsigned char buffer[64];     /* input buffer */
 } MD5_CTX;
 
 void MD5Init (MD5_CTX *);
 void MD5Update (MD5_CTX *, unsigned char *, unsigned int);
-void MD5Final (unsigned char [16], MD5_CTX *);
+void MD5Final (unsigned char[16], MD5_CTX *);
 
 #endif
diff --git a/md5c.c b/md5c.c
index be22860..02f4661 100644 (file)
--- a/md5c.c
+++ b/md5c.c
@@ -49,7 +49,7 @@ documentation and/or software.
 #define S43 15
 #define S44 21
 
-static void MD5Transform (uint32_t [4], unsigned char [64]);
+static void MD5Transform (uint32_t[4], unsigned char[64]);
 static void Encode (unsigned char *, uint32_t *, unsigned int);
 static void Decode (uint32_t *, unsigned char *, unsigned int);
 static void MD5_memcpy (POINTER, POINTER, unsigned int);
@@ -99,11 +99,11 @@ Rotation is separate from addition to prevent recomputation.
 /* MD5 initialization. Begins an MD5 operation, writing a new context.
  */
 void MD5Init (context)
-MD5_CTX *context;                                        /* context */
+     MD5_CTX *context;          /* context */
 {
   context->count[0] = context->count[1] = 0;
   /* Load magic initialization constants.
-*/
+   */
   context->state[0] = 0x67452301;
   context->state[1] = 0xefcdab89;
   context->state[2] = 0x98badcfe;
@@ -115,50 +115,48 @@ MD5_CTX *context;                                        /* context */
   context.
  */
 void MD5Update (context, input, inputLen)
-MD5_CTX *context;                                        /* context */
-unsigned char *input;                                /* input block */
-unsigned int inputLen;                     /* length of input block */
+     MD5_CTX *context;          /* context */
+     unsigned char *input;      /* input block */
+     unsigned int inputLen;     /* length of input block */
 {
   unsigned int i, index, partLen;
 
   /* Compute number of bytes mod 64 */
-  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+  index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
   /* Update number of bits */
-  if ((context->count[0] += ((uint32_t)inputLen << 3))
-   < ((uint32_t)inputLen << 3))
- context->count[1]++;
-  context->count[1] += ((uint32_t)inputLen >> 29);
+  if ((context->count[0] += ((uint32_t) inputLen << 3))
+      < ((uint32_t) inputLen << 3))
   context->count[1]++;
+  context->count[1] += ((uint32_t) inputLen >> 29);
 
   partLen = 64 - index;
 
   /* Transform as many times as possible.
-*/
+   */
   if (inputLen >= partLen) {
- MD5_memcpy
-   ((POINTER)&context->buffer[index], (POINTER)input, partLen);
- MD5Transform (context->state, context->buffer);
+    MD5_memcpy ((POINTER) & context->buffer[index], (POINTER) input, partLen);
+    MD5Transform (context->state, context->buffer);
 
- for (i = partLen; i + 63 < inputLen; i += 64)
-   MD5Transform (context->state, &input[i]);
   for (i = partLen; i + 63 < inputLen; i += 64)
+      MD5Transform (context->state, &input[i]);
 
- index = 0;
   index = 0;
   }
   else
- i = 0;
   i = 0;
 
   /* Buffer remaining input */
   MD5_memcpy
- ((POINTER)&context->buffer[index], (POINTER)&input[i],
-  inputLen-i);
+    ((POINTER) & context->buffer[index], (POINTER) & input[i], inputLen - i);
 }
 
 /* MD5 finalization. Ends an MD5 message-digest operation, writing the
   the message digest and zeroizing the context.
  */
 void MD5Final (digest, context)
-unsigned char digest[16];                         /* message digest */
-MD5_CTX *context;                                       /* context */
+     unsigned char digest[16];  /* message digest */
+     MD5_CTX *context;          /* context */
 {
   unsigned char bits[8];
   unsigned int index, padLen;
@@ -167,8 +165,8 @@ MD5_CTX *context;                                       /* context */
   Encode (bits, context->count, 8);
 
   /* Pad out to 56 mod 64.
-*/
-  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+   */
+  index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
   padLen = (index < 56) ? (56 - index) : (120 - index);
   MD5Update (context, PADDING, padLen);
 
@@ -178,91 +176,91 @@ MD5_CTX *context;                                       /* context */
   Encode (digest, context->state, 16);
 
   /* Zeroize sensitive information.
-*/
-  MD5_memset ((POINTER)context, 0, sizeof (*context));
+   */
+  MD5_memset ((POINTER) context, 0, sizeof (*context));
 }
 
 /* MD5 basic transformation. Transforms state based on block.
  */
 static void MD5Transform (state, block)
-uint32_t state[4];
-unsigned char block[64];
+     uint32_t state[4];
+     unsigned char block[64];
 {
   uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
 
   Decode (x, block, 64);
 
   /* Round 1 */
-  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
-  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
-  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
-  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
-  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
-  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
-  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
-  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
-  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
-  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
-  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
-  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
-  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
-  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
-  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
-  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
-  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
-  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
-  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
-  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
-  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
-  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
-  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
-  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
-  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
-  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
-  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
-  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
-  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
-  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
-  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
-  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+  FF (a, b, c, d, x[0], S11, 0xd76aa478);       /* 1 */
+  FF (d, a, b, c, x[1], S12, 0xe8c7b756);       /* 2 */
+  FF (c, d, a, b, x[2], S13, 0x242070db);       /* 3 */
+  FF (b, c, d, a, x[3], S14, 0xc1bdceee);       /* 4 */
+  FF (a, b, c, d, x[4], S11, 0xf57c0faf);       /* 5 */
+  FF (d, a, b, c, x[5], S12, 0x4787c62a);       /* 6 */
+  FF (c, d, a, b, x[6], S13, 0xa8304613);       /* 7 */
+  FF (b, c, d, a, x[7], S14, 0xfd469501);       /* 8 */
+  FF (a, b, c, d, x[8], S11, 0x698098d8);       /* 9 */
+  FF (d, a, b, c, x[9], S12, 0x8b44f7af);       /* 10 */
+  FF (c, d, a, b, x[10], S13, 0xffff5bb1);      /* 11 */
+  FF (b, c, d, a, x[11], S14, 0x895cd7be);      /* 12 */
+  FF (a, b, c, d, x[12], S11, 0x6b901122);      /* 13 */
+  FF (d, a, b, c, x[13], S12, 0xfd987193);      /* 14 */
+  FF (c, d, a, b, x[14], S13, 0xa679438e);      /* 15 */
+  FF (b, c, d, a, x[15], S14, 0x49b40821);      /* 16 */
+
 /* Round 2 */
+  GG (a, b, c, d, x[1], S21, 0xf61e2562);       /* 17 */
+  GG (d, a, b, c, x[6], S22, 0xc040b340);       /* 18 */
+  GG (c, d, a, b, x[11], S23, 0x265e5a51);      /* 19 */
+  GG (b, c, d, a, x[0], S24, 0xe9b6c7aa);       /* 20 */
+  GG (a, b, c, d, x[5], S21, 0xd62f105d);       /* 21 */
+  GG (d, a, b, c, x[10], S22, 0x2441453);       /* 22 */
+  GG (c, d, a, b, x[15], S23, 0xd8a1e681);      /* 23 */
+  GG (b, c, d, a, x[4], S24, 0xe7d3fbc8);       /* 24 */
+  GG (a, b, c, d, x[9], S21, 0x21e1cde6);       /* 25 */
+  GG (d, a, b, c, x[14], S22, 0xc33707d6);      /* 26 */
+  GG (c, d, a, b, x[3], S23, 0xf4d50d87);       /* 27 */
+  GG (b, c, d, a, x[8], S24, 0x455a14ed);       /* 28 */
+  GG (a, b, c, d, x[13], S21, 0xa9e3e905);      /* 29 */
+  GG (d, a, b, c, x[2], S22, 0xfcefa3f8);       /* 30 */
+  GG (c, d, a, b, x[7], S23, 0x676f02d9);       /* 31 */
+  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a);      /* 32 */
 
   /* Round 3 */
-  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
-  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
-  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
-  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
-  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
-  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
-  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
-  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
-  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
-  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
-  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
-  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
-  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
-  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
-  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
-  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+  HH (a, b, c, d, x[5], S31, 0xfffa3942);       /* 33 */
+  HH (d, a, b, c, x[8], S32, 0x8771f681);       /* 34 */
+  HH (c, d, a, b, x[11], S33, 0x6d9d6122);      /* 35 */
+  HH (b, c, d, a, x[14], S34, 0xfde5380c);      /* 36 */
+  HH (a, b, c, d, x[1], S31, 0xa4beea44);       /* 37 */
+  HH (d, a, b, c, x[4], S32, 0x4bdecfa9);       /* 38 */
+  HH (c, d, a, b, x[7], S33, 0xf6bb4b60);       /* 39 */
+  HH (b, c, d, a, x[10], S34, 0xbebfbc70);      /* 40 */
+  HH (a, b, c, d, x[13], S31, 0x289b7ec6);      /* 41 */
+  HH (d, a, b, c, x[0], S32, 0xeaa127fa);       /* 42 */
+  HH (c, d, a, b, x[3], S33, 0xd4ef3085);       /* 43 */
+  HH (b, c, d, a, x[6], S34, 0x4881d05);        /* 44 */
+  HH (a, b, c, d, x[9], S31, 0xd9d4d039);       /* 45 */
+  HH (d, a, b, c, x[12], S32, 0xe6db99e5);      /* 46 */
+  HH (c, d, a, b, x[15], S33, 0x1fa27cf8);      /* 47 */
+  HH (b, c, d, a, x[2], S34, 0xc4ac5665);       /* 48 */
 
   /* Round 4 */
-  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
-  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
-  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
-  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
-  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
-  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
-  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
-  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
-  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
-  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
-  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
-  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
-  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
-  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
-  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
-  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+  II (a, b, c, d, x[0], S41, 0xf4292244);       /* 49 */
+  II (d, a, b, c, x[7], S42, 0x432aff97);       /* 50 */
+  II (c, d, a, b, x[14], S43, 0xab9423a7);      /* 51 */
+  II (b, c, d, a, x[5], S44, 0xfc93a039);       /* 52 */
+  II (a, b, c, d, x[12], S41, 0x655b59c3);      /* 53 */
+  II (d, a, b, c, x[3], S42, 0x8f0ccc92);       /* 54 */
+  II (c, d, a, b, x[10], S43, 0xffeff47d);      /* 55 */
+  II (b, c, d, a, x[1], S44, 0x85845dd1);       /* 56 */
+  II (a, b, c, d, x[8], S41, 0x6fa87e4f);       /* 57 */
+  II (d, a, b, c, x[15], S42, 0xfe2ce6e0);      /* 58 */
+  II (c, d, a, b, x[6], S43, 0xa3014314);       /* 59 */
+  II (b, c, d, a, x[13], S44, 0x4e0811a1);      /* 60 */
+  II (a, b, c, d, x[4], S41, 0xf7537e82);       /* 61 */
+  II (d, a, b, c, x[11], S42, 0xbd3af235);      /* 62 */
+  II (c, d, a, b, x[2], S43, 0x2ad7d2bb);       /* 63 */
+  II (b, c, d, a, x[9], S44, 0xeb86d391);       /* 64 */
 
   state[0] += a;
   state[1] += b;
@@ -270,24 +268,24 @@ unsigned char block[64];
   state[3] += d;
 
   /* Zeroize sensitive information. */
-  MD5_memset ((POINTER)x, 0, sizeof (x));
+  MD5_memset ((POINTER) x, 0, sizeof (x));
 }
 
 /* Encodes input (uint32_t) into output (unsigned char). Assumes len is
   a multiple of 4.
  */
 static void Encode (output, input, len)
-unsigned char *output;
-uint32_t *input;
-unsigned int len;
+     unsigned char *output;
+     uint32_t *input;
+     unsigned int len;
 {
   unsigned int i, j;
 
   for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
   output[j] = (unsigned char) (input[i] & 0xff);
   output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
   output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
   output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
   }
 }
 
@@ -295,40 +293,40 @@ unsigned int len;
   a multiple of 4.
  */
 static void Decode (output, input, len)
-uint32_t *output;
-unsigned char *input;
-unsigned int len;
+     uint32_t *output;
+     unsigned char *input;
+     unsigned int len;
 {
   unsigned int i, j;
 
   for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
-   (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
   output[i] = ((uint32_t) input[j]) | (((uint32_t) input[j + 1]) << 8) |
+      (((uint32_t) input[j + 2]) << 16) | (((uint32_t) input[j + 3]) << 24);
 }
 
 /* Note: Replace "for loop" with standard memcpy if possible.
  */
 
 static void MD5_memcpy (output, input, len)
-POINTER output;
-POINTER input;
-unsigned int len;
+     POINTER output;
+     POINTER input;
+     unsigned int len;
 {
   unsigned int i;
 
   for (i = 0; i < len; i++)
-  output[i] = input[i];
+    output[i] = input[i];
 }
 
 /* Note: Replace "for loop" with standard memset if possible.
  */
 static void MD5_memset (output, value, len)
-POINTER output;
-int value;
-unsigned int len;
+     POINTER output;
+     int value;
+     unsigned int len;
 {
   unsigned int i;
 
   for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
   ((char *) output)[i] = (char) value;
 }
diff --git a/menu.c b/menu.c
index 8ff8ace..0a35299 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -33,7 +33,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-extern int Charset_is_utf8; /* FIXME: bad modularisation */
+extern int Charset_is_utf8;     /* FIXME: bad modularisation */
 
 extern size_t UngetCount;
 
@@ -41,115 +41,110 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color)
 {
   wchar_t wc;
   size_t k;
-  size_t n = mutt_strlen ((char *)s);
+  size_t n = mutt_strlen ((char *) s);
   mbstate_t mbstate;
 
   memset (&mbstate, 0, sizeof (mbstate));
-  while (*s)
-  {
-    if (*s < M_TREE_MAX)
-    {
+  while (*s) {
+    if (*s < M_TREE_MAX) {
       if (do_color)
         SETCOLOR (MT_COLOR_TREE);
-      while (*s && *s < M_TREE_MAX)
-      {
-        switch (*s)
-        {
-          case M_TREE_LLCORNER:
-            if (option (OPTASCIICHARS))
-              addch ('`');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\224"); /* WACS_LLCORNER */
-            else
-              addch (ACS_LLCORNER);
-            break;
-          case M_TREE_ULCORNER:
-            if (option (OPTASCIICHARS))
-              addch (',');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\214"); /* WACS_ULCORNER */
-            else
-              addch (ACS_ULCORNER);
-            break;
-          case M_TREE_LTEE:
-            if (option (OPTASCIICHARS))
-              addch ('|');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\234"); /* WACS_LTEE */
-            else
-              addch (ACS_LTEE);
-            break;
-          case M_TREE_HLINE:
-            if (option (OPTASCIICHARS))
-              addch ('-');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\200"); /* WACS_HLINE */
-            else
-              addch (ACS_HLINE);
-            break;
-          case M_TREE_VLINE:
-            if (option (OPTASCIICHARS))
-              addch ('|');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\202"); /* WACS_VLINE */
-            else
-              addch (ACS_VLINE);
-            break;
-          case M_TREE_TTEE:
-            if (option (OPTASCIICHARS))
-              addch ('-');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\254"); /* WACS_TTEE */
-            else
-              addch (ACS_TTEE);
-            break;
-          case M_TREE_BTEE:
-            if (option (OPTASCIICHARS))
-              addch ('-');
-            else if (Charset_is_utf8)
-              addstr ("\342\224\264"); /* WACS_BTEE */
-            else
-              addch (ACS_BTEE);
-            break;
-          case M_TREE_SPACE:
-            addch (' ');
-            break;
-          case M_TREE_RARROW:
-            addch ('>');
-            break;
-          case M_TREE_STAR:
-            addch ('*'); /* fake thread indicator */
-            break;
-          case M_TREE_HIDDEN:
-            addch ('&');
-            break;
-          case M_TREE_EQUALS:
-            addch ('=');
-            break;
-          case M_TREE_MISSING:
-            addch ('?');
-            break;
+      while (*s && *s < M_TREE_MAX) {
+        switch (*s) {
+        case M_TREE_LLCORNER:
+          if (option (OPTASCIICHARS))
+            addch ('`');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\224");    /* WACS_LLCORNER */
+          else
+            addch (ACS_LLCORNER);
+          break;
+        case M_TREE_ULCORNER:
+          if (option (OPTASCIICHARS))
+            addch (',');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\214");    /* WACS_ULCORNER */
+          else
+            addch (ACS_ULCORNER);
+          break;
+        case M_TREE_LTEE:
+          if (option (OPTASCIICHARS))
+            addch ('|');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\234");    /* WACS_LTEE */
+          else
+            addch (ACS_LTEE);
+          break;
+        case M_TREE_HLINE:
+          if (option (OPTASCIICHARS))
+            addch ('-');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\200");    /* WACS_HLINE */
+          else
+            addch (ACS_HLINE);
+          break;
+        case M_TREE_VLINE:
+          if (option (OPTASCIICHARS))
+            addch ('|');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\202");    /* WACS_VLINE */
+          else
+            addch (ACS_VLINE);
+          break;
+        case M_TREE_TTEE:
+          if (option (OPTASCIICHARS))
+            addch ('-');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\254");    /* WACS_TTEE */
+          else
+            addch (ACS_TTEE);
+          break;
+        case M_TREE_BTEE:
+          if (option (OPTASCIICHARS))
+            addch ('-');
+          else if (Charset_is_utf8)
+            addstr ("\342\224\264");    /* WACS_BTEE */
+          else
+            addch (ACS_BTEE);
+          break;
+        case M_TREE_SPACE:
+          addch (' ');
+          break;
+        case M_TREE_RARROW:
+          addch ('>');
+          break;
+        case M_TREE_STAR:
+          addch ('*');          /* fake thread indicator */
+          break;
+        case M_TREE_HIDDEN:
+          addch ('&');
+          break;
+        case M_TREE_EQUALS:
+          addch ('=');
+          break;
+        case M_TREE_MISSING:
+          addch ('?');
+          break;
         }
         s++, n--;
       }
-      if (do_color) attrset(attr);
+      if (do_color)
+        attrset (attr);
     }
-    else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
-    {
-      addnstr ((char *)s, k);
-      s += k, n-= k;
+    else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) > 0) {
+      addnstr ((char *) s, k);
+      s += k, n -= k;
     }
     else
       break;
   }
 }
 
-static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i) 
+static void menu_make_entry (char *s, int l, MUTTMENU * menu, int i)
 {
-  if (menu->dialog) 
-  {
+  if (menu->dialog) {
     strncpy (s, menu->dialog[i], l);
-    menu->current = -1; /* hide menubar */
+    menu->current = -1;         /* hide menubar */
   }
   else
     menu->make_entry (s, l, menu, i);
@@ -158,36 +153,35 @@ static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i)
 void menu_pad_string (char *s, size_t n)
 {
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
-  int cols; 
-  char* tmpbuf = safe_malloc (n);
-  if (option(OPTMBOXPANE))
+  int cols;
+  char *tmpbuf = safe_malloc (n);
+
+  if (option (OPTMBOXPANE))
     cols = COLS - shift - SidebarWidth;
   else
     cols = COLS - shift;
   mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, strlen (s), 1);
   tmpbuf[n - 1] = 0;
-  snprintf(s,n,"%s",tmpbuf); /* overkill */
-  FREE(&tmpbuf);
+  snprintf (s, n, "%s", tmpbuf);        /* overkill */
+  FREE (&tmpbuf);
 }
 
-void menu_redraw_full (MUTTMENU *menu)
+void menu_redraw_full (MUTTMENU * menu)
 {
   SETCOLOR (MT_COLOR_NORMAL);
   /* clear() doesn't optimize screen redraws */
   move (0, 0);
   clrtobot ();
 
-  if (option (OPTHELP))
-  {
+  if (option (OPTHELP)) {
     SETCOLOR (MT_COLOR_STATUS);
-    move (option (OPTSTATUSONTOP) ? LINES-2 : 0, 0);
+    move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, 0);
     mutt_paddstr (COLS, menu->help);
     SETCOLOR (MT_COLOR_NORMAL);
     menu->offset = 1;
     menu->pagelen = LINES - 3;
   }
-  else
-  {
+  else {
     menu->offset = option (OPTSTATUSONTOP) ? 1 : 0;
     menu->pagelen = LINES - 2;
   }
@@ -197,7 +191,7 @@ void menu_redraw_full (MUTTMENU *menu)
   menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
 }
 
-void menu_redraw_status (MUTTMENU *menu)
+void menu_redraw_status (MUTTMENU * menu)
 {
   char buf[STRING];
 
@@ -209,26 +203,22 @@ void menu_redraw_status (MUTTMENU *menu)
   menu->redraw &= ~REDRAW_STATUS;
 }
 
-void menu_redraw_index (MUTTMENU *menu)
+void menu_redraw_index (MUTTMENU * menu)
 {
   char buf[STRING];
   int i;
 
-  draw_sidebar(1);
-  for (i = menu->top; i < menu->top + menu->pagelen; i++)
-  {
-    if (i < menu->max)
-    {
+  draw_sidebar (1);
+  for (i = menu->top; i < menu->top + menu->pagelen; i++) {
+    if (i < menu->max) {
       menu_make_entry (buf, sizeof (buf), menu, i);
       menu_pad_string (buf, sizeof (buf));
 
-      if (option (OPTARROWCURSOR))
-      {
+      if (option (OPTARROWCURSOR)) {
         attrset (menu->color (i));
         CLEARLINE_WIN (i - menu->top + menu->offset);
 
-        if (i == menu->current)
-        {
+        if (i == menu->current) {
           attrset (menu->color (i));
           ADDCOLOR (MT_COLOR_INDICATOR);
           addstr ("->");
@@ -238,21 +228,20 @@ void menu_redraw_index (MUTTMENU *menu)
         else
           move (i - menu->top + menu->offset, SidebarWidth + 3);
 
-        print_enriched_string (menu->color(i), (unsigned char *) buf, 1);
-        SETCOLOR (MT_COLOR_NORMAL);          
+        print_enriched_string (menu->color (i), (unsigned char *) buf, 1);
+        SETCOLOR (MT_COLOR_NORMAL);
       }
-      else
-      {
+      else {
         attrset (menu->color (i));
-            
-        if (i == menu->current)
-        {
+
+        if (i == menu->current) {
           ADDCOLOR (MT_COLOR_INDICATOR);
           BKGDSET (MT_COLOR_INDICATOR);
         }
 
         CLEARLINE_WIN (i - menu->top + menu->offset);
-        print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
+        print_enriched_string (menu->color (i), (unsigned char *) buf,
+                               i != menu->current);
         SETCOLOR (MT_COLOR_NORMAL);
         BKGDSET (MT_COLOR_NORMAL);
       }
@@ -263,33 +252,31 @@ void menu_redraw_index (MUTTMENU *menu)
   menu->redraw = 0;
 }
 
-void menu_redraw_motion (MUTTMENU *menu)
+void menu_redraw_motion (MUTTMENU * menu)
 {
   char buf[STRING];
 
-  if (menu->dialog) 
-  {
+  if (menu->dialog) {
     menu->redraw &= ~REDRAW_MOTION;
     return;
   }
-  
+
   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
   SETCOLOR (MT_COLOR_NORMAL);
   BKGDSET (MT_COLOR_NORMAL);
 
-  if (option (OPTARROWCURSOR))
-  {
+  if (option (OPTARROWCURSOR)) {
     /* clear the pointer */
     attrset (menu->color (menu->oldcurrent));
     addstr ("  ");
 
-    if (menu->redraw & REDRAW_MOTION_RESYNCH)
-    {
+    if (menu->redraw & REDRAW_MOTION_RESYNCH) {
       clrtoeol ();
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
       menu_pad_string (buf, sizeof (buf));
       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
-      print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+      print_enriched_string (menu->color (menu->oldcurrent),
+                             (unsigned char *) buf, 1);
       SETCOLOR (MT_COLOR_NORMAL);
     }
 
@@ -300,14 +287,14 @@ void menu_redraw_motion (MUTTMENU *menu)
     addstr ("->");
     SETCOLOR (MT_COLOR_NORMAL);
   }
-  else
-  {
+  else {
     /* erase the current indicator */
     attrset (menu->color (menu->oldcurrent));
     clrtoeol ();
     menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
     menu_pad_string (buf, sizeof (buf));
-    print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+    print_enriched_string (menu->color (menu->oldcurrent),
+                           (unsigned char *) buf, 1);
 
     /* now draw the new one to reflect the change */
     menu_make_entry (buf, sizeof (buf), menu, menu->current);
@@ -316,24 +303,25 @@ void menu_redraw_motion (MUTTMENU *menu)
     ADDCOLOR (MT_COLOR_INDICATOR);
     BKGDSET (MT_COLOR_INDICATOR);
     CLEARLINE_WIN (menu->current - menu->top + menu->offset);
-    print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+    print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
+                           0);
     SETCOLOR (MT_COLOR_NORMAL);
     BKGDSET (MT_COLOR_NORMAL);
   }
   menu->redraw &= REDRAW_STATUS;
 }
 
-void menu_redraw_current (MUTTMENU *menu)
+void menu_redraw_current (MUTTMENU * menu)
 {
   char buf[STRING];
-  
+
   move (menu->current + menu->offset - menu->top, SidebarWidth);
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
   menu_pad_string (buf, sizeof (buf));
 
-  if (option (OPTARROWCURSOR))
-  {
+  if (option (OPTARROWCURSOR)) {
     int attr = menu->color (menu->current);
+
     attrset (attr);
     clrtoeol ();
     attrset (menu->color (menu->current));
@@ -342,28 +330,27 @@ void menu_redraw_current (MUTTMENU *menu)
     attrset (attr);
     addch (' ');
     menu_pad_string (buf, sizeof (buf));
-    print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 1);
+    print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
+                           1);
     SETCOLOR (MT_COLOR_NORMAL);
   }
-  else
-  {
+  else {
     attrset (menu->color (menu->current));
     ADDCOLOR (MT_COLOR_INDICATOR);
     BKGDSET (MT_COLOR_INDICATOR);
     clrtoeol ();
-    print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
+    print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
+                           0);
     SETCOLOR (MT_COLOR_NORMAL);
     BKGDSET (MT_COLOR_NORMAL);
   }
   menu->redraw &= REDRAW_STATUS;
 }
 
-void menu_redraw_prompt (MUTTMENU *menu)
+void menu_redraw_prompt (MUTTMENU * menu)
 {
-  if (menu->dialog) 
-  {
-    if (option (OPTMSGERR)) 
-    {
+  if (menu->dialog) {
+    if (option (OPTMSGERR)) {
       mutt_sleep (1);
       unset_option (OPTMSGERR);
     }
@@ -377,31 +364,33 @@ void menu_redraw_prompt (MUTTMENU *menu)
   }
 }
 
-void menu_check_recenter (MUTTMENU *menu)
+void menu_check_recenter (MUTTMENU * menu)
 {
   int c = MIN (MenuContext, menu->pagelen / 2);
   int old_top = menu->top;
 
-  if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) /* less entries than lines */
-  {
+  if (!option (OPTMENUMOVEOFF) && menu->max <= menu->pagelen) { /* less entries than lines */
     if (menu->top != 0) {
       menu->top = 0;
       set_option (OPTNEEDREDRAW);
     }
   }
-  else if (menu->current >= menu->top + menu->pagelen - c) /* indicator below bottom threshold */
-  {
+  else if (menu->current >= menu->top + menu->pagelen - c) {    /* indicator below bottom threshold */
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
       menu->top = menu->current - menu->pagelen + c + 1;
     else
-      menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
+      menu->top +=
+        (menu->pagelen -
+         c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
   }
-  else if (menu->current < menu->top + c) /* indicator above top threshold */
-  {
+  else if (menu->current < menu->top + c) {     /* indicator above top threshold */
     if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
       menu->top = menu->current - c;
     else
-      menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
+      menu->top -=
+        (menu->pagelen -
+         c) * ((menu->top + menu->pagelen - 1 -
+                menu->current) / (menu->pagelen - c)) - c;
   }
 
   if (!option (OPTMENUMOVEOFF)) /* make entries stick to bottom */
@@ -412,20 +401,17 @@ void menu_check_recenter (MUTTMENU *menu)
     menu->redraw |= REDRAW_INDEX;
 }
 
-void menu_jump (MUTTMENU *menu)
+void menu_jump (MUTTMENU * menu)
 {
   int n;
   char buf[SHORT_STRING];
 
-  if (menu->max)
-  {
+  if (menu->max) {
     mutt_ungetch (LastKey, 0);
     buf[0] = 0;
-    if (mutt_get_field (_("Jump to: "), buf, sizeof (buf), 0) == 0 && buf[0])
-    {
+    if (mutt_get_field (_("Jump to: "), buf, sizeof (buf), 0) == 0 && buf[0]) {
       n = atoi (buf) - 1;
-      if (n >= 0 && n < menu->max)
-      {
+      if (n >= 0 && n < menu->max) {
         menu->current = n;
         menu->redraw = REDRAW_MOTION;
       }
@@ -437,15 +423,15 @@ void menu_jump (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_next_line (MUTTMENU *menu)
+void menu_next_line (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     int c = MIN (MenuContext, menu->pagelen / 2);
 
-    if (menu->top + 1 < menu->max - c
-      && (option(OPTMENUMOVEOFF) || (menu->max > menu->pagelen && menu->top < menu->max - menu->pagelen)))
-    {
+    if (menu->top + 1 < menu->max - c && (option (OPTMENUMOVEOFF)
+                                          || (menu->max > menu->pagelen
+                                              && menu->top <
+                                              menu->max - menu->pagelen))) {
       menu->top++;
       if (menu->current < menu->top + c && menu->current < menu->max - 1)
         menu->current++;
@@ -458,10 +444,9 @@ void menu_next_line (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_prev_line (MUTTMENU *menu)
+void menu_prev_line (MUTTMENU * menu)
 {
-  if (menu->top > 0)
-  {
+  if (menu->top > 0) {
     int c = MIN (MenuContext, menu->pagelen / 2);
 
     menu->top--;
@@ -473,19 +458,16 @@ void menu_prev_line (MUTTMENU *menu)
     mutt_error _("You cannot scroll up farther.");
 }
 
-void menu_next_page (MUTTMENU *menu)
+void menu_next_page (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
-    if (menu->top + menu->pagelen < menu->max)
-    {
+  if (menu->max) {
+    if (menu->top + menu->pagelen < menu->max) {
       menu->top += menu->pagelen;
       if (menu->current < menu->top)
         menu->current = menu->top;
       menu->redraw = REDRAW_INDEX;
     }
-    else if (menu->current != menu->max - 1 && !menu->dialog)
-    {
+    else if (menu->current != menu->max - 1 && !menu->dialog) {
       menu->current = menu->max - 1;
       menu->redraw = REDRAW_MOTION;
     }
@@ -496,20 +478,18 @@ void menu_next_page (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_prev_page (MUTTMENU *menu)
+void menu_prev_page (MUTTMENU * menu)
 {
   int c = MIN (MenuContext, menu->pagelen / 2);
 
-  if (menu->top > c)
-  {
+  if (menu->top > c) {
     if ((menu->top -= menu->pagelen) < 0)
       menu->top = 0;
     if (menu->current >= menu->top + menu->pagelen)
       menu->current = menu->top + menu->pagelen - 1;
     menu->redraw = REDRAW_INDEX;
   }
-  else if (menu->current && !menu->dialog)
-  {
+  else if (menu->current && !menu->dialog) {
     menu->current = 0;
     menu->redraw = REDRAW_MOTION;
   }
@@ -517,19 +497,17 @@ void menu_prev_page (MUTTMENU *menu)
     mutt_error _("You are on the first page.");
 }
 
-void menu_top_page (MUTTMENU *menu)
+void menu_top_page (MUTTMENU * menu)
 {
-  if (menu->current != menu->top)
-  {
+  if (menu->current != menu->top) {
     menu->current = menu->top;
     menu->redraw = REDRAW_MOTION;
   }
 }
 
-void menu_bottom_page (MUTTMENU *menu)
+void menu_bottom_page (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->current = menu->top + menu->pagelen - 1;
     if (menu->current > menu->max - 1)
       menu->current = menu->max - 1;
@@ -539,12 +517,11 @@ void menu_bottom_page (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_middle_page (MUTTMENU *menu)
+void menu_middle_page (MUTTMENU * menu)
 {
   int i;
 
-  if (menu->max)
-  {
+  if (menu->max) {
     i = menu->top + menu->pagelen;
     if (i > menu->max - 1)
       i = menu->max - 1;
@@ -555,10 +532,9 @@ void menu_middle_page (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_first_entry (MUTTMENU *menu)
+void menu_first_entry (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->current = 0;
     menu->redraw = REDRAW_MOTION;
   }
@@ -566,10 +542,9 @@ void menu_first_entry (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_last_entry (MUTTMENU *menu)
+void menu_last_entry (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->current = menu->max - 1;
     menu->redraw = REDRAW_MOTION;
   }
@@ -577,18 +552,16 @@ void menu_last_entry (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_half_up (MUTTMENU *menu)
+void menu_half_up (MUTTMENU * menu)
 {
-  if (menu->top > 0)
-  {
+  if (menu->top > 0) {
     if ((menu->top -= menu->pagelen / 2) < 0)
       menu->top = 0;
     if (menu->current >= menu->top + menu->pagelen)
       menu->current = menu->top + menu->pagelen - 1;
     menu->redraw = REDRAW_INDEX;
   }
-  else if (menu->current && !menu->dialog)
-  {
+  else if (menu->current && !menu->dialog) {
     menu->current = 0;
     menu->redraw = REDRAW_MOTION;
   }
@@ -596,19 +569,16 @@ void menu_half_up (MUTTMENU *menu)
     mutt_error _("First entry is shown.");
 }
 
-void menu_half_down (MUTTMENU *menu)
+void menu_half_down (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
-    if (menu->top + menu->pagelen < menu->max)
-    {
+  if (menu->max) {
+    if (menu->top + menu->pagelen < menu->max) {
       menu->top += menu->pagelen / 2;
       if (menu->current < menu->top)
         menu->current = menu->top;
       menu->redraw = REDRAW_INDEX;
     }
-    else if (menu->current != menu->max - 1 && !menu->dialog)
-    {
+    else if (menu->current != menu->max - 1 && !menu->dialog) {
       menu->current = menu->max - 1;
       menu->redraw = REDRAW_INDEX;
     }
@@ -619,10 +589,9 @@ void menu_half_down (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_current_top (MUTTMENU *menu)
+void menu_current_top (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->top = menu->current;
     menu->redraw = REDRAW_INDEX;
   }
@@ -630,10 +599,9 @@ void menu_current_top (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_current_middle (MUTTMENU *menu)
+void menu_current_middle (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->top = menu->current - menu->pagelen / 2;
     if (menu->top < 0)
       menu->top = 0;
@@ -643,10 +611,9 @@ void menu_current_middle (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_current_bottom (MUTTMENU *menu)
+void menu_current_bottom (MUTTMENU * menu)
 {
-  if (menu->max)
-  {
+  if (menu->max) {
     menu->top = menu->current - menu->pagelen + 1;
     if (menu->top < 0)
       menu->top = 0;
@@ -656,10 +623,9 @@ void menu_current_bottom (MUTTMENU *menu)
     mutt_error _("No entries.");
 }
 
-void menu_next_entry (MUTTMENU *menu)
+void menu_next_entry (MUTTMENU * menu)
 {
-  if (menu->current < menu->max - 1)
-  {
+  if (menu->current < menu->max - 1) {
     menu->current++;
     menu->redraw = REDRAW_MOTION;
   }
@@ -667,10 +633,9 @@ void menu_next_entry (MUTTMENU *menu)
     mutt_error _("You are on the last entry.");
 }
 
-void menu_prev_entry (MUTTMENU *menu)
+void menu_prev_entry (MUTTMENU * menu)
 {
-  if (menu->current)
-  {
+  if (menu->current) {
     menu->current--;
     menu->redraw = REDRAW_MOTION;
   }
@@ -680,10 +645,10 @@ void menu_prev_entry (MUTTMENU *menu)
 
 static int default_color (int i)
 {
-   return ColorDefs[MT_COLOR_NORMAL];
+  return ColorDefs[MT_COLOR_NORMAL];
 }
 
-static int menu_search_generic (MUTTMENU *m, regex_t *re, int n)
+static int menu_search_generic (MUTTMENU * m, regex_t * re, int n)
 {
   char buf[LONG_STRING];
 
@@ -705,18 +670,17 @@ MUTTMENU *mutt_new_menu (void)
   return (p);
 }
 
-void mutt_menuDestroy (MUTTMENU **p)
+void mutt_menuDestroy (MUTTMENU ** p)
 {
   int i;
 
   FREE (&(*p)->searchBuf);
 
-  if ((*p)->dialog) 
-  {
-    for (i=0; i < (*p)->max; i++)
+  if ((*p)->dialog) {
+    for (i = 0; i < (*p)->max; i++)
       FREE (&(*p)->dialog[i]);
 
-    FREE (& (*p)->dialog);
+    FREE (&(*p)->dialog);
   }
 
   FREE (p);
@@ -725,28 +689,26 @@ void mutt_menuDestroy (MUTTMENU **p)
 #define M_SEARCH_UP   1
 #define M_SEARCH_DOWN 2
 
-static int menu_search (MUTTMENU *menu, int op)
+static int menu_search (MUTTMENU * menu, int op)
 {
   int r;
   int searchDir;
   regex_t re;
   char buf[SHORT_STRING];
 
-  if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
-  {
+  if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE) {
     strfcpy (buf, menu->searchBuf ? menu->searchBuf : "", sizeof (buf));
-    if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") : 
-                                            _("Reverse search for: "),
-                         buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
+    if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
+                        _("Reverse search for: "),
+                        buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
       return (-1);
     mutt_str_replace (&menu->searchBuf, buf);
     menu->searchDir = (op == OP_SEARCH) ? M_SEARCH_DOWN : M_SEARCH_UP;
   }
-  else 
-  {
-    if (!menu->searchBuf)
-    {
+  else {
+    if (!menu->searchBuf) {
       mutt_error _("No search pattern.");
+
       return (-1);
     }
   }
@@ -755,8 +717,9 @@ static int menu_search (MUTTMENU *menu, int op)
   if (op == OP_SEARCH_OPPOSITE)
     searchDir = -searchDir;
 
-  if ((r = REGCOMP (&re, menu->searchBuf, REG_NOSUB | mutt_which_case (menu->searchBuf))) != 0)
-  {
+  if ((r =
+       REGCOMP (&re, menu->searchBuf,
+                REG_NOSUB | mutt_which_case (menu->searchBuf))) != 0) {
     regerror (r, &re, buf, sizeof (buf));
     regfree (&re);
     mutt_error ("%s", buf);
@@ -764,10 +727,8 @@ static int menu_search (MUTTMENU *menu, int op)
   }
 
   r = menu->current + searchDir;
-  while (r >= 0 && r < menu->max)
-  {
-    if (menu->search (menu, &re, r) == 0)
-    {
+  while (r >= 0 && r < menu->max) {
+    if (menu->search (menu, &re, r) == 0) {
       regfree (&re);
       return r;
     }
@@ -777,66 +738,64 @@ static int menu_search (MUTTMENU *menu, int op)
 
   regfree (&re);
   mutt_error _("Not found.");
+
   return (-1);
 }
 
 static int menu_dialog_translate_op (int i)
 {
-  switch (i)
-  {
-    case OP_NEXT_ENTRY:   
-      return OP_NEXT_LINE;
-    case OP_PREV_ENTRY:          
-      return OP_PREV_LINE;
-    case OP_CURRENT_TOP:   case OP_FIRST_ENTRY:  
-      return OP_TOP_PAGE;
-    case OP_CURRENT_BOTTOM:    case OP_LAST_ENTRY:          
-      return OP_BOTTOM_PAGE;
-    case OP_CURRENT_MIDDLE: 
-      return OP_MIDDLE_PAGE; 
+  switch (i) {
+  case OP_NEXT_ENTRY:
+    return OP_NEXT_LINE;
+  case OP_PREV_ENTRY:
+    return OP_PREV_LINE;
+  case OP_CURRENT_TOP:
+  case OP_FIRST_ENTRY:
+    return OP_TOP_PAGE;
+  case OP_CURRENT_BOTTOM:
+  case OP_LAST_ENTRY:
+    return OP_BOTTOM_PAGE;
+  case OP_CURRENT_MIDDLE:
+    return OP_MIDDLE_PAGE;
   }
-  
+
   return i;
 }
 
-static int menu_dialog_dokey (MUTTMENU *menu, int *ip)
+static int menu_dialog_dokey (MUTTMENU * menu, int *ip)
 {
   event_t ch;
   char *p;
 
   ch = mutt_getch ();
 
-  if (ch.ch == -1)
-  {
+  if (ch.ch == -1) {
     *ip = -1;
     return 0;
   }
 
-  if (ch.ch && (p = strchr (menu->keys, ch.ch)))
-  {
+  if (ch.ch && (p = strchr (menu->keys, ch.ch))) {
     *ip = OP_MAX + (p - menu->keys + 1);
     return 0;
   }
-  else
-  {
+  else {
     mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
     return -1;
   }
 }
 
-int menu_redraw (MUTTMENU *menu)
+int menu_redraw (MUTTMENU * menu)
 {
   /* See if all or part of the screen needs to be updated.  */
-  if (menu->redraw & REDRAW_FULL)
-  {
+  if (menu->redraw & REDRAW_FULL) {
     menu_redraw_full (menu);
     /* allow the caller to do any local configuration */
     return (OP_REDRAW);
   }
-  
+
   if (!menu->dialog)
     menu_check_recenter (menu);
-  
+
   if (menu->redraw & REDRAW_STATUS)
     menu_redraw_status (menu);
   if (menu->redraw & REDRAW_INDEX)
@@ -845,26 +804,24 @@ int menu_redraw (MUTTMENU *menu)
     menu_redraw_motion (menu);
   else if (menu->redraw == REDRAW_CURRENT)
     menu_redraw_current (menu);
-  
+
   if (menu->dialog)
     menu_redraw_prompt (menu);
-  
+
   return OP_NULL;
 }
 
-int mutt_menuLoop (MUTTMENU *menu)
+int mutt_menuLoop (MUTTMENU * menu)
 {
   int i = OP_NULL;
 
-  FOREVER
-  {
-    if (option (OPTMENUCALLER))
-    {
+  FOREVER {
+    if (option (OPTMENUCALLER)) {
       unset_option (OPTMENUCALLER);
       return OP_NULL;
     }
-    
-    
+
+
     mutt_curs_set (0);
 
 #ifdef USE_IMAP
@@ -873,45 +830,45 @@ int mutt_menuLoop (MUTTMENU *menu)
 
     if (menu_redraw (menu) == OP_REDRAW)
       return OP_REDRAW;
-    
+
     menu->oldcurrent = menu->current;
 
 
     /* move the cursor out of the way */
     move (menu->current - menu->top + menu->offset,
-          (option (OPTARROWCURSOR) ? 2 : COLS-1));
+          (option (OPTARROWCURSOR) ? 2 : COLS - 1));
 
     mutt_refresh ();
-    
+
     /* try to catch dialog keys before ops */
     if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
       return i;
-                    
+
     i = km_dokey (menu->menu);
-    if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND)
-    {
-      if (menu->tagged)
-      {
+    if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) {
+      if (menu->tagged) {
         mvaddstr (LINES - 1, 0, "Tag-");
         clrtoeol ();
         i = km_dokey (menu->menu);
         menu->tagprefix = 1;
         CLEARLINE (LINES - 1);
       }
-      else if (i == OP_TAG_PREFIX)
-      {
+      else if (i == OP_TAG_PREFIX) {
         mutt_error _("No tagged entries.");
+
         i = -1;
       }
-      else /* None tagged, OP_TAG_PREFIX_COND */
-      {
+      else {                    /* None tagged, OP_TAG_PREFIX_COND */
+
         event_t tmp;
-        while(UngetCount>0)
-        {
-          tmp=mutt_getch();
-          if(tmp.op==OP_END_COND)break;
+
+        while (UngetCount > 0) {
+          tmp = mutt_getch ();
+          if (tmp.op == OP_END_COND)
+            break;
         }
         mutt_message _("Nothing to do.");
+
         i = -1;
       }
     }
@@ -923,12 +880,11 @@ int mutt_menuLoop (MUTTMENU *menu)
     mutt_curs_set (1);
 
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-    if (SigWinch)
-    {
+    if (SigWinch) {
       mutt_resize_screen ();
       menu->redraw = REDRAW_FULL;
       SigWinch = 0;
-      clearok(stdscr,TRUE);/*force complete redraw*/
+      clearok (stdscr, TRUE);   /*force complete redraw */
     }
 #endif
 
@@ -939,149 +895,144 @@ int mutt_menuLoop (MUTTMENU *menu)
       mutt_clear_error ();
 
     /* Convert menubar movement to scrolling */
-    if (menu->dialog) 
+    if (menu->dialog)
       i = menu_dialog_translate_op (i);
 
-    switch (i)
-    {
-      case OP_NEXT_ENTRY:
-        menu_next_entry (menu);
-        break;
-      case OP_PREV_ENTRY:
-        menu_prev_entry (menu);
-        break;
-      case OP_HALF_DOWN:
-        menu_half_down (menu);
-        break;
-      case OP_HALF_UP:
-        menu_half_up (menu);
-        break;
-      case OP_NEXT_PAGE:
-        menu_next_page (menu);
-        break;
-      case OP_PREV_PAGE:
-        menu_prev_page (menu);
-        break;
-      case OP_NEXT_LINE:
-        menu_next_line (menu);
-        break;
-      case OP_PREV_LINE:
-        menu_prev_line (menu);
-        break;
-      case OP_FIRST_ENTRY:
-        menu_first_entry (menu);
-        break;
-      case OP_LAST_ENTRY:
-        menu_last_entry (menu);
-        break;
-      case OP_TOP_PAGE:
-        menu_top_page (menu);
-        break;
-      case OP_MIDDLE_PAGE:
-        menu_middle_page (menu);
-        break;
-      case OP_BOTTOM_PAGE:
-        menu_bottom_page (menu);
-        break;
-      case OP_CURRENT_TOP:
-        menu_current_top (menu);
-        break;
-      case OP_CURRENT_MIDDLE:
-        menu_current_middle (menu);
-        break;
-      case OP_CURRENT_BOTTOM:
-        menu_current_bottom (menu);
-        break;
-      case OP_SEARCH:
-      case OP_SEARCH_REVERSE:
-      case OP_SEARCH_NEXT:
-      case OP_SEARCH_OPPOSITE:
-        if (menu->search && !menu->dialog) /* Searching dialogs won't work */
-        {
-          menu->oldcurrent = menu->current;
-          if ((menu->current = menu_search (menu, i)) != -1)
-            menu->redraw = REDRAW_MOTION;
-          else
-            menu->current = menu->oldcurrent;
-        }
+    switch (i) {
+    case OP_NEXT_ENTRY:
+      menu_next_entry (menu);
+      break;
+    case OP_PREV_ENTRY:
+      menu_prev_entry (menu);
+      break;
+    case OP_HALF_DOWN:
+      menu_half_down (menu);
+      break;
+    case OP_HALF_UP:
+      menu_half_up (menu);
+      break;
+    case OP_NEXT_PAGE:
+      menu_next_page (menu);
+      break;
+    case OP_PREV_PAGE:
+      menu_prev_page (menu);
+      break;
+    case OP_NEXT_LINE:
+      menu_next_line (menu);
+      break;
+    case OP_PREV_LINE:
+      menu_prev_line (menu);
+      break;
+    case OP_FIRST_ENTRY:
+      menu_first_entry (menu);
+      break;
+    case OP_LAST_ENTRY:
+      menu_last_entry (menu);
+      break;
+    case OP_TOP_PAGE:
+      menu_top_page (menu);
+      break;
+    case OP_MIDDLE_PAGE:
+      menu_middle_page (menu);
+      break;
+    case OP_BOTTOM_PAGE:
+      menu_bottom_page (menu);
+      break;
+    case OP_CURRENT_TOP:
+      menu_current_top (menu);
+      break;
+    case OP_CURRENT_MIDDLE:
+      menu_current_middle (menu);
+      break;
+    case OP_CURRENT_BOTTOM:
+      menu_current_bottom (menu);
+      break;
+    case OP_SEARCH:
+    case OP_SEARCH_REVERSE:
+    case OP_SEARCH_NEXT:
+    case OP_SEARCH_OPPOSITE:
+      if (menu->search && !menu->dialog) {      /* Searching dialogs won't work */
+        menu->oldcurrent = menu->current;
+        if ((menu->current = menu_search (menu, i)) != -1)
+          menu->redraw = REDRAW_MOTION;
         else
-          mutt_error _("Search is not implemented for this menu.");
-        break;
+          menu->current = menu->oldcurrent;
+      }
+      else
+        mutt_error _("Search is not implemented for this menu.");
+      break;
 
-      case OP_JUMP:
-        if (menu->dialog)
-          mutt_error _("Jumping is not implemented for dialogs.");
-        else
-          menu_jump (menu);
-        break;
-
-      case OP_ENTER_COMMAND:
-        CurrentMenu = menu->menu;
-        mutt_enter_command ();
-        if (option (OPTFORCEREDRAWINDEX))
-        {
-          menu->redraw = REDRAW_FULL;
-          unset_option (OPTFORCEREDRAWINDEX);
-          unset_option (OPTFORCEREDRAWPAGER);
+    case OP_JUMP:
+      if (menu->dialog)
+        mutt_error (_("Jumping is not implemented for dialogs."));
+
+      else
+        menu_jump (menu);
+      break;
+
+    case OP_ENTER_COMMAND:
+      CurrentMenu = menu->menu;
+      mutt_enter_command ();
+      if (option (OPTFORCEREDRAWINDEX)) {
+        menu->redraw = REDRAW_FULL;
+        unset_option (OPTFORCEREDRAWINDEX);
+        unset_option (OPTFORCEREDRAWPAGER);
+      }
+      break;
+
+    case OP_TAG:
+      if (menu->tag && !menu->dialog) {
+        if (menu->tagprefix && !option (OPTAUTOTAG)) {
+          for (i = 0; i < menu->max; i++)
+            menu->tagged += menu->tag (menu, i, 0);
+          menu->redraw = REDRAW_INDEX;
         }
-        break;
-
-      case OP_TAG:
-        if (menu->tag && !menu->dialog)
-        {
-          if (menu->tagprefix && !option (OPTAUTOTAG))
-          {
-            for (i = 0; i < menu->max; i++)
-              menu->tagged += menu->tag (menu, i, 0);
-            menu->redraw = REDRAW_INDEX;
-          }
-          else if (menu->max)
-          {
-            int i = menu->tag (menu, menu->current, -1);
-            menu->tagged += i;
-            if (i && option (OPTRESOLVE) && menu->current < menu->max - 1)
-            {
-              menu->current++;
-              menu->redraw = REDRAW_MOTION_RESYNCH;
-            }
-            else
-              menu->redraw = REDRAW_CURRENT;
+        else if (menu->max) {
+          int i = menu->tag (menu, menu->current, -1);
+
+          menu->tagged += i;
+          if (i && option (OPTRESOLVE) && menu->current < menu->max - 1) {
+            menu->current++;
+            menu->redraw = REDRAW_MOTION_RESYNCH;
           }
           else
-            mutt_error _("No entries.");
+            menu->redraw = REDRAW_CURRENT;
         }
         else
-          mutt_error _("Tagging is not supported.");
-        break;
+          mutt_error _("No entries.");
+      }
+      else
+        mutt_error _("Tagging is not supported.");
+      break;
 
-      case OP_SHELL_ESCAPE:
-        mutt_shell_escape ();
-        MAYBE_REDRAW (menu->redraw);
-        break;
+    case OP_SHELL_ESCAPE:
+      mutt_shell_escape ();
+      MAYBE_REDRAW (menu->redraw);
+      break;
 
-      case OP_WHAT_KEY:
-        mutt_what_key ();
-        break;
+    case OP_WHAT_KEY:
+      mutt_what_key ();
+      break;
 
-      case OP_REDRAW:
-        clearok (stdscr, TRUE);
-        menu->redraw = REDRAW_FULL;
-        break;
+    case OP_REDRAW:
+      clearok (stdscr, TRUE);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_HELP:
-        mutt_help (menu->menu);
-        menu->redraw = REDRAW_FULL;
-        break;
+    case OP_HELP:
+      mutt_help (menu->menu);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_NULL:
-        km_error_key (menu->menu);
-        break;
+    case OP_NULL:
+      km_error_key (menu->menu);
+      break;
 
-      case OP_END_COND:
-        break;
+    case OP_END_COND:
+      break;
 
-      default:
-        return (i);
+    default:
+      return (i);
     }
   }
   /* not reached */
diff --git a/mh.c b/mh.c
index ae978e9..cbc7b8b 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -47,8 +47,7 @@
 #include <string.h>
 #include <utime.h>
 
-struct maildir
-{
+struct maildir {
   HEADER *h;
   char *canon_fname;
   unsigned header_parsed:1;
@@ -56,8 +55,7 @@ struct maildir
   struct maildir *next;
 };
 
-struct mh_sequences
-{
+struct mh_sequences {
   int max;
   short *flags;
 };
@@ -73,8 +71,7 @@ static void mhs_alloc (struct mh_sequences *mhs, int i)
   int j;
   int newmax;
 
-  if (i > mhs->max || !mhs->flags)
-  {
+  if (i > mhs->max || !mhs->flags) {
     newmax = i + 128;
     safe_realloc (&mhs->flags, sizeof (mhs->flags[0]) * (newmax + 1));
     for (j = mhs->max + 1; j <= newmax; j++)
@@ -120,8 +117,8 @@ static short mhs_unset (struct mh_sequences *mhs, int i, short f)
 static void mh_read_token (char *t, int *first, int *last)
 {
   char *p;
-  if ((p = strchr (t, '-')))
-  {
+
+  if ((p = strchr (t, '-'))) {
     *p++ = '\0';
     *first = atoi (t);
     *last = atoi (p);
@@ -142,13 +139,13 @@ static void mh_read_sequences (struct mh_sequences *mhs, const char *path)
   int first, last;
 
   char pathname[_POSIX_PATH_MAX];
+
   snprintf (pathname, sizeof (pathname), "%s/.mh_sequences", path);
 
   if (!(fp = fopen (pathname, "r")))
     return;
 
-  while ((buff = mutt_read_line (buff, &sz, fp, &line)))
-  {
+  while ((buff = mutt_read_line (buff, &sz, fp, &line))) {
     if (!(t = strtok (buff, " \t:")))
       continue;
 
@@ -158,14 +155,13 @@ static void mh_read_sequences (struct mh_sequences *mhs, const char *path)
       f = MH_SEQ_FLAGGED;
     else if (!mutt_strcmp (t, MhReplied))
       f = MH_SEQ_REPLIED;
-    else                       /* unknown sequence */
+    else                        /* unknown sequence */
       continue;
 
-    while ((t = strtok (NULL, " \t:")))
-    {
+    while ((t = strtok (NULL, " \t:"))) {
       mh_read_token (t, &first, &last);
       for (; first <= last; first++)
-       mhs_set (mhs, first, f);
+        mhs_set (mhs, first, f);
     }
   }
 
@@ -177,6 +173,7 @@ int mh_buffy (const char *path)
 {
   int i, r = 0;
   struct mh_sequences mhs;
+
   memset (&mhs, 0, sizeof (mhs));
 
   mh_read_sequences (&mhs, path);
@@ -192,28 +189,23 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
   int fd;
   char path[_POSIX_PATH_MAX];
 
-  FOREVER
-  {
+  FOREVER {
     snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
-             dest->path, NONULL (Hostname), (int) getpid (), Counter++);
-    umask(Umask);
-    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
-    {
-      if (errno != EEXIST)
-      {
-       mutt_perror (path);
-       return -1;
+              dest->path, NONULL (Hostname), (int) getpid (), Counter++);
+    umask (Umask);
+    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
+      if (errno != EEXIST) {
+        mutt_perror (path);
+        return -1;
       }
     }
-    else
-    {
+    else {
       *tgt = safe_strdup (path);
       break;
     }
   }
 
-  if ((*fp = fdopen (fd, "w")) == NULL)
-  {
+  if ((*fp = fdopen (fd, "w")) == NULL) {
     FREE (tgt);
     close (fd);
     unlink (path);
@@ -224,38 +216,35 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
 }
 
 static void mhs_write_one_sequence (FILE * fp, struct mh_sequences *mhs,
-                                   short f, const char *tag)
+                                    short f, const char *tag)
 {
   int i;
   int first, last;
+
   fprintf (fp, "%s:", tag);
 
   first = -1;
   last = -1;
 
-  for (i = 0; i <= mhs->max; i++)
-  {
-    if ((mhs_check (mhs, i) & f))
-    {
+  for (i = 0; i <= mhs->max; i++) {
+    if ((mhs_check (mhs, i) & f)) {
       if (first < 0)
-       first = i;
+        first = i;
       else
-       last = i;
+        last = i;
     }
-    else if (first >= 0)
-    {
+    else if (first >= 0) {
       if (last < 0)
-       fprintf (fp, " %d", first);
+        fprintf (fp, " %d", first);
       else
-       fprintf (fp, " %d-%d", first, last);
+        fprintf (fp, " %d-%d", first, last);
 
       first = -1;
       last = -1;
     }
   }
 
-  if (first >= 0)
-  {
+  if (first >= 0) {
     if (last < 0)
       fprintf (fp, " %d", first);
     else
@@ -289,14 +278,14 @@ void mh_update_sequences (CONTEXT * ctx)
 
 
   struct mh_sequences mhs;
+
   memset (&mhs, 0, sizeof (mhs));
 
   snprintf (seq_unseen, sizeof (seq_unseen), "%s:", NONULL (MhUnseen));
   snprintf (seq_replied, sizeof (seq_replied), "%s:", NONULL (MhReplied));
   snprintf (seq_flagged, sizeof (seq_flagged), "%s:", NONULL (MhFlagged));
 
-  if (mh_mkstemp (ctx, &nfp, &tmpfname) != 0)
-  {
+  if (mh_mkstemp (ctx, &nfp, &tmpfname) != 0) {
     /* error message? */
     return;
   }
@@ -305,16 +294,14 @@ void mh_update_sequences (CONTEXT * ctx)
 
 
   /* first, copy unknown sequences */
-  if ((ofp = fopen (sequences, "r")))
-  {
-    while ((buff = mutt_read_line (buff, &s, ofp, &l)))
-    {
+  if ((ofp = fopen (sequences, "r"))) {
+    while ((buff = mutt_read_line (buff, &s, ofp, &l))) {
       if (!mutt_strncmp (buff, seq_unseen, mutt_strlen (seq_unseen)))
-       continue;
+        continue;
       if (!mutt_strncmp (buff, seq_flagged, mutt_strlen (seq_flagged)))
-       continue;
+        continue;
       if (!mutt_strncmp (buff, seq_replied, mutt_strlen (seq_replied)))
-       continue;
+        continue;
 
       fprintf (nfp, "%s\n", buff);
     }
@@ -322,8 +309,7 @@ void mh_update_sequences (CONTEXT * ctx)
   safe_fclose (&ofp);
 
   /* now, update our unseen, flagged, and replied sequences */
-  for (l = 0; l < ctx->msgcount; l++)
-  {
+  for (l = 0; l < ctx->msgcount; l++) {
     if (ctx->hdrs[l]->deleted)
       continue;
 
@@ -334,18 +320,15 @@ void mh_update_sequences (CONTEXT * ctx)
 
     i = atoi (p);
 
-    if (!ctx->hdrs[l]->read)
-    {
+    if (!ctx->hdrs[l]->read) {
       mhs_set (&mhs, i, MH_SEQ_UNSEEN);
       unseen++;
     }
-    if (ctx->hdrs[l]->flagged)
-    {
+    if (ctx->hdrs[l]->flagged) {
       mhs_set (&mhs, i, MH_SEQ_FLAGGED);
       flagged++;
     }
-    if (ctx->hdrs[l]->replied)
-    {
+    if (ctx->hdrs[l]->replied) {
       mhs_set (&mhs, i, MH_SEQ_REPLIED);
       replied++;
     }
@@ -366,8 +349,7 @@ void mh_update_sequences (CONTEXT * ctx)
   safe_fclose (&nfp);
 
   unlink (sequences);
-  if (safe_rename (tmpfname, sequences) != 0)
-  {
+  if (safe_rename (tmpfname, sequences) != 0) {
     /* report an error? */
     unlink (tmpfname);
   }
@@ -376,7 +358,7 @@ void mh_update_sequences (CONTEXT * ctx)
 }
 
 static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
-                                 short flagged, short replied)
+                                  short flagged, short replied)
 {
   short unseen_done = 0;
   short flagged_done = 0;
@@ -403,29 +385,24 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen,
   snprintf (seq_flagged, sizeof (seq_flagged), "%s:", NONULL (MhFlagged));
 
   snprintf (sequences, sizeof (sequences), "%s/.mh_sequences", ctx->path);
-  if ((ofp = fopen (sequences, "r")))
-  {
-    while ((buff = mutt_read_line (buff, &sz, ofp, &line)))
-    {
-      if (unseen && !strncmp (buff, seq_unseen, mutt_strlen (seq_unseen)))
-      {
-       fprintf (nfp, "%s %d\n", buff, n);
-       unseen_done = 1;
+  if ((ofp = fopen (sequences, "r"))) {
+    while ((buff = mutt_read_line (buff, &sz, ofp, &line))) {
+      if (unseen && !strncmp (buff, seq_unseen, mutt_strlen (seq_unseen))) {
+        fprintf (nfp, "%s %d\n", buff, n);
+        unseen_done = 1;
       }
       else if (flagged
-              && !strncmp (buff, seq_flagged, mutt_strlen (seq_flagged)))
-      {
-       fprintf (nfp, "%s %d\n", buff, n);
-       flagged_done = 1;
+               && !strncmp (buff, seq_flagged, mutt_strlen (seq_flagged))) {
+        fprintf (nfp, "%s %d\n", buff, n);
+        flagged_done = 1;
       }
       else if (replied
-              && !strncmp (buff, seq_replied, mutt_strlen (seq_replied)))
-      {
-       fprintf (nfp, "%s %d\n", buff, n);
-       replied_done = 1;
+               && !strncmp (buff, seq_replied, mutt_strlen (seq_replied))) {
+        fprintf (nfp, "%s %d\n", buff, n);
+        replied_done = 1;
       }
       else
-       fprintf (nfp, "%s\n", buff);
+        fprintf (nfp, "%s\n", buff);
     }
   }
   safe_fclose (&ofp);
@@ -453,8 +430,7 @@ static void mh_update_maildir (struct maildir *md, struct mh_sequences *mhs)
   short f;
   char *p;
 
-  for (; md; md = md->next)
-  {
+  for (; md; md = md->next) {
     if ((p = strrchr (md->h->path, '/')))
       p++;
     else
@@ -490,8 +466,7 @@ static void maildir_free_maildir (struct maildir **md)
   if (!md || !*md)
     return;
 
-  for (p = *md; p; p = q)
-  {
+  for (p = *md; p; p = q) {
     q = p->next;
     maildir_free_entry (&p);
   }
@@ -505,45 +480,42 @@ static void maildir_parse_flags (HEADER * h, const char *path)
   h->read = 0;
   h->replied = 0;
 
-  if ((p = strrchr (path, ':')) != NULL && mutt_strncmp (p + 1, "2,", 2) == 0)
-  {
+  if ((p = strrchr (path, ':')) != NULL && mutt_strncmp (p + 1, "2,", 2) == 0) {
     p += 3;
-    
+
     mutt_str_replace (&h->maildir_flags, p);
     q = h->maildir_flags;
 
-    while (*p)
-    {
-      switch (*p)
-      {
+    while (*p) {
+      switch (*p) {
       case 'F':
 
-       h->flagged = 1;
-       break;
+        h->flagged = 1;
+        break;
+
+      case 'S':                /* seen */
 
-      case 'S':                /* seen */
+        h->read = 1;
+        break;
 
-       h->read = 1;
-       break;
+      case 'R':                /* replied */
 
-      case 'R':                /* replied */
+        h->replied = 1;
+        break;
 
-       h->replied = 1;
-       break;
+      case 'T':                /* trashed */
+        h->trash = 1;
+        h->deleted = 1;
+        break;
 
-      case 'T':                /* trashed */
-       h->trash = 1;
-       h->deleted = 1;
-       break;
-      
       default:
-       *q++ = *p;
-       break;
+        *q++ = *p;
+        break;
       }
       p++;
     }
   }
-  
+
   if (q == h->maildir_flags)
     FREE (&h->maildir_flags);
   else if (q)
@@ -555,15 +527,13 @@ static void maildir_update_mtime (CONTEXT * ctx)
   char buf[_POSIX_PATH_MAX];
   struct stat st;
 
-  if (ctx->magic == M_MAILDIR)
-  {
+  if (ctx->magic == M_MAILDIR) {
     snprintf (buf, sizeof (buf), "%s/%s", ctx->path, "cur");
     if (stat (buf, &st) == 0)
       ctx->mtime_cur = st.st_mtime;
     snprintf (buf, sizeof (buf), "%s/%s", ctx->path, "new");
   }
-  else
-  {
+  else {
     snprintf (buf, sizeof (buf), "%s/.mh_sequences", ctx->path);
     if (stat (buf, &st) == 0)
       ctx->mtime_cur = st.st_mtime;
@@ -580,14 +550,13 @@ static void maildir_update_mtime (CONTEXT * ctx)
  * out a fake header structure generated by lazy maildir parsing.
  */
 static HEADER *maildir_parse_message (int magic, const char *fname,
-                                     int is_old, HEADER * _h)
+                                      int is_old, HEADER * _h)
 {
   FILE *f;
   HEADER *h = _h;
   struct stat st;
 
-  if ((f = fopen (fname, "r")) != NULL)
-  {
+  if ((f = fopen (fname, "r")) != NULL) {
     if (!h)
       h = mutt_new_header ();
     h->env = mutt_read_rfc822_header (f, h, 0, 0);
@@ -603,8 +572,7 @@ static HEADER *maildir_parse_message (int magic, const char *fname,
 
     h->index = -1;
 
-    if (magic == M_MAILDIR)
-    {
+    if (magic == M_MAILDIR) {
       /* 
        * maildir stores its flags in the filename, so ignore the
        * flags in the header of the message 
@@ -632,8 +600,8 @@ static HEADER *maildir_parse_message (int magic, const char *fname,
  */
 
 static int maildir_parse_entry (CONTEXT * ctx, struct maildir ***last,
-                               const char *subdir, const char *fname,
-                               int *count, int is_old, ino_t inode)
+                                const char *subdir, const char *fname,
+                                int *count, int is_old, ino_t inode)
 {
   struct maildir *entry;
   HEADER *h = NULL;
@@ -646,24 +614,20 @@ static int maildir_parse_entry (CONTEXT * ctx, struct maildir ***last,
 
   if (ctx->magic == M_MH)
     h = maildir_parse_message (ctx->magic, buf, is_old, NULL);
-  else
-  {
+  else {
     h = mutt_new_header ();
     h->old = is_old;
     maildir_parse_flags (h, buf);
   }
 
-  if (h != NULL)
-  {
-    if (count)
-    {
+  if (h != NULL) {
+    if (count) {
       (*count)++;
       if (!ctx->quiet && ReadInc && ((*count % ReadInc) == 0 || *count == 1))
-       mutt_message (_("Reading %s... %d"), ctx->path, *count);
+        mutt_message (_("Reading %s... %d"), ctx->path, *count);
     }
 
-    if (subdir)
-    {
+    if (subdir) {
       snprintf (buf, sizeof (buf), "%s/%s", subdir, fname);
       h->path = safe_strdup (buf);
     }
@@ -692,8 +656,7 @@ static int maildir_parse_entry (CONTEXT * ctx, struct maildir ***last,
 
 int mh_valid_message (const char *s)
 {
-  for (; *s; s++)
-  {
+  for (; *s; s++) {
     if (!isdigit ((unsigned char) *s))
       return 0;
   }
@@ -701,15 +664,14 @@ int mh_valid_message (const char *s)
 }
 
 static int maildir_parse_dir (CONTEXT * ctx, struct maildir ***last,
-                             const char *subdir, int *count)
+                              const char *subdir, int *count)
 {
   DIR *dirp;
   struct dirent *de;
   char buf[_POSIX_PATH_MAX];
   int is_old = 0;
 
-  if (subdir)
-  {
+  if (subdir) {
     snprintf (buf, sizeof (buf), "%s/%s", ctx->path, subdir);
     is_old = (mutt_strcmp ("cur", subdir) == 0);
   }
@@ -719,20 +681,19 @@ static int maildir_parse_dir (CONTEXT * ctx, struct maildir ***last,
   if ((dirp = opendir (buf)) == NULL)
     return -1;
 
-  while ((de = readdir (dirp)) != NULL)
-  {
+  while ((de = readdir (dirp)) != NULL) {
 
     if ((ctx->magic == M_MH && !mh_valid_message (de->d_name))
-       || (ctx->magic == M_MAILDIR && *de->d_name == '.'))
+        || (ctx->magic == M_MAILDIR && *de->d_name == '.'))
       continue;
 
     /* FOO - really ignore the return value? */
 
     dprint (2,
-           (debugfile, "%s:%d: parsing %s\n", __FILE__, __LINE__,
-            de->d_name));
-    maildir_parse_entry (ctx, last, subdir, de->d_name, count, is_old, 
-                        de->d_ino);
+            (debugfile, "%s:%d: parsing %s\n", __FILE__, __LINE__,
+             de->d_name));
+    maildir_parse_entry (ctx, last, subdir, de->d_name, count, is_old,
+                         de->d_ino);
   }
 
   closedir (dirp);
@@ -743,28 +704,26 @@ static int maildir_add_to_context (CONTEXT * ctx, struct maildir *md)
 {
   int oldmsgcount = ctx->msgcount;
 
-  while (md)
-  {
+  while (md) {
 
     dprint (2, (debugfile, "%s:%d maildir_add_to_context(): Considering %s\n",
-               __FILE__, __LINE__, NONULL (md->canon_fname)));
+                __FILE__, __LINE__, NONULL (md->canon_fname)));
 
-    if (md->h)
-    {
+    if (md->h) {
       dprint (2,
-             (debugfile,
-              "%s:%d Adding header structure. Flags: %s%s%s%s%s\n", __FILE__,
-              __LINE__, md->h->flagged ? "f" : "", md->h->deleted ? "D" : "",
-              md->h->replied ? "r" : "", md->h->old ? "O" : "",
-              md->h->read ? "R" : ""));
+              (debugfile,
+               "%s:%d Adding header structure. Flags: %s%s%s%s%s\n", __FILE__,
+               __LINE__, md->h->flagged ? "f" : "", md->h->deleted ? "D" : "",
+               md->h->replied ? "r" : "", md->h->old ? "O" : "",
+               md->h->read ? "R" : ""));
       if (ctx->msgcount == ctx->hdrmax)
-       mx_alloc_memory (ctx);
+        mx_alloc_memory (ctx);
 
       ctx->hdrs[ctx->msgcount] = md->h;
       ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
       ctx->size +=
-       md->h->content->length + md->h->content->offset -
-       md->h->content->hdr_offset;
+        md->h->content->length + md->h->content->offset -
+        md->h->content->hdr_offset;
 
       md->h = NULL;
       ctx->msgcount++;
@@ -772,8 +731,7 @@ static int maildir_add_to_context (CONTEXT * ctx, struct maildir *md)
     md = md->next;
   }
 
-  if (ctx->msgcount > oldmsgcount)
-  {
+  if (ctx->msgcount > oldmsgcount) {
     mx_update_context (ctx, ctx->msgcount - oldmsgcount);
     return 1;
   }
@@ -783,6 +741,7 @@ static int maildir_add_to_context (CONTEXT * ctx, struct maildir *md)
 static int maildir_move_to_context (CONTEXT * ctx, struct maildir **md)
 {
   int r;
+
   r = maildir_add_to_context (ctx, *md);
   maildir_free_maildir (md);
   return r;
@@ -791,56 +750,47 @@ static int maildir_move_to_context (CONTEXT * ctx, struct maildir **md)
 /*
  * Merge two maildir lists according to the inode numbers.
  */
-static struct maildir*  maildir_merge_inode (struct maildir *left,
-                                            struct maildir *right)
+static struct maildir *maildir_merge_inode (struct maildir *left,
+                                            struct maildir *right)
 {
-  struct maildirhead;
-  struct maildirtail;
+  struct maildir *head;
+  struct maildir *tail;
 
-  if (left && right) 
-  {
-    if (left->inode < right->inode)
-    {
+  if (left && right) {
+    if (left->inode < right->inode) {
       head = left;
       left = left->next;
     }
-    else 
-    {
+    else {
       head = right;
       right = right->next;
     }
-  } 
-  else 
-  {
-    if (left) 
+  }
+  else {
+    if (left)
       return left;
-    else 
+    else
       return right;
   }
-    
+
   tail = head;
 
-  while (left && right) 
-  {
-    if (left->inode < right->inode) 
-    {
+  while (left && right) {
+    if (left->inode < right->inode) {
       tail->next = left;
       left = left->next;
-    } 
-    else 
-    {
+    }
+    else {
       tail->next = right;
       right = right->next;
     }
     tail = tail->next;
   }
 
-  if (left) 
-  {
+  if (left) {
     tail->next = left;
   }
-  else
-  {
+  else {
     tail->next = right;
   }
 
@@ -850,19 +800,17 @@ static struct maildir*  maildir_merge_inode (struct maildir *left,
 /*
  * Sort maildir list according to inode.
  */
-static struct maildir* maildir_sort_inode(struct maildir* list)
+static struct maildir *maildir_sort_inode (struct maildir *list)
 {
-  struct maildirleft = list;
-  struct maildirright = list;
+  struct maildir *left = list;
+  struct maildir *right = list;
 
-  if (!list || !list->next) 
-  {
+  if (!list || !list->next) {
     return list;
   }
 
   list = list->next;
-  while (list && list->next) 
-  {
+  while (list && list->next) {
     right = right->next;
     list = list->next->next;
   }
@@ -871,16 +819,17 @@ static struct maildir* maildir_sort_inode(struct maildir* list)
   right = right->next;
   list->next = 0;
 
-  left = maildir_sort_inode(left);
-  right = maildir_sort_inode(right);
-  return maildir_merge_inode(left, right);
+  left = maildir_sort_inode (left);
+  right = maildir_sort_inode (right);
+  return maildir_merge_inode (left, right);
 }
 
 #if USE_HCACHE
 static size_t maildir_hcache_keylen (const char *fn)
 {
-  const char * p = strchr (fn, ':');
-  return p ? (size_t) (p - fn) : mutt_strlen(fn);
+  const char *p = strchr (fn, ':');
+
+  return p ? (size_t) (p - fn) : mutt_strlen (fn);
 }
 #endif
 
@@ -904,14 +853,13 @@ void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
   hc = mutt_hcache_open (HeaderCache, ctx->path);
 #endif
 
-  for (p = md, count = 0; p; p = p->next, count++)
-  {
-    if (! (p && p->h && !p->header_parsed))
-       continue;
+  for (p = md, count = 0; p; p = p->next, count++) {
+    if (!(p && p->h && !p->header_parsed))
+      continue;
 
 #if USE_HCACHE
-    data      = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen);
-    when      = (struct timeval *) data;
+    data = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen);
+    when = (struct timeval *) data;
 #endif
 
     if (!ctx->quiet && ReadInc && ((count % ReadInc) == 0 || count == 1))
@@ -919,30 +867,31 @@ void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
     snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path);
 
 #if USE_HCACHE
-    if (option(OPTHCACHEVERIFY)) {
-      ret = stat(fn, &lastchanged);
-    } else {
+    if (option (OPTHCACHEVERIFY)) {
+      ret = stat (fn, &lastchanged);
+    }
+    else {
       lastchanged.st_mtime = 0;
       ret = 0;
     }
 
-    if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec)
-    {
-      p->h = mutt_hcache_restore ((unsigned char *)data, &p->h);
+    if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) {
+      p->h = mutt_hcache_restore ((unsigned char *) data, &p->h);
       maildir_parse_flags (p->h, fn);
-    } else
+    }
+    else
 #endif
-    if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h))
-    {
+    if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) {
       p->header_parsed = 1;
       maildir_parse_flags (p->h, fn);
 #if USE_HCACHE
       mutt_hcache_store (hc, p->h->path + 3, p->h, 0, &maildir_hcache_keylen);
 #endif
-    } else
+    }
+    else
       mutt_free_header (&p->h);
 #if USE_HCACHE
-    FREE(&data);
+    FREE (&data);
 #endif
   }
 #if USE_HCACHE
@@ -975,14 +924,13 @@ int mh_read_dir (CONTEXT * ctx, const char *subdir)
   if (maildir_parse_dir (ctx, &last, subdir, &count) == -1)
     return -1;
 
-  if (ctx->magic == M_MH)
-  {
+  if (ctx->magic == M_MH) {
     mh_read_sequences (&mhs, ctx->path);
     mh_update_maildir (md, &mhs);
     mhs_free_sequences (&mhs);
   }
 
-  md = maildir_sort_inode(md);
+  md = maildir_sort_inode (md);
 
   if (ctx->magic == M_MAILDIR)
     maildir_delayed_parsing (ctx, md);
@@ -1014,7 +962,7 @@ int mh_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
 
 int ch_compar (const void *a, const void *b)
 {
-  return (int)*((const char *) a) - *((const char *) b));
+  return (int) (*((const char *) a) - *((const char *) b));
 }
 
 static void maildir_flags (char *dest, size_t destlen, HEADER * hdr)
@@ -1028,16 +976,18 @@ static void maildir_flags (char *dest, size_t destlen, HEADER * hdr)
    * will end up in the cur directory, so we include it in the following
    * test even though there is no associated flag.
    */
-  
-  if (hdr && (hdr->flagged || hdr->replied || hdr->read || hdr->deleted || hdr->old || hdr->maildir_flags))
-  {
+
+  if (hdr
+      && (hdr->flagged || hdr->replied || hdr->read || hdr->deleted
+          || hdr->old || hdr->maildir_flags)) {
     char tmp[LONG_STRING];
+
     snprintf (tmp, sizeof (tmp),
-             "%s%s%s%s%s",
-             hdr->flagged ? "F" : "",
-             hdr->replied ? "R" : "",
-             hdr->read ? "S" : "", hdr->deleted ? "T" : "",
-             NONULL(hdr->maildir_flags));
+              "%s%s%s%s%s",
+              hdr->flagged ? "F" : "",
+              hdr->replied ? "R" : "",
+              hdr->read ? "S" : "", hdr->deleted ? "T" : "",
+              NONULL (hdr->maildir_flags));
     if (hdr->maildir_flags)
       qsort (tmp, strlen (tmp), 1, ch_compar);
     snprintf (dest, destlen, ":2,%s", tmp);
@@ -1060,9 +1010,9 @@ int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
   char suffix[16];
   char subdir[16];
 
-  if (hdr)
-  {
+  if (hdr) {
     short deleted = hdr->deleted;
+
     hdr->deleted = 0;
 
     maildir_flags (suffix, sizeof (suffix), hdr);
@@ -1077,34 +1027,29 @@ int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
   else
     strfcpy (subdir, "new", sizeof (subdir));
 
-  FOREVER
-  {
+  FOREVER {
     snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s",
-             dest->path, subdir, (long) time (NULL), (unsigned int)getpid (),
-             Counter++, NONULL (Hostname), suffix);
+              dest->path, subdir, (long) time (NULL),
+              (unsigned int) getpid (), Counter++, NONULL (Hostname), suffix);
 
     dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
-               path));
-
-    umask(Umask);
-    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
-    {
-      if (errno != EEXIST)
-      {
-       mutt_perror (path);
-       return -1;
+                path));
+
+    umask (Umask);
+    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
+      if (errno != EEXIST) {
+        mutt_perror (path);
+        return -1;
       }
     }
-    else
-    {
+    else {
       dprint (2, (debugfile, "maildir_open_new_message (): Success.\n"));
       msg->path = safe_strdup (path);
       break;
     }
   }
 
-  if ((msg->fp = fdopen (fd, "w")) == NULL)
-  {
+  if ((msg->fp = fdopen (fd, "w")) == NULL) {
     FREE (&msg->path);
     close (fd);
     unlink (path);
@@ -1159,20 +1104,18 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
     suffix[0] = '\0';
 
   /* construct a new file name. */
-  FOREVER
-  {
+  FOREVER {
     snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir,
-             (long) time (NULL), (unsigned int)getpid (), Counter++, 
-             NONULL (Hostname), suffix);
+              (long) time (NULL), (unsigned int) getpid (), Counter++,
+              NONULL (Hostname), suffix);
     snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
 
     dprint (2, (debugfile, "maildir_commit_message (): renaming %s to %s.\n",
-               msg->path, full));
+                msg->path, full));
 
-    if (safe_rename (msg->path, full) == 0)
-    {
+    if (safe_rename (msg->path, full) == 0) {
       if (hdr)
-       mutt_str_replace (&hdr->path, path);
+        mutt_str_replace (&hdr->path, path);
       FREE (&msg->path);
 
       /*
@@ -1181,23 +1124,21 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
        * messages between mailboxes, so we test to ensure that it is
        * actually set.
        */
-      if (msg->received)
-      {
-       struct utimbuf ut;
-
-       ut.actime = msg->received;
-       ut.modtime = msg->received;
-       if (utime (full, &ut))
-       {
-         mutt_perror (_("maildir_commit_message(): unable to set time on file"));
-         return -1;
-       }
+      if (msg->received) {
+        struct utimbuf ut;
+
+        ut.actime = msg->received;
+        ut.modtime = msg->received;
+        if (utime (full, &ut)) {
+          mutt_perror (_
+                       ("maildir_commit_message(): unable to set time on file"));
+          return -1;
+        }
       }
 
       return 0;
     }
-    else if (errno != EEXIST)
-    {
+    else if (errno != EEXIST) {
       mutt_perror (ctx->path);
       return -1;
     }
@@ -1211,7 +1152,7 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
 
 
 static int _mh_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr,
-                              short updseq)
+                               short updseq)
 {
   DIR *dirp;
   struct dirent *de;
@@ -1223,30 +1164,26 @@ static int _mh_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr,
   if (safe_fclose (&msg->fp) != 0)
     return -1;
 
-  if ((dirp = opendir (ctx->path)) == NULL)
-  {
+  if ((dirp = opendir (ctx->path)) == NULL) {
     mutt_perror (ctx->path);
     return (-1);
   }
 
   /* figure out what the next message number is */
-  while ((de = readdir (dirp)) != NULL)
-  {
+  while ((de = readdir (dirp)) != NULL) {
     dep = de->d_name;
     if (*dep == ',')
       dep++;
     cp = dep;
-    while (*cp)
-    {
+    while (*cp) {
       if (!isdigit ((unsigned char) *cp))
-       break;
+        break;
       cp++;
     }
-    if (!*cp)
-    {
+    if (!*cp) {
       n = atoi (dep);
       if (n > hi)
-       hi = n;
+        hi = n;
     }
   }
   closedir (dirp);
@@ -1258,27 +1195,24 @@ static int _mh_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr,
    * slot.
    */
 
-  FOREVER
-  {
+  FOREVER {
     hi++;
     snprintf (tmp, sizeof (tmp), "%d", hi);
     snprintf (path, sizeof (path), "%s/%s", ctx->path, tmp);
-    if (safe_rename (msg->path, path) == 0)
-    {
+    if (safe_rename (msg->path, path) == 0) {
       if (hdr)
-       mutt_str_replace (&hdr->path, tmp);
+        mutt_str_replace (&hdr->path, tmp);
       FREE (&msg->path);
       break;
     }
-    else if (errno != EEXIST)
-    {
+    else if (errno != EEXIST) {
       mutt_perror (ctx->path);
       return -1;
     }
   }
   if (updseq)
     mh_sequences_add_one (ctx, hi, !msg->flags.read, msg->flags.flagged,
-                         msg->flags.replied);
+                          msg->flags.replied);
   return 0;
 }
 
@@ -1313,7 +1247,7 @@ static int mh_rewrite_message (CONTEXT * ctx, int msgno)
     return -1;
 
   if ((rc = mutt_copy_message (dest->fp, ctx, h,
-                              M_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0)
+                               M_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN)) == 0)
   {
     snprintf (oldpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
     strfcpy (partpath, h->path, _POSIX_PATH_MAX);
@@ -1325,8 +1259,7 @@ static int mh_rewrite_message (CONTEXT * ctx, int msgno)
 
     mx_close_message (&dest);
 
-    if (rc == 0)
-    {
+    if (rc == 0) {
       unlink (oldpath);
       restore = 0;
     }
@@ -1346,18 +1279,16 @@ static int mh_rewrite_message (CONTEXT * ctx, int msgno)
      * lose flag modifications.
      */
 
-    if (ctx->magic == M_MH && rc == 0)
-    {
+    if (ctx->magic == M_MH && rc == 0) {
       snprintf (newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path);
       if ((rc = safe_rename (newpath, oldpath)) == 0)
-       mutt_str_replace (&h->path, partpath);
+        mutt_str_replace (&h->path, partpath);
     }
   }
   else
     mx_close_message (&dest);
 
-  if (rc == -1 && restore)
-  {
+  if (rc == -1 && restore) {
     h->content->offset = old_body_offset;
     h->content->length = old_body_length;
     h->lines = old_hdr_lines;
@@ -1382,14 +1313,12 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno)
 {
   HEADER *h = ctx->hdrs[msgno];
 
-  if (h->attach_del || h->refs_changed || h->irt_changed)
-  {
+  if (h->attach_del || h->refs_changed || h->irt_changed) {
     /* when doing attachment deletion/rethreading, fall back to the MH case. */
     if (mh_rewrite_message (ctx, msgno) != 0)
       return (-1);
   }
-  else
-  {
+  else {
     /* we just have to rename the file. */
 
     char newpath[_POSIX_PATH_MAX];
@@ -1399,12 +1328,11 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno)
     char suffix[16];
     char *p;
 
-    if ((p = strrchr (h->path, '/')) == NULL)
-    {
+    if ((p = strrchr (h->path, '/')) == NULL) {
       dprint (1,
-             (debugfile,
-              "maildir_sync_message: %s: unable to find subdir!\n",
-              h->path));
+              (debugfile,
+               "maildir_sync_message: %s: unable to find subdir!\n",
+               h->path));
       return (-1);
     }
     p++;
@@ -1417,12 +1345,11 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno)
     maildir_flags (suffix, sizeof (suffix), h);
 
     snprintf (partpath, sizeof (partpath), "%s/%s%s",
-             (h->read || h->old) ? "cur" : "new", newpath, suffix);
+              (h->read || h->old) ? "cur" : "new", newpath, suffix);
     snprintf (fullpath, sizeof (fullpath), "%s/%s", ctx->path, partpath);
     snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path);
 
-    if (mutt_strcmp (fullpath, oldpath) == 0)
-    {
+    if (mutt_strcmp (fullpath, oldpath) == 0) {
       /* message hasn't really changed */
       return 0;
     }
@@ -1430,8 +1357,7 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno)
     /* record that the message is possibly marked as trashed on disk */
     h->trash = h->deleted;
 
-    if (rename (oldpath, fullpath) != 0)
-    {
+    if (rename (oldpath, fullpath) != 0) {
       mutt_perror ("rename");
       return (-1);
     }
@@ -1444,65 +1370,59 @@ int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
 {
   char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX];
   int i, j;
+
 #if USE_HCACHE
   void *hc = NULL;
 #endif /* USE_HCACHE */
 
   if (ctx->magic == M_MH)
     i = mh_check_mailbox (ctx, index_hint);
-  else 
+  else
     i = maildir_check_mailbox (ctx, index_hint);
-      
+
   if (i != 0)
     return i;
 
 #if USE_HCACHE
   if (ctx->magic == M_MAILDIR)
-    hc = mutt_hcache_open(HeaderCache, ctx->path);
+    hc = mutt_hcache_open (HeaderCache, ctx->path);
 #endif /* USE_HCACHE */
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     if (ctx->hdrs[i]->deleted
-       && (ctx->magic != M_MAILDIR || !option (OPTMAILDIRTRASH)))
-    {
+        && (ctx->magic != M_MAILDIR || !option (OPTMAILDIRTRASH))) {
       snprintf (path, sizeof (path), "%s/%s", ctx->path, ctx->hdrs[i]->path);
       if (ctx->magic == M_MAILDIR
-         || (option (OPTMHPURGE) && ctx->magic == M_MH))
-      {
+          || (option (OPTMHPURGE) && ctx->magic == M_MH)) {
 #if USE_HCACHE
         if (ctx->magic == M_MAILDIR)
-          mutt_hcache_delete (hc, ctx->hdrs[i]->path + 3, &maildir_hcache_keylen);
+          mutt_hcache_delete (hc, ctx->hdrs[i]->path + 3,
+                              &maildir_hcache_keylen);
 #endif /* USE_HCACHE */
-       unlink (path);
+        unlink (path);
       }
-      else if (ctx->magic == M_MH)
-      {
-       /* MH just moves files out of the way when you delete them */
-       if (*ctx->hdrs[i]->path != ',')
-       {
-         snprintf (tmp, sizeof (tmp), "%s/,%s", ctx->path,
-                   ctx->hdrs[i]->path);
-         unlink (tmp);
-         rename (path, tmp);
-       }
+      else if (ctx->magic == M_MH) {
+        /* MH just moves files out of the way when you delete them */
+        if (*ctx->hdrs[i]->path != ',') {
+          snprintf (tmp, sizeof (tmp), "%s/,%s", ctx->path,
+                    ctx->hdrs[i]->path);
+          unlink (tmp);
+          rename (path, tmp);
+        }
 
       }
     }
     else if (ctx->hdrs[i]->changed || ctx->hdrs[i]->attach_del ||
-            (ctx->magic == M_MAILDIR
-             && (option (OPTMAILDIRTRASH) || ctx->hdrs[i]->trash)
-             && (ctx->hdrs[i]->deleted != ctx->hdrs[i]->trash)))
-    {
-      if (ctx->magic == M_MAILDIR)
-      {
-       if (maildir_sync_message (ctx, i) == -1)
-         goto err;
+             (ctx->magic == M_MAILDIR
+              && (option (OPTMAILDIRTRASH) || ctx->hdrs[i]->trash)
+              && (ctx->hdrs[i]->deleted != ctx->hdrs[i]->trash))) {
+      if (ctx->magic == M_MAILDIR) {
+        if (maildir_sync_message (ctx, i) == -1)
+          goto err;
       }
-      else
-      {
-       if (mh_sync_message (ctx, i) == -1)
-         goto err;
+      else {
+        if (mh_sync_message (ctx, i) == -1)
+          goto err;
       }
     }
   }
@@ -1521,13 +1441,11 @@ int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
 
   /* adjust indices */
 
-  if (ctx->deleted)
-  {
-    for (i = 0, j = 0; i < ctx->msgcount; i++)
-    {
+  if (ctx->deleted) {
+    for (i = 0, j = 0; i < ctx->msgcount; i++) {
       if (!ctx->hdrs[i]->deleted
-         || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
-       ctx->hdrs[i]->index = j++;
+          || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
+        ctx->hdrs[i]->index = j++;
     }
   }
 
@@ -1555,26 +1473,24 @@ static char *maildir_canon_filename (char *dest, const char *src, size_t l)
   return dest;
 }
 
-static void maildir_update_tables (CONTEXT *ctx, int *index_hint)
+static void maildir_update_tables (CONTEXT * ctx, int *index_hint)
 {
   short old_sort;
   int old_count;
   int i, j;
-  
-  if (Sort != SORT_ORDER)
-  {
+
+  if (Sort != SORT_ORDER) {
     old_sort = Sort;
     Sort = SORT_ORDER;
     mutt_sort_headers (ctx, 1);
     Sort = old_sort;
   }
-  
+
   old_count = ctx->msgcount;
-  for (i = 0, j = 0; i < old_count; i++)
-  {
+  for (i = 0, j = 0; i < old_count; i++) {
     if (ctx->hdrs[i]->active && index_hint && *index_hint == i)
       *index_hint = j;
-    
+
     if (ctx->hdrs[i]->active)
       ctx->hdrs[i]->index = j++;
   }
@@ -1583,13 +1499,13 @@ static void maildir_update_tables (CONTEXT *ctx, int *index_hint)
   mutt_clear_threads (ctx);
 }
 
-static void maildir_update_flags (CONTEXT *ctx, HEADER *o, HEADER *n)
+static void maildir_update_flags (CONTEXT * ctx, HEADER * o, HEADER * n)
 {
   /* save the global state here so we can reset it at the
    * end of list block if required.
    */
   int context_changed = ctx->changed;
-  
+
   /* user didn't modify this message.  alter the flags to
    * match the current state on disk.  This may not actually
    * do anything, but we can't tell right now.  mutt_set_flag()
@@ -1607,7 +1523,7 @@ static void maildir_update_flags (CONTEXT *ctx, HEADER *o, HEADER *n)
    * message.
    */
   o->changed = 0;
-  
+
   /* if the mailbox was not modified before we made these
    * changes, unset the changed flag since nothing needs to
    * be synchronized.
@@ -1627,18 +1543,18 @@ static void maildir_update_flags (CONTEXT *ctx, HEADER *o, HEADER *n)
  */
 int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
 {
-  struct stat st_new;          /* status of the "new" subdirectory */
-  struct stat st_cur;          /* status of the "cur" subdirectory */
+  struct stat st_new;           /* status of the "new" subdirectory */
+  struct stat st_cur;           /* status of the "cur" subdirectory */
   char buf[_POSIX_PATH_MAX];
-  int changed = 0;             /* bitmask representing which subdirectories
-                                  have changed.  0x1 = new, 0x2 = cur */
-  int occult = 0;              /* messages were removed from the mailbox */
-  int have_new = 0;            /* messages were added to the mailbox */
-  struct maildir *md;          /* list of messages in the mailbox */
+  int changed = 0;              /* bitmask representing which subdirectories
+                                   have changed.  0x1 = new, 0x2 = cur */
+  int occult = 0;               /* messages were removed from the mailbox */
+  int have_new = 0;             /* messages were added to the mailbox */
+  struct maildir *md;           /* list of messages in the mailbox */
   struct maildir **last, *p;
   int i;
-  HASH *fnames;                        /* hash table for quickly looking up the base filename
-                                  for a maildir message */
+  HASH *fnames;                 /* hash table for quickly looking up the base filename
+                                   for a maildir message */
 
   /* XXX seems like this check belongs in mx_check_mailbox()
    * rather than here.
@@ -1661,7 +1577,7 @@ int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
     changed |= 2;
 
   if (!changed)
-    return 0;                  /* nothing to do */
+    return 0;                   /* nothing to do */
 
   /* update the modification times on the mailbox */
   ctx->mtime_cur = st_cur.st_mtime;
@@ -1683,21 +1599,18 @@ int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
    */
   fnames = hash_create (1031);
 
-  for (p = md; p; p = p->next)
-  {
+  for (p = md; p; p = p->next) {
     maildir_canon_filename (buf, p->h->path, sizeof (buf));
     p->canon_fname = safe_strdup (buf);
     hash_insert (fnames, p->canon_fname, p, 0);
   }
 
   /* check for modifications and adjust flags */
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     ctx->hdrs[i]->active = 0;
     maildir_canon_filename (buf, ctx->hdrs[i]->path, sizeof (buf));
     p = hash_find (fnames, buf);
-    if (p && p->h)
-    {
+    if (p && p->h) {
       /* message already exists, merge flags */
       ctx->hdrs[i]->active = 1;
 
@@ -1705,16 +1618,16 @@ int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
        * subdirectory.  If so, update the associated filename.
        */
       if (mutt_strcmp (ctx->hdrs[i]->path, p->h->path))
-       mutt_str_replace (&ctx->hdrs[i]->path, p->h->path);
+        mutt_str_replace (&ctx->hdrs[i]->path, p->h->path);
 
       /* if the user hasn't modified the flags on this message, update
        * the flags we just detected.
        */
       if (!ctx->hdrs[i]->changed)
-       maildir_update_flags (ctx, ctx->hdrs[i], p->h);
+        maildir_update_flags (ctx, ctx->hdrs[i], p->h);
 
       if (ctx->hdrs[i]->deleted == ctx->hdrs[i]->trash)
-       ctx->hdrs[i]->deleted = p->h->deleted;
+        ctx->hdrs[i]->deleted = p->h->deleted;
       ctx->hdrs[i]->trash = p->h->trash;
 
       /* this is a duplicate of an existing header, so remove it */
@@ -1725,16 +1638,14 @@ int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
      * message has disappeared out from underneath us.
      */
     else if (((changed & 1) && (!strncmp (ctx->hdrs[i]->path, "new/", 4))) ||
-            ((changed & 2) && (!strncmp (ctx->hdrs[i]->path, "cur/", 4))))
-    {
+             ((changed & 2) && (!strncmp (ctx->hdrs[i]->path, "cur/", 4)))) {
       /* This message disappeared, so we need to simulate a "reopen"
        * event.  We know it disappeared because we just scanned the
        * subdirectory it used to reside in.
        */
       occult = 1;
     }
-    else
-    {
+    else {
       /* This message resides in a subdirectory which was not
        * modified, so we assume that it is still present and
        * unchanged.
@@ -1749,7 +1660,7 @@ int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
   /* If we didn't just get new mail, update the tables. */
   if (occult)
     maildir_update_tables (ctx, index_hint);
-  
+
   /* do any delayed parsing we need to do. */
   maildir_delayed_parsing (ctx, md);
 
@@ -1787,19 +1698,17 @@ int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
   strfcpy (buf, ctx->path, sizeof (buf));
   if (stat (buf, &st) == -1)
     return -1;
-  
+
   /* create .mh_sequences when there isn't one. */
   snprintf (buf, sizeof (buf), "%s/.mh_sequences", ctx->path);
-  if ((i = stat (buf, &st_cur) == -1) && errno == ENOENT)
-  {
+  if ((i = stat (buf, &st_cur) == -1) && errno == ENOENT) {
     char *tmp;
     FILE *fp = NULL;
-    
-    if (mh_mkstemp (ctx, &fp, &tmp) == 0)
-    {
+
+    if (mh_mkstemp (ctx, &fp, &tmp) == 0) {
       safe_fclose (&fp);
       if (safe_rename (tmp, buf) == -1)
-       unlink (tmp);
+        unlink (tmp);
       FREE (&tmp);
     }
   }
@@ -1817,8 +1726,8 @@ int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
   ctx->mtime = st.st_mtime;
 
   memset (&mhs, 0, sizeof (mhs));
-  
-  md   = NULL;
+
+  md = NULL;
   last = &md;
   maildir_parse_dir (ctx, &last, NULL, NULL);
   mh_read_sequences (&mhs, ctx->path);
@@ -1831,21 +1740,19 @@ int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
   for (p = md; p; p = p->next)
     hash_insert (fnames, p->h->path, p, 0);
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     ctx->hdrs[i]->active = 0;
 
     if ((p = hash_find (fnames, ctx->hdrs[i]->path)) && p->h &&
-       (mbox_strict_cmp_headers (ctx->hdrs[i], p->h)))
-    {
+        (mbox_strict_cmp_headers (ctx->hdrs[i], p->h))) {
       ctx->hdrs[i]->active = 1;
       /* found the right message */
       if (!ctx->hdrs[i]->changed)
-       maildir_update_flags (ctx, ctx->hdrs[i], p->h);
+        maildir_update_flags (ctx, ctx->hdrs[i], p->h);
 
       mutt_free_header (&p->h);
     }
-    else /* message has disappeared */
+    else                        /* message has disappeared */
       occult = 1;
   }
 
@@ -1873,7 +1780,7 @@ int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
  */
 
 FILE *_maildir_open_find_message (const char *folder, const char *unique,
-                                 const char *subfolder)
+                                  const char *subfolder)
 {
   char dir[_POSIX_PATH_MAX];
   char tunique[_POSIX_PATH_MAX];
@@ -1887,21 +1794,18 @@ FILE *_maildir_open_find_message (const char *folder, const char *unique,
 
   snprintf (dir, sizeof (dir), "%s/%s", folder, subfolder);
 
-  if ((dp = opendir (dir)) == NULL)
-  {
+  if ((dp = opendir (dir)) == NULL) {
     errno = ENOENT;
     return NULL;
   }
 
-  while ((de = readdir (dp)))
-  {
+  while ((de = readdir (dp))) {
     maildir_canon_filename (tunique, de->d_name, sizeof (tunique));
 
-    if (!mutt_strcmp (tunique, unique))
-    {
+    if (!mutt_strcmp (tunique, unique)) {
       snprintf (fname, sizeof (fname), "%s/%s/%s", folder, subfolder,
-               de->d_name);
-      fp = fopen (fname, "r"); /* __FOPEN_CHECKED__ */
+                de->d_name);
+      fp = fopen (fname, "r");  /* __FOPEN_CHECKED__ */
       oe = errno;
       break;
     }
@@ -1918,32 +1822,26 @@ FILE *maildir_open_find_message (const char *folder, const char *msg)
   char unique[_POSIX_PATH_MAX];
   FILE *fp;
 
-  static unsigned int new_hits = 0, cur_hits = 0;      /* simple dynamic optimization */
+  static unsigned int new_hits = 0, cur_hits = 0;       /* simple dynamic optimization */
 
   maildir_canon_filename (unique, msg, sizeof (unique));
 
-  if (
-      (fp =
+  if ((fp =
        _maildir_open_find_message (folder, unique,
-                                  new_hits > cur_hits ? "new" : "cur"))
-      || errno != ENOENT)
-  {
-    if (new_hits < UINT_MAX && cur_hits < UINT_MAX)
-    {
+                                   new_hits > cur_hits ? "new" : "cur"))
+      || errno != ENOENT) {
+    if (new_hits < UINT_MAX && cur_hits < UINT_MAX) {
       new_hits += (new_hits > cur_hits ? 1 : 0);
       cur_hits += (new_hits > cur_hits ? 0 : 1);
     }
 
     return fp;
   }
-  if (
-      (fp =
+  if ((fp =
        _maildir_open_find_message (folder, unique,
-                                  new_hits > cur_hits ? "cur" : "new"))
-      || errno != ENOENT)
-  {
-    if (new_hits < UINT_MAX && cur_hits < UINT_MAX)
-    {
+                                   new_hits > cur_hits ? "cur" : "new"))
+      || errno != ENOENT) {
+    if (new_hits < UINT_MAX && cur_hits < UINT_MAX) {
       new_hits += (new_hits > cur_hits ? 0 : 1);
       cur_hits += (new_hits > cur_hits ? 1 : 0);
     }
@@ -1965,7 +1863,7 @@ int maildir_check_empty (const char *path)
 {
   DIR *dp;
   struct dirent *de;
-  int r = 1; /* assume empty until we find a message */
+  int r = 1;                    /* assume empty until we find a message */
   char realpath[_POSIX_PATH_MAX];
   int iter = 0;
 
@@ -1976,15 +1874,13 @@ int maildir_check_empty (const char *path)
      * find old messages without having to scan both subdirs
      */
     snprintf (realpath, sizeof (realpath), "%s/%s", path,
-             iter == 0 ? "cur" : "new");
+              iter == 0 ? "cur" : "new");
     if ((dp = opendir (realpath)) == NULL)
       return -1;
-    while ((de = readdir (dp)))
-    {
-      if (*de->d_name != '.')
-      {
-       r = 0;
-       break;
+    while ((de = readdir (dp))) {
+      if (*de->d_name != '.') {
+        r = 0;
+        break;
       }
     }
     closedir (dp);
@@ -2004,19 +1900,17 @@ int mh_check_empty (const char *path)
 {
   DIR *dp;
   struct dirent *de;
-  int r = 1; /* assume empty until we find a message */
-  
+  int r = 1;                    /* assume empty until we find a message */
+
   if ((dp = opendir (path)) == NULL)
     return -1;
-  while ((de = readdir (dp)))
-  {
-    if (mh_valid_message (de->d_name))
-    {
+  while ((de = readdir (dp))) {
+    if (mh_valid_message (de->d_name)) {
       r = 0;
       break;
     }
   }
   closedir (dp);
-  
+
   return r;
 }
diff --git a/mime.h b/mime.h
index ebef53e..d6ea496 100644 (file)
--- a/mime.h
+++ b/mime.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* Content-Type */
-enum
-{
+enum {
   TYPEOTHER,
   TYPEAUDIO,
   TYPEAPPLICATION,
@@ -31,8 +30,7 @@ enum
 };
 
 /* Content-Transfer-Encoding */
-enum
-{
+enum {
   ENCOTHER,
   ENC7BIT,
   ENC8BIT,
@@ -43,8 +41,7 @@ enum
 };
 
 /* Content-Disposition values */
-enum
-{
+enum {
   DISPINLINE,
   DISPATTACH,
   DISPFORMDATA
diff --git a/mutt.h b/mutt.h
index 72316f0..4896e5d 100644 (file)
--- a/mutt.h
+++ b/mutt.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef MUTT_H
-#define MUTT_H 
+#define MUTT_H
 
 #include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_UNISTD_H
-# include <unistd.h> /* needed for SEEK_SET */
+# include <unistd.h>            /* needed for SEEK_SET */
 #endif
 #ifdef HAVE_UNIX_H
-# include <unix.h>   /* needed for snprintf on QNX. */
+# include <unix.h>              /* needed for snprintf on QNX. */
 #endif
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #ifdef SUBVERSION
 # define MUTT_VERSION (VERSION SUBVERSION)
-#else  
+#else
 # define MUTT_VERSION (VERSION)
 #endif
 
 /* nifty trick I stole from ELM 2.5alpha. */
 #ifdef MAIN_C
-#define WHERE 
+#define WHERE
 #define INITVAL(x) = x
 #else
 #define WHERE extern
-#define INITVAL(x) 
+#define INITVAL(x)
 #endif
 
 #include "mutt_regex.h"
 
 /* flags for mutt_copy_header() */
-#define CH_UPDATE      1      /* update the status and x-status fields? */
-#define CH_WEED                (1<<1) /* weed the headers? */
-#define CH_DECODE      (1<<2) /* do RFC1522 decoding? */
-#define CH_XMIT                (1<<3) /* transmitting this message? */
-#define CH_FROM                (1<<4) /* retain the "From " message separator? */
-#define CH_PREFIX      (1<<5) /* use Prefix string? */
-#define CH_NOSTATUS    (1<<6) /* supress the status and x-status fields */
-#define CH_REORDER     (1<<7) /* Re-order output of headers */
-#define CH_NONEWLINE   (1<<8) /* don't output terminating newline */
-#define CH_MIME                (1<<9) /* ignore MIME fields */
+#define CH_UPDATE      1       /* update the status and x-status fields? */
+#define CH_WEED                (1<<1)  /* weed the headers? */
+#define CH_DECODE      (1<<2)  /* do RFC1522 decoding? */
+#define CH_XMIT                (1<<3)  /* transmitting this message? */
+#define CH_FROM                (1<<4)  /* retain the "From " message separator? */
+#define CH_PREFIX      (1<<5)  /* use Prefix string? */
+#define CH_NOSTATUS    (1<<6)  /* supress the status and x-status fields */
+#define CH_REORDER     (1<<7)  /* Re-order output of headers */
+#define CH_NONEWLINE   (1<<8)  /* don't output terminating newline */
+#define CH_MIME                (1<<9)  /* ignore MIME fields */
 #define CH_UPDATE_LEN  (1<<10) /* update Lines: and Content-Length: */
 #define CH_TXTPLAIN    (1<<11) /* generate text/plain MIME headers */
 #define CH_NOLEN       (1<<12) /* don't write Content-Length: and Lines: */
-#define CH_WEED_DELIVERED (1<<13) /* weed eventual Delivered-To headers */
-#define CH_FORCE_FROM  (1<<14) /* give CH_FROM precedence over CH_WEED? */
-#define CH_NOQFROM     (1<<15) /* give CH_FROM precedence over CH_WEED? */
+#define CH_WEED_DELIVERED (1<<13)       /* weed eventual Delivered-To headers */
+#define CH_FORCE_FROM  (1<<14) /* give CH_FROM precedence over CH_WEED? */
+#define CH_NOQFROM     (1<<15) /* give CH_FROM precedence over CH_WEED? */
 #define CH_UPDATE_IRT  (1<<16) /* update In-Reply-To: */
 #define CH_UPDATE_REFS (1<<17) /* update References: */
 
 /* flags for mutt_enter_string() */
-#define  M_ALIAS   1      /* do alias "completion" by calling up the alias-menu */
-#define  M_FILE    (1<<1) /* do file completion */
-#define  M_EFILE   (1<<2) /* do file completion, plus incoming folders */
-#define  M_CMD     (1<<3) /* do completion on previous word */
-#define  M_PASS    (1<<4) /* password mode (no echo) */
-#define  M_CLEAR   (1<<5) /* clear input if printable character is pressed */
-#define  M_COMMAND (1<<6) /* do command completion */
-#define  M_PATTERN (1<<7) /* pattern mode - only used for history classes */
-#define  M_LASTFOLDER (1<<8) /* last-folder mode - hack hack hack */
+#define  M_ALIAS   1            /* do alias "completion" by calling up the alias-menu */
+#define  M_FILE    (1<<1)       /* do file completion */
+#define  M_EFILE   (1<<2)       /* do file completion, plus incoming folders */
+#define  M_CMD     (1<<3)       /* do completion on previous word */
+#define  M_PASS    (1<<4)       /* password mode (no echo) */
+#define  M_CLEAR   (1<<5)       /* clear input if printable character is pressed */
+#define  M_COMMAND (1<<6)       /* do command completion */
+#define  M_PATTERN (1<<7)       /* pattern mode - only used for history classes */
+#define  M_LASTFOLDER (1<<8)    /* last-folder mode - hack hack hack */
 
 /* flags for mutt_get_token() */
-#define M_TOKEN_EQUAL          1       /* treat '=' as a special */
-#define M_TOKEN_CONDENSE       (1<<1)  /* ^(char) to control chars (macros) */
+#define M_TOKEN_EQUAL          1       /* treat '=' as a special */
+#define M_TOKEN_CONDENSE       (1<<1)  /* ^(char) to control chars (macros) */
 #define M_TOKEN_SPACE          (1<<2)  /* don't treat whitespace as a term */
-#define M_TOKEN_QUOTE          (1<<3)  /* don't interpret quotes */
-#define M_TOKEN_PATTERN                (1<<4)  /* !)|~ are terms (for patterns) */
-#define M_TOKEN_COMMENT                (1<<5)  /* don't reap comments */
-#define M_TOKEN_SEMICOLON      (1<<6)  /* don't treat ; as special */
+#define M_TOKEN_QUOTE          (1<<3)  /* don't interpret quotes */
+#define M_TOKEN_PATTERN                (1<<4)  /* !)|~ are terms (for patterns) */
+#define M_TOKEN_COMMENT                (1<<5)  /* don't reap comments */
+#define M_TOKEN_SEMICOLON      (1<<6)  /* don't treat ; as special */
 
 /* flags for km_dokey() */
-#define M_KM_UNBUFFERED 1 /* don't read from the key buffer */
-
-typedef struct
-{
-  char *data;  /* pointer to data */
-  char *dptr;  /* current read/write position */
-  size_t dsize;        /* length of data */
-  int destroy; /* destroy `data' when done? */
+#define M_KM_UNBUFFERED 1       /* don't read from the key buffer */
+
+typedef struct {
+  char *data;                   /* pointer to data */
+  char *dptr;                   /* current read/write position */
+  size_t dsize;                 /* length of data */
+  int destroy;                  /* destroy `data' when done? */
 } BUFFER;
 
-typedef struct
-{
-  int ch; /* raw key pressed */
-  int op; /* function op */
+typedef struct {
+  int ch;                       /* raw key pressed */
+  int op;                       /* function op */
 } event_t;
 
 /* flags for _mutt_system() */
-#define M_DETACH_PROCESS       1       /* detach subprocess from group */
+#define M_DETACH_PROCESS       1       /* detach subprocess from group */
 
 /* flags for mutt_FormatString() */
-typedef enum
-{
-  M_FORMAT_FORCESUBJ   = (1<<0), /* print the subject even if unchanged */
-  M_FORMAT_TREE                = (1<<1), /* draw the thread tree */
-  M_FORMAT_MAKEPRINT   = (1<<2), /* make sure that all chars are printable */
-  M_FORMAT_OPTIONAL    = (1<<3),
-  M_FORMAT_STAT_FILE   = (1<<4), /* used by mutt_attach_fmt */
-  M_FORMAT_ARROWCURSOR = (1<<5), /* reserve space for arrow_cursor */
-  M_FORMAT_INDEX       = (1<<6)  /* this is a main index entry */
+typedef enum {
+  M_FORMAT_FORCESUBJ = (1 << 0),        /* print the subject even if unchanged */
+  M_FORMAT_TREE = (1 << 1),     /* draw the thread tree */
+  M_FORMAT_MAKEPRINT = (1 << 2),        /* make sure that all chars are printable */
+  M_FORMAT_OPTIONAL = (1 << 3),
+  M_FORMAT_STAT_FILE = (1 << 4),        /* used by mutt_attach_fmt */
+  M_FORMAT_ARROWCURSOR = (1 << 5),      /* reserve space for arrow_cursor */
+  M_FORMAT_INDEX = (1 << 6)     /* this is a main index entry */
 } format_flag;
 
 /* types for mutt_add_hook() */
@@ -192,8 +189,7 @@ typedef enum
 #define M_THREAD_UNREAD                (1<<3)
 #define M_THREAD_NEXT_UNREAD   (1<<4)
 
-enum
-{
+enum {
   /* modes for mutt_view_attachment() */
   M_REGULAR = 1,
   M_MAILCAP,
@@ -255,7 +251,7 @@ enum
 #ifdef USE_NNTP
   M_NEWSGROUPS,
 #endif
-  
+
   /* Options for Mailcap lookup */
   M_EDIT,
   M_COMPOSE,
@@ -274,8 +270,7 @@ enum
 };
 
 /* possible arguments to set_quadoption() */
-enum
-{
+enum {
   M_NO,
   M_YES,
   M_ASKNO,
@@ -283,8 +278,7 @@ enum
 };
 
 /* quad-option vars */
-enum
-{
+enum {
   OPT_ABORT,
   OPT_BOUNCE,
   OPT_COPY,
@@ -298,7 +292,7 @@ enum
   OPT_MIMEFWD,
   OPT_MIMEFWDREST,
   OPT_MOVE,
-  OPT_PGPMIMEAUTO,     /* ask to revert to PGP/MIME when inline fails */
+  OPT_PGPMIMEAUTO,              /* ask to revert to PGP/MIME when inline fails */
 #ifdef USE_POP
   OPT_POPDELETE,
   OPT_POPRECONNECT,
@@ -312,15 +306,15 @@ enum
   OPT_SSLSTARTTLS,
 #endif
   OPT_SUBJECT,
-  OPT_VERIFYSIG,      /* verify PGP signatures */
+  OPT_VERIFYSIG,                /* verify PGP signatures */
   OPT_LISTREPLY,
 #ifdef USE_NNTP
   OPT_TOMODERATED,
   OPT_NNTPRECONNECT,
   OPT_CATCHUP,
   OPT_FOLLOWUPTOPOSTER,
-#endif /* USE_NNTP */
-    
+#endif                          /* USE_NNTP */
+
   /* THIS MUST BE THE LAST VALUE. */
   OPT_MAX
 };
@@ -347,8 +341,7 @@ enum
 #define M_NOSPAM        2
 
 /* boolean vars */
-enum
-{
+enum {
   OPTALLOW8BIT,
   OPTALLOWANSI,
   OPTARROWCURSOR,
@@ -421,14 +414,14 @@ enum
   OPTMARKERS,
   OPTMARKOLD,
   OPTMBOXPANE,
-  OPTMENUSCROLL,       /* scroll menu instead of implicit next-page */
+  OPTMENUSCROLL,                /* scroll menu instead of implicit next-page */
   OPTMENUMOVEOFF,
-  OPTMETAKEY,          /* interpret ALT-x as ESC-x */
+  OPTMETAKEY,                   /* interpret ALT-x as ESC-x */
   OPTMETOO,
   OPTMHPURGE,
   OPTMIMEFORWDECODE,
 #ifdef USE_NNTP
-  OPTMIMESUBJECT,      /* encode subject line with RFC2047 */
+  OPTMIMESUBJECT,               /* encode subject line with RFC2047 */
 #endif
   OPTNARROWTREE,
   OPTPAGERSTOP,
@@ -483,14 +476,14 @@ enum
   OPTWEED,
   OPTWRAP,
   OPTWRAPSEARCH,
-  OPTWRITEBCC,         /* write out a bcc header? */
+  OPTWRITEBCC,                  /* write out a bcc header? */
   OPTXMAILER,
   OPTXTERMSETTITLES,
 
   OPTCRYPTUSEGPGME,
 
   /* PGP options */
-  
+
   OPTCRYPTAUTOSIGN,
   OPTCRYPTAUTOENCRYPT,
   OPTCRYPTAUTOPGP,
@@ -524,45 +517,45 @@ enum
   OPTSAVEUNSUB,
   OPTLOADDESC,
   OPTXCOMMENTTO,
-#endif /* USE_NNTP */
+#endif                          /* USE_NNTP */
 
   /* pseudo options */
 
-  OPTAUXSORT,          /* (pseudo) using auxillary sort function */
-  OPTFORCEREFRESH,     /* (pseudo) refresh even during macros */
-  OPTLOCALES,          /* (pseudo) set if user has valid locale definition */
-  OPTNOCURSES,         /* (pseudo) when sending in batch mode */
-  OPTNEEDREDRAW,       /* (pseudo) to notify caller of a submenu */
-  OPTSEARCHREVERSE,    /* (pseudo) used by ci_search_command */
-  OPTMSGERR,           /* (pseudo) used by mutt_error/mutt_message */
-  OPTSEARCHINVALID,    /* (pseudo) used to invalidate the search pat */
-  OPTSIGNALSBLOCKED,   /* (pseudo) using by mutt_block_signals () */
-  OPTSYSSIGNALSBLOCKED,        /* (pseudo) using by mutt_block_signals_system () */
-  OPTNEEDRESORT,       /* (pseudo) used to force a re-sort */
-  OPTRESORTINIT,       /* (pseudo) used to force the next resort to be from scratch */
-  OPTVIEWATTACH,       /* (pseudo) signals that we are viewing attachments */
-  OPTFORCEREDRAWINDEX, /* (pseudo) used to force a redraw in the main index */
-  OPTFORCEREDRAWPAGER, /* (pseudo) used to force a redraw in the pager */
-  OPTSORTSUBTHREADS,   /* (pseudo) used when $sort_aux changes */
-  OPTNEEDRESCORE,      /* (pseudo) set when the `score' command is used */
-  OPTATTACHMSG,                /* (pseudo) used by attach-message */
-  OPTHIDEREAD,         /* (pseudo) whether or not hide read messages */
-  OPTKEEPQUIET,                /* (pseudo) shut up the message and refresh
-                        *          functions while we are executing an
-                        *          external program.
-                        */
-  OPTMENUCALLER,       /* (pseudo) tell menu to give caller a take */
-  OPTREDRAWTREE,       /* (pseudo) redraw the thread tree */
-  OPTPGPCHECKTRUST,    /* (pseudo) used by pgp_select_key () */
-  OPTDONTHANDLEPGPKEYS,        /* (pseudo) used to extract PGP keys */
-  OPTUNBUFFEREDINPUT,   /* (pseudo) don't use key buffer */
+  OPTAUXSORT,                   /* (pseudo) using auxillary sort function */
+  OPTFORCEREFRESH,              /* (pseudo) refresh even during macros */
+  OPTLOCALES,                   /* (pseudo) set if user has valid locale definition */
+  OPTNOCURSES,                  /* (pseudo) when sending in batch mode */
+  OPTNEEDREDRAW,                /* (pseudo) to notify caller of a submenu */
+  OPTSEARCHREVERSE,             /* (pseudo) used by ci_search_command */
+  OPTMSGERR,                    /* (pseudo) used by mutt_error/mutt_message */
+  OPTSEARCHINVALID,             /* (pseudo) used to invalidate the search pat */
+  OPTSIGNALSBLOCKED,            /* (pseudo) using by mutt_block_signals () */
+  OPTSYSSIGNALSBLOCKED,         /* (pseudo) using by mutt_block_signals_system () */
+  OPTNEEDRESORT,                /* (pseudo) used to force a re-sort */
+  OPTRESORTINIT,                /* (pseudo) used to force the next resort to be from scratch */
+  OPTVIEWATTACH,                /* (pseudo) signals that we are viewing attachments */
+  OPTFORCEREDRAWINDEX,          /* (pseudo) used to force a redraw in the main index */
+  OPTFORCEREDRAWPAGER,          /* (pseudo) used to force a redraw in the pager */
+  OPTSORTSUBTHREADS,            /* (pseudo) used when $sort_aux changes */
+  OPTNEEDRESCORE,               /* (pseudo) set when the `score' command is used */
+  OPTATTACHMSG,                 /* (pseudo) used by attach-message */
+  OPTHIDEREAD,                  /* (pseudo) whether or not hide read messages */
+  OPTKEEPQUIET,                 /* (pseudo) shut up the message and refresh
+                                 *          functions while we are executing an
+                                 *          external program.
+                                 */
+  OPTMENUCALLER,                /* (pseudo) tell menu to give caller a take */
+  OPTREDRAWTREE,                /* (pseudo) redraw the thread tree */
+  OPTPGPCHECKTRUST,             /* (pseudo) used by pgp_select_key () */
+  OPTDONTHANDLEPGPKEYS,         /* (pseudo) used to extract PGP keys */
+  OPTUNBUFFEREDINPUT,           /* (pseudo) don't use key buffer */
 
 #ifdef USE_NNTP
-  OPTNEWS,             /* (pseudo) used to change reader mode */
-  OPTNEWSSEND,         /* (pseudo) used to change behavior when posting */
-  OPTNEWSCACHE,                /* (pseudo) used to indicate if news cache exist */
+  OPTNEWS,                      /* (pseudo) used to change reader mode */
+  OPTNEWSSEND,                  /* (pseudo) used to change behavior when posting */
+  OPTNEWSCACHE,                 /* (pseudo) used to indicate if news cache exist */
 #endif
-  OPTSHORTENHIERARCHY, /* set when to shorten "hierarchies" in the sidebar */
+  OPTSHORTENHIERARCHY,          /* set when to shorten "hierarchies" in the sidebar */
   OPTSIDEBARNEWMAILONLY,
   OPTMAX
 };
@@ -582,26 +575,23 @@ enum
 #define S_ERR 127
 #define S_BKG 126
 
-typedef struct list_t
-{
+typedef struct list_t {
   char *data;
   struct list_t *next;
 } LIST;
 
-typedef struct rx_list_t
-{
+typedef struct rx_list_t {
   REGEXP *rx;
   struct rx_list_t *next;
 } RX_LIST;
 
-typedef struct spam_list_t
-{
+typedef struct spam_list_t {
   REGEXP *rx;
-  int     nmatch;
-  char   *template;
+  int nmatch;
+  char *template;
   struct spam_list_t *next;
 } SPAM_LIST;
+
 
 #define mutt_new_list() safe_calloc (1, sizeof (LIST))
 #define mutt_new_spam_list() safe_calloc (1, sizeof (SPAM_LIST))
@@ -611,14 +601,14 @@ void mutt_free_rx_list (RX_LIST **);
 void mutt_free_spam_list (SPAM_LIST **);
 LIST *mutt_copy_list (LIST *);
 int mutt_matches_ignore (const char *, LIST *);
+
 /* add an element to a list */
 LIST *mutt_add_list (LIST *, const char *);
 
 void mutt_init (int, LIST *);
 
-typedef struct alias
-{
-  struct alias *self;          /* XXX - ugly hack */
+typedef struct alias {
+  struct alias *self;           /* XXX - ugly hack */
   char *name;
   ADDRESS *addr;
   struct alias *next;
@@ -627,8 +617,7 @@ typedef struct alias
   short num;
 } ALIAS;
 
-typedef struct envelope
-{
+typedef struct envelope {
   ADDRESS *return_path;
   ADDRESS *from;
   ADDRESS *to;
@@ -637,9 +626,9 @@ typedef struct envelope
   ADDRESS *sender;
   ADDRESS *reply_to;
   ADDRESS *mail_followup_to;
-  char *list_post;             /* this stores a mailto URL, or nothing */
+  char *list_post;              /* this stores a mailto URL, or nothing */
   char *subject;
-  char *real_subj;             /* offset of the real subject */
+  char *real_subj;              /* offset of the real subject */
   char *message_id;
   char *supersedes;
   char *date;
@@ -652,200 +641,195 @@ typedef struct envelope
   char *x_comment_to;
 #endif
   BUFFER *spam;
-  LIST *references;            /* message references (in reverse order) */
-  LIST *in_reply_to;           /* in-reply-to header content */
-  LIST *userhdrs;              /* user defined headers */
+  LIST *references;             /* message references (in reverse order) */
+  LIST *in_reply_to;            /* in-reply-to header content */
+  LIST *userhdrs;               /* user defined headers */
 } ENVELOPE;
 
-typedef struct parameter
-{
+typedef struct parameter {
   char *attribute;
   char *value;
   struct parameter *next;
 } PARAMETER;
 
 /* Information that helps in determing the Content-* of an attachment */
-typedef struct content
-{
-  long hibin;              /* 8-bit characters */
-  long lobin;              /* unprintable 7-bit chars (eg., control chars) */
-  long crlf;              /* '\r' and '\n' characters */
-  long ascii;              /* number of ascii chars */
-  long linemax;            /* length of the longest line in the file */
-  unsigned int space : 1;  /* whitespace at the end of lines? */
-  unsigned int binary : 1; /* long lines, or CR not in CRLF pair */
-  unsigned int from : 1;   /* has a line beginning with "From "? */
-  unsigned int dot : 1;    /* has a line consisting of a single dot? */
-  unsigned int cr : 1;     /* has CR, even when in a CRLF pair */
+typedef struct content {
+  long hibin;                   /* 8-bit characters */
+  long lobin;                   /* unprintable 7-bit chars (eg., control chars) */
+  long crlf;                    /* '\r' and '\n' characters */
+  long ascii;                   /* number of ascii chars */
+  long linemax;                 /* length of the longest line in the file */
+  unsigned int space:1;         /* whitespace at the end of lines? */
+  unsigned int binary:1;        /* long lines, or CR not in CRLF pair */
+  unsigned int from:1;          /* has a line beginning with "From "? */
+  unsigned int dot:1;           /* has a line consisting of a single dot? */
+  unsigned int cr:1;            /* has CR, even when in a CRLF pair */
 } CONTENT;
 
-typedef struct body
-{
-  char *xtype;                 /* content-type if x-unknown */
+typedef struct body {
+  char *xtype;                  /* content-type if x-unknown */
   char *subtype;                /* content-type subtype */
   PARAMETER *parameter;         /* parameters of the content-type */
   char *description;            /* content-description */
-  char *form_name;             /* Content-Disposition form-data name param */
+  char *form_name;              /* Content-Disposition form-data name param */
   long hdr_offset;              /* offset in stream where the headers begin.
-                                * this info is used when invoking metamail,
-                                * where we need to send the headers of the
-                                * attachment
-                                */
+                                 * this info is used when invoking metamail,
+                                 * where we need to send the headers of the
+                                 * attachment
+                                 */
   long offset;                  /* offset where the actual data begins */
   long length;                  /* length (in bytes) of attachment */
   char *filename;               /* when sending a message, this is the file
-                                * to which this structure refers
-                                */
-  char *d_filename;            /* filename to be used for the 
-                                * content-disposition header.
-                                * If NULL, filename is used 
-                                * instead.
-                                */
+                                 * to which this structure refers
+                                 */
+  char *d_filename;             /* filename to be used for the 
+                                 * content-disposition header.
+                                 * If NULL, filename is used 
+                                 * instead.
+                                 */
   char *file_charset;           /* charset of attached file */
   CONTENT *content;             /* structure used to store detailed info about
-                                * the content of the attachment.  this is used
-                                * to determine what content-transfer-encoding
-                                * is required when sending mail.
-                                */
+                                 * the content of the attachment.  this is used
+                                 * to determine what content-transfer-encoding
+                                 * is required when sending mail.
+                                 */
   struct body *next;            /* next attachment in the list */
   struct body *parts;           /* parts of a multipart or message/rfc822 */
-  struct header *hdr;          /* header information for message/rfc822 */
-
-  struct attachptr *aptr;      /* Menu information, used in recvattach.c */
-  
-  time_t stamp;                        /* time stamp of last
-                                * encoding update.
-                                */
-  
-  unsigned int type : 4;        /* content-type primary type */
-  unsigned int encoding : 3;    /* content-transfer-encoding */
-  unsigned int disposition : 2; /* content-disposition */
-  unsigned int use_disp : 1;    /* Content-Disposition uses filename= ? */
-  unsigned int unlink : 1;      /* flag to indicate the the file named by
-                                * "filename" should be unlink()ed before
-                                * free()ing this structure
-                                */
-  unsigned int tagged : 1;
-  unsigned int deleted : 1;    /* attachment marked for deletion */
-
-  unsigned int noconv : 1;     /* don't do character set conversion */
-  unsigned int force_charset : 1; 
-                               /* send mode: don't adjust the character
-                                * set when in send-mode.
-                                */
-  unsigned int is_signed_data : 1; /* A lot of MUAs don't indicate
-                                      S/MIME signed-data correctly,
-                                      e.g. they use foo.p7m even for
-                                      the name of signed data.  This
-                                      flag is used to keep track of
-                                      the actual message type.  It
-                                      gets set during the verification
-                                      (which is done if the encryption
-                                      try failed) and check by the
-                                      function to figure the type of
-                                      the message. */
-
-  unsigned int goodsig : 1;    /* good cryptographic signature */
-  unsigned int warnsig : 1;     /* maybe good signature */
-  unsigned int badsig : 1;     /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */
-
-  unsigned int collapsed : 1;  /* used by recvattach */
+  struct header *hdr;           /* header information for message/rfc822 */
+
+  struct attachptr *aptr;       /* Menu information, used in recvattach.c */
+
+  time_t stamp;                 /* time stamp of last
+                                 * encoding update.
+                                 */
+
+  unsigned int type:4;          /* content-type primary type */
+  unsigned int encoding:3;      /* content-transfer-encoding */
+  unsigned int disposition:2;   /* content-disposition */
+  unsigned int use_disp:1;      /* Content-Disposition uses filename= ? */
+  unsigned int unlink:1;        /* flag to indicate the the file named by
+                                 * "filename" should be unlink()ed before
+                                 * free()ing this structure
+                                 */
+  unsigned int tagged:1;
+  unsigned int deleted:1;       /* attachment marked for deletion */
+
+  unsigned int noconv:1;        /* don't do character set conversion */
+  unsigned int force_charset:1;
+  /* send mode: don't adjust the character
+   * set when in send-mode.
+   */
+  unsigned int is_signed_data:1;        /* A lot of MUAs don't indicate
+                                           S/MIME signed-data correctly,
+                                           e.g. they use foo.p7m even for
+                                           the name of signed data.  This
+                                           flag is used to keep track of
+                                           the actual message type.  It
+                                           gets set during the verification
+                                           (which is done if the encryption
+                                           try failed) and check by the
+                                           function to figure the type of
+                                           the message. */
+
+  unsigned int goodsig:1;       /* good cryptographic signature */
+  unsigned int warnsig:1;       /* maybe good signature */
+  unsigned int badsig:1;        /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */
+
+  unsigned int collapsed:1;     /* used by recvattach */
 
 } BODY;
 
-typedef struct header
-{
-  unsigned int security : 11;  /* bit 0-6: flags, bit 7,8: application.
-                                see: crypt.h pgplib.h, smime.h */
-
-  unsigned int mime : 1;               /* has a Mime-Version header? */
-  unsigned int flagged : 1;            /* marked important? */
-  unsigned int tagged : 1;
-  unsigned int appended : 1; /* has been saved */
-  unsigned int purged : 1;   /* bypassing the trash folder */
-  unsigned int deleted : 1;
-  unsigned int changed : 1;
-  unsigned int attach_del : 1;                 /* has an attachment marked for deletion */
-  unsigned int old : 1;
-  unsigned int read : 1;
-  unsigned int expired : 1;            /* already expired? */
-  unsigned int superseded : 1;                 /* got superseded? */
-  unsigned int replied : 1;
-  unsigned int subject_changed : 1;    /* used for threading */
-  unsigned int threaded : 1;           /* used for threading */
-  unsigned int display_subject : 1;    /* used for threading */
-  unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */
-  unsigned int refs_changed : 1; /* References changed to break thread */
-  unsigned int recip_valid : 1;        /* is_recipient is valid */
-  unsigned int active : 1;             /* message is not to be removed */
-  unsigned int trash : 1;              /* message is marked as trashed on disk.
-                                        * This flag is used by the maildir_trash
-                                        * option.
-                                        */
-  
+typedef struct header {
+  unsigned int security:11;     /* bit 0-6: flags, bit 7,8: application.
+                                   see: crypt.h pgplib.h, smime.h */
+
+  unsigned int mime:1;          /* has a Mime-Version header? */
+  unsigned int flagged:1;       /* marked important? */
+  unsigned int tagged:1;
+  unsigned int appended:1;      /* has been saved */
+  unsigned int purged:1;        /* bypassing the trash folder */
+  unsigned int deleted:1;
+  unsigned int changed:1;
+  unsigned int attach_del:1;    /* has an attachment marked for deletion */
+  unsigned int old:1;
+  unsigned int read:1;
+  unsigned int expired:1;       /* already expired? */
+  unsigned int superseded:1;    /* got superseded? */
+  unsigned int replied:1;
+  unsigned int subject_changed:1;       /* used for threading */
+  unsigned int threaded:1;      /* used for threading */
+  unsigned int display_subject:1;       /* used for threading */
+  unsigned int irt_changed:1;   /* In-Reply-To changed to link/break threads */
+  unsigned int refs_changed:1;  /* References changed to break thread */
+  unsigned int recip_valid:1;   /* is_recipient is valid */
+  unsigned int active:1;        /* message is not to be removed */
+  unsigned int trash:1;         /* message is marked as trashed on disk.
+                                 * This flag is used by the maildir_trash
+                                 * option.
+                                 */
+
   /* timezone of the sender of this message */
-  unsigned int zhours : 5;
-  unsigned int zminutes : 6;
-  unsigned int zoccident : 1;
+  unsigned int zhours:5;
+  unsigned int zminutes:6;
+  unsigned int zoccident:1;
 
   /* bits used for caching when searching */
-  unsigned int searched : 1;
-  unsigned int matched : 1;
+  unsigned int searched:1;
+  unsigned int matched:1;
 
   /* the following are used to support collapsing threads  */
-  unsigned int collapsed : 1;  /* is this message part of a collapsed thread? */
-  unsigned int limited : 1;    /* is this message in a limited view?  */
-  size_t num_hidden;           /* number of hidden messages in this view */
-
-  short recipient;             /* user_is_recipient()'s return value, cached */
-  
-  int pair;                    /* color-pair to use when displaying in the index */
-
-  time_t date_sent;            /* time when the message was sent (UTC) */
-  time_t received;             /* time when the message was placed in the mailbox */
-  long offset;                 /* where in the stream does this message begin? */
-  int lines;                   /* how many lines in the body of this message? */
-  int index;                   /* the absolute (unsorted) message number */
-  int msgno;                   /* number displayed to the user */
-  int virtual;                 /* virtual message number */
+  unsigned int collapsed:1;     /* is this message part of a collapsed thread? */
+  unsigned int limited:1;       /* is this message in a limited view?  */
+  size_t num_hidden;            /* number of hidden messages in this view */
+
+  short recipient;              /* user_is_recipient()'s return value, cached */
+
+  int pair;                     /* color-pair to use when displaying in the index */
+
+  time_t date_sent;             /* time when the message was sent (UTC) */
+  time_t received;              /* time when the message was placed in the mailbox */
+  long offset;                  /* where in the stream does this message begin? */
+  int lines;                    /* how many lines in the body of this message? */
+  int index;                    /* the absolute (unsorted) message number */
+  int msgno;                    /* number displayed to the user */
+  int virtual;                  /* virtual message number */
   int score;
-  ENVELOPE *env;               /* envelope information */
-  BODY *content;               /* list of MIME parts */
+  ENVELOPE *env;                /* envelope information */
+  BODY *content;                /* list of MIME parts */
   char *path;
 #ifdef USE_NNTP
   int article_num;
 #endif
-  
-  char *tree;                  /* character string to print thread tree */
+
+  char *tree;                   /* character string to print thread tree */
   struct thread *thread;
 
-  ENVELOPE *new_env;   /* envelope information for rethreading */
+  ENVELOPE *new_env;            /* envelope information for rethreading */
 
 #ifdef MIXMASTER
   LIST *chain;
 #endif
 
 #ifdef USE_POP
-  int refno;                   /* message number on server */
+  int refno;                    /* message number on server */
 #endif
 
 #if defined USE_POP || defined USE_IMAP || defined USE_NNTP
-  void *data;                  /* driver-specific data */
+  void *data;                   /* driver-specific data */
 #endif
-  
-  char *maildir_flags;         /* unknown maildir flags */
+
+  char *maildir_flags;          /* unknown maildir flags */
 } HEADER;
 
-typedef struct thread
-{
-  unsigned int fake_thread : 1;
-  unsigned int duplicate_thread : 1;
-  unsigned int sort_children : 1;
-  unsigned int check_subject : 1;
-  unsigned int visible : 1;
-  unsigned int deep : 1;
-  unsigned int subtree_visible : 2;
-  unsigned int next_subtree_visible : 1;
+typedef struct thread {
+  unsigned int fake_thread:1;
+  unsigned int duplicate_thread:1;
+  unsigned int sort_children:1;
+  unsigned int check_subject:1;
+  unsigned int visible:1;
+  unsigned int deep:1;
+  unsigned int subtree_visible:2;
+  unsigned int next_subtree_visible:1;
   struct thread *parent;
   struct thread *child;
   struct thread *next;
@@ -856,74 +840,71 @@ typedef struct thread
 
 
 /* flag to mutt_pattern_comp() */
-#define M_FULL_MSG     1       /* enable body and header matching */
+#define M_FULL_MSG     1       /* enable body and header matching */
 
 typedef enum {
   M_MATCH_FULL_ADDRESS = 1
 } pattern_exec_flag;
 
-typedef struct pattern_t
-{
+typedef struct pattern_t {
   short op;
   short not;
   short alladdr;
   int min;
   int max;
   struct pattern_t *next;
-  struct pattern_t *child;             /* arguments to logical op */
+  struct pattern_t *child;      /* arguments to logical op */
   regex_t *rx;
 } pattern_t;
 
-typedef struct
-{
+typedef struct {
   char *path;
   FILE *fp;
   time_t mtime;
-  time_t mtime_cur;            /* used with maildir folders */
+  time_t mtime_cur;             /* used with maildir folders */
   off_t size;
   off_t vsize;
   char *pattern;                /* limit pattern string */
   pattern_t *limit_pattern;     /* compiled limit pattern */
   HEADER **hdrs;
-  HEADER *last_tag;            /* last tagged msg. used to link threads */
-  THREAD *tree;                        /* top of thread tree */
-  HASH *id_hash;               /* hash table by msg id */
-  HASH *subj_hash;             /* hash table by subject */
-  HASH *thread_hash;           /* hash table for threading */
-  int *v2r;                    /* mapping from virtual to real msgno */
-  int hdrmax;                  /* number of pointers in hdrs */
-  int msgcount;                        /* number of messages in the mailbox */
-  int vcount;                  /* the number of virtual messages */
-  int tagged;                  /* how many messages are tagged? */
-  int new;                     /* how many new messages? */
-  int unread;                  /* how many unread messages? */
-  int deleted;                 /* how many deleted messages */
+  HEADER *last_tag;             /* last tagged msg. used to link threads */
+  THREAD *tree;                 /* top of thread tree */
+  HASH *id_hash;                /* hash table by msg id */
+  HASH *subj_hash;              /* hash table by subject */
+  HASH *thread_hash;            /* hash table for threading */
+  int *v2r;                     /* mapping from virtual to real msgno */
+  int hdrmax;                   /* number of pointers in hdrs */
+  int msgcount;                 /* number of messages in the mailbox */
+  int vcount;                   /* the number of virtual messages */
+  int tagged;                   /* how many messages are tagged? */
+  int new;                      /* how many new messages? */
+  int unread;                   /* how many unread messages? */
+  int deleted;                  /* how many deleted messages */
   int appended;                 /* how many saved messages? */
-  int flagged;                 /* how many flagged messages */
-  int msgnotreadyet;           /* which msg "new" in pager, -1 if none */
+  int flagged;                  /* how many flagged messages */
+  int msgnotreadyet;            /* which msg "new" in pager, -1 if none */
 #if defined USE_POP || defined USE_IMAP || defined USE_NNTP
-  void *data;                  /* driver specific data */
-#endif /* USE_IMAP */
+  void *data;                   /* driver specific data */
+#endif                          /* USE_IMAP */
 
-  short magic;                 /* mailbox type */
+  short magic;                  /* mailbox type */
 
 #ifdef USE_COMPRESSED
-  void *compressinfo;          /* compressed mbox module private data */
-  char *realpath;              /* path to compressed mailbox */
-#endif /* USE_COMPRESSED */
-
-  unsigned int locked : 1;     /* is the mailbox locked? */
-  unsigned int changed : 1;    /* mailbox has been modified */
-  unsigned int readonly : 1;    /* don't allow changes to the mailbox */
-  unsigned int dontwrite : 1;   /* dont write the mailbox on close */
-  unsigned int append : 1;     /* mailbox is opened in append mode */
-  unsigned int quiet : 1;      /* inhibit status messages? */
-  unsigned int collapsed : 1;   /* are all threads collapsed? */
-  unsigned int closing : 1;    /* mailbox is being closed */
+  void *compressinfo;           /* compressed mbox module private data */
+  char *realpath;               /* path to compressed mailbox */
+#endif                          /* USE_COMPRESSED */
+
+  unsigned int locked:1;        /* is the mailbox locked? */
+  unsigned int changed:1;       /* mailbox has been modified */
+  unsigned int readonly:1;      /* don't allow changes to the mailbox */
+  unsigned int dontwrite:1;     /* dont write the mailbox on close */
+  unsigned int append:1;        /* mailbox is opened in append mode */
+  unsigned int quiet:1;         /* inhibit status messages? */
+  unsigned int collapsed:1;     /* are all threads collapsed? */
+  unsigned int closing:1;       /* mailbox is being closed */
 } CONTEXT;
 
-typedef struct attachptr
-{
+typedef struct attachptr {
   BODY *content;
   int parent_type;
   char *tree;
@@ -931,8 +912,7 @@ typedef struct attachptr
   int num;
 } ATTACHPTR;
 
-typedef struct
-{
+typedef struct {
   FILE *fpin;
   FILE *fpout;
   char *prefix;
@@ -941,25 +921,24 @@ typedef struct
 
 /* used by enter.c */
 
-typedef struct
-{
+typedef struct {
   wchar_t *wbuf;
   size_t wbuflen;
   size_t lastchar;
   size_t curpos;
   size_t begin;
-  int   tabs;
+  int tabs;
 } ENTER_STATE;
 
 /* flags for the STATE struct */
-#define M_DISPLAY      (1<<0) /* output is displayed to the user */
-#define M_VERIFY       (1<<1) /* perform signature verification */
-#define M_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
-#define M_WEED          (1<<3) /* weed headers even when not in display mode */
-#define M_CHARCONV     (1<<4) /* Do character set conversions */
-#define M_PRINTING     (1<<5) /* are we printing? - M_DISPLAY "light" */
-#define M_REPLYING     (1<<6) /* are we replying? */
-#define M_FIRSTDONE    (1<<7) /* the first attachment has been done */
+#define M_DISPLAY      (1<<0)  /* output is displayed to the user */
+#define M_VERIFY       (1<<1)  /* perform signature verification */
+#define M_PENDINGPREFIX (1<<2)  /* prefix to write, but character must follow */
+#define M_WEED          (1<<3)  /* weed headers even when not in display mode */
+#define M_CHARCONV     (1<<4)  /* Do character set conversions */
+#define M_PRINTING     (1<<5)  /* are we printing? - M_DISPLAY "light" */
+#define M_REPLYING     (1<<6)  /* are we replying? */
+#define M_FIRSTDONE    (1<<7)  /* the first attachment has been done */
 
 #define state_set_prefix(s) ((s)->flags |= M_PENDINGPREFIX)
 #define state_reset_prefix(s) ((s)->flags &= ~M_PENDINGPREFIX)
@@ -969,11 +948,11 @@ typedef struct
 void state_mark_attach (STATE *);
 void state_attach_puts (const char *, STATE *);
 void state_prefix_putc (char, STATE *);
-int  state_printf(STATE *, const char *, ...);
+int state_printf (STATE *, const char *, ...);
 
 #include "ascii.h"
 #include "protos.h"
 #include "lib.h"
 #include "globals.h"
 
-#endif /*MUTT_H*/
+#endif /*MUTT_H */
index 6b57382..5e3f617 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
    Common definitions and prototypes for the crypt functions. They are
@@ -25,7 +25,7 @@
 #ifndef MUTT_CRYPT_H
 #define MUTT_CRYPT_H
 
-#include "mutt.h"        /* Need this to declare BODY, ADDRESS. STATE etc. */
+#include "mutt.h"               /* Need this to declare BODY, ADDRESS. STATE etc. */
 /* FIXME: They should be pointer to anonymous structures for better
    information hiding. */
 
 #define BADSIGN    (1 << 3)
 #define PARTSIGN   (1 << 4)
 #define SIGNOPAQUE (1 << 5)
-#define KEYBLOCK   (1 << 6) /* KEY too generic? */
+#define KEYBLOCK   (1 << 6)     /* KEY too generic? */
 #define INLINE     (1 << 7)
 
-#define APPLICATION_PGP    (1 << 8) 
+#define APPLICATION_PGP    (1 << 8)
 #define APPLICATION_SMIME  (1 << 9)
 
 #define PGP_TRADITIONAL_CHECKED (1 << 10)
@@ -48,7 +48,7 @@
 #define PGPENCRYPT  (APPLICATION_PGP | ENCRYPT)
 #define PGPSIGN     (APPLICATION_PGP | SIGN)
 #define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
-#define PGPKEY      (APPLICATION_PGP | KEYBLOCK) 
+#define PGPKEY      (APPLICATION_PGP | KEYBLOCK)
 #define PGPINLINE   (APPLICATION_PGP | INLINE)
 
 #define SMIMEENCRYPT  (APPLICATION_SMIME | ENCRYPT)
@@ -92,8 +92,7 @@
 
 #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
 
-enum pgp_ring
-{
+enum pgp_ring {
   PGP_PUBRING,
   PGP_SECRING
 };
@@ -126,22 +125,22 @@ void convert_to_7bit (BODY *);
 
 
 
-/*-- crypt.c --*/ 
+/*-- crypt.c --*/
 
-/* Print the current time. */ 
-void crypt_current_time(STATE *s, char *app_name);
+/* Print the current time. */
+void crypt_current_time (STATE * s, char *app_name);
 
 /* Check out the type of encryption used and set the cached status
    values if there are any. */
-int crypt_query (BODY *m);
+int crypt_query (BODY * m);
 
 /* Fixme: To be documented. */
-void crypt_extract_keys_from_messages (HEADER *h);
+void crypt_extract_keys_from_messages (HEADER * h);
 
 /* Do a quick check to make sure that we can find all of the
    encryption keys if the user has requested this service. 
    Return the list of keys in KEYLIST. */
-int crypt_get_keys (HEADER *msg, char **keylist);
+int crypt_get_keys (HEADER * msg, char **keylist);
 
 /* Forget a passphrase and display a message. */
 void crypt_forget_passphrase (void);
@@ -151,7 +150,7 @@ int crypt_valid_passphrase (int);
 
 /* Write the message body/part A described by state S to a the given
    TEMPFILE.  */
-int crypt_write_signed(BODY *a, STATE *s, const char *tempf);
+int crypt_write_signed (BODY * a, STATE * s, const char *tempf);
 
 
 
@@ -168,57 +167,58 @@ int crypt_pgp_valid_passphrase (void);
 
 
 /* Decrypt a PGP/MIME message. */
-int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
+int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
 
 /* MIME handler for the application/pgp content-type. */
-void crypt_pgp_application_pgp_handler (BODY *m, STATE *s);
+void crypt_pgp_application_pgp_handler (BODY * m, STATE * s);
 
 /* MIME handler for an PGP/MIME encrypted message. */
-void crypt_pgp_encrypted_handler (BODY *a, STATE *s);
+void crypt_pgp_encrypted_handler (BODY * a, STATE * s);
 
 /* fixme: needs documentation. */
-void crypt_pgp_invoke_getkeys (ADDRESS *addr);
+void crypt_pgp_invoke_getkeys (ADDRESS * addr);
 
 /* Ask for a PGP key. */
 pgp_key_t crypt_pgp_ask_for_key (char *tag, char *whatfor,
                                  short abilities, pgp_ring_t keyring);
 
 /* Check for a traditional PGP message in body B. */
-int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only);
+int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only);
 
 /* fixme: needs documentation. */
-BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist);
+BODY *crypt_pgp_traditional_encryptsign (BODY * a, int flags, char *keylist);
 
 /* Release the PGP key KPP (note, that we pass a pointer to it). */
-void crypt_pgp_free_key (pgp_key_t *kpp);
+void crypt_pgp_free_key (pgp_key_t * kpp);
 
 /* Generate a PGP public key attachment. */
 BODY *crypt_pgp_make_key_attachment (char *tempf);
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+char *crypt_pgp_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
 
 /* Create a new body with a PGP signed message from A. */
-BODY *crypt_pgp_sign_message (BODY *a);
+BODY *crypt_pgp_sign_message (BODY * a);
 
 /* Warning: A is no longer freed in this routine, you need to free it
    later.  This is necessary for $fcc_attach. */
-BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign);
+BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign);
 
 /* Invoke the PGP command to import a key. */
 void crypt_pgp_invoke_import (const char *fname);
 
-int crypt_pgp_send_menu (HEADER *msg, int *redraw);
+int crypt_pgp_send_menu (HEADER * msg, int *redraw);
 
 /* fixme: needs documentation */
-int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf);
+int crypt_pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempf);
 
 /* Access the keyID in K. */
 char *crypt_pgp_keyid (pgp_key_t k);
 
 /* fixme: needs documentation */
-void crypt_pgp_extract_keys_from_attachment_list (FILE *fp, int tag,BODY *top);
+void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag,
+                                                  BODY * top);
 
 
 
@@ -230,38 +230,38 @@ void crypt_smime_void_passphrase (void);
 int crypt_smime_valid_passphrase (void);
 
 /* Decrypt an S/MIME message. */
-int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
+int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
 
 /* MIME handler for the application/smime content-type. */
-void crypt_smime_application_smime_handler (BODY *m, STATE *s);
+void crypt_smime_application_smime_handler (BODY * m, STATE * s);
 
 /* fixme: Needs documentation. */
-void crypt_smime_getkeys (ENVELOPE *env);
+void crypt_smime_getkeys (ENVELOPE * env);
 
 /* Check that the sender matches. */
-int crypt_smime_verify_sender(HEADER *h);
+int crypt_smime_verify_sender (HEADER * h);
 
 /* Ask for an SMIME key. */
 char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public);
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+char *crypt_smime_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
 
 /* fixme: Needs documentation. */
-BODY *crypt_smime_sign_message (BODY *a);
+BODY *crypt_smime_sign_message (BODY * a);
 
 /* fixme: needs documentation. */
-BODY *crypt_smime_build_smime_entity (BODY *a, char *certlist);
+BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist);
 
 /* Add a certificate and update index file (externally). */
 void crypt_smime_invoke_import (char *infile, char *mailbox);
 
-int crypt_smime_send_menu (HEADER *msg, int *redraw);
+int crypt_smime_send_menu (HEADER * msg, int *redraw);
 
 /* fixme: needs documentation */
-int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf);
+int crypt_smime_verify_one (BODY * sigbdy, STATE * s, const char *tempf);
 
 void crypt_init (void);
 
-#endif /*MUTT_CRYPT_H*/
+#endif /*MUTT_CRYPT_H */
index f07e98a..1575bbf 100644 (file)
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifdef USE_SLANG_CURSES
 
-#ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */
+#ifndef unix                    /* this symbol is not defined by the hp-ux compiler (sigh) */
 #define unix
 #endif /* unix */
 
@@ -102,8 +102,7 @@ void mutt_need_hard_redraw (void);
  * Support for color
  */
 
-enum
-{
+enum {
   MT_COLOR_HDEFAULT = 0,
   MT_COLOR_QUOTED,
   MT_COLOR_SIGNATURE,
@@ -128,12 +127,11 @@ enum
   MT_COLOR_MAX
 };
 
-typedef struct color_line
-{
+typedef struct color_line {
   regex_t rx;
   char *pattern;
-  pattern_t *color_pattern; /* compiled pattern to speed up index color
-                               calculation */
+  pattern_t *color_pattern;     /* compiled pattern to speed up index color
+                                   calculation */
   short fg;
   short bg;
   int pair;
@@ -160,21 +158,21 @@ void ci_start_color (void);
  */
 
 #if !defined(STDC_HEADERS) && !defined(NCURSES_VERSION) && !defined(USE_SLANG_CURSES)
-extern int endwin();
-extern int printw();
-extern int beep();
-extern int isendwin();
-extern int w32addch();
-extern int keypad();
-extern int wclrtobot();
-extern int mvprintw();
-extern int getcurx();
-extern int getcury();
-extern int noecho();
-extern int wdelch();
-extern int wrefresh();
-extern int wmove();
-extern int wclear();
-extern int waddstr();
-extern int wclrtoeol();
+extern int endwin ();
+extern int printw ();
+extern int beep ();
+extern int isendwin ();
+extern int w32addch ();
+extern int keypad ();
+extern int wclrtobot ();
+extern int mvprintw ();
+extern int getcurx ();
+extern int getcury ();
+extern int noecho ();
+extern int wdelch ();
+extern int wrefresh ();
+extern int wmove ();
+extern int wclear ();
+extern int waddstr ();
+extern int wclrtoeol ();
 #endif
index bc7a976..b8bf8fd 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -39,7 +39,7 @@ int mutt_local_to_idna (const char *in, char **out)
   *out = safe_strdup (in);
   return 0;
 }
-                       
+
 #else
 
 int mutt_idna_to_local (const char *in, char **out, int flags)
@@ -51,7 +51,7 @@ int mutt_idna_to_local (const char *in, char **out, int flags)
 
   if (!in)
     goto notrans;
-  
+
   /* Is this the right function?  Interesting effects with some bad identifiers! */
   if (idna_to_unicode_8z8z (in, out, 1) != IDNA_SUCCESS)
     goto notrans;
@@ -62,23 +62,24 @@ int mutt_idna_to_local (const char *in, char **out, int flags)
    * make sure that we can convert back and come out with the same
    * domain name. 
    */
-  
-  if ((flags & MI_MAY_BE_IRREVERSIBLE) == 0)
-  {
+
+  if ((flags & MI_MAY_BE_IRREVERSIBLE) == 0) {
     int irrev = 0;
     char *t2 = NULL;
     char *tmp = safe_strdup (*out);
+
     if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
       irrev = 1;
     if (!irrev && idna_to_ascii_8z (tmp, &t2, 1) != IDNA_SUCCESS)
       irrev = 1;
-    if (!irrev && ascii_strcasecmp (t2, in))
-    {
-      dprint (1, (debugfile, "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
-                 in, t2));
+    if (!irrev && ascii_strcasecmp (t2, in)) {
+      dprint (1,
+              (debugfile,
+               "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
+               in, t2));
       irrev = 1;
     }
-    
+
     FREE (&t2);
     FREE (&tmp);
 
@@ -87,8 +88,8 @@ int mutt_idna_to_local (const char *in, char **out, int flags)
   }
 
   return 0;
-  
- notrans:
+
+notrans:
   FREE (out);
   *out = safe_strdup (in);
   return 1;
@@ -98,22 +99,21 @@ int mutt_local_to_idna (const char *in, char **out)
 {
   int rv = 0;
   char *tmp = safe_strdup (in);
+
   *out = NULL;
 
-  if (!in)
-  {
+  if (!in) {
     *out = NULL;
     return -1;
   }
-  
+
   if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
     rv = -1;
   if (!rv && idna_to_ascii_8z (tmp, out, 1) != IDNA_SUCCESS)
     rv = -2;
-  
+
   FREE (&tmp);
-  if (rv < 0)
-  {
+  if (rv < 0) {
     FREE (out);
     *out = safe_strdup (in);
   }
@@ -128,107 +128,103 @@ int mutt_local_to_idna (const char *in, char **out)
 static int mbox_to_udomain (const char *mbx, char **user, char **domain)
 {
   char *p;
+
   *user = NULL;
   *domain = NULL;
-  
+
   p = strchr (mbx, '@');
   if (!p)
     return -1;
-  *user = safe_calloc((p - mbx + 1), sizeof(mbx[0]));
+  *user = safe_calloc ((p - mbx + 1), sizeof (mbx[0]));
   strfcpy (*user, mbx, (p - mbx + 1));
-  *domain = safe_strdup(p + 1);
+  *domain = safe_strdup (p + 1);
   return 0;
 }
 
-int mutt_addrlist_to_idna (ADDRESS *a, char **err)
+int mutt_addrlist_to_idna (ADDRESS * a, char **err)
 {
   char *user = NULL, *domain = NULL;
   char *tmp = NULL;
   int e = 0;
-  
+
   if (err)
     *err = NULL;
 
-  for (; a; a = a->next)
-  {
+  for (; a; a = a->next) {
     if (!a->mailbox)
       continue;
     if (mbox_to_udomain (a->mailbox, &user, &domain) == -1)
       continue;
-    
-    if (mutt_local_to_idna (domain, &tmp) < 0)
-    {
+
+    if (mutt_local_to_idna (domain, &tmp) < 0) {
       e = 1;
       if (err)
-       *err = safe_strdup (domain);
+        *err = safe_strdup (domain);
     }
-    else
-    {
+    else {
       safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
-      sprintf (a->mailbox, "%s@%s", NONULL(user), NONULL(tmp)); /* __SPRINTF_CHECKED__ */
+      sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp));       /* __SPRINTF_CHECKED__ */
     }
-    
+
     FREE (&domain);
     FREE (&user);
     FREE (&tmp);
-    
+
     if (e)
       return -1;
   }
-  
+
   return 0;
 }
 
-int mutt_addrlist_to_local (ADDRESS *a)
+int mutt_addrlist_to_local (ADDRESS * a)
 {
   char *user, *domain;
   char *tmp = NULL;
-  
-  for (; a; a = a->next)
-  {
+
+  for (; a; a = a->next) {
     if (!a->mailbox)
       continue;
     if (mbox_to_udomain (a->mailbox, &user, &domain) == -1)
       continue;
-    
-    if (mutt_idna_to_local (domain, &tmp, 0) == 0)
-    {
+
+    if (mutt_idna_to_local (domain, &tmp, 0) == 0) {
       safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
-      sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
+      sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp));       /* __SPRINTF_CHECKED__ */
     }
-    
+
     FREE (&domain);
     FREE (&user);
     FREE (&tmp);
   }
-  
+
   return 0;
 }
 
 /* convert just for displaying purposes */
-const char *mutt_addr_for_display (ADDRESS *a)
+const char *mutt_addr_for_display (ADDRESS * a)
 {
   static char *buff = NULL;
   char *tmp = NULL;
+
   /* user and domain will be either allocated or reseted to the NULL in
    * the mbox_to_udomain(), but for safety... */
   char *domain = NULL;
   char *user = NULL;
-  
+
   FREE (&buff);
-  
+
   if (mbox_to_udomain (a->mailbox, &user, &domain) != 0)
     return a->mailbox;
-  if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0)
-  {
+  if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0) {
     FREE (&user);
     FREE (&domain);
     FREE (&tmp);
     return a->mailbox;
   }
-  
+
   safe_realloc (&buff, mutt_strlen (tmp) + mutt_strlen (user) + 2);
-  sprintf (buff, "%s@%s", NONULL(user), NONULL(tmp)); /* __SPRINTF_CHECKED__ */
+  sprintf (buff, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
   FREE (&tmp);
   FREE (&user);
   FREE (&domain);
@@ -237,7 +233,7 @@ const char *mutt_addr_for_display (ADDRESS *a)
 
 /* Convert an ENVELOPE structure */
 
-void mutt_env_to_local (ENVELOPE *e)
+void mutt_env_to_local (ENVELOPE * e)
 {
   mutt_addrlist_to_local (e->return_path);
   mutt_addrlist_to_local (e->from);
@@ -258,16 +254,17 @@ void mutt_env_to_local (ENVELOPE *e)
      if (tag) *tag = #a; e = 1; err = NULL; \
   }
 
-int mutt_env_to_idna (ENVELOPE *env, char **tag, char **err)
+int mutt_env_to_idna (ENVELOPE * env, char **tag, char **err)
 {
   int e = 0;
-  H_TO_IDNA(return_path);
-  H_TO_IDNA(from);
-  H_TO_IDNA(to);
-  H_TO_IDNA(cc);
-  H_TO_IDNA(bcc);
-  H_TO_IDNA(reply_to);
-  H_TO_IDNA(mail_followup_to);
+
+  H_TO_IDNA (return_path);
+  H_TO_IDNA (from);
+  H_TO_IDNA (to);
+  H_TO_IDNA (cc);
+  H_TO_IDNA (bcc);
+  H_TO_IDNA (reply_to);
+  H_TO_IDNA (mail_followup_to);
   return e;
 }
 
index 4b48516..606ab6b 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _MUTT_IDNA_H
 # define _MUTT_IDNA_H
@@ -37,7 +37,7 @@ int mutt_addrlist_to_local (ADDRESS *);
 void mutt_env_to_local (ENVELOPE *);
 int mutt_env_to_idna (ENVELOPE *, char **, char **);
 
-const char *mutt_addr_for_display (ADDRESS *a);
+const char *mutt_addr_for_display (ADDRESS * a);
 
 /* Work around incompatibilities in the libidn API */
 
index 2d1fecc..a8eb110 100644 (file)
@@ -30,14 +30,13 @@ static char authpass[STRING] = "";
  * _mutt_libesmtp_ensure_init
  *   Make sure the libESMTP support in mutt is initialized at some time.
  */
-static void
-_mutt_libesmtp_ensure_init()
+static void _mutt_libesmtp_ensure_init ()
 {
   static int libesmtp_init = 0;
 
   if (!libesmtp_init) {
     if (SmtpAuthUser)
-      auth_client_init();
+      auth_client_init ();
     libesmtp_init = 1;
   }
 }
@@ -47,12 +46,12 @@ _mutt_libesmtp_ensure_init()
  *   Prints 'msg', a colon, and then a string representation of the
  *   libesmtp errno as a mutt error.
  */
-static void
-_mutt_libesmtp_perror(const char* msg)
+static void _mutt_libesmtp_perror (const char *msg)
 {
   char buf[512];
 
-  mutt_error("%s: %s", msg, smtp_strerror(smtp_errno(), buf, sizeof(buf)));
+  mutt_error ("%s: %s", msg,
+              smtp_strerror (smtp_errno (), buf, sizeof (buf)));
 }
 
 /*
@@ -65,15 +64,15 @@ _mutt_libesmtp_perror(const char* msg)
  *   Very similar to sendlib.c::add_args
  */
 static int
-_mutt_libesmtp_add_recipients(smtp_message_t message, ADDRESS *addr)
+_mutt_libesmtp_add_recipients (smtp_message_t message, ADDRESS * addr)
 {
   int ret = 0;
 
   for (; addr; addr = addr->next) {
     /* weed out group mailboxes, since those are for display only */
     if (addr->mailbox && !addr->group) {
-      if (!smtp_add_recipient(message, addr->mailbox))
-        SMTPFAIL("smtp_add_recipient");
+      if (!smtp_add_recipient (message, addr->mailbox))
+        SMTPFAIL ("smtp_add_recipient");
     }
   }
 
@@ -82,24 +81,27 @@ Done:
 }
 
 static int
-_mutt_libesmtp_auth_interact(auth_client_request_t request,
-                             char **result, int fields, void *arg)
+_mutt_libesmtp_auth_interact (auth_client_request_t request,
+                              char **result, int fields, void *arg)
 {
   int i;
 
   for (i = 0; i < fields; i++) {
     if (request[i].flags & AUTH_USER) {
       result[i] = SmtpAuthUser;
-    } else if (request[i].flags & AUTH_PASS) {
+    }
+    else if (request[i].flags & AUTH_PASS) {
       if (SmtpAuthPass) {
         result[i] = SmtpAuthPass;
-      } else {
+      }
+      else {
         if (authpass[0] == '\0') {
           char prompt[STRING];
 
-          snprintf(prompt, sizeof(prompt), "%s%s: ", request[i].prompt,
-                   (request[i].flags & AUTH_CLEARTEXT) ? " (not encrypted)" : "");
-          mutt_get_password(prompt, authpass, sizeof(authpass));
+          snprintf (prompt, sizeof (prompt), "%s%s: ", request[i].prompt,
+                    (request[i].
+                     flags & AUTH_CLEARTEXT) ? " (not encrypted)" : "");
+          mutt_get_password (prompt, authpass, sizeof (authpass));
         }
         result[i] = authpass;
       }
@@ -111,29 +113,30 @@ _mutt_libesmtp_auth_interact(auth_client_request_t request,
 
 #define BUFLEN 8192
 
-static const char*
-_mutt_libesmtp_messagefp_cb(void **buf, int *len, void *arg)
+static const char *_mutt_libesmtp_messagefp_cb (void **buf, int *len,
+                                                void *arg)
 {
   int octets;
 
   if (*buf == NULL)
-    *buf = malloc(BUFLEN);
+    *buf = malloc (BUFLEN);
 
   if (len == NULL) {
-    rewind((FILE*) arg);
+    rewind ((FILE *) arg);
     return NULL;
   }
 
-  if (fgets(*buf, BUFLEN - 2, (FILE*) arg) == NULL) {
+  if (fgets (*buf, BUFLEN - 2, (FILE *) arg) == NULL) {
     octets = 0;
-  } else {
-    char* p = strchr(*buf, '\0');
+  }
+  else {
+    char *p = strchr (*buf, '\0');
 
     if (p[-1] == '\n' && p[-2] != '\r') {
-      strcpy(p - 1, "\r\n");
+      strcpy (p - 1, "\r\n");
       p++;
     }
-    octets = p - (char*) *buf;
+    octets = p - (char *) *buf;
   }
 
   *len = octets;
@@ -146,83 +149,84 @@ _mutt_libesmtp_messagefp_cb(void **buf, int *len, void *arg)
  *   Returns 0 upon success, -1 upon failure (and prints an error
  *   message).
  */
-int
-mutt_invoke_libesmtp(ADDRESS *from,  /* the sender */
-                     ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
-                     const char *msg, /* file containing message */
-                     int eightbit) /* message contains 8bit chars */
-{
-  int ret = 0; /* return value, default = success */
+int mutt_invoke_libesmtp (ADDRESS * from,       /* the sender */
+                          ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,    /* recips */
+                          const char *msg,      /* file containing message */
+                          int eightbit)
+{                               /* message contains 8bit chars */
+  int ret = 0;                  /* return value, default = success */
   smtp_session_t session;
   smtp_message_t message;
-  charhostportstr = NULL;
+  char *hostportstr = NULL;
   size_t hostportlen;
-  FILEfp = NULL;
+  FILE *fp = NULL;
   auth_context_t authctx = NULL;
-  const smtp_status_tstatus;
+  const smtp_status_t *status;
 
-  _mutt_libesmtp_ensure_init();
+  _mutt_libesmtp_ensure_init ();
 
-  if ((session = smtp_create_session()) == NULL)
-    SMTPFAIL("smtp_create_session");
+  if ((session = smtp_create_session ()) == NULL)
+    SMTPFAIL ("smtp_create_session");
 
   /* Create hostname:port string and tell libesmtp */
   /* len = SmtpHost len + colon + max port (65536 => 5 chars) + terminator */
-  hostportlen = strlen(SmtpHost) + 7;
-  hostportstr = safe_malloc(hostportlen);
-  snprintf(hostportstr, hostportlen, "%s:%d", SmtpHost, SmtpPort);
-  if (!smtp_set_server(session, hostportstr))
-    SMTPFAIL("smtp_set_server");
+  hostportlen = strlen (SmtpHost) + 7;
+  hostportstr = safe_malloc (hostportlen);
+  snprintf (hostportstr, hostportlen, "%s:%d", SmtpHost, SmtpPort);
+  if (!smtp_set_server (session, hostportstr))
+    SMTPFAIL ("smtp_set_server");
 
   if (SmtpAuthUser) {
-    if ((authctx = auth_create_context()) == NULL)
-      MSGFAIL("auth_create_context failed");
-    auth_set_mechanism_flags(authctx, AUTH_PLUGIN_PLAIN, 0);
-    auth_set_interact_cb(authctx, _mutt_libesmtp_auth_interact, NULL);
-    if (!smtp_auth_set_context(session, authctx))
-      SMTPFAIL("smtp_auth_set_context");
+    if ((authctx = auth_create_context ()) == NULL)
+      MSGFAIL ("auth_create_context failed");
+    auth_set_mechanism_flags (authctx, AUTH_PLUGIN_PLAIN, 0);
+    auth_set_interact_cb (authctx, _mutt_libesmtp_auth_interact, NULL);
+
+    if (!smtp_auth_set_context (session, authctx))
+      SMTPFAIL ("smtp_auth_set_context");
   }
-  
-  if ((message = smtp_add_message(session)) == NULL)
-    SMTPFAIL("smtp_add_message");
+
+  if ((message = smtp_add_message (session)) == NULL)
+    SMTPFAIL ("smtp_add_message");
   /*  Initialize envelope sender */
-  if (!smtp_set_reverse_path(message, from->mailbox))
-    SMTPFAIL("smtp_set_reverse_path");
-
-  if ((fp = fopen(msg, "r")) == NULL)
-    LIBCFAIL("fopen");
-  if (!smtp_set_messagecb(message, _mutt_libesmtp_messagefp_cb, fp))
-    SMTPFAIL("smtp_set_messagecb");
-  if (_mutt_libesmtp_add_recipients(message, to))
-    FAIL(); 
-  if (_mutt_libesmtp_add_recipients(message, cc))
-    FAIL();
-  if (_mutt_libesmtp_add_recipients(message, bcc))
-    FAIL();
-  if (!smtp_start_session(session))
-    SMTPFAIL("smtp_start_session");
-
-  status = smtp_message_transfer_status(message);
+  if (!smtp_set_reverse_path (message, from->mailbox))
+    SMTPFAIL ("smtp_set_reverse_path");
+
+  if ((fp = fopen (msg, "r")) == NULL)
+    LIBCFAIL ("fopen");
+  if (!smtp_set_messagecb (message, _mutt_libesmtp_messagefp_cb, fp))
+    SMTPFAIL ("smtp_set_messagecb");
+  if (_mutt_libesmtp_add_recipients (message, to))
+    FAIL ();
+  if (_mutt_libesmtp_add_recipients (message, cc))
+    FAIL ();
+  if (_mutt_libesmtp_add_recipients (message, bcc))
+    FAIL ();
+  if (!smtp_start_session (session))
+    SMTPFAIL ("smtp_start_session");
+
+  status = smtp_message_transfer_status (message);
   if (status->code < 200 || status->code > 299) {
     char buf[256];
-    snprintf(buf, sizeof(buf), "SMTP error while sending: %d %s", status->code, status->text);
-    MSGFAIL(buf);
+
+    snprintf (buf, sizeof (buf), "SMTP error while sending: %d %s",
+              status->code, status->text);
+    MSGFAIL (buf);
   }
 
 Done:
   if (fp != NULL)
-    fclose(fp);
+    fclose (fp);
   if (hostportstr != NULL)
-    free(hostportstr);
+    free (hostportstr);
   if (session != NULL)
-    smtp_destroy_session(session);
+    smtp_destroy_session (session);
   if (authctx != NULL)
-    auth_destroy_context(authctx);
+    auth_destroy_context (authctx);
 
   /* Forget user-entered SMTP AUTH password if send fails */
   if (ret != 0)
-    authpass[0] = '\0'; 
+    authpass[0] = '\0';
 
   return ret;
 }
index 9470792..c69bf4a 100644 (file)
@@ -1,10 +1,9 @@
 #if !defined(LIBESMTP_H)
 #define LIBESMTP_H
 
-int
-mutt_invoke_libesmtp (ADDRESS *from,   /* the sender */
-                ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
-                const char *msg, /* file containing message */
-                int eightbit); /* message contains 8bit chars */
+int mutt_invoke_libesmtp (ADDRESS * from,       /* the sender */
+                          ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,    /* recips */
+                          const char *msg,      /* file containing message */
+                          int eightbit);        /* message contains 8bit chars */
 
 #endif /* !defined(LIBESMTP_H) */
index fb3d9f5..abbf11f 100644 (file)
 
 #define M_MODEFMT "-- Mutt-ng: %s"
 
-typedef struct menu_t
-{
-  char *title;   /* the title of this menu */
-  char *help;    /* quickref for the current menu */
-  void *data;    /* extra data for the current menu */
-  int current;   /* current entry */
-  int max;       /* the number of entries in the menu */
-  int redraw;  /* when to redraw the screen */
-  int menu;    /* menu definition for keymap entries. */
-  int offset;  /* which screen row to start the index */
-  int pagelen; /* number of entries per screen */
+typedef struct menu_t {
+  char *title;                  /* the title of this menu */
+  char *help;                   /* quickref for the current menu */
+  void *data;                   /* extra data for the current menu */
+  int current;                  /* current entry */
+  int max;                      /* the number of entries in the menu */
+  int redraw;                   /* when to redraw the screen */
+  int menu;                     /* menu definition for keymap entries. */
+  int offset;                   /* which screen row to start the index */
+  int pagelen;                  /* number of entries per screen */
   int tagprefix;
 
   /* Setting dialog != NULL overrides normal menu behaviour. 
@@ -53,15 +52,15 @@ typedef struct menu_t
    * normal menu movement keys. This can cause problems with scrolling, if 
    * prompt keys override movement keys.
    */
-  char **dialog;       /* dialog lines themselves */
-  char *prompt;                /* prompt for user, similar to mutt_multi_choice */
-  char *keys;          /* keys used in the prompt */
-  
+  char **dialog;                /* dialog lines themselves */
+  char *prompt;                 /* prompt for user, similar to mutt_multi_choice */
+  char *keys;                   /* keys used in the prompt */
+
   /* callback to generate an index line for the requested element */
   void (*make_entry) (char *, size_t, struct menu_t *, int);
-  
+
   /* how to search the menu */
-  int (*search) (struct menu_t *, regex_t *re, int n);
+  int (*search) (struct menu_t *, regex_t * re, int n);
 
   int (*tag) (struct menu_t *, int i, int m);
 
@@ -69,13 +68,13 @@ typedef struct menu_t
    * (default function returns ColorDefs[MT_COLOR_NORMAL])
    */
   int (*color) (int i);
-   
+
   /* the following are used only by mutt_menuLoop() */
-  int top;             /* entry that is the top of the current page */
-  int oldcurrent;      /* for driver use only. */
-  char *searchBuf;     /* last search pattern */
-  int searchDir;       /* direction of search */
-  int tagged;          /* number of tagged entries */
+  int top;                      /* entry that is the top of the current page */
+  int oldcurrent;               /* for driver use only. */
+  char *searchBuf;              /* last search pattern */
+  int searchDir;                /* direction of search */
+  int tagged;                   /* number of tagged entries */
 } MUTTMENU;
 
 void menu_jump (MUTTMENU *);
@@ -84,7 +83,7 @@ void menu_redraw_index (MUTTMENU *);
 void menu_redraw_status (MUTTMENU *);
 void menu_redraw_motion (MUTTMENU *);
 void menu_redraw_current (MUTTMENU *);
-int  menu_redraw (MUTTMENU *);
+int menu_redraw (MUTTMENU *);
 void menu_first_entry (MUTTMENU *);
 void menu_last_entry (MUTTMENU *);
 void menu_top_page (MUTTMENU *);
index da047c5..855d215 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * A (more) generic interface to regular expression matching
 #define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z))
 #define REGEXEC(X,Y) regexec(&X, Y, (size_t)0, (regmatch_t *)0, (int)0)
 
-typedef struct
-{
-  char *pattern;       /* printable version */
-  regex_t *rx;                 /* compiled expression */
-  int not;             /* do not match */
+typedef struct {
+  char *pattern;                /* printable version */
+  regex_t *rx;                  /* compiled expression */
+  int not;                      /* do not match */
 } REGEXP;
 
 WHERE REGEXP Mask;
index f4cb345..757f316 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* common SASL helper routines */
 
 #include <netinet/in.h>
 
 #ifdef USE_SASL2
-static int getnameinfo_err(int ret)
+static int getnameinfo_err (int ret)
 {
   int err;
+
   dprint (1, (debugfile, "getnameinfo: "));
-  switch(ret)
-  {
-     case EAI_AGAIN:
-       dprint (1, (debugfile, "The name could not be resolved at this time.  Future attempts may succeed.\n"));
-       err=SASL_TRYAGAIN;
-       break;
-     case EAI_BADFLAGS:
-       dprint (1, (debugfile, "The flags had an invalid value.\n"));
-       err=SASL_BADPARAM;
-       break;
-     case EAI_FAIL:
-       dprint (1, (debugfile, "A non-recoverable error occurred.\n"));
-       err=SASL_FAIL;
-       break;
-     case EAI_FAMILY:
-       dprint (1, (debugfile, "The address family was not recognized or the address length was invalid for the specified family.\n"));
-       err=SASL_BADPROT;
-       break;
-     case EAI_MEMORY:
-       dprint (1, (debugfile, "There was a memory allocation failure.\n"));
-       err=SASL_NOMEM;
-       break;
-     case EAI_NONAME:
-       dprint (1, (debugfile, "The name does not resolve for the supplied parameters.  NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n"));
-       err=SASL_FAIL; /* no real equivalent */
-       break;
-     case EAI_SYSTEM:
-       dprint (1, (debugfile, "A system error occurred.  The error code can be found in errno(%d,%s)).\n",errno,strerror(errno)));
-       err=SASL_FAIL; /* no real equivalent */
-       break;
-     default:
-       dprint (1, (debugfile, "Unknown error %d\n",ret));
-       err=SASL_FAIL; /* no real equivalent */
-       break;
+  switch (ret) {
+  case EAI_AGAIN:
+    dprint (1,
+            (debugfile,
+             "The name could not be resolved at this time.  Future attempts may succeed.\n"));
+    err = SASL_TRYAGAIN;
+    break;
+  case EAI_BADFLAGS:
+    dprint (1, (debugfile, "The flags had an invalid value.\n"));
+    err = SASL_BADPARAM;
+    break;
+  case EAI_FAIL:
+    dprint (1, (debugfile, "A non-recoverable error occurred.\n"));
+    err = SASL_FAIL;
+    break;
+  case EAI_FAMILY:
+    dprint (1,
+            (debugfile,
+             "The address family was not recognized or the address length was invalid for the specified family.\n"));
+    err = SASL_BADPROT;
+    break;
+  case EAI_MEMORY:
+    dprint (1, (debugfile, "There was a memory allocation failure.\n"));
+    err = SASL_NOMEM;
+    break;
+  case EAI_NONAME:
+    dprint (1,
+            (debugfile,
+             "The name does not resolve for the supplied parameters.  NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n"));
+    err = SASL_FAIL;            /* no real equivalent */
+    break;
+  case EAI_SYSTEM:
+    dprint (1,
+            (debugfile,
+             "A system error occurred.  The error code can be found in errno(%d,%s)).\n",
+             errno, strerror (errno)));
+    err = SASL_FAIL;            /* no real equivalent */
+    break;
+  default:
+    dprint (1, (debugfile, "Unknown error %d\n", ret));
+    err = SASL_FAIL;            /* no real equivalent */
+    break;
   }
   return err;
 }
@@ -83,7 +92,7 @@ static int getnameinfo_err(int ret)
 
 /* arbitrary. SASL will probably use a smaller buffer anyway. OTOH it's
  * been a while since I've had access to an SASL server which negotiated
- * a protection buffer. */ 
+ * a protection buffer. */
 #define M_SASL_MAXBUF 65536
 
 #ifdef USE_SASL2
@@ -95,43 +104,46 @@ static sasl_callback_t mutt_sasl_callbacks[5];
 static int mutt_sasl_start (void);
 
 /* callbacks */
-static int mutt_sasl_cb_log (void* context, int priority, const char* message);
-static int mutt_sasl_cb_authname (void* context, int id, const char** result,
-  unsigned int* len);
-static int mutt_sasl_cb_pass (sasl_conn_t* conn, void* context, int id,
-  sasl_secret_t** psecret);
+static int mutt_sasl_cb_log (void *context, int priority,
+                             const char *message);
+static int mutt_sasl_cb_authname (void *context, int id, const char **result,
+                                  unsigned int *len);
+static int mutt_sasl_cb_pass (sasl_conn_t * conn, void *context, int id,
+                              sasl_secret_t ** psecret);
 
 /* socket wrappers for a SASL security layer */
-static int mutt_sasl_conn_open (CONNECTION* conn);
-static int mutt_sasl_conn_close (CONNECTION* conn);
-static int mutt_sasl_conn_read (CONNECTION* conn, char* buf, size_t len);
-static int mutt_sasl_conn_write (CONNECTION* conn, const char* buf,
-  size_t count);
+static int mutt_sasl_conn_open (CONNECTION * conn);
+static int mutt_sasl_conn_close (CONNECTION * conn);
+static int mutt_sasl_conn_read (CONNECTION * conn, char *buf, size_t len);
+static int mutt_sasl_conn_write (CONNECTION * conn, const char *buf,
+                                 size_t count);
 
 #ifdef USE_SASL2
 /* utility function, stolen from sasl2 sample code */
-static int iptostring(const struct sockaddr *addr, socklen_t addrlen,
-                     char *out, unsigned outlen) {
-    char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
-    int ret;
-    
-    if(!addr || !out) return SASL_BADPARAM;
-
-    ret=getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
-                   NI_NUMERICHOST |
+static int iptostring (const struct sockaddr *addr, socklen_t addrlen,
+                       char *out, unsigned outlen)
+{
+  char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+  int ret;
+
+  if (!addr || !out)
+    return SASL_BADPARAM;
+
+  ret = getnameinfo (addr, addrlen, hbuf, sizeof (hbuf), pbuf, sizeof (pbuf),
+                     NI_NUMERICHOST |
 #ifdef NI_WITHSCOPEID
-                  NI_WITHSCOPEID |
+                     NI_WITHSCOPEID |
 #endif
-                  NI_NUMERICSERV);
-    if(ret)
-      return getnameinfo_err(ret);
+                     NI_NUMERICSERV);
+  if (ret)
+    return getnameinfo_err (ret);
 
-    if(outlen < strlen(hbuf) + strlen(pbuf) + 2)
-        return SASL_BUFOVER;
+  if (outlen < strlen (hbuf) + strlen (pbuf) + 2)
+    return SASL_BUFOVER;
 
-    snprintf(out, outlen, "%s;%s", hbuf, pbuf);
+  snprintf (out, outlen, "%s;%s", hbuf, pbuf);
 
-    return SASL_OK;
+  return SASL_OK;
 }
 #endif
 
@@ -158,9 +170,9 @@ int mutt_sasl_start (void)
 
   rc = sasl_client_init (callbacks);
 
-  if (rc != SASL_OK)
-  {
-    dprint (1, (debugfile, "mutt_sasl_start: libsasl initialisation failed.\n"));
+  if (rc != SASL_OK) {
+    dprint (1,
+            (debugfile, "mutt_sasl_start: libsasl initialisation failed.\n"));
     return SASL_FAIL;
   }
 
@@ -172,9 +184,10 @@ int mutt_sasl_start (void)
 /* mutt_sasl_client_new: wrapper for sasl_client_new which also sets various
  * security properties. If this turns out to be fine for POP too we can
  * probably stop exporting mutt_sasl_get_callbacks(). */
-int mutt_sasl_client_new (CONNECTION* conn, sasl_conn_t** saslconn)
+int mutt_sasl_client_new (CONNECTION * conn, sasl_conn_t ** saslconn)
 {
   sasl_security_properties_t secprops;
+
 #ifdef USE_SASL2
   struct sockaddr_storage local, remote;
   socklen_t size;
@@ -182,62 +195,76 @@ int mutt_sasl_client_new (CONNECTION* conn, sasl_conn_t** saslconn)
 #else
   sasl_external_properties_t extprops;
 #endif
-  const charservice;
+  const char *service;
   int rc;
 
   if (mutt_sasl_start () != SASL_OK)
     return -1;
 
-  switch (conn->account.type)
-  {
-    case M_ACCT_TYPE_IMAP:
-      service = "imap";
-      break;
-    case M_ACCT_TYPE_POP:
-      service = "pop";
-      break;
-    default:
-      dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
-      return -1;
+  switch (conn->account.type) {
+  case M_ACCT_TYPE_IMAP:
+    service = "imap";
+    break;
+  case M_ACCT_TYPE_POP:
+    service = "pop";
+    break;
+  default:
+    dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
+    return -1;
   }
 
 #ifdef USE_SASL2
   size = sizeof (local);
-  if (getsockname (conn->fd, (struct sockaddr *)&local, &size)){
-    dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for local failed\n"));
+  if (getsockname (conn->fd, (struct sockaddr *) &local, &size)) {
+    dprint (1,
+            (debugfile,
+             "mutt_sasl_client_new: getsockname for local failed\n"));
     return -1;
   }
-  else 
-  if (iptostring((struct sockaddr *)&local, size, iplocalport, IP_PORT_BUFLEN) != SASL_OK){
-    dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for local failed\n"));
+  else
+    if (iptostring
+        ((struct sockaddr *) &local, size, iplocalport,
+         IP_PORT_BUFLEN) != SASL_OK) {
+    dprint (1,
+            (debugfile,
+             "mutt_sasl_client_new: iptostring for local failed\n"));
     return -1;
   }
-  
+
   size = sizeof (remote);
-  if (getpeername (conn->fd, (struct sockaddr *)&remote, &size)){
-    dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for remote failed\n"));
+  if (getpeername (conn->fd, (struct sockaddr *) &remote, &size)) {
+    dprint (1,
+            (debugfile,
+             "mutt_sasl_client_new: getsockname for remote failed\n"));
     return -1;
   }
-  else 
-  if (iptostring((struct sockaddr *)&remote, size, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){
-    dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for remote failed\n"));
+  else
+    if (iptostring
+        ((struct sockaddr *) &remote, size, ipremoteport,
+         IP_PORT_BUFLEN) != SASL_OK) {
+    dprint (1,
+            (debugfile,
+             "mutt_sasl_client_new: iptostring for remote failed\n"));
     return -1;
   }
 
-dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport));
-  
-  rc = sasl_client_new (service, conn->account.host, iplocalport, ipremoteport,
-    mutt_sasl_get_callbacks (&conn->account), 0, saslconn);
+  dprint (1,
+          (debugfile, "local ip: %s, remote ip:%s\n", iplocalport,
+           ipremoteport));
+
+  rc =
+    sasl_client_new (service, conn->account.host, iplocalport, ipremoteport,
+                     mutt_sasl_get_callbacks (&conn->account), 0, saslconn);
 
 #else
   rc = sasl_client_new (service, conn->account.host,
-    mutt_sasl_get_callbacks (&conn->account), SASL_SECURITY_LAYER, saslconn);
+                        mutt_sasl_get_callbacks (&conn->account),
+                        SASL_SECURITY_LAYER, saslconn);
 #endif
 
-  if (rc != SASL_OK)
-  {
+  if (rc != SASL_OK) {
     dprint (1, (debugfile,
-      "mutt_sasl_client_new: Error allocating SASL connection\n"));
+                "mutt_sasl_client_new: Error allocating SASL connection\n"));
     return -1;
   }
 
@@ -245,33 +272,31 @@ dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport))
   /* Do we need to fail if this fails? I would assume having these unset
    * would just disable KRB4. Who wrote this code? I'm not sure how this
    * interacts with the NSS code either, since that mucks with the fd. */
-#ifndef USE_SASL2 /* with SASLv2 this all happens in sasl_client_new */
+#ifndef USE_SASL2               /* with SASLv2 this all happens in sasl_client_new */
   {
     struct sockaddr_in local, remote;
     socklen_t size;
 
     size = sizeof (local);
-    if (getsockname (conn->fd, (struct sockaddr*) &local, &size))
+    if (getsockname (conn->fd, (struct sockaddr *) &local, &size))
       return -1;
 
-    size = sizeof(remote);
-    if (getpeername(conn->fd, (struct sockaddr*) &remote, &size))
+    size = sizeof (remote);
+    if (getpeername (conn->fd, (struct sockaddr *) &remote, &size))
       return -1;
 
 #ifdef SASL_IP_LOCAL
-    if (sasl_setprop(*saslconn, SASL_IP_LOCAL, &local) != SASL_OK)
-    {
+    if (sasl_setprop (*saslconn, SASL_IP_LOCAL, &local) != SASL_OK) {
       dprint (1, (debugfile,
-       "mutt_sasl_client_new: Error setting local IP address\n"));
+                  "mutt_sasl_client_new: Error setting local IP address\n"));
       return -1;
     }
 #endif
 
 #ifdef SASL_IP_REMOTE
-    if (sasl_setprop(*saslconn, SASL_IP_REMOTE, &remote) != SASL_OK)
-    {
+    if (sasl_setprop (*saslconn, SASL_IP_REMOTE, &remote) != SASL_OK) {
       dprint (1, (debugfile,
-       "mutt_sasl_client_new: Error setting remote IP address\n"));
+                  "mutt_sasl_client_new: Error setting remote IP address\n"));
       return -1;
     }
 #endif
@@ -287,10 +312,9 @@ dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport))
   secprops.max_ssf = 0x7fff;
   secprops.maxbufsize = M_SASL_MAXBUF;
   secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
-  if (sasl_setprop (*saslconn, SASL_SEC_PROPS, &secprops) != SASL_OK)
-  {
+  if (sasl_setprop (*saslconn, SASL_SEC_PROPS, &secprops) != SASL_OK) {
     dprint (1, (debugfile,
-      "mutt_sasl_client_new: Error setting security properties\n"));
+                "mutt_sasl_client_new: Error setting security properties\n"));
     return -1;
   }
 
@@ -299,9 +323,8 @@ dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport))
    * I have a feeling more SSL code could be shared between those two files,
    * but I haven't looked into it yet, since I still don't know the APIs. */
 #if (defined(USE_SSL) || defined(USE_GNUTLS) && !defined(USE_NSS))
-  if (conn->account.flags & M_ACCT_SSL)
-  {
-#ifdef USE_SASL2 /* I'm not sure this actually has an effect, at least with SASLv2 */
+  if (conn->account.flags & M_ACCT_SSL) {
+#ifdef USE_SASL2                /* I'm not sure this actually has an effect, at least with SASLv2 */
     dprint (2, (debugfile, "External SSF: %d\n", conn->ssf));
     if (sasl_setprop (*saslconn, SASL_SSF_EXTERNAL, &(conn->ssf)) != SASL_OK)
 #else
@@ -311,14 +334,20 @@ dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport))
     if (sasl_setprop (*saslconn, SASL_SSF_EXTERNAL, &extprops) != SASL_OK)
 #endif
     {
-      dprint (1, (debugfile, "mutt_sasl_client_new: Error setting external properties\n"));
+      dprint (1,
+              (debugfile,
+               "mutt_sasl_client_new: Error setting external properties\n"));
       return -1;
     }
 #ifdef USE_SASL2
-    dprint (2, (debugfile, "External authentication name: %s\n", conn->account.user));
-    if (sasl_setprop (*saslconn, SASL_AUTH_EXTERNAL, conn->account.user) != SASL_OK)
-     {
-      dprint (1, (debugfile, "mutt_sasl_client_new: Error setting external properties\n"));
+    dprint (2,
+            (debugfile, "External authentication name: %s\n",
+             conn->account.user));
+    if (sasl_setprop (*saslconn, SASL_AUTH_EXTERNAL, conn->account.user) !=
+        SASL_OK) {
+      dprint (1,
+              (debugfile,
+               "mutt_sasl_client_new: Error setting external properties\n"));
       return -1;
     }
 #endif
@@ -328,9 +357,9 @@ dprint(1,(debugfile, "local ip: %s, remote ip:%s\n", iplocalport, ipremoteport))
   return 0;
 }
 
-sasl_callback_t* mutt_sasl_get_callbacks (ACCOUNT* account)
+sasl_callback_t *mutt_sasl_get_callbacks (ACCOUNT * account)
 {
-  sasl_callback_tcallback;
+  sasl_callback_t *callback;
 
   callback = mutt_sasl_callbacks;
 
@@ -361,21 +390,23 @@ sasl_callback_t* mutt_sasl_get_callbacks (ACCOUNT* account)
   return mutt_sasl_callbacks;
 }
 
-int mutt_sasl_interact (sasl_interact_t* interaction)
+int mutt_sasl_interact (sasl_interact_t * interaction)
 {
   char prompt[SHORT_STRING];
   char resp[SHORT_STRING];
 
-  while (interaction->id != SASL_CB_LIST_END)
-  {
-    dprint (2, (debugfile, "mutt_sasl_interact: filling in SASL interaction %ld.\n", interaction->id));
+  while (interaction->id != SASL_CB_LIST_END) {
+    dprint (2,
+            (debugfile,
+             "mutt_sasl_interact: filling in SASL interaction %ld.\n",
+             interaction->id));
 
     snprintf (prompt, sizeof (prompt), "%s: ", interaction->prompt);
     resp[0] = '\0';
     if (mutt_get_field (prompt, resp, sizeof (resp), 0))
       return SASL_FAIL;
 
-    interaction->len = mutt_strlen (resp)+1;
+    interaction->len = mutt_strlen (resp) + 1;
     interaction->result = safe_malloc (interaction->len);
     memcpy (interaction->result, resp, interaction->len);
 
@@ -401,26 +432,29 @@ int mutt_sasl_interact (sasl_interact_t* interaction)
 /* mutt_sasl_setup_conn: replace connection methods, sockdata with 
  *   SASL wrappers, for protection layers. Also get ssf, as a fastpath
  *   for the read/write methods. */
-void mutt_sasl_setup_conn (CONNECTION* conn, sasl_conn_t* saslconn)
+void mutt_sasl_setup_conn (CONNECTION * conn, sasl_conn_t * saslconn)
 {
-  SASL_DATA* sasldata = (SASL_DATA*) safe_malloc (sizeof (SASL_DATA));
+  SASL_DATA *sasldata = (SASL_DATA *) safe_malloc (sizeof (SASL_DATA));
 
   sasldata->saslconn = saslconn;
   /* get ssf so we know whether we have to (en|de)code read/write */
 #ifdef USE_SASL2
-  sasl_getprop (saslconn, SASL_SSF, (const void**) &sasldata->ssf);
+  sasl_getprop (saslconn, SASL_SSF, (const void **) &sasldata->ssf);
 #else
-  sasl_getprop (saslconn, SASL_SSF, (void**) &sasldata->ssf);
+  sasl_getprop (saslconn, SASL_SSF, (void **) &sasldata->ssf);
 #endif
   dprint (3, (debugfile, "SASL protection strength: %u\n", *sasldata->ssf));
   /* Add SASL SSF to transport SSF */
   conn->ssf += *sasldata->ssf;
 #ifdef USE_SASL2
-  sasl_getprop (saslconn, SASL_MAXOUTBUF, (const void**) &sasldata->pbufsize);
+  sasl_getprop (saslconn, SASL_MAXOUTBUF,
+                (const void **) &sasldata->pbufsize);
 #else
-  sasl_getprop (saslconn, SASL_MAXOUTBUF, (void**) &sasldata->pbufsize);
+  sasl_getprop (saslconn, SASL_MAXOUTBUF, (void **) &sasldata->pbufsize);
 #endif
-  dprint (3, (debugfile, "SASL protection buffer size: %u\n", *sasldata->pbufsize));
+  dprint (3,
+          (debugfile, "SASL protection buffer size: %u\n",
+           *sasldata->pbufsize));
 
   /* clear input buffer */
   sasldata->buf = NULL;
@@ -443,7 +477,7 @@ void mutt_sasl_setup_conn (CONNECTION* conn, sasl_conn_t* saslconn)
 }
 
 /* mutt_sasl_cb_log: callback to log SASL messages */
-static int mutt_sasl_cb_log (void* context, int priority, const char* message)
+static int mutt_sasl_cb_log (void *context, int priority, const char *message)
 {
   dprint (priority, (debugfile, "SASL: %s\n", message));
 
@@ -452,10 +486,10 @@ static int mutt_sasl_cb_log (void* context, int priority, const char* message)
 
 /* mutt_sasl_cb_authname: callback to retrieve authname or user (mutt
  *   doesn't distinguish, even if some SASL plugins do) from ACCOUNT */
-static int mutt_sasl_cb_authname (void* context, int id, const char** result,
-  unsigned* len)
+static int mutt_sasl_cb_authname (void *context, int id, const char **result,
+                                  unsigned *len)
 {
-  ACCOUNT* account = (ACCOUNT*) context;
+  ACCOUNT *account = (ACCOUNT *) context;
 
   *result = NULL;
   if (len)
@@ -465,8 +499,8 @@ static int mutt_sasl_cb_authname (void* context, int id, const char** result,
     return SASL_BADPARAM;
 
   dprint (2, (debugfile, "mutt_sasl_cb_authname: getting %s for %s:%u\n",
-             id == SASL_CB_AUTHNAME ? "authname" : "user",
-             account->host, account->port));
+              id == SASL_CB_AUTHNAME ? "authname" : "user",
+              account->host, account->port));
 
   if (mutt_account_getuser (account))
     return SASL_FAIL;
@@ -479,27 +513,27 @@ static int mutt_sasl_cb_authname (void* context, int id, const char** result,
   return SASL_OK;
 }
 
-static int mutt_sasl_cb_pass (sasl_conn_t* conn, void* context, int id,
-  sasl_secret_t** psecret)
+static int mutt_sasl_cb_pass (sasl_conn_t * conn, void *context, int id,
+                              sasl_secret_t ** psecret)
 {
-  ACCOUNT* account = (ACCOUNT*) context;
+  ACCOUNT *account = (ACCOUNT *) context;
   int len;
 
   if (!account || !psecret)
     return SASL_BADPARAM;
 
   dprint (2, (debugfile,
-    "mutt_sasl_cb_pass: getting password for %s@%s:%u\n", account->user,
-    account->host, account->port));
+              "mutt_sasl_cb_pass: getting password for %s@%s:%u\n",
+              account->user, account->host, account->port));
 
   if (mutt_account_getpass (account))
     return SASL_FAIL;
 
   len = strlen (account->pass);
 
-  *psecret = (sasl_secret_t*) safe_malloc (sizeof (sasl_secret_t) + len);
+  *psecret = (sasl_secret_t *) safe_malloc (sizeof (sasl_secret_t) + len);
   (*psecret)->len = len;
-  strcpy ((*psecret)->data, account->pass);    /* __STRCPY_CHECKED__ */
+  strcpy ((*psecret)->data, account->pass);     /* __STRCPY_CHECKED__ */
 
   return SASL_OK;
 }
@@ -508,12 +542,12 @@ static int mutt_sasl_cb_pass (sasl_conn_t* conn, void* context, int id,
  *   don't know in advance that a connection will use SASL, so we
  *   replace conn's methods with sasl methods when authentication
  *   is successful, using mutt_sasl_setup_conn */
-static int mutt_sasl_conn_open (CONNECTION* conn)
+static int mutt_sasl_conn_open (CONNECTION * conn)
 {
-  SASL_DATAsasldata;
+  SASL_DATA *sasldata;
   int rc;
 
-  sasldata = (SASL_DATA*) conn->sockdata;
+  sasldata = (SASL_DATA *) conn->sockdata;
   conn->sockdata = sasldata->sockdata;
   rc = (sasldata->msasl_open) (conn);
   conn->sockdata = sasldata;
@@ -523,12 +557,12 @@ static int mutt_sasl_conn_open (CONNECTION* conn)
 
 /* mutt_sasl_conn_close: calls underlying close function and disposes of
  *   the sasl_conn_t object, then restores connection to pre-sasl state */
-static int mutt_sasl_conn_close (CONNECTION* conn)
+static int mutt_sasl_conn_close (CONNECTION * conn)
 {
-  SASL_DATAsasldata;
+  SASL_DATA *sasldata;
   int rc;
 
-  sasldata = (SASL_DATA*) conn->sockdata;
+  sasldata = (SASL_DATA *) conn->sockdata;
 
   /* restore connection's underlying methods */
   conn->sockdata = sasldata->sockdata;
@@ -550,27 +584,26 @@ static int mutt_sasl_conn_close (CONNECTION* conn)
   return rc;
 }
 
-static int mutt_sasl_conn_read (CONNECTION* conn, char* buf, size_t len)
+static int mutt_sasl_conn_read (CONNECTION * conn, char *buf, size_t len)
 {
-  SASL_DATAsasldata;
+  SASL_DATA *sasldata;
   int rc;
 
   unsigned int olen;
 
-  sasldata = (SASL_DATA*) conn->sockdata;
+  sasldata = (SASL_DATA *) conn->sockdata;
 
   /* if we still have data in our read buffer, copy it into buf */
-  if (sasldata->blen > sasldata->bpos)
-  {
+  if (sasldata->blen > sasldata->bpos) {
     olen = (sasldata->blen - sasldata->bpos > len) ? len :
       sasldata->blen - sasldata->bpos;
 
-    memcpy (buf, sasldata->buf+sasldata->bpos, olen);
+    memcpy (buf, sasldata->buf + sasldata->bpos, olen);
     sasldata->bpos += olen;
 
     return olen;
   }
-  
+
   conn->sockdata = sasldata->sockdata;
 
 #ifndef USE_SASL2
@@ -580,22 +613,19 @@ static int mutt_sasl_conn_read (CONNECTION* conn, char* buf, size_t len)
   sasldata->blen = 0;
 
   /* and decode the result, if necessary */
-  if (*sasldata->ssf)
-  {
-    do
-    {
+  if (*sasldata->ssf) {
+    do {
       /* call the underlying read function to fill the buffer */
       rc = (sasldata->msasl_read) (conn, buf, len);
       if (rc <= 0)
-       goto out;
+        goto out;
 
       rc = sasl_decode (sasldata->saslconn, buf, rc, &sasldata->buf,
-        &sasldata->blen);
-      if (rc != SASL_OK)
-      {
-       dprint (1, (debugfile, "SASL decode failed: %s\n",
-          sasl_errstring (rc, NULL, NULL)));
-       goto out;
+                        &sasldata->blen);
+      if (rc != SASL_OK) {
+        dprint (1, (debugfile, "SASL decode failed: %s\n",
+                    sasl_errstring (rc, NULL, NULL)));
+        goto out;
       }
     }
     while (!sasldata->blen);
@@ -611,42 +641,39 @@ static int mutt_sasl_conn_read (CONNECTION* conn, char* buf, size_t len)
   else
     rc = (sasldata->msasl_read) (conn, buf, len);
 
-  out:
-    conn->sockdata = sasldata;
+out:
+  conn->sockdata = sasldata;
 
-    return rc;
+  return rc;
 }
 
-static int mutt_sasl_conn_write (CONNECTION* conn, const char* buf,
-  size_t len)
+static int mutt_sasl_conn_write (CONNECTION * conn, const char *buf,
+                                 size_t len)
 {
-  SASL_DATAsasldata;
+  SASL_DATA *sasldata;
   int rc;
 
 #ifdef USE_SASL2
   const char *pbuf;
 #else
-  charpbuf;
+  char *pbuf;
 #endif
   unsigned int olen, plen;
 
-  sasldata = (SASL_DATA*) conn->sockdata;
+  sasldata = (SASL_DATA *) conn->sockdata;
   conn->sockdata = sasldata->sockdata;
 
   /* encode data, if necessary */
-  if (*sasldata->ssf)
-  {
+  if (*sasldata->ssf) {
     /* handle data larger than MAXOUTBUF */
-    do
-    {
+    do {
       olen = (len > *sasldata->pbufsize) ? *sasldata->pbufsize : len;
 
       rc = sasl_encode (sasldata->saslconn, buf, olen, &pbuf, &plen);
-      if (rc != SASL_OK)
-      {
-       dprint (1, (debugfile, "SASL encoding failed: %s\n",
-          sasl_errstring (rc, NULL, NULL)));
-       goto fail;
+      if (rc != SASL_OK) {
+        dprint (1, (debugfile, "SASL encoding failed: %s\n",
+                    sasl_errstring (rc, NULL, NULL)));
+        goto fail;
       }
 
       rc = (sasldata->msasl_write) (conn, pbuf, plen);
@@ -654,7 +681,7 @@ static int mutt_sasl_conn_write (CONNECTION* conn, const char* buf,
       FREE (&pbuf);
 #endif
       if (rc != plen)
-       goto fail;
+        goto fail;
 
       len -= olen;
       buf += olen;
@@ -662,14 +689,14 @@ static int mutt_sasl_conn_write (CONNECTION* conn, const char* buf,
     while (len > *sasldata->pbufsize);
   }
   else
-  /* just write using the underlying socket function */
+    /* just write using the underlying socket function */
     rc = (sasldata->msasl_write) (conn, buf, len);
-  
+
   conn->sockdata = sasldata;
 
   return rc;
 
- fail:
+fail:
   conn->sockdata = sasldata;
   return -1;
 }
index 3959ee7..4017a26 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* common SASL helper routines */
 
 
 #include "mutt_socket.h"
 
-int mutt_sasl_client_new (CONNECTION*, sasl_conn_t**);
-sasl_callback_t* mutt_sasl_get_callbacks (ACCOUNT*);
-int mutt_sasl_interact (sasl_interact_t*);
-void mutt_sasl_setup_conn (CONNECTION*, sasl_conn_t*);
+int mutt_sasl_client_new (CONNECTION *, sasl_conn_t **);
+sasl_callback_t *mutt_sasl_get_callbacks (ACCOUNT *);
+int mutt_sasl_interact (sasl_interact_t *);
+void mutt_sasl_setup_conn (CONNECTION *, sasl_conn_t *);
 
-typedef struct 
-{
-  sasl_conn_t* saslconn;
-  const sasl_ssf_t* ssf;
-  const unsigned int* pbufsize;
+typedef struct {
+  sasl_conn_t *saslconn;
+  const sasl_ssf_t *ssf;
+  const unsigned int *pbufsize;
 
   /* read buffer */
 #ifdef USE_SASL2
   const char *buf;
 #else
-  charbuf;
+  char *buf;
 #endif
   unsigned int blen;
   unsigned int bpos;
 
   /* underlying socket data */
-  void* sockdata;
-  int (*msasl_open) (CONNECTION* conn);
-  int (*msasl_close) (CONNECTION* conn);
-  int (*msasl_read) (CONNECTION* conn, char* buf, size_t len);
-  int (*msasl_write) (CONNECTION* conn, const char* buf, size_t count);
-}
-SASL_DATA;
+  void *sockdata;
+  int (*msasl_open) (CONNECTION * conn);
+  int (*msasl_close) (CONNECTION * conn);
+  int (*msasl_read) (CONNECTION * conn, char *buf, size_t len);
+  int (*msasl_write) (CONNECTION * conn, const char *buf, size_t count);
+} SASL_DATA;
 
 #endif /* _MUTT_SASL_H_ */
index 3919ccd..c79d927 100644 (file)
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -47,11 +47,11 @@ static CONNECTION *Connections = NULL;
 
 /* forward declarations */
 static int socket_preconnect (void);
-static int socket_connect (int fd, struct sockaddrsa);
-static CONNECTIONsocket_new_conn ();
+static int socket_connect (int fd, struct sockaddr *sa);
+static CONNECTION *socket_new_conn ();
 
 /* Wrappers */
-int mutt_socket_open (CONNECTION* conn) 
+int mutt_socket_open (CONNECTION * conn)
 {
   if (socket_preconnect ())
     return -1;
@@ -59,12 +59,14 @@ int mutt_socket_open (CONNECTION* conn)
   return conn->conn_open (conn);
 }
 
-int mutt_socket_close (CONNECTION* conn)
+int mutt_socket_close (CONNECTION * conn)
 {
   int rc = -1;
 
   if (conn->fd < 0)
-    dprint (1, (debugfile, "mutt_socket_close: Attempt to close closed connection.\n"));
+    dprint (1,
+            (debugfile,
+             "mutt_socket_close: Attempt to close closed connection.\n"));
   else
     rc = conn->conn_close (conn);
 
@@ -74,20 +76,20 @@ int mutt_socket_close (CONNECTION* conn)
   return rc;
 }
 
-int mutt_socket_read (CONNECTION* conn, char* buf, size_t len)
+int mutt_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
   int rc;
 
-  if (conn->fd < 0)
-  {
-    dprint (1, (debugfile, "mutt_socket_read: attempt to read from closed connection\n"));
+  if (conn->fd < 0) {
+    dprint (1,
+            (debugfile,
+             "mutt_socket_read: attempt to read from closed connection\n"));
     return -1;
   }
 
   rc = conn->conn_read (conn, buf, len);
   /* EOF */
-  if (rc == 0)
-  {
+  if (rc == 0) {
     mutt_error (_("Connection to %s closed"), conn->account.host);
     mutt_sleep (2);
   }
@@ -97,58 +99,57 @@ int mutt_socket_read (CONNECTION* conn, char* buf, size_t len)
   return rc;
 }
 
-int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg)
+int mutt_socket_write_d (CONNECTION * conn, const char *buf, int dbg)
 {
   int rc;
   int len;
 
-  dprint (dbg, (debugfile,"> %s", buf));
+  dprint (dbg, (debugfile, "> %s", buf));
 
-  if (conn->fd < 0)
-  {
-    dprint (1, (debugfile, "mutt_socket_write: attempt to write to closed connection\n"));
+  if (conn->fd < 0) {
+    dprint (1,
+            (debugfile,
+             "mutt_socket_write: attempt to write to closed connection\n"));
     return -1;
   }
 
   len = mutt_strlen (buf);
-  if ((rc = conn->conn_write (conn, buf, len)) < 0)
-  {
+  if ((rc = conn->conn_write (conn, buf, len)) < 0) {
     dprint (1, (debugfile,
-      "mutt_socket_write: error writing, closing socket\n"));
+                "mutt_socket_write: error writing, closing socket\n"));
     mutt_socket_close (conn);
 
     return -1;
   }
 
-  if (rc < len)
-  {
+  if (rc < len) {
     dprint (1, (debugfile,
-      "mutt_socket_write: ERROR: wrote %d of %d bytes!\n", rc, len));
+                "mutt_socket_write: ERROR: wrote %d of %d bytes!\n", rc,
+                len));
   }
 
   return rc;
 }
 
 /* simple read buffering to speed things up. */
-int mutt_socket_readchar (CONNECTION *conn, char *c)
+int mutt_socket_readchar (CONNECTION * conn, char *c)
 {
-  if (conn->bufpos >= conn->available)
-  {
+  if (conn->bufpos >= conn->available) {
     if (conn->fd >= 0)
-      conn->available = conn->conn_read (conn, conn->inbuf, sizeof (conn->inbuf));
-    else
-    {
-      dprint (1, (debugfile, "mutt_socket_readchar: attempt to read from closed connection.\n"));
+      conn->available =
+        conn->conn_read (conn, conn->inbuf, sizeof (conn->inbuf));
+    else {
+      dprint (1,
+              (debugfile,
+               "mutt_socket_readchar: attempt to read from closed connection.\n"));
       return -1;
     }
     conn->bufpos = 0;
-    if (conn->available == 0)
-    {
+    if (conn->available == 0) {
       mutt_error (_("Connection to %s closed"), conn->account.host);
       mutt_sleep (2);
     }
-    if (conn->available <= 0)
-    {
+    if (conn->available <= 0) {
       mutt_socket_close (conn);
       return -1;
     }
@@ -158,15 +159,14 @@ int mutt_socket_readchar (CONNECTION *conn, char *c)
   return 1;
 }
 
-int mutt_socket_readln_d (char* buf, size_t buflen, CONNECTION* conn, int dbg)
+int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION * conn,
+                          int dbg)
 {
   char ch;
   int i;
 
-  for (i = 0; i < buflen-1; i++)
-  {
-    if (mutt_socket_readchar (conn, &ch) != 1)
-    {
+  for (i = 0; i < buflen - 1; i++) {
+    if (mutt_socket_readchar (conn, &ch) != 1) {
       buf[i] = '\0';
       return -1;
     }
@@ -177,42 +177,39 @@ int mutt_socket_readln_d (char* buf, size_t buflen, CONNECTION* conn, int dbg)
   }
 
   /* strip \r from \r\n termination */
-  if (i && buf[i-1] == '\r')
+  if (i && buf[i - 1] == '\r')
     buf[--i] = '\0';
   else
     buf[i] = '\0';
 
   dprint (dbg, (debugfile, "< %s\n", buf));
-  
+
   /* number of bytes read, not strlen */
   return i + 1;
 }
 
-CONNECTIONmutt_socket_head (void)
+CONNECTION *mutt_socket_head (void)
 {
   return Connections;
 }
 
 /* mutt_socket_free: remove connection from connection list and free it */
-void mutt_socket_free (CONNECTION* conn)
+void mutt_socket_free (CONNECTION * conn)
 {
-  CONNECTIONiter;
-  CONNECTIONtmp;
+  CONNECTION *iter;
+  CONNECTION *tmp;
 
   iter = Connections;
 
   /* head is special case, doesn't need prev updated */
-  if (iter == conn)
-  {
+  if (iter == conn) {
     Connections = iter->next;
     FREE (&iter);
     return;
   }
 
-  while (iter->next)
-  {
-    if (iter->next == conn)
-    {
+  while (iter->next) {
+    if (iter->next == conn) {
       tmp = iter->next;
       iter->next = tmp->next;
       FREE (&tmp);
@@ -227,21 +224,20 @@ void mutt_socket_free (CONNECTION* conn)
  *   connections after the given connection (allows higher level socket code
  *   to make more fine-grained searches than account info - eg in IMAP we may
  *   wish to find a connection which is not in IMAP_SELECTED state) */
-CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account)
+CONNECTION *mutt_conn_find (const CONNECTION * start, const ACCOUNT * account)
 {
-  CONNECTIONconn;
+  CONNECTION *conn;
   ciss_url_t url;
   char hook[LONG_STRING];
 
   /* account isn't actually modified, since url isn't either */
-  mutt_account_tourl ((ACCOUNT*) account, &url);
+  mutt_account_tourl ((ACCOUNT *) account, &url);
   url.path = NULL;
   url_ciss_tostring (&url, hook, sizeof (hook), 0);
   mutt_account_hook (hook);
 
   conn = start ? start->next : Connections;
-  while (conn)
-  {
+  while (conn) {
     if (mutt_account_match (account, &(conn->account)))
       return conn;
     conn = conn->next;
@@ -255,28 +251,26 @@ CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account)
 
   if (Tunnel && *Tunnel)
     mutt_tunnel_socket_setup (conn);
-  else if (account->flags & M_ACCT_SSL) 
-  {
+  else if (account->flags & M_ACCT_SSL) {
 #ifdef USE_SSL
     ssl_socket_setup (conn);
 #elif USE_NSS
     mutt_nss_socket_setup (conn);
 #elif USE_GNUTLS
-    if (mutt_gnutls_socket_setup (conn) < 0)
-    {
+    if (mutt_gnutls_socket_setup (conn) < 0) {
       mutt_socket_free (conn);
       return NULL;
     }
 #else
     mutt_error _("SSL is unavailable.");
+
     mutt_sleep (2);
     mutt_socket_free (conn);
 
     return NULL;
 #endif
   }
-  else
-  {
+  else {
     conn->conn_read = raw_socket_read;
     conn->conn_write = raw_socket_write;
     conn->conn_open = raw_socket_open;
@@ -291,17 +285,15 @@ static int socket_preconnect (void)
   int rc;
   int save_errno;
 
-  if (mutt_strlen (Preconnect))
-  {
+  if (mutt_strlen (Preconnect)) {
     dprint (2, (debugfile, "Executing preconnect: %s\n", Preconnect));
     rc = mutt_system (Preconnect);
     dprint (2, (debugfile, "Preconnect result: %d\n", rc));
-    if (rc)
-    {
+    if (rc) {
       save_errno = errno;
       mutt_perror (_("Preconnect command failed."));
       mutt_sleep (1);
-      
+
       return save_errno;
     }
   }
@@ -310,7 +302,7 @@ static int socket_preconnect (void)
 }
 
 /* socket_connect: set up to connect to a socket fd. */
-static int socket_connect (int fd, struct sockaddrsa)
+static int socket_connect (int fd, struct sockaddr *sa)
 {
   int sa_size;
   int save_errno;
@@ -321,37 +313,35 @@ static int socket_connect (int fd, struct sockaddr* sa)
   else if (sa->sa_family == AF_INET6)
     sa_size = sizeof (struct sockaddr_in6);
 #endif
-  else
-  {
+  else {
     dprint (1, (debugfile, "Unknown address family!\n"));
     return -1;
   }
-  
+
   if (ConnectTimeout > 0)
-      alarm (ConnectTimeout);
+    alarm (ConnectTimeout);
 
   mutt_allow_interrupt (1);
 
   save_errno = 0;
 
-  if (connect (fd, sa, sa_size) < 0)
-  {
-      save_errno = errno;
-      dprint (2, (debugfile, "Connection failed. errno: %d...\n", errno));
-      SigInt = 0;      /* reset in case we caught SIGINTR while in connect() */
+  if (connect (fd, sa, sa_size) < 0) {
+    save_errno = errno;
+    dprint (2, (debugfile, "Connection failed. errno: %d...\n", errno));
+    SigInt = 0;                 /* reset in case we caught SIGINTR while in connect() */
   }
 
   if (ConnectTimeout > 0)
-      alarm (0);
+    alarm (0);
   mutt_allow_interrupt (0);
 
   return save_errno;
 }
 
 /* socket_new_conn: allocate and initialise a new connection. */
-static CONNECTIONsocket_new_conn ()
+static CONNECTION *socket_new_conn ()
 {
-  CONNECTIONconn;
+  CONNECTION *conn;
 
   conn = (CONNECTION *) safe_calloc (1, sizeof (CONNECTION));
   conn->fd = -1;
@@ -359,54 +349,52 @@ static CONNECTION* socket_new_conn ()
   return conn;
 }
 
-int raw_socket_close (CONNECTION *conn)
+int raw_socket_close (CONNECTION * conn)
 {
   return close (conn->fd);
 }
 
-int raw_socket_read (CONNECTION* conn, char* buf, size_t len)
+int raw_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
   int rc;
 
-  if ((rc = read (conn->fd, buf, len)) == -1)
-  {
+  if ((rc = read (conn->fd, buf, len)) == -1) {
     mutt_error (_("Error talking to %s (%s)"), conn->account.host,
-               strerror (errno));
+                strerror (errno));
     mutt_sleep (2);
   }
 
   return rc;
 }
 
-int raw_socket_write (CONNECTION* conn, const char* buf, size_t count)
+int raw_socket_write (CONNECTION * conn, const char *buf, size_t count)
 {
   int rc;
 
-  if ((rc = write (conn->fd, buf, count)) == -1)
-  {
+  if ((rc = write (conn->fd, buf, count)) == -1) {
     mutt_error (_("Error talking to %s (%s)"), conn->account.host,
-               strerror (errno));
+                strerror (errno));
     mutt_sleep (2);
   }
 
   return rc;
 }
 
-int raw_socket_open (CONNECTION* conn)
+int raw_socket_open (CONNECTION * conn)
 {
   int rc;
   int fd;
 
   char *host_idna = NULL;
-  
+
 #ifdef HAVE_GETADDRINFO
 /* --- IPv4/6 --- */
 
   /* "65536\0" */
   char port[6];
   struct addrinfo hints;
-  struct addrinfores;
-  struct addrinfocur;
+  struct addrinfo *res;
+  struct addrinfo *cur;
 
   /* we accept v4 or v6 STREAM sockets */
   memset (&hints, 0, sizeof (hints));
@@ -419,10 +407,9 @@ int raw_socket_open (CONNECTION* conn)
   hints.ai_socktype = SOCK_STREAM;
 
   snprintf (port, sizeof (port), "%d", conn->account.port);
-  
+
 # ifdef HAVE_LIBIDN
-  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
-  {
+  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS) {
     mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
     return -1;
   }
@@ -432,35 +419,31 @@ int raw_socket_open (CONNECTION* conn)
 
   mutt_message (_("Looking up %s..."), conn->account.host);
 
-  
+
   rc = getaddrinfo (host_idna, port, &hints, &res);
 
 # ifdef HAVE_LIBIDN
   FREE (&host_idna);
 # endif
 
-  if (rc)
-  {
+  if (rc) {
     mutt_error (_("Could not find the host \"%s\""), conn->account.host);
     return -1;
   }
 
-  mutt_message (_("Connecting to %s..."), conn->account.host); 
+  mutt_message (_("Connecting to %s..."), conn->account.host);
 
   rc = -1;
-  for (cur = res; cur != NULL; cur = cur->ai_next)
-  {
+  for (cur = res; cur != NULL; cur = cur->ai_next) {
     fd = socket (cur->ai_family, cur->ai_socktype, cur->ai_protocol);
-    if (fd >= 0)
-    {
-      if ((rc = socket_connect (fd, cur->ai_addr)) == 0)
-      {
-       fcntl (fd, F_SETFD, FD_CLOEXEC);
-       conn->fd = fd;
-       break;
+    if (fd >= 0) {
+      if ((rc = socket_connect (fd, cur->ai_addr)) == 0) {
+        fcntl (fd, F_SETFD, FD_CLOEXEC);
+        conn->fd = fd;
+        break;
       }
       else
-       close (fd);
+        close (fd);
     }
   }
 
@@ -470,7 +453,7 @@ int raw_socket_open (CONNECTION* conn)
   /* --- IPv4 only --- */
 
   struct sockaddr_in sin;
-  struct hostenthe;
+  struct hostent *he;
   int i;
 
   memset (&sin, 0, sizeof (sin));
@@ -478,8 +461,7 @@ int raw_socket_open (CONNECTION* conn)
   sin.sin_family = AF_INET;
 
 # ifdef HAVE_LIBIDN
-  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
-  {
+  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS) {
     mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
     return -1;
   }
@@ -489,13 +471,12 @@ int raw_socket_open (CONNECTION* conn)
 
   mutt_message (_("Looking up %s..."), conn->account.host);
 
-  if ((he = gethostbyname (host_idna)) == NULL)
-  {
+  if ((he = gethostbyname (host_idna)) == NULL) {
 # ifdef HAVE_LIBIDN
     FREE (&host_idna);
 # endif
     mutt_error (_("Could not find the host \"%s\""), conn->account.host);
-       
+
     return -1;
   }
 
@@ -503,34 +484,30 @@ int raw_socket_open (CONNECTION* conn)
   FREE (&host_idna);
 # endif
 
-  mutt_message (_("Connecting to %s..."), conn->account.host); 
+  mutt_message (_("Connecting to %s..."), conn->account.host);
 
   rc = -1;
-  for (i = 0; he->h_addr_list[i] != NULL; i++)
-  {
+  for (i = 0; he->h_addr_list[i] != NULL; i++) {
     memcpy (&sin.sin_addr, he->h_addr_list[i], he->h_length);
     fd = socket (PF_INET, SOCK_STREAM, IPPROTO_IP);
 
-    if (fd >= 0)
-    {
-      if ((rc = socket_connect (fd, (struct sockaddr*) &sin)) == 0)
-      {
-       conn->fd = fd;
-       break;
+    if (fd >= 0) {
+      if ((rc = socket_connect (fd, (struct sockaddr *) &sin)) == 0) {
+        conn->fd = fd;
+        break;
       }
       else
-       close (fd);
+        close (fd);
     }
   }
 
 #endif
-  if (rc)
-  {
+  if (rc) {
     mutt_error (_("Could not connect to %s (%s)."), conn->account.host,
-           (rc > 0) ? strerror (rc) : _("unknown error"));
+                (rc > 0) ? strerror (rc) : _("unknown error"));
     mutt_sleep (2);
     return -1;
   }
-  
+
   return 0;
 }
index 5483cb6..6ceeeac 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _MUTT_SOCKET_H_
 #define _MUTT_SOCKET_H_ 1
@@ -28,8 +28,7 @@
 #define M_SOCK_LOG_HDR  3
 #define M_SOCK_LOG_FULL 4
 
-typedef struct _connection
-{
+typedef struct _connection {
   ACCOUNT account;
   /* security strength factor, in bits */
   unsigned int ssf;
@@ -44,29 +43,33 @@ typedef struct _connection
   struct _connection *next;
 
   void *sockdata;
-  int (*conn_read) (struct _connection* conn, char* buf, size_t len);
-  int (*conn_write) (struct _connection *conn, const char *buf, size_t count);
-  int (*conn_open) (struct _connection *conn);
-  int (*conn_close) (struct _connection *conn);
+  int (*conn_read) (struct _connection * conn, char *buf, size_t len);
+  int (*conn_write) (struct _connection * conn, const char *buf,
+                     size_t count);
+  int (*conn_open) (struct _connection * conn);
+  int (*conn_close) (struct _connection * conn);
 } CONNECTION;
 
-int mutt_socket_open (CONNECTION* conn);
-int mutt_socket_close (CONNECTION* conn);
-int mutt_socket_read (CONNECTION* conn, char* buf, size_t len);
-int mutt_socket_readchar (CONNECTION *conn, char *c);
+int mutt_socket_open (CONNECTION * conn);
+int mutt_socket_close (CONNECTION * conn);
+int mutt_socket_read (CONNECTION * conn, char *buf, size_t len);
+int mutt_socket_readchar (CONNECTION * conn, char *c);
+
 #define mutt_socket_readln(A,B,C) mutt_socket_readln_d(A,B,C,M_SOCK_LOG_CMD)
-int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION *conn, int dbg);
+int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION * conn,
+                          int dbg);
 #define mutt_socket_write(A,B) mutt_socket_write_d(A,B,M_SOCK_LOG_CMD);
-int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg);
+int mutt_socket_write_d (CONNECTION * conn, const char *buf, int dbg);
 
 /* stupid hack for imap_logout_all */
-CONNECTION* mutt_socket_head (void);
-void mutt_socket_free (CONNECTION* conn);
-CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account);
+CONNECTION *mutt_socket_head (void);
+void mutt_socket_free (CONNECTION * conn);
+CONNECTION *mutt_conn_find (const CONNECTION * start,
+                            const ACCOUNT * account);
 
-int raw_socket_read (CONNECTION* conn, char* buf, size_t len);
-int raw_socket_write (CONNECTION* conn, const char* buf, size_t count);
-int raw_socket_open (CONNECTION *conn);
-int raw_socket_close (CONNECTION *conn);
+int raw_socket_read (CONNECTION * conn, char *buf, size_t len);
+int raw_socket_write (CONNECTION * conn, const char *buf, size_t count);
+int raw_socket_open (CONNECTION * conn);
+int raw_socket_close (CONNECTION * conn);
 
 #endif /* _MUTT_SOCKET_H_ */
index a56147d..317728c 100644 (file)
 #define HAVE_ENTROPY() (RAND_status() == 1)
 #else
 static int entropy_byte_count = 0;
+
 /* OpenSSL fills the entropy pool from /dev/urandom if it exists */
 #define HAVE_ENTROPY() (!access(DEVRANDOM, R_OK) || entropy_byte_count >= 16)
 #endif
 
-typedef struct _sslsockdata
-{
+typedef struct _sslsockdata {
   SSL_CTX *ctx;
   SSL *ssl;
   X509 *cert;
-}
-sslsockdata;
+} sslsockdata;
 
 /* local prototypes */
 int ssl_init (void);
 static int add_entropy (const char *file);
-static int ssl_socket_read (CONNECTION* conn, char* buf, size_t len);
-static int ssl_socket_write (CONNECTION* conn, const char* buf, size_t len);
+static int ssl_socket_read (CONNECTION * conn, char *buf, size_t len);
+static int ssl_socket_write (CONNECTION * conn, const char *buf, size_t len);
 static int ssl_socket_open (CONNECTION * conn);
 static int ssl_socket_close (CONNECTION * conn);
-static int tls_close (CONNECTION* conn);
+static int tls_close (CONNECTION * conn);
 static int ssl_check_certificate (sslsockdata * data);
-static void ssl_get_client_cert(sslsockdata *ssldata, CONNECTION *conn);
-static int ssl_passwd_cb(char *buf, int size, int rwflag, void *userdata);
-static int ssl_negotiate (sslsockdata*);
+static void ssl_get_client_cert (sslsockdata * ssldata, CONNECTION * conn);
+static int ssl_passwd_cb (char *buf, int size, int rwflag, void *userdata);
+static int ssl_negotiate (sslsockdata *);
 
 /* mutt_ssl_starttls: Negotiate TLS over an already opened connection.
  *   TODO: Merge this code better with ssl_socket_open. */
-int mutt_ssl_starttls (CONNECTION* conn)
+int mutt_ssl_starttls (CONNECTION * conn)
 {
-  sslsockdatassldata;
+  sslsockdata *ssldata;
   int maxbits;
 
-  if (ssl_init())
+  if (ssl_init ())
     goto bail;
 
-  ssldata = (sslsockdata*) safe_calloc (1, sizeof (sslsockdata));
+  ssldata = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata));
   /* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS. */
-  if (! (ssldata->ctx = SSL_CTX_new (TLSv1_client_method ())))
-  {
+  if (!(ssldata->ctx = SSL_CTX_new (TLSv1_client_method ()))) {
     dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL_CTX\n"));
     goto bail_ssldata;
   }
 
-  ssl_get_client_cert(ssldata, conn);
+  ssl_get_client_cert (ssldata, conn);
 
-  if (! (ssldata->ssl = SSL_new (ssldata->ctx)))
-  {
+  if (!(ssldata->ssl = SSL_new (ssldata->ctx))) {
     dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL\n"));
     goto bail_ctx;
   }
 
-  if (SSL_set_fd (ssldata->ssl, conn->fd) != 1)
-  {
+  if (SSL_set_fd (ssldata->ssl, conn->fd) != 1) {
     dprint (1, (debugfile, "mutt_ssl_starttls: Error setting fd\n"));
     goto bail_ssl;
   }
@@ -121,17 +117,17 @@ int mutt_ssl_starttls (CONNECTION* conn)
   conn->conn_close = tls_close;
 
   conn->ssf = SSL_CIPHER_get_bits (SSL_get_current_cipher (ssldata->ssl),
-    &maxbits);
+                                   &maxbits);
 
   return 0;
 
- bail_ssl:
+bail_ssl:
   FREE (&ssldata->ssl);
- bail_ctx:
+bail_ctx:
   FREE (&ssldata->ctx);
- bail_ssldata:
+bail_ssldata:
   FREE (&ssldata);
- bail:
+bail:
   return -1;
 }
 
@@ -153,16 +149,15 @@ int ssl_init (void)
   if (init_complete)
     return 0;
 
-  if (! HAVE_ENTROPY())
-  {
+  if (!HAVE_ENTROPY ()) {
     /* load entropy from files */
     add_entropy (SslEntropyFile);
     add_entropy (RAND_file_name (path, sizeof (path)));
-  
+
     /* load entropy from egd sockets */
 #ifdef HAVE_RAND_EGD
     add_entropy (getenv ("EGDSOCKET"));
-    snprintf (path, sizeof(path), "%s/.entropy", NONULL(Homedir));
+    snprintf (path, sizeof (path), "%s/.entropy", NONULL (Homedir));
     add_entropy (path);
     add_entropy ("/tmp/entropy");
 #endif
@@ -170,8 +165,7 @@ int ssl_init (void)
     /* shuffle $RANDFILE (or ~/.rnd if unset) */
     RAND_write_file (RAND_file_name (path, sizeof (path)));
     mutt_clear_error ();
-    if (! HAVE_ENTROPY())
-    {
+    if (!HAVE_ENTROPY ()) {
       mutt_error (_("Failed to find enough entropy on your system"));
       mutt_sleep (2);
       return -1;
@@ -180,8 +174,8 @@ int ssl_init (void)
 
   /* I don't think you can do this just before reading the error. The call
    * itself might clobber the last SSL error. */
-  SSL_load_error_strings();
-  SSL_library_init();
+  SSL_load_error_strings ();
+  SSL_library_init ();
   init_complete = 1;
   return 0;
 }
@@ -191,19 +185,18 @@ static int add_entropy (const char *file)
   struct stat st;
   int n = -1;
 
-  if (!file) return 0;
+  if (!file)
+    return 0;
 
   if (stat (file, &st) == -1)
     return errno == ENOENT ? 0 : -1;
 
-  mutt_message (_("Filling entropy pool: %s...\n"),
-               file);
-  
+  mutt_message (_("Filling entropy pool: %s...\n"), file);
+
   /* check that the file permissions are secure */
-  if (st.st_uid != getuid () || 
+  if (st.st_uid != getuid () ||
       ((st.st_mode & (S_IWGRP | S_IRGRP)) != 0) ||
-      ((st.st_mode & (S_IWOTH | S_IROTH)) != 0))
-  {
+      ((st.st_mode & (S_IWOTH | S_IROTH)) != 0)) {
     mutt_error (_("%s has insecure permissions!"), file);
     mutt_sleep (2);
     return -1;
@@ -216,12 +209,13 @@ static int add_entropy (const char *file)
     n = RAND_load_file (file, -1);
 
 #ifndef HAVE_RAND_STATUS
-  if (n > 0) entropy_byte_count += n;
+  if (n > 0)
+    entropy_byte_count += n;
 #endif
   return n;
 }
 
-static int ssl_socket_open_err (CONNECTION *conn)
+static int ssl_socket_open_err (CONNECTION * conn)
 {
   mutt_error (_("SSL disabled due the lack of entropy"));
   mutt_sleep (2);
@@ -231,29 +225,30 @@ static int ssl_socket_open_err (CONNECTION *conn)
 
 int ssl_socket_setup (CONNECTION * conn)
 {
-  if (ssl_init() < 0)
-  {
+  if (ssl_init () < 0) {
     conn->conn_open = ssl_socket_open_err;
     return -1;
   }
 
-  conn->conn_open      = ssl_socket_open;
-  conn->conn_read      = ssl_socket_read;
-  conn->conn_write     = ssl_socket_write;
-  conn->conn_close     = ssl_socket_close;
+  conn->conn_open = ssl_socket_open;
+  conn->conn_read = ssl_socket_read;
+  conn->conn_write = ssl_socket_write;
+  conn->conn_close = ssl_socket_close;
 
   return 0;
 }
 
-static int ssl_socket_read (CONNECTION* conn, char* buf, size_t len)
+static int ssl_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
   sslsockdata *data = conn->sockdata;
+
   return SSL_read (data->ssl, buf, len);
 }
 
-static int ssl_socket_write (CONNECTION* conn, const char* buf, size_t len)
+static int ssl_socket_write (CONNECTION * conn, const char *buf, size_t len)
 {
   sslsockdata *data = conn->sockdata;
+
   return SSL_write (data->ssl, buf, len);
 }
 
@@ -271,42 +266,38 @@ static int ssl_socket_open (CONNECTION * conn)
   data->ctx = SSL_CTX_new (SSLv23_client_method ());
 
   /* disable SSL protocols as needed */
-  if (!option(OPTTLSV1)) 
-  {
-    SSL_CTX_set_options(data->ctx, SSL_OP_NO_TLSv1);
+  if (!option (OPTTLSV1)) {
+    SSL_CTX_set_options (data->ctx, SSL_OP_NO_TLSv1);
   }
-  if (!option(OPTSSLV2)) 
-  {
-    SSL_CTX_set_options(data->ctx, SSL_OP_NO_SSLv2);
+  if (!option (OPTSSLV2)) {
+    SSL_CTX_set_options (data->ctx, SSL_OP_NO_SSLv2);
   }
-  if (!option(OPTSSLV3)) 
-  {
-    SSL_CTX_set_options(data->ctx, SSL_OP_NO_SSLv3);
+  if (!option (OPTSSLV3)) {
+    SSL_CTX_set_options (data->ctx, SSL_OP_NO_SSLv3);
   }
 
-  ssl_get_client_cert(data, conn);
+  ssl_get_client_cert (data, conn);
 
   data->ssl = SSL_new (data->ctx);
   SSL_set_fd (data->ssl, conn->fd);
 
-  if (ssl_negotiate(data))
-  {
+  if (ssl_negotiate (data)) {
     mutt_socket_close (conn);
     return -1;
   }
-  
+
   conn->ssf = SSL_CIPHER_get_bits (SSL_get_current_cipher (data->ssl),
-    &maxbits);
+                                   &maxbits);
 
   return 0;
 }
 
 /* ssl_negotiate: After SSL state has been initialised, attempt to negotiate
  *   SSL over the wire, including certificate checks. */
-static int ssl_negotiate (sslsockdata* ssldata)
+static int ssl_negotiate (sslsockdata * ssldata)
 {
   int err;
-  const charerrmsg;
+  const char *errmsg;
 
 #if OPENSSL_VERSION_NUMBER >= 0x00906000L
   /* This only exists in 0.9.6 and above. Without it we may get interrupted
@@ -314,10 +305,8 @@ static int ssl_negotiate (sslsockdata* ssldata)
   SSL_set_mode (ssldata->ssl, SSL_MODE_AUTO_RETRY);
 #endif
 
-  if ((err = SSL_connect (ssldata->ssl)) != 1)
-  {
-    switch (SSL_get_error (ssldata->ssl, err))
-    {
+  if ((err = SSL_connect (ssldata->ssl)) != 1) {
+    switch (SSL_get_error (ssldata->ssl, err)) {
     case SSL_ERROR_SYSCALL:
       errmsg = _("I/O error");
       break;
@@ -327,7 +316,7 @@ static int ssl_negotiate (sslsockdata* ssldata)
     default:
       errmsg = _("unknown error");
     }
-    
+
     mutt_error (_("SSL failed: %s"), errmsg);
     mutt_sleep (1);
 
@@ -335,8 +324,7 @@ static int ssl_negotiate (sslsockdata* ssldata)
   }
 
   ssldata->cert = SSL_get_peer_certificate (ssldata->ssl);
-  if (!ssldata->cert)
-  {
+  if (!ssldata->cert) {
     mutt_error (_("Unable to get certificate from peer"));
     mutt_sleep (1);
     return -1;
@@ -345,8 +333,9 @@ static int ssl_negotiate (sslsockdata* ssldata)
   if (!ssl_check_certificate (ssldata))
     return -1;
 
-  mutt_message (_("SSL connection using %s (%s)"), 
-    SSL_get_cipher_version (ssldata->ssl), SSL_get_cipher_name (ssldata->ssl));
+  mutt_message (_("SSL connection using %s (%s)"),
+                SSL_get_cipher_version (ssldata->ssl),
+                SSL_get_cipher_name (ssldata->ssl));
   mutt_sleep (0);
 
   return 0;
@@ -355,8 +344,8 @@ static int ssl_negotiate (sslsockdata* ssldata)
 static int ssl_socket_close (CONNECTION * conn)
 {
   sslsockdata *data = conn->sockdata;
-  if (data)
-  {
+
+  if (data) {
     SSL_shutdown (data->ssl);
 
     X509_free (data->cert);
@@ -368,7 +357,7 @@ static int ssl_socket_close (CONNECTION * conn)
   return raw_socket_close (conn);
 }
 
-static int tls_close (CONNECTION* conn)
+static int tls_close (CONNECTION * conn)
 {
   int rc;
 
@@ -388,8 +377,7 @@ static char *x509_get_part (char *line, const char *ndx)
   strfcpy (ret, _("Unknown"), sizeof (ret));
 
   c = strstr (line, ndx);
-  if (c)
-  {
+  if (c) {
     c += strlen (ndx);
     c2 = strchr (c, '/');
     if (c2)
@@ -408,31 +396,28 @@ static void x509_fingerprint (char *s, int l, X509 * cert)
   unsigned int n;
   int j;
 
-  if (!X509_digest (cert, EVP_md5 (), md, &n))
-  {
+  if (!X509_digest (cert, EVP_md5 (), md, &n)) {
     snprintf (s, l, "%s", _("[unable to calculate]"));
   }
-  else
-  {
-    for (j = 0; j < (int) n; j++)
-    {
+  else {
+    for (j = 0; j < (int) n; j++) {
       char ch[8];
+
       snprintf (ch, 8, "%02X%s", md[j], (j % 2 ? " " : ""));
       safe_strcat (s, l, ch);
     }
   }
 }
 
-static char *asn1time_to_string (ASN1_UTCTIME *tm)
+static char *asn1time_to_string (ASN1_UTCTIME * tm)
 {
   static char buf[64];
   BIO *bio;
 
   strfcpy (buf, _("[invalid date]"), sizeof (buf));
-  
-  bio = BIO_new (BIO_s_mem());
-  if (bio)
-  {
+
+  bio = BIO_new (BIO_s_mem ());
+  if (bio) {
     if (ASN1_TIME_print (bio, tm))
       (void) BIO_read (bio, buf, sizeof (buf));
     BIO_free (bio);
@@ -441,17 +426,17 @@ static char *asn1time_to_string (ASN1_UTCTIME *tm)
   return buf;
 }
 
-static int check_certificate_by_signer (X509 *peercert)
+static int check_certificate_by_signer (X509 * peercert)
 {
   X509_STORE_CTX xsc;
   X509_STORE *ctx;
   int pass = 0;
 
   ctx = X509_STORE_new ();
-  if (ctx == NULL) return 0;
+  if (ctx == NULL)
+    return 0;
 
-  if (option (OPTSSLSYSTEMCERTS))
-  {
+  if (option (OPTSSLSYSTEMCERTS)) {
     if (X509_STORE_set_default_paths (ctx))
       pass++;
     else
@@ -463,8 +448,7 @@ static int check_certificate_by_signer (X509 *peercert)
   else
     dprint (2, (debugfile, "X509_STORE_load_locations_failed\n"));
 
-  if (pass == 0)
-  {
+  if (pass == 0) {
     /* nothing to do */
     X509_STORE_free (ctx);
     return 0;
@@ -474,14 +458,13 @@ static int check_certificate_by_signer (X509 *peercert)
 
   pass = (X509_verify_cert (&xsc) > 0);
 #ifdef DEBUG
-  if (! pass)
-  {
+  if (!pass) {
     char buf[SHORT_STRING];
     int err;
 
     err = X509_STORE_CTX_get_error (&xsc);
-    snprintf (buf, sizeof (buf), "%s (%d)", 
-       X509_verify_cert_error_string(err), err);
+    snprintf (buf, sizeof (buf), "%s (%d)",
+              X509_verify_cert_error_string (err), err);
     dprint (2, (debugfile, "X509_verify_cert: %s\n", buf));
   }
 #endif
@@ -491,7 +474,7 @@ static int check_certificate_by_signer (X509 *peercert)
   return pass;
 }
 
-static int check_certificate_by_digest (X509 *peercert)
+static int check_certificate_by_digest (X509 * peercert)
 {
   unsigned char peermd[EVP_MAX_MD_SIZE];
   unsigned int peermdlen;
@@ -500,15 +483,13 @@ static int check_certificate_by_digest (X509 *peercert)
   FILE *fp;
 
   /* expiration check */
-  if (X509_cmp_current_time (X509_get_notBefore (peercert)) >= 0)
-  {
+  if (X509_cmp_current_time (X509_get_notBefore (peercert)) >= 0) {
     dprint (2, (debugfile, "Server certificate is not yet valid\n"));
     mutt_error (_("Server certificate is not yet valid"));
     mutt_sleep (2);
     return 0;
   }
-  if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0)
-  {
+  if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0) {
     dprint (2, (debugfile, "Server certificate has expired"));
     mutt_error (_("Server certificate has expired"));
     mutt_sleep (2);
@@ -518,14 +499,12 @@ static int check_certificate_by_digest (X509 *peercert)
   if ((fp = fopen (SslCertFile, "rt")) == NULL)
     return 0;
 
-  if (!X509_digest (peercert, EVP_sha1(), peermd, &peermdlen))
-  {
+  if (!X509_digest (peercert, EVP_sha1 (), peermd, &peermdlen)) {
     fclose (fp);
     return 0;
   }
-  
-  while ((cert = READ_X509_KEY (fp, &cert)) != NULL)
-  {
+
+  while ((cert = READ_X509_KEY (fp, &cert)) != NULL) {
     unsigned char md[EVP_MAX_MD_SIZE];
     unsigned int mdlen;
 
@@ -533,13 +512,13 @@ static int check_certificate_by_digest (X509 *peercert)
      * not even remotely equal.
      */
     if (X509_subject_name_cmp (cert, peercert) != 0 ||
-       X509_issuer_name_cmp (cert, peercert) != 0)
+        X509_issuer_name_cmp (cert, peercert) != 0)
       continue;
 
-    if (!X509_digest (cert, EVP_sha1(), md, &mdlen) || peermdlen != mdlen)
+    if (!X509_digest (cert, EVP_sha1 (), md, &mdlen) || peermdlen != mdlen)
       continue;
-    
-    if (memcmp(peermd, md, mdlen) != 0)
+
+    if (memcmp (peermd, md, mdlen) != 0)
       continue;
 
     pass = 1;
@@ -553,8 +532,7 @@ static int check_certificate_by_digest (X509 *peercert)
 
 static int ssl_check_certificate (sslsockdata * data)
 {
-  char *part[] =
-  {"/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C="};
+  char *part[] = { "/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C=" };
   char helpstr[SHORT_STRING];
   char buf[SHORT_STRING];
   MUTTMENU *menu;
@@ -562,15 +540,13 @@ static int ssl_check_certificate (sslsockdata * data)
   FILE *fp;
   char *name = NULL, *c;
 
-  if (check_certificate_by_signer (data->cert))
-  {
+  if (check_certificate_by_signer (data->cert)) {
     dprint (1, (debugfile, "ssl_check_certificate: signer check passed\n"));
     return 1;
   }
 
   /* automatic check from user's database */
-  if (SslCertFile && check_certificate_by_digest (data->cert))
-  {
+  if (SslCertFile && check_certificate_by_digest (data->cert)) {
     dprint (1, (debugfile, "ssl_check_certificate: digest check passed\n"));
     return 1;
   }
@@ -583,33 +559,34 @@ static int ssl_check_certificate (sslsockdata * data)
     menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
 
   row = 0;
-  strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING);
+  strfcpy (menu->dialog[row], _("This certificate belongs to:"),
+           SHORT_STRING);
   row++;
   name = X509_NAME_oneline (X509_get_subject_name (data->cert),
-                           buf, sizeof (buf));
-  for (i = 0; i < 5; i++)
-  {
+                            buf, sizeof (buf));
+  for (i = 0; i < 5; i++) {
     c = x509_get_part (name, part[i]);
     snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
   }
 
   row++;
-  strfcpy (menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING);
+  strfcpy (menu->dialog[row], _("This certificate was issued by:"),
+           SHORT_STRING);
   row++;
   name = X509_NAME_oneline (X509_get_issuer_name (data->cert),
-                           buf, sizeof (buf));
-  for (i = 0; i < 5; i++)
-  {
+                            buf, sizeof (buf));
+  for (i = 0; i < 5; i++) {
     c = x509_get_part (name, part[i]);
     snprintf (menu->dialog[row++], SHORT_STRING, "   %s", c);
   }
 
   row++;
-  snprintf (menu->dialog[row++], SHORT_STRING, "%s", _("This certificate is valid"));
-  snprintf (menu->dialog[row++], SHORT_STRING, _("   from %s"), 
-      asn1time_to_string (X509_get_notBefore (data->cert)));
-  snprintf (menu->dialog[row++], SHORT_STRING, _("     to %s"), 
-      asn1time_to_string (X509_get_notAfter (data->cert)));
+  snprintf (menu->dialog[row++], SHORT_STRING, "%s",
+            _("This certificate is valid"));
+  snprintf (menu->dialog[row++], SHORT_STRING, _("   from %s"),
+            asn1time_to_string (X509_get_notBefore (data->cert)));
+  snprintf (menu->dialog[row++], SHORT_STRING, _("     to %s"),
+            asn1time_to_string (X509_get_notAfter (data->cert)));
 
   row++;
   buf[0] = '\0';
@@ -617,17 +594,15 @@ static int ssl_check_certificate (sslsockdata * data)
   snprintf (menu->dialog[row++], SHORT_STRING, _("Fingerprint: %s"), buf);
 
   menu->title = _("SSL Certificate check");
-  if (SslCertFile)
-  {
+  if (SslCertFile) {
     menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always");
     menu->keys = _("roa");
   }
-  else
-  {
+  else {
     menu->prompt = _("(r)eject, accept (o)nce");
     menu->keys = _("ro");
   }
-  
+
   helpstr[0] = '\0';
   mutt_make_help (buf, sizeof (buf), _("Exit  "), MENU_GENERIC, OP_EXIT);
   safe_strcat (helpstr, sizeof (helpstr), buf);
@@ -636,69 +611,65 @@ static int ssl_check_certificate (sslsockdata * data)
   menu->help = helpstr;
 
   done = 0;
-  set_option(OPTUNBUFFEREDINPUT);
-  while (!done)
-  {
-    switch (mutt_menuLoop (menu))
-    {
-      case -1:                 /* abort */
-      case OP_MAX + 1:         /* reject */
-      case OP_EXIT:
-        done = 1;
-        break;
-      case OP_MAX + 3:         /* accept always */
-        done = 0;
-        if ((fp = fopen (SslCertFile, "a")))
-       {
-         if (PEM_write_X509 (fp, data->cert))
-           done = 1;
-         fclose (fp);
-       }
-       if (!done)
-        {
-         mutt_error (_("Warning: Couldn't save certificate"));
-         mutt_sleep (2);
-       }
-       else
-        {
-         mutt_message (_("Certificate saved"));
-         mutt_sleep (0);
-       }
-        /* fall through */
-      case OP_MAX + 2:         /* accept once */
-        done = 2;
-        break;
+  set_option (OPTUNBUFFEREDINPUT);
+  while (!done) {
+    switch (mutt_menuLoop (menu)) {
+    case -1:                   /* abort */
+    case OP_MAX + 1:           /* reject */
+    case OP_EXIT:
+      done = 1;
+      break;
+    case OP_MAX + 3:           /* accept always */
+      done = 0;
+      if ((fp = fopen (SslCertFile, "a"))) {
+        if (PEM_write_X509 (fp, data->cert))
+          done = 1;
+        fclose (fp);
+      }
+      if (!done) {
+        mutt_error (_("Warning: Couldn't save certificate"));
+        mutt_sleep (2);
+      }
+      else {
+        mutt_message (_("Certificate saved"));
+        mutt_sleep (0);
+      }
+      /* fall through */
+    case OP_MAX + 2:           /* accept once */
+      done = 2;
+      break;
     }
   }
-  unset_option(OPTUNBUFFEREDINPUT);
+  unset_option (OPTUNBUFFEREDINPUT);
   mutt_menuDestroy (&menu);
   return (done == 2);
 }
 
-static void ssl_get_client_cert(sslsockdata *ssldata, CONNECTION *conn)
+static void ssl_get_client_cert (sslsockdata * ssldata, CONNECTION * conn)
 {
-  if (SslClientCert)
-  {
+  if (SslClientCert) {
     dprint (2, (debugfile, "Using client certificate %s\n", SslClientCert));
-    SSL_CTX_set_default_passwd_cb_userdata(ssldata->ctx, &conn->account);
-    SSL_CTX_set_default_passwd_cb(ssldata->ctx, ssl_passwd_cb);
-    SSL_CTX_use_certificate_file(ssldata->ctx, SslClientCert, SSL_FILETYPE_PEM);
-    SSL_CTX_use_PrivateKey_file(ssldata->ctx, SslClientCert, SSL_FILETYPE_PEM);
+    SSL_CTX_set_default_passwd_cb_userdata (ssldata->ctx, &conn->account);
+    SSL_CTX_set_default_passwd_cb (ssldata->ctx, ssl_passwd_cb);
+    SSL_CTX_use_certificate_file (ssldata->ctx, SslClientCert,
+                                  SSL_FILETYPE_PEM);
+    SSL_CTX_use_PrivateKey_file (ssldata->ctx, SslClientCert,
+                                 SSL_FILETYPE_PEM);
   }
 }
 
-static int ssl_passwd_cb(char *buf, int size, int rwflag, void *userdata)
+static int ssl_passwd_cb (char *buf, int size, int rwflag, void *userdata)
 {
-  ACCOUNT *account = (ACCOUNT*)userdata;
+  ACCOUNT *account = (ACCOUNT *) userdata;
 
   if (mutt_account_getuser (account))
     return 0;
 
   dprint (2, (debugfile, "ssl_passwd_cb: getting password for %s@%s:%u\n",
-             account->user, account->host, account->port));
-  
+              account->user, account->host, account->port));
+
   if (mutt_account_getpass (account))
     return 0;
 
-  return snprintf(buf, size, "%s", account->pass);
+  return snprintf (buf, size, "%s", account->pass);
 }
index 985c61e..8e1c652 100644 (file)
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _MUTT_SSL_H_
 #define _MUTT_SSL_H_ 1
 #include "mutt_socket.h"
 
 #ifdef USE_SSL
-int mutt_ssl_starttls (CONNECTION* conn);
+int mutt_ssl_starttls (CONNECTION * conn);
 
-extern int ssl_socket_setup (CONNECTION *conn);
+extern int ssl_socket_setup (CONNECTION * conn);
 #endif
 #ifdef USE_GNUTLS
-int mutt_gnutls_starttls (CONNECTION* conn);
+int mutt_gnutls_starttls (CONNECTION * conn);
 
-extern int mutt_gnutls_socket_setup (CONNECTION *conn);
+extern int mutt_gnutls_socket_setup (CONNECTION * conn);
 #endif
 #ifdef USE_NSS
-int mutt_nss_socket_setup (CONNECTION* conn);
+int mutt_nss_socket_setup (CONNECTION * conn);
 #endif
 #endif /* _MUTT_SSL_H_ */
index 4a38893..6983328 100644 (file)
 #include "mutt_ssl.h"
 #include "mutt_regex.h"
 
-typedef struct _tlssockdata
-{
+typedef struct _tlssockdata {
   gnutls_session state;
   gnutls_certificate_credentials xcred;
-}
-tlssockdata;
+} tlssockdata;
 
 /* local prototypes */
-static int tls_socket_read (CONNECTION* conn, char* buf, size_t len);
-static int tls_socket_write (CONNECTION* conn, const char* buf, size_t len);
-static int tls_socket_open (CONNECTION* conn);
-static int tls_socket_close (CONNECTION* conn);
-static int tls_starttls_close (CONNECTION* conn);
+static int tls_socket_read (CONNECTION * conn, char *buf, size_t len);
+static int tls_socket_write (CONNECTION * conn, const char *buf, size_t len);
+static int tls_socket_open (CONNECTION * conn);
+static int tls_socket_close (CONNECTION * conn);
+static int tls_starttls_close (CONNECTION * conn);
 
 static int tls_init (void);
-static int tls_negotiate (CONNECTION* conn);
-static int tls_check_certificate (CONNECTION* conn);
+static int tls_negotiate (CONNECTION * conn);
+static int tls_check_certificate (CONNECTION * conn);
 
 
 static int tls_init (void)
@@ -60,10 +58,9 @@ static int tls_init (void)
   if (init_complete)
     return 0;
 
-  err = gnutls_global_init();
-  if (err < 0)
-  {
-    mutt_error ("gnutls_global_init: %s", gnutls_strerror(err));
+  err = gnutls_global_init ();
+  if (err < 0) {
+    mutt_error ("gnutls_global_init: %s", gnutls_strerror (err));
     mutt_sleep (2);
     return -1;
   }
@@ -72,34 +69,32 @@ static int tls_init (void)
   return 0;
 }
 
-int mutt_gnutls_socket_setup (CONNECTION* conn)
+int mutt_gnutls_socket_setup (CONNECTION * conn)
 {
-  if (tls_init() < 0)
+  if (tls_init () < 0)
     return -1;
 
-  conn->conn_open      = tls_socket_open;
-  conn->conn_read      = tls_socket_read;
-  conn->conn_write     = tls_socket_write;
-  conn->conn_close     = tls_socket_close;
+  conn->conn_open = tls_socket_open;
+  conn->conn_read = tls_socket_read;
+  conn->conn_write = tls_socket_write;
+  conn->conn_close = tls_socket_close;
 
   return 0;
 }
 
-static int tls_socket_read (CONNECTION* conn, char* buf, size_t len)
+static int tls_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
   tlssockdata *data = conn->sockdata;
   int ret;
 
-  if (!data)
-  {
+  if (!data) {
     mutt_error ("Error: no TLS socket open");
     mutt_sleep (2);
     return -1;
   }
 
   ret = gnutls_record_recv (data->state, buf, len);
-  if (gnutls_error_is_fatal(ret) == 1)
-  {
+  if (gnutls_error_is_fatal (ret) == 1) {
     mutt_error ("tls_socket_read (%s)", gnutls_strerror (ret));
     mutt_sleep (4);
     return -1;
@@ -107,21 +102,19 @@ static int tls_socket_read (CONNECTION* conn, char* buf, size_t len)
   return ret;
 }
 
-static int tls_socket_write (CONNECTION* conn, const char* buf, size_t len)
+static int tls_socket_write (CONNECTION * conn, const char *buf, size_t len)
 {
   tlssockdata *data = conn->sockdata;
   int ret;
 
-  if (!data)
-  {
+  if (!data) {
     mutt_error ("Error: no TLS socket open");
     mutt_sleep (2);
     return -1;
   }
 
   ret = gnutls_record_send (data->state, buf, len);
-  if (gnutls_error_is_fatal(ret) == 1)
-  {
+  if (gnutls_error_is_fatal (ret) == 1) {
     mutt_error ("tls_socket_write (%s)", gnutls_strerror (ret));
     mutt_sleep (4);
     return -1;
@@ -129,13 +122,12 @@ static int tls_socket_write (CONNECTION* conn, const char* buf, size_t len)
   return ret;
 }
 
-static int tls_socket_open (CONNECTION* conn)
+static int tls_socket_open (CONNECTION * conn)
 {
   if (raw_socket_open (conn) < 0)
     return -1;
 
-  if (tls_negotiate (conn) < 0)
-  {
+  if (tls_negotiate (conn) < 0) {
     tls_socket_close (conn);
     return -1;
   }
@@ -143,22 +135,22 @@ static int tls_socket_open (CONNECTION* conn)
   return 0;
 }
 
-int mutt_gnutls_starttls (CONNECTION* conn)
+int mutt_gnutls_starttls (CONNECTION * conn)
 {
-  if (tls_init() < 0)
+  if (tls_init () < 0)
     return -1;
 
   if (tls_negotiate (conn) < 0)
     return -1;
 
-  conn->conn_read      = tls_socket_read;
-  conn->conn_write     = tls_socket_write;
-  conn->conn_close     = tls_starttls_close;
+  conn->conn_read = tls_socket_read;
+  conn->conn_write = tls_socket_write;
+  conn->conn_close = tls_starttls_close;
 
   return 0;
 }
 
-static int protocol_priority[] = {GNUTLS_TLS1, GNUTLS_SSL3, 0};
+static int protocol_priority[] = { GNUTLS_TLS1, GNUTLS_SSL3, 0 };
 
 /* tls_negotiate: After TLS state has been initialised, attempt to negotiate
  *   TLS over the wire, including certificate checks. */
@@ -170,20 +162,19 @@ static int tls_negotiate (CONNECTION * conn)
   data = (tlssockdata *) safe_calloc (1, sizeof (tlssockdata));
   conn->sockdata = data;
   err = gnutls_certificate_allocate_credentials (&data->xcred);
-  if (err < 0)
-  {
-    FREE(&conn->sockdata);
-    mutt_error ("gnutls_certificate_allocate_credentials: %s", gnutls_strerror(err));
+  if (err < 0) {
+    FREE (&conn->sockdata);
+    mutt_error ("gnutls_certificate_allocate_credentials: %s",
+                gnutls_strerror (err));
     mutt_sleep (2);
     return -1;
   }
 
   gnutls_certificate_set_x509_trust_file (data->xcred, SslCertFile,
-                                         GNUTLS_X509_FMT_PEM);
+                                          GNUTLS_X509_FMT_PEM);
   /* ignore errors, maybe file doesn't exist yet */
 
-  if (SslCACertFile)
-  {
+  if (SslCACertFile) {
     gnutls_certificate_set_x509_trust_file (data->xcred, SslCACertFile,
                                             GNUTLS_X509_FMT_PEM);
   }
@@ -193,39 +184,35 @@ static int tls_negotiate (CONNECTION * conn)
   gnutls_set_x509_cert_callback (data->xcred, cert_callback);
 */
 
-  gnutls_init(&data->state, GNUTLS_CLIENT);
+  gnutls_init (&data->state, GNUTLS_CLIENT);
 
   /* set socket */
-  gnutls_transport_set_ptr (data->state, (gnutls_transport_ptr)conn->fd);
+  gnutls_transport_set_ptr (data->state, (gnutls_transport_ptr) conn->fd);
 
   /* disable TLS/SSL protocols as needed */
-  if (!option(OPTTLSV1) && !option(OPTSSLV3))
-  {
+  if (!option (OPTTLSV1) && !option (OPTSSLV3)) {
     mutt_error (_("All available protocols for TLS/SSL connection disabled"));
     goto fail;
   }
-  else if (!option(OPTTLSV1))
-  {
+  else if (!option (OPTTLSV1)) {
     protocol_priority[0] = GNUTLS_SSL3;
     protocol_priority[1] = 0;
   }
-  else if (!option(OPTSSLV3))
-  {
+  else if (!option (OPTSSLV3)) {
     protocol_priority[0] = GNUTLS_TLS1;
     protocol_priority[1] = 0;
   }
   /*
-  else
-    use the list set above
-  */
+     else
+     use the list set above
+   */
 
   /* We use default priorities (see gnutls documentation),
      except for protocol version */
   gnutls_set_default_priority (data->state);
   gnutls_protocol_set_priority (data->state, protocol_priority);
 
-  if (SslDHPrimeBits > 0)
-  {
+  if (SslDHPrimeBits > 0) {
     gnutls_dh_set_prime_bits (data->state, SslDHPrimeBits);
   }
 
@@ -235,54 +222,53 @@ static int tls_negotiate (CONNECTION * conn)
 
   gnutls_credentials_set (data->state, GNUTLS_CRD_CERTIFICATE, data->xcred);
 
-  err = gnutls_handshake(data->state);
+  err = gnutls_handshake (data->state);
 
-  while (err == GNUTLS_E_AGAIN || err == GNUTLS_E_INTERRUPTED)
-  {
-    err = gnutls_handshake(data->state);
+  while (err == GNUTLS_E_AGAIN || err == GNUTLS_E_INTERRUPTED) {
+    err = gnutls_handshake (data->state);
   }
   if (err < 0) {
-    if (err == GNUTLS_E_FATAL_ALERT_RECEIVED)
-    {
-      mutt_error("gnutls_handshake: %s(%s)", gnutls_strerror(err),
-                gnutls_alert_get_name(gnutls_alert_get(data->state)));
+    if (err == GNUTLS_E_FATAL_ALERT_RECEIVED) {
+      mutt_error ("gnutls_handshake: %s(%s)", gnutls_strerror (err),
+                  gnutls_alert_get_name (gnutls_alert_get (data->state)));
     }
-    else
-    {
-      mutt_error("gnutls_handshake: %s", gnutls_strerror(err));
+    else {
+      mutt_error ("gnutls_handshake: %s", gnutls_strerror (err));
     }
     mutt_sleep (2);
     goto fail;
   }
 
-  if (!tls_check_certificate(conn))
+  if (!tls_check_certificate (conn))
     goto fail;
 
   /* set Security Strength Factor (SSF) for SASL */
   /* NB: gnutls_cipher_get_key_size() returns key length in bytes */
-  conn->ssf = gnutls_cipher_get_key_size (gnutls_cipher_get (data->state)) * 8;
+  conn->ssf =
+    gnutls_cipher_get_key_size (gnutls_cipher_get (data->state)) * 8;
 
   mutt_message (_("SSL/TLS connection using %s (%s/%s/%s)"),
-               gnutls_protocol_get_name (gnutls_protocol_get_version (data->state)),
-               gnutls_kx_get_name (gnutls_kx_get (data->state)),
-               gnutls_cipher_get_name (gnutls_cipher_get (data->state)),
-               gnutls_mac_get_name (gnutls_mac_get (data->state)));
+                gnutls_protocol_get_name (gnutls_protocol_get_version
+                                          (data->state)),
+                gnutls_kx_get_name (gnutls_kx_get (data->state)),
+                gnutls_cipher_get_name (gnutls_cipher_get (data->state)),
+                gnutls_mac_get_name (gnutls_mac_get (data->state)));
   mutt_sleep (0);
 
   return 0;
 
- fail:
+fail:
   gnutls_certificate_free_credentials (data->xcred);
   gnutls_deinit (data->state);
-  FREE(&conn->sockdata);
+  FREE (&conn->sockdata);
   return -1;
 }
 
-static int tls_socket_close (CONNECTION* conn)
+static int tls_socket_close (CONNECTION * conn)
 {
   tlssockdata *data = conn->sockdata;
-  if (data)
-  {
+
+  if (data) {
     gnutls_bye (data->state, GNUTLS_SHUT_RDWR);
 
     gnutls_certificate_free_credentials (data->xcred);
@@ -293,7 +279,7 @@ static int tls_socket_close (CONNECTION* conn)
   return raw_socket_close (conn);
 }
 
-static int tls_starttls_close (CONNECTION* conn)
+static int tls_starttls_close (CONNECTION * conn)
 {
   int rc;
 
@@ -308,7 +294,7 @@ static int tls_starttls_close (CONNECTION* conn)
 #define CERT_SEP "-----BEGIN"
 
 /* this bit is based on read_ca_file() in gnutls */
-static int tls_compare_certificates (const gnutls_datum *peercert)
+static int tls_compare_certificates (const gnutls_datum * peercert)
 {
   gnutls_datum cert;
   unsigned char *ptr;
@@ -318,48 +304,45 @@ static int tls_compare_certificates (const gnutls_datum *peercert)
   unsigned char *b64_data_data;
   struct stat filestat;
 
-  if (stat(SslCertFile, &filestat) == -1)
+  if (stat (SslCertFile, &filestat) == -1)
     return 0;
 
-  b64_data.size = filestat.st_size+1;
+  b64_data.size = filestat.st_size + 1;
   b64_data_data = (unsigned char *) safe_calloc (1, b64_data.size);
-  b64_data_data[b64_data.size-1] = '\0';
+  b64_data_data[b64_data.size - 1] = '\0';
   b64_data.data = b64_data_data;
 
-  fd1 = fopen(SslCertFile, "r");
+  fd1 = fopen (SslCertFile, "r");
   if (fd1 == NULL) {
     return 0;
   }
 
-  b64_data.size = fread(b64_data.data, 1, b64_data.size, fd1);
-  fclose(fd1);
+  b64_data.size = fread (b64_data.data, 1, b64_data.size, fd1);
+  fclose (fd1);
 
   do {
-    ret = gnutls_pem_base64_decode_alloc(NULL, &b64_data, &cert);
-    if (ret != 0)
-    {
+    ret = gnutls_pem_base64_decode_alloc (NULL, &b64_data, &cert);
+    if (ret != 0) {
       FREE (&b64_data_data);
       return 0;
     }
 
-    ptr = (unsigned char *)strstr(b64_data.data, CERT_SEP) + 1;
-    ptr = (unsigned char *)strstr(ptr, CERT_SEP);
+    ptr = (unsigned char *) strstr (b64_data.data, CERT_SEP) + 1;
+    ptr = (unsigned char *) strstr (ptr, CERT_SEP);
 
     b64_data.size = b64_data.size - (ptr - b64_data.data);
     b64_data.data = ptr;
 
-    if (cert.size == peercert->size)
-    {
-      if (memcmp (cert.data, peercert->data, cert.size) == 0)
-      {
-       /* match found */
-        gnutls_free(cert.data);
-       FREE (&b64_data_data);
-       return 1;
+    if (cert.size == peercert->size) {
+      if (memcmp (cert.data, peercert->data, cert.size) == 0) {
+        /* match found */
+        gnutls_free (cert.data);
+        FREE (&b64_data_data);
+        return 1;
       }
     }
 
-    gnutls_free(cert.data);
+    gnutls_free (cert.data);
   } while (ptr != NULL);
 
   /* no match found */
@@ -368,7 +351,7 @@ static int tls_compare_certificates (const gnutls_datum *peercert)
 }
 
 static void tls_fingerprint (gnutls_digest_algorithm algo,
-                             char* s, int l, const gnutls_datum* data)
+                             char *s, int l, const gnutls_datum * data)
 {
   unsigned char md[36];
   size_t n;
@@ -376,19 +359,17 @@ static void tls_fingerprint (gnutls_digest_algorithm algo,
 
   n = 36;
 
-  if (gnutls_fingerprint (algo, data, (char *)md, &n) < 0)
-  {
+  if (gnutls_fingerprint (algo, data, (char *) md, &n) < 0) {
     snprintf (s, l, _("[unable to calculate]"));
   }
-  else
-  {
-    for (j = 0; j < (int) n; j++)
-    {
+  else {
+    for (j = 0; j < (int) n; j++) {
       char ch[8];
+
       snprintf (ch, 8, "%02X%s", md[j], (j % 2 ? " " : ""));
       strncat (s, ch, l);
     }
-    s[2*n+n/2-1] = '\0'; /* don't want trailing space */
+    s[2 * n + n / 2 - 1] = '\0';        /* don't want trailing space */
   }
 }
 
@@ -397,16 +378,16 @@ static char *tls_make_date (time_t t, char *s, size_t len)
   struct tm *l = gmtime (&t);
 
   if (l)
-    snprintf (s, len,  "%s, %d %s %d %02d:%02d:%02d UTC",
-             Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon],
-             l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec);
+    snprintf (s, len, "%s, %d %s %d %02d:%02d:%02d UTC",
+              Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon],
+              l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec);
   else
     strfcpy (s, _("[invalid date]"), len);
 
   return (s);
 }
 
-static int tls_check_stored_hostname (const gnutls_datum *cert,
+static int tls_check_stored_hostname (const gnutls_datum * cert,
                                       const char *hostname)
 {
   char buf[80];
@@ -418,45 +399,43 @@ static int tls_check_stored_hostname (const gnutls_datum *cert,
   regmatch_t pmatch[3];
 
   /* try checking against names stored in stored certs file */
-  if ((fp = fopen (SslCertFile, "r")))
-  {
-    if (regcomp(&preg, "^#H ([a-zA-Z0-9_\\.-]+) ([0-9A-F]{4}( [0-9A-F]{4}){7})[ \t]*$", REG_ICASE|REG_EXTENDED) != 0)
-    {
-       regfree(&preg);
-       return 0;
+  if ((fp = fopen (SslCertFile, "r"))) {
+    if (regcomp
+        (&preg,
+         "^#H ([a-zA-Z0-9_\\.-]+) ([0-9A-F]{4}( [0-9A-F]{4}){7})[ \t]*$",
+         REG_ICASE | REG_EXTENDED) != 0) {
+      regfree (&preg);
+      return 0;
     }
 
     buf[0] = '\0';
     tls_fingerprint (GNUTLS_DIG_MD5, buf, sizeof (buf), cert);
-    while ((linestr = mutt_read_line(linestr, &linestrsize, fp, &linenum)) != NULL)
-    {
-      if(linestr[0] == '#' && linestr[1] == 'H')
-      {
-        if (regexec(&preg, linestr, 3, pmatch, 0) == 0)
-        {
+    while ((linestr =
+            mutt_read_line (linestr, &linestrsize, fp, &linenum)) != NULL) {
+      if (linestr[0] == '#' && linestr[1] == 'H') {
+        if (regexec (&preg, linestr, 3, pmatch, 0) == 0) {
           linestr[pmatch[1].rm_eo] = '\0';
           linestr[pmatch[2].rm_eo] = '\0';
-          if (strcmp(linestr + pmatch[1].rm_so, hostname) == 0 &&
-              strcmp(linestr + pmatch[2].rm_so, buf) == 0)
-          {
-            regfree(&preg);
-            safe_free((void**)&linestr);
-            fclose(fp);
+          if (strcmp (linestr + pmatch[1].rm_so, hostname) == 0 &&
+              strcmp (linestr + pmatch[2].rm_so, buf) == 0) {
+            regfree (&preg);
+            safe_free ((void **) &linestr);
+            fclose (fp);
             return 1;
           }
         }
       }
     }
 
-    regfree(&preg);
-    fclose(fp);
+    regfree (&preg);
+    fclose (fp);
   }
 
   /* not found a matching name */
   return 0;
 }
 
-static int tls_check_certificate (CONNECTION* conn)
+static int tls_check_certificate (CONNECTION * conn)
 {
   tlssockdata *data = conn->sockdata;
   gnutls_session state = data->state;
@@ -489,94 +468,81 @@ static int tls_check_certificate (CONNECTION* conn)
   int certerr_revoked = 0;
   int certerr_signernotca = 0;
 
-  if (gnutls_auth_get_type(state) != GNUTLS_CRD_CERTIFICATE)
-  {
+  if (gnutls_auth_get_type (state) != GNUTLS_CRD_CERTIFICATE) {
     mutt_error (_("Unable to get certificate from peer"));
     mutt_sleep (2);
     return 0;
   }
 
-  certstat = gnutls_certificate_verify_peers(state);
+  certstat = gnutls_certificate_verify_peers (state);
 
-  if (certstat == GNUTLS_E_NO_CERTIFICATE_FOUND)
-  {
+  if (certstat == GNUTLS_E_NO_CERTIFICATE_FOUND) {
     mutt_error (_("Unable to get certificate from peer"));
     mutt_sleep (2);
     return 0;
   }
-  if (certstat < 0)
-  {
-    mutt_error (_("Certificate verification error (%s)"), gnutls_strerror(certstat));
+  if (certstat < 0) {
+    mutt_error (_("Certificate verification error (%s)"),
+                gnutls_strerror (certstat));
     mutt_sleep (2);
     return 0;
   }
 
   /* We only support X.509 certificates (not OpenPGP) at the moment */
-  if (gnutls_certificate_type_get(state) != GNUTLS_CRT_X509)
-  {
+  if (gnutls_certificate_type_get (state) != GNUTLS_CRT_X509) {
     mutt_error (_("Error certificate is not X.509"));
     mutt_sleep (2);
     return 0;
   }
 
-  if (gnutls_x509_crt_init(&cert) < 0)
-  {
+  if (gnutls_x509_crt_init (&cert) < 0) {
     mutt_error (_("Error initialising gnutls certificate data"));
     mutt_sleep (2);
     return 0;
   }
 
-  cert_list = gnutls_certificate_get_peers(state, &cert_list_size);
-  if (!cert_list)
-  {
+  cert_list = gnutls_certificate_get_peers (state, &cert_list_size);
+  if (!cert_list) {
     mutt_error (_("Unable to get certificate from peer"));
     mutt_sleep (2);
     return 0;
   }
 
   /* FIXME: Currently only check first certificate in chain. */
-  if (gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER) < 0)
-  {
+  if (gnutls_x509_crt_import (cert, &cert_list[0], GNUTLS_X509_FMT_DER) < 0) {
     mutt_error (_("Error processing certificate data"));
     mutt_sleep (2);
     return 0;
   }
 
-  if (gnutls_x509_crt_get_expiration_time(cert) < time(NULL))
-  {
+  if (gnutls_x509_crt_get_expiration_time (cert) < time (NULL)) {
     certerr_expired = 1;
   }
 
-  if (gnutls_x509_crt_get_activation_time(cert) > time(NULL))
-  {
+  if (gnutls_x509_crt_get_activation_time (cert) > time (NULL)) {
     certerr_notyetvalid = 1;
   }
 
-  if (!gnutls_x509_crt_check_hostname(cert, conn->account.host) &&
-      !tls_check_stored_hostname (&cert_list[0], conn->account.host))
-  {
+  if (!gnutls_x509_crt_check_hostname (cert, conn->account.host) &&
+      !tls_check_stored_hostname (&cert_list[0], conn->account.host)) {
     certerr_hostname = 1;
   }
 
   /* see whether certificate is in our cache (certificates file) */
-  if (tls_compare_certificates (&cert_list[0]))
-  {
-    if (certstat & GNUTLS_CERT_INVALID)
-    {
+  if (tls_compare_certificates (&cert_list[0])) {
+    if (certstat & GNUTLS_CERT_INVALID) {
       /* doesn't matter - have decided is valid because server
          certificate is in our trusted cache */
       certstat ^= GNUTLS_CERT_INVALID;
     }
 
-    if (certstat & GNUTLS_CERT_SIGNER_NOT_FOUND)
-    {
+    if (certstat & GNUTLS_CERT_SIGNER_NOT_FOUND) {
       /* doesn't matter that we haven't found the signer, since
          certificate is in our trusted cache */
       certstat ^= GNUTLS_CERT_SIGNER_NOT_FOUND;
     }
 
-    if (certstat & GNUTLS_CERT_SIGNER_NOT_CA)
-    {
+    if (certstat & GNUTLS_CERT_SIGNER_NOT_CA) {
       /* Hmm. Not really sure how to handle this, but let's say
          that we don't care if the CA certificate hasn't got the
          correct X.509 basic constraints if server certificate is
@@ -586,27 +552,23 @@ static int tls_check_certificate (CONNECTION* conn)
 
   }
 
-  if (certstat & GNUTLS_CERT_REVOKED)
-  {
+  if (certstat & GNUTLS_CERT_REVOKED) {
     certerr_revoked = 1;
     certstat ^= GNUTLS_CERT_REVOKED;
   }
 
-  if (certstat & GNUTLS_CERT_INVALID)
-  {
+  if (certstat & GNUTLS_CERT_INVALID) {
     certerr_nottrusted = 1;
     certstat ^= GNUTLS_CERT_INVALID;
   }
 
-  if (certstat & GNUTLS_CERT_SIGNER_NOT_FOUND)
-  {
+  if (certstat & GNUTLS_CERT_SIGNER_NOT_FOUND) {
     /* NB: already cleared if cert in cache */
     certerr_nottrusted = 1;
     certstat ^= GNUTLS_CERT_SIGNER_NOT_FOUND;
   }
 
-  if (certstat & GNUTLS_CERT_SIGNER_NOT_CA)
-  {
+  if (certstat & GNUTLS_CERT_SIGNER_NOT_CA) {
     /* NB: already cleared if cert in cache */
     certerr_signernotca = 1;
     certstat ^= GNUTLS_CERT_SIGNER_NOT_CA;
@@ -616,10 +578,9 @@ static int tls_check_certificate (CONNECTION* conn)
   /* we've been zeroing the interesting bits in certstat - 
      don't return OK if there are any unhandled bits we don't
      understand */
-  if (!(certerr_expired || certerr_notyetvalid || 
-       certerr_hostname || certerr_nottrusted) && certstat == 0)
-  {
-    gnutls_x509_crt_deinit(cert);
+  if (!(certerr_expired || certerr_notyetvalid ||
+        certerr_hostname || certerr_nottrusted) && certstat == 0) {
+    gnutls_x509_crt_deinit (cert);
     return 1;
   }
 
@@ -632,141 +593,157 @@ static int tls_check_certificate (CONNECTION* conn)
     menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
 
   row = 0;
-  strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING);
+  strfcpy (menu->dialog[row], _("This certificate belongs to:"),
+           SHORT_STRING);
   row++;
 
-  buflen = sizeof(dn_common_name);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
-                                    dn_common_name, &buflen) != 0)
+  buflen = sizeof (dn_common_name);
+  if (gnutls_x509_crt_get_dn_by_oid (cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
+                                     dn_common_name, &buflen) != 0)
     dn_common_name[0] = '\0';
-  buflen = sizeof(dn_email);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
-                                    dn_email, &buflen) != 0)
+  buflen = sizeof (dn_email);
+  if (gnutls_x509_crt_get_dn_by_oid (cert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
+                                     dn_email, &buflen) != 0)
     dn_email[0] = '\0';
-  buflen = sizeof(dn_organization);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
-                                    dn_organization, &buflen) != 0)
+  buflen = sizeof (dn_organization);
+  if (gnutls_x509_crt_get_dn_by_oid
+      (cert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, dn_organization,
+       &buflen) != 0)
     dn_organization[0] = '\0';
-  buflen = sizeof(dn_organizational_unit);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
-                                    dn_organizational_unit, &buflen) != 0)
+  buflen = sizeof (dn_organizational_unit);
+  if (gnutls_x509_crt_get_dn_by_oid
+      (cert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
+       dn_organizational_unit, &buflen) != 0)
     dn_organizational_unit[0] = '\0';
-  buflen = sizeof(dn_locality);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
-                                    dn_locality, &buflen) != 0)
+  buflen = sizeof (dn_locality);
+  if (gnutls_x509_crt_get_dn_by_oid
+      (cert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0, dn_locality, &buflen) != 0)
     dn_locality[0] = '\0';
-  buflen = sizeof(dn_province);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
-                                    dn_province, &buflen) != 0)
+  buflen = sizeof (dn_province);
+  if (gnutls_x509_crt_get_dn_by_oid
+      (cert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0, dn_province,
+       &buflen) != 0)
     dn_province[0] = '\0';
-  buflen = sizeof(dn_country);
-  if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
-                                    dn_country, &buflen) != 0)
+  buflen = sizeof (dn_country);
+  if (gnutls_x509_crt_get_dn_by_oid (cert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
+                                     dn_country, &buflen) != 0)
     dn_country[0] = '\0';
 
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s", dn_common_name, dn_email);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s", dn_common_name,
+            dn_email);
   snprintf (menu->dialog[row++], SHORT_STRING, "   %s", dn_organization);
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s", dn_organizational_unit);
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s  %s",
-            dn_locality, dn_province, dn_country);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s",
+            dn_organizational_unit);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s  %s", dn_locality,
+            dn_province, dn_country);
   row++;
-  
-  strfcpy (menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING);
+
+  strfcpy (menu->dialog[row], _("This certificate was issued by:"),
+           SHORT_STRING);
   row++;
 
-  buflen = sizeof(dn_common_name);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
-                                    dn_common_name, &buflen) != 0)
+  buflen = sizeof (dn_common_name);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0, dn_common_name, &buflen) != 0)
     dn_common_name[0] = '\0';
-  buflen = sizeof(dn_email);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
-                                    dn_email, &buflen) != 0)
+  buflen = sizeof (dn_email);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_PKCS9_EMAIL, 0, 0, dn_email, &buflen) != 0)
     dn_email[0] = '\0';
-  buflen = sizeof(dn_organization);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
-                                    dn_organization, &buflen) != 0)
+  buflen = sizeof (dn_organization);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, dn_organization,
+       &buflen) != 0)
     dn_organization[0] = '\0';
-  buflen = sizeof(dn_organizational_unit);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
-                                    dn_organizational_unit, &buflen) != 0)
+  buflen = sizeof (dn_organizational_unit);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
+       dn_organizational_unit, &buflen) != 0)
     dn_organizational_unit[0] = '\0';
-  buflen = sizeof(dn_locality);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
-                                    dn_locality, &buflen) != 0)
+  buflen = sizeof (dn_locality);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0, dn_locality, &buflen) != 0)
     dn_locality[0] = '\0';
-  buflen = sizeof(dn_province);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
-                                    dn_province, &buflen) != 0)
+  buflen = sizeof (dn_province);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0, dn_province,
+       &buflen) != 0)
     dn_province[0] = '\0';
-  buflen = sizeof(dn_country);
-  if (gnutls_x509_crt_get_issuer_dn_by_oid(cert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
-                                    dn_country, &buflen) != 0)
+  buflen = sizeof (dn_country);
+  if (gnutls_x509_crt_get_issuer_dn_by_oid
+      (cert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0, dn_country, &buflen) != 0)
     dn_country[0] = '\0';
 
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s", dn_common_name, dn_email);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s", dn_common_name,
+            dn_email);
   snprintf (menu->dialog[row++], SHORT_STRING, "   %s", dn_organization);
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s", dn_organizational_unit);
-  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s  %s",
-            dn_locality, dn_province, dn_country);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s",
+            dn_organizational_unit);
+  snprintf (menu->dialog[row++], SHORT_STRING, "   %s  %s  %s", dn_locality,
+            dn_province, dn_country);
   row++;
 
-  snprintf (menu->dialog[row++], SHORT_STRING, _("This certificate is valid"));
+  snprintf (menu->dialog[row++], SHORT_STRING,
+            _("This certificate is valid"));
 
-  t = gnutls_x509_crt_get_activation_time(cert);
-  snprintf (menu->dialog[row++], SHORT_STRING, _("   from %s"), 
-           tls_make_date(t, datestr, 30));
+  t = gnutls_x509_crt_get_activation_time (cert);
+  snprintf (menu->dialog[row++], SHORT_STRING, _("   from %s"),
+            tls_make_date (t, datestr, 30));
 
-  t = gnutls_x509_crt_get_expiration_time(cert);
-  snprintf (menu->dialog[row++], SHORT_STRING, _("     to %s"), 
-           tls_make_date(t, datestr, 30));
+  t = gnutls_x509_crt_get_expiration_time (cert);
+  snprintf (menu->dialog[row++], SHORT_STRING, _("     to %s"),
+            tls_make_date (t, datestr, 30));
 
   fpbuf[0] = '\0';
   tls_fingerprint (GNUTLS_DIG_SHA, fpbuf, sizeof (fpbuf), &cert_list[0]);
-  snprintf (menu->dialog[row++], SHORT_STRING, _("SHA1 Fingerprint: %s"), fpbuf);
+  snprintf (menu->dialog[row++], SHORT_STRING, _("SHA1 Fingerprint: %s"),
+            fpbuf);
   fpbuf[0] = '\0';
   tls_fingerprint (GNUTLS_DIG_MD5, fpbuf, sizeof (fpbuf), &cert_list[0]);
-  snprintf (menu->dialog[row++], SHORT_STRING, _("MD5 Fingerprint: %s"), fpbuf);
+  snprintf (menu->dialog[row++], SHORT_STRING, _("MD5 Fingerprint: %s"),
+            fpbuf);
 
-  if (certerr_notyetvalid)
-  {
+  if (certerr_notyetvalid) {
     row++;
-    strfcpy (menu->dialog[row], _("WARNING: Server certificate is not yet valid"), SHORT_STRING);
+    strfcpy (menu->dialog[row],
+             _("WARNING: Server certificate is not yet valid"), SHORT_STRING);
   }
-  if (certerr_expired)
-  {
+  if (certerr_expired) {
     row++;
-    strfcpy (menu->dialog[row], _("WARNING: Server certificate has expired"), SHORT_STRING);
+    strfcpy (menu->dialog[row], _("WARNING: Server certificate has expired"),
+             SHORT_STRING);
   }
-  if (certerr_revoked)
-  {
+  if (certerr_revoked) {
     row++;
-    strfcpy (menu->dialog[row], _("WARNING: Server certificate has been revoked"), SHORT_STRING);
+    strfcpy (menu->dialog[row],
+             _("WARNING: Server certificate has been revoked"), SHORT_STRING);
   }
-  if (certerr_hostname)
-  {
+  if (certerr_hostname) {
     row++;
-    strfcpy (menu->dialog[row], _("WARNING: Server hostname does not match certificate"), SHORT_STRING);
+    strfcpy (menu->dialog[row],
+             _("WARNING: Server hostname does not match certificate"),
+             SHORT_STRING);
   }
-  if (certerr_signernotca)
-  {
+  if (certerr_signernotca) {
     row++;
-    strfcpy (menu->dialog[row], _("WARNING: Signer of server certificate is not a CA"), SHORT_STRING);
+    strfcpy (menu->dialog[row],
+             _("WARNING: Signer of server certificate is not a CA"),
+             SHORT_STRING);
   }
 
   menu->title = _("TLS/SSL Certificate check");
   /* certificates with bad dates, or that are revoked, must be
      accepted manually each and every time */
-  if (SslCertFile && !certerr_expired && !certerr_notyetvalid && !certerr_revoked)
-  {
+  if (SslCertFile && !certerr_expired && !certerr_notyetvalid
+      && !certerr_revoked) {
     menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always");
     menu->keys = _("roa");
   }
-  else
-  {
+  else {
     menu->prompt = _("(r)eject, accept (o)nce");
     menu->keys = _("ro");
   }
-  
+
   helpstr[0] = '\0';
   mutt_make_help (buf, sizeof (buf), _("Exit  "), MENU_GENERIC, OP_EXIT);
   strncat (helpstr, buf, sizeof (helpstr));
@@ -775,58 +752,49 @@ static int tls_check_certificate (CONNECTION* conn)
   menu->help = helpstr;
 
   done = 0;
-  while (!done)
-  {
-    switch (mutt_menuLoop (menu))
-    {
-      case -1:                 /* abort */
-      case OP_MAX + 1:         /* reject */
-      case OP_EXIT:
-        done = 1;
-        break;
-      case OP_MAX + 3:         /* accept always */
-        done = 0;
-        if ((fp = fopen (SslCertFile, "a")))
-       {
-         /* save hostname if necessary */
-         if (certerr_hostname)
-         {
-           fprintf(fp, "#H %s %s\n", conn->account.host, fpbuf);
-           done = 1;
-         }
-         if (certerr_nottrusted)
-         {
-            done = 0;
-           ret = gnutls_pem_base64_encode_alloc ("CERTIFICATE", &cert_list[0],
-                                                  &pemdata);
-           if (ret == 0)
-           {
-             if (fwrite(pemdata.data, pemdata.size, 1, fp) == 1)
-             {
-               done = 1;
-             }
-              gnutls_free(pemdata.data);
-           }
-         }
-         fclose (fp);
-       }
-       if (!done)
-        {
-         mutt_error (_("Warning: Couldn't save certificate"));
-         mutt_sleep (2);
-       }
-       else
-        {
-         mutt_message (_("Certificate saved"));
-         mutt_sleep (0);
-       }
-        /* fall through */
-      case OP_MAX + 2:         /* accept once */
-        done = 2;
-        break;
+  while (!done) {
+    switch (mutt_menuLoop (menu)) {
+    case -1:                   /* abort */
+    case OP_MAX + 1:           /* reject */
+    case OP_EXIT:
+      done = 1;
+      break;
+    case OP_MAX + 3:           /* accept always */
+      done = 0;
+      if ((fp = fopen (SslCertFile, "a"))) {
+        /* save hostname if necessary */
+        if (certerr_hostname) {
+          fprintf (fp, "#H %s %s\n", conn->account.host, fpbuf);
+          done = 1;
+        }
+        if (certerr_nottrusted) {
+          done = 0;
+          ret = gnutls_pem_base64_encode_alloc ("CERTIFICATE", &cert_list[0],
+                                                &pemdata);
+          if (ret == 0) {
+            if (fwrite (pemdata.data, pemdata.size, 1, fp) == 1) {
+              done = 1;
+            }
+            gnutls_free (pemdata.data);
+          }
+        }
+        fclose (fp);
+      }
+      if (!done) {
+        mutt_error (_("Warning: Couldn't save certificate"));
+        mutt_sleep (2);
+      }
+      else {
+        mutt_message (_("Certificate saved"));
+        mutt_sleep (0);
+      }
+      /* fall through */
+    case OP_MAX + 2:           /* accept once */
+      done = 2;
+      break;
     }
   }
   mutt_menuDestroy (&menu);
-  gnutls_x509_crt_deinit(cert);
+  gnutls_x509_crt_deinit (cert);
   return (done == 2);
 }
index 420215d..8d64201 100644 (file)
@@ -39,22 +39,19 @@ static int MuttNssInitialized = 0;
  * data gets stuffed so that the main mutt_socket.h doesn't have to be
  * modified.
  */
-typedef struct
-{
+typedef struct {
   PRFileDesc *fd;
   CERTCertDBHandle *db;
-}
-mutt_nss_t;
+} mutt_nss_t;
 
 /* nss callback to grab the user's password. */
-static char *
-mutt_nss_password_func (PK11SlotInfo * slot, PRBool retry, void *arg)
+static char *mutt_nss_password_func (PK11SlotInfo * slot, PRBool retry,
+                                     void *arg)
 {
   return NULL;
 }
 
-static int
-mutt_nss_error (const char *call)
+static int mutt_nss_error (const char *call)
 {
   mutt_error (_("%s failed (error %d)"), call, PR_GetError ());
   return -1;
@@ -63,49 +60,46 @@ mutt_nss_error (const char *call)
 /* initialize the NSS library for use.  must be called prior to any other
  * functions in this module.
  */
-static int
-mutt_nss_init (void)
+static int mutt_nss_init (void)
 {
-  if (!MuttNssInitialized)
-  {
+  if (!MuttNssInitialized) {
     PK11_SetPasswordFunc (mutt_nss_password_func);
     if (NSS_Init (SslCertFile) == SECFailure)
       return mutt_nss_error ("NSS_Init");
-    
+
     /* always use strong crypto. */
     if (NSS_SetDomesticPolicy () == SECFailure)
       return mutt_nss_error ("NSS_SetDomesticPolicy");
-    
+
     /* intialize the session cache */
     SSL_ClearSessionCache ();
-    
+
     MuttNssInitialized = 1;
   }
   return 0;
 }
 
 /* convert from int64 to a readable string and print on the screen */
-static void
-mutt_nss_pretty_time (int64 usecs)
+static void mutt_nss_pretty_time (int64 usecs)
 {
   struct tm t;
   PRExplodedTime ex;
   char timebuf[128];
-  
+
   PR_ExplodeTime (usecs, PR_LocalTimeParameters, &ex);
-  
+
   t.tm_sec = ex.tm_sec;
   t.tm_min = ex.tm_min;
   t.tm_hour = ex.tm_hour;
   t.tm_mday = ex.tm_mday;
   t.tm_mon = ex.tm_month;
-  t.tm_year = ex.tm_year - 1900;       /* PRExplodedTime uses the absolute year */
+  t.tm_year = ex.tm_year - 1900;        /* PRExplodedTime uses the absolute year */
   t.tm_wday = ex.tm_wday;
   t.tm_yday = ex.tm_yday;
-  
+
   strfcpy (timebuf, asctime (&t), sizeof (timebuf));
   timebuf[strlen (timebuf) - 1] = 0;
-  
+
   addstr (timebuf);
 }
 
@@ -114,8 +108,7 @@ mutt_nss_pretty_time (int64 usecs)
  * database.  we are given the option to override the decision and accept
  * it anyway.
  */
-static SECStatus
-mutt_nss_bad_cert (void *arg, PRFileDesc * fd)
+static SECStatus mutt_nss_bad_cert (void *arg, PRFileDesc * fd)
 {
   PRErrorCode err;
   CERTCertificate *cert, *issuer;
@@ -160,13 +153,12 @@ mutt_nss_bad_cert (void *arg, PRFileDesc * fd)
 
   /* calculate the MD5 hash of the raw certificate */
   HASH_HashBuf (HASH_AlgMD5, hash, cert->derCert.data, cert->derCert.len);
-  for (i = 0; i < 16; i++)
-  {
+  for (i = 0; i < 16; i++) {
     printw ("%0x", hash[i]);
     if (i != 15)
       addch (':');
   }
-  
+
   mvaddstr (LINES - 3, 0, "Signature:   ");
   clrtoeol ();
 
@@ -189,57 +181,51 @@ mutt_nss_bad_cert (void *arg, PRFileDesc * fd)
   else
     status[sizeof (status) - 1] = 0;
   memcpy (status, "--- SSL Certificate Check",
-         sizeof ("--- SSL Certificate Check") - 1);
+          sizeof ("--- SSL Certificate Check") - 1);
   addstr (status);
   clrtoeol ();
   SETCOLOR (MT_COLOR_NORMAL);
 
-  for (;;)
-  {
+  for (;;) {
     mvaddstr (LINES - 1, 0, "(r)eject, accept (o)nce, (a)lways accept?");
     clrtoeol ();
     ch = mutt_getch ();
-    if (ch.ch == -1)
-    {
+    if (ch.ch == -1) {
       i = SECFailure;
       break;
     }
-    else if (ascii_tolower (ch.ch) == 'r')
-    {
+    else if (ascii_tolower (ch.ch) == 'r') {
       i = SECFailure;
       break;
     }
-    else if (ascii_tolower (ch.ch) == 'o')
-    {
+    else if (ascii_tolower (ch.ch) == 'o') {
       i = SECSuccess;
       break;
     }
-    else if (ascii_tolower (ch.ch) == 'a')
-    {
+    else if (ascii_tolower (ch.ch) == 'a') {
       /* push this certificate onto the user's certificate store so it
        * automatically becomes valid next time we see it
        */
-      
+
       /* set this certificate as a valid peer for SSL-auth ONLY. */
       CERT_DecodeTrustString (&trust, "P,,");
-      
+
       CERT_AddTempCertToPerm (cert, NULL, &trust);
       i = SECSuccess;
       break;
     }
     BEEP ();
   }
-  
+
   /* SSL_PeerCertificate() returns a copy with an updated ref count, so
    * we have to destroy our copy here.
    */
   CERT_DestroyCertificate (cert);
-  
+
   return i;
 }
 
-static int
-mutt_nss_socket_open (CONNECTION * con)
+static int mutt_nss_socket_open (CONNECTION * con)
 {
   mutt_nss_t *sockdata;
   PRNetAddr addr;
@@ -249,8 +235,7 @@ mutt_nss_socket_open (CONNECTION * con)
   addr.inet.family = AF_INET;
   addr.inet.port = PR_htons (con->account.port);
   he = gethostbyname (con->account.host);
-  if (!he)
-  {
+  if (!he) {
     mutt_error (_("Unable to find ip for host %s"), con->account.host);
     return -1;
   }
@@ -258,32 +243,29 @@ mutt_nss_socket_open (CONNECTION * con)
 
   sockdata = safe_calloc (1, sizeof (mutt_nss_t));
 
-  do
-  {
+  do {
     sockdata->fd = PR_NewTCPSocket ();
-    if (sockdata->fd == NULL)
-    {
+    if (sockdata->fd == NULL) {
       mutt_error (_("PR_NewTCPSocket failed."));
       break;
     }
     /* make this a SSL socket */
     sockdata->fd = SSL_ImportFD (NULL, sockdata->fd);
-    
+
     /* set SSL version options based upon user's preferences */
     if (!option (OPTTLSV1))
       SSL_OptionSet (sockdata->fd, SSL_ENABLE_TLS, PR_FALSE);
-    
+
     if (!option (OPTSSLV2))
       SSL_OptionSet (sockdata->fd, SSL_ENABLE_SSL2, PR_FALSE);
 
     if (!option (OPTSSLV3))
       SSL_OptionSet (sockdata->fd, SSL_ENABLE_SSL3, PR_FALSE);
-    
+
     /* set the host we were attempting to connect to in order to verify
      * the name in the certificate we get back.
      */
-    if (SSL_SetURL (sockdata->fd, con->account.host))
-    {
+    if (SSL_SetURL (sockdata->fd, con->account.host)) {
       mutt_nss_error ("SSL_SetURL");
       break;
     }
@@ -292,46 +274,43 @@ mutt_nss_socket_open (CONNECTION * con)
      * via SSL.
      */
     SSL_SetPKCS11PinArg (sockdata->fd, 0);
-    
+
     sockdata->db = CERT_GetDefaultCertDB ();
-    
+
     /* use the default supplied hook.  it takes an argument to our
      * certificate database.  the manual lies, you can't really specify
      * NULL for the callback to get the default!
      */
-    SSL_AuthCertificateHook (sockdata->fd, SSL_AuthCertificate,
-                            sockdata->db);
+    SSL_AuthCertificateHook (sockdata->fd, SSL_AuthCertificate, sockdata->db);
     /* set the callback to be used when SSL_AuthCertificate() fails.  this
      * allows us to override and insert the cert back into the db
      */
     SSL_BadCertHook (sockdata->fd, mutt_nss_bad_cert, sockdata->db);
-    
+
     if (PR_Connect (sockdata->fd, &addr, PR_INTERVAL_NO_TIMEOUT) ==
-       PR_FAILURE)
-    {
+        PR_FAILURE) {
       mutt_error (_("Unable to connect to host %s"), con->account.host);
       break;
     }
-    
+
     /* store the extra info in the CONNECTION struct for later use. */
     con->sockdata = sockdata;
-    
+
     /* HACK.  some of the higher level calls in mutt_socket.c depend on this
      * being >0 when we are in the connected state.  we just set this to
      * an arbitrary value to avoid hitting that bug, since we neve have the
      * real fd.
      */
     con->fd = 42;
-    
+
     /* success */
     return 0;
   }
   while (0);
-  
+
   /* we get here when we had an oops.  clean up the mess. */
 
-  if (sockdata)
-  {
+  if (sockdata) {
     if (sockdata->fd)
       PR_Close (sockdata->fd);
     if (sockdata->db)
@@ -341,8 +320,7 @@ mutt_nss_socket_open (CONNECTION * con)
   return -1;
 }
 
-static int
-mutt_nss_socket_close (CONNECTION * con)
+static int mutt_nss_socket_close (CONNECTION * con)
 {
   mutt_nss_t *sockdata = (mutt_nss_t *) con->sockdata;
 
@@ -356,10 +334,9 @@ mutt_nss_socket_close (CONNECTION * con)
   return 0;
 }
 
-static int
-mutt_nss_socket_read (CONNECTION* conn, char* buf, size_t len)
+static int mutt_nss_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
-  return PR_Read (((mutt_nss_t*) conn->sockdata)->fd, buf, len);
+  return PR_Read (((mutt_nss_t *) conn->sockdata)->fd, buf, len);
 }
 
 static int
@@ -369,8 +346,7 @@ mutt_nss_socket_write (CONNECTION * con, const char *buf, size_t count)
 }
 
 /* initialize a new connection for use with NSS */
-int
-mutt_nss_socket_setup (CONNECTION * con)
+int mutt_nss_socket_setup (CONNECTION * con)
 {
   if (mutt_nss_init ())
     return -1;
index fc2b2e1..4a012f0 100644 (file)
 #include <errno.h>
 
 /* -- data types -- */
-typedef struct
-{
+typedef struct {
   pid_t pid;
   int readfd;
   int writefd;
 } TUNNEL_DATA;
 
 /* forward declarations */
-static int tunnel_socket_open (CONNECTION*);
-static int tunnel_socket_close (CONNECTION*);
-static int tunnel_socket_read (CONNECTION* conn, char* buf, size_t len);
-static int tunnel_socket_write (CONNECTION* conn, const char* buf, size_t len);
+static int tunnel_socket_open (CONNECTION *);
+static int tunnel_socket_close (CONNECTION *);
+static int tunnel_socket_read (CONNECTION * conn, char *buf, size_t len);
+static int tunnel_socket_write (CONNECTION * conn, const char *buf,
+                                size_t len);
 
 /* -- public functions -- */
-int mutt_tunnel_socket_setup (CONNECTION *conn)
+int mutt_tunnel_socket_setup (CONNECTION * conn)
 {
   conn->conn_open = tunnel_socket_open;
   conn->conn_close = tunnel_socket_close;
@@ -57,32 +57,29 @@ int mutt_tunnel_socket_setup (CONNECTION *conn)
   return 0;
 }
 
-static int tunnel_socket_open (CONNECTION *conn)
+static int tunnel_socket_open (CONNECTION * conn)
 {
-  TUNNEL_DATAtunnel;
+  TUNNEL_DATA *tunnel;
   int pid;
   int rc;
   int pin[2], pout[2];
 
-  tunnel = (TUNNEL_DATA*) safe_malloc (sizeof (TUNNEL_DATA));
+  tunnel = (TUNNEL_DATA *) safe_malloc (sizeof (TUNNEL_DATA));
   conn->sockdata = tunnel;
 
   mutt_message (_("Connecting with \"%s\"..."), Tunnel);
 
-  if ((rc = pipe (pin)) == -1)
-  {
+  if ((rc = pipe (pin)) == -1) {
     mutt_perror ("pipe");
     return -1;
   }
-  if ((rc = pipe (pout)) == -1)
-  {
+  if ((rc = pipe (pout)) == -1) {
     mutt_perror ("pipe");
     return -1;
   }
 
   mutt_block_signals_system ();
-  if ((pid = fork ()) == 0)
-  {
+  if ((pid = fork ()) == 0) {
     mutt_unblock_signals_system (0);
     if (dup2 (pout[0], STDIN_FILENO) < 0 || dup2 (pin[1], STDOUT_FILENO) < 0)
       _exit (127);
@@ -100,8 +97,7 @@ static int tunnel_socket_open (CONNECTION *conn)
   }
   mutt_unblock_signals_system (1);
 
-  if (pid == -1)
-  {
+  if (pid == -1) {
     close (pin[0]);
     close (pin[1]);
     close (pout[0]);
@@ -119,14 +115,14 @@ static int tunnel_socket_open (CONNECTION *conn)
   tunnel->writefd = pout[1];
   tunnel->pid = pid;
 
-  conn->fd = 42; /* stupid hack */
+  conn->fd = 42;                /* stupid hack */
 
   return 0;
 }
 
-static int tunnel_socket_close (CONNECTION* conn)
+static int tunnel_socket_close (CONNECTION * conn)
 {
-  TUNNEL_DATA* tunnel = (TUNNEL_DATA*) conn->sockdata;
+  TUNNEL_DATA *tunnel = (TUNNEL_DATA *) conn->sockdata;
 
   close (tunnel->readfd);
   close (tunnel->writefd);
@@ -136,32 +132,31 @@ static int tunnel_socket_close (CONNECTION* conn)
   return 0;
 }
 
-static int tunnel_socket_read (CONNECTION* conn, char* buf, size_t len)
+static int tunnel_socket_read (CONNECTION * conn, char *buf, size_t len)
 {
-  TUNNEL_DATA* tunnel = (TUNNEL_DATA*) conn->sockdata;
+  TUNNEL_DATA *tunnel = (TUNNEL_DATA *) conn->sockdata;
   int rc;
 
   rc = read (tunnel->readfd, buf, len);
-  if (rc == -1)
-  {
+  if (rc == -1) {
     mutt_error (_("Tunnel error talking to %s: %s"), conn->account.host,
-               strerror (errno));
+                strerror (errno));
     mutt_sleep (1);
   }
 
   return rc;
 }
 
-static int tunnel_socket_write (CONNECTION* conn, const char* buf, size_t len)
+static int tunnel_socket_write (CONNECTION * conn, const char *buf,
+                                size_t len)
 {
-  TUNNEL_DATA* tunnel = (TUNNEL_DATA*) conn->sockdata;
+  TUNNEL_DATA *tunnel = (TUNNEL_DATA *) conn->sockdata;
   int rc;
 
   rc = write (tunnel->writefd, buf, len);
-  if (rc == -1)
-  {
+  if (rc == -1) {
     mutt_error (_("Tunnel error talking to %s: %s"), conn->account.host,
-               strerror (errno));
+                strerror (errno));
     mutt_sleep (1);
   }
 
index 711b3d8..3e96ae9 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -51,7 +51,7 @@
 BODY *mutt_new_body (void)
 {
   BODY *p = (BODY *) safe_calloc (1, sizeof (BODY));
-    
+
   p->disposition = DISPATTACH;
   p->use_disp = 1;
   return (p);
@@ -71,16 +71,14 @@ void mutt_adv_mktemp (char *s, size_t l)
   char *period;
   size_t sl;
   struct stat sb;
-  
+
   strfcpy (buf, NONULL (Tempdir), sizeof (buf));
   mutt_expand_path (buf, sizeof (buf));
-  if (s[0] == '\0')
-  {
+  if (s[0] == '\0') {
     snprintf (s, l, "%s/muttXXXXXX", buf);
     mktemp (s);
   }
-  else
-  {
+  else {
     strfcpy (tmp, s, sizeof (tmp));
     mutt_sanitize_filename (tmp, 1);
     snprintf (s, l, "%s/%s", buf, tmp);
@@ -90,33 +88,30 @@ void mutt_adv_mktemp (char *s, size_t l)
       *period = 0;
     snprintf (s, l, "%s/%s.XXXXXX", buf, tmp);
     mktemp (s);
-    if (period != NULL)
-    {
+    if (period != NULL) {
       *period = '.';
-      sl = mutt_strlen(s);
-      strfcpy(s + sl, period, l - sl);
+      sl = mutt_strlen (s);
+      strfcpy (s + sl, period, l - sl);
     }
   }
 }
 
 /* create a send-mode duplicate from a receive-mode body */
 
-int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src)
+int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
 {
   char tmp[_POSIX_PATH_MAX];
   BODY *b;
 
   PARAMETER *par, **ppar;
-  
+
   short use_disp;
 
-  if (src->filename)
-  {
+  if (src->filename) {
     use_disp = 1;
     strfcpy (tmp, src->filename, sizeof (tmp));
   }
-  else
-  {
+  else {
     use_disp = 0;
     tmp[0] = '\0';
   }
@@ -124,13 +119,13 @@ int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src)
   mutt_adv_mktemp (tmp, sizeof (tmp));
   if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
     return -1;
-      
+
   *tgt = mutt_new_body ();
   b = *tgt;
 
   memcpy (b, src, sizeof (BODY));
   b->parts = NULL;
-  b->next  = NULL;
+  b->next = NULL;
 
   b->filename = safe_strdup (tmp);
   b->use_disp = use_disp;
@@ -151,41 +146,42 @@ int mutt_copy_body (FILE *fp, BODY **tgt, BODY *src)
    * XXX - this may change in the future
    */
 
-  if (b->hdr) b->hdr = NULL;
-  
+  if (b->hdr)
+    b->hdr = NULL;
+
   /* copy parameters */
-  for (par = b->parameter, ppar = &b->parameter; par; ppar = &(*ppar)->next, par = par->next)
-  {
+  for (par = b->parameter, ppar = &b->parameter; par;
+       ppar = &(*ppar)->next, par = par->next) {
     *ppar = mutt_new_parameter ();
     (*ppar)->attribute = safe_strdup (par->attribute);
     (*ppar)->value = safe_strdup (par->value);
   }
 
   mutt_stamp_attachment (b);
-  
+
   return 0;
 }
 
 
 
-void mutt_free_body (BODY **p)
+void mutt_free_body (BODY ** p)
 {
   BODY *a = *p, *b;
 
-  while (a)
-  {
+  while (a) {
     b = a;
-    a = a->next; 
+    a = a->next;
 
     if (b->parameter)
       mutt_free_parameter (&b->parameter);
-    if (b->unlink && b->filename)
-    {
+    if (b->unlink && b->filename) {
       dprint (1, (debugfile, "mutt_free_body: Unlinking %s.\n", b->filename));
       unlink (b->filename);
     }
-    else if (b->filename) 
-      dprint (1, (debugfile, "mutt_free_body: Not unlinking %s.\n", b->filename));
+    else if (b->filename)
+      dprint (1,
+              (debugfile, "mutt_free_body: Not unlinking %s.\n",
+               b->filename));
 
     FREE (&b->filename);
     FREE (&b->content);
@@ -194,11 +190,10 @@ void mutt_free_body (BODY **p)
     FREE (&b->description);
     FREE (&b->form_name);
 
-    if (b->hdr)
-    {
+    if (b->hdr) {
       /* Don't free twice (b->hdr->content = b->parts) */
       b->hdr->content = NULL;
-      mutt_free_header(&b->hdr);
+      mutt_free_header (&b->hdr);
     }
 
     if (b->parts)
@@ -210,13 +205,12 @@ void mutt_free_body (BODY **p)
   *p = 0;
 }
 
-void mutt_free_parameter (PARAMETER **p)
+void mutt_free_parameter (PARAMETER ** p)
 {
   PARAMETER *t = *p;
   PARAMETER *o;
 
-  while (t)
-  {
+  while (t) {
     FREE (&t->attribute);
     FREE (&t->value);
     o = t;
@@ -226,14 +220,12 @@ void mutt_free_parameter (PARAMETER **p)
   *p = 0;
 }
 
-LIST *mutt_add_list (LIST *head, const char *data)
+LIST *mutt_add_list (LIST * head, const char *data)
 {
   LIST *tmp;
 
-  for (tmp = head; tmp && tmp->next; tmp = tmp->next)
-    ;
-  if (tmp)
-  {
+  for (tmp = head; tmp && tmp->next; tmp = tmp->next);
+  if (tmp) {
     tmp->next = safe_malloc (sizeof (LIST));
     tmp = tmp->next;
   }
@@ -245,13 +237,13 @@ LIST *mutt_add_list (LIST *head, const char *data)
   return head;
 }
 
-void mutt_free_list (LIST **list)
+void mutt_free_list (LIST ** list)
 {
   LIST *p;
-  
-  if (!list) return;
-  while (*list)
-  {
+
+  if (!list)
+    return;
+  while (*list) {
     p = *list;
     *list = (*list)->next;
     FREE (&p->data);
@@ -259,18 +251,19 @@ void mutt_free_list (LIST **list)
   }
 }
 
-HEADER *mutt_dup_header(HEADER *h)
+HEADER *mutt_dup_header (HEADER * h)
 {
   HEADER *hnew;
 
-  hnew = mutt_new_header();
-  memcpy(hnew, h, sizeof (HEADER));
+  hnew = mutt_new_header ();
+  memcpy (hnew, h, sizeof (HEADER));
   return hnew;
 }
 
-void mutt_free_header (HEADER **h)
+void mutt_free_header (HEADER ** h)
 {
-  if(!h || !*h) return;
+  if (!h || !*h)
+    return;
   mutt_free_envelope (&(*h)->env);
   mutt_free_body (&(*h)->content);
   FREE (&(*h)->maildir_flags);
@@ -286,11 +279,11 @@ void mutt_free_header (HEADER **h)
 }
 
 /* returns true if the header contained in "s" is in list "t" */
-int mutt_matches_ignore (const char *s, LIST *t)
+int mutt_matches_ignore (const char *s, LIST * t)
 {
-  for (; t; t = t->next)
-  {
-    if (!ascii_strncasecmp (s, t->data, mutt_strlen (t->data)) || *t->data == '*')
+  for (; t; t = t->next) {
+    if (!ascii_strncasecmp (s, t->data, mutt_strlen (t->data))
+        || *t->data == '*')
       return 1;
   }
   return 0;
@@ -303,14 +296,12 @@ void mutt_expand_link (char *newpath, const char *path, const char *link)
   size_t len;
 
   /* link is full path */
-  if (*link == '/')
-  {
+  if (*link == '/') {
     strfcpy (newpath, link, _POSIX_PATH_MAX);
     return;
   }
 
-  if ((lb = strrchr (path, '/')) == NULL)
-  {
+  if ((lb = strrchr (path, '/')) == NULL) {
     /* no path in link */
     strfcpy (newpath, link, _POSIX_PATH_MAX);
     return;
@@ -333,151 +324,141 @@ char *_mutt_expand_path (char *s, size_t slen, int rx)
   char tmp[_POSIX_PATH_MAX];
   char *t;
 
-  char *tail = ""; 
+  char *tail = "";
 
   int recurse = 0;
-  
-  do 
-  {
+
+  do {
     recurse = 0;
 
-    switch (*s)
-    {
-      case '~':
+    switch (*s) {
+    case '~':
       {
-       if (*(s + 1) == '/' || *(s + 1) == 0)
-       {
-         strfcpy (p, NONULL(Homedir), sizeof (p));
-         tail = s + 1;
-       }
-       else
-       {
-         struct passwd *pw;
-         if ((t = strchr (s + 1, '/'))) 
-           *t = 0;
-
-         if ((pw = getpwnam (s + 1)))
-         {
-           strfcpy (p, pw->pw_dir, sizeof (p));
-           if (t)
-           {
-             *t = '/';
-             tail = t;
-           }
-           else
-             tail = "";
-         }
-         else
-         {
-           /* user not found! */
-           if (t)
-             *t = '/';
-           *p = '\0';
-           tail = s;
-         }
-       }
+        if (*(s + 1) == '/' || *(s + 1) == 0) {
+          strfcpy (p, NONULL (Homedir), sizeof (p));
+          tail = s + 1;
+        }
+        else {
+          struct passwd *pw;
+
+          if ((t = strchr (s + 1, '/')))
+            *t = 0;
+
+          if ((pw = getpwnam (s + 1))) {
+            strfcpy (p, pw->pw_dir, sizeof (p));
+            if (t) {
+              *t = '/';
+              tail = t;
+            }
+            else
+              tail = "";
+          }
+          else {
+            /* user not found! */
+            if (t)
+              *t = '/';
+            *p = '\0';
+            tail = s;
+          }
+        }
       }
       break;
-      
-      case '=':
-      case '+':    
+
+    case '=':
+    case '+':
       {
 #ifdef USE_IMAP
-       /* if folder = {host} or imap[s]://host/: don't append slash */
-       if (mx_is_imap (NONULL (Maildir)) &&
-           (Maildir[strlen (Maildir) - 1] == '}' ||
-            Maildir[strlen (Maildir) - 1] == '/'))
-         strfcpy (p, NONULL (Maildir), sizeof (p));
-       else
+        /* if folder = {host} or imap[s]://host/: don't append slash */
+        if (mx_is_imap (NONULL (Maildir)) &&
+            (Maildir[strlen (Maildir) - 1] == '}' ||
+             Maildir[strlen (Maildir) - 1] == '/'))
+          strfcpy (p, NONULL (Maildir), sizeof (p));
+        else
 #endif
-         snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
-       
-       tail = s + 1;
+          snprintf (p, sizeof (p), "%s/", NONULL (Maildir));
+
+        tail = s + 1;
       }
       break;
-      
+
       /* elm compatibility, @ expands alias to user name */
-    
-      case '@':
+
+    case '@':
       {
-       HEADER *h;
-       ADDRESS *alias;
-       
-       if ((alias = mutt_lookup_alias (s + 1)))
-       {
-         h = mutt_new_header();
-         h->env = mutt_new_envelope();
-         h->env->from = h->env->to = alias;
-         mutt_default_save (p, sizeof (p), h);
-         h->env->from = h->env->to = NULL;
-         mutt_free_header (&h);
-         /* Avoid infinite recursion if the resulting folder starts with '@' */
-         if (*p != '@')
-           recurse = 1;
-         
-         tail = "";
-       }
+        HEADER *h;
+        ADDRESS *alias;
+
+        if ((alias = mutt_lookup_alias (s + 1))) {
+          h = mutt_new_header ();
+          h->env = mutt_new_envelope ();
+          h->env->from = h->env->to = alias;
+          mutt_default_save (p, sizeof (p), h);
+          h->env->from = h->env->to = NULL;
+          mutt_free_header (&h);
+          /* Avoid infinite recursion if the resulting folder starts with '@' */
+          if (*p != '@')
+            recurse = 1;
+
+          tail = "";
+        }
       }
       break;
-      
-      case '>':
+
+    case '>':
       {
-       strfcpy (p, NONULL(Inbox), sizeof (p));
-       tail = s + 1;
+        strfcpy (p, NONULL (Inbox), sizeof (p));
+        tail = s + 1;
       }
       break;
-      
-      case '<':
+
+    case '<':
       {
-       strfcpy (p, NONULL(Outbox), sizeof (p));
-       tail = s + 1;
+        strfcpy (p, NONULL (Outbox), sizeof (p));
+        tail = s + 1;
       }
       break;
-      
-      case '!':
+
+    case '!':
       {
-       if (*(s+1) == '!')
-       {
-         strfcpy (p, NONULL(LastFolder), sizeof (p));
-         tail = s + 2;
-       }
-       else 
-       {
-         strfcpy (p, NONULL(Spoolfile), sizeof (p));
-         tail = s + 1;
-       }
+        if (*(s + 1) == '!') {
+          strfcpy (p, NONULL (LastFolder), sizeof (p));
+          tail = s + 2;
+        }
+        else {
+          strfcpy (p, NONULL (Spoolfile), sizeof (p));
+          tail = s + 1;
+        }
       }
       break;
-      
-      case '-':
+
+    case '-':
       {
-       strfcpy (p, NONULL(LastFolder), sizeof (p));
-       tail = s + 1;
+        strfcpy (p, NONULL (LastFolder), sizeof (p));
+        tail = s + 1;
       }
       break;
-      
-      case '^':
+
+    case '^':
       {
-        strfcpy (p, NONULL(CurrentFolder), sizeof (p));
+        strfcpy (p, NONULL (CurrentFolder), sizeof (p));
         tail = s + 1;
       }
       break;
-      default:
+
+    default:
       {
-       *p = '\0';
-       tail = s;
+        *p = '\0';
+        tail = s;
       }
     }
 
-    if (rx && *p && !recurse)
-    {
+    if (rx && *p && !recurse) {
       mutt_rx_sanitize_string (q, sizeof (q), p);
       snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
     }
     else
       snprintf (tmp, sizeof (tmp), "%s%s", p, tail);
-    
+
     strfcpy (s, tmp, slen);
   }
   while (recurse);
@@ -506,17 +487,16 @@ char *mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw)
   size_t pwnl;
   int idx;
   char *p;
-  
-  if (!pw || !pw->pw_gecos) 
+
+  if (!pw || !pw->pw_gecos)
     return NULL;
 
   memset (dest, 0, destlen);
-  
-  if (GecosMask.rx)
-  {
+
+  if (GecosMask.rx) {
     if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0)
-      strfcpy (dest, pw->pw_gecos + pat_match[0].rm_so, 
-              MIN (pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen));
+      strfcpy (dest, pw->pw_gecos + pat_match[0].rm_so,
+               MIN (pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen));
   }
   else if ((p = strchr (pw->pw_gecos, ',')))
     strfcpy (dest, pw->pw_gecos, MIN (destlen, p - pw->pw_gecos + 1));
@@ -525,22 +505,20 @@ char *mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw)
 
   pwnl = strlen (pw->pw_name);
 
-  for (idx = 0; dest[idx]; idx++)
-  {
-    if (dest[idx] == '&')
-    {
+  for (idx = 0; dest[idx]; idx++) {
+    if (dest[idx] == '&') {
       memmove (&dest[idx + pwnl], &dest[idx + 1],
-              MAX(destlen - idx - pwnl - 1, 0));
-      memcpy (&dest[idx], pw->pw_name, MIN(destlen - idx - 1, pwnl));
+               MAX (destlen - idx - pwnl - 1, 0));
+      memcpy (&dest[idx], pw->pw_name, MIN (destlen - idx - 1, pwnl));
       dest[idx] = toupper ((unsigned char) dest[idx]);
     }
   }
-      
+
   return dest;
 }
-  
 
-char *mutt_get_parameter (const char *s, PARAMETER *p)
+
+char *mutt_get_parameter (const char *s, PARAMETER * p)
 {
   for (; p; p = p->next)
     if (ascii_strcasecmp (s, p->attribute) == 0)
@@ -549,40 +527,36 @@ char *mutt_get_parameter (const char *s, PARAMETER *p)
   return NULL;
 }
 
-void mutt_set_parameter (const char *attribute, const char *value, PARAMETER **p)
+void mutt_set_parameter (const char *attribute, const char *value,
+                         PARAMETER ** p)
 {
   PARAMETER *q;
 
-  if (!value)
-  {
+  if (!value) {
     mutt_delete_parameter (attribute, p);
     return;
   }
-  
-  for(q = *p; q; q = q->next)
-  {
-    if (ascii_strcasecmp (attribute, q->attribute) == 0)
-    {
+
+  for (q = *p; q; q = q->next) {
+    if (ascii_strcasecmp (attribute, q->attribute) == 0) {
       mutt_str_replace (&q->value, value);
       return;
     }
   }
-  
-  q = mutt_new_parameter();
-  q->attribute = safe_strdup(attribute);
-  q->value = safe_strdup(value);
+
+  q = mutt_new_parameter ();
+  q->attribute = safe_strdup (attribute);
+  q->value = safe_strdup (value);
   q->next = *p;
   *p = q;
 }
 
-void mutt_delete_parameter (const char *attribute, PARAMETER **p)
+void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
 {
   PARAMETER *q;
-  
-  for (q = *p; q; p = &q->next, q = q->next)
-  {
-    if (ascii_strcasecmp (attribute, q->attribute) == 0)
-    {
+
+  for (q = *p; q; p = &q->next, q = q->next) {
+    if (ascii_strcasecmp (attribute, q->attribute) == 0) {
       *p = q->next;
       q->next = NULL;
       mutt_free_parameter (&q);
@@ -592,52 +566,49 @@ void mutt_delete_parameter (const char *attribute, PARAMETER **p)
 }
 
 /* returns 1 if Mutt can't display this type of data, 0 otherwise */
-int mutt_needs_mailcap (BODY *m)
+int mutt_needs_mailcap (BODY * m)
 {
-  switch (m->type)
-  {
-    case TYPETEXT:
-
-      if (!ascii_strcasecmp ("plain", m->subtype) ||
-         !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
-         !ascii_strcasecmp ("enriched", m->subtype))
-       return 0;
-      break;
+  switch (m->type) {
+  case TYPETEXT:
 
-    case TYPEAPPLICATION:
-      if((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp(m))
-       return 0;
-      if((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(m))
-       return 0;
-      break;
+    if (!ascii_strcasecmp ("plain", m->subtype) ||
+        !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
+        !ascii_strcasecmp ("enriched", m->subtype))
+      return 0;
+    break;
 
-    case TYPEMULTIPART:
-    case TYPEMESSAGE:
+  case TYPEAPPLICATION:
+    if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (m))
       return 0;
+    if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime (m))
+      return 0;
+    break;
+
+  case TYPEMULTIPART:
+  case TYPEMESSAGE:
+    return 0;
   }
 
   return 1;
 }
 
-int mutt_is_text_part (BODY *b)
+int mutt_is_text_part (BODY * b)
 {
   int t = b->type;
   char *s = b->subtype;
-  
+
   if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
     return 0;
 
   if (t == TYPETEXT)
     return 1;
 
-  if (t == TYPEMESSAGE)
-  {
+  if (t == TYPEMESSAGE) {
     if (!ascii_strcasecmp ("delivery-status", s))
       return 1;
   }
 
-  if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION)
-  {
+  if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION) {
     if (!ascii_strcasecmp ("pgp-keys", s))
       return 1;
   }
@@ -645,9 +616,10 @@ int mutt_is_text_part (BODY *b)
   return 0;
 }
 
-void mutt_free_envelope (ENVELOPE **p)
+void mutt_free_envelope (ENVELOPE ** p)
 {
-  if (!*p) return;
+  if (!*p)
+    return;
   rfc822_free_address (&(*p)->return_path);
   rfc822_free_address (&(*p)->from);
   rfc822_free_address (&(*p)->to);
@@ -681,17 +653,18 @@ void mutt_free_envelope (ENVELOPE **p)
 
 void _mutt_mktemp (char *s, 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++);
-  dprint (1, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
+  snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d-%d", NONULL (Tempdir),
+            NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++);
+  dprint (1,
+          (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
   unlink (s);
 }
 
-void mutt_free_alias (ALIAS **p)
+void mutt_free_alias (ALIAS ** p)
 {
   ALIAS *t;
 
-  while (*p)
-  {
+  while (*p) {
     t = *p;
     *p = (*p)->next;
     FREE (&t->name);
@@ -710,34 +683,29 @@ void mutt_pretty_mailbox (char *s)
   scheme = url_check_scheme (s);
 
 #ifdef USE_IMAP
-  if (scheme == U_IMAP || scheme == U_IMAPS)
-  {
+  if (scheme == U_IMAP || scheme == U_IMAPS) {
     imap_pretty_mailbox (s);
     return;
   }
 #endif
 
   /* if s is an url, only collapse path component */
-  if (scheme != U_UNKNOWN)
-  {
-    p = strchr(s, ':')+1;
+  if (scheme != U_UNKNOWN) {
+    p = strchr (s, ':') + 1;
     if (!strncmp (p, "//", 2))
-      q = strchr (p+2, '/');
+      q = strchr (p + 2, '/');
     if (!q)
       q = strchr (p, '\0');
     p = q;
   }
-  
+
   /* first attempt to collapse the pathname */
-  while (*p)
-  {
-    if (*p == '/' && p[1] == '/')
-    {
+  while (*p) {
+    if (*p == '/' && p[1] == '/') {
       *q++ = '/';
       p += 2;
     }
-    else if (p[0] == '/' && p[1] == '.' && p[2] == '/')
-    {
+    else if (p[0] == '/' && p[1] == '.' && p[2] == '/') {
       *q++ = '/';
       p += 3;
     }
@@ -747,14 +715,12 @@ void mutt_pretty_mailbox (char *s)
   *q = 0;
 
   if (mutt_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 &&
-      s[len] == '/')
-  {
+      s[len] == '/') {
     *s++ = '=';
     memmove (s, s + len, mutt_strlen (s + len) + 1);
   }
   else if (mutt_strncmp (s, Homedir, (len = mutt_strlen (Homedir))) == 0 &&
-          s[len] == '/')
-  {
+           s[len] == '/') {
     *s++ = '~';
     memmove (s, s + len - 1, mutt_strlen (s + len - 1) + 1);
   }
@@ -764,31 +730,32 @@ void mutt_pretty_size (char *s, size_t len, long n)
 {
   if (n == 0)
     strfcpy (s, "0K", len);
-  else if (n < 10189) /* 0.1K - 9.9K */
+  else if (n < 10189)           /* 0.1K - 9.9K */
     snprintf (s, len, "%3.1fK", (n < 103) ? 0.1 : n / 1024.0);
-  else if (n < 1023949) /* 10K - 999K */
-  {
+  else if (n < 1023949) {       /* 10K - 999K */
     /* 51 is magic which causes 10189/10240 to be rounded up to 10 */
     snprintf (s, len, "%ldK", (n + 51) / 1024);
   }
-  else if (n < 10433332) /* 1.0M - 9.9M */
+  else if (n < 10433332)        /* 1.0M - 9.9M */
     snprintf (s, len, "%3.1fM", n / 1048576.0);
-  else /* 10M+ */
-  {
+  else {                        /* 10M+ */
+
     /* (10433332 + 52428) / 1048576 = 10 */
     snprintf (s, len, "%ldM", (n + 52428) / 1048576);
   }
 }
 
-void mutt_expand_file_fmt (char *dest, size_t destlen, const char *fmt, const char *src)
+void mutt_expand_file_fmt (char *dest, size_t destlen, const char *fmt,
+                           const char *src)
 {
   char tmp[LONG_STRING];
-  
+
   mutt_quote_filename (tmp, sizeof (tmp), src);
   mutt_expand_fmt (dest, destlen, fmt, tmp);
 }
 
-void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, const char *src)
+void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt,
+                      const char *src)
 {
   const char *p;
   char *d;
@@ -797,50 +764,46 @@ void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, const char *s
 
   slen = mutt_strlen (src);
   destlen--;
-  
-  for (p = fmt, d = dest; destlen && *p; p++)
-  {
-    if (*p == '%') 
-    {
-      switch (p[1])
-      {
-       case '%':
-         *d++ = *p++;
-         destlen--;
-         break;
-       case 's':
-         found = 1;
-         strfcpy (d, src, destlen + 1);
-         d       += destlen > slen ? slen : destlen;
-         destlen -= destlen > slen ? slen : destlen;
-         p++;
-         break;
-       default:
-         *d++ = *p; 
-         destlen--;
-         break;
+
+  for (p = fmt, d = dest; destlen && *p; p++) {
+    if (*p == '%') {
+      switch (p[1]) {
+      case '%':
+        *d++ = *p++;
+        destlen--;
+        break;
+      case 's':
+        found = 1;
+        strfcpy (d, src, destlen + 1);
+        d += destlen > slen ? slen : destlen;
+        destlen -= destlen > slen ? slen : destlen;
+        p++;
+        break;
+      default:
+        *d++ = *p;
+        destlen--;
+        break;
       }
     }
-    else
-    {
+    else {
       *d++ = *p;
       destlen--;
     }
   }
-  
+
   *d = '\0';
-  
-  if (!found && destlen > 0)
-  {
+
+  if (!found && destlen > 0) {
     safe_strcat (dest, destlen, " ");
     safe_strcat (dest, destlen, src);
   }
-  
+
 }
 
 /* return 0 on success, -1 on abort, 1 on error */
 int mutt_check_overwrite (const char *attname, const char *path,
-                               char *fname, size_t flen, int *append, char **directory) 
+                          char *fname, size_t flen, int *append,
+                          char **directory)
 {
   int rc = 0;
   char tmp[_POSIX_PATH_MAX];
@@ -851,74 +814,71 @@ int mutt_check_overwrite (const char *attname, const char *path,
     return 0;
   if (stat (fname, &st) != 0)
     return -1;
-  if (S_ISDIR (st.st_mode))
-  {
-    if (directory)
-    {
+  if (S_ISDIR (st.st_mode)) {
+    if (directory) {
       switch (mutt_multi_choice
-             (_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"), _("yna")))
-      {
-       case 3:         /* all */
-         mutt_str_replace (directory, fname);
-         break;
-       case 1:         /* yes */
-         FREE (directory);
-         break;
-       case -1:        /* abort */
-         FREE (directory); 
-         return -1;
-       case  2:        /* no */
-         FREE (directory);
-         return 1;
+              (_("File is a directory, save under it? [(y)es, (n)o, (a)ll]"),
+               _("yna"))) {
+      case 3:                  /* all */
+        mutt_str_replace (directory, fname);
+        break;
+      case 1:                  /* yes */
+        FREE (directory);
+        break;
+      case -1:                 /* abort */
+        FREE (directory);
+        return -1;
+      case 2:                  /* no */
+        FREE (directory);
+        return 1;
       }
     }
-    else if ((rc = mutt_yesorno (_("File is a directory, save under it?"), M_YES)) != M_YES)
+    else
+      if ((rc =
+           mutt_yesorno (_("File is a directory, save under it?"),
+                         M_YES)) != M_YES)
       return (rc == M_NO) ? 1 : -1;
 
-    if (!attname || !attname[0])
-    {
+    if (!attname || !attname[0]) {
       tmp[0] = 0;
       if (mutt_get_field (_("File under directory: "), tmp, sizeof (tmp),
-                                     M_FILE | M_CLEAR) != 0 || !tmp[0])
-       return (-1);
+                          M_FILE | M_CLEAR) != 0 || !tmp[0])
+        return (-1);
       mutt_concat_path (fname, path, tmp, flen);
     }
     else
       mutt_concat_path (fname, path, mutt_basename (attname), flen);
   }
-  
-  if (*append == 0 && access (fname, F_OK) == 0)
-  {
+
+  if (*append == 0 && access (fname, F_OK) == 0) {
     switch (mutt_multi_choice
-           (_("File exists, (o)verwrite, (a)ppend, or (c)ancel?"), _("oac")))
+            (_("File exists, (o)verwrite, (a)ppend, or (c)ancel?"), _("oac")))
     {
-      case -1: /* abort */
-        return -1;
-      case 3:  /* cancel */
-       return 1;
+    case -1:                   /* abort */
+      return -1;
+    case 3:                    /* cancel */
+      return 1;
 
-      case 2: /* append */
-        *append = M_SAVE_APPEND;
-        break;
-      case 1: /* overwrite */
-        *append = M_SAVE_OVERWRITE;
-        break;
+    case 2:                    /* append */
+      *append = M_SAVE_APPEND;
+      break;
+    case 1:                    /* overwrite */
+      *append = M_SAVE_OVERWRITE;
+      break;
     }
   }
   return 0;
 }
 
-void mutt_save_path (char *d, size_t dsize, ADDRESS *a)
+void mutt_save_path (char *d, size_t dsize, ADDRESS * a)
 {
-  if (a && a->mailbox)
-  {
+  if (a && a->mailbox) {
     strfcpy (d, a->mailbox, dsize);
-    if (!option (OPTSAVEADDRESS))
-    {
+    if (!option (OPTSAVEADDRESS)) {
       char *p;
 
       if ((p = strpbrk (d, "%@")))
-       *p = 0;
+        *p = 0;
     }
     mutt_strlower (d);
   }
@@ -926,7 +886,7 @@ void mutt_save_path (char *d, size_t dsize, ADDRESS *a)
     *d = 0;
 }
 
-void mutt_safe_path (char *s, size_t l, ADDRESS *a)
+void mutt_safe_path (char *s, size_t l, ADDRESS * a)
 {
   char *p;
 
@@ -938,11 +898,14 @@ void mutt_safe_path (char *s, size_t l, ADDRESS *a)
 
 /* counts how many characters in s can be skipped while none of the
  * characters of c appears */
-int mutt_skipchars (const char* s, const char* c) {
+int mutt_skipchars (const char *s, const char *c)
+{
   int ret = 0;
-  const char* p = s;
+  const char *p = s;
+
   while (s && *s) {
-    register const char* t = c;
+    register const char *t = c;
+
     while (t && *t) {
       if (*t == *s)
         return (ret);
@@ -954,234 +917,220 @@ int mutt_skipchars (const char* s, const char* c) {
   return (mutt_strlen (p));
 }
 
-void mutt_FormatString (char *dest,            /* output buffer */
-                       size_t destlen,         /* output buffer len */
-                       const char *src,        /* template string */
-                       format_t *callback,     /* callback for processing */
-                       unsigned long data,     /* callback data */
-                       format_flag flags)      /* callback flags */
-{
+void mutt_FormatString (char *dest,     /* output buffer */
+                        size_t destlen, /* output buffer len */
+                        const char *src,        /* template string */
+                        format_t * callback,    /* callback for processing */
+                        unsigned long data,     /* callback data */
+                        format_flag flags)
+{                               /* callback flags */
   char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch;
   char ifstring[SHORT_STRING], elsestring[SHORT_STRING];
   size_t wlen, count, len, col, wid;
 
   prefix[0] = '\0';
-  destlen--; /* save room for the terminal \0 */
+  destlen--;                    /* save room for the terminal \0 */
   wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0;
   col = wlen;
-    
-  while (*src && wlen < destlen)
-  {
-    if (*src == '%')
-    {
-      if (*++src == '%')
-      {
-       *wptr++ = '%';
-       wlen++;
-       col++;
-       src++;
-       continue;
+
+  while (*src && wlen < destlen) {
+    if (*src == '%') {
+      if (*++src == '%') {
+        *wptr++ = '%';
+        wlen++;
+        col++;
+        src++;
+        continue;
       }
 
-      if (*src == '?')
-      {
-       flags |= M_FORMAT_OPTIONAL;
-       src++;
+      if (*src == '?') {
+        flags |= M_FORMAT_OPTIONAL;
+        src++;
       }
-      else
-      {
-       flags &= ~M_FORMAT_OPTIONAL;
-
-       /* eat the format string */
-       cp = prefix;
-       count = 0;
-       while (count < sizeof (prefix) &&
-              (isdigit ((unsigned char) *src) || *src == '.' || *src == '-'))
-       {
-         *cp++ = *src++;
-         count++;
-       }
-       *cp = 0;
+      else {
+        flags &= ~M_FORMAT_OPTIONAL;
+
+        /* eat the format string */
+        cp = prefix;
+        count = 0;
+        while (count < sizeof (prefix) &&
+               (isdigit ((unsigned char) *src) || *src == '.' || *src == '-'))
+        {
+          *cp++ = *src++;
+          count++;
+        }
+        *cp = 0;
       }
 
       if (!*src)
-       break; /* bad format */
+        break;                  /* bad format */
 
-      ch = *src++; /* save the character to switch on */
+      ch = *src++;              /* save the character to switch on */
 
-      if (flags & M_FORMAT_OPTIONAL)
-      {
+      if (flags & M_FORMAT_OPTIONAL) {
         if (*src != '?')
-          break; /* bad format */
+          break;                /* bad format */
         src++;
 
         /* eat the `if' part of the string */
         cp = ifstring;
-       count = 0;
-        while (count < sizeof (ifstring) && *src && *src != '?' && *src != '&')
-       {
+        count = 0;
+        while (count < sizeof (ifstring) && *src && *src != '?'
+               && *src != '&') {
           *cp++ = *src++;
-         count++;
-       }
+          count++;
+        }
         *cp = 0;
 
-       /* eat the `else' part of the string (optional) */
-       if (*src == '&')
-         src++; /* skip the & */
-       cp = elsestring;
-       count = 0;
-       while (count < sizeof (elsestring) && *src && *src != '?')
-       {
-         *cp++ = *src++;
-         count++;
-       }
-       *cp = 0;
-
-       if (!*src)
-         break; /* bad format */
-
-        src++; /* move past the trailing `?' */
+        /* eat the `else' part of the string (optional) */
+        if (*src == '&')
+          src++;                /* skip the & */
+        cp = elsestring;
+        count = 0;
+        while (count < sizeof (elsestring) && *src && *src != '?') {
+          *cp++ = *src++;
+          count++;
+        }
+        *cp = 0;
+
+        if (!*src)
+          break;                /* bad format */
+
+        src++;                  /* move past the trailing `?' */
       }
 
       /* handle generic cases first */
-      if (ch == '>')
-      {
-       /* right justify to EOL */
-       ch = *src++; /* pad char */
-       /* calculate space left on line.  if we've already written more data
-          than will fit on the line, ignore the rest of the line */
-       if ( DrawFullLine  || option(OPTSTATUSONTOP))
-         count = (COLS < destlen ? COLS : destlen);
-       else
-         count = ((COLS-SidebarWidth) < destlen ? (COLS - SidebarWidth) : destlen);
-       if (count > col)
-       {
-         count -= col; /* how many columns left on this line */
-         mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
-         wid = mutt_strlen (buf);
-         if (count > wid)
-         {
-           count -= wid; /* how many chars to pad */
-           memset (wptr, ch, count);
-           wptr += count;
-           col += count;
-         }
-         if (wid + wlen > destlen)
-           len = destlen - wlen;
-    else
-      len = wid;
-         memcpy (wptr, buf, len);
-         wptr += len;
-         wlen += len;
-         col += mutt_strwidth (buf);
-       }
-       break; /* skip rest of input */
+      if (ch == '>') {
+        /* right justify to EOL */
+        ch = *src++;            /* pad char */
+        /* calculate space left on line.  if we've already written more data
+           than will fit on the line, ignore the rest of the line */
+        if (DrawFullLine || option (OPTSTATUSONTOP))
+          count = (COLS < destlen ? COLS : destlen);
+        else
+          count =
+            ((COLS - SidebarWidth) <
+             destlen ? (COLS - SidebarWidth) : destlen);
+        if (count > col) {
+          count -= col;         /* how many columns left on this line */
+          mutt_FormatString (buf, sizeof (buf), src, callback, data, flags);
+          wid = mutt_strlen (buf);
+          if (count > wid) {
+            count -= wid;       /* how many chars to pad */
+            memset (wptr, ch, count);
+            wptr += count;
+            col += count;
+          }
+          if (wid + wlen > destlen)
+            len = destlen - wlen;
+          else
+            len = wid;
+          memcpy (wptr, buf, len);
+          wptr += len;
+          wlen += len;
+          col += mutt_strwidth (buf);
+        }
+        break;                  /* skip rest of input */
       }
-      else if (ch == '|')
-      {
-       /* pad to EOL */
-       ch = *src++;
-       if (destlen > COLS)
-         destlen = COLS;
-       if (destlen > wlen)
-       {
-         count = destlen - wlen;
-         memset (wptr, ch, count);
-         wptr += count;
-       }
-       break; /* skip rest of input */
+      else if (ch == '|') {
+        /* pad to EOL */
+        ch = *src++;
+        if (destlen > COLS)
+          destlen = COLS;
+        if (destlen > wlen) {
+          count = destlen - wlen;
+          memset (wptr, ch, count);
+          wptr += count;
+        }
+        break;                  /* skip rest of input */
       }
-      else
-      {
-       short tolower =  0;
-       short nodots  = 0;
-       
-       while (ch == '_' || ch == ':') 
-       {
-         if (ch == '_')
-           tolower = 1;
-         else if (ch == ':') 
-           nodots = 1;
-         
-         ch = *src++;
-       }
-       
-       /* use callback function to handle this case */
-       src = callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring, data, flags);
-
-       if (tolower)
-         mutt_strlower (buf);
-       if (nodots) 
-       {
-         char *p = buf;
-         for (; *p; p++)
-           if (*p == '.')
-               *p = '_';
-       }
-       
-       if ((len = mutt_strlen (buf)) + wlen > destlen)
-         len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
-
-       memcpy (wptr, buf, len);
-       wptr += len;
-       wlen += len;
-       col += mutt_strwidth (buf);
+      else {
+        short tolower = 0;
+        short nodots = 0;
+
+        while (ch == '_' || ch == ':') {
+          if (ch == '_')
+            tolower = 1;
+          else if (ch == ':')
+            nodots = 1;
+
+          ch = *src++;
+        }
+
+        /* use callback function to handle this case */
+        src =
+          callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring,
+                    data, flags);
+
+        if (tolower)
+          mutt_strlower (buf);
+        if (nodots) {
+          char *p = buf;
+
+          for (; *p; p++)
+            if (*p == '.')
+              *p = '_';
+        }
+
+        if ((len = mutt_strlen (buf)) + wlen > destlen)
+          len = (destlen - wlen > 0) ? (destlen - wlen) : 0;
+
+        memcpy (wptr, buf, len);
+        wptr += len;
+        wlen += len;
+        col += mutt_strwidth (buf);
       }
     }
-    else if (*src == '\\')
-    {
+    else if (*src == '\\') {
       if (!*++src)
-       break;
-      switch (*src)
-      {
-       case 'n':
-         *wptr = '\n';
-         break;
-       case 't':
-         *wptr = '\t';
-         break;
-       case 'r':
-         *wptr = '\r';
-         break;
-       case 'f':
-         *wptr = '\f';
-         break;
-       case 'v':
-         *wptr = '\v';
-         break;
-       default:
-         *wptr = *src;
-         break;
+        break;
+      switch (*src) {
+      case 'n':
+        *wptr = '\n';
+        break;
+      case 't':
+        *wptr = '\t';
+        break;
+      case 'r':
+        *wptr = '\r';
+        break;
+      case 'f':
+        *wptr = '\f';
+        break;
+      case 'v':
+        *wptr = '\v';
+        break;
+      default:
+        *wptr = *src;
+        break;
       }
       src++;
       wptr++;
       wlen++;
       col++;
     }
-    else
-    {
+    else {
       unsigned int bar = mutt_skipchars (src, "%\\");
-      char* bar2 = safe_malloc (bar+1);
-      strfcpy (bar2, src, bar+1);
+      char *bar2 = safe_malloc (bar + 1);
+
+      strfcpy (bar2, src, bar + 1);
       while (bar--) {
         *wptr++ = *src++;
         wlen++;
       }
       col += mutt_strwidth (bar2);
-      FREE(&bar2);
+      FREE (&bar2);
     }
   }
   *wptr = 0;
 
 #if 0
-  if (flags & M_FORMAT_MAKEPRINT)
-  {
+  if (flags & M_FORMAT_MAKEPRINT) {
     /* Make sure that the string is printable by changing all non-printable
        chars to dots, or spaces for non-printable whitespace */
-    for (cp = dest ; *cp ; cp++)
-      if (!IsPrint (*cp) &&
-         !((flags & M_FORMAT_TREE) && (*cp <= M_TREE_MAX)))
-       *cp = isspace ((unsigned char) *cp) ? ' ' : '.';
+    for (cp = dest; *cp; cp++)
+      if (!IsPrint (*cp) && !((flags & M_FORMAT_TREE) && (*cp <= M_TREE_MAX)))
+        *cp = isspace ((unsigned char) *cp) ? ' ' : '.';
   }
 #endif
 }
@@ -1189,15 +1138,14 @@ void mutt_FormatString (char *dest,             /* output buffer */
 /* This function allows the user to specify a command to read stdout from in
    place of a normal file.  If the last character in the string is a pipe (|),
    then we assume it is a commmand to run instead of a normal file. */
-FILE *mutt_open_read (const char *path, pid_t *thepid)
+FILE *mutt_open_read (const char *path, pid_t * thepid)
 {
   FILE *f;
   struct stat s;
 
   int len = mutt_strlen (path);
 
-  if (path[len - 1] == '|')
-  {
+  if (path[len - 1] == '|') {
     /* read from a pipe */
 
     char *s = safe_strdup (path);
@@ -1207,12 +1155,10 @@ FILE *mutt_open_read (const char *path, pid_t *thepid)
     *thepid = mutt_create_filter (s, NULL, &f, NULL);
     FREE (&s);
   }
-  else
-  {
+  else {
     if (stat (path, &s) < 0)
       return (NULL);
-    if (S_ISDIR (s.st_mode))
-    {
+    if (S_ISDIR (s.st_mode)) {
       errno = EINVAL;
       return (NULL);
     }
@@ -1233,42 +1179,39 @@ int mutt_save_confirm (const char *s, struct stat *st)
   magic = mx_get_magic (s);
 
 #ifdef USE_POP
-  if (magic == M_POP)
-  {
+  if (magic == M_POP) {
     mutt_error _("Can't save message to POP mailbox.");
+
     return 1;
   }
 #endif
 
 #ifdef USE_NNTP
-  if (magic == M_NNTP)
-  {
+  if (magic == M_NNTP) {
     mutt_error _("Can't save message to newsserver.");
+
     return 0;
   }
 #endif
 
-  if (stat (s, st) != -1)
-  {
-    if (magic == -1)
-    {
+  if (stat (s, st) != -1) {
+    if (magic == -1) {
       mutt_error (_("%s is not a mailbox!"), s);
       return 1;
     }
 
     if (option (OPTCONFIRMAPPEND) &&
-       (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
+        (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
       /* if we're appending to the trash, there's no point in asking */
     {
       snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
       if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
-       ret = 1;
+        ret = 1;
       else if (rc == -1)
-       ret = -1;
+        ret = -1;
     }
   }
-  else
-  {
+  else {
 #ifdef USE_IMAP
     if (magic != M_IMAP)
 #endif /* execute the block unconditionally if we don't use imap */
@@ -1276,62 +1219,58 @@ int mutt_save_confirm (const char *s, struct stat *st)
       st->st_mtime = 0;
       st->st_atime = 0;
 
-      if (errno == ENOENT)
-      {
-       if (option (OPTCONFIRMCREATE))
-       {
-         snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
-         if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
-           ret = 1;
-         else if (rc == -1)
-           ret = -1;
-       }
+      if (errno == ENOENT) {
+        if (option (OPTCONFIRMCREATE)) {
+          snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
+          if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
+            ret = 1;
+          else if (rc == -1)
+            ret = -1;
+        }
       }
-      else
-      {
-       mutt_perror (s);
-       return 1;
+      else {
+        mutt_perror (s);
+        return 1;
       }
     }
   }
 
-  CLEARLINE (LINES-1);
+  CLEARLINE (LINES - 1);
   return (ret);
 }
 
-void state_prefix_putc (char c, STATE *s)
+void state_prefix_putc (char c, STATE * s)
 {
-  if (s->flags & M_PENDINGPREFIX)
-  {
+  if (s->flags & M_PENDINGPREFIX) {
     int i;
 
     i = strlen (Quotebuf);
     Quotebuf[i++] = c;
     Quotebuf[i] = '\0';
-    if (i == sizeof (Quotebuf) - 1 || c == '\n')
-    {
+    if (i == sizeof (Quotebuf) - 1 || c == '\n') {
       char buf[2 * SHORT_STRING];
       int j = 0, offset = 0;
       regmatch_t pmatch[1];
 
       state_reset_prefix (s);
-      while (regexec ((regex_t *) QuoteRegexp.rx, &Quotebuf[offset], 1, pmatch, 0) == 0)
-       offset += pmatch->rm_eo;
+      while (regexec
+             ((regex_t *) QuoteRegexp.rx, &Quotebuf[offset], 1, pmatch,
+              0) == 0)
+        offset += pmatch->rm_eo;
 
       if (!option (OPTQUOTEEMPTY) && Quotebuf[offset] == '\n') {
         buf[0] = '\n';
         buf[1] = '\0';
       }
-      else if (option (OPTQUOTEQUOTED) && offset)
-      {
-       for (i = 0; i < offset; i++)
-         if (Quotebuf[i] != ' ')
-           j = i;
-       strncpy (buf, Quotebuf, j + 1);
-       strcpy (buf + j + 1, Quotebuf + j);
+      else if (option (OPTQUOTEQUOTED) && offset) {
+        for (i = 0; i < offset; i++)
+          if (Quotebuf[i] != ' ')
+            j = i;
+        strncpy (buf, Quotebuf, j + 1);
+        strcpy (buf + j + 1, Quotebuf + j);
       }
       else
-       snprintf (buf, sizeof (buf), "%s%s", NONULL(s->prefix), Quotebuf);
+        snprintf (buf, sizeof (buf), "%s%s", NONULL (s->prefix), Quotebuf);
 
       state_puts (buf, s);
     }
@@ -1339,14 +1278,13 @@ void state_prefix_putc (char c, STATE *s)
   else
     state_putc (c, s);
 
-  if (c == '\n')
-  {
+  if (c == '\n') {
     state_set_prefix (s);
     Quotebuf[0] = '\0';
   }
 }
 
-int state_printf (STATE *s, const char *fmt, ...)
+int state_printf (STATE * s, const char *fmt, ...)
 {
   int rv;
   va_list ap;
@@ -1354,36 +1292,36 @@ int state_printf (STATE *s, const char *fmt, ...)
   va_start (ap, fmt);
   rv = vfprintf (s->fpout, fmt, ap);
   va_end (ap);
-  
+
   return rv;
 }
 
-void state_mark_attach (STATE *s)
+void state_mark_attach (STATE * s)
 {
   if ((s->flags & M_DISPLAY) && !mutt_strcmp (Pager, "builtin"))
     state_puts (AttachmentMarker, s);
 }
 
-void state_attach_puts (const char *t, STATE *s)
+void state_attach_puts (const char *t, STATE * s)
 {
-  if (*t != '\n') state_mark_attach (s);
-  while (*t)
-  {
+  if (*t != '\n')
+    state_mark_attach (s);
+  while (*t) {
     state_putc (*t, s);
     if (*t++ == '\n' && *t)
-      if (*t != '\n') state_mark_attach (s);
+      if (*t != '\n')
+        state_mark_attach (s);
   }
 }
 
 void mutt_display_sanitize (char *s)
 {
-  for (; *s; s++)
-  {
+  for (; *s; s++) {
     if (!IsPrint (*s))
       *s = '?';
   }
 }
-      
+
 void mutt_sleep (short s)
 {
   if (SleepTime > s)
@@ -1399,19 +1337,17 @@ void mutt_sleep (short s)
  * Disregards the 'destroy' flag, which seems reserved for caller.
  * This is bad, but there's no apparent protocol for it.
  */
-BUFFER * mutt_buffer_init(BUFFER *b)
+BUFFER *mutt_buffer_init (BUFFER * b)
 {
-  if (!b)
-  {
-    b = safe_malloc(sizeof(BUFFER));
+  if (!b) {
+    b = safe_malloc (sizeof (BUFFER));
     if (!b)
       return NULL;
   }
-  else
-  {
-    safe_free(b->data);
+  else {
+    safe_free (b->data);
   }
-  memset(b, 0, sizeof(BUFFER));
+  memset (b, 0, sizeof (BUFFER));
   return b;
 }
 
@@ -1423,50 +1359,49 @@ BUFFER * mutt_buffer_init(BUFFER *b)
  * Disregards the 'destroy' flag, which seems reserved for caller.
  * This is bad, but there's no apparent protocol for it.
  */
-BUFFER * mutt_buffer_from(BUFFER *b, char *seed)
+BUFFER *mutt_buffer_from (BUFFER * b, char *seed)
 {
   if (!seed)
     return NULL;
 
-  b = mutt_buffer_init(b);
+  b = mutt_buffer_init (b);
   b->data = safe_strdup (seed);
   b->dsize = mutt_strlen (seed);
   b->dptr = (char *) b->data + b->dsize;
   return b;
 }
 
-void mutt_buffer_addstr (BUFFER* buf, const char* s)
+void mutt_buffer_addstr (BUFFER * buf, const char *s)
 {
   mutt_buffer_add (buf, s, mutt_strlen (s));
 }
 
-void mutt_buffer_addch (BUFFER* buf, char c)
+void mutt_buffer_addch (BUFFER * buf, char c)
 {
   mutt_buffer_add (buf, &c, 1);
 }
 
-void mutt_buffer_free (BUFFER **p)
+void mutt_buffer_free (BUFFER ** p)
 {
-  if (!p || !*p) 
+  if (!p || !*p)
     return;
 
-   FREE(&(*p)->data);
-   /* dptr is just an offset to data and shouldn't be freed */
-   FREE(p);
+  FREE (&(*p)->data);
+  /* dptr is just an offset to data and shouldn't be freed */
+  FREE (p);
 }
 
 /* dynamically grows a BUFFER to accomodate s, in increments of 128 bytes.
  * Always one byte bigger than necessary for the null terminator, and
  * the buffer is always null-terminated */
-void mutt_buffer_add (BUFFER* buf, const char* s, size_t len)
+void mutt_buffer_add (BUFFER * buf, const char *s, size_t len)
 {
   size_t offset;
 
-  if (buf->dptr + len + 1 > buf->data + buf->dsize)
-  {
+  if (buf->dptr + len + 1 > buf->data + buf->dsize) {
     offset = buf->dptr - buf->data;
     buf->dsize += len < 128 ? 128 : len + 1;
-    safe_realloc ((void**) &buf->data, buf->dsize);
+    safe_realloc ((void **) &buf->data, buf->dsize);
     buf->dptr = buf->data + offset;
   }
   memcpy (buf->dptr, s, len);
@@ -1481,45 +1416,45 @@ time_t mutt_decrease_mtime (const char *f, struct stat *st)
   struct utimbuf utim;
   struct stat _st;
   time_t mtime;
-  
-  if (!st)
-  {
+
+  if (!st) {
     if (stat (f, &_st) == -1)
       return -1;
     st = &_st;
   }
 
-  if ((mtime = st->st_mtime) == time (NULL))
-  {
+  if ((mtime = st->st_mtime) == time (NULL)) {
     mtime -= 1;
     utim.actime = mtime;
     utim.modtime = mtime;
     utime (f, &utim);
   }
-  
+
   return mtime;
 }
 
 const char *mutt_make_version (void)
 {
   static char vstring[STRING];
+
   snprintf (vstring, sizeof (vstring), "Mutt-ng %s (%s)",
-           MUTT_VERSION, ReleaseDate);
+            MUTT_VERSION, ReleaseDate);
   return vstring;
 }
 
 REGEXP *mutt_compile_regexp (const char *s, int flags)
 {
   REGEXP *pp = safe_calloc (sizeof (REGEXP), 1);
+
   pp->pattern = safe_strdup (s);
   pp->rx = safe_calloc (sizeof (regex_t), 1);
-  if (REGCOMP (pp->rx, NONULL(s), flags) != 0)
+  if (REGCOMP (pp->rx, NONULL (s), flags) != 0)
     mutt_free_regexp (&pp);
 
   return pp;
 }
 
-void mutt_free_regexp (REGEXP **pp)
+void mutt_free_regexp (REGEXP ** pp)
 {
   FREE (&(*pp)->pattern);
   regfree ((*pp)->rx);
@@ -1527,13 +1462,13 @@ void mutt_free_regexp (REGEXP **pp)
   FREE (pp);
 }
 
-void mutt_free_rx_list (RX_LIST **list)
+void mutt_free_rx_list (RX_LIST ** list)
 {
   RX_LIST *p;
-  
-  if (!list) return;
-  while (*list)
-  {
+
+  if (!list)
+    return;
+  while (*list) {
     p = *list;
     *list = (*list)->next;
     mutt_free_regexp (&p->rx);
@@ -1541,30 +1476,31 @@ void mutt_free_rx_list (RX_LIST **list)
   }
 }
 
-void mutt_free_spam_list (SPAM_LIST **list)
+void mutt_free_spam_list (SPAM_LIST ** list)
 {
   SPAM_LIST *p;
-  
-  if (!list) return;
-  while (*list)
-  {
+
+  if (!list)
+    return;
+  while (*list) {
     p = *list;
     *list = (*list)->next;
     mutt_free_regexp (&p->rx);
-    safe_free(&p->template);
+    safe_free (&p->template);
     FREE (&p);
   }
 }
 
-int mutt_match_rx_list (const char *s, RX_LIST *l)
+int mutt_match_rx_list (const char *s, RX_LIST * l)
 {
-  if (!s)  return 0;
-  
-  for (; l; l = l->next)
-  {
-    if (regexec (l->rx->rx, s, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0)
-    {
-      dprint (5, (debugfile, "mutt_match_rx_list: %s matches %s\n", s, l->rx->pattern));
+  if (!s)
+    return 0;
+
+  for (; l; l = l->next) {
+    if (regexec (l->rx->rx, s, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0) {
+      dprint (5,
+              (debugfile, "mutt_match_rx_list: %s matches %s\n", s,
+               l->rx->pattern));
       return 1;
     }
   }
@@ -1572,47 +1508,48 @@ int mutt_match_rx_list (const char *s, RX_LIST *l)
   return 0;
 }
 
-int mutt_match_spam_list (const char *s, SPAM_LIST *l, char *text, int x)
+int mutt_match_spam_list (const char *s, SPAM_LIST * l, char *text, int x)
 {
   static regmatch_t *pmatch = NULL;
   static int nmatch = 0;
   int i, n, tlen;
   char *p;
 
-  if (!s)  return 0;
+  if (!s)
+    return 0;
 
   tlen = 0;
 
-  for (; l; l = l->next)
-  {
+  for (; l; l = l->next) {
     /* If this pattern needs more matches, expand pmatch. */
-    if (l->nmatch > nmatch)
-    {
-      safe_realloc (&pmatch, l->nmatch * sizeof(regmatch_t));
+    if (l->nmatch > nmatch) {
+      safe_realloc (&pmatch, l->nmatch * sizeof (regmatch_t));
       nmatch = l->nmatch;
     }
 
     /* Does this pattern match? */
-    if (regexec (l->rx->rx, s, (size_t) l->nmatch, (regmatch_t *) pmatch, (int) 0) == 0)
-    {
-      dprint (5, (debugfile, "mutt_match_spam_list: %s matches %s\n", s, l->rx->pattern));
-      dprint (5, (debugfile, "mutt_match_spam_list: %d subs\n", l->rx->rx->re_nsub));
+    if (regexec
+        (l->rx->rx, s, (size_t) l->nmatch, (regmatch_t *) pmatch,
+         (int) 0) == 0) {
+      dprint (5,
+              (debugfile, "mutt_match_spam_list: %s matches %s\n", s,
+               l->rx->pattern));
+      dprint (5,
+              (debugfile, "mutt_match_spam_list: %d subs\n",
+               l->rx->rx->re_nsub));
 
       /* Copy template into text, with substitutions. */
-      for (p = l->template; *p;)
-      {
-       if (*p == '%')
-       {
-         n = atoi(++p);                        /* find pmatch index */
-         while (isdigit(*p))
-           ++p;                                /* skip subst token */
-         for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
-           text[tlen++] = s[i];
-       }
-       else
-       {
-         text[tlen++] = *p++;
-       }
+      for (p = l->template; *p;) {
+        if (*p == '%') {
+          n = atoi (++p);       /* find pmatch index */
+          while (isdigit (*p))
+            ++p;                /* skip subst token */
+          for (i = pmatch[n].rm_so; (i < pmatch[n].rm_eo) && (tlen < x); i++)
+            text[tlen++] = s[i];
+        }
+        else {
+          text[tlen++] = *p++;
+        }
       }
       text[tlen] = '\0';
       dprint (5, (debugfile, "mutt_match_spam_list: \"%s\"\n", text));
diff --git a/mx.c b/mx.c
index e45fda3..ec09008 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -85,27 +85,26 @@ static int invoke_dotlock (const char *path, int dummy, int flags, int retry)
   char cmd[LONG_STRING + _POSIX_PATH_MAX];
   char f[SHORT_STRING + _POSIX_PATH_MAX];
   char r[SHORT_STRING];
-  
+
   if (flags & DL_FL_RETRY)
     snprintf (r, sizeof (r), "-r %d ", retry ? MAXLOCKATTEMPT : 0);
-  
+
   mutt_quote_filename (f, sizeof (f), path);
-  
+
   snprintf (cmd, sizeof (cmd),
-           "%s %s%s%s%s%s%s%s",
-           NONULL (MuttDotlock),
-           flags & DL_FL_TRY ? "-t " : "",
-           flags & DL_FL_UNLOCK ? "-u " : "",
-           flags & DL_FL_USEPRIV ? "-p " : "",
-           flags & DL_FL_FORCE ? "-f " : "",
-           flags & DL_FL_UNLINK ? "-d " : "",
-           flags & DL_FL_RETRY ? r : "",
-           f);
-  
+            "%s %s%s%s%s%s%s%s",
+            NONULL (MuttDotlock),
+            flags & DL_FL_TRY ? "-t " : "",
+            flags & DL_FL_UNLOCK ? "-u " : "",
+            flags & DL_FL_USEPRIV ? "-p " : "",
+            flags & DL_FL_FORCE ? "-f " : "",
+            flags & DL_FL_UNLINK ? "-d " : "",
+            flags & DL_FL_RETRY ? r : "", f);
+
   return mutt_system (cmd);
 }
 
-#else 
+#else
 
 #define invoke_dotlock dotlock_invoke
 
@@ -116,28 +115,25 @@ static int dotlock_file (const char *path, int fd, int retry)
   int r;
   int flags = DL_FL_USEPRIV | DL_FL_RETRY;
 
-  if (retry) retry = 1;
+  if (retry)
+    retry = 1;
 
 retry_lock:
-  if ((r = invoke_dotlock(path, fd, flags, retry)) == DL_EX_EXIST)
-  {
-    if (!option (OPTNOCURSES))
-    {
+  if ((r = invoke_dotlock (path, fd, flags, retry)) == DL_EX_EXIST) {
+    if (!option (OPTNOCURSES)) {
       char msg[LONG_STRING];
-      
-      snprintf(msg, sizeof(msg), _("Lock count exceeded, remove lock for %s?"),
-              path);
-      if(retry && mutt_yesorno(msg, M_YES) == M_YES)
-      {
-       flags |= DL_FL_FORCE;
-       retry--;
-       mutt_clear_error ();
-       goto retry_lock;
+
+      snprintf (msg, sizeof (msg),
+                _("Lock count exceeded, remove lock for %s?"), path);
+      if (retry && mutt_yesorno (msg, M_YES) == M_YES) {
+        flags |= DL_FL_FORCE;
+        retry--;
+        mutt_clear_error ();
+        goto retry_lock;
       }
-    } 
-    else
-    {
-      mutt_error ( _("Can't dotlock %s.\n"), path);
+    }
+    else {
+      mutt_error (_("Can't dotlock %s.\n"), path);
     }
   }
   return (r == DL_EX_OK ? 0 : -1);
@@ -145,8 +141,8 @@ retry_lock:
 
 static int undotlock_file (const char *path, int fd)
 {
-  return (invoke_dotlock(path, fd, DL_FL_USEPRIV | DL_FL_UNLOCK, 0) == DL_EX_OK ? 
-         0 : -1);
+  return (invoke_dotlock (path, fd, DL_FL_USEPRIV | DL_FL_UNLOCK, 0) ==
+          DL_EX_OK ? 0 : -1);
 }
 
 #endif /* USE_DOTLOCK */
@@ -167,7 +163,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
 
 #ifdef USE_FCNTL
   struct flock lck;
-  
+
 
   memset (&lck, 0, sizeof (struct flock));
   lck.l_type = excl ? F_WRLCK : F_RDLCK;
@@ -175,27 +171,27 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
 
   count = 0;
   attempt = 0;
-  while (fcntl (fd, F_SETLK, &lck) == -1)
-  {
+  while (fcntl (fd, F_SETLK, &lck) == -1) {
     struct stat sb;
-    dprint(1,(debugfile, "mx_lock_file(): fcntl errno %d.\n", errno));
-    if (errno != EAGAIN && errno != EACCES)
-    {
+
+    dprint (1, (debugfile, "mx_lock_file(): fcntl errno %d.\n", errno));
+    if (errno != EAGAIN && errno != EACCES) {
       mutt_perror ("fcntl");
       return (-1);
     }
 
     if (fstat (fd, &sb) != 0)
-     sb.st_size = 0;
-    
+      sb.st_size = 0;
+
     if (count == 0)
       prev_sb = sb;
 
     /* only unlock file if it is unchanged */
-    if (prev_sb.st_size == sb.st_size && ++count >= (timeout?MAXLOCKATTEMPT:0))
-    {
+    if (prev_sb.st_size == sb.st_size
+        && ++count >= (timeout ? MAXLOCKATTEMPT : 0)) {
       if (timeout)
-       mutt_error _("Timeout exceeded while attempting fcntl lock!");
+        mutt_error _("Timeout exceeded while attempting fcntl lock!");
+
       return (-1);
     }
 
@@ -209,27 +205,27 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
 #ifdef USE_FLOCK
   count = 0;
   attempt = 0;
-  while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1)
-  {
+  while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1) {
     struct stat sb;
-    if (errno != EWOULDBLOCK)
-    {
+
+    if (errno != EWOULDBLOCK) {
       mutt_perror ("flock");
       r = -1;
       break;
     }
 
-    if (fstat(fd,&sb) != 0 )
-     sb.st_size=0;
-    
+    if (fstat (fd, &sb) != 0)
+      sb.st_size = 0;
+
     if (count == 0)
-      prev_sb=sb;
+      prev_sb = sb;
 
     /* only unlock file if it is unchanged */
-    if (prev_sb.st_size == sb.st_size && ++count >= (timeout?MAXLOCKATTEMPT:0))
-    {
+    if (prev_sb.st_size == sb.st_size
+        && ++count >= (timeout ? MAXLOCKATTEMPT : 0)) {
       if (timeout)
-       mutt_error _("Timeout exceeded while attempting flock lock!");
+        mutt_error _("Timeout exceeded while attempting flock lock!");
+
       r = -1;
       break;
     }
@@ -246,8 +242,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
     r = dotlock_file (path, fd, timeout);
 #endif /* USE_DOTLOCK */
 
-  if (r == -1)
-  {
+  if (r == -1) {
     /* release any other locks obtained in this routine */
 
 #ifdef USE_FCNTL
@@ -284,13 +279,14 @@ int mx_unlock_file (const char *path, int fd, int dot)
   if (dot)
     undotlock_file (path, fd);
 #endif
-  
+
   return 0;
 }
 
 void mx_unlink_empty (const char *path)
 {
   int fd;
+
 #ifndef USE_DOTLOCK
   struct stat sb;
 #endif
@@ -298,8 +294,7 @@ void mx_unlink_empty (const char *path)
   if ((fd = open (path, O_RDWR)) == -1)
     return;
 
-  if (mx_lock_file (path, fd, 1, 0, 1) == -1)
-  {
+  if (mx_lock_file (path, fd, 1, 0, 1) == -1) {
     close (fd);
     return;
   }
@@ -325,7 +320,7 @@ void mx_unlink_empty (const char *path)
 
 #ifdef USE_IMAP
 
-int mx_is_imap(const char *p)
+int mx_is_imap (const char *p)
 {
   url_scheme_t scheme;
 
@@ -384,7 +379,7 @@ int mx_get_magic (const char *path)
   FILE *f;
 
 #ifdef USE_IMAP
-  if(mx_is_imap(path))
+  if (mx_is_imap (path))
     return M_IMAP;
 #endif /* USE_IMAP */
 
@@ -398,15 +393,14 @@ int mx_get_magic (const char *path)
     return M_NNTP;
 #endif /* USE_NNTP */
 
-  if (stat (path, &st) == -1)
-  {
-    dprint (1, (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
-               path, strerror (errno), errno));
+  if (stat (path, &st) == -1) {
+    dprint (1,
+            (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
+             path, strerror (errno), errno));
     return (-1);
   }
 
-  if (S_ISDIR (st.st_mode))
-  {
+  if (S_ISDIR (st.st_mode)) {
     /* check for maildir-style mailbox */
 
     snprintf (tmp, sizeof (tmp), "%s/cur", path);
@@ -422,7 +416,7 @@ int mx_get_magic (const char *path)
     snprintf (tmp, sizeof (tmp), "%s/.xmhcache", path);
     if (access (tmp, F_OK) == 0)
       return (M_MH);
-    
+
     snprintf (tmp, sizeof (tmp), "%s/.mew_cache", path);
     if (access (tmp, F_OK) == 0)
       return (M_MH);
@@ -430,7 +424,7 @@ int mx_get_magic (const char *path)
     snprintf (tmp, sizeof (tmp), "%s/.mew-cache", path);
     if (access (tmp, F_OK) == 0)
       return (M_MH);
-    
+
     snprintf (tmp, sizeof (tmp), "%s/.sylpheed_cache", path);
     if (access (tmp, F_OK) == 0)
       return (M_MH);
@@ -445,16 +439,14 @@ int mx_get_magic (const char *path)
       return (M_MH);
 
   }
-  else if (st.st_size == 0)
-  {
+  else if (st.st_size == 0) {
     /* hard to tell what zero-length files are, so assume the default magic */
     if (DefaultMagic == M_MBOX || DefaultMagic == M_MMDF)
       return (DefaultMagic);
     else
       return (M_MBOX);
   }
-  else if ((f = fopen (path, "r")) != NULL)
-  {
+  else if ((f = fopen (path, "r")) != NULL) {
 #ifndef BUFFY_SIZE
     struct utimbuf times;
 #endif
@@ -475,10 +467,10 @@ int mx_get_magic (const char *path)
     utime (path, &times);
 #endif
   }
-  else
-  {
-    dprint (1, (debugfile, "mx_get_magic(): unable to open file %s for reading.\n",
-               path));
+  else {
+    dprint (1,
+            (debugfile,
+             "mx_get_magic(): unable to open file %s for reading.\n", path));
     mutt_perror (path);
     return (-1);
   }
@@ -513,7 +505,7 @@ int mx_set_magic (const char *s)
 /* mx_access: Wrapper for access, checks permissions on a given mailbox.
  *   We may be interested in using ACL-style flags at some point, currently
  *   we use the normal access() flags. */
-int mx_access (const charpath, int flags)
+int mx_access (const char *path, int flags)
 {
 #ifdef USE_IMAP
   if (mx_is_imap (path))
@@ -523,7 +515,7 @@ int mx_access (const char* path, int flags)
   return access (path, flags);
 }
 
-static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
+static int mx_open_mailbox_append (CONTEXT * ctx, int flags)
 {
   struct stat sb;
 
@@ -537,117 +529,103 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
   ctx->append = 1;
 
 #ifdef USE_IMAP
-  
-  if(mx_is_imap(ctx->path))  
+
+  if (mx_is_imap (ctx->path))
     return imap_open_mailbox_append (ctx);
 
 #endif
-  
-  if(stat(ctx->path, &sb) == 0)
-  {
+
+  if (stat (ctx->path, &sb) == 0) {
     ctx->magic = mx_get_magic (ctx->path);
-    
-    switch (ctx->magic)
-    {
-      case 0:
-       mutt_error (_("%s is not a mailbox."), ctx->path);
-       /* fall through */
-      case -1:
-       return (-1);
+
+    switch (ctx->magic) {
+    case 0:
+      mutt_error (_("%s is not a mailbox."), ctx->path);
+      /* fall through */
+    case -1:
+      return (-1);
     }
   }
-  else if (errno == ENOENT)
-  {
+  else if (errno == ENOENT) {
     ctx->magic = DefaultMagic;
 
-    if (ctx->magic == M_MH || ctx->magic == M_MAILDIR)
-    {
+    if (ctx->magic == M_MH || ctx->magic == M_MAILDIR) {
       char tmp[_POSIX_PATH_MAX];
 
-      if (mkdir (ctx->path, S_IRWXU))
-      {
-       mutt_perror (ctx->path);
-       return (-1);
+      if (mkdir (ctx->path, S_IRWXU)) {
+        mutt_perror (ctx->path);
+        return (-1);
       }
 
-      if (ctx->magic == M_MAILDIR)
-      {
-       snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
-       if (mkdir (tmp, S_IRWXU))
-       {
-         mutt_perror (tmp);
-         rmdir (ctx->path);
-         return (-1);
-       }
-
-       snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
-       if (mkdir (tmp, S_IRWXU))
-       {
-         mutt_perror (tmp);
-         snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
-         rmdir (tmp);
-         rmdir (ctx->path);
-         return (-1);
-       }
-       snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path);
-       if (mkdir (tmp, S_IRWXU))
-       {
-         mutt_perror (tmp);
-         snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
-         rmdir (tmp);
-         snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
-         rmdir (tmp);
-         rmdir (ctx->path);
-         return (-1);
-       }
+      if (ctx->magic == M_MAILDIR) {
+        snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
+        if (mkdir (tmp, S_IRWXU)) {
+          mutt_perror (tmp);
+          rmdir (ctx->path);
+          return (-1);
+        }
+
+        snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
+        if (mkdir (tmp, S_IRWXU)) {
+          mutt_perror (tmp);
+          snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
+          rmdir (tmp);
+          rmdir (ctx->path);
+          return (-1);
+        }
+        snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path);
+        if (mkdir (tmp, S_IRWXU)) {
+          mutt_perror (tmp);
+          snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
+          rmdir (tmp);
+          snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
+          rmdir (tmp);
+          rmdir (ctx->path);
+          return (-1);
+        }
       }
-      else
-      {
-       int i;
-
-       snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", ctx->path);
-       if ((i = creat (tmp, S_IRWXU)) == -1)
-       {
-         mutt_perror (tmp);
-         rmdir (ctx->path);
-         return (-1);
-       }
-       close (i);
+      else {
+        int i;
+
+        snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", ctx->path);
+        if ((i = creat (tmp, S_IRWXU)) == -1) {
+          mutt_perror (tmp);
+          rmdir (ctx->path);
+          return (-1);
+        }
+        close (i);
       }
     }
   }
-  else
-  {
+  else {
     mutt_perror (ctx->path);
     return (-1);
   }
 
-  switch (ctx->magic)
-  {
-    case M_MBOX:
-    case M_MMDF:
-    if ((ctx->fp = safe_fopen (ctx->path, flags & M_NEWFOLDER ? "w" : "a")) == NULL ||
-         mbox_lock_mailbox (ctx, 1, 1) != 0)
-      {
-       if (!ctx->fp)
-         mutt_perror (ctx->path);
-       else
-       {
-         mutt_error (_("Couldn't lock %s\n"), ctx->path);
-         safe_fclose (&ctx->fp);
-       }
-       return (-1);
+  switch (ctx->magic) {
+  case M_MBOX:
+  case M_MMDF:
+    if ((ctx->fp =
+         safe_fopen (ctx->path, flags & M_NEWFOLDER ? "w" : "a")) == NULL
+        || mbox_lock_mailbox (ctx, 1, 1) != 0) {
+      if (!ctx->fp)
+        mutt_perror (ctx->path);
+      else {
+        mutt_error (_("Couldn't lock %s\n"), ctx->path);
+        safe_fclose (&ctx->fp);
       }
-      fseek (ctx->fp, 0, 2);
-      break;
+      return (-1);
+    }
+    fseek (ctx->fp, 0, 2);
+    break;
 
-    case M_MH:
-    case M_MAILDIR:
-      /* nothing to do */
-      break;
+  case M_MH:
+  case M_MAILDIR:
+    /* nothing to do */
+    break;
 
-    default:
-      return (-1);
+  default:
+    return (-1);
   }
 
   return 0;
@@ -663,7 +641,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
  *             M_QUIET         only print error messages
  *     ctx     if non-null, context struct to use
  */
-CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
+CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx)
 {
   CONTEXT *ctx = pctx;
   int rc;
@@ -675,45 +653,42 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
 
   ctx->msgnotreadyet = -1;
   ctx->collapsed = 0;
-  
+
   if (flags & M_QUIET)
     ctx->quiet = 1;
   if (flags & M_READONLY)
     ctx->readonly = 1;
 
-  if (flags & (M_APPEND|M_NEWFOLDER))
-  {
-    if (mx_open_mailbox_append (ctx, flags) != 0)
-    {
+  if (flags & (M_APPEND | M_NEWFOLDER)) {
+    if (mx_open_mailbox_append (ctx, flags) != 0) {
       mx_fastclose_mailbox (ctx);
       if (!pctx)
-       FREE (&ctx);
+        FREE (&ctx);
       return NULL;
     }
     return ctx;
   }
 
   ctx->magic = mx_get_magic (path);
-  
+
 #ifdef USE_COMPRESSED
   if (ctx->magic == M_COMPRESSED)
     mutt_open_read_compressed (ctx);
 #endif
 
-  if(ctx->magic == 0)
+  if (ctx->magic == 0)
     mutt_error (_("%s is not a mailbox."), path);
 
-  if(ctx->magic == -1)
-    mutt_perror(path);
-  
-  if(ctx->magic <= 0)
-  {
+  if (ctx->magic == -1)
+    mutt_perror (path);
+
+  if (ctx->magic <= 0) {
     mx_fastclose_mailbox (ctx);
     if (!pctx)
       FREE (&ctx);
     return (NULL);
   }
-  
+
   /* if the user has a `push' command in their .muttrc, or in a folder-hook,
    * it will cause the progress messages not to be displayed because
    * mutt_refresh() will think we are in the middle of a macro.  so set a
@@ -724,50 +699,47 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
   if (!ctx->quiet)
     mutt_message (_("Reading %s..."), ctx->path);
 
-  switch (ctx->magic)
-  {
-    case M_MH:
-      rc = mh_read_dir (ctx, NULL);
-      break;
+  switch (ctx->magic) {
+  case M_MH:
+    rc = mh_read_dir (ctx, NULL);
+    break;
 
-    case M_MAILDIR:
-      rc = maildir_read_dir (ctx);
-      break;
+  case M_MAILDIR:
+    rc = maildir_read_dir (ctx);
+    break;
 
-    case M_MMDF:
-    case M_MBOX:
-      rc = mbox_open_mailbox (ctx);
-      break;
+  case M_MMDF:
+  case M_MBOX:
+    rc = mbox_open_mailbox (ctx);
+    break;
 
 #ifdef USE_IMAP
-    case M_IMAP:
-      rc = imap_open_mailbox (ctx);
-      break;
+  case M_IMAP:
+    rc = imap_open_mailbox (ctx);
+    break;
 #endif /* USE_IMAP */
 
 #ifdef USE_POP
-    case M_POP:
-      rc = pop_open_mailbox (ctx);
-      break;
+  case M_POP:
+    rc = pop_open_mailbox (ctx);
+    break;
 #endif /* USE_POP */
 
 #ifdef USE_NNTP
-    case M_NNTP:
-      rc = nntp_open_mailbox (ctx);
-      break;
+  case M_NNTP:
+    rc = nntp_open_mailbox (ctx);
+    break;
 #endif /* USE_NNTP */
 
-    default:
-      rc = -1;
-      break;
+  default:
+    rc = -1;
+    break;
   }
 
-  if (rc == 0)
-  {
-    if ((flags & M_NOSORT) == 0)
-    {
+  if (rc == 0) {
+    if ((flags & M_NOSORT) == 0) {
       /* avoid unnecessary work since the mailbox is completely unthreaded
-        to begin with */
+         to begin with */
       unset_option (OPTSORTSUBTHREADS);
       unset_option (OPTNEEDRESCORE);
       mutt_sort_headers (ctx, 1);
@@ -775,8 +747,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
     if (!ctx->quiet)
       mutt_clear_error ();
   }
-  else
-  {
+  else {
     mx_fastclose_mailbox (ctx);
     if (!pctx)
       FREE (&ctx);
@@ -787,13 +758,13 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
 }
 
 /* free up memory associated with the mailbox context */
-void mx_fastclose_mailbox (CONTEXT *ctx)
+void mx_fastclose_mailbox (CONTEXT * ctx)
 {
   int i;
 
-  if(!ctx) 
+  if (!ctx)
     return;
-  
+
 #ifdef USE_IMAP
   if (ctx->magic == M_IMAP)
     imap_close_mailbox (ctx);
@@ -821,14 +792,14 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
 #endif
   FREE (&ctx->path);
   FREE (&ctx->pattern);
-  if (ctx->limit_pattern) 
+  if (ctx->limit_pattern)
     mutt_pattern_free (&ctx->limit_pattern);
   safe_fclose (&ctx->fp);
   memset (ctx, 0, sizeof (CONTEXT));
 }
 
 /* save changes to disk */
-static int sync_mailbox (CONTEXT *ctx, int *index_hint)
+static int sync_mailbox (CONTEXT * ctx, int *index_hint)
 {
 #ifdef BUFFY_SIZE
   BUFFY *tmp = NULL;
@@ -838,46 +809,45 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint)
   if (!ctx->quiet)
     mutt_message (_("Writing %s..."), ctx->path);
 
-  switch (ctx->magic)
-  {
-    case M_MBOX:
-    case M_MMDF:
-      rc = mbox_sync_mailbox (ctx, index_hint);
+  switch (ctx->magic) {
+  case M_MBOX:
+  case M_MMDF:
+    rc = mbox_sync_mailbox (ctx, index_hint);
 #ifdef BUFFY_SIZE
-      tmp = mutt_find_mailbox (ctx->path);
+    tmp = mutt_find_mailbox (ctx->path);
 #endif
-      break;
-      
-    case M_MH:
-    case M_MAILDIR:
-      rc = mh_sync_mailbox (ctx, index_hint);
-      break;
-      
+    break;
+
+  case M_MH:
+  case M_MAILDIR:
+    rc = mh_sync_mailbox (ctx, index_hint);
+    break;
+
 #ifdef USE_IMAP
-    case M_IMAP:
-      /* extra argument means EXPUNGE */
-      rc = imap_sync_mailbox (ctx, 1, index_hint);
-      break;
+  case M_IMAP:
+    /* extra argument means EXPUNGE */
+    rc = imap_sync_mailbox (ctx, 1, index_hint);
+    break;
 #endif /* USE_IMAP */
 
 #ifdef USE_POP
-    case M_POP:
-      rc = pop_sync_mailbox (ctx, index_hint);
-      break;
+  case M_POP:
+    rc = pop_sync_mailbox (ctx, index_hint);
+    break;
 #endif /* USE_POP */
 
 #ifdef USE_NNTP
-    case M_NNTP:
-      rc = nntp_sync_mailbox (ctx);
-      break;
+  case M_NNTP:
+    rc = nntp_sync_mailbox (ctx);
+    break;
 #endif /* USE_NNTP */
   }
 
 #if 0
   if (!ctx->quiet && !ctx->shutup && rc == -1)
-    mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path);
+    mutt_error (_("Could not synchronize mailbox %s!"), ctx->path);
 #endif
-  
+
 #ifdef BUFFY_SIZE
   if (tmp && tmp->new == 0)
     mutt_update_mailbox (tmp);
@@ -892,55 +862,53 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint)
 }
 
 /* move deleted mails to the trash folder */
-static int trash_append (CONTEXT *ctx)
+static int trash_append (CONTEXT * ctx)
 {
-    CONTEXT *ctx_trash;
-    int i = 0;
-    struct stat st, stc;
+  CONTEXT *ctx_trash;
+  int i = 0;
+  struct stat st, stc;
 
-    if (!TrashPath || !ctx->deleted ||
-       (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
-      return 0;
+  if (!TrashPath || !ctx->deleted ||
+      (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
+    return 0;
 
-    for (;i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
-                               ctx->hdrs[i]->appended); i++);
-    if (i == ctx->msgcount)
-      return 0; /* nothing to be done */
+  for (; i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
+                               ctx->hdrs[i]->appended); i++);
+  if (i == ctx->msgcount)
+    return 0;                   /* nothing to be done */
 
-    if (mutt_save_confirm (TrashPath, &st) != 0)
-    {
-      mutt_error _("message(s) not deleted");
-      return -1;
-    }
+  if (mutt_save_confirm (TrashPath, &st) != 0) {
+    mutt_error _("message(s) not deleted");
 
-    if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
-       && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
-      return 0;  /* we are in the trash folder: simple sync */
+    return -1;
+  }
 
-    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
-    {
-      for (i = 0 ; i < ctx->msgcount ; i++)
-       if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
-           && !ctx->hdrs[i]->purged
-           && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
-         {
-           mx_close_mailbox (ctx_trash, NULL);
-           return -1;
-         }
-
-      mx_close_mailbox (ctx_trash, NULL);
-    }
-    else
-    {
-      mutt_error _("Can't open trash folder");
-      return -1;
-    }
+  if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
+      && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
+    return 0;                   /* we are in the trash folder: simple sync */
 
-    return 0;
+  if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) {
+    for (i = 0; i < ctx->msgcount; i++)
+      if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
+          && !ctx->hdrs[i]->purged
+          && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) {
+        mx_close_mailbox (ctx_trash, NULL);
+        return -1;
+      }
+
+    mx_close_mailbox (ctx_trash, NULL);
+  }
+  else {
+    mutt_error _("Can't open trash folder");
+
+    return -1;
+  }
+
+  return 0;
 }
 
 /* save changes and close mailbox */
-int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
+int mx_close_mailbox (CONTEXT * ctx, int *index_hint)
 {
   int i, move_messages = 0, purge = 1, read_msgs = 0;
   int check;
@@ -949,13 +917,13 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
   char mbox[_POSIX_PATH_MAX];
   char buf[SHORT_STRING];
 
-  if (!ctx) return 0;
+  if (!ctx)
+    return 0;
 
   ctx->closing = 1;
 
 #ifdef USE_NNTP
-  if (ctx->magic == M_NNTP)
-  {
+  if (ctx->magic == M_NNTP) {
     int ret;
 
     ret = nntp_close_mailbox (ctx);
@@ -963,15 +931,13 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     return ret;
   }
 #endif
-  if (ctx->readonly || ctx->dontwrite)
-  {
+  if (ctx->readonly || ctx->dontwrite) {
     /* mailbox is readonly or we don't want to write */
     mx_fastclose_mailbox (ctx);
     return 0;
   }
 
-  if (ctx->append)
-  {
+  if (ctx->append) {
     /* mailbox was opened in write-mode */
     if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
       mbox_close_mailbox (ctx);
@@ -980,36 +946,30 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     return 0;
   }
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
-    if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
+  for (i = 0; i < ctx->msgcount; i++) {
+    if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read
         && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
       read_msgs++;
   }
 
-  if (read_msgs && quadoption (OPT_MOVE) != M_NO)
-  {
+  if (read_msgs && quadoption (OPT_MOVE) != M_NO) {
     char *p;
 
-    if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path)))
-    {
+    if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path))) {
       isSpool = 1;
       strfcpy (mbox, p, sizeof (mbox));
     }
-    else
-    {
-      strfcpy (mbox, NONULL(Inbox), sizeof (mbox));
+    else {
+      strfcpy (mbox, NONULL (Inbox), sizeof (mbox));
       isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
     }
     mutt_expand_path (mbox, sizeof (mbox));
 
-    if (isSpool)
-    {
+    if (isSpool) {
       snprintf (buf, sizeof (buf), _("Move read messages to %s?"), mbox);
-      if ((move_messages = query_quadoption (OPT_MOVE, buf)) == -1)
-      {
-       ctx->closing = 0;
-       return (-1);
+      if ((move_messages = query_quadoption (OPT_MOVE, buf)) == -1) {
+        ctx->closing = 0;
+        return (-1);
       }
     }
   }
@@ -1018,13 +978,11 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
    * There is no point in asking whether or not to purge if we are
    * just marking messages as "trash".
    */
-  if (ctx->deleted && !(ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
-  {
+  if (ctx->deleted && !(ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
     snprintf (buf, sizeof (buf), ctx->deleted == 1
-            ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"),
-             ctx->deleted);
-    if ((purge = query_quadoption (OPT_DELETE, buf)) < 0)
-    {
+              ? _("Purge %d deleted message?") :
+              _("Purge %d deleted messages?"), ctx->deleted);
+    if ((purge = query_quadoption (OPT_DELETE, buf)) < 0) {
       ctx->closing = 0;
       return (-1);
     }
@@ -1034,96 +992,84 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
   /* IMAP servers manage the OLD flag themselves */
   if (ctx->magic != M_IMAP)
 #endif
-  if (option (OPTMARKOLD))
-  {
-    for (i = 0; i < ctx->msgcount; i++)
-    {
-      if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->old)
-       mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, 1);
+    if (option (OPTMARKOLD)) {
+      for (i = 0; i < ctx->msgcount; i++) {
+        if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->old)
+          mutt_set_flag (ctx, ctx->hdrs[i], M_OLD, 1);
+      }
     }
-  }
 
-  if (move_messages)
-  {
+  if (move_messages) {
     mutt_message (_("Moving read messages to %s..."), mbox);
 
 #ifdef USE_IMAP
     /* try to use server-side copy first */
     i = 1;
-    
-    if (ctx->magic == M_IMAP && mx_is_imap (mbox))
-    {
+
+    if (ctx->magic == M_IMAP && mx_is_imap (mbox)) {
       /* tag messages for moving, and clear old tags, if any */
       for (i = 0; i < ctx->msgcount; i++)
-       if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
-            && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) 
-         ctx->hdrs[i]->tagged = 1;
-       else
-         ctx->hdrs[i]->tagged = 0;
-      
+        if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
+            && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
+          ctx->hdrs[i]->tagged = 1;
+        else
+          ctx->hdrs[i]->tagged = 0;
+
       i = imap_copy_messages (ctx, NULL, mbox, 1);
     }
-    
-    if (i == 0) /* success */
+
+    if (i == 0)                 /* success */
       mutt_clear_error ();
-    else if (i == -1) /* horrible error, bail */
-    {
-      ctx->closing=0;
+    else if (i == -1) {         /* horrible error, bail */
+      ctx->closing = 0;
       return -1;
     }
-    else /* use regular append-copy mode */
+    else                        /* use regular append-copy mode */
 #endif
     {
-      if (mx_open_mailbox (mbox, M_APPEND, &f) == NULL)
-      {
-       ctx->closing = 0;
-       return -1;
+      if (mx_open_mailbox (mbox, M_APPEND, &f) == NULL) {
+        ctx->closing = 0;
+        return -1;
       }
 
-      for (i = 0; i < ctx->msgcount; i++)
-      {
-       if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
-            && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
-        {
-         if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0)
-         {
-           mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
-           mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
-         }
-         else
-         {
-           mx_close_mailbox (&f, NULL);
-           ctx->closing = 0;
-           return -1;
-         }
-       }
+      for (i = 0; i < ctx->msgcount; i++) {
+        if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
+            && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) {
+          if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) ==
+              0) {
+            mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
+            mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
+          }
+          else {
+            mx_close_mailbox (&f, NULL);
+            ctx->closing = 0;
+            return -1;
+          }
+        }
       }
-    
+
       mx_close_mailbox (&f, NULL);
     }
-    
+
   }
-  else if (!ctx->changed && ctx->deleted == 0)
-  {
+  else if (!ctx->changed && ctx->deleted == 0) {
     mutt_message _("Mailbox is unchanged.");
+
     mx_fastclose_mailbox (ctx);
     return 0;
   }
-  
+
   /* copy mails to the trash before expunging */
   if (purge && ctx->deleted)
-    if (trash_append (ctx) != 0)
-    {
+    if (trash_append (ctx) != 0) {
       ctx->closing = 0;
       return -1;
     }
 
 #ifdef USE_IMAP
   /* allow IMAP to preserve the deleted flag across sessions */
-  if (ctx->magic == M_IMAP)
-  {
-    if ((check = imap_sync_mailbox (ctx, purge, index_hint)) != 0)
-    {
+  if (ctx->magic == M_IMAP) {
+    if ((check = imap_sync_mailbox (ctx, purge, index_hint)) != 0) {
       ctx->closing = 0;
       return check;
     }
@@ -1131,33 +1077,30 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
   else
 #endif
   {
-    if (!purge)
-    {
+    if (!purge) {
       for (i = 0; i < ctx->msgcount; i++)
         ctx->hdrs[i]->deleted = 0;
       ctx->deleted = 0;
     }
 
-    if (ctx->changed || ctx->deleted)
-    {
-      if ((check = sync_mailbox (ctx, index_hint)) != 0)
-      {
-       ctx->closing = 0;
-       return check;
+    if (ctx->changed || ctx->deleted) {
+      if ((check = sync_mailbox (ctx, index_hint)) != 0) {
+        ctx->closing = 0;
+        return check;
       }
     }
   }
 
   if (move_messages)
-     mutt_message (_("%d kept, %d moved, %d deleted."),
-       ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted);
+    mutt_message (_("%d kept, %d moved, %d deleted."),
+                  ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted);
   else
     mutt_message (_("%d kept, %d deleted."),
-      ctx->msgcount - ctx->deleted, ctx->deleted);
+                  ctx->msgcount - ctx->deleted, ctx->deleted);
 
   if (ctx->msgcount == ctx->deleted &&
       (ctx->magic == M_MMDF || ctx->magic == M_MBOX) &&
-      !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY))
+      !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY))
     mx_unlink_empty (ctx->path);
 
 #ifdef USE_COMPRESSED
@@ -1173,10 +1116,10 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
 
 /* update a Context structure's internal tables. */
 
-void mx_update_tables(CONTEXT *ctx, int committing)
+void mx_update_tables (CONTEXT * ctx, int committing)
 {
   int i, j;
-  
+
   /* update memory to reflect the new state of the mailbox */
   ctx->vcount = 0;
   ctx->vsize = 0;
@@ -1187,61 +1130,59 @@ void mx_update_tables(CONTEXT *ctx, int committing)
   ctx->changed = 0;
   ctx->flagged = 0;
 #define this_body ctx->hdrs[j]->content
-  for (i = 0, j = 0; i < ctx->msgcount; i++)
-  {
-    if ((committing && (!ctx->hdrs[i]->deleted || 
-                       (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))) ||
-       (!committing && ctx->hdrs[i]->active))
-    {
-      if (i != j)
-      {
-       ctx->hdrs[j] = ctx->hdrs[i];
-       ctx->hdrs[i] = NULL;
+  for (i = 0, j = 0; i < ctx->msgcount; i++) {
+    if ((committing && (!ctx->hdrs[i]->deleted ||
+                        (ctx->magic == M_MAILDIR
+                         && option (OPTMAILDIRTRASH)))) || (!committing
+                                                            && ctx->hdrs[i]->
+                                                            active)) {
+      if (i != j) {
+        ctx->hdrs[j] = ctx->hdrs[i];
+        ctx->hdrs[i] = NULL;
       }
       ctx->hdrs[j]->msgno = j;
-      if (ctx->hdrs[j]->virtual != -1)
-      {
-       ctx->v2r[ctx->vcount] = j;
-       ctx->hdrs[j]->virtual = ctx->vcount++;
-       ctx->vsize += this_body->length + this_body->offset -
-         this_body->hdr_offset;
+      if (ctx->hdrs[j]->virtual != -1) {
+        ctx->v2r[ctx->vcount] = j;
+        ctx->hdrs[j]->virtual = ctx->vcount++;
+        ctx->vsize += this_body->length + this_body->offset -
+          this_body->hdr_offset;
       }
 
       if (committing)
-       ctx->hdrs[j]->changed = 0;
+        ctx->hdrs[j]->changed = 0;
       else if (ctx->hdrs[j]->changed)
-       ctx->changed++;
-      
-      if (!committing || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
-      {
-       if (ctx->hdrs[j]->deleted)
-         ctx->deleted++;
+        ctx->changed++;
+
+      if (!committing
+          || (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) {
+        if (ctx->hdrs[j]->deleted)
+          ctx->deleted++;
       }
 
       if (ctx->hdrs[j]->tagged)
-       ctx->tagged++;
+        ctx->tagged++;
       if (ctx->hdrs[j]->flagged)
-       ctx->flagged++;
-      if (!ctx->hdrs[j]->read)
-      { 
-       ctx->unread++;
-       if (!ctx->hdrs[j]->old)
-         ctx->new++;
-      } 
+        ctx->flagged++;
+      if (!ctx->hdrs[j]->read) {
+        ctx->unread++;
+        if (!ctx->hdrs[j]->old)
+          ctx->new++;
+      }
 
       j++;
     }
-    else
-    {
+    else {
       if (ctx->magic == M_MH || ctx->magic == M_MAILDIR)
-       ctx->size -= (ctx->hdrs[i]->content->length +
-                     ctx->hdrs[i]->content->offset -
-                     ctx->hdrs[i]->content->hdr_offset);
+        ctx->size -= (ctx->hdrs[i]->content->length +
+                      ctx->hdrs[i]->content->offset -
+                      ctx->hdrs[i]->content->hdr_offset);
       /* remove message from the hash tables */
       if (ctx->subj_hash && ctx->hdrs[i]->env->real_subj)
-       hash_delete (ctx->subj_hash, ctx->hdrs[i]->env->real_subj, ctx->hdrs[i], NULL);
+        hash_delete (ctx->subj_hash, ctx->hdrs[i]->env->real_subj,
+                     ctx->hdrs[i], NULL);
       if (ctx->id_hash && ctx->hdrs[i]->env->message_id)
-       hash_delete (ctx->id_hash, ctx->hdrs[i]->env->message_id, ctx->hdrs[i], NULL);
+        hash_delete (ctx->id_hash, ctx->hdrs[i]->env->message_id,
+                     ctx->hdrs[i], NULL);
       mutt_free_header (&ctx->hdrs[i]);
     }
   }
@@ -1256,61 +1197,60 @@ void mx_update_tables(CONTEXT *ctx, int committing)
  *     0               success
  *     -1              error
  */
-int mx_sync_mailbox (CONTEXT *ctx, int *index_hint)
+int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
 {
   int rc, i;
   int purge = 1;
   int msgcount, deleted;
 
-  if (ctx->dontwrite)
-  {
+  if (ctx->dontwrite) {
     char buf[STRING], tmp[STRING];
-    if (km_expand_key (buf, sizeof(buf),
+
+    if (km_expand_key (buf, sizeof (buf),
                        km_find_func (MENU_MAIN, OP_TOGGLE_WRITE)))
-      snprintf (tmp, sizeof(tmp), _(" Press '%s' to toggle write"), buf);
+      snprintf (tmp, sizeof (tmp), _(" Press '%s' to toggle write"), buf);
     else
-      strfcpy (tmp, _("Use 'toggle-write' to re-enable write!"), sizeof(tmp));
+      strfcpy (tmp, _("Use 'toggle-write' to re-enable write!"),
+               sizeof (tmp));
 
     mutt_error (_("Mailbox is marked unwritable. %s"), tmp);
     return -1;
   }
-  else if (ctx->readonly)
-  {
+  else if (ctx->readonly) {
     mutt_error _("Mailbox is read-only.");
+
     return -1;
   }
 
-  if (!ctx->changed && !ctx->deleted)
-  {
+  if (!ctx->changed && !ctx->deleted) {
     mutt_message _("Mailbox is unchanged.");
+
     return (0);
   }
 
-  if (ctx->deleted)
-  {
+  if (ctx->deleted) {
     char buf[SHORT_STRING];
 
     snprintf (buf, sizeof (buf), ctx->deleted == 1
-            ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"),
-             ctx->deleted);
+              ? _("Purge %d deleted message?") :
+              _("Purge %d deleted messages?"), ctx->deleted);
     if ((purge = query_quadoption (OPT_DELETE, buf)) < 0)
       return (-1);
-    else if (purge == M_NO)
-    {
+    else if (purge == M_NO) {
       if (!ctx->changed)
-       return 0; /* nothing to do! */
+        return 0;               /* nothing to do! */
 #ifdef USE_IMAP
       /* let IMAP servers hold on to D flags */
       if (ctx->magic != M_IMAP)
 #endif
       {
-        for (i = 0 ; i < ctx->msgcount ; i++)
+        for (i = 0; i < ctx->msgcount; i++)
           ctx->hdrs[i]->deleted = 0;
         ctx->deleted = 0;
       }
     }
     else if (ctx->last_tag && ctx->last_tag->deleted)
-      ctx->last_tag = NULL; /* reset last tagged msg now useless */
+      ctx->last_tag = NULL;     /* reset last tagged msg now useless */
   }
 
   /* really only for IMAP - imap_sync_mailbox results in a call to
@@ -1318,11 +1258,10 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint)
   msgcount = ctx->msgcount;
   deleted = ctx->deleted;
 
-  if (purge && ctx->deleted)
-  {
+  if (purge && ctx->deleted) {
     if (trash_append (ctx) == -1)
       return -1;
-  } 
+  }
 
 #ifdef USE_IMAP
   if (ctx->magic == M_IMAP)
@@ -1330,22 +1269,20 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint)
   else
 #endif
     rc = sync_mailbox (ctx, index_hint);
-  if (rc == 0)
-  {
+  if (rc == 0) {
 #ifdef USE_IMAP
     if (ctx->magic == M_IMAP && !purge)
-      mutt_message _("Mailbox checkpointed.");
+      mutt_message (_("Mailbox checkpointed."));
+
     else
 #endif
-    mutt_message (_("%d kept, %d deleted."), msgcount - deleted,
-      deleted);
+      mutt_message (_("%d kept, %d deleted."), msgcount - deleted, deleted);
 
     mutt_sleep (0);
-    
+
     if (ctx->msgcount == ctx->deleted &&
-       (ctx->magic == M_MBOX || ctx->magic == M_MMDF) &&
-       !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY))
-    {
+        (ctx->magic == M_MBOX || ctx->magic == M_MMDF) &&
+        !mutt_is_spool (ctx->path) && !option (OPTSAVEEMPTY)) {
       unlink (ctx->path);
       mx_fastclose_mailbox (ctx);
       return 0;
@@ -1358,15 +1295,14 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint)
      * MH and maildir are safe.  mbox-style seems to need re-sorting,
      * at least with the new threading code.
      */
-    if (purge || (ctx->magic != M_MAILDIR && ctx->magic != M_MH))
-    {
+    if (purge || (ctx->magic != M_MAILDIR && ctx->magic != M_MH)) {
 #ifdef USE_IMAP
       /* IMAP does this automatically after handling EXPUNGE */
       if (ctx->magic != M_IMAP)
 #endif
       {
-       mx_update_tables (ctx, 1);
-       mutt_sort_headers (ctx, 1); /* rethread from scratch */
+        mx_update_tables (ctx, 1);
+        mutt_sort_headers (ctx, 1);     /* rethread from scratch */
       }
     }
   }
@@ -1377,21 +1313,21 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint)
 
 /* {maildir,mh}_open_new_message are in mh.c. */
 
-int mbox_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr)
+int mbox_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
 {
   msg->fp = dest->fp;
   return 0;
 }
 
 #ifdef USE_IMAP
-int imap_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr)
+int imap_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
 {
   char tmp[_POSIX_PATH_MAX];
 
-  mutt_mktemp(tmp);
+  mutt_mktemp (tmp);
   if ((msg->fp = safe_fopen (tmp, "w")) == NULL)
     return (-1);
-  msg->path = safe_strdup(tmp);
+  msg->path = safe_strdup (tmp);
   return 0;
 }
 #endif
@@ -1401,69 +1337,66 @@ int imap_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr)
  *     hdr     message being copied (required for maildir support, because
  *             the filename depends on the message flags)
  */
-MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags)
+MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
 {
   MESSAGE *msg;
   int (*func) (MESSAGE *, CONTEXT *, HEADER *);
   ADDRESS *p = NULL;
 
-  switch (dest->magic)
-  {
-    case M_MMDF:
-    case M_MBOX:
-      func = mbox_open_new_message;
-      break;
-    case M_MAILDIR:
-      func = maildir_open_new_message;
-      break;
-    case M_MH:
-      func = mh_open_new_message;
-      break;
+  switch (dest->magic) {
+  case M_MMDF:
+  case M_MBOX:
+    func = mbox_open_new_message;
+    break;
+  case M_MAILDIR:
+    func = maildir_open_new_message;
+    break;
+  case M_MH:
+    func = mh_open_new_message;
+    break;
 #ifdef USE_IMAP
-    case M_IMAP:
-      func = imap_open_new_message;
-      break;
+  case M_IMAP:
+    func = imap_open_new_message;
+    break;
 #endif
-    default:
-      dprint (1, (debugfile, "mx_open_new_message(): function unimplemented for mailbox type %d.\n",
-                 dest->magic));
-      return (NULL);
+  default:
+    dprint (1,
+            (debugfile,
+             "mx_open_new_message(): function unimplemented for mailbox type %d.\n",
+             dest->magic));
+    return (NULL);
   }
 
   msg = safe_calloc (1, sizeof (MESSAGE));
   msg->magic = dest->magic;
   msg->write = 1;
 
-  if (hdr)
-  {
+  if (hdr) {
     msg->flags.flagged = hdr->flagged;
     msg->flags.replied = hdr->replied;
-    msg->flags.read    = hdr->read;
+    msg->flags.read = hdr->read;
     msg->received = hdr->received;
   }
 
-  if(msg->received == 0)
-    time(&msg->received);
-  
-  if (func (msg, dest, hdr) == 0)
-  {
+  if (msg->received == 0)
+    time (&msg->received);
+
+  if (func (msg, dest, hdr) == 0) {
     if (dest->magic == M_MMDF)
       fputs (MMDF_SEP, msg->fp);
 
-    if ((msg->magic == M_MBOX || msg->magic ==  M_MMDF) &&
-       flags & M_ADD_FROM)
-    {
-      if (hdr)
-      {
-       if (hdr->env->return_path)
-         p = hdr->env->return_path;
-       else if (hdr->env->sender)
-         p = hdr->env->sender;
-       else
-         p = hdr->env->from;
+    if ((msg->magic == M_MBOX || msg->magic == M_MMDF) && flags & M_ADD_FROM) {
+      if (hdr) {
+        if (hdr->env->return_path)
+          p = hdr->env->return_path;
+        else if (hdr->env->sender)
+          p = hdr->env->sender;
+        else
+          p = hdr->env->from;
       }
 
-      fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(Username), ctime (&msg->received));
+      fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL (Username),
+               ctime (&msg->received));
     }
   }
   else
@@ -1473,7 +1406,7 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags)
 }
 
 /* check for new mail */
-int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock)
+int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock)
 {
   int rc;
 
@@ -1482,54 +1415,50 @@ int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock)
     return mutt_check_mailbox_compressed (ctx);
 #endif
 
-  if (ctx)
-  {
-    if (ctx->locked) lock = 0;
+  if (ctx) {
+    if (ctx->locked)
+      lock = 0;
 
-    switch (ctx->magic)
-    {
-      case M_MBOX:
-      case M_MMDF:
-
-       if (lock)
-       {
-         mutt_block_signals ();
-         if (mbox_lock_mailbox (ctx, 0, 0) == -1)
-         {
-           mutt_unblock_signals ();
-           return M_LOCKED;
-         }
-       }
-       
-       rc = mbox_check_mailbox (ctx, index_hint);
-
-       if (lock)
-       {
-         mutt_unblock_signals ();
-         mbox_unlock_mailbox (ctx);
-       }
-       
-       return rc;
-
-
-      case M_MH:
-       return (mh_check_mailbox (ctx, index_hint));
-      case M_MAILDIR:
-       return (maildir_check_mailbox (ctx, index_hint));
+    switch (ctx->magic) {
+    case M_MBOX:
+    case M_MMDF:
+
+      if (lock) {
+        mutt_block_signals ();
+        if (mbox_lock_mailbox (ctx, 0, 0) == -1) {
+          mutt_unblock_signals ();
+          return M_LOCKED;
+        }
+      }
+
+      rc = mbox_check_mailbox (ctx, index_hint);
+
+      if (lock) {
+        mutt_unblock_signals ();
+        mbox_unlock_mailbox (ctx);
+      }
+
+      return rc;
+
+
+    case M_MH:
+      return (mh_check_mailbox (ctx, index_hint));
+    case M_MAILDIR:
+      return (maildir_check_mailbox (ctx, index_hint));
 
 #ifdef USE_IMAP
-      case M_IMAP:
-       return (imap_check_mailbox (ctx, index_hint, 0));
+    case M_IMAP:
+      return (imap_check_mailbox (ctx, index_hint, 0));
 #endif /* USE_IMAP */
 
 #ifdef USE_POP
-      case M_POP:
-       return (pop_check_mailbox (ctx, index_hint));
+    case M_POP:
+      return (pop_check_mailbox (ctx, index_hint));
 #endif /* USE_POP */
 
 #ifdef USE_NNTP
-      case M_NNTP:
-       return (nntp_check_mailbox (ctx));
+    case M_NNTP:
+      return (nntp_check_mailbox (ctx));
 #endif /* USE_NNTP */
     }
   }
@@ -1539,138 +1468,139 @@ int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock)
 }
 
 /* return a stream pointer for a message */
-MESSAGE *mx_open_message (CONTEXT *ctx, int msgno)
+MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
 {
   MESSAGE *msg;
-  
+
   msg = safe_calloc (1, sizeof (MESSAGE));
-  switch (msg->magic = ctx->magic)
-  {
-    case M_MBOX:
-    case M_MMDF:
-      msg->fp = ctx->fp;
-      break;
+  switch (msg->magic = ctx->magic) {
+  case M_MBOX:
+  case M_MMDF:
+    msg->fp = ctx->fp;
+    break;
 
-    case M_MH:
-    case M_MAILDIR:
+  case M_MH:
+  case M_MAILDIR:
     {
       HEADER *cur = ctx->hdrs[msgno];
       char path[_POSIX_PATH_MAX];
-      
+
       snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path);
-      
+
       if ((msg->fp = fopen (path, "r")) == NULL && errno == ENOENT &&
-         ctx->magic == M_MAILDIR)
-       msg->fp = maildir_open_find_message (ctx->path, cur->path);
-      
-      if (msg->fp == NULL)
-      {
-       mutt_perror (path);
-       dprint (1, (debugfile, "mx_open_message: fopen: %s: %s (errno %d).\n",
-                   path, strerror (errno), errno));
-       FREE (&msg);
+          ctx->magic == M_MAILDIR)
+        msg->fp = maildir_open_find_message (ctx->path, cur->path);
+
+      if (msg->fp == NULL) {
+        mutt_perror (path);
+        dprint (1, (debugfile, "mx_open_message: fopen: %s: %s (errno %d).\n",
+                    path, strerror (errno), errno));
+        FREE (&msg);
       }
     }
     break;
-    
+
 #ifdef USE_IMAP
-    case M_IMAP:
+  case M_IMAP:
     {
       if (imap_fetch_message (msg, ctx, msgno) != 0)
-       FREE (&msg);
+        FREE (&msg);
       break;
     }
 #endif /* USE_IMAP */
 
 #ifdef USE_POP
-    case M_POP:
+  case M_POP:
     {
       if (pop_fetch_message (msg, ctx, msgno) != 0)
-       FREE (&msg);
+        FREE (&msg);
       break;
     }
 #endif /* USE_POP */
 
 #ifdef USE_NNTP
-    case M_NNTP:
+  case M_NNTP:
     {
       if (nntp_fetch_message (msg, ctx, msgno) != 0)
-       FREE (&msg);
+        FREE (&msg);
       break;
     }
 #endif /* USE_NNTP */
 
-    default:
-      dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic));
-      FREE (&msg);
-      break;
+  default:
+    dprint (1,
+            (debugfile,
+             "mx_open_message(): function not implemented for mailbox type %d.\n",
+             ctx->magic));
+    FREE (&msg);
+    break;
   }
   return (msg);
 }
 
 /* commit a message to a folder */
 
-int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
+int mx_commit_message (MESSAGE * msg, CONTEXT * ctx)
 {
   int r = 0;
 
-  if (!(msg->write && ctx->append))
-  {
-    dprint (1, (debugfile, "mx_commit_message(): msg->write = %d, ctx->append = %d\n",
-               msg->write, ctx->append));
+  if (!(msg->write && ctx->append)) {
+    dprint (1,
+            (debugfile,
+             "mx_commit_message(): msg->write = %d, ctx->append = %d\n",
+             msg->write, ctx->append));
     return -1;
   }
 
-  switch (msg->magic)
-  {
-    case M_MMDF:
+  switch (msg->magic) {
+  case M_MMDF:
     {
       if (fputs (MMDF_SEP, msg->fp) == EOF)
-       r = -1;
+        r = -1;
       break;
     }
-    
-    case M_MBOX:
+
+  case M_MBOX:
     {
       if (fputc ('\n', msg->fp) == EOF)
-       r = -1;
+        r = -1;
       break;
     }
 
 #ifdef USE_IMAP
-    case M_IMAP:
+  case M_IMAP:
     {
       if ((r = safe_fclose (&msg->fp)) == 0)
-       r = imap_append_message (ctx, msg);
+        r = imap_append_message (ctx, msg);
       break;
     }
 #endif
-    
-    case M_MAILDIR:
+
+  case M_MAILDIR:
     {
       r = maildir_commit_message (ctx, msg, NULL);
       break;
     }
-    
-    case M_MH:
+
+  case M_MH:
     {
       r = mh_commit_message (ctx, msg, NULL);
       break;
     }
   }
-  
+
   if (r == 0 && (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
-      && (fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1))
-  {
+      && (fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1)) {
     mutt_perror _("Can't write message");
+
     r = -1;
   }
+
   return r;
 }
 
 /* close a pointer to a message */
-int mx_close_message (MESSAGE **msg)
+int mx_close_message (MESSAGE ** msg)
 {
   int r = 0;
 
@@ -1684,17 +1614,15 @@ int mx_close_message (MESSAGE **msg)
 #ifdef USE_NNTP
       || (*msg)->magic == M_NNTP
 #endif
-      )
-  {
+    ) {
     r = safe_fclose (&(*msg)->fp);
   }
   else
     (*msg)->fp = NULL;
 
-  if ((*msg)->path)
-  {
+  if ((*msg)->path) {
     dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",
-               (*msg)->path));
+                (*msg)->path));
     unlink ((*msg)->path);
     FREE (&(*msg)->path);
   }
@@ -1703,30 +1631,27 @@ int mx_close_message (MESSAGE **msg)
   return (r);
 }
 
-void mx_alloc_memory (CONTEXT *ctx)
+void mx_alloc_memory (CONTEXT * ctx)
 {
   int i;
   size_t s = MAX (sizeof (HEADER *), sizeof (int));
-  
-  if ((ctx->hdrmax + 25) * s < ctx->hdrmax * s)
-  {
+
+  if ((ctx->hdrmax + 25) * s < ctx->hdrmax * s) {
     mutt_error _("Integer overflow -- can't allocate memory.");
+
     sleep (1);
     mutt_exit (1);
   }
-  
-  if (ctx->hdrs)
-  {
+
+  if (ctx->hdrs) {
     safe_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25));
     safe_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax);
   }
-  else
-  {
+  else {
     ctx->hdrs = safe_calloc ((ctx->hdrmax += 25), sizeof (HEADER *));
     ctx->v2r = safe_calloc (ctx->hdrmax, sizeof (int));
   }
-  for (i = ctx->msgcount ; i < ctx->hdrmax ; i++)
-  {
+  for (i = ctx->msgcount; i < ctx->hdrmax; i++) {
     ctx->hdrs[i] = NULL;
     ctx->v2r[i] = -1;
   }
@@ -1735,23 +1660,20 @@ void mx_alloc_memory (CONTEXT *ctx)
 /* this routine is called to update the counts in the context structure for
  * the last message header parsed.
  */
-void mx_update_context (CONTEXT *ctx, int new_messages)
+void mx_update_context (CONTEXT * ctx, int new_messages)
 {
   HEADER *h;
   int msgno;
 
-  for (msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++)
-  {
+  for (msgno = ctx->msgcount - new_messages; msgno < ctx->msgcount; msgno++) {
     h = ctx->hdrs[msgno];
 
-    if (WithCrypto)
-    {
+    if (WithCrypto) {
       /* NOTE: this _must_ be done before the check for mailcap! */
       h->security = crypt_query (h->content);
     }
 
-    if (!ctx->pattern)
-    {
+    if (!ctx->pattern) {
       ctx->v2r[ctx->vcount] = msgno;
       h->virtual = ctx->vcount++;
     }
@@ -1759,21 +1681,19 @@ void mx_update_context (CONTEXT *ctx, int new_messages)
       h->virtual = -1;
     h->msgno = msgno;
 
-    if (h->env->supersedes)
-    {
+    if (h->env->supersedes) {
       HEADER *h2;
 
-      if (!ctx->id_hash)       
-       ctx->id_hash = mutt_make_id_hash (ctx);
+      if (!ctx->id_hash)
+        ctx->id_hash = mutt_make_id_hash (ctx);
 
       h2 = hash_find (ctx->id_hash, h->env->supersedes);
 
       /* FREE (&h->env->supersedes); should I ? */
-      if (h2)
-      {
-       h2->superseded = 1;
-       if (option (OPTSCORE)) 
-         mutt_score_message (ctx, h2, 1);
+      if (h2) {
+        h2->superseded = 1;
+        if (option (OPTSCORE))
+          mutt_score_message (ctx, h2, 1);
       }
     }
 
@@ -1783,7 +1703,7 @@ void mx_update_context (CONTEXT *ctx, int new_messages)
     if (ctx->subj_hash && h->env->real_subj)
       hash_insert (ctx->subj_hash, h->env->real_subj, h, 1);
 
-    if (option (OPTSCORE)) 
+    if (option (OPTSCORE))
       mutt_score_message (ctx, h, 0);
 
     if (h->changed)
@@ -1792,11 +1712,10 @@ void mx_update_context (CONTEXT *ctx, int new_messages)
       ctx->flagged++;
     if (h->deleted)
       ctx->deleted++;
-    if (!h->read)
-    {
+    if (!h->read) {
       ctx->unread++;
       if (!h->old)
-       ctx->new++;
+        ctx->new++;
     }
   }
 }
@@ -1809,18 +1728,17 @@ void mx_update_context (CONTEXT *ctx, int new_messages)
  */
 int mx_check_empty (const char *path)
 {
-  switch (mx_get_magic (path))
-  {
-    case M_MBOX:
-    case M_MMDF:
-      return mbox_check_empty (path);
-    case M_MH:
-      return mh_check_empty (path);
-    case M_MAILDIR:
-      return maildir_check_empty (path);
-    default:
-      errno = EINVAL;
-      return -1;
+  switch (mx_get_magic (path)) {
+  case M_MBOX:
+  case M_MMDF:
+    return mbox_check_empty (path);
+  case M_MH:
+    return mh_check_empty (path);
+  case M_MAILDIR:
+    return maildir_check_empty (path);
+  default:
+    errno = EINVAL;
+    return -1;
   }
   /* not reached */
 }
diff --git a/mx.h b/mx.h
index f5a31a7..37e7e41 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * This header file contains prototypes for internal functions used by the
 #include "mailbox.h"
 
 /* supported mailbox formats */
-enum
-{
+enum {
   M_MBOX = 1,
   M_MMDF,
   M_MH,
   M_MAILDIR
 #ifdef USE_IMAP
-  , M_IMAP
+    , M_IMAP
 #endif
 #ifdef USE_POP
-  , M_POP
+    , M_POP
 #endif
 #ifdef USE_NNTP
-  , M_NNTP
+    , M_NNTP
 #endif
 #ifdef USE_COMPRESSED
-  , M_COMPRESSED
+    , M_COMPRESSED
 #endif
 };
 
index 3131cc4..5f52223 100644 (file)
--- a/newsrc.c
+++ b/newsrc.c
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */ 
+ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -39,7 +39,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 
-void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
+void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
 {
   LIST *l;
 
@@ -55,7 +55,7 @@ void nntp_add_to_list (NNTP_SERVER *s, NNTP_DATA *d)
   l->data = (void *) d;
 }
 
-static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
+static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
 {
   NNTP_DATA *data;
   char group[LONG_STRING];
@@ -63,29 +63,30 @@ static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
   char *p = line, *b, *h;
   size_t len;
 
-  while (*p)
-  {
+  while (*p) {
     if (*p++ == ',')
       x++;
   }
 
   p = line;
-  while (*p && (*p != ':' && *p != '!')) p++;
+  while (*p && (*p != ':' && *p != '!'))
+    p++;
   if (!*p)
     return -1;
   len = p + 1 - line;
   if (len > sizeof (group))
     len = sizeof (group);
   strfcpy (group, line, len);
-  if ((data = (NNTP_DATA *)hash_find (news->newsgroups, group)) == NULL)
-  {
-    data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
+  if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
+    data =
+      (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
     data->group = (char *) data + sizeof (NNTP_DATA);
     strcpy (data->group, group);
     data->nserv = news;
     data->deleted = 1;
     if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-      news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
+      news->newsgroups =
+        hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
     hash_insert (news->newsgroups, data->group, data, 0);
     nntp_add_to_list (news, data);
   }
@@ -93,8 +94,8 @@ static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
     FREE ((void **) &data->entries);
 
   data->rc = 1;
-  data->entries = safe_calloc (x*2, sizeof (NEWSRC_ENTRY));
-  data->max = x*2;
+  data->entries = safe_calloc (x * 2, sizeof (NEWSRC_ENTRY));
+  data->max = x * 2;
 
   if (*p == ':')
     data->subscribed = 1;
@@ -104,24 +105,21 @@ static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
   p++;
   b = p;
   x = 0;
-  while (*b)
-  {
-    while (*p && *p != ',' && *p != '\n') p++;
-    if (*p)
-    {
+  while (*b) {
+    while (*p && *p != ',' && *p != '\n')
+      p++;
+    if (*p) {
       *p = '\0';
       p++;
     }
-    if ((h = strchr(b, '-')))
-    {
+    if ((h = strchr (b, '-'))) {
       *h = '\0';
       h++;
-      data->entries[x].first = atoi(b);
-      data->entries[x].last = atoi(h);
+      data->entries[x].first = atoi (b);
+      data->entries[x].last = atoi (h);
     }
-    else
-    {
-      data->entries[x].first = atoi(b);
+    else {
+      data->entries[x].first = atoi (b);
       data->entries[x].last = data->entries[x].first;
     }
     b = p;
@@ -129,15 +127,15 @@ static int nntp_parse_newsrc_line (NNTP_SERVER *news, char *line)
       x++;
   }
   if (x && !data->lastMessage)
-    data->lastMessage = data->entries[x-1].last;
+    data->lastMessage = data->entries[x - 1].last;
   data->num = x;
   mutt_newsgroup_stat (data);
   dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
-  
+
   return 0;
 }
 
-static int slurp_newsrc (NNTP_SERVER *news)
+static int slurp_newsrc (NNTP_SERVER * news)
 {
   FILE *fp;
   char *buf;
@@ -150,8 +148,7 @@ static int slurp_newsrc (NNTP_SERVER *news)
   if ((fp = safe_fopen (news->newsrc, "r")) == NULL)
     return -1;
   /* hmm, should we use dotlock? */
-  if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1))
-  {
+  if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1)) {
     fclose (fp);
     return -1;
   }
@@ -174,7 +171,7 @@ void nntp_cache_expand (char *dst, const char *src)
 
 /* Loads $news_cache_dir/.index into memory, loads newsserver data
  * and newsgroup cache names */
-static int nntp_parse_cacheindex (NNTP_SERVER *news)
+static int nntp_parse_cacheindex (NNTP_SERVER * news)
 {
   struct stat st;
   char buf[HUGE_STRING], *cp;
@@ -191,102 +188,101 @@ static int nntp_parse_cacheindex (NNTP_SERVER *news)
     return 0;
 
   strfcpy (dir, NewsCacheDir, sizeof (dir));
-  mutt_expand_path (dir, sizeof(dir));
-
-  if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0)
-  {
-    snprintf (buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir);
-    if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU+S_IRWXG+
-         S_IRWXO)))
-    {
+  mutt_expand_path (dir, sizeof (dir));
+
+  if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) {
+    snprintf (buf, sizeof (buf), _("Directory %s not exist. Create it?"),
+              dir);
+    if (mutt_yesorno (buf, M_YES) != M_YES
+        || mkdir (dir, (S_IRWXU + S_IRWXG + S_IRWXO))) {
       mutt_error _("Cache directory not created!");
+
       return -1;
     }
-    mutt_clear_error();
+    mutt_clear_error ();
   }
 
   set_option (OPTNEWSCACHE);
 
   FREE (&news->cache);
-  snprintf (buf, sizeof(buf), "%s/.index", dir);
+  snprintf (buf, sizeof (buf), "%s/.index", dir);
   if (!(index = safe_fopen (buf, "a+")))
     return 0;
   rewind (index);
-  while (fgets (buf, sizeof(buf), index))
-  {
-    buf[strlen(buf) - 1] = 0;  /* strip ending '\n' */
+  while (fgets (buf, sizeof (buf), index)) {
+    buf[strlen (buf) - 1] = 0;  /* strip ending '\n' */
     if (!mutt_strncmp (buf, "#: ", 3) &&
-       !mutt_strcasecmp (buf+3, news->conn->account.host))
+        !mutt_strcasecmp (buf + 3, news->conn->account.host))
       break;
   }
-  while (fgets (buf, sizeof(buf), index))
-  {
+  while (fgets (buf, sizeof (buf), index)) {
     cp = buf;
-    while (*cp && *cp != ' ') cp++;
-    if (!*cp) continue;
+    while (*cp && *cp != ' ')
+      cp++;
+    if (!*cp)
+      continue;
     cp[0] = 0;
     if (!mutt_strcmp (buf, "#:"))
       break;
     sscanf (cp + 1, "%s %d %d", file, &l, &m);
-    if (!mutt_strcmp (buf, "ALL"))
-    {
+    if (!mutt_strcmp (buf, "ALL")) {
       news->cache = safe_strdup (file);
       news->newgroups_time = m;
     }
-    else if (news->newsgroups)
-    {
-      if ((data = (NNTP_DATA *)hash_find (news->newsgroups, buf)) == NULL)
-      {
-       data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
-       data->group = (char *) data + sizeof (NNTP_DATA);
-       strcpy(data->group, buf);
-       data->nserv = news;
-       data->deleted = 1;
-       if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-         news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
-       hash_insert (news->newsgroups, data->group, data, 0);
-       nntp_add_to_list (news, data);
+    else if (news->newsgroups) {
+      if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) {
+        data =
+          (NNTP_DATA *) safe_calloc (1,
+                                     sizeof (NNTP_DATA) + strlen (buf) + 1);
+        data->group = (char *) data + sizeof (NNTP_DATA);
+        strcpy (data->group, buf);
+        data->nserv = news;
+        data->deleted = 1;
+        if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
+          news->newsgroups =
+            hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
+        hash_insert (news->newsgroups, data->group, data, 0);
+        nntp_add_to_list (news, data);
       }
       data->cache = safe_strdup (file);
       t = 0;
       if (!data->firstMessage || data->lastMessage < m)
-       t = 1;
+        t = 1;
       if (!data->firstMessage)
-       data->firstMessage = l;
+        data->firstMessage = l;
       if (data->lastMessage < m)
-       data->lastMessage = m;
+        data->lastMessage = m;
       data->lastCached = m;
       if (t || !data->unread)
-       mutt_newsgroup_stat (data);
+        mutt_newsgroup_stat (data);
     }
   }
   fclose (index);
   return 0;
 }
 
-const char *
-nntp_format_str (char *dest, size_t destlen, char op, const char *src,
-               const char *fmt, const char *ifstring, const char *elsestring,
-               unsigned long data, format_flag flags)
+const char *nntp_format_str (char *dest, size_t destlen, char op,
+                             const char *src, const char *fmt,
+                             const char *ifstring, const char *elsestring,
+                             unsigned long data, format_flag flags)
 {
   char fn[SHORT_STRING], tmp[SHORT_STRING];
 
-  switch (op)
-  {
-    case 's':
-      strncpy (fn, NewsServer, sizeof(fn) - 1);
-      mutt_strlower (fn);
-      snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
-      snprintf (dest, destlen, tmp, fn);
-      break;
+  switch (op) {
+  case 's':
+    strncpy (fn, NewsServer, sizeof (fn) - 1);
+    mutt_strlower (fn);
+    snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
+    snprintf (dest, destlen, tmp, fn);
+    break;
   }
   return (src);
 }
 
 /* nntp_parse_url: given an NNPT URL, return host, port,
  * username, password and newsgroup will recognise. */
-int nntp_parse_url (const char *server, ACCOUNT *acct,
-                   char *group, size_t group_len)
+int nntp_parse_url (const char *server, ACCOUNT * acct,
+                    char *group, size_t group_len)
 {
   ciss_url_t url;
   char *c;
@@ -300,10 +296,8 @@ int nntp_parse_url (const char *server, ACCOUNT *acct,
   c = safe_strdup (server);
   url_parse_ciss (&url, c);
 
-  if (url.scheme == U_NNTP || url.scheme == U_NNTPS)
-  {
-    if (url.scheme == U_NNTPS)
-    {
+  if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
+    if (url.scheme == U_NNTPS) {
       acct->flags |= M_ACCT_SSL;
       acct->port = NNTP_SSL_PORT;
     }
@@ -319,7 +313,7 @@ int nntp_parse_url (const char *server, ACCOUNT *acct,
   return ret;
 }
 
-void nntp_expand_path (char *line, size_t len, ACCOUNT *acct)
+void nntp_expand_path (char *line, size_t len, ACCOUNT * acct)
 {
   ciss_url_t url;
 
@@ -348,22 +342,20 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
   NNTP_SERVER *serv;
   CONNECTION *conn;
 
-  if (!server || !*server)
-  {
+  if (!server || !*server) {
     mutt_error _("No newsserver defined!");
+
     return NULL;
   }
 
   buf = p = safe_calloc (strlen (server) + 10, sizeof (char));
-  if (url_check_scheme (server) == U_UNKNOWN)
-  {
+  if (url_check_scheme (server) == U_UNKNOWN) {
     strcpy (buf, "nntp://");
     p = strchr (buf, '\0');
   }
   strcpy (p, server);
 
-  if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file)
-  {
+  if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) {
     FREE (&buf);
     mutt_error (_("%s is an invalid newsserver specification!"), server);
     return NULL;
@@ -374,28 +366,26 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
   if (!conn)
     return NULL;
 
-  mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0, 0);
+  mutt_FormatString (file, sizeof (file), NONULL (NewsRc), nntp_format_str, 0,
+                     0);
   mutt_expand_path (file, sizeof (file));
 
-  serv = (NNTP_SERVER *)conn->data;
-  if (serv)
-  {
+  serv = (NNTP_SERVER *) conn->data;
+  if (serv) {
     struct stat sb;
 
     /* externally modified? */
     if (serv->stat != stat (file, &sb) || (!serv->stat &&
-       (serv->size != sb.st_size || serv->mtime != sb.st_mtime)))
-    {
-      for (list = serv->list; list; list = list->next)
-      {
-       NNTP_DATA *data = (NNTP_DATA *) list->data;
-
-       if (data)
-       {
-         data->subscribed = 0;
-         data->rc = 0;
-         data->num = 0;
-       }
+                                           (serv->size != sb.st_size
+                                            || serv->mtime != sb.st_mtime))) {
+      for (list = serv->list; list; list = list->next) {
+        NNTP_DATA *data = (NNTP_DATA *) list->data;
+
+        if (data) {
+          data->subscribed = 0;
+          data->rc = 0;
+          data->num = 0;
+        }
       }
       slurp_newsrc (serv);
       nntp_clear_cacheindex (serv);
@@ -412,12 +402,11 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
   serv->conn = conn;
   serv->newsrc = safe_strdup (file);
   serv->newsgroups = hash_create (1009);
-  slurp_newsrc (serv);                 /* load .newsrc */
-  nntp_parse_cacheindex (serv);                /* load .index */
+  slurp_newsrc (serv);          /* load .newsrc */
+  nntp_parse_cacheindex (serv); /* load .index */
   if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
     nntp_check_newgroups (serv, 1);
-  else if (nntp_get_active (serv) < 0)
-  {
+  else if (nntp_get_active (serv) < 0) {
     hash_destroy (&serv->newsgroups, nntp_delete_data);
     for (list = serv->list; list; list = list->next)
       list->data = NULL;
@@ -428,7 +417,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
     return NULL;
   }
   nntp_clear_cacheindex (serv);
-  conn->data = (void *)serv;
+  conn->data = (void *) serv;
 
   return serv;
 }
@@ -443,7 +432,7 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
  * "skipped" in the newsrc, and new is anything not in the newsrc nor
  * in the cache. By skipped, I mean before the last unread message
  */
-void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
+void nntp_get_status (CONTEXT * ctx, HEADER * h, char *group, int article)
 {
   NNTP_DATA *data = (NNTP_DATA *) ctx->data;
   int x;
@@ -451,8 +440,7 @@ void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
   if (group)
     data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
 
-  if (!data)
-  {
+  if (!data) {
 #ifdef DEBUG
     if (group)
       dprint (3, (debugfile, "newsgroup %s not found\n", group));
@@ -460,13 +448,11 @@ void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
     return;
   }
 
-  for (x = 0; x < data->num; x++)
-  {
+  for (x = 0; x < data->num; x++) {
     if ((article >= data->entries[x].first) &&
-       (article <= data->entries[x].last))
-    {
+        (article <= data->entries[x].last)) {
       /* we cannot use mutt_set_flag() because mx_update_context()
-        didn't called yet */
+         didn't called yet */
       h->read = 1;
       return;
     }
@@ -480,7 +466,7 @@ void nntp_get_status (CONTEXT *ctx, HEADER *h, char *group, int article)
     h->old = 1;
 }
 
-void mutt_newsgroup_stat (NNTP_DATA *data)
+void mutt_newsgroup_stat (NNTP_DATA * data)
 {
   int i;
   unsigned int first, last;
@@ -490,8 +476,7 @@ void mutt_newsgroup_stat (NNTP_DATA *data)
     return;
 
   data->unread = data->lastMessage - data->firstMessage + 1;
-  for (i = 0; i < data->num; i++)
-  {
+  for (i = 0; i < data->num; i++) {
     first = data->entries[i].first;
     if (first < data->firstMessage)
       first = data->firstMessage;
@@ -507,8 +492,7 @@ static int puti (char *line, int num)
 {
   char *p, s[32];
 
-  for (p = s; num; )
-  {
+  for (p = s; num;) {
     *p++ = '0' + num % 10;
     num /= 10;
   }
@@ -518,14 +502,14 @@ static int puti (char *line, int num)
   return num;
 }
 
-static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline, size_t *buflen)
+static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf,
+                                     char **pline, size_t * buflen)
 {
   char *line = *pline;
   size_t len = *buflen - (*pline - *buf);
   int x, i;
 
-  if (len < LONG_STRING * 10)
-  {
+  if (len < LONG_STRING * 10) {
     len += *buflen;
     *buflen *= 2;
     line = *buf;
@@ -539,10 +523,8 @@ static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline,
   *line++ = ' ';
   *line = '\0';
 
-  for (x = 0; x < data->num; x++)
-  {
-    if (len < LONG_STRING)
-    {
+  for (x = 0; x < data->num; x++) {
+    if (len < LONG_STRING) {
       len += *buflen;
       *buflen *= 2;
       *pline = line;
@@ -550,8 +532,7 @@ static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline,
       safe_realloc (buf, *buflen);
       line = *buf + (*pline - line);
     }
-    if (x)
-    {
+    if (x) {
       *line++ = ',';
       len--;
     }
@@ -560,19 +541,20 @@ static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline,
     if (data->entries[x].first == data->entries[x].last)
       snprintf (line, len, "%d%n", data->entries[x].first, &i);
     else
-      snprintf (line, len, "%d-%d%n", 
-           data->entries[x].first, data->entries[x].last, &i);
+      snprintf (line, len, "%d-%d%n",
+                data->entries[x].first, data->entries[x].last, &i);
     len -= i;
     line += i;
 #else
     i = puti (line, data->entries[x].first);
-    line +=i; len -= i;
-    if (data->entries[x].first != data->entries[x].last)
-    {
+    line += i;
+    len -= i;
+    if (data->entries[x].first != data->entries[x].last) {
       *line++ = '-';
       len--;
       i = puti (line, data->entries[x].last);
-      line +=i; len -= i;
+      line += i;
+      len -= i;
     }
 #endif
   }
@@ -581,22 +563,20 @@ static void nntp_create_newsrc_line (NNTP_DATA *data, char **buf, char **pline,
   *pline = line;
 }
 
-void newsrc_gen_entries (CONTEXT *ctx)
+void newsrc_gen_entries (CONTEXT * ctx)
 {
-  NNTP_DATA *data = (NNTP_DATA *)ctx->data;
+  NNTP_DATA *data = (NNTP_DATA *) ctx->data;
   int series, x;
   unsigned int last = 0, first = 1;
   int save_sort = SORT_ORDER;
 
-  if (Sort != SORT_ORDER)
-  {
+  if (Sort != SORT_ORDER) {
     save_sort = Sort;
     Sort = SORT_ORDER;
     mutt_sort_headers (ctx, 0);
   }
 
-  if (!data->max)
-  {
+  if (!data->max) {
     data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
     data->max = 5;
   }
@@ -608,61 +588,51 @@ void newsrc_gen_entries (CONTEXT *ctx)
   data->num = 0;
   series = 1;
 
-  for (x = 0; x < ctx->msgcount; x++)
-  {
-    if (series) /* search for first unread */
-    {
+  for (x = 0; x < ctx->msgcount; x++) {
+    if (series) {               /* search for first unread */
       /*
        * We don't actually check sequential order, since we mark 
        * "missing" entries as read/deleted
        */
       last = ctx->hdrs[x]->article_num;
       if (last >= data->firstMessage && !ctx->hdrs[x]->deleted &&
-           !ctx->hdrs[x]->read)
-      {
-       if (data->num >= data->max)
-       {
-         data->max = data->max * 2;
-         safe_realloc (&data->entries, 
-             data->max * sizeof (NEWSRC_ENTRY));
-       }
-       data->entries[data->num].first = first;
-       data->entries[data->num].last = last - 1;
-       data->num++;
-       series = 0;
+          !ctx->hdrs[x]->read) {
+        if (data->num >= data->max) {
+          data->max = data->max * 2;
+          safe_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY));
+        }
+        data->entries[data->num].first = first;
+        data->entries[data->num].last = last - 1;
+        data->num++;
+        series = 0;
       }
     }
-    else /* search for first read */
-    {
-      if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read)
-      {
-       first = last + 1;
-       series = 1;
+    else {                      /* search for first read */
+
+      if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read) {
+        first = last + 1;
+        series = 1;
       }
       last = ctx->hdrs[x]->article_num;
     }
   }
-  if (series && first <= data->lastLoaded)
-  {
-    if (data->num >= data->max)
-    {
+  if (series && first <= data->lastLoaded) {
+    if (data->num >= data->max) {
       data->max = data->max * 2;
-      safe_realloc (&data->entries, 
-                   data->max * sizeof (NEWSRC_ENTRY));
+      safe_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY));
     }
     data->entries[data->num].first = first;
     data->entries[data->num].last = data->lastLoaded;
     data->num++;
   }
 
-  if (save_sort != Sort)
-  {
+  if (save_sort != Sort) {
     Sort = save_sort;
     mutt_sort_headers (ctx, 0);
   }
 }
 
-int mutt_newsrc_update (NNTP_SERVER *news)
+int mutt_newsrc_update (NNTP_SERVER * news)
 {
   char *buf, *line;
   NNTP_DATA *data;
@@ -675,8 +645,7 @@ int mutt_newsrc_update (NNTP_SERVER *news)
   llen = len = 10 * LONG_STRING;
   line = buf = safe_calloc (1, len);
   /* we will generate full newsrc here */
-  for (tmp = news->list; tmp; tmp = tmp->next)
-  {
+  for (tmp = news->list; tmp; tmp = tmp->next) {
     data = (NNTP_DATA *) tmp->data;
     if (!data || !data->rc)
       continue;
@@ -686,8 +655,7 @@ int mutt_newsrc_update (NNTP_SERVER *news)
   }
   /* newrc being fully rewritten */
   if (news->newsrc &&
-     (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0)
-  {
+      (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0) {
     struct stat st;
 
     stat (news->newsrc, &st);
@@ -709,15 +677,15 @@ static FILE *mutt_mkname (char *s)
     return fp;
 
   nntp_cache_expand (buf, "cache-XXXXXX");
-  pc = buf + strlen (buf) - 12;        /* positioning to "cache-XXXXXX" */
+  pc = buf + strlen (buf) - 12; /* positioning to "cache-XXXXXX" */
   if ((fd = mkstemp (buf)) == -1)
     return NULL;
-  strcpy (s, pc);      /* generated name */
+  strcpy (s, pc);               /* generated name */
   return fdopen (fd, "w");
 }
 
 /* Updates info into .index file: ALL or about selected newsgroup */
-static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
+static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data)
 {
   char buf[LONG_STRING], *key = "ALL";
   char file[_POSIX_PATH_MAX];
@@ -725,23 +693,22 @@ static int nntp_update_cacheindex (NNTP_SERVER *serv, NNTP_DATA *data)
   if (!serv || !serv->conn || !serv->conn->account.host)
     return -1;
 
-  if (data && data->group)
-  {
+  if (data && data->group) {
     key = data->group;
     snprintf (buf, sizeof (buf), "%s %s %d %d", key, data->cache,
-         data->firstMessage, data->lastLoaded);
+              data->firstMessage, data->lastLoaded);
   }
-  else
-  {
+  else {
     strfcpy (file, serv->cache, sizeof (file));
-    snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int)serv->newgroups_time);
+    snprintf (buf, sizeof (buf), "ALL %s 0 %d", file,
+              (int) serv->newgroups_time);
   }
   nntp_cache_expand (file, ".index");
   return mutt_update_list_file (file, serv->conn->account.host, key, buf);
 }
 
 /* Remove cache files of unsubscribed newsgroups */
-void nntp_clear_cacheindex (NNTP_SERVER *news)
+void nntp_clear_cacheindex (NNTP_SERVER * news)
 {
   NNTP_DATA *data;
   LIST *tmp;
@@ -749,8 +716,7 @@ void nntp_clear_cacheindex (NNTP_SERVER *news)
   if (option (OPTSAVEUNSUB) || !news)
     return;
 
-  for (tmp = news->list; tmp; tmp = tmp->next)
-  {
+  for (tmp = news->list; tmp; tmp = tmp->next) {
     data = (NNTP_DATA *) tmp->data;
     if (!data || data->subscribed || !data->cache)
       continue;
@@ -760,7 +726,7 @@ void nntp_clear_cacheindex (NNTP_SERVER *news)
   return;
 }
 
-int nntp_save_cache_index (NNTP_SERVER *news)
+int nntp_save_cache_index (NNTP_SERVER * news)
 {
   char buf[HUGE_STRING];
   char file[_POSIX_PATH_MAX];
@@ -773,15 +739,13 @@ int nntp_save_cache_index (NNTP_SERVER *news)
   if (!option (OPTNEWSCACHE))
     return 0;
 
-  if (news->cache)
-  {
+  if (news->cache) {
     nntp_cache_expand (file, news->cache);
     unlink (file);
     f = safe_fopen (file, "w");
   }
-  else
-  {
-    strfcpy (buf, news->conn->account.host, sizeof(buf));
+  else {
+    strfcpy (buf, news->conn->account.host, sizeof (buf));
     f = mutt_mkname (buf);
     news->cache = safe_strdup (buf);
     nntp_cache_expand (file, buf);
@@ -789,36 +753,32 @@ int nntp_save_cache_index (NNTP_SERVER *news)
   if (!f)
     return -1;
 
-  for (l = news->list; l; l = l->next)
-  {
-    if ((d = (NNTP_DATA *)l->data) && !d->deleted)
-    {
+  for (l = news->list; l; l = l->next) {
+    if ((d = (NNTP_DATA *) l->data) && !d->deleted) {
       if (d->desc)
-       snprintf (buf, sizeof(buf), "%s %d %d %c %s\n", d->group,
-             d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
-             d->desc);
+        snprintf (buf, sizeof (buf), "%s %d %d %c %s\n", d->group,
+                  d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
+                  d->desc);
       else
-       snprintf (buf, sizeof(buf), "%s %d %d %c\n", d->group,
-             d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
-      if (fputs (buf, f) == EOF)
-      {
-       fclose (f);
-       unlink (file);
-       return -1;
+        snprintf (buf, sizeof (buf), "%s %d %d %c\n", d->group,
+                  d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
+      if (fputs (buf, f) == EOF) {
+        fclose (f);
+        unlink (file);
+        return -1;
       }
     }
   }
   fclose (f);
 
-  if (nntp_update_cacheindex (news, NULL))
-  {
+  if (nntp_update_cacheindex (news, NULL)) {
     unlink (file);
     return -1;
   }
   return 0;
 }
 
-int nntp_save_cache_group (CONTEXT *ctx)
+int nntp_save_cache_group (CONTEXT * ctx)
 {
   char buf[HUGE_STRING], addr[STRING];
   char file[_POSIX_PATH_MAX];
@@ -833,81 +793,74 @@ int nntp_save_cache_group (CONTEXT *ctx)
   if (!ctx || !ctx->data || ctx->magic != M_NNTP)
     return -1;
 
-  if (((NNTP_DATA *)ctx->data)->cache)
-  {
-    nntp_cache_expand (file, ((NNTP_DATA *)ctx->data)->cache);
+  if (((NNTP_DATA *) ctx->data)->cache) {
+    nntp_cache_expand (file, ((NNTP_DATA *) ctx->data)->cache);
     unlink (file);
     f = safe_fopen (file, "w");
   }
-  else
-  {
-    snprintf (buf, sizeof(buf), "%s-%s",
-       ((NNTP_DATA *)ctx->data)->nserv->conn->account.host,
-       ((NNTP_DATA *)ctx->data)->group);
+  else {
+    snprintf (buf, sizeof (buf), "%s-%s",
+              ((NNTP_DATA *) ctx->data)->nserv->conn->account.host,
+              ((NNTP_DATA *) ctx->data)->group);
     f = mutt_mkname (buf);
-    ((NNTP_DATA *)ctx->data)->cache = safe_strdup (buf);
+    ((NNTP_DATA *) ctx->data)->cache = safe_strdup (buf);
     nntp_cache_expand (file, buf);
   }
   if (!f)
     return -1;
 
-  if (Sort != SORT_ORDER)
-  {
+  if (Sort != SORT_ORDER) {
     save = Sort;
     Sort = SORT_ORDER;
     mutt_sort_headers (ctx, 0);
   }
 
   /* Save only $nntp_context messages... */
-  ((NNTP_DATA *)ctx->data)->lastCached = 0;
+  ((NNTP_DATA *) ctx->data)->lastCached = 0;
   if (NntpContext && ctx->msgcount > NntpContext)
     i = ctx->msgcount - NntpContext;
-  for (; i < ctx->msgcount; i++)
-  {
-    if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev)
-    {
+  for (; i < ctx->msgcount; i++) {
+    if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) {
       h = ctx->hdrs[i];
       addr[0] = 0;
-      rfc822_write_address (addr, sizeof(addr), h->env->from, 0);
+      rfc822_write_address (addr, sizeof (addr), h->env->from, 0);
       tm = gmtime (&h->date_sent);
-      snprintf (buf, sizeof(buf),
-           "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
-           h->article_num, h->env->subject, addr, tm->tm_mday,
-           Months[tm->tm_mon], tm->tm_year+1900, tm->tm_hour, tm->tm_min,
-           tm->tm_sec, h->env->message_id);
+      snprintf (buf, sizeof (buf),
+                "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
+                h->article_num, h->env->subject, addr, tm->tm_mday,
+                Months[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour,
+                tm->tm_min, tm->tm_sec, h->env->message_id);
       fputs (buf, f);
       if (h->env->references)
-       mutt_write_references (h->env->references, f);
-      snprintf (buf, sizeof(buf), "\t%ld\t%d\tXref: %s\n", h->content->length,
-           h->lines, NONULL(h->env->xref));
-      if (fputs (buf, f) == EOF)
-      {
-       fclose (f);
-       unlink (file);
-       return -1;
+        mutt_write_references (h->env->references, f);
+      snprintf (buf, sizeof (buf), "\t%ld\t%d\tXref: %s\n",
+                h->content->length, h->lines, NONULL (h->env->xref));
+      if (fputs (buf, f) == EOF) {
+        fclose (f);
+        unlink (file);
+        return -1;
       }
     }
     prev = ctx->hdrs[i]->article_num;
   }
 
-  if (save != Sort)
-  {
+  if (save != Sort) {
     Sort = save;
     mutt_sort_headers (ctx, 0);
   }
   fclose (f);
 
-  if (nntp_update_cacheindex (((NNTP_DATA *)ctx->data)->nserv,
-       (NNTP_DATA *)ctx->data))
-  {
+  if (nntp_update_cacheindex (((NNTP_DATA *) ctx->data)->nserv,
+                              (NNTP_DATA *) ctx->data)) {
     unlink (file);
     return -1;
   }
-  ((NNTP_DATA *)ctx->data)->lastCached = ((NNTP_DATA *)ctx->data)->lastLoaded;
+  ((NNTP_DATA *) ctx->data)->lastCached =
+    ((NNTP_DATA *) ctx->data)->lastLoaded;
   return 0;
 }
 
-void nntp_delete_cache (NNTP_DATA *data)
+void nntp_delete_cache (NNTP_DATA * data)
 {
   char buf[_POSIX_PATH_MAX];
 
@@ -919,44 +872,44 @@ void nntp_delete_cache (NNTP_DATA *data)
   FREE (&data->cache);
   data->lastCached = 0;
   nntp_cache_expand (buf, ".index");
-  mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, NULL);
+  mutt_update_list_file (buf, data->nserv->conn->account.host, data->group,
+                         NULL);
 }
 
-NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *news, char *group)
+NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER * news, char *group)
 {
   NNTP_DATA *data;
 
   if (!news || !news->newsgroups || !group || !*group)
     return NULL;
-  if (!(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
-  {
-    data = (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
+  if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) {
+    data =
+      (NNTP_DATA *) safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
     data->group = (char *) data + sizeof (NNTP_DATA);
     strcpy (data->group, group);
     data->nserv = news;
     data->deleted = 1;
     if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-      news->newsgroups = hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
+      news->newsgroups =
+        hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
     hash_insert (news->newsgroups, data->group, data, 0);
     nntp_add_to_list (news, data);
   }
-  if (!data->subscribed)
-  {
+  if (!data->subscribed) {
     data->subscribed = 1;
     data->rc = 1;
   }
   return data;
 }
 
-NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
+NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER * news, char *group)
 {
   NNTP_DATA *data;
 
   if (!news || !news->newsgroups || !group || !*group ||
-       !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
+      !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
     return NULL;
-  if (data->subscribed)
-  {
+  if (data->subscribed) {
     data->subscribed = 0;
     if (!option (OPTSAVEUNSUB))
       data->rc = 0;
@@ -964,15 +917,14 @@ NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *news, char *group)
   return data;
 }
 
-NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
+NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER * news, char *group)
 {
   NNTP_DATA *data;
 
   if (!news || !news->newsgroups || !group || !*group ||
-      !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
+      !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
     return NULL;
-  if (!data->max)
-  {
+  if (!data->max) {
     data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
     data->max = 5;
   }
@@ -980,8 +932,7 @@ NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
   data->entries[0].first = 1;
   data->unread = 0;
   data->entries[0].last = data->lastMessage;
-  if (Context && Context->data == data)
-  {
+  if (Context && Context->data == data) {
     int x;
 
     for (x = 0; x < Context->msgcount; x++)
@@ -990,23 +941,21 @@ NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *news, char *group)
   return data;
 }
 
-NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *news, char *group)
+NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group)
 {
   NNTP_DATA *data;
 
   if (!news || !news->newsgroups || !group || !*group ||
-      !(data = (NNTP_DATA *)hash_find (news->newsgroups, group)))
+      !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
     return NULL;
-  if (!data->max)
-  {
+  if (!data->max) {
     data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
     data->max = 5;
   }
   data->num = 1;
   data->entries[0].first = 1;
   data->entries[0].last = data->firstMessage - 1;
-  if (Context && Context->data == data)
-  {
+  if (Context && Context->data == data) {
     int x;
 
     data->unread = Context->msgcount;
@@ -1023,22 +972,19 @@ void nntp_buffy (char *s)
 {
   LIST *list;
 
-  for (list = CurrentNewsSrv->list; list; list = list->next)
-  {
+  for (list = CurrentNewsSrv->list; list; list = list->next) {
     NNTP_DATA *data = (NNTP_DATA *) list->data;
 
-    if (data && data->subscribed && data->unread)
-    {
+    if (data && data->subscribed && data->unread) {
       if (Context && Context->magic == M_NNTP &&
-         !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group))
-      {
-       unsigned int i, unread = 0;
-
-       for (i = 0; i < Context->msgcount; i++)
-         if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
-           unread++;
-       if (!unread)
-         continue;
+          !mutt_strcmp (data->group, ((NNTP_DATA *) Context->data)->group)) {
+        unsigned int i, unread = 0;
+
+        for (i = 0; i < Context->msgcount; i++)
+          if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted)
+            unread++;
+        if (!unread)
+          continue;
       }
       strcpy (s, data->group);
       break;
diff --git a/nntp.c b/nntp.c
index 9c9a591..64cc4d2 100644 (file)
--- a/nntp.c
+++ b/nntp.c
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */ 
+ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -50,19 +50,20 @@ static unsigned int _checked = 0;
 #ifdef DEBUG
 static void nntp_error (const char *where, const char *msg)
 {
-  dprint (1, (debugfile, "nntp_error(): unexpected response in %s: %s\n", where, msg));
+  dprint (1,
+          (debugfile, "nntp_error(): unexpected response in %s: %s\n", where,
+           msg));
 }
 #endif /* DEBUG */
 
-static int nntp_auth (NNTP_SERVER *serv)
+static int nntp_auth (NNTP_SERVER * serv)
 {
   CONNECTION *conn = serv->conn;
   char buf[STRING];
   unsigned char flags = conn->account.flags;
 
   if (mutt_account_getuser (&conn->account) || !conn->account.user[0] ||
-      mutt_account_getpass (&conn->account) || !conn->account.pass[0])
-  {
+      mutt_account_getpass (&conn->account) || !conn->account.pass[0]) {
     conn->account.flags = flags;
     return -2;
   }
@@ -71,8 +72,7 @@ static int nntp_auth (NNTP_SERVER *serv)
 
   snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user);
   mutt_socket_write (conn, buf);
-  if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
-  {
+  if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) {
     conn->account.flags = flags;
     return -1;
   }
@@ -84,16 +84,15 @@ static int nntp_auth (NNTP_SERVER *serv)
 #endif
   snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
   mutt_socket_write_d (conn, buf, M_SOCK_LOG_FULL);
-  if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
-  {
+  if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) {
     conn->account.flags = flags;
     return -1;
   }
 
-  if (mutt_strncmp ("281", buf, 3))
-  {
+  if (mutt_strncmp ("281", buf, 3)) {
     conn->account.flags = flags;
     mutt_error _("Login failed.");
+
     sleep (2);
     return -3;
   }
@@ -101,16 +100,17 @@ static int nntp_auth (NNTP_SERVER *serv)
   return 0;
 }
 
-static int nntp_connect_error (NNTP_SERVER *serv)
+static int nntp_connect_error (NNTP_SERVER * serv)
 {
   serv->status = NNTP_NONE;
   mutt_socket_close (serv->conn);
   mutt_error _("Server closed connection!");
+
   sleep (2);
   return -1;
 }
 
-static int nntp_connect_and_auth (NNTP_SERVER *serv)
+static int nntp_connect_and_auth (NNTP_SERVER * serv)
 {
   CONNECTION *conn = serv->conn;
   char buf[STRING];
@@ -128,8 +128,7 @@ static int nntp_connect_and_auth (NNTP_SERVER *serv)
     mutt_message (_("Connected to %s. Posting ok."), conn->account.host);
   else if (!mutt_strncmp ("201", buf, 3))
     mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
-  else
-  {
+  else {
     mutt_socket_close (conn);
     mutt_remove_trailing_ws (buf);
     mutt_error ("%s", buf);
@@ -140,7 +139,7 @@ static int nntp_connect_and_auth (NNTP_SERVER *serv)
   sleep (1);
 
   /* Tell INN to switch to mode reader if it isn't so. Ignore all
-   returned codes and messages. */
+     returned codes and messages. */
   mutt_socket_write (conn, "MODE READER\r\n");
   if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
     return nntp_connect_error (serv);
@@ -149,8 +148,7 @@ static int nntp_connect_and_auth (NNTP_SERVER *serv)
   if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
     return nntp_connect_error (serv);
 
-  if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3))
-  {
+  if (!(conn->account.flags & M_ACCT_USER) && mutt_strncmp ("480", buf, 3)) {
     serv->status = NNTP_OK;
     return 0;
   }
@@ -158,16 +156,15 @@ static int nntp_connect_and_auth (NNTP_SERVER *serv)
   rc = nntp_auth (serv);
   if (rc == -1)
     return nntp_connect_error (serv);
-  if (rc == -2)
-  {
+  if (rc == -2) {
     mutt_socket_close (conn);
     serv->status = NNTP_BYE;
     return -1;
   }
-  if (rc < 0)
-  {
+  if (rc < 0) {
     mutt_socket_close (conn);
     mutt_error _("Login failed.");
+
     sleep (2);
     return -1;
   }
@@ -175,7 +172,7 @@ static int nntp_connect_and_auth (NNTP_SERVER *serv)
   return 0;
 }
 
-static int nntp_attempt_features (NNTP_SERVER *serv)
+static int nntp_attempt_features (NNTP_SERVER * serv)
 {
   char buf[LONG_STRING];
   CONNECTION *conn = serv->conn;
@@ -204,19 +201,17 @@ static int nntp_attempt_features (NNTP_SERVER *serv)
   if (mutt_strncmp ("500", buf, 3))
     serv->hasXGTITLE = 1;
 
-  if (!mutt_strncmp ("282", buf, 3))
-  {
-    do
-    {
+  if (!mutt_strncmp ("282", buf, 3)) {
+    do {
       if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
-       return nntp_connect_error (serv);
+        return nntp_connect_error (serv);
     } while (!(buf[0] == '.' && buf[1] == '\0'));
   }
 
   return 0;
 }
 
-static int nntp_open_connection (NNTP_SERVER *serv)
+static int nntp_open_connection (NNTP_SERVER * serv)
 {
   if (serv->status == NNTP_OK)
     return 0;
@@ -229,21 +224,19 @@ static int nntp_open_connection (NNTP_SERVER *serv)
   return 0;
 }
 
-static int nntp_reconnect (NNTP_SERVER *serv)
+static int nntp_reconnect (NNTP_SERVER * serv)
 {
   char buf[SHORT_STRING];
 
   mutt_socket_close (serv->conn);
 
-  FOREVER
-  {
+  FOREVER {
     if (nntp_connect_and_auth (serv) == 0)
       return 0;
 
     snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"),
-                               serv->conn->account.host);
-    if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES)
-    {
+              serv->conn->account.host);
+    if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES) {
       serv->status = NNTP_BYE;
       return -1;
     }
@@ -251,7 +244,7 @@ static int nntp_reconnect (NNTP_SERVER *serv)
 }
 
 /* Send data from line[LONG_STRING] and receive answer to same line */
-static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
+static int mutt_nntp_query (NNTP_DATA * data, char *line, size_t linelen)
 {
   char buf[LONG_STRING];
   int done = TRUE;
@@ -259,33 +252,28 @@ static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
   if (data->nserv->status == NNTP_BYE)
     return -1;
 
-  do
-  {
-    if (*line)
-    {
+  do {
+    if (*line) {
       mutt_socket_write (data->nserv->conn, line);
     }
-    else if (data->group)
-    {
+    else if (data->group) {
       snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
       mutt_socket_write (data->nserv->conn, buf);
     }
 
     done = TRUE;
-    if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
-    {
+    if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) {
       if (nntp_reconnect (data->nserv) < 0)
-       return -1;
-
-      if (data->group)
-      {
-       snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
-       mutt_socket_write (data->nserv->conn, buf);
-       if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
-         return -1;
+        return -1;
+
+      if (data->group) {
+        snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group);
+        mutt_socket_write (data->nserv->conn, buf);
+        if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0)
+          return -1;
       }
       if (*line)
-       done = FALSE;
+        done = FALSE;
     }
     else if ((!mutt_strncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0)
       return -1;
@@ -305,8 +293,9 @@ static int mutt_nntp_query (NNTP_DATA *data, char *line, size_t linelen)
  * -2 - invalid command or execution error,
  * -3 - error in funct(*line, *data).
  */
-static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
-               int (*funct) (char *, void *), void *data, int tagged)
+static int mutt_nntp_fetch (NNTP_DATA * nntp_data, char *query, char *msg,
+                            int (*funct) (char *, void *), void *data,
+                            int tagged)
 {
   char buf[LONG_STRING];
   char *inbuf, *p;
@@ -315,8 +304,7 @@ static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
   size_t lenbuf = 0;
   int ret;
 
-  do
-  {
+  do {
     strfcpy (buf, query, sizeof (buf));
     if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
       return -1;
@@ -329,44 +317,39 @@ static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
     line = 0;
     inbuf = safe_malloc (sizeof (buf));
 
-    FOREVER
-    {
+    FOREVER {
       chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn,
-                                   M_SOCK_LOG_HDR);
+                                    M_SOCK_LOG_HDR);
       if (chunk < 0)
-       break;
+        break;
 
       p = buf;
-      if (!lenbuf && buf[0] == '.')
-      {
-       if (buf[1] == '\0')
-       {
-         done = TRUE;
-         break;
-       }
-       if (buf[1] == '.')
-         p++;
+      if (!lenbuf && buf[0] == '.') {
+        if (buf[1] == '\0') {
+          done = TRUE;
+          break;
+        }
+        if (buf[1] == '.')
+          p++;
       }
 
       strfcpy (inbuf + lenbuf, p, sizeof (buf));
 
-      if (chunk >= sizeof (buf))
-      {
-       lenbuf += strlen (p);
+      if (chunk >= sizeof (buf)) {
+        lenbuf += strlen (p);
       }
-      else
-      {
-       line++;
-       if (msg && ReadInc && (line % ReadInc == 0)) {
-         if (tagged)
-           mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
-         else
-           mutt_message ("%s %d", msg, line);
-       }
-
-       if (ret == 0 && funct (inbuf, data) < 0)
-         ret = -3;
-       lenbuf = 0;
+      else {
+        line++;
+        if (msg && ReadInc && (line % ReadInc == 0)) {
+          if (tagged)
+            mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line);
+          else
+            mutt_message ("%s %d", msg, line);
+        }
+
+        if (ret == 0 && funct (inbuf, data) < 0)
+          ret = -3;
+        lenbuf = 0;
       }
 
       safe_realloc (&inbuf, lenbuf + sizeof (buf));
@@ -380,12 +363,11 @@ static int mutt_nntp_fetch (NNTP_DATA *nntp_data, char *query, char *msg,
 
 static int nntp_read_tempfile (char *line, void *file)
 {
-  FILE *f = (FILE *)file;
+  FILE *f = (FILE *) file;
 
   if (!line)
     rewind (f);
-  else
-  {
+  else {
     fputs (line, f);
     if (fputc ('\n', f) == EOF)
       return -1;
@@ -393,38 +375,36 @@ static int nntp_read_tempfile (char *line, void *file)
   return 0;
 }
 
-static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
+static void nntp_parse_xref (CONTEXT * ctx, char *group, char *xref,
+                             HEADER * h)
 {
   register char *p, *b;
   register char *colon = NULL;
 
   b = p = xref;
-  while (*p)
-  {
+  while (*p) {
     /* skip to next word */
     b = p;
-    while (*b && ((*b == ' ') || (*b == '\t'))) b++;
+    while (*b && ((*b == ' ') || (*b == '\t')))
+      b++;
     p = b;
     colon = NULL;
     /* skip to end of word */
-    while (*p && (*p != ' ') && (*p != '\t')) 
-    {
+    while (*p && (*p != ' ') && (*p != '\t')) {
       if (*p == ':')
-       colon = p;
+        colon = p;
       p++;
     }
-    if (*p)
-    {
+    if (*p) {
       *p = '\0';
       p++;
     }
-    if (colon)
-    {
+    if (colon) {
       *colon = '\0';
       colon++;
-      nntp_get_status (ctx, h, p, atoi(colon));
+      nntp_get_status (ctx, h, p, atoi (colon));
       if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
-       h->article_num = atoi(colon);
+        h->article_num = atoi (colon);
     }
   }
 }
@@ -435,9 +415,10 @@ static void nntp_parse_xref (CONTEXT *ctx, char *group, char *xref, HEADER *h)
  *  1 if article not found
  * -1 if read or write error on tempfile or socket
  */
-static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
+static int nntp_read_header (CONTEXT * ctx, const char *msgid,
+                             int article_num)
 {
-  NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
+  NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data);
   FILE *f;
   char buf[LONG_STRING];
   char tempfile[_POSIX_PATH_MAX];
@@ -454,11 +435,10 @@ static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
     snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid);
 
   ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
-  if (ret)
-  {
+  if (ret) {
 #ifdef DEBUG
     if (ret != -1)
-      dprint(1, (debugfile, "nntp_read_header: %s\n", buf));
+      dprint (1, (debugfile, "nntp_read_header: %s\n", buf));
 #endif
     fclose (f);
     unlink (tempfile);
@@ -472,8 +452,7 @@ static int nntp_read_header (CONTEXT *ctx, const char *msgid, int article_num)
 
   if (h->env->xref != NULL)
     nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h);
-  else if (h->article_num == 0 && msgid)
-  {
+  else if (h->article_num == 0 && msgid) {
     snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid);
     if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0)
       h->article_num = atoi (buf + 4);
@@ -490,14 +469,15 @@ static int parse_description (char *line, void *n)
 
   if (!line)
     return 0;
-  while (*d && *d != '\t' && *d != ' ') d++;
-    *d = 0;
+  while (*d && *d != '\t' && *d != ' ')
+    d++;
+  *d = 0;
   d++;
-  while (*d && (*d == '\t' || *d == ' ')) d++;
+  while (*d && (*d == '\t' || *d == ' '))
+    d++;
   dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
   if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
-       mutt_strcmp (d, data->desc))
-  {
+      mutt_strcmp (d, data->desc)) {
     FREE (&data->desc);
     data->desc = safe_strdup (d);
   }
@@ -505,7 +485,7 @@ static int parse_description (char *line, void *n)
 #undef news
 }
 
-static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
+static void nntp_get_desc (NNTP_DATA * data, char *mask, char *msg)
 {
   char buf[STRING];
 
@@ -517,8 +497,8 @@ static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
     snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask);
   else
     snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask);
-  if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) != 0)
-  {
+  if (mutt_nntp_fetch (data, buf, msg, parse_description, data->nserv, 0) !=
+      0) {
 #ifdef DEBUG
     nntp_error ("nntp_get_desc()", buf);
 #endif
@@ -533,15 +513,15 @@ static void nntp_get_desc (NNTP_DATA *data, char *mask, char *msg)
  * mutt_read_rfc822_header(), since it replaces the call to that (albeit with
  * a limited number of headers which are "parsed" by placement in the list)
  */
-static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
+static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
 {
   NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
   char *p, *b;
   int x, done = 0;
 
-  hdr->env = mutt_new_envelope();
+  hdr->env = mutt_new_envelope ();
   hdr->env->newsgroups = safe_strdup (nntp_data->group);
-  hdr->content = mutt_new_body();
+  hdr->content = mutt_new_body ();
   hdr->content->type = TYPETEXT;
   hdr->content->subtype = safe_strdup ("plain");
   hdr->content->encoding = ENC7BIT;
@@ -549,65 +529,64 @@ static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
   hdr->content->length = -1;
   b = p = buf;
 
-  for (x = 0; !done && x < 9; x++)
-  {
+  for (x = 0; !done && x < 9; x++) {
     /* if from file, need to skip newline character */
-    while (*p && *p != '\n' && *p != '\t') p++;
-    if (!*p) done++;
+    while (*p && *p != '\n' && *p != '\t')
+      p++;
+    if (!*p)
+      done++;
     *p = '\0';
     p++;
-    switch (x)
-    {
-      case 0:
-
-       hdr->article_num = atoi (b);
-       nntp_get_status (ctx, hdr, NULL, hdr->article_num);
-       break;
-      case 1:
-       hdr->env->subject = safe_strdup (b);
-       /* Now we need to do the things which would normally be done in 
-        * mutt_read_rfc822_header() */
-       if (hdr->env->subject)
-       {
-         regmatch_t pmatch[1];
-
-         rfc2047_decode (&hdr->env->subject);
-
-         if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
-           hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
-         else
-           hdr->env->real_subj = hdr->env->subject;
-       }
-       break;
-      case 2:
-       rfc822_free_address (&hdr->env->from);
-       hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
-       rfc2047_decode_adrlist (hdr->env->from);
-       break;
-      case 3:
-       hdr->date_sent = mutt_parse_date (b, hdr);
-       hdr->received = hdr->date_sent;
-       break;
-      case 4:
-       FREE (&hdr->env->message_id);
-       hdr->env->message_id = safe_strdup (b);
-       break;
-      case 5:
-       mutt_free_list (&hdr->env->references);
-       hdr->env->references = mutt_parse_references (b, 0);
-       break;
-      case 6:
-       hdr->content->length = atoi (b);
-       break;
-      case 7:
-       hdr->lines = atoi (b);
-       break;
-      case 8:
-       if (!hdr->read)
-         FREE (&hdr->env->xref);
-         b = b + 6;    /* skips the "Xref: " */
-         hdr->env->xref = safe_strdup (b);
-         nntp_parse_xref (ctx, nntp_data->group, b, hdr);
+    switch (x) {
+    case 0:
+
+      hdr->article_num = atoi (b);
+      nntp_get_status (ctx, hdr, NULL, hdr->article_num);
+      break;
+    case 1:
+      hdr->env->subject = safe_strdup (b);
+      /* Now we need to do the things which would normally be done in 
+       * mutt_read_rfc822_header() */
+      if (hdr->env->subject) {
+        regmatch_t pmatch[1];
+
+        rfc2047_decode (&hdr->env->subject);
+
+        if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
+          hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
+        else
+          hdr->env->real_subj = hdr->env->subject;
+      }
+      break;
+    case 2:
+      rfc822_free_address (&hdr->env->from);
+      hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
+      rfc2047_decode_adrlist (hdr->env->from);
+      break;
+    case 3:
+      hdr->date_sent = mutt_parse_date (b, hdr);
+      hdr->received = hdr->date_sent;
+      break;
+    case 4:
+      FREE (&hdr->env->message_id);
+      hdr->env->message_id = safe_strdup (b);
+      break;
+    case 5:
+      mutt_free_list (&hdr->env->references);
+      hdr->env->references = mutt_parse_references (b, 0);
+      break;
+    case 6:
+      hdr->content->length = atoi (b);
+      break;
+    case 7:
+      hdr->lines = atoi (b);
+      break;
+    case 8:
+      if (!hdr->read)
+        FREE (&hdr->env->xref);
+      b = b + 6;                /* skips the "Xref: " */
+      hdr->env->xref = safe_strdup (b);
+      nntp_parse_xref (ctx, nntp_data->group, b, hdr);
     }
     if (!*p)
       return -1;
@@ -616,18 +595,18 @@ static int nntp_parse_xover (CONTEXT *ctx, char *buf, HEADER *hdr)
   return 0;
 }
 
-typedef struct
-{
+typedef struct {
   CONTEXT *ctx;
   unsigned int base;
   unsigned int first;
   unsigned int last;
   unsigned short *messages;
-  charmsg;
+  char *msg;
 } FETCH_CONTEXT;
 
 #define fc ((FETCH_CONTEXT *) c)
-static int _nntp_fetch_numbers (unsigned int num ,void* c) {
+static int _nntp_fetch_numbers (unsigned int num, void *c)
+{
   if (num < fc->base || num > fc->last)
     return 0;
   fc->messages[num - fc->base] = 1;
@@ -644,7 +623,7 @@ static int add_xover_line (char *line, void *c)
 {
   unsigned int num, total;
   CONTEXT *ctx = fc->ctx;
-  NNTP_DATA *data = (NNTP_DATA *)ctx->data;
+  NNTP_DATA *data = (NNTP_DATA *) ctx->data;
 
   if (!line)
     return 0;
@@ -657,8 +636,7 @@ static int add_xover_line (char *line, void *c)
   nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
   num = ctx->hdrs[ctx->msgcount]->article_num;
 
-  if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base])
-  {
+  if (num >= fc->first && num <= fc->last && fc->messages[num - fc->base]) {
     ctx->msgcount++;
     if (num > data->lastLoaded)
       data->lastLoaded = num;
@@ -668,18 +646,19 @@ static int add_xover_line (char *line, void *c)
       mutt_message ("%s %d/%d", fc->msg, num, total);
   }
   else
-    mutt_free_header (&ctx->hdrs[ctx->msgcount]); /* skip it */
+    mutt_free_header (&ctx->hdrs[ctx->msgcount]);       /* skip it */
 
   return 0;
 }
+
 #undef fc
 
-static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
-       unsigned int last)
+static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first,
+                               unsigned int last)
 {
   char buf[HUGE_STRING];
   char *msg = _("Fetching message headers...");
-  NNTP_DATA *nntp_data = ((NNTP_DATA *)ctx->data);
+  NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data);
   int ret;
   int num;
   int oldmsgcount;
@@ -693,14 +672,15 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
 
   /* fetch list of articles */
   mutt_message _("Fetching list of articles...");
+
   fc.ctx = ctx;
   fc.base = first;
   fc.last = last;
   fc.messages = safe_calloc (last - first + 1, sizeof (unsigned short));
   if (nntp_data->nserv->hasLISTGROUP) {
     snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group);
-    if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) != 0)
-    {
+    if (mutt_nntp_fetch (nntp_data, buf, NULL, nntp_fetch_numbers, &fc, 0) !=
+        0) {
       mutt_error (_("LISTGROUP command failed: %s"), buf);
       sleep (2);
 #ifdef DEBUG
@@ -709,7 +689,8 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
       FREE (&fc.messages);
       return -1;
     }
-  } else {
+  }
+  else {
     /* mutt_nntp_query() issues a 'GROUP nntp_data->group' 
      * command on its own if !*buf */
     buf[0] = '\0';
@@ -718,7 +699,8 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
       mutt_error (_("GROUP command failed: %s"), buf);
       FREE (&fc.messages);
       return (-1);
-    } else {
+    }
+    else {
       for (num = fc.first; num < fc.last; num++)
         _nntp_fetch_numbers (num, &fc);
     }
@@ -726,38 +708,36 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
 
   /* CACHE: must be loaded xover cache here */
   num = nntp_data->lastCached - first + 1;
-  if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0)
-  {
+  if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) {
     nntp_cache_expand (buf, nntp_data->cache);
     mutt_message _("Fetching headers from cache...");
-    if ((f = safe_fopen (buf, "r")))
-    {
+
+    if ((f = safe_fopen (buf, "r"))) {
       int r = 0;
 
       /* counting number of lines */
       while (fgets (buf, sizeof (buf), f) != NULL)
-       r++;
+        r++;
       rewind (f);
       while (r > num && fgets (buf, sizeof (buf), f) != NULL)
-       r--;
+        r--;
       oldmsgcount = ctx->msgcount;
       fc.first = first;
       fc.last = first + num - 1;
       fc.msg = NULL;
       while (fgets (buf, sizeof (buf), f) != NULL)
-       add_xover_line (buf, &fc);
+        add_xover_line (buf, &fc);
       fclose (f);
       nntp_data->lastLoaded = fc.last;
       first = fc.last + 1;
       if (ctx->msgcount > oldmsgcount)
-       mx_update_context (ctx, ctx->msgcount - oldmsgcount);
+        mx_update_context (ctx, ctx->msgcount - oldmsgcount);
     }
     else
       nntp_delete_cache (nntp_data);
   }
   num = last - first + 1;
-  if (num <= 0)
-  {
+  if (num <= 0) {
     FREE (&fc.messages);
     return 0;
   }
@@ -767,8 +747,7 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
    * it.  With XOVER, we ask for all of them
    */
   mutt_message (msg);
-  if (nntp_data->nserv->hasXOVER)
-  {
+  if (nntp_data->nserv->hasXOVER) {
     oldmsgcount = ctx->msgcount;
     fc.first = first;
     fc.last = last;
@@ -777,8 +756,7 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
     ret = mutt_nntp_fetch (nntp_data, buf, NULL, add_xover_line, &fc, 0);
     if (ctx->msgcount > oldmsgcount)
       mx_update_context (ctx, ctx->msgcount - oldmsgcount);
-    if (ret != 0)
-    {
+    if (ret != 0) {
       mutt_error (_("XOVER command failed: %s"), buf);
 #ifdef DEBUG
       nntp_error ("nntp_fetch_headers()", buf);
@@ -789,39 +767,36 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
     /* fetched OK */
   }
   else
-  for (current = first; current <= last; current++)
-  {
-    HEADER *h;
-
-    ret = current - first + 1;
-    mutt_message ("%s %d/%d", msg, ret, num);
-
-    if (!fc.messages[current - fc.base])
-      continue;
-
-    if (ctx->msgcount >= ctx->hdrmax)
-      mx_alloc_memory (ctx);
-    h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
-    h->index = ctx->msgcount;
-
-    ret = nntp_read_header (ctx, NULL, current);
-    if (ret == 0) /* Got article. Fetch next header */
-    {
-      nntp_get_status (ctx, h, NULL, h->article_num);
-      ctx->msgcount++;
-      mx_update_context (ctx, 1);
-    }
-    else
-      mutt_free_header (&h); /* skip it */
-    if (ret == -1)
-    {
-      FREE (&fc.messages);
-      return -1;
-    }
+    for (current = first; current <= last; current++) {
+      HEADER *h;
 
-    if (current > nntp_data->lastLoaded)
-      nntp_data->lastLoaded = current;
-  }
+      ret = current - first + 1;
+      mutt_message ("%s %d/%d", msg, ret, num);
+
+      if (!fc.messages[current - fc.base])
+        continue;
+
+      if (ctx->msgcount >= ctx->hdrmax)
+        mx_alloc_memory (ctx);
+      h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
+      h->index = ctx->msgcount;
+
+      ret = nntp_read_header (ctx, NULL, current);
+      if (ret == 0) {           /* Got article. Fetch next header */
+        nntp_get_status (ctx, h, NULL, h->article_num);
+        ctx->msgcount++;
+        mx_update_context (ctx, 1);
+      }
+      else
+        mutt_free_header (&h);  /* skip it */
+      if (ret == -1) {
+        FREE (&fc.messages);
+        return -1;
+      }
+
+      if (current > nntp_data->lastLoaded)
+        nntp_data->lastLoaded = current;
+    }
   FREE (&fc.messages);
   nntp_data->lastLoaded = last;
   mutt_clear_error ();
@@ -831,7 +806,7 @@ static int nntp_fetch_headers (CONTEXT *ctx, unsigned int first,
 /* 
  * currently, nntp "mailbox" is "newsgroup"
  */
-int nntp_open_mailbox (CONTEXT *ctx)
+int nntp_open_mailbox (CONTEXT * ctx)
 {
   NNTP_DATA *nntp_data;
   NNTP_SERVER *serv;
@@ -841,8 +816,7 @@ int nntp_open_mailbox (CONTEXT *ctx)
   unsigned int first;
   ACCOUNT acct;
 
-  if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf)
-  {
+  if (nntp_parse_url (ctx->path, &acct, buf, sizeof (buf)) < 0 || !*buf) {
     mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path);
     mutt_sleep (2);
     return -1;
@@ -856,8 +830,7 @@ int nntp_open_mailbox (CONTEXT *ctx)
   CurrentNewsSrv = serv;
 
   /* create NNTP-specific state struct if nof found in list */
-  if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL)
-  {
+  if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) {
     nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (buf) + 1);
     nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
     strcpy (nntp_data->group, buf);
@@ -869,38 +842,36 @@ int nntp_open_mailbox (CONTEXT *ctx)
 
   mutt_message (_("Selecting %s..."), nntp_data->group);
 
-  if (!nntp_data->desc)
-  {
+  if (!nntp_data->desc) {
     nntp_get_desc (nntp_data, nntp_data->group, NULL);
     if (nntp_data->desc)
       nntp_save_cache_index (serv);
   }
 
   buf[0] = 0;
-  if (mutt_nntp_query (nntp_data, buf, sizeof(buf)) < 0)
-  {
+  if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) {
 #ifdef DEBUG
     nntp_error ("nntp_open_mailbox()", buf);
 #endif
     return -1;
   }
 
-  if (mutt_strncmp ("211", buf, 3))
-  {
+  if (mutt_strncmp ("211", buf, 3)) {
     LIST *l = serv->list;
 
     /* GROUP command failed */
-    if (!mutt_strncmp ("411", buf, 3))
-    {
+    if (!mutt_strncmp ("411", buf, 3)) {
       mutt_error (_("Newsgroup %s not found on server %s"),
-                   nntp_data->group, serv->conn->account.host);
+                  nntp_data->group, serv->conn->account.host);
 
       /* CACHE: delete cache and line from .index */
       nntp_delete_cache (nntp_data);
-      hash_delete (serv->newsgroups, nntp_data->group, NULL, nntp_delete_data);
-      while (l && l->data != (void *) nntp_data) l = l->next;
+      hash_delete (serv->newsgroups, nntp_data->group, NULL,
+                   nntp_delete_data);
+      while (l && l->data != (void *) nntp_data)
+        l = l->next;
       if (l)
-       l->data = NULL;
+        l->data = NULL;
 
       sleep (2);
     }
@@ -908,8 +879,8 @@ int nntp_open_mailbox (CONTEXT *ctx)
     return -1;
   }
 
-  sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage, 
-         &nntp_data->lastMessage, buf);
+  sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->firstMessage,
+          &nntp_data->lastMessage, buf);
 
   nntp_data->deleted = 0;
 
@@ -927,7 +898,7 @@ int nntp_open_mailbox (CONTEXT *ctx)
   return nntp_fetch_headers (ctx, first, nntp_data->lastMessage);
 }
 
-int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
+int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
 {
   char buf[LONG_STRING];
   char path[_POSIX_PATH_MAX];
@@ -936,7 +907,9 @@ int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   int ret;
 
   /* see if we already have the message in our cache */
-  cache = &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index % NNTP_CACHE_LEN];
+  cache =
+    &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index %
+                                       NNTP_CACHE_LEN];
 
   /* if everything is fine, assign msg->fp and return */
   if (cache->path && cache->index == ctx->hdrs[msgno]->index &&
@@ -952,30 +925,27 @@ int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   cache->index = ctx->hdrs[msgno]->index;
   mutt_mktemp (path);
   cache->path = safe_strdup (path);
-  if (!(msg->fp = safe_fopen (path, "w+")))
-  {
+  if (!(msg->fp = safe_fopen (path, "w+"))) {
     FREE (&cache->path);
     return -1;
   }
 
   if (ctx->hdrs[msgno]->article_num == 0)
     snprintf (buf, sizeof (buf), "ARTICLE %s\r\n",
-         ctx->hdrs[msgno]->env->message_id);
+              ctx->hdrs[msgno]->env->message_id);
   else
     snprintf (buf, sizeof (buf), "ARTICLE %d\r\n",
-         ctx->hdrs[msgno]->article_num);
-
-  ret = mutt_nntp_fetch ((NNTP_DATA *)ctx->data, buf, m, nntp_read_tempfile,
-       msg->fp, ctx->tagged);
-  if (ret == 1)
-  {
-    mutt_error (_("Article %d not found on server"), 
-         ctx->hdrs[msgno]->article_num);
+              ctx->hdrs[msgno]->article_num);
+
+  ret = mutt_nntp_fetch ((NNTP_DATA *) ctx->data, buf, m, nntp_read_tempfile,
+                         msg->fp, ctx->tagged);
+  if (ret == 1) {
+    mutt_error (_("Article %d not found on server"),
+                ctx->hdrs[msgno]->article_num);
     dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
   }
 
-  if (ret)
-  {
+  if (ret) {
     fclose (msg->fp);
     unlink (path);
     FREE (&cache->path);
@@ -983,11 +953,12 @@ int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   }
 
   mutt_free_envelope (&ctx->hdrs[msgno]->env);
-  ctx->hdrs[msgno]->env = mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
+  ctx->hdrs[msgno]->env =
+    mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
   /* fix content length */
-  fseek(msg->fp, 0, SEEK_END);
-  ctx->hdrs[msgno]->content->length = ftell (msg->fp) - 
-                                        ctx->hdrs[msgno]->content->offset;
+  fseek (msg->fp, 0, SEEK_END);
+  ctx->hdrs[msgno]->content->length = ftell (msg->fp) -
+    ctx->hdrs[msgno]->content->offset;
 
   /* this is called in mutt before the open which fetches the message, 
    * which is probably wrong, but we just call it again here to handle
@@ -1003,58 +974,52 @@ int nntp_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno)
   ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
 #endif /* HAVE_PGP || HAVE_SMIME */
 
-  mutt_clear_error();
+  mutt_clear_error ();
   rewind (msg->fp);
 
   return 0;
 }
 
 /* Post article */
-int nntp_post (const char *msg) {
+int nntp_post (const char *msg)
+{
   char buf[LONG_STRING];
   size_t len;
   FILE *f;
   NNTP_DATA *nntp_data;
 
   if (Context && Context->magic == M_NNTP)
-    nntp_data = (NNTP_DATA *)Context->data;
-  else
-  {
+    nntp_data = (NNTP_DATA *) Context->data;
+  else {
     if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
-       !CurrentNewsSrv->list || !CurrentNewsSrv->list->data)
-    {
+        !CurrentNewsSrv->list || !CurrentNewsSrv->list->data) {
       mutt_error (_("Can't post article. No connection to news server."));
       return -1;
     }
-    nntp_data = (NNTP_DATA *)CurrentNewsSrv->list->data;
+    nntp_data = (NNTP_DATA *) CurrentNewsSrv->list->data;
   }
 
-  if (!(f = safe_fopen (msg, "r")))
-  {
+  if (!(f = safe_fopen (msg, "r"))) {
     mutt_error (_("Can't post article. Unable to open %s"), msg);
     return -1;
   }
 
   strfcpy (buf, "POST\r\n", sizeof (buf));
-  if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
-  {
+  if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) {
     mutt_error (_("Can't post article. Connection to %s lost."),
-               nntp_data->nserv->conn->account.host);
+                nntp_data->nserv->conn->account.host);
     return -1;
   }
-  if (buf[0] != '3')
-  {
+  if (buf[0] != '3') {
     mutt_error (_("Can't post article: %s"), buf);
     return -1;
   }
 
   buf[0] = '.';
   buf[1] = '\0';
-  while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL)
-  {
+  while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) {
     len = strlen (buf);
-    if (buf[len - 1] == '\n')
-    {
+    if (buf[len - 1] == '\n') {
       buf[len - 1] = '\r';
       buf[len] = '\n';
       len++;
@@ -1070,14 +1035,12 @@ int nntp_post (const char *msg) {
   if (buf[strlen (buf) - 1] != '\n')
     mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", M_SOCK_LOG_HDR);
   mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", M_SOCK_LOG_HDR);
-  if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0)
-  {
+  if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) {
     mutt_error (_("Can't post article. Connection to %s lost."),
-               nntp_data->nserv->conn->account.host);
+                nntp_data->nserv->conn->account.host);
     return -1;
   }
-  if (buf[0] != '2')
-  {
+  if (buf[0] != '2') {
     mutt_error (_("Can't post article: %s"), buf);
     return -1;
   }
@@ -1089,17 +1052,15 @@ int nntp_post (const char *msg) {
 void nntp_logout_all (void)
 {
   char buf[LONG_STRING];
-  CONNECTIONconn;
-  CONNECTIONtmp;
+  CONNECTION *conn;
+  CONNECTION *tmp;
 
   conn = mutt_socket_head ();
 
-  while (conn)
-  {
+  while (conn) {
     tmp = conn;
 
-    if (conn->account.type == M_ACCT_TYPE_NNTP)
-    {
+    if (conn->account.type == M_ACCT_TYPE_NNTP) {
       mutt_message (_("Closing connection to %s..."), conn->account.host);
       mutt_socket_write (conn, "QUIT\r\n");
       mutt_socket_readln (buf, sizeof (buf), conn);
@@ -1113,14 +1074,12 @@ void nntp_logout_all (void)
   }
 }
 
-static void nntp_free_acache (NNTP_DATA *data)
+static void nntp_free_acache (NNTP_DATA * data)
 {
   int i;
 
-  for (i = 0; i < NNTP_CACHE_LEN; i++)
-  {
-    if (data->acache[i].path)
-    {
+  for (i = 0; i < NNTP_CACHE_LEN; i++) {
+    if (data->acache[i].path) {
       unlink (data->acache[i].path);
       FREE (&data->acache[i].path);
     }
@@ -1129,7 +1088,7 @@ static void nntp_free_acache (NNTP_DATA *data)
 
 void nntp_delete_data (void *p)
 {
-  NNTP_DATA *data = (NNTP_DATA *)p;
+  NNTP_DATA *data = (NNTP_DATA *) p;
 
   if (!p)
     return;
@@ -1140,7 +1099,7 @@ void nntp_delete_data (void *p)
   FREE (p);
 }
 
-int nntp_sync_mailbox (CONTEXT *ctx)
+int nntp_sync_mailbox (CONTEXT * ctx)
 {
   NNTP_DATA *data = ctx->data;
 
@@ -1149,11 +1108,11 @@ int nntp_sync_mailbox (CONTEXT *ctx)
     nntp_save_cache_group (ctx);
   nntp_free_acache (data);
 
-  data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */
+  data->nserv->check_time = 0;  /* next nntp_check_mailbox() will really check */
   return 0;
 }
 
-void nntp_fastclose_mailbox (CONTEXT *ctx)
+void nntp_fastclose_mailbox (CONTEXT * ctx)
 {
   NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
 
@@ -1164,46 +1123,44 @@ void nntp_fastclose_mailbox (CONTEXT *ctx)
     return;
   nntp_save_cache_index (data->nserv);
   if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
-       || tmp != data)
+      || tmp != data)
     nntp_delete_data (data);
 }
 
 /* commit changes and terminate connection */
-int nntp_close_mailbox (CONTEXT *ctx)
+int nntp_close_mailbox (CONTEXT * ctx)
 {
   if (!ctx)
     return -1;
   mutt_message _("Quitting newsgroup...");
-  if (ctx->data)
-  {
+
+  if (ctx->data) {
     NNTP_DATA *data = (NNTP_DATA *) ctx->data;
     int ret;
 
-    if (data->nserv && data->nserv->conn && ctx->unread)
-    {
+    if (data->nserv && data->nserv->conn && ctx->unread) {
       ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?"));
       if (ret == M_YES)
-       mutt_newsgroup_catchup (data->nserv, data->group);
+        mutt_newsgroup_catchup (data->nserv, data->group);
       else if (ret < 0)
-       return -1;
+        return -1;
     }
   }
   nntp_sync_mailbox (ctx);
-  if (ctx->data && ((NNTP_DATA *)ctx->data)->nserv)
-  {
+  if (ctx->data && ((NNTP_DATA *) ctx->data)->nserv) {
     NNTP_SERVER *news;
 
-    news = ((NNTP_DATA *)ctx->data)->nserv;
+    news = ((NNTP_DATA *) ctx->data)->nserv;
     newsrc_gen_entries (ctx);
-    ((NNTP_DATA *)ctx->data)->unread = ctx->unread;
+    ((NNTP_DATA *) ctx->data)->unread = ctx->unread;
     mutt_newsrc_update (news);
   }
-  mutt_clear_error();
+  mutt_clear_error ();
   return 0;
 }
 
 /* use the GROUP command to poll for new mail */
-static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
+static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data)
 {
   char buf[LONG_STRING];
   int count = 0;
@@ -1212,34 +1169,29 @@ static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
     return 0;
 
   buf[0] = 0;
-  if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
-  {
+  if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) {
 #ifdef DEBUG
     nntp_error ("nntp_check_mailbox()", buf);
 #endif
     return -1;
   }
-  if (mutt_strncmp ("211", buf, 3))
-  {
+  if (mutt_strncmp ("211", buf, 3)) {
     buf[0] = 0;
-    if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0)
-    {
+    if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) {
 #ifdef DEBUG
       nntp_error ("nntp_check_mailbox()", buf);
 #endif
       return -1;
     }
   }
-  if (!mutt_strncmp ("211", buf, 3))
-  {
+  if (!mutt_strncmp ("211", buf, 3)) {
     int first;
     int last;
 
     sscanf (buf + 4, "%d %d %d", &count, &first, &last);
     nntp_data->firstMessage = first;
     nntp_data->lastMessage = last;
-    if (ctx && last > nntp_data->lastLoaded)
-    {
+    if (ctx && last > nntp_data->lastLoaded) {
       nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last);
       time (&nntp_data->nserv->check_time);
       return 1;
@@ -1249,12 +1201,10 @@ static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
     else
       mutt_newsgroup_stat (nntp_data);
     /* active was renumbered? */
-    if (last < nntp_data->lastLoaded)
-    {
-      if (!nntp_data->max)
-      {
-       nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
-       nntp_data->max = 5;
+    if (last < nntp_data->lastLoaded) {
+      if (!nntp_data->max) {
+        nntp_data->entries = safe_calloc (5, sizeof (NEWSRC_ENTRY));
+        nntp_data->max = 5;
       }
       nntp_data->lastCached = 0;
       nntp_data->num = 1;
@@ -1267,9 +1217,9 @@ static int _nntp_check_mailbox (CONTEXT *ctx, NNTP_DATA *nntp_data)
   return 0;
 }
 
-int nntp_check_mailbox (CONTEXT *ctx)
+int nntp_check_mailbox (CONTEXT * ctx)
 {
-  return _nntp_check_mailbox (ctx, (NNTP_DATA *)ctx->data);
+  return _nntp_check_mailbox (ctx, (NNTP_DATA *) ctx->data);
 }
 
 static int add_group (char *buf, void *serv)
@@ -1280,8 +1230,8 @@ static int add_group (char *buf, void *serv)
   NNTP_DATA *nntp_data;
   static int n = 0;
 
-  _checked = n;        /* _checked have N, where N = number of groups */
-  if (!buf)    /* at EOF must be zerouth */
+  _checked = n;                 /* _checked have N, where N = number of groups */
+  if (!buf)                     /* at EOF must be zerouth */
     n = 0;
 
   if (!s || !buf)
@@ -1291,8 +1241,7 @@ static int add_group (char *buf, void *serv)
   sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
   if (!group)
     return 0;
-  if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL)
-  {
+  if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) {
     n++;
     nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + strlen (group) + 1);
     nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
@@ -1317,7 +1266,7 @@ static int add_group (char *buf, void *serv)
   if (nntp_data->rc || nntp_data->lastCached)
     mutt_newsgroup_stat (nntp_data);
   else if (nntp_data->lastMessage &&
-       nntp_data->firstMessage <= nntp_data->lastMessage)
+           nntp_data->firstMessage <= nntp_data->lastMessage)
     nntp_data->unread = nntp_data->lastMessage - nntp_data->firstMessage + 1;
   else
     nntp_data->unread = 0;
@@ -1326,7 +1275,7 @@ static int add_group (char *buf, void *serv)
 #undef s
 }
 
-int nntp_check_newgroups (NNTP_SERVER *serv, int force)
+int nntp_check_newgroups (NNTP_SERVER * serv, int force)
 {
   char buf[LONG_STRING];
   NNTP_DATA nntp_data;
@@ -1342,35 +1291,34 @@ int nntp_check_newgroups (NNTP_SERVER *serv, int force)
     return -1;
 
   /* check subscribed groups for new news */
-  if (option (OPTSHOWNEWNEWS))
-  {
+  if (option (OPTSHOWNEWNEWS)) {
     mutt_message _("Checking for new messages...");
-    for (l = serv->list; l; l = l->next)
-    {
-      serv->check_time = 0;    /* really check! */
+
+    for (l = serv->list; l; l = l->next) {
+      serv->check_time = 0;     /* really check! */
       if (l->data && ((NNTP_DATA *) l->data)->subscribed)
-       _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
+        _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
     }
   }
   else if (!force)
     return 0;
 
   mutt_message _("Checking for new newsgroups...");
+
   now = serv->newgroups_time;
   time (&serv->newgroups_time);
   t = gmtime (&now);
   snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
-       (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
-       t->tm_sec);
+            (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour,
+            t->tm_min, t->tm_sec);
   nntp_data.nserv = serv;
   if (Context && Context->magic == M_NNTP)
-    nntp_data.group = ((NNTP_DATA *)Context->data)->group;
+    nntp_data.group = ((NNTP_DATA *) Context->data)->group;
   else
     nntp_data.group = NULL;
   l = serv->tail;
   if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."),
-       add_group, serv, 0) != 0)
-  {
+                       add_group, serv, 0) != 0) {
 #ifdef DEBUG
     nntp_error ("nntp_check_newgroups()", buf);
 #endif
@@ -1378,16 +1326,17 @@ int nntp_check_newgroups (NNTP_SERVER *serv, int force)
   }
 
   mutt_message _("Loading descriptions...");
+
   if (l)
     emp.next = l->next;
   else
     emp.next = serv->list;
   l = &emp;
-  while (l->next)
-  {
+  while (l->next) {
     l = l->next;
     ((NNTP_DATA *) l->data)->new = 1;
-    nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group, NULL);
+    nntp_get_desc ((NNTP_DATA *) l->data, ((NNTP_DATA *) l->data)->group,
+                   NULL);
   }
   if (emp.next)
     nntp_save_cache_index (serv);
@@ -1396,20 +1345,18 @@ int nntp_check_newgroups (NNTP_SERVER *serv, int force)
 }
 
 /* Load list of all newsgroups from cache ALL */
-int nntp_get_cache_all (NNTP_SERVER *serv)
+int nntp_get_cache_all (NNTP_SERVER * serv)
 {
   char buf[HUGE_STRING];
   FILE *f;
 
   nntp_cache_expand (buf, serv->cache);
-  if ((f = safe_fopen (buf, "r")))
-  {
+  if ((f = safe_fopen (buf, "r"))) {
     int i = 0;
 
-    while (fgets (buf, sizeof(buf), f) != NULL)
-    {
+    while (fgets (buf, sizeof (buf), f) != NULL) {
       if (ReadInc && (i % ReadInc == 0))
-       mutt_message (_("Loading list from cache... %d"), i);
+        mutt_message (_("Loading list from cache... %d"), i);
       add_group (buf, serv);
       i++;
     }
@@ -1418,15 +1365,14 @@ int nntp_get_cache_all (NNTP_SERVER *serv)
     mutt_clear_error ();
     return 0;
   }
-  else
-  {
+  else {
     FREE (&serv->cache);
     return -1;
   }
 }
 
 /* Load list of all newsgroups from active */
-int nntp_get_active (NNTP_SERVER *serv)
+int nntp_get_active (NNTP_SERVER * serv)
 {
   char msg[SHORT_STRING];
   NNTP_DATA nntp_data;
@@ -1435,15 +1381,15 @@ int nntp_get_active (NNTP_SERVER *serv)
   if (nntp_open_connection (serv) < 0)
     return -1;
 
-  snprintf (msg, sizeof(msg), _("Loading list of all newsgroups on server %s..."),
-               serv->conn->account.host);
+  snprintf (msg, sizeof (msg),
+            _("Loading list of all newsgroups on server %s..."),
+            serv->conn->account.host);
   mutt_message (msg);
   time (&serv->newgroups_time);
   nntp_data.nserv = serv;
   nntp_data.group = NULL;
 
-  if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0)
-  {
+  if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, add_group, serv, 0) < 0) {
 #ifdef DEBUG
     nntp_error ("nntp_get_active()", "LIST\r\n");
 #endif
@@ -1454,12 +1400,10 @@ int nntp_get_active (NNTP_SERVER *serv)
   mutt_message (msg);
   nntp_get_desc (&nntp_data, "*", msg);
 
-  for (tmp = serv->list; tmp; tmp = tmp->next)
-  {
-    NNTP_DATA *data = (NNTP_DATA *)tmp->data;
+  for (tmp = serv->list; tmp; tmp = tmp->next) {
+    NNTP_DATA *data = (NNTP_DATA *) tmp->data;
 
-    if (data && data->deleted && !data->rc)
-    {
+    if (data && data->deleted && !data->rc) {
       nntp_delete_cache (data);
       hash_delete (serv->newsgroups, data->group, NULL, nntp_delete_data);
       tmp->data = NULL;
@@ -1475,7 +1419,7 @@ int nntp_get_active (NNTP_SERVER *serv)
  * returns -1 if error ocurred while retrieving header,
  * number of articles which ones exist in context on success.
  */
-int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
+int nntp_check_msgid (CONTEXT * ctx, const char *msgid)
 {
   int ret;
 
@@ -1486,15 +1430,14 @@ int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
     mx_alloc_memory (ctx);
   ctx->hdrs[ctx->msgcount] = mutt_new_header ();
   ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
-  
+
   mutt_message (_("Fetching %s from server..."), msgid);
   ret = nntp_read_header (ctx, msgid, 0);
   /* since nntp_read_header() may set read flag, we must reset it */
   ctx->hdrs[ctx->msgcount]->read = 0;
   if (ret != 0)
     mutt_free_header (&ctx->hdrs[ctx->msgcount]);
-  else
-  {
+  else {
     ctx->msgcount++;
     mx_update_context (ctx, 1);
     ctx->changed = 1;
@@ -1502,8 +1445,7 @@ int nntp_check_msgid (CONTEXT *ctx, const char *msgid)
   return ret;
 }
 
-typedef struct
-{
+typedef struct {
   CONTEXT *ctx;
   unsigned int num;
   unsigned int max;
@@ -1528,34 +1470,32 @@ static int check_children (char *s, void *c)
 #undef cc
 }
 
-int nntp_check_children (CONTEXT *ctx, const char *msgid)
+int nntp_check_children (CONTEXT * ctx, const char *msgid)
 {
-  NNTP_DATA *nntp_data = (NNTP_DATA *)ctx->data;
+  NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
   char buf[STRING];
   int i, ret = 0, tmp = 0;
   CHILD_CONTEXT cc;
 
   if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn ||
-       !nntp_data->nserv->conn->account.host)
+      !nntp_data->nserv->conn->account.host)
     return -1;
   if (nntp_data->firstMessage > nntp_data->lastLoaded)
     return 0;
-  if (!nntp_data->nserv->hasXPAT)
-  {
+  if (!nntp_data->nserv->hasXPAT) {
     mutt_error (_("Server %s does not support this operation!"),
-         nntp_data->nserv->conn->account.host);
+                nntp_data->nserv->conn->account.host);
     return -1;
   }
 
-  snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", 
-       nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
+  snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n",
+            nntp_data->firstMessage, nntp_data->lastLoaded, msgid);
 
   cc.ctx = ctx;
   cc.num = 0;
   cc.max = 25;
   cc.child = safe_malloc (sizeof (unsigned int) * 25);
-  if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0))
-  {
+  if (mutt_nntp_fetch (nntp_data, buf, NULL, check_children, &cc, 0)) {
     FREE (&cc.child);
     return -1;
   }
@@ -1563,17 +1503,15 @@ int nntp_check_children (CONTEXT *ctx, const char *msgid)
    * made sure that we dont have the article, so we need to visit
    * the server. Reading the cache at this point is also bad
    * because it would duplicate messages */
-  if (option (OPTNEWSCACHE))
-  {
+  if (option (OPTNEWSCACHE)) {
     tmp++;
     unset_option (OPTNEWSCACHE);
   }
-  for (i = 0; i < cc.num; i++)
-  {
+  for (i = 0; i < cc.num; i++) {
     if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i])))
       break;
     if (ctx->msgcount &&
-         ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
+        ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i])
       ctx->hdrs[ctx->msgcount - 1]->read = 0;
   }
   if (tmp)
diff --git a/nntp.h b/nntp.h
index 335f094..5fa5250 100644 (file)
--- a/nntp.h
+++ b/nntp.h
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */ 
+ */
 
 #ifndef _NNTP_H_
 #define _NNTP_H_ 1
 /* number of entries in the hash table */
 #define NNTP_CACHE_LEN 10
 
-enum
-{
+enum {
   NNTP_NONE = 0,
   NNTP_OK,
   NNTP_BYE
 };
 
-typedef struct
-{
+typedef struct {
   int first;
   int last;
 } NEWSRC_ENTRY;
 
-typedef struct
-{
-  unsigned int hasXPAT : 1;
-  unsigned int hasXGTITLE : 1;
-  unsigned int hasXOVER : 1;
-  unsigned int hasLISTGROUP : 1;
-  unsigned int status : 3;
+typedef struct {
+  unsigned int hasXPAT:1;
+  unsigned int hasXGTITLE:1;
+  unsigned int hasXOVER:1;
+  unsigned int hasLISTGROUP:1;
+  unsigned int status:3;
   char *newsrc;
   char *cache;
   int stat;
@@ -60,32 +57,30 @@ typedef struct
   time_t newgroups_time;
   time_t check_time;
   HASH *newsgroups;
-  LIST *list;  /* list of newsgroups */
-  LIST *tail;  /* last entry of list */
+  LIST *list;                   /* list of newsgroups */
+  LIST *tail;                   /* last entry of list */
   CONNECTION *conn;
 } NNTP_SERVER;
 
-typedef struct
-{
+typedef struct {
   unsigned int index;
   char *path;
 } NNTP_CACHE;
 
-typedef struct
-{
+typedef struct {
   NEWSRC_ENTRY *entries;
-  unsigned int num;    /* number of used entries */
-  unsigned int max;    /* number of allocated entries */
+  unsigned int num;             /* number of used entries */
+  unsigned int max;             /* number of allocated entries */
   unsigned int unread;
   unsigned int firstMessage;
   unsigned int lastMessage;
   unsigned int lastLoaded;
   unsigned int lastCached;
-  unsigned int subscribed : 1;
-  unsigned int rc : 1;
-  unsigned int new : 1;
-  unsigned int allowed : 1;
-  unsigned int deleted : 1;
+  unsigned int subscribed:1;
+  unsigned int rc:1;
+  unsigned int new:1;
+  unsigned int allowed:1;
+  unsigned int deleted:1;
   char *group;
   char *desc;
   char *cache;
@@ -129,7 +124,8 @@ void nntp_buffy (char *);
 void nntp_expand_path (char *, size_t, ACCOUNT *);
 void nntp_logout_all ();
 const char *nntp_format_str (char *, size_t, char, const char *, const char *,
-               const char *, const char *, unsigned long, format_flag);
+                             const char *, const char *, unsigned long,
+                             format_flag);
 
 NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
 
diff --git a/pager.c b/pager.c
index c2f784b..83859a1 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #define IsMsgAttach(x) (x && (x)->fp && (x)->bdy && (x)->bdy->hdr)
 #define IsHeader(x) (x && (x)->hdr && !(x)->bdy)
 
-static const char *Not_available_in_this_menu = N_("Not available in this menu.");
+static const char *Not_available_in_this_menu =
+N_("Not available in this menu.");
 static const char *Mailbox_is_read_only = N_("Mailbox is read-only.");
-static const char *Function_not_permitted_in_attach_message_mode = N_("Function not permitted in attach-message mode.");
+static const char *Function_not_permitted_in_attach_message_mode =
+N_("Function not permitted in attach-message mode.");
 
 #define CHECK_MODE(x)  if (!(x)) \
                        { \
@@ -80,7 +82,7 @@ static const char *Function_not_permitted_in_attach_message_mode = N_("Function
                        break; \
                     }
 
-#ifdef USE_IMAP 
+#ifdef USE_IMAP
 /* the error message returned here could be better. */
 #define CHECK_IMAP_ACL(aclbit) if (Context->magic == M_IMAP) \
                if (mutt_bit_isset (((IMAP_DATA *)Context->data)->capabilities, ACL) \
@@ -91,8 +93,7 @@ static const char *Function_not_permitted_in_attach_message_mode = N_("Function
                }
 #endif
 
-struct q_class_t
-{
+struct q_class_t {
   int length;
   int index;
   int color;
@@ -101,15 +102,13 @@ struct q_class_t
   struct q_class_t *down, *up;
 };
 
-struct syntax_t
-{
+struct syntax_t {
   int color;
   int first;
   int last;
 };
 
-struct line_t
-{
+struct line_t {
   long offset;
   short type;
   short continuation;
@@ -141,7 +140,7 @@ static struct resize {
   int line;
   int SearchCompiled;
   int SearchBack;
-} *Resize = NULL;
+}     *Resize = NULL;
 #endif
 
 #define NumSigLines 4
@@ -150,8 +149,7 @@ static int check_sig (const char *s, struct line_t *info, int n)
 {
   int count = 0;
 
-  while (n > 0 && count <= NumSigLines)
-  {
+  while (n > 0 && count <= NumSigLines) {
     if (info[n].type != MT_COLOR_SIGNATURE)
       break;
     count++;
@@ -161,13 +159,11 @@ static int check_sig (const char *s, struct line_t *info, int n)
   if (count == 0)
     return (-1);
 
-  if (count > NumSigLines)
-  {
+  if (count > NumSigLines) {
     /* check for a blank line */
-    while (*s)
-    {
+    while (*s) {
       if (!ISSPACE (*s))
-       return 0;
+        return 0;
       s++;
     }
 
@@ -178,21 +174,19 @@ static int check_sig (const char *s, struct line_t *info, int n)
 }
 
 static void
-resolve_color (struct line_t *lineInfo, int n, int cnt, int flags, int special,
-    ansi_attr *a)
+resolve_color (struct line_t *lineInfo, int n, int cnt, int flags,
+               int special, ansi_attr * a)
 {
-  int def_color;               /* color without syntax hilight */
-  int color;                   /* final color */
-  static int last_color;       /* last color set */
+  int def_color;                /* color without syntax hilight */
+  int color;                    /* final color */
+  static int last_color;        /* last color set */
   int search = 0, i, m;
 
   if (!cnt)
-    last_color = -1;           /* force attrset() */
+    last_color = -1;            /* force attrset() */
 
-  if (lineInfo[n].continuation)
-  {
-    if (!cnt && option (OPTMARKERS))
-    {
+  if (lineInfo[n].continuation) {
+    if (!cnt && option (OPTMARKERS)) {
       SETCOLOR (MT_COLOR_MARKERS);
       addch ('+');
       last_color = ColorDefs[MT_COLOR_MARKERS];
@@ -209,128 +203,110 @@ resolve_color (struct line_t *lineInfo, int n, int cnt, int flags, int special,
   else
     def_color = ColorDefs[lineInfo[m].type];
 
-  if ((flags & M_SHOWCOLOR) && lineInfo[m].type == MT_COLOR_QUOTED)
-  {
+  if ((flags & M_SHOWCOLOR) && lineInfo[m].type == MT_COLOR_QUOTED) {
     struct q_class_t *class = lineInfo[m].quote;
 
-    if (class)
-    {
+    if (class) {
       def_color = class->color;
 
-      while (class && class->length > cnt)
-      {
-       def_color = class->color;
-       class = class->up;
+      while (class && class->length > cnt) {
+        def_color = class->color;
+        class = class->up;
       }
     }
   }
 
   color = def_color;
-  if (flags & M_SHOWCOLOR)
-  {
-    for (i = 0; i < lineInfo[m].chunks; i++)
-    {
+  if (flags & M_SHOWCOLOR) {
+    for (i = 0; i < lineInfo[m].chunks; i++) {
       /* we assume the chunks are sorted */
       if (cnt > (lineInfo[m].syntax)[i].last)
-       continue;
+        continue;
       if (cnt < (lineInfo[m].syntax)[i].first)
-       break;
-      if (cnt != (lineInfo[m].syntax)[i].last)
-      {
-       color = (lineInfo[m].syntax)[i].color;
-       break;
+        break;
+      if (cnt != (lineInfo[m].syntax)[i].last) {
+        color = (lineInfo[m].syntax)[i].color;
+        break;
       }
       /* don't break here, as cnt might be 
        * in the next chunk as well */
     }
   }
 
-  if (flags & M_SEARCH)
-  {
-    for (i = 0; i < lineInfo[m].search_cnt; i++)
-    {
+  if (flags & M_SEARCH) {
+    for (i = 0; i < lineInfo[m].search_cnt; i++) {
       if (cnt > (lineInfo[m].search)[i].last)
-       continue;
+        continue;
       if (cnt < (lineInfo[m].search)[i].first)
-       break;
-      if (cnt != (lineInfo[m].search)[i].last)
-      {
-       color = ColorDefs[MT_COLOR_SEARCH];
-       search = 1;
-       break;
+        break;
+      if (cnt != (lineInfo[m].search)[i].last) {
+        color = ColorDefs[MT_COLOR_SEARCH];
+        search = 1;
+        break;
       }
     }
   }
 
   /* handle "special" bold & underlined characters */
-  if (special || a->attr)
-  {
+  if (special || a->attr) {
 #ifdef HAVE_COLOR
-    if ((a->attr & ANSI_COLOR))
-    {
+    if ((a->attr & ANSI_COLOR)) {
       if (a->pair == -1)
-       a->pair = mutt_alloc_color (a->fg, a->bg);
+        a->pair = mutt_alloc_color (a->fg, a->bg);
       color = a->pair;
       if (a->attr & ANSI_BOLD)
-         color |= A_BOLD;
+        color |= A_BOLD;
     }
     else
 #endif
-      if ((special & A_BOLD) || (a->attr & ANSI_BOLD))
-    {
+    if ((special & A_BOLD) || (a->attr & ANSI_BOLD)) {
       if (ColorDefs[MT_COLOR_BOLD] && !search)
-       color = ColorDefs[MT_COLOR_BOLD];
+        color = ColorDefs[MT_COLOR_BOLD];
       else
-       color ^= A_BOLD;
+        color ^= A_BOLD;
     }
-    if ((special & A_UNDERLINE) || (a->attr & ANSI_UNDERLINE))
-    {
+    if ((special & A_UNDERLINE) || (a->attr & ANSI_UNDERLINE)) {
       if (ColorDefs[MT_COLOR_UNDERLINE] && !search)
-       color = ColorDefs[MT_COLOR_UNDERLINE];
+        color = ColorDefs[MT_COLOR_UNDERLINE];
       else
-       color ^= A_UNDERLINE;
+        color ^= A_UNDERLINE;
     }
-    else if (a->attr & ANSI_REVERSE) 
-    {
+    else if (a->attr & ANSI_REVERSE) {
       color ^= A_REVERSE;
     }
-    else if (a->attr & ANSI_BLINK) 
-    {
+    else if (a->attr & ANSI_BLINK) {
       color ^= A_BLINK;
     }
-    else if (a->attr & ANSI_OFF)
-    {
+    else if (a->attr & ANSI_OFF) {
       a->attr = 0;
     }
   }
 
-  if (color != last_color)
-  {
+  if (color != last_color) {
     attrset (color);
     last_color = color;
   }
 }
 
-static void
-append_line (struct line_t *lineInfo, int n, int cnt)
+static void append_line (struct line_t *lineInfo, int n, int cnt)
 {
   int m;
 
-  lineInfo[n+1].type = lineInfo[n].type;
-  (lineInfo[n+1].syntax)[0].color = (lineInfo[n].syntax)[0].color;
-  lineInfo[n+1].continuation = 1;
+  lineInfo[n + 1].type = lineInfo[n].type;
+  (lineInfo[n + 1].syntax)[0].color = (lineInfo[n].syntax)[0].color;
+  lineInfo[n + 1].continuation = 1;
 
   /* find the real start of the line */
   for (m = n; m >= 0; m--)
-    if (lineInfo[m].continuation == 0) break;
+    if (lineInfo[m].continuation == 0)
+      break;
 
-  (lineInfo[n+1].syntax)[0].first = m;
-  (lineInfo[n+1].syntax)[0].last = (lineInfo[n].continuation) ? 
+  (lineInfo[n + 1].syntax)[0].first = m;
+  (lineInfo[n + 1].syntax)[0].last = (lineInfo[n].continuation) ?
     cnt + (lineInfo[n].syntax)[0].last : cnt;
 }
 
-static void
-new_class_color (struct q_class_t *class, int *q_level)
+static void new_class_color (struct q_class_t *class, int *q_level)
 {
   class->index = (*q_level)++;
   class->color = ColorQuote[class->index % ColorQuoteUsed];
@@ -338,17 +314,15 @@ new_class_color (struct q_class_t *class, int *q_level)
 
 static void
 shift_class_colors (struct q_class_t *QuoteList, struct q_class_t *new_class,
-                     int index, int *q_level)
+                    int index, int *q_level)
 {
-  struct q_class_t * q_list;
+  struct q_class_t *q_list;
 
   q_list = QuoteList;
   new_class->index = -1;
 
-  while (q_list)
-  {
-    if (q_list->index >= index)
-    {
+  while (q_list) {
+    if (q_list->index >= index) {
       q_list->index++;
       q_list->color = ColorQuote[q_list->index % ColorQuoteUsed];
     }
@@ -356,16 +330,14 @@ shift_class_colors (struct q_class_t *QuoteList, struct q_class_t *new_class,
       q_list = q_list->down;
     else if (q_list->next)
       q_list = q_list->next;
-    else
-    {
-      while (!q_list->next)
-      {
-       q_list = q_list->up;
-       if (q_list == NULL)
-         break;
+    else {
+      while (!q_list->next) {
+        q_list = q_list->up;
+        if (q_list == NULL)
+          break;
       }
       if (q_list)
-       q_list = q_list->next;
+        q_list = q_list->next;
     }
   }
 
@@ -374,13 +346,11 @@ shift_class_colors (struct q_class_t *QuoteList, struct q_class_t *new_class,
   (*q_level)++;
 }
 
-static void
-cleanup_quote (struct q_class_t **QuoteList)
+static void cleanup_quote (struct q_class_t **QuoteList)
 {
   struct q_class_t *ptr;
 
-  while (*QuoteList)
-  {
+  while (*QuoteList) {
     if ((*QuoteList)->down)
       cleanup_quote (&((*QuoteList)->down));
     ptr = (*QuoteList)->next;
@@ -393,9 +363,9 @@ cleanup_quote (struct q_class_t **QuoteList)
   return;
 }
 
-static struct q_class_t *
-classify_quote (struct q_class_t **QuoteList, const char *qptr,
-               int length, int *force_redraw, int *q_level)
+static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
+                                         const char *qptr, int length,
+                                         int *force_redraw, int *q_level)
 {
   struct q_class_t *q_list = *QuoteList;
   struct q_class_t *class = NULL, *tmp = NULL, *ptr, *save;
@@ -403,12 +373,10 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr,
   int offset, tail_lng;
   int index = -1;
 
-  if (ColorQuoteUsed <= 1)
-  {
+  if (ColorQuoteUsed <= 1) {
     /* not much point in classifying quotes... */
 
-    if (*QuoteList == NULL)
-    {
+    if (*QuoteList == NULL) {
       class = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
       class->color = ColorQuote[0];
       *QuoteList = class;
@@ -419,270 +387,250 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr,
   /* Did I mention how much I like emulating Lisp in C? */
 
   /* classify quoting prefix */
-  while (q_list)
-  {
-    if (length <= q_list->length)
-    {
+  while (q_list) {
+    if (length <= q_list->length) {
       /* case 1: check the top level nodes */
 
-      if (mutt_strncmp (qptr, q_list->prefix, length) == 0)
-      {
-       if (length == q_list->length)
-         return q_list;        /* same prefix: return the current class */
-
-       /* found shorter prefix */
-       if (tmp == NULL)
-       {
-         /* add a node above q_list */
-         tmp = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
-         tmp->prefix = (char *) safe_calloc (1, length + 1);
-         strncpy (tmp->prefix, qptr, length);
-         tmp->length = length;
-
-         /* replace q_list by tmp in the top level list */
-         if (q_list->next)
-         {
-           tmp->next = q_list->next;
-           q_list->next->prev = tmp;
-         }
-         if (q_list->prev)
-         {
-           tmp->prev = q_list->prev;
-           q_list->prev->next = tmp;
-         }
-
-         /* make q_list a child of tmp */
-         tmp->down = q_list;
-         q_list->up = tmp;
-
-         /* q_list has no siblings for now */
-         q_list->next = NULL;
-         q_list->prev = NULL;
-
-         /* update the root if necessary */
-         if (q_list == *QuoteList)
-           *QuoteList = tmp;
-
-         index = q_list->index;
-
-         /* tmp should be the return class too */
-         class = tmp;
-
-         /* next class to test; if tmp is a shorter prefix for another
-          * node, that node can only be in the top level list, so don't
-          * go down after this point
-          */
-         q_list = tmp->next;
-       }
-       else
-       {
-         /* found another branch for which tmp is a shorter prefix */
-
-         /* save the next sibling for later */
-         save = q_list->next;
-
-         /* unlink q_list from the top level list */
-         if (q_list->next)
-           q_list->next->prev = q_list->prev;
-         if (q_list->prev)
-           q_list->prev->next = q_list->next;
-
-         /* at this point, we have a tmp->down; link q_list to it */
-         ptr = tmp->down;
-         /* sibling order is important here, q_list should be linked last */
-         while (ptr->next)
-           ptr = ptr->next;
-         ptr->next = q_list;
-         q_list->next = NULL;
-         q_list->prev = ptr;
-         q_list->up = tmp;
-
-         index = q_list->index;
-
-         /* next class to test; as above, we shouldn't go down */
-         q_list = save;
-       }
-
-       /* we found a shorter prefix, so certain quotes have changed classes */
-       *force_redraw = 1;
-       continue;
+      if (mutt_strncmp (qptr, q_list->prefix, length) == 0) {
+        if (length == q_list->length)
+          return q_list;        /* same prefix: return the current class */
+
+        /* found shorter prefix */
+        if (tmp == NULL) {
+          /* add a node above q_list */
+          tmp =
+            (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
+          tmp->prefix = (char *) safe_calloc (1, length + 1);
+          strncpy (tmp->prefix, qptr, length);
+          tmp->length = length;
+
+          /* replace q_list by tmp in the top level list */
+          if (q_list->next) {
+            tmp->next = q_list->next;
+            q_list->next->prev = tmp;
+          }
+          if (q_list->prev) {
+            tmp->prev = q_list->prev;
+            q_list->prev->next = tmp;
+          }
+
+          /* make q_list a child of tmp */
+          tmp->down = q_list;
+          q_list->up = tmp;
+
+          /* q_list has no siblings for now */
+          q_list->next = NULL;
+          q_list->prev = NULL;
+
+          /* update the root if necessary */
+          if (q_list == *QuoteList)
+            *QuoteList = tmp;
+
+          index = q_list->index;
+
+          /* tmp should be the return class too */
+          class = tmp;
+
+          /* next class to test; if tmp is a shorter prefix for another
+           * node, that node can only be in the top level list, so don't
+           * go down after this point
+           */
+          q_list = tmp->next;
+        }
+        else {
+          /* found another branch for which tmp is a shorter prefix */
+
+          /* save the next sibling for later */
+          save = q_list->next;
+
+          /* unlink q_list from the top level list */
+          if (q_list->next)
+            q_list->next->prev = q_list->prev;
+          if (q_list->prev)
+            q_list->prev->next = q_list->next;
+
+          /* at this point, we have a tmp->down; link q_list to it */
+          ptr = tmp->down;
+          /* sibling order is important here, q_list should be linked last */
+          while (ptr->next)
+            ptr = ptr->next;
+          ptr->next = q_list;
+          q_list->next = NULL;
+          q_list->prev = ptr;
+          q_list->up = tmp;
+
+          index = q_list->index;
+
+          /* next class to test; as above, we shouldn't go down */
+          q_list = save;
+        }
+
+        /* we found a shorter prefix, so certain quotes have changed classes */
+        *force_redraw = 1;
+        continue;
       }
-      else
-      {
-       /* shorter, but not a substring of the current class: try next */
-       q_list = q_list->next;
-       continue;
+      else {
+        /* shorter, but not a substring of the current class: try next */
+        q_list = q_list->next;
+        continue;
       }
     }
-    else
-    {
+    else {
       /* case 2: try subclassing the current top level node */
-      
+
       /* tmp != NULL means we already found a shorter prefix at case 1 */
-      if (tmp == NULL && mutt_strncmp (qptr, q_list->prefix, q_list->length) == 0)
-      {
-       /* ok, it's a subclass somewhere on this branch */
-
-       ptr = q_list;
-       offset = q_list->length;
-
-       q_list = q_list->down;
-       tail_lng = length - offset;
-       tail_qptr = (char *) qptr + offset;
-
-       while (q_list)
-       {
-         if (length <= q_list->length)
-         {
-           if (mutt_strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng) == 0)
-           {
-             /* same prefix: return the current class */
-             if (length == q_list->length)
-               return q_list;
-
-             /* found shorter common prefix */
-             if (tmp == NULL)
-             {
-               /* add a node above q_list */
-               tmp = (struct q_class_t *) safe_calloc (1, 
-                                           sizeof (struct q_class_t));
-               tmp->prefix = (char *) safe_calloc (1, length + 1);
-               strncpy (tmp->prefix, qptr, length);
-               tmp->length = length;
-                       
-               /* replace q_list by tmp */
-               if (q_list->next)
-               {
-                 tmp->next = q_list->next;
-                 q_list->next->prev = tmp;
-               }
-               if (q_list->prev)
-               {
-                 tmp->prev = q_list->prev;
-                 q_list->prev->next = tmp;
-               }
+      if (tmp == NULL
+          && mutt_strncmp (qptr, q_list->prefix, q_list->length) == 0) {
+        /* ok, it's a subclass somewhere on this branch */
+
+        ptr = q_list;
+        offset = q_list->length;
+
+        q_list = q_list->down;
+        tail_lng = length - offset;
+        tail_qptr = (char *) qptr + offset;
+
+        while (q_list) {
+          if (length <= q_list->length) {
+            if (mutt_strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng)
+                == 0) {
+              /* same prefix: return the current class */
+              if (length == q_list->length)
+                return q_list;
+
+              /* found shorter common prefix */
+              if (tmp == NULL) {
+                /* add a node above q_list */
+                tmp = (struct q_class_t *) safe_calloc (1,
+                                                        sizeof (struct
+                                                                q_class_t));
+                tmp->prefix = (char *) safe_calloc (1, length + 1);
+                strncpy (tmp->prefix, qptr, length);
+                tmp->length = length;
+
+                /* replace q_list by tmp */
+                if (q_list->next) {
+                  tmp->next = q_list->next;
+                  q_list->next->prev = tmp;
+                }
+                if (q_list->prev) {
+                  tmp->prev = q_list->prev;
+                  q_list->prev->next = tmp;
+                }
+
+                /* make q_list a child of tmp */
+                tmp->down = q_list;
+                tmp->up = q_list->up;
+                q_list->up = tmp;
+                if (tmp->up->down == q_list)
+                  tmp->up->down = tmp;
+
+                /* q_list has no siblings */
+                q_list->next = NULL;
+                q_list->prev = NULL;
+
+                index = q_list->index;
+
+                /* tmp should be the return class too */
+                class = tmp;
+
+                /* next class to test */
+                q_list = tmp->next;
+              }
+              else {
+                /* found another branch for which tmp is a shorter prefix */
+
+                /* save the next sibling for later */
+                save = q_list->next;
+
+                /* unlink q_list from the top level list */
+                if (q_list->next)
+                  q_list->next->prev = q_list->prev;
+                if (q_list->prev)
+                  q_list->prev->next = q_list->next;
+
+                /* at this point, we have a tmp->down; link q_list to it */
+                ptr = tmp->down;
+                while (ptr->next)
+                  ptr = ptr->next;
+                ptr->next = q_list;
+                q_list->next = NULL;
+                q_list->prev = ptr;
+                q_list->up = tmp;
+
+                index = q_list->index;
+
+                /* next class to test */
+                q_list = save;
+              }
+
+              /* we found a shorter prefix, so we need a redraw */
+              *force_redraw = 1;
+              continue;
+            }
+            else {
+              q_list = q_list->next;
+              continue;
+            }
+          }
+          else {
+            /* longer than the current prefix: try subclassing it */
+            if (tmp == NULL
+                && mutt_strncmp (tail_qptr, (q_list->prefix) + offset,
+                                 q_list->length - offset) == 0) {
+              /* still a subclass: go down one level */
+              ptr = q_list;
+              offset = q_list->length;
+
+              q_list = q_list->down;
+              tail_lng = length - offset;
+              tail_qptr = (char *) qptr + offset;
+
+              continue;
+            }
+            else {
+              /* nope, try the next prefix */
+              q_list = q_list->next;
+              continue;
+            }
+          }
+        }
+
+        /* still not found so far: add it as a sibling to the current node */
+        if (class == NULL) {
+          tmp =
+            (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
+          tmp->prefix = (char *) safe_calloc (1, length + 1);
+          strncpy (tmp->prefix, qptr, length);
+          tmp->length = length;
+
+          if (ptr->down) {
+            tmp->next = ptr->down;
+            ptr->down->prev = tmp;
+          }
+          ptr->down = tmp;
+          tmp->up = ptr;
+
+          new_class_color (tmp, q_level);
+
+          return tmp;
+        }
+        else {
+          if (index != -1)
+            shift_class_colors (*QuoteList, tmp, index, q_level);
 
-               /* make q_list a child of tmp */
-               tmp->down = q_list;
-               tmp->up = q_list->up;
-               q_list->up = tmp;
-               if (tmp->up->down == q_list)
-                 tmp->up->down = tmp;
-
-               /* q_list has no siblings */
-               q_list->next = NULL;
-               q_list->prev = NULL;
-                              
-               index = q_list->index;
-
-               /* tmp should be the return class too */
-               class = tmp;
-
-               /* next class to test */
-               q_list = tmp->next;
-             }
-             else
-             {
-               /* found another branch for which tmp is a shorter prefix */
-
-               /* save the next sibling for later */
-               save = q_list->next;
-
-               /* unlink q_list from the top level list */
-               if (q_list->next)
-                 q_list->next->prev = q_list->prev;
-               if (q_list->prev)
-                 q_list->prev->next = q_list->next;
-
-               /* at this point, we have a tmp->down; link q_list to it */
-               ptr = tmp->down;
-               while (ptr->next)
-                 ptr = ptr->next;
-               ptr->next = q_list;
-               q_list->next = NULL;
-               q_list->prev = ptr;
-               q_list->up = tmp;
-
-               index = q_list->index;
-
-               /* next class to test */
-               q_list = save;
-             }
-
-             /* we found a shorter prefix, so we need a redraw */
-             *force_redraw = 1;
-             continue;
-           }
-           else
-           {
-             q_list = q_list->next;
-             continue;
-           }
-         }
-         else
-         {
-           /* longer than the current prefix: try subclassing it */
-           if (tmp == NULL && mutt_strncmp (tail_qptr, (q_list->prefix) + offset,
-                         q_list->length - offset) == 0)
-           {
-             /* still a subclass: go down one level */
-             ptr = q_list;
-             offset = q_list->length;
-
-             q_list = q_list->down;
-             tail_lng = length - offset;
-             tail_qptr = (char *) qptr + offset;
-
-             continue;
-           }
-           else
-           {
-             /* nope, try the next prefix */
-             q_list = q_list->next;
-             continue;
-           }
-         }
-       }
-
-       /* still not found so far: add it as a sibling to the current node */
-       if (class == NULL)
-       {
-         tmp = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
-         tmp->prefix = (char *) safe_calloc (1, length + 1);
-         strncpy (tmp->prefix, qptr, length);
-         tmp->length = length;
-
-         if (ptr->down)
-         {
-           tmp->next = ptr->down;
-           ptr->down->prev = tmp;
-         }
-         ptr->down = tmp;
-         tmp->up = ptr;
-
-         new_class_color (tmp, q_level);
-
-         return tmp;
-       }
-       else
-       {
-         if (index != -1)
-           shift_class_colors (*QuoteList, tmp, index, q_level);
-
-         return class;
-       }
+          return class;
+        }
       }
-      else
-      {
-       /* nope, try the next prefix */
-       q_list = q_list->next;
-       continue;
+      else {
+        /* nope, try the next prefix */
+        q_list = q_list->next;
+        continue;
       }
     }
   }
 
-  if (class == NULL)
-  {
+  if (class == NULL) {
     /* not found so far: add it as a top level class */
     class = (struct q_class_t *) safe_calloc (1, sizeof (struct q_class_t));
     class->prefix = (char *) safe_calloc (1, length + 1);
@@ -690,8 +638,7 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr,
     class->length = length;
     new_class_color (class, q_level);
 
-    if (*QuoteList)
-    {
+    if (*QuoteList) {
       class->next = *QuoteList;
       (*QuoteList)->prev = class;
     }
@@ -708,39 +655,34 @@ static int check_attachment_marker (char *);
 
 static void
 resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
-               struct q_class_t **QuoteList, int *q_level, int *force_redraw,
-               int q_classify)
+               struct q_class_t **QuoteList, int *q_level, int *force_redraw,
+               int q_classify)
 {
   COLOR_LINE *color_line;
   regmatch_t pmatch[1], smatch[1];
   int found, offset, null_rx, i;
 
-  if (n == 0 || ISHEADER (lineInfo[n-1].type))
-  {
+  if (n == 0 || ISHEADER (lineInfo[n - 1].type)) {
     if (buf[0] == '\n')
       lineInfo[n].type = MT_COLOR_NORMAL;
-    else if (n > 0 && (buf[0] == ' ' || buf[0] == '\t'))
-    {
-      lineInfo[n].type = lineInfo[n-1].type; /* wrapped line */
-      (lineInfo[n].syntax)[0].color = (lineInfo[n-1].syntax)[0].color;
+    else if (n > 0 && (buf[0] == ' ' || buf[0] == '\t')) {
+      lineInfo[n].type = lineInfo[n - 1].type;  /* wrapped line */
+      (lineInfo[n].syntax)[0].color = (lineInfo[n - 1].syntax)[0].color;
     }
-    else
-    {
+    else {
       lineInfo[n].type = MT_COLOR_HDEFAULT;
       color_line = ColorHdrList;
-      while (color_line)
-      {
-       if (REGEXEC (color_line->rx, buf) == 0)
-       {
-         lineInfo[n].type = MT_COLOR_HEADER;
-         lineInfo[n].syntax[0].color = color_line->pair;
-         break;
-       }
-       color_line = color_line->next;
+      while (color_line) {
+        if (REGEXEC (color_line->rx, buf) == 0) {
+          lineInfo[n].type = MT_COLOR_HEADER;
+          lineInfo[n].syntax[0].color = color_line->pair;
+          break;
+        }
+        color_line = color_line->next;
       }
     }
   }
-  else if (mutt_strncmp ("\033[0m", raw, 4) == 0)      /* a little hack... */
+  else if (mutt_strncmp ("\033[0m", raw, 4) == 0)       /* a little hack... */
     lineInfo[n].type = MT_COLOR_NORMAL;
 #if 0
   else if (mutt_strncmp ("[-- ", buf, 4) == 0)
@@ -749,63 +691,56 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
   else if (check_attachment_marker ((char *) raw) == 0)
     lineInfo[n].type = MT_COLOR_ATTACHMENT;
 #endif
-  else if (mutt_strcmp ("-- \n", buf) == 0 || mutt_strcmp ("-- \r\n", buf) == 0)
-  {
+  else if (mutt_strcmp ("-- \n", buf) == 0
+           || mutt_strcmp ("-- \r\n", buf) == 0) {
     i = n + 1;
 
     lineInfo[n].type = MT_COLOR_SIGNATURE;
     while (i < last && check_sig (buf, lineInfo, i - 1) == 0 &&
-          (lineInfo[i].type == MT_COLOR_NORMAL ||
-           lineInfo[i].type == MT_COLOR_QUOTED ||
-           lineInfo[i].type == MT_COLOR_HEADER))
-      {
-       /* oops... */
-       if (lineInfo[i].chunks)
-       {
-         lineInfo[i].chunks = 0;
-         safe_realloc (&(lineInfo[n].syntax), 
-                       sizeof (struct syntax_t));
-       }
-       lineInfo[i++].type = MT_COLOR_SIGNATURE;
+           (lineInfo[i].type == MT_COLOR_NORMAL ||
+            lineInfo[i].type == MT_COLOR_QUOTED ||
+            lineInfo[i].type == MT_COLOR_HEADER)) {
+      /* oops... */
+      if (lineInfo[i].chunks) {
+        lineInfo[i].chunks = 0;
+        safe_realloc (&(lineInfo[n].syntax), sizeof (struct syntax_t));
       }
+      lineInfo[i++].type = MT_COLOR_SIGNATURE;
+    }
   }
   else if (check_sig (buf, lineInfo, n - 1) == 0)
     lineInfo[n].type = MT_COLOR_SIGNATURE;
-  else if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
-  {
-    if (regexec ((regex_t *) Smileys.rx, buf, 1, smatch, 0) == 0)
-    {
-      if (smatch[0].rm_so > 0)
-      {
-       char c;
-
-       /* hack to avoid making an extra copy of buf */
-       c = buf[smatch[0].rm_so];
-       buf[smatch[0].rm_so] = 0;
-
-       if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
-       {
-         if (q_classify && lineInfo[n].quote == NULL)
-           lineInfo[n].quote = classify_quote (QuoteList,
-                                 buf + pmatch[0].rm_so,
-                                 pmatch[0].rm_eo - pmatch[0].rm_so,
-                                 force_redraw, q_level);
-         lineInfo[n].type = MT_COLOR_QUOTED;
-       }
-       else
-         lineInfo[n].type = MT_COLOR_NORMAL;
-
-       buf[smatch[0].rm_so] = c;
+  else if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0) {
+    if (regexec ((regex_t *) Smileys.rx, buf, 1, smatch, 0) == 0) {
+      if (smatch[0].rm_so > 0) {
+        char c;
+
+        /* hack to avoid making an extra copy of buf */
+        c = buf[smatch[0].rm_so];
+        buf[smatch[0].rm_so] = 0;
+
+        if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0) {
+          if (q_classify && lineInfo[n].quote == NULL)
+            lineInfo[n].quote = classify_quote (QuoteList,
+                                                buf + pmatch[0].rm_so,
+                                                pmatch[0].rm_eo -
+                                                pmatch[0].rm_so, force_redraw,
+                                                q_level);
+          lineInfo[n].type = MT_COLOR_QUOTED;
+        }
+        else
+          lineInfo[n].type = MT_COLOR_NORMAL;
+
+        buf[smatch[0].rm_so] = c;
       }
       else
-       lineInfo[n].type = MT_COLOR_NORMAL;
+        lineInfo[n].type = MT_COLOR_NORMAL;
     }
-    else
-    {
+    else {
       if (q_classify && lineInfo[n].quote == NULL)
-       lineInfo[n].quote = classify_quote (QuoteList, buf + pmatch[0].rm_so,
-                             pmatch[0].rm_eo - pmatch[0].rm_so,
-                             force_redraw, q_level);
+        lineInfo[n].quote = classify_quote (QuoteList, buf + pmatch[0].rm_so,
+                                            pmatch[0].rm_eo - pmatch[0].rm_so,
+                                            force_redraw, q_level);
       lineInfo[n].type = MT_COLOR_QUOTED;
     }
   }
@@ -813,66 +748,60 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last,
     lineInfo[n].type = MT_COLOR_NORMAL;
 
   /* body patterns */
-  if (lineInfo[n].type == MT_COLOR_NORMAL || 
-      lineInfo[n].type == MT_COLOR_QUOTED)
-  {
+  if (lineInfo[n].type == MT_COLOR_NORMAL ||
+      lineInfo[n].type == MT_COLOR_QUOTED) {
     i = 0;
 
     offset = 0;
     lineInfo[n].chunks = 0;
-    do
-    {
+    do {
       if (!buf[offset])
-       break;
+        break;
 
       found = 0;
       null_rx = 0;
       color_line = ColorBodyList;
-      while (color_line)
-      {
-       if (regexec (&color_line->rx, buf + offset, 1, pmatch,
-                    (offset ? REG_NOTBOL : 0)) == 0)
-       {
-         if (pmatch[0].rm_eo != pmatch[0].rm_so)
-         {
-           if (!found)
-           {
-             if (++(lineInfo[n].chunks) > 1)
-               safe_realloc (&(lineInfo[n].syntax), 
-                             (lineInfo[n].chunks) * sizeof (struct syntax_t));
-           }
-           i = lineInfo[n].chunks - 1;
-           pmatch[0].rm_so += offset;
-           pmatch[0].rm_eo += offset;
-           if (!found ||
-               pmatch[0].rm_so < (lineInfo[n].syntax)[i].first ||
-               (pmatch[0].rm_so == (lineInfo[n].syntax)[i].first &&
-                pmatch[0].rm_eo > (lineInfo[n].syntax)[i].last))
-           {
-             (lineInfo[n].syntax)[i].color = color_line->pair;
-             (lineInfo[n].syntax)[i].first = pmatch[0].rm_so;
-             (lineInfo[n].syntax)[i].last = pmatch[0].rm_eo;
-           }
-           found = 1;
-           null_rx = 0;
-         }
-         else
-           null_rx = 1; /* empty regexp; don't add it, but keep looking */
-       }
-       color_line = color_line->next;
+      while (color_line) {
+        if (regexec (&color_line->rx, buf + offset, 1, pmatch,
+                     (offset ? REG_NOTBOL : 0)) == 0) {
+          if (pmatch[0].rm_eo != pmatch[0].rm_so) {
+            if (!found) {
+              if (++(lineInfo[n].chunks) > 1)
+                safe_realloc (&(lineInfo[n].syntax),
+                              (lineInfo[n].chunks) *
+                              sizeof (struct syntax_t));
+            }
+            i = lineInfo[n].chunks - 1;
+            pmatch[0].rm_so += offset;
+            pmatch[0].rm_eo += offset;
+            if (!found ||
+                pmatch[0].rm_so < (lineInfo[n].syntax)[i].first ||
+                (pmatch[0].rm_so == (lineInfo[n].syntax)[i].first &&
+                 pmatch[0].rm_eo > (lineInfo[n].syntax)[i].last)) {
+              (lineInfo[n].syntax)[i].color = color_line->pair;
+              (lineInfo[n].syntax)[i].first = pmatch[0].rm_so;
+              (lineInfo[n].syntax)[i].last = pmatch[0].rm_eo;
+            }
+            found = 1;
+            null_rx = 0;
+          }
+          else
+            null_rx = 1;        /* empty regexp; don't add it, but keep looking */
+        }
+        color_line = color_line->next;
       }
 
       if (null_rx)
-       offset++; /* avoid degenerate cases */
+        offset++;               /* avoid degenerate cases */
       else
-       offset = (lineInfo[n].syntax)[i].last;
+        offset = (lineInfo[n].syntax)[i].last;
     } while (found || null_rx);
   }
 }
 
 static int is_ansi (unsigned char *buf)
 {
-  while (*buf && (isdigit(*buf) || *buf == ';'))
+  while (*buf && (isdigit (*buf) || *buf == ';'))
     buf++;
   return (*buf == 'm');
 }
@@ -880,89 +809,78 @@ static int is_ansi (unsigned char *buf)
 static int check_attachment_marker (char *p)
 {
   char *q = AttachmentMarker;
-  
-  for (;*p == *q && *q && *p && *q != '\a' && *p != '\a'; p++, q++)
-    ;
+
+  for (; *p == *q && *q && *p && *q != '\a' && *p != '\a'; p++, q++);
   return (int) (*p - *q);
 }
 
-static int grok_ansi(unsigned char *buf, int pos, ansi_attr *a)
+static int grok_ansi (unsigned char *buf, int pos, ansi_attr * a)
 {
   int x = pos;
 
-  while (isdigit(buf[x]) || buf[x] == ';')
+  while (isdigit (buf[x]) || buf[x] == ';')
     x++;
 
   /* Character Attributes */
-  if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm')
-  {
-    if (pos == x)
-    {
+  if (option (OPTALLOWANSI) && a != NULL && buf[x] == 'm') {
+    if (pos == x) {
 #ifdef HAVE_COLOR
       if (a->pair != -1)
-       mutt_free_color (a->fg, a->bg);
+        mutt_free_color (a->fg, a->bg);
 #endif
       a->attr = ANSI_OFF;
       a->pair = -1;
     }
-    while (pos < x)
-    {
-      if (buf[pos] == '1' && (pos+1 == x || buf[pos+1] == ';'))
-      {
-       a->attr |= ANSI_BOLD;
-       pos += 2;
-      } 
-      else if (buf[pos] == '4' && (pos+1 == x || buf[pos+1] == ';'))
-      {
-       a->attr |= ANSI_UNDERLINE;
-       pos += 2;
-      }
-      else if (buf[pos] == '5' && (pos+1 == x || buf[pos+1] == ';'))
-      {
-       a->attr |= ANSI_BLINK;
-       pos += 2;
-      }
-      else if (buf[pos] == '7' && (pos+1 == x || buf[pos+1] == ';'))
-      {
-       a->attr |= ANSI_REVERSE;
-       pos += 2;
-      }
-      else if (buf[pos] == '0' && (pos+1 == x || buf[pos+1] == ';'))
-      {
+    while (pos < x) {
+      if (buf[pos] == '1' && (pos + 1 == x || buf[pos + 1] == ';')) {
+        a->attr |= ANSI_BOLD;
+        pos += 2;
+      }
+      else if (buf[pos] == '4' && (pos + 1 == x || buf[pos + 1] == ';')) {
+        a->attr |= ANSI_UNDERLINE;
+        pos += 2;
+      }
+      else if (buf[pos] == '5' && (pos + 1 == x || buf[pos + 1] == ';')) {
+        a->attr |= ANSI_BLINK;
+        pos += 2;
+      }
+      else if (buf[pos] == '7' && (pos + 1 == x || buf[pos + 1] == ';')) {
+        a->attr |= ANSI_REVERSE;
+        pos += 2;
+      }
+      else if (buf[pos] == '0' && (pos + 1 == x || buf[pos + 1] == ';')) {
 #ifdef HAVE_COLOR
-       if (a->pair != -1)
-         mutt_free_color(a->fg,a->bg);
+        if (a->pair != -1)
+          mutt_free_color (a->fg, a->bg);
 #endif
-       a->attr = ANSI_OFF;
-       a->pair = -1;
-       pos += 2;
+        a->attr = ANSI_OFF;
+        a->pair = -1;
+        pos += 2;
       }
-      else if (buf[pos] == '3' && isdigit(buf[pos+1]))
-      {
+      else if (buf[pos] == '3' && isdigit (buf[pos + 1])) {
 #ifdef HAVE_COLOR
-       if (a->pair != -1)
-         mutt_free_color(a->fg,a->bg);
+        if (a->pair != -1)
+          mutt_free_color (a->fg, a->bg);
 #endif
-       a->pair = -1;
-       a->attr |= ANSI_COLOR;
-       a->fg = buf[pos+1] - '0';
-       pos += 3;
+        a->pair = -1;
+        a->attr |= ANSI_COLOR;
+        a->fg = buf[pos + 1] - '0';
+        pos += 3;
       }
-      else if (buf[pos] == '4' && isdigit(buf[pos+1]))
-      {
+      else if (buf[pos] == '4' && isdigit (buf[pos + 1])) {
 #ifdef HAVE_COLOR
-       if (a->pair != -1)
-         mutt_free_color(a->fg,a->bg);
+        if (a->pair != -1)
+          mutt_free_color (a->fg, a->bg);
 #endif
-       a->pair = -1;
-       a->attr |= ANSI_COLOR;
-       a->bg = buf[pos+1] - '0';
-       pos += 3;
+        a->pair = -1;
+        a->attr |= ANSI_COLOR;
+        a->bg = buf[pos + 1] - '0';
+        pos += 3;
       }
-      else 
-      {
-       while (pos < x && buf[pos] != ';') pos++;
-       pos++;
+      else {
+        while (pos < x && buf[pos] != ';')
+          pos++;
+        pos++;
       }
     }
   }
@@ -971,19 +889,17 @@ static int grok_ansi(unsigned char *buf, int pos, ansi_attr *a)
 }
 
 static int
-fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf, 
-            unsigned char *fmt, size_t blen, int *buf_ready)
+fill_buffer (FILE * f, long *last_pos, long offset, unsigned char *buf,
+             unsigned char *fmt, size_t blen, int *buf_ready)
 {
   unsigned char *p;
   static int b_read = 0;
 
-  if (*buf_ready == 0)
-  {
+  if (*buf_ready == 0) {
     buf[blen - 1] = 0;
     if (offset != *last_pos)
       fseek (f, offset, 0);
-    if (fgets ((char *) buf, blen - 1, f) == NULL)
-    {
+    if (fgets ((char *) buf, blen - 1, f) == NULL) {
       fmt[0] = 0;
       return (-1);
     }
@@ -993,33 +909,29 @@ fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf,
 
     /* copy "buf" to "fmt", but without bold and underline controls */
     p = buf;
-    while (*p)
-    {
-      if (*p == '\010' && (p > buf))
-      {
-       if (*(p+1) == '_')      /* underline */
-         p += 2;
-       else if (*(p+1))        /* bold or overstrike */
-       {
-         *(fmt-1) = *(p+1);
-         p += 2;
-       }
-       else                    /* ^H */
-         *fmt++ = *p++;
-      }
-      else if (*p == '\033' && *(p+1) == '[' && is_ansi (p + 2))
-      {
-       while (*p++ != 'm')     /* skip ANSI sequence */
-         ;
-      }
-      else if (*p == '\033' && *(p+1) == ']' && check_attachment_marker ((char *) p) == 0)
-      {
-       dprint (2, (debugfile, "fill_buffer: Seen attachment marker.\n"));
-       while (*p++ != '\a')    /* skip pseudo-ANSI sequence */
-         ;
+    while (*p) {
+      if (*p == '\010' && (p > buf)) {
+        if (*(p + 1) == '_')    /* underline */
+          p += 2;
+        else if (*(p + 1)) {    /* bold or overstrike */
+          *(fmt - 1) = *(p + 1);
+          p += 2;
+        }
+        else                    /* ^H */
+          *fmt++ = *p++;
+      }
+      else if (*p == '\033' && *(p + 1) == '[' && is_ansi (p + 2)) {
+        while (*p++ != 'm')     /* skip ANSI sequence */
+          ;
+      }
+      else if (*p == '\033' && *(p + 1) == ']'
+               && check_attachment_marker ((char *) p) == 0) {
+        dprint (2, (debugfile, "fill_buffer: Seen attachment marker.\n"));
+        while (*p++ != '\a')    /* skip pseudo-ANSI sequence */
+          ;
       }
       else
-       *fmt++ = *p++;
+        *fmt++ = *p++;
     }
     *fmt = 0;
   }
@@ -1033,55 +945,53 @@ fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf,
 
 
 static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
-                       int flags, ansi_attr *pa, int cnt,
-                       int *pspace, int *pvch, int *pcol, int *pspecial)
+                        int flags, ansi_attr * pa, int cnt,
+                        int *pspace, int *pvch, int *pcol, int *pspecial)
 {
-  int space = -1; /* index of the last space or TAB */
+  int space = -1;               /* index of the last space or TAB */
   int col = option (OPTMARKERS) ? (*lineInfo)[n].continuation : 0;
   int ch, vch, k, last_special = -1, special = 0, t;
   wchar_t wc;
   mbstate_t mbstate;
 
   int wrap_cols = COLS;
+
   if (!(flags & (M_SHOWFLAT)))
     wrap_cols -= WrapMargin;
   wrap_cols -= SidebarWidth;
 
   if (wrap_cols <= 0)
     wrap_cols = COLS;
-  
+
   /* FIXME: this should come from lineInfo */
-  memset(&mbstate, 0, sizeof(mbstate));
+  memset (&mbstate, 0, sizeof (mbstate));
 
-  for (ch = 0, vch = 0; ch < cnt; ch += k, vch += k)
-  {
+  for (ch = 0, vch = 0; ch < cnt; ch += k, vch += k) {
     /* Handle ANSI sequences */
-    while (cnt-ch >= 2 && buf[ch] == '\033' && buf[ch+1] == '[' &&
-          is_ansi (buf+ch+2))
-      ch = grok_ansi (buf, ch+2, pa) + 1;
+    while (cnt - ch >= 2 && buf[ch] == '\033' && buf[ch + 1] == '[' &&
+           is_ansi (buf + ch + 2))
+      ch = grok_ansi (buf, ch + 2, pa) + 1;
 
-    while (cnt-ch >= 2 && buf[ch] == '\033' && buf[ch+1] == ']' &&
-          check_attachment_marker ((char *) buf+ch) == 0)
-    {
+    while (cnt - ch >= 2 && buf[ch] == '\033' && buf[ch + 1] == ']' &&
+           check_attachment_marker ((char *) buf + ch) == 0) {
       while (buf[ch++] != '\a')
-       if (ch >= cnt)
-         break;
+        if (ch >= cnt)
+          break;
     }
 
     /* is anything left to do? */
     if (ch >= cnt)
       break;
-    
-    k = mbrtowc (&wc, (char *)buf+ch, cnt-ch, &mbstate);
-    if (k == -2 || k == -1)
-    {
+
+    k = mbrtowc (&wc, (char *) buf + ch, cnt - ch, &mbstate);
+    if (k == -2 || k == -1) {
       dprint (1, (debugfile, "%s:%d: mbrtowc returned %d; errno = %d.\n",
-                 __FILE__, __LINE__, k, errno));
+                  __FILE__, __LINE__, k, errno));
       if (col + 4 > wrap_cols)
-       break;
+        break;
       col += 4;
       if (pa)
-       printw ("\\%03o", buf[ch]);
+        printw ("\\%03o", buf[ch]);
       k = 1;
       continue;
     }
@@ -1090,96 +1000,86 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
 
     /* Handle backspace */
     special = 0;
-    if (IsWPrint (wc))
-    {
+    if (IsWPrint (wc)) {
       wchar_t wc1;
       mbstate_t mbstate1;
       int k1, k2;
 
       while ((wc1 = 0, mbstate1 = mbstate,
-             k1 = k + mbrtowc (&wc1, (char *)buf+ch+k, cnt-ch-k, &mbstate1),
-             k1 - k > 0 && wc1 == '\b') &&
-            (wc1 = 0,
-             k2 = mbrtowc (&wc1, (char *)buf+ch+k1, cnt-ch-k1, &mbstate1),
-             k2 > 0 && IsWPrint (wc1)))
-      {
-       if (wc == wc1)
-       {
-         special |= (wc == '_' && special & A_UNDERLINE)
-           ? A_UNDERLINE : A_BOLD;
-       }
-       else if (wc == '_' || wc1 == '_')
-       {
-         special |= A_UNDERLINE;
-         wc = (wc1 == '_') ? wc : wc1;
-       }
-       else
-       {
-         /* special = 0; / * overstrike: nothing to do! */
-         wc = wc1;
-       }
-       ch += k1;
-       k = k2;
-       mbstate = mbstate1;
+              k1 =
+              k + mbrtowc (&wc1, (char *) buf + ch + k, cnt - ch - k,
+                           &mbstate1), k1 - k > 0 && wc1 == '\b')
+             && (wc1 = 0, k2 =
+                 mbrtowc (&wc1, (char *) buf + ch + k1, cnt - ch - k1,
+                          &mbstate1), k2 > 0 && IsWPrint (wc1))) {
+        if (wc == wc1) {
+          special |= (wc == '_' && special & A_UNDERLINE)
+            ? A_UNDERLINE : A_BOLD;
+        }
+        else if (wc == '_' || wc1 == '_') {
+          special |= A_UNDERLINE;
+          wc = (wc1 == '_') ? wc : wc1;
+        }
+        else {
+          /* special = 0; / * overstrike: nothing to do! */
+          wc = wc1;
+        }
+        ch += k1;
+        k = k2;
+        mbstate = mbstate1;
       }
     }
 
     if (pa &&
-       ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) ||
-        special || last_special || pa->attr))
-    {
+        ((flags & (M_SHOWCOLOR | M_SEARCH | M_PAGER_MARKER)) ||
+         special || last_special || pa->attr)) {
       resolve_color (*lineInfo, n, vch, flags, special, pa);
       last_special = special;
     }
 
-    if (IsWPrint (wc))
-    {
+    if (IsWPrint (wc)) {
       if (wc == ' ')
-       space = ch;
+        space = ch;
       t = wcwidth (wc);
       if (col + t > wrap_cols)
-       break;
+        break;
       col += t;
       if (pa)
-       mutt_addwch (wc);
+        mutt_addwch (wc);
     }
     else if (wc == '\n')
       break;
-    else if (wc == '\t')
-    {
+    else if (wc == '\t') {
       space = ch;
       t = (col & ~7) + 8;
       if (t > wrap_cols)
-       break;
+        break;
       if (pa)
-       for (; col < t; col++)
-         addch (' ');
+        for (; col < t; col++)
+          addch (' ');
       else
-       col = t;
+        col = t;
     }
-    else if (wc < 0x20 || wc == 0x7f)
-    {
+    else if (wc < 0x20 || wc == 0x7f) {
       if (col + 2 > wrap_cols)
-       break;
+        break;
       col += 2;
       if (pa)
-       printw ("^%c", ('@' + wc) & 0x7f);
+        printw ("^%c", ('@' + wc) & 0x7f);
     }
-    else if (wc < 0x100)
-    {
+    else if (wc < 0x100) {
       if (col + 4 > wrap_cols)
-       break;
+        break;
       col += 4;
       if (pa)
-       printw ("\\%03o", wc);
+        printw ("\\%03o", wc);
     }
-    else
-    {
+    else {
       if (col + 1 > wrap_cols)
-       break;
+        break;
       ++col;
       if (pa)
-       addch (replacement_char ());
+        addch (replacement_char ());
     }
   }
   *pspace = space;
@@ -1207,9 +1107,9 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
  */
 
 static int
-display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n, 
-             int *last, int *max, int flags, struct q_class_t **QuoteList,
-             int *q_level, int *force_redraw, regex_t *SearchRE)
+display_line (FILE * f, long *last_pos, struct line_t **lineInfo, int n,
+              int *last, int *max, int flags, struct q_class_t **QuoteList,
+              int *q_level, int *force_redraw, regex_t * SearchRE)
 {
   unsigned char buf[LONG_STRING], fmt[LONG_STRING];
   unsigned char *buf_ptr = buf;
@@ -1219,52 +1119,51 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
   int offset;
   int def_color;
   int m;
-  ansi_attr a = {0,0,0,-1};
+  ansi_attr a = { 0, 0, 0, -1 };
   regmatch_t pmatch[1];
 
-  if (n == *last)
-  {
+  if (n == *last) {
     (*last)++;
     change_last = 1;
   }
 
-  if (*last == *max)
-  {
+  if (*last == *max) {
     safe_realloc (lineInfo, sizeof (struct line_t) * (*max += LINES));
-    for (ch = *last; ch < *max ; ch++)
-    {
+    for (ch = *last; ch < *max; ch++) {
       memset (&((*lineInfo)[ch]), 0, sizeof (struct line_t));
       (*lineInfo)[ch].type = -1;
       (*lineInfo)[ch].search_cnt = -1;
       (*lineInfo)[ch].syntax = safe_malloc (sizeof (struct syntax_t));
-      ((*lineInfo)[ch].syntax)[0].first = ((*lineInfo)[ch].syntax)[0].last = -1;
+      ((*lineInfo)[ch].syntax)[0].first = ((*lineInfo)[ch].syntax)[0].last =
+        -1;
     }
   }
 
   /* only do color hiliting if we are viewing a message */
-  if (flags & (M_SHOWCOLOR | M_TYPES))
-  {
-    if ((*lineInfo)[n].type == -1)
-    {
+  if (flags & (M_SHOWCOLOR | M_TYPES)) {
+    if ((*lineInfo)[n].type == -1) {
       /* determine the line class */
-      if (fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf), &buf_ready) < 0)
-      {
-       if (change_last)
-         (*last)--;
-       return (-1);
+      if (fill_buffer
+          (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf),
+           &buf_ready) < 0) {
+        if (change_last)
+          (*last)--;
+        return (-1);
       }
 
       resolve_types ((char *) fmt, (char *) buf, *lineInfo, n, *last,
-                     QuoteList, q_level, force_redraw, flags & M_SHOWCOLOR);
+                     QuoteList, q_level, force_redraw, flags & M_SHOWCOLOR);
 
       /* avoid race condition for continuation lines when scrolling up */
-      for (m = n + 1; m < *last && (*lineInfo)[m].offset && (*lineInfo)[m].continuation; m++)
-       (*lineInfo)[m].type = (*lineInfo)[n].type;
+      for (m = n + 1;
+           m < *last && (*lineInfo)[m].offset && (*lineInfo)[m].continuation;
+           m++)
+        (*lineInfo)[m].type = (*lineInfo)[n].type;
     }
 
     /* this also prevents searching through the hidden lines */
     if ((flags & M_HIDE) && (*lineInfo)[n].type == MT_COLOR_QUOTED)
-      flags = 0; /* M_NOSHOW */
+      flags = 0;                /* M_NOSHOW */
   }
 
   /* At this point, (*lineInfo[n]).quote may still be undefined. We 
@@ -1276,94 +1175,96 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
   if ((flags & M_SHOWCOLOR) && !(*lineInfo)[n].continuation &&
       (*lineInfo)[n].type == MT_COLOR_QUOTED && (*lineInfo)[n].quote == NULL)
   {
-    if (fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf), &buf_ready) < 0)
-    {
+    if (fill_buffer
+        (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf),
+         &buf_ready) < 0) {
       if (change_last)
-       (*last)--;
+        (*last)--;
       return (-1);
     }
     regexec ((regex_t *) QuoteRegexp.rx, (char *) fmt, 1, pmatch, 0);
     (*lineInfo)[n].quote = classify_quote (QuoteList,
-                           (char *) fmt + pmatch[0].rm_so,
-                           pmatch[0].rm_eo - pmatch[0].rm_so,
-                           force_redraw, q_level);
+                                           (char *) fmt + pmatch[0].rm_so,
+                                           pmatch[0].rm_eo - pmatch[0].rm_so,
+                                           force_redraw, q_level);
   }
 
-  if ((flags & M_SEARCH) && !(*lineInfo)[n].continuation && (*lineInfo)[n].search_cnt == -1) 
-  {
-    if (fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf), &buf_ready) < 0)
-    {
+  if ((flags & M_SEARCH) && !(*lineInfo)[n].continuation
+      && (*lineInfo)[n].search_cnt == -1) {
+    if (fill_buffer
+        (f, last_pos, (*lineInfo)[n].offset, buf, fmt, sizeof (buf),
+         &buf_ready) < 0) {
       if (change_last)
-       (*last)--;
+        (*last)--;
       return (-1);
     }
 
     offset = 0;
     (*lineInfo)[n].search_cnt = 0;
-    while (regexec (SearchRE, (char *) fmt + offset, 1, pmatch, (offset ? REG_NOTBOL : 0)) == 0)
-    {
+    while (regexec
+           (SearchRE, (char *) fmt + offset, 1, pmatch,
+            (offset ? REG_NOTBOL : 0)) == 0) {
       if (++((*lineInfo)[n].search_cnt) > 1)
-       safe_realloc (&((*lineInfo)[n].search),
-                     ((*lineInfo)[n].search_cnt) * sizeof (struct syntax_t));
+        safe_realloc (&((*lineInfo)[n].search),
+                      ((*lineInfo)[n].search_cnt) * sizeof (struct syntax_t));
       else
-       (*lineInfo)[n].search = safe_malloc (sizeof (struct syntax_t));
+        (*lineInfo)[n].search = safe_malloc (sizeof (struct syntax_t));
       pmatch[0].rm_so += offset;
       pmatch[0].rm_eo += offset;
-      ((*lineInfo)[n].search)[(*lineInfo)[n].search_cnt - 1].first = pmatch[0].rm_so;
-      ((*lineInfo)[n].search)[(*lineInfo)[n].search_cnt - 1].last = pmatch[0].rm_eo;
+      ((*lineInfo)[n].search)[(*lineInfo)[n].search_cnt - 1].first =
+        pmatch[0].rm_so;
+      ((*lineInfo)[n].search)[(*lineInfo)[n].search_cnt - 1].last =
+        pmatch[0].rm_eo;
 
       if (pmatch[0].rm_eo == pmatch[0].rm_so)
-       offset++; /* avoid degenerate cases */
+        offset++;               /* avoid degenerate cases */
       else
-       offset = pmatch[0].rm_eo;
+        offset = pmatch[0].rm_eo;
       if (!fmt[offset])
-       break;
+        break;
     }
   }
 
-  if (!(flags & M_SHOW) && (*lineInfo)[n+1].offset > 0)
-  {
+  if (!(flags & M_SHOW) && (*lineInfo)[n + 1].offset > 0) {
     /* we've already scanned this line, so just exit */
     return (0);
   }
-  if ((flags & M_SHOWCOLOR) && *force_redraw && (*lineInfo)[n+1].offset > 0)
-  {
+  if ((flags & M_SHOWCOLOR) && *force_redraw && (*lineInfo)[n + 1].offset > 0) {
     /* no need to try to display this line... */
-    return (1); /* fake display */
+    return (1);                 /* fake display */
   }
 
-  if ((b_read = fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt, 
-                             sizeof (buf), &buf_ready)) < 0)
-  {
+  if ((b_read = fill_buffer (f, last_pos, (*lineInfo)[n].offset, buf, fmt,
+                             sizeof (buf), &buf_ready)) < 0) {
     if (change_last)
       (*last)--;
     return (-1);
   }
 
   /* now chose a good place to break the line */
-  cnt = format_line (lineInfo, n, buf, flags, 0, b_read, &ch, &vch, &col, &special);
+  cnt =
+    format_line (lineInfo, n, buf, flags, 0, b_read, &ch, &vch, &col,
+                 &special);
   buf_ptr = buf + cnt;
 
   /* move the break point only if smart_wrap is set */
-  if (option (OPTWRAP))
-  {
-    if (cnt < b_read)
-    {
-      if (ch != -1 && buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n' && buf[cnt] != '\r')
-      {
-       buf_ptr = buf + ch;
-       /* skip trailing blanks */
-       while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
-         ch--;
-       cnt = ch + 1;
+  if (option (OPTWRAP)) {
+    if (cnt < b_read) {
+      if (ch != -1 && buf[cnt] != ' ' && buf[cnt] != '\t' && buf[cnt] != '\n'
+          && buf[cnt] != '\r') {
+        buf_ptr = buf + ch;
+        /* skip trailing blanks */
+        while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r'))
+          ch--;
+        cnt = ch + 1;
       }
       else
-       buf_ptr = buf + cnt; /* a very long word... */
+        buf_ptr = buf + cnt;    /* a very long word... */
     }
     if (!(flags & M_PAGER_NSKIP))
       /* skip leading blanks on the next line too */
-      while (*buf_ptr == ' ' || *buf_ptr == '\t') 
-       buf_ptr++;
+      while (*buf_ptr == ' ' || *buf_ptr == '\t')
+        buf_ptr++;
   }
 
   if (*buf_ptr == '\r')
@@ -1371,9 +1272,9 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
   if (*buf_ptr == '\n')
     buf_ptr++;
 
-  if ((int) (buf_ptr - buf) < b_read && !(*lineInfo)[n+1].continuation)
+  if ((int) (buf_ptr - buf) < b_read && !(*lineInfo)[n + 1].continuation)
     append_line (*lineInfo, n, (int) (buf_ptr - buf));
-  (*lineInfo)[n+1].offset = (*lineInfo)[n].offset + (long) (buf_ptr - buf);
+  (*lineInfo)[n + 1].offset = (*lineInfo)[n].offset + (long) (buf_ptr - buf);
 
   /* if we don't need to display the line we are done */
   if (!(flags & M_SHOW))
@@ -1384,8 +1285,7 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
 
   /* avoid a bug in ncurses... */
 #ifndef USE_SLANG_CURSES
-  if (col == 0)
-  {
+  if (col == 0) {
     SETCOLOR (MT_COLOR_NORMAL);
     addch (' ');
   }
@@ -1394,19 +1294,18 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
   /* end the last color pattern (needed by S-Lang) */
   if (special || (col != COLS && (flags & (M_SHOWCOLOR | M_SEARCH))))
     resolve_color (*lineInfo, n, vch, flags, 0, &a);
-          
+
   /*
    * Fill the blank space at the end of the line with the prevailing color.
    * ncurses does an implicit clrtoeol() when you do addch('\n') so we have
    * to make sure to reset the color *after* that
    */
-  if (flags & M_SHOWCOLOR)
-  {
+  if (flags & M_SHOWCOLOR) {
     m = ((*lineInfo)[n].continuation) ? ((*lineInfo)[n].syntax)[0].first : n;
     if ((*lineInfo)[m].type == MT_COLOR_HEADER)
       def_color = ((*lineInfo)[m].syntax)[0].color;
     else
-      def_color = ColorDefs[ (*lineInfo)[m].type ];
+      def_color = ColorDefs[(*lineInfo)[m].type];
 
     attrset (def_color);
 #ifdef HAVE_BKGDSET
@@ -1419,19 +1318,18 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
    * a newline (grr!).
    */
 #ifndef USE_SLANG_CURSES
-    if (col < COLS)
+  if (col < COLS)
 #endif
-      addch ('\n');
+    addch ('\n');
 
   /*
    * reset the color back to normal.  This *must* come after the
    * addch('\n'), otherwise the color for this line will not be
    * filled to the right margin.
    */
-  if (flags & M_SHOWCOLOR)
-  {
-    SETCOLOR(MT_COLOR_NORMAL);
-    BKGDSET(MT_COLOR_NORMAL);
+  if (flags & M_SHOWCOLOR) {
+    SETCOLOR (MT_COLOR_NORMAL);
+    BKGDSET (MT_COLOR_NORMAL);
   }
 
   /* build a return code */
@@ -1441,11 +1339,9 @@ display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n,
   return (flags);
 }
 
-static int
-upNLines (int nlines, struct line_t *info, int cur, int hiding)
+static int upNLines (int nlines, struct line_t *info, int cur, int hiding)
 {
-  while (cur > 0 && nlines > 0)
-  {
+  while (cur > 0 && nlines > 0) {
     cur--;
     if (!hiding || info[cur].type != MT_COLOR_QUOTED)
       nlines--;
@@ -1455,26 +1351,26 @@ upNLines (int nlines, struct line_t *info, int cur, int hiding)
 }
 
 static struct mapping_t PagerHelp[] = {
-  { N_("Exit"),        OP_EXIT },
-  { N_("PrevPg"), OP_PREV_PAGE },
-  { N_("NextPg"), OP_NEXT_PAGE },
-  { NULL,      0 }
+  {N_("Exit"), OP_EXIT},
+  {N_("PrevPg"), OP_PREV_PAGE},
+  {N_("NextPg"), OP_NEXT_PAGE},
+  {NULL, 0}
 };
 static struct mapping_t PagerHelpExtra[] = {
-  { N_("View Attachm."), OP_VIEW_ATTACHMENTS },
-  { N_("Del"), OP_DELETE },
-  { N_("Reply"), OP_REPLY },
-  { N_("Next"),        OP_MAIN_NEXT_UNDELETED },
-  { NULL,      0 }
+  {N_("View Attachm."), OP_VIEW_ATTACHMENTS},
+  {N_("Del"), OP_DELETE},
+  {N_("Reply"), OP_REPLY},
+  {N_("Next"), OP_MAIN_NEXT_UNDELETED},
+  {NULL, 0}
 };
 
 #ifdef USE_NNTP
 static struct mapping_t PagerNewsHelpExtra[] = {
-  { N_("Post"),     OP_POST },
-  { N_("Followup"), OP_FOLLOWUP },
-  { N_("Del"),      OP_DELETE },
-  { N_("Next"),     OP_MAIN_NEXT_UNDELETED },
-  { NULL,           0 }
+  {N_("Post"), OP_POST},
+  {N_("Followup"), OP_FOLLOWUP},
+  {N_("Del"), OP_DELETE},
+  {N_("Next"), OP_MAIN_NEXT_UNDELETED},
+  {NULL, 0}
 };
 #endif
 
@@ -1485,13 +1381,13 @@ static struct mapping_t PagerNewsHelpExtra[] = {
    can be distinguished by whether or not ``hdr'' is NULL.  The ``hdr'' arg
    is there so that we can do operations on the current message without the
    need to pop back out to the main-menu.  */
-int 
-mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
+int
+mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
 {
   static char searchbuf[STRING];
   char buffer[LONG_STRING];
-  char helpstr[SHORT_STRING*2];
-  char tmphelp[SHORT_STRING*2];
+  char helpstr[SHORT_STRING * 2];
+  char tmphelp[SHORT_STRING * 2];
   int maxLine, lastLine = 0;
   struct line_t *lineInfo;
   struct q_class_t *QuoteList = NULL;
@@ -1505,19 +1401,19 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
   struct stat sb;
   regex_t SearchRE;
   int SearchCompiled = 0, SearchFlag = 0, SearchBack = 0;
-  int has_types = (IsHeader(extra) || (flags & M_SHOWCOLOR)) ? M_TYPES : 0; /* main message or rfc822 attachment */
+  int has_types = (IsHeader (extra) || (flags & M_SHOWCOLOR)) ? M_TYPES : 0;    /* main message or rfc822 attachment */
 
-  int bodyoffset = 1;                  /* offset of first line of real text */
-  int statusoffset = 0;                /* offset for the status bar */
-  int helpoffset = LINES - 2;          /* offset for the help bar. */
+  int bodyoffset = 1;           /* offset of first line of real text */
+  int statusoffset = 0;         /* offset for the status bar */
+  int helpoffset = LINES - 2;   /* offset for the help bar. */
   int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
 
-  MUTTMENU *index = NULL;              /* the Pager Index (PI) */
-  int indexoffset = 0;                 /* offset for the PI */
-  int indexlen = PagerIndexLines;      /* indexlen not always == PIL */
-  int indicator = indexlen / 3;        /* the indicator line of the PI */
-  int old_PagerIndexLines;             /* some people want to resize it
-                                        * while inside the pager... */
+  MUTTMENU *index = NULL;       /* the Pager Index (PI) */
+  int indexoffset = 0;          /* offset for the PI */
+  int indexlen = PagerIndexLines;       /* indexlen not always == PIL */
+  int indicator = indexlen / 3; /* the indicator line of the PI */
+  int old_PagerIndexLines;      /* some people want to resize it
+                                 * while inside the pager... */
 
 #ifdef USE_NNTP
   char *followup_to;
@@ -1526,14 +1422,12 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
   if (!(flags & M_SHOWCOLOR))
     flags |= M_SHOWFLAT;
 
-  if ((fp = fopen (fname, "r")) == NULL)
-  {
+  if ((fp = fopen (fname, "r")) == NULL) {
     mutt_perror (fname);
     return (-1);
   }
 
-  if (stat (fname, &sb) != 0)
-  {
+  if (stat (fname, &sb) != 0) {
     mutt_perror (fname);
     fclose (fp);
     return (-1);
@@ -1542,15 +1436,13 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
 
   /* Initialize variables */
 
-  if (IsHeader (extra) && !extra->hdr->read)
-  {
+  if (IsHeader (extra) && !extra->hdr->read) {
     Context->msgnotreadyet = extra->hdr->msgno;
     mutt_set_flag (Context, extra->hdr, M_READ, 1);
   }
 
   lineInfo = safe_malloc (sizeof (struct line_t) * (maxLine = LINES));
-  for (i = 0 ; i < maxLine ; i++)
-  {
+  for (i = 0; i < maxLine; i++) {
     memset (&lineInfo[i], 0, sizeof (struct line_t));
     lineInfo[i].type = -1;
     lineInfo[i].search_cnt = -1;
@@ -1559,1227 +1451,1167 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
   }
 
   mutt_compile_help (helpstr, sizeof (helpstr), MENU_PAGER, PagerHelp);
-  if (IsHeader (extra))
-  {
+  if (IsHeader (extra)) {
     strfcpy (tmphelp, helpstr, sizeof (tmphelp));
     mutt_compile_help (buffer, sizeof (buffer), MENU_PAGER,
 #ifdef USE_NNTP
-       (Context && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
+                       (Context
+                        && (Context->magic == M_NNTP)) ? PagerNewsHelpExtra :
 #endif
-       PagerHelpExtra);
+                       PagerHelpExtra);
     snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
   }
-  if (!InHelp)
-  {
+  if (!InHelp) {
     strfcpy (tmphelp, helpstr, sizeof (tmphelp));
     mutt_make_help (buffer, sizeof (buffer), _("Help"), MENU_PAGER, OP_HELP);
     snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
   }
 
-  while (ch != -1)
-  {
+  while (ch != -1) {
     mutt_curs_set (0);
 
 #ifdef USE_IMAP
     imap_keepalive ();
 #endif
-    
-    if (redraw & REDRAW_FULL)
-    {
+
+    if (redraw & REDRAW_FULL) {
       SETCOLOR (MT_COLOR_NORMAL);
       /* clear() doesn't optimize screen redraws */
       move (0, 0);
       clrtobot ();
 
       if (IsHeader (extra) && Context->vcount + 1 < PagerIndexLines)
-       indexlen = Context->vcount + 1;
+        indexlen = Context->vcount + 1;
       else
-       indexlen = PagerIndexLines;
+        indexlen = PagerIndexLines;
 
       indicator = indexlen / 3;
 
-      if (option (OPTSTATUSONTOP))
-      {
-       indexoffset = 0;
-       statusoffset = IsHeader (extra) ? indexlen : 0;
-       bodyoffset = statusoffset + 1;
-       helpoffset = LINES - 2;
-       bodylen = helpoffset - bodyoffset;
-       if (!option (OPTHELP))
-         bodylen++;
+      if (option (OPTSTATUSONTOP)) {
+        indexoffset = 0;
+        statusoffset = IsHeader (extra) ? indexlen : 0;
+        bodyoffset = statusoffset + 1;
+        helpoffset = LINES - 2;
+        bodylen = helpoffset - bodyoffset;
+        if (!option (OPTHELP))
+          bodylen++;
       }
-      else
-      {
-       helpoffset = 0;
-       indexoffset = 1;
-       statusoffset = LINES - 2;
-       if (!option (OPTHELP))
-         indexoffset = 0;
-       bodyoffset = indexoffset + (IsHeader (extra) ? indexlen : 0);
-       bodylen = statusoffset - bodyoffset;
+      else {
+        helpoffset = 0;
+        indexoffset = 1;
+        statusoffset = LINES - 2;
+        if (!option (OPTHELP))
+          indexoffset = 0;
+        bodyoffset = indexoffset + (IsHeader (extra) ? indexlen : 0);
+        bodylen = statusoffset - bodyoffset;
       }
 
-      if (option (OPTHELP))
-      {
-       SETCOLOR (MT_COLOR_STATUS);
-       move (helpoffset, 0);
-       mutt_paddstr (COLS, helpstr);
-       SETCOLOR (MT_COLOR_NORMAL);
+      if (option (OPTHELP)) {
+        SETCOLOR (MT_COLOR_STATUS);
+        move (helpoffset, 0);
+        mutt_paddstr (COLS, helpstr);
+        SETCOLOR (MT_COLOR_NORMAL);
       }
 
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-      if (Resize != NULL)
-      {
-       if ((SearchCompiled = Resize->SearchCompiled))
-       {
-         REGCOMP
-           (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf));
-         SearchFlag = M_SEARCH;
-         SearchBack = Resize->SearchBack;
-       }
-       lines = Resize->line;
-       redraw |= REDRAW_SIGWINCH;
-
-       FREE (&Resize);
+      if (Resize != NULL) {
+        if ((SearchCompiled = Resize->SearchCompiled)) {
+          REGCOMP
+            (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf));
+          SearchFlag = M_SEARCH;
+          SearchBack = Resize->SearchBack;
+        }
+        lines = Resize->line;
+        redraw |= REDRAW_SIGWINCH;
+
+        FREE (&Resize);
       }
 #endif
 
-      if (IsHeader (extra) && PagerIndexLines)
-      {
-       if (index == NULL)
-       {
-         /* only allocate the space if/when we need the index.
-            Initialise the menu as per the main index */
-         index = mutt_new_menu();
-         index->menu = MENU_MAIN;
-         index->make_entry = index_make_entry;
-         index->color = index_color;
-         index->max = Context->vcount;
-         index->current = extra->hdr->virtual;
-       }
+      if (IsHeader (extra) && PagerIndexLines) {
+        if (index == NULL) {
+          /* only allocate the space if/when we need the index.
+             Initialise the menu as per the main index */
+          index = mutt_new_menu ();
+          index->menu = MENU_MAIN;
+          index->make_entry = index_make_entry;
+          index->color = index_color;
+          index->max = Context->vcount;
+          index->current = extra->hdr->virtual;
+        }
 
-       SETCOLOR (MT_COLOR_NORMAL);
-       index->offset  = indexoffset + (option (OPTSTATUSONTOP) ? 1 : 0);
+        SETCOLOR (MT_COLOR_NORMAL);
+        index->offset = indexoffset + (option (OPTSTATUSONTOP) ? 1 : 0);
 
-       index->pagelen = indexlen - 1;
+        index->pagelen = indexlen - 1;
 
-       /* some fudge to work out where abouts the indicator should go */
-       if (index->current - indicator < 0)
-         index->top = 0;
-       else if (index->max - index->current < index->pagelen - indicator)
-         index->top = index->max - index->pagelen;
-       else
-         index->top = index->current - indicator;
+        /* some fudge to work out where abouts the indicator should go */
+        if (index->current - indicator < 0)
+          index->top = 0;
+        else if (index->max - index->current < index->pagelen - indicator)
+          index->top = index->max - index->pagelen;
+        else
+          index->top = index->current - indicator;
 
-       menu_redraw_index(index);
+        menu_redraw_index (index);
       }
 
       redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS;
       mutt_show_error ();
     }
 
-    if (redraw & REDRAW_SIGWINCH)
-    {
+    if (redraw & REDRAW_SIGWINCH) {
       i = -1;
       j = -1;
       while (display_line (fp, &last_pos, &lineInfo, ++i, &lastLine, &maxLine,
-            has_types | SearchFlag, &QuoteList, &q_level, &force_redraw,
-            &SearchRE) == 0) {
-        if (!lineInfo[i].continuation && ++j == lines)
-        {
+                           has_types | SearchFlag, &QuoteList, &q_level,
+                           &force_redraw, &SearchRE) == 0) {
+        if (!lineInfo[i].continuation && ++j == lines) {
           topline = i;
           if (!SearchFlag)
             break;
         }
         redraw |= REDRAW_SIDEBAR;
-      } /* while */
+      }                         /* while */
     }
 
-    if ((redraw & REDRAW_BODY) || topline != oldtopline)
-    {
+    if ((redraw & REDRAW_BODY) || topline != oldtopline) {
       do {
-       move (bodyoffset, SidebarWidth);
-       curline = oldtopline = topline;
-       lines = 0;
-       force_redraw = 0;
-
-       while (lines < bodylen && lineInfo[curline].offset <= sb.st_size - 1)
-       {
-         if (display_line (fp, &last_pos, &lineInfo, curline, &lastLine, 
-                           &maxLine,
-                           (flags & M_DISPLAYFLAGS) | hideQuoted | SearchFlag, 
-                           &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
-           lines++;
-         curline++;
-               move(lines + bodyoffset, SidebarWidth);
+        move (bodyoffset, SidebarWidth);
+        curline = oldtopline = topline;
+        lines = 0;
+        force_redraw = 0;
+
+        while (lines < bodylen && lineInfo[curline].offset <= sb.st_size - 1) {
+          if (display_line (fp, &last_pos, &lineInfo, curline, &lastLine,
+                            &maxLine,
+                            (flags & M_DISPLAYFLAGS) | hideQuoted |
+                            SearchFlag, &QuoteList, &q_level, &force_redraw,
+                            &SearchRE) > 0)
+            lines++;
+          curline++;
+          move (lines + bodyoffset, SidebarWidth);
           redraw |= REDRAW_SIDEBAR;
-       }
-       last_offset = lineInfo[curline].offset;
+        }
+        last_offset = lineInfo[curline].offset;
       } while (force_redraw);
 
       SETCOLOR (MT_COLOR_TILDE);
       BKGDSET (MT_COLOR_TILDE);
-      while (lines < bodylen)
-      {
-       clrtoeol ();
-       if (option (OPTTILDE))
-         addch ('~');
-       addch ('\n');
-       lines++;
-       move(lines + bodyoffset, SidebarWidth);
+      while (lines < bodylen) {
+        clrtoeol ();
+        if (option (OPTTILDE))
+          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. */
 
-      redraw |= REDRAW_STATUS; /* need to update the % seen */
+      redraw |= REDRAW_STATUS;  /* need to update the % seen */
     }
 
-    if (redraw & REDRAW_STATUS)
-    {
+    if (redraw & REDRAW_STATUS) {
       /* print out the pager status bar */
       SETCOLOR (MT_COLOR_STATUS);
       BKGDSET (MT_COLOR_STATUS);
-      CLEARLINE_WIN(statusoffset);
-      if (IsHeader (extra))
-      {
-       size_t l1 = (COLS - 9) * MB_LEN_MAX;
-       size_t l2 = sizeof (buffer);
-       _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
-                          Context, extra->hdr, M_FORMAT_MAKEPRINT);
-      }
-      else if (IsMsgAttach (extra))
-      {
-       size_t l1 = (COLS - 9) * MB_LEN_MAX;
-       size_t l2 = sizeof (buffer);
-       _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
-                          Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
-      }
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),option(OPTSTATUSONTOP)?0:SidebarWidth);
-      mutt_paddstr (COLS-10, IsHeader (extra) || IsMsgAttach (extra) ?
-                    buffer : banner);
+      CLEARLINE_WIN (statusoffset);
+      if (IsHeader (extra)) {
+        size_t l1 = (COLS - 9) * MB_LEN_MAX;
+        size_t l2 = sizeof (buffer);
+
+        _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
+                           Context, extra->hdr, M_FORMAT_MAKEPRINT);
+      }
+      else if (IsMsgAttach (extra)) {
+        size_t l1 = (COLS - 9) * MB_LEN_MAX;
+        size_t l2 = sizeof (buffer);
+
+        _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
+                           Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
+      }
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
+            option (OPTSTATUSONTOP) ? 0 : SidebarWidth);
+      mutt_paddstr (COLS - 10, IsHeader (extra)
+                    || IsMsgAttach (extra) ? buffer : banner);
 
       addstr (" -- (");
       if (last_pos < sb.st_size - 1)
-       printw ("%d%%)", (int) (100 * last_offset / sb.st_size));
+        printw ("%d%%)", (int) (100 * last_offset / sb.st_size));
       else
-       addstr (topline == 0 ? "all)" : "end)");
+        addstr (topline == 0 ? "all)" : "end)");
       BKGDSET (MT_COLOR_NORMAL);
       SETCOLOR (MT_COLOR_NORMAL);
     }
 
     if (redraw & REDRAW_SIDEBAR)
-      draw_sidebar(MENU_PAGER);
+      draw_sidebar (MENU_PAGER);
 
-    if ((redraw & REDRAW_INDEX) && index)
-    {
+    if ((redraw & REDRAW_INDEX) && index) {
       /* redraw the pager_index indicator, because the
        * flags for this message might have changed. */
       menu_redraw_current (index);
-      draw_sidebar(MENU_PAGER);
+      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)),option(OPTSTATUSONTOP)?0:SidebarWidth);
+      menu_status_line (buffer, sizeof (buffer), index, NONULL (Status));
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
+            option (OPTSTATUSONTOP) ? 0 : SidebarWidth);
       SETCOLOR (MT_COLOR_STATUS);
-      mutt_paddstr (COLS-(option(OPTSTATUSONTOP)?0:SidebarWidth), buffer);
+      mutt_paddstr (COLS - (option (OPTSTATUSONTOP) ? 0 : SidebarWidth),
+                    buffer);
       SETCOLOR (MT_COLOR_NORMAL);
     }
-       /* if we're not using the index, update every time */
-       if ( index == 0 )
-               draw_sidebar(MENU_PAGER);
+    /* if we're not using the index, update every time */
+    if (index == 0)
+      draw_sidebar (MENU_PAGER);
 
     redraw = 0;
 
-    move (statusoffset, COLS-1);
+    move (statusoffset, COLS - 1);
     mutt_refresh ();
     ch = km_dokey (MENU_PAGER);
     if (ch != -1)
       mutt_clear_error ();
     mutt_curs_set (1);
 
-    if (SigInt)
-    {
+    if (SigInt) {
       mutt_query_exit ();
       continue;
     }
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-    else if (SigWinch)
-    {
+    else if (SigWinch) {
       mutt_resize_screen ();
 
       /* Store current position. */
       lines = -1;
       for (i = 0; i <= topline; i++)
-       if (!lineInfo[i].continuation)
-         lines++;
+        if (!lineInfo[i].continuation)
+          lines++;
 
-      if (flags & M_PAGER_RETWINCH)
-      {
-       Resize = safe_malloc (sizeof (struct resize));
+      if (flags & M_PAGER_RETWINCH) {
+        Resize = safe_malloc (sizeof (struct resize));
 
-       Resize->line = lines;
-       Resize->SearchCompiled = SearchCompiled;
-       Resize->SearchBack = SearchBack;
+        Resize->line = lines;
+        Resize->SearchCompiled = SearchCompiled;
+        Resize->SearchBack = SearchBack;
 
-       ch = -1;
-       rc = OP_REFORMAT_WINCH;
+        ch = -1;
+        rc = OP_REFORMAT_WINCH;
       }
-      else
-      {
-       for (i = 0; i < maxLine; i++)
-       {
-         lineInfo[i].offset = 0;
-         lineInfo[i].type = -1;
-         lineInfo[i].continuation = 0;
-         lineInfo[i].chunks = 0;
-         lineInfo[i].search_cnt = -1;
-         lineInfo[i].quote = NULL;
-
-         safe_realloc (&(lineInfo[i].syntax),
-                       sizeof (struct syntax_t));
-         if (SearchCompiled && lineInfo[i].search)
-             FREE (&(lineInfo[i].search));
-       }
+      else {
+        for (i = 0; i < maxLine; i++) {
+          lineInfo[i].offset = 0;
+          lineInfo[i].type = -1;
+          lineInfo[i].continuation = 0;
+          lineInfo[i].chunks = 0;
+          lineInfo[i].search_cnt = -1;
+          lineInfo[i].quote = NULL;
+
+          safe_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t));
+          if (SearchCompiled && lineInfo[i].search)
+            FREE (&(lineInfo[i].search));
+        }
 
-       lastLine = 0;
-       topline = 0;
+        lastLine = 0;
+        topline = 0;
 
-       redraw = REDRAW_FULL | REDRAW_SIGWINCH;
-       ch = 0;
+        redraw = REDRAW_FULL | REDRAW_SIGWINCH;
+        ch = 0;
       }
 
       SigWinch = 0;
-      clearok(stdscr,TRUE);/*force complete redraw*/
+      clearok (stdscr, TRUE);   /*force complete redraw */
       continue;
     }
 #endif
-    else if (ch == -1)
-    {
+    else if (ch == -1) {
       ch = 0;
       continue;
     }
 
     rc = ch;
 
-    switch (ch)
-    {
-      case OP_EXIT:
-       rc = -1;
-       ch = -1;
-       break;
-
-      case OP_NEXT_PAGE:
-       if (lineInfo[curline].offset < sb.st_size-1)
-       {
-         topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);
-       }
-       else if (option (OPTPAGERSTOP))
-       {
-         /* emulate "less -q" and don't go on to the next message. */
-         mutt_error _("Bottom of message is shown.");
-       }
-       else
-       {
-         /* end of the current message, so display the next message. */
-         rc = OP_MAIN_NEXT_UNDELETED;
-         ch = -1;
-       }
-       break;
-
-      case OP_PREV_PAGE:
-       if (topline != 0)
-       {
-         topline = upNLines (bodylen-PagerContext, lineInfo, topline, hideQuoted);
-       }
-       else
-         mutt_error _("Top of message is shown.");
-       break;
-
-      case OP_NEXT_LINE:
-       if (lineInfo[curline].offset < sb.st_size-1)
-       {
-         topline++;
-         if (hideQuoted)
-         {
-           while (lineInfo[topline].type == MT_COLOR_QUOTED &&
-                  topline < lastLine)
-             topline++;
-         }
-       }
-       else
-         mutt_error _("Bottom of message is shown.");
-       break;
-
-      case OP_PREV_LINE:
-       if (topline)
-         topline = upNLines (1, lineInfo, topline, hideQuoted);
-       else
-         mutt_error _("Top of message is shown.");
-       break;
-
-      case OP_PAGER_TOP:
-        if (topline)
-         topline = 0;
-       else
-         mutt_error _("Top of message is shown.");
-       break;
-
-      case OP_HALF_UP:
-       if (topline)
-         topline = upNLines (bodylen/2, lineInfo, topline, hideQuoted);
-       else
-         mutt_error _("Top of message is shown.");
-       break;
-
-      case OP_HALF_DOWN:
-       if (lineInfo[curline].offset < sb.st_size-1)
-       {
-         topline = upNLines (bodylen/2, lineInfo, curline, hideQuoted);
-       }
-       else if (option (OPTPAGERSTOP))
-       {
-         /* emulate "less -q" and don't go on to the next message. */
-         mutt_error _("Bottom of message is shown.");
-       }
-       else
-       {
-         /* end of the current message, so display the next message. */
-         rc = OP_MAIN_NEXT_UNDELETED;
-         ch = -1;
-       }
-       break;
-
-      case OP_SEARCH_NEXT:
-      case OP_SEARCH_OPPOSITE:
-       if (SearchCompiled)
-       {
-search_next:
-         if ((!SearchBack && ch==OP_SEARCH_NEXT) ||
-             (SearchBack &&ch==OP_SEARCH_OPPOSITE))
-         {
-           /* searching forward */
-           for (i = topline + 1; i < lastLine; i++)
-           {
-             if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 
-                   !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
-               break;
-           }
-
-           if (i < lastLine)
-             topline = i;
-           else
-             mutt_error _("Not found.");
-         }
-         else
-         {
-           /* searching backward */
-           for (i = topline - 1; i >= 0; i--)
-           {
-             if ((!hideQuoted || (has_types && 
-                   lineInfo[i].type != MT_COLOR_QUOTED)) && 
-                   !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
-               break;
-           }
-
-           if (i >= 0)
-             topline = i;
-           else
-             mutt_error _("Not found.");
-         }
-
-         if (lineInfo[topline].search_cnt > 0)
-           SearchFlag = M_SEARCH;
-
-         break;
-       }
-       /* no previous search pattern, so fall through to search */
-
-      case OP_SEARCH:
-      case OP_SEARCH_REVERSE:
-        strfcpy (buffer, searchbuf, sizeof (buffer));
-       if (mutt_get_field ((SearchBack ? _("Reverse search: ") :
-                         _("Search: ")), buffer, sizeof (buffer),
-                         M_CLEAR) != 0)
-         break;
-
-       if (!strcmp (buffer, searchbuf))
-       {
-         if (SearchCompiled)
-         {
-           /* do an implicit search-next */
-           if (ch == OP_SEARCH)
-             ch = OP_SEARCH_NEXT;
-           else
-             ch = OP_SEARCH_OPPOSITE;
-
-           goto search_next;
-         }
-       }
-      
-        if (!buffer[0])
-         break;
-      
-       strfcpy (searchbuf, buffer, sizeof (searchbuf));
-
-       /* leave SearchBack alone if ch == OP_SEARCH_NEXT */
-       if (ch == OP_SEARCH)
-         SearchBack = 0;
-       else if (ch == OP_SEARCH_REVERSE)
-         SearchBack = 1;
-
-       if (SearchCompiled)
-       {
-         regfree (&SearchRE);
-         for (i = 0; i < lastLine; i++)
-         {
-           if (lineInfo[i].search)
-             FREE (&(lineInfo[i].search));
-           lineInfo[i].search_cnt = -1;
-         }
-       }
-
-       if ((err = REGCOMP (&SearchRE, searchbuf, REG_NEWLINE | mutt_which_case (searchbuf))) != 0)
-       {
-         regerror (err, &SearchRE, buffer, sizeof (buffer));
-         mutt_error ("%s", buffer);
-         regfree (&SearchRE);
-         for (i = 0; i < maxLine ; i++)
-         {
-           /* cleanup */
-           if (lineInfo[i].search)
-             FREE (&(lineInfo[i].search));
-           lineInfo[i].search_cnt = -1;
-         }
-         SearchFlag = 0;
-         SearchCompiled = 0;
-       }
-       else
-       {
-         SearchCompiled = 1;
-         /* update the search pointers */
-         i = 0;
-         while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, 
-                               &maxLine, M_SEARCH | (flags & M_PAGER_NSKIP),
-                               &QuoteList, &q_level,
-                               &force_redraw, &SearchRE) == 0) {
-           i++;
-            redraw |= REDRAW_SIDEBAR;
+    switch (ch) {
+    case OP_EXIT:
+      rc = -1;
+      ch = -1;
+      break;
+
+    case OP_NEXT_PAGE:
+      if (lineInfo[curline].offset < sb.st_size - 1) {
+        topline = upNLines (PagerContext, lineInfo, curline, hideQuoted);
+      }
+      else if (option (OPTPAGERSTOP)) {
+        /* emulate "less -q" and don't go on to the next message. */
+        mutt_error _("Bottom of message is shown.");
+      }
+      else {
+        /* end of the current message, so display the next message. */
+        rc = OP_MAIN_NEXT_UNDELETED;
+        ch = -1;
+      }
+      break;
+
+    case OP_PREV_PAGE:
+      if (topline != 0) {
+        topline =
+          upNLines (bodylen - PagerContext, lineInfo, topline, hideQuoted);
+      }
+      else
+        mutt_error _("Top of message is shown.");
+      break;
+
+    case OP_NEXT_LINE:
+      if (lineInfo[curline].offset < sb.st_size - 1) {
+        topline++;
+        if (hideQuoted) {
+          while (lineInfo[topline].type == MT_COLOR_QUOTED &&
+                 topline < lastLine)
+            topline++;
+        }
+      }
+      else
+        mutt_error _("Bottom of message is shown.");
+      break;
+
+    case OP_PREV_LINE:
+      if (topline)
+        topline = upNLines (1, lineInfo, topline, hideQuoted);
+      else
+        mutt_error _("Top of message is shown.");
+      break;
+
+    case OP_PAGER_TOP:
+      if (topline)
+        topline = 0;
+      else
+        mutt_error _("Top of message is shown.");
+      break;
+
+    case OP_HALF_UP:
+      if (topline)
+        topline = upNLines (bodylen / 2, lineInfo, topline, hideQuoted);
+      else
+        mutt_error _("Top of message is shown.");
+      break;
+
+    case OP_HALF_DOWN:
+      if (lineInfo[curline].offset < sb.st_size - 1) {
+        topline = upNLines (bodylen / 2, lineInfo, curline, hideQuoted);
+      }
+      else if (option (OPTPAGERSTOP)) {
+        /* emulate "less -q" and don't go on to the next message. */
+        mutt_error _("Bottom of message is shown.");
+      }
+      else {
+        /* end of the current message, so display the next message. */
+        rc = OP_MAIN_NEXT_UNDELETED;
+        ch = -1;
+      }
+      break;
+
+    case OP_SEARCH_NEXT:
+    case OP_SEARCH_OPPOSITE:
+      if (SearchCompiled) {
+      search_next:
+        if ((!SearchBack && ch == OP_SEARCH_NEXT) ||
+            (SearchBack && ch == OP_SEARCH_OPPOSITE)) {
+          /* searching forward */
+          for (i = topline + 1; i < lastLine; i++) {
+            if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
+                !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+              break;
           }
 
-         if (!SearchBack)
-         {
-           /* searching forward */
-           for (i = topline; i < lastLine; i++)
-           {
-             if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 
-                   !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
-               break;
-           }
-
-           if (i < lastLine) topline = i;
-         }
-         else
-         {
-           /* searching backward */
-           for (i = topline; i >= 0; i--)
-           {
-             if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) && 
-                   !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
-               break;
-           }
-
-           if (i >= 0) topline = i;
-         }
-
-         if (lineInfo[topline].search_cnt == 0)
-         {
-           SearchFlag = 0;
-           mutt_error _("Not found.");
-         }
-         else
-           SearchFlag = M_SEARCH;
-       }
-       redraw = REDRAW_BODY;
-       break;
-
-      case OP_SEARCH_TOGGLE:
-       if (SearchCompiled)
-       {
-         SearchFlag ^= M_SEARCH;
-         redraw = REDRAW_BODY;
-       }
-       break;
-
-      case OP_HELP:
-       /* don't let the user enter the help-menu from the help screen! */
-       if (! InHelp)
-       {
-         InHelp = 1;
-         mutt_help (MENU_PAGER);
-         redraw = REDRAW_FULL;
-         InHelp = 0;
-       }
-       else
-         mutt_error _("Help is currently being shown.");
-       break;
-
-      case OP_PAGER_HIDE_QUOTED:
-       if (has_types)
-       {
-         hideQuoted ^= M_HIDE;
-         if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED)
-           topline = upNLines (1, lineInfo, topline, hideQuoted);
-         else
-           redraw = REDRAW_BODY;
-       }
-       break;
-
-      case OP_PAGER_SKIP_QUOTED:
-       if (has_types)
-       {
-         int dretval = 0;
-         int new_topline = topline;
-
-         while ((new_topline < lastLine ||
-                 (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
-                        new_topline, &lastLine, &maxLine, M_TYPES,
-                        &QuoteList, &q_level, &force_redraw, &SearchRE))))
-                && lineInfo[new_topline].type != MT_COLOR_QUOTED) {
-            redraw |= REDRAW_SIDEBAR;
-           new_topline++;
+          if (i < lastLine)
+            topline = i;
+          else
+            mutt_error _("Not found.");
+        }
+        else {
+          /* searching backward */
+          for (i = topline - 1; i >= 0; i--) {
+            if ((!hideQuoted || (has_types &&
+                                 lineInfo[i].type != MT_COLOR_QUOTED)) &&
+                !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+              break;
           }
 
-         if (dretval < 0)
-         {
-           mutt_error _("No more quoted text.");
-           break;
-         }
-
-         while ((new_topline < lastLine ||
-                 (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
-                        new_topline, &lastLine, &maxLine, M_TYPES,
-                        &QuoteList, &q_level, &force_redraw, &SearchRE))))
-                && lineInfo[new_topline].type == MT_COLOR_QUOTED) {
-           new_topline++;
-            redraw |= REDRAW_SIDEBAR;
+          if (i >= 0)
+            topline = i;
+          else
+            mutt_error _("Not found.");
+        }
+
+        if (lineInfo[topline].search_cnt > 0)
+          SearchFlag = M_SEARCH;
+
+        break;
+      }
+      /* no previous search pattern, so fall through to search */
+
+    case OP_SEARCH:
+    case OP_SEARCH_REVERSE:
+      strfcpy (buffer, searchbuf, sizeof (buffer));
+      if (mutt_get_field ((SearchBack ? _("Reverse search: ") :
+                           _("Search: ")), buffer, sizeof (buffer),
+                          M_CLEAR) != 0)
+        break;
+
+      if (!strcmp (buffer, searchbuf)) {
+        if (SearchCompiled) {
+          /* do an implicit search-next */
+          if (ch == OP_SEARCH)
+            ch = OP_SEARCH_NEXT;
+          else
+            ch = OP_SEARCH_OPPOSITE;
+
+          goto search_next;
+        }
+      }
+
+      if (!buffer[0])
+        break;
+
+      strfcpy (searchbuf, buffer, sizeof (searchbuf));
+
+      /* leave SearchBack alone if ch == OP_SEARCH_NEXT */
+      if (ch == OP_SEARCH)
+        SearchBack = 0;
+      else if (ch == OP_SEARCH_REVERSE)
+        SearchBack = 1;
+
+      if (SearchCompiled) {
+        regfree (&SearchRE);
+        for (i = 0; i < lastLine; i++) {
+          if (lineInfo[i].search)
+            FREE (&(lineInfo[i].search));
+          lineInfo[i].search_cnt = -1;
+        }
+      }
+
+      if ((err =
+           REGCOMP (&SearchRE, searchbuf,
+                    REG_NEWLINE | mutt_which_case (searchbuf))) != 0) {
+        regerror (err, &SearchRE, buffer, sizeof (buffer));
+        mutt_error ("%s", buffer);
+        regfree (&SearchRE);
+        for (i = 0; i < maxLine; i++) {
+          /* cleanup */
+          if (lineInfo[i].search)
+            FREE (&(lineInfo[i].search));
+          lineInfo[i].search_cnt = -1;
+        }
+        SearchFlag = 0;
+        SearchCompiled = 0;
+      }
+      else {
+        SearchCompiled = 1;
+        /* update the search pointers */
+        i = 0;
+        while (display_line (fp, &last_pos, &lineInfo, i, &lastLine,
+                             &maxLine, M_SEARCH | (flags & M_PAGER_NSKIP),
+                             &QuoteList, &q_level,
+                             &force_redraw, &SearchRE) == 0) {
+          i++;
+          redraw |= REDRAW_SIDEBAR;
+        }
+
+        if (!SearchBack) {
+          /* searching forward */
+          for (i = topline; i < lastLine; i++) {
+            if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
+                !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+              break;
           }
 
-         if (dretval < 0)
-         {
-           mutt_error _("No more unquoted text after quoted text.");
-           break;        
-         }
-         topline = new_topline;
-       }
-       break;
-
-      case OP_PAGER_BOTTOM: /* move to the end of the file */
-       if (lineInfo[curline].offset < sb.st_size - 1)
-       {
-         i = curline;
-         /* make sure the types are defined to the end of file */
-         while (display_line (fp, &last_pos, &lineInfo, i, &lastLine, 
-                               &maxLine, has_types, 
-                               &QuoteList, &q_level, &force_redraw,
-                               &SearchRE) == 0) {
-           i++;
-            redraw |= REDRAW_SIDEBAR;
+          if (i < lastLine)
+            topline = i;
+        }
+        else {
+          /* searching backward */
+          for (i = topline; i >= 0; i--) {
+            if ((!hideQuoted || lineInfo[i].type != MT_COLOR_QUOTED) &&
+                !lineInfo[i].continuation && lineInfo[i].search_cnt > 0)
+              break;
           }
-         topline = upNLines (bodylen, lineInfo, lastLine, hideQuoted);
-       }
-       else
-         mutt_error _("Bottom of message is shown.");
-       break;
-
-      case OP_REDRAW:
-       clearok (stdscr, TRUE);
-       redraw = REDRAW_FULL;
-       break;
-
-      case OP_NULL:
-       km_error_key (MENU_PAGER);
-       break;
-
-       /* --------------------------------------------------------------------
-        * The following are operations on the current message rather than
-        * adjusting the view of the message.
-        */
-
-      case OP_BOUNCE_MESSAGE:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra))
-        CHECK_ATTACH;
-        if (IsMsgAttach (extra))
-         mutt_attach_bounce (extra->fp, extra->hdr,
-                             extra->idx, extra->idxlen,
-                             extra->bdy);
-        else
-          ci_bounce_message (extra->hdr, &redraw);
-       break;
 
-      case OP_RESEND:
-        CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra))
-        CHECK_ATTACH;
-        if (IsMsgAttach (extra))
-         mutt_attach_resend (extra->fp, extra->hdr,
-                             extra->idx, extra->idxlen,
-                             extra->bdy);
+          if (i >= 0)
+            topline = i;
+        }
+
+        if (lineInfo[topline].search_cnt == 0) {
+          SearchFlag = 0;
+          mutt_error _("Not found.");
+        }
         else
-         mutt_resend_message (NULL, extra->ctx, extra->hdr);
+          SearchFlag = M_SEARCH;
+      }
+      redraw = REDRAW_BODY;
+      break;
+
+    case OP_SEARCH_TOGGLE:
+      if (SearchCompiled) {
+        SearchFlag ^= M_SEARCH;
+        redraw = REDRAW_BODY;
+      }
+      break;
+
+    case OP_HELP:
+      /* don't let the user enter the help-menu from the help screen! */
+      if (!InHelp) {
+        InHelp = 1;
+        mutt_help (MENU_PAGER);
         redraw = REDRAW_FULL;
-        break;
+        InHelp = 0;
+      }
+      else
+        mutt_error _("Help is currently being shown.");
+      break;
 
-      case OP_CHECK_TRADITIONAL:
-        CHECK_MODE (IsHeader (extra));
-        if (!(WithCrypto & APPLICATION_PGP))
-         break;
-        if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) 
-        {
-         ch = -1;
-         rc = OP_CHECK_TRADITIONAL;
-       }
-        break;
-      
-      case OP_CREATE_ALIAS:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        if (IsMsgAttach (extra))
-         mutt_create_alias (extra->bdy->hdr->env, NULL);
+    case OP_PAGER_HIDE_QUOTED:
+      if (has_types) {
+        hideQuoted ^= M_HIDE;
+        if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED)
+          topline = upNLines (1, lineInfo, topline, hideQuoted);
         else
-         mutt_create_alias (extra->hdr->env, NULL);
-       MAYBE_REDRAW (redraw);
-       break;
+          redraw = REDRAW_BODY;
+      }
+      break;
+
+    case OP_PAGER_SKIP_QUOTED:
+      if (has_types) {
+        int dretval = 0;
+        int new_topline = topline;
+
+        while ((new_topline < lastLine ||
+                (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
+                                               new_topline, &lastLine,
+                                               &maxLine, M_TYPES, &QuoteList,
+                                               &q_level, &force_redraw,
+                                               &SearchRE))))
+               && lineInfo[new_topline].type != MT_COLOR_QUOTED) {
+          redraw |= REDRAW_SIDEBAR;
+          new_topline++;
+        }
+
+        if (dretval < 0) {
+          mutt_error _("No more quoted text.");
+
+          break;
+        }
+
+        while ((new_topline < lastLine ||
+                (0 == (dretval = display_line (fp, &last_pos, &lineInfo,
+                                               new_topline, &lastLine,
+                                               &maxLine, M_TYPES, &QuoteList,
+                                               &q_level, &force_redraw,
+                                               &SearchRE))))
+               && lineInfo[new_topline].type == MT_COLOR_QUOTED) {
+          new_topline++;
+          redraw |= REDRAW_SIDEBAR;
+        }
+
+        if (dretval < 0) {
+          mutt_error _("No more unquoted text after quoted text.");
+
+          break;
+        }
+        topline = new_topline;
+      }
+      break;
+
+    case OP_PAGER_BOTTOM:      /* move to the end of the file */
+      if (lineInfo[curline].offset < sb.st_size - 1) {
+        i = curline;
+        /* make sure the types are defined to the end of file */
+        while (display_line (fp, &last_pos, &lineInfo, i, &lastLine,
+                             &maxLine, has_types,
+                             &QuoteList, &q_level, &force_redraw,
+                             &SearchRE) == 0) {
+          i++;
+          redraw |= REDRAW_SIDEBAR;
+        }
+        topline = upNLines (bodylen, lineInfo, lastLine, hideQuoted);
+      }
+      else
+        mutt_error _("Bottom of message is shown.");
+      break;
+
+    case OP_REDRAW:
+      clearok (stdscr, TRUE);
+      redraw = REDRAW_FULL;
+      break;
+
+    case OP_NULL:
+      km_error_key (MENU_PAGER);
+      break;
+
+      /* --------------------------------------------------------------------
+       * The following are operations on the current message rather than
+       * adjusting the view of the message.
+       */
+
+    case OP_BOUNCE_MESSAGE:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra))
+        CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_bounce (extra->fp, extra->hdr,
+                            extra->idx, extra->idxlen, extra->bdy);
+      else
+        ci_bounce_message (extra->hdr, &redraw);
+      break;
+
+    case OP_RESEND:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra))
+        CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_resend (extra->fp, extra->hdr,
+                            extra->idx, extra->idxlen, extra->bdy);
+      else
+        mutt_resend_message (NULL, extra->ctx, extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
+
+    case OP_CHECK_TRADITIONAL:
+      CHECK_MODE (IsHeader (extra));
+      if (!(WithCrypto & APPLICATION_PGP))
+        break;
+      if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) {
+        ch = -1;
+        rc = OP_CHECK_TRADITIONAL;
+      }
+      break;
 
-      case OP_PURGE_MESSAGE:
-      case OP_DELETE:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+    case OP_CREATE_ALIAS:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      if (IsMsgAttach (extra))
+        mutt_create_alias (extra->bdy->hdr->env, NULL);
+      else
+        mutt_create_alias (extra->hdr->env, NULL);
+      MAYBE_REDRAW (redraw);
+      break;
+
+    case OP_PURGE_MESSAGE:
+    case OP_DELETE:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-       mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
-       mutt_set_flag (Context, extra->hdr, M_PURGED,
-                      ch != OP_PURGE_MESSAGE ? 0 : 1);
-        if (option (OPTDELETEUNTAG))
-         mutt_set_flag (Context, extra->hdr, M_TAG, 0);
-       redraw = REDRAW_STATUS | REDRAW_INDEX;
-       if (option (OPTRESOLVE))
-       {
-         ch = -1;
-         rc = OP_MAIN_NEXT_UNDELETED;
-       }
-       break;
-
-      case OP_DELETE_THREAD:
-      case OP_DELETE_SUBTHREAD:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+      mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
+      mutt_set_flag (Context, extra->hdr, M_PURGED,
+                     ch != OP_PURGE_MESSAGE ? 0 : 1);
+      if (option (OPTDELETEUNTAG))
+        mutt_set_flag (Context, extra->hdr, M_TAG, 0);
+      redraw = REDRAW_STATUS | REDRAW_INDEX;
+      if (option (OPTRESOLVE)) {
+        ch = -1;
+        rc = OP_MAIN_NEXT_UNDELETED;
+      }
+      break;
+
+    case OP_DELETE_THREAD:
+    case OP_DELETE_SUBTHREAD:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-       r = mutt_thread_set_flag (extra->hdr, M_DELETE, 1,
-                                 ch == OP_DELETE_THREAD ? 0 : 1);
-
-       if (r != -1)
-       {
-         if (option (OPTDELETEUNTAG))
-           mutt_thread_set_flag (extra->hdr, M_TAG, 0,
-                                 ch == OP_DELETE_THREAD ? 0 : 1);
-         if (option (OPTRESOLVE))
-         {
-           rc = OP_MAIN_NEXT_UNDELETED;
-           ch = -1;
-         }
-
-         if (!option (OPTRESOLVE) && PagerIndexLines)
-           redraw = REDRAW_FULL;
-         else
-           redraw = REDRAW_STATUS | REDRAW_INDEX;
-       }
-       break;
-
-      case OP_DISPLAY_ADDRESS:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        if (IsMsgAttach (extra))
-         mutt_display_address (extra->bdy->hdr->env);
+      r = mutt_thread_set_flag (extra->hdr, M_DELETE, 1,
+                                ch == OP_DELETE_THREAD ? 0 : 1);
+
+      if (r != -1) {
+        if (option (OPTDELETEUNTAG))
+          mutt_thread_set_flag (extra->hdr, M_TAG, 0,
+                                ch == OP_DELETE_THREAD ? 0 : 1);
+        if (option (OPTRESOLVE)) {
+          rc = OP_MAIN_NEXT_UNDELETED;
+          ch = -1;
+        }
+
+        if (!option (OPTRESOLVE) && PagerIndexLines)
+          redraw = REDRAW_FULL;
         else
-         mutt_display_address (extra->hdr->env);
-       break;
-
-      case OP_ENTER_COMMAND:
-       old_smart_wrap = option (OPTWRAP);
-       old_markers = option (OPTMARKERS);
-       old_PagerIndexLines = PagerIndexLines;
-
-       CurrentMenu = MENU_PAGER;
-       mutt_enter_command ();
-
-       if (option (OPTNEEDRESORT))
-       {
-         unset_option (OPTNEEDRESORT);
-         CHECK_MODE(IsHeader (extra));
-         set_option (OPTNEEDRESORT);
-       }
-
-       if (old_PagerIndexLines != PagerIndexLines)
-       {
-         if (index)
-           mutt_menuDestroy (&index);
-         index = NULL;
-       }
-       
-       if (option (OPTWRAP) != old_smart_wrap || 
-           option (OPTMARKERS) != old_markers)
-       {
-         if (flags & M_PAGER_RETWINCH)
-         {
-           ch = -1;
-           rc = OP_REFORMAT_WINCH;
-           continue;
-         }
-
-         /* count the real lines above */
-         j = 0;
-         for (i = 0; i <= topline; i++)
-         {
-           if (!lineInfo[i].continuation)
-             j++;
-         }
-
-         /* we need to restart the whole thing */
-         for (i = 0; i < maxLine; i++)
-         {
-           lineInfo[i].offset = 0;
-           lineInfo[i].type = -1;
-           lineInfo[i].continuation = 0;
-           lineInfo[i].chunks = 0;
-           lineInfo[i].search_cnt = -1;
-           lineInfo[i].quote = NULL;
-
-           safe_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t));
-           if (SearchCompiled && lineInfo[i].search)
-               FREE (&(lineInfo[i].search));
-         }
-
-         if (SearchCompiled)
-         {
-           regfree (&SearchRE);
-           SearchCompiled = 0;
-         }
-         SearchFlag = 0;
-
-         /* try to keep the old position */
-         topline = 0;
-         lastLine = 0;
-         while (j > 0 && display_line (fp, &last_pos, &lineInfo, topline, 
-                                       &lastLine, &maxLine,
-                                       (has_types ? M_TYPES : 0),
-                                       &QuoteList, &q_level, &force_redraw,
-                                       &SearchRE) == 0)
-         {
-            redraw |= REDRAW_SIDEBAR;
-           if (! lineInfo[topline].continuation)
-             j--;
-           if (j > 0)
-             topline++;
-         }
-
-         ch = 0;
-       }
-
-       if (option (OPTFORCEREDRAWPAGER))
-         redraw = REDRAW_FULL;
-       unset_option (OPTFORCEREDRAWINDEX);
-       unset_option (OPTFORCEREDRAWPAGER);
-       break;
-
-      case OP_FLAG_MESSAGE:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+          redraw = REDRAW_STATUS | REDRAW_INDEX;
+      }
+      break;
+
+    case OP_DISPLAY_ADDRESS:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      if (IsMsgAttach (extra))
+        mutt_display_address (extra->bdy->hdr->env);
+      else
+        mutt_display_address (extra->hdr->env);
+      break;
+
+    case OP_ENTER_COMMAND:
+      old_smart_wrap = option (OPTWRAP);
+      old_markers = option (OPTMARKERS);
+      old_PagerIndexLines = PagerIndexLines;
+
+      CurrentMenu = MENU_PAGER;
+      mutt_enter_command ();
+
+      if (option (OPTNEEDRESORT)) {
+        unset_option (OPTNEEDRESORT);
+        CHECK_MODE (IsHeader (extra));
+        set_option (OPTNEEDRESORT);
+      }
+
+      if (old_PagerIndexLines != PagerIndexLines) {
+        if (index)
+          mutt_menuDestroy (&index);
+        index = NULL;
+      }
+
+      if (option (OPTWRAP) != old_smart_wrap ||
+          option (OPTMARKERS) != old_markers) {
+        if (flags & M_PAGER_RETWINCH) {
+          ch = -1;
+          rc = OP_REFORMAT_WINCH;
+          continue;
+        }
+
+        /* count the real lines above */
+        j = 0;
+        for (i = 0; i <= topline; i++) {
+          if (!lineInfo[i].continuation)
+            j++;
+        }
+
+        /* we need to restart the whole thing */
+        for (i = 0; i < maxLine; i++) {
+          lineInfo[i].offset = 0;
+          lineInfo[i].type = -1;
+          lineInfo[i].continuation = 0;
+          lineInfo[i].chunks = 0;
+          lineInfo[i].search_cnt = -1;
+          lineInfo[i].quote = NULL;
+
+          safe_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t));
+          if (SearchCompiled && lineInfo[i].search)
+            FREE (&(lineInfo[i].search));
+        }
+
+        if (SearchCompiled) {
+          regfree (&SearchRE);
+          SearchCompiled = 0;
+        }
+        SearchFlag = 0;
+
+        /* try to keep the old position */
+        topline = 0;
+        lastLine = 0;
+        while (j > 0 && display_line (fp, &last_pos, &lineInfo, topline,
+                                      &lastLine, &maxLine,
+                                      (has_types ? M_TYPES : 0),
+                                      &QuoteList, &q_level, &force_redraw,
+                                      &SearchRE) == 0) {
+          redraw |= REDRAW_SIDEBAR;
+          if (!lineInfo[topline].continuation)
+            j--;
+          if (j > 0)
+            topline++;
+        }
+
+        ch = 0;
+      }
+
+      if (option (OPTFORCEREDRAWPAGER))
+        redraw = REDRAW_FULL;
+      unset_option (OPTFORCEREDRAWINDEX);
+      unset_option (OPTFORCEREDRAWPAGER);
+      break;
+
+    case OP_FLAG_MESSAGE:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_POP
-       if (Context->magic == M_POP)
-       {
-         mutt_flushinp ();
-         mutt_error _("Can't change 'important' flag on POP server.");
-         break;
-       }
+      if (Context->magic == M_POP) {
+        mutt_flushinp ();
+        mutt_error _("Can't change 'important' flag on POP server.");
+
+        break;
+      }
 #endif
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_WRITE);
+      CHECK_IMAP_ACL (IMAP_ACL_WRITE);
 #endif
 
 #ifdef USE_NNTP
-       if (Context->magic == M_NNTP)
-       {
-         mutt_flushinp ();
-         mutt_error _("Can't change 'important' flag on NNTP server.");
-         break;
-       }
+      if (Context->magic == M_NNTP) {
+        mutt_flushinp ();
+        mutt_error _("Can't change 'important' flag on NNTP server.");
+
+        break;
+      }
 #endif
 
-       mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
-       redraw = REDRAW_STATUS | REDRAW_INDEX;
-       if (option (OPTRESOLVE))
-       {
-         ch = -1;
-         rc = OP_MAIN_NEXT_UNDELETED;
-       }
-       break;
-
-      case OP_PIPE:
-       CHECK_MODE(IsHeader (extra) || IsAttach (extra));
-       if (IsAttach (extra))
-         mutt_pipe_attachment_list (extra->fp, 0, extra->bdy, 0);
-       else
-         mutt_pipe_message (extra->hdr);
-       MAYBE_REDRAW (redraw);
-       break;
-
-      case OP_PRINT:
-       CHECK_MODE(IsHeader (extra) || IsAttach (extra));
-        if (IsAttach (extra))
-         mutt_print_attachment_list (extra->fp, 0, extra->bdy);
-        else
-         mutt_print_message (extra->hdr);
-       break;
+      mutt_set_flag (Context, extra->hdr, M_FLAG, !extra->hdr->flagged);
+      redraw = REDRAW_STATUS | REDRAW_INDEX;
+      if (option (OPTRESOLVE)) {
+        ch = -1;
+        rc = OP_MAIN_NEXT_UNDELETED;
+      }
+      break;
 
-      case OP_MAIL:
-       CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
-        CHECK_ATTACH;      
-       ci_send_message (0, NULL, NULL, extra->ctx, NULL);
-       redraw = REDRAW_FULL;
-       break;
+    case OP_PIPE:
+      CHECK_MODE (IsHeader (extra) || IsAttach (extra));
+      if (IsAttach (extra))
+        mutt_pipe_attachment_list (extra->fp, 0, extra->bdy, 0);
+      else
+        mutt_pipe_message (extra->hdr);
+      MAYBE_REDRAW (redraw);
+      break;
+
+    case OP_PRINT:
+      CHECK_MODE (IsHeader (extra) || IsAttach (extra));
+      if (IsAttach (extra))
+        mutt_print_attachment_list (extra->fp, 0, extra->bdy);
+      else
+        mutt_print_message (extra->hdr);
+      break;
+
+    case OP_MAIL:
+      CHECK_MODE (IsHeader (extra) && !IsAttach (extra));
+      CHECK_ATTACH;
+      ci_send_message (0, NULL, NULL, extra->ctx, NULL);
+      redraw = REDRAW_FULL;
+      break;
 
 #ifdef USE_NNTP
-      case OP_POST:
-       CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
-       CHECK_ATTACH;
-       if (extra->ctx && extra->ctx->magic == M_NNTP &&
-           !((NNTP_DATA *)extra->ctx->data)->allowed &&
-           query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
-         break;
-       ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
-       redraw = REDRAW_FULL;
-       break;
-
-      case OP_FORWARD_TO_GROUP:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-       CHECK_ATTACH;
-       if (extra->ctx && extra->ctx->magic == M_NNTP &&
-           !((NNTP_DATA *)extra->ctx->data)->allowed &&
-           query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
-         break;
-       if (IsMsgAttach (extra))
-         mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
-                              extra->idxlen, extra->bdy, SENDNEWS);
-       else
-         ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
-
-      case OP_FOLLOWUP:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-       CHECK_ATTACH;
+    case OP_POST:
+      CHECK_MODE (IsHeader (extra) && !IsAttach (extra));
+      CHECK_ATTACH;
+      if (extra->ctx && extra->ctx->magic == M_NNTP &&
+          !((NNTP_DATA *) extra->ctx->data)->allowed &&
+          query_quadoption (OPT_TOMODERATED,
+                            _
+                            ("Posting to this group not allowed, may be moderated. Continue?"))
+          != M_YES)
+        break;
+      ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL);
+      redraw = REDRAW_FULL;
+      break;
 
+    case OP_FORWARD_TO_GROUP:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+      if (extra->ctx && extra->ctx->magic == M_NNTP &&
+          !((NNTP_DATA *) extra->ctx->data)->allowed &&
+          query_quadoption (OPT_TOMODERATED,
+                            _
+                            ("Posting to this group not allowed, may be moderated. Continue?"))
+          != M_YES)
+        break;
+      if (IsMsgAttach (extra))
+        mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
+                             extra->idxlen, extra->bdy, SENDNEWS);
+      else
+        ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, extra->ctx,
+                         extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
+
+    case OP_FOLLOWUP:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+
+      if (IsMsgAttach (extra))
+        followup_to = extra->bdy->hdr->env->followup_to;
+      else
+        followup_to = extra->hdr->env->followup_to;
+
+      if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
+          query_quadoption (OPT_FOLLOWUPTOPOSTER,
+                            _("Reply by mail as poster prefers?")) != M_YES) {
+        if (extra->ctx && extra->ctx->magic == M_NNTP
+            && !((NNTP_DATA *) extra->ctx->data)->allowed
+            && query_quadoption (OPT_TOMODERATED,
+                                 _
+                                 ("Posting to this group not allowed, may be moderated. Continue?"))
+            != M_YES)
+          break;
         if (IsMsgAttach (extra))
-         followup_to = extra->bdy->hdr->env->followup_to;
+          mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
+                             extra->idxlen, extra->bdy, SENDNEWS | SENDREPLY);
         else
-         followup_to = extra->hdr->env->followup_to;
-
-       if (!followup_to || mutt_strcasecmp (followup_to, "poster") ||
-           query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
-       {
-         if (extra->ctx && extra->ctx->magic == M_NNTP &&
-             !((NNTP_DATA *)extra->ctx->data)->allowed &&
-             query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != M_YES)
-           break;
-         if (IsMsgAttach (extra))
-           mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
-                              extra->idxlen, extra->bdy, SENDNEWS|SENDREPLY);
-         else
-           ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL,
-                            extra->ctx, extra->hdr);
-         redraw = REDRAW_FULL;
-         break;
-       }
+          ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL,
+                           extra->ctx, extra->hdr);
+        redraw = REDRAW_FULL;
+        break;
+      }
 #endif
 
-      case OP_REPLY:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        CHECK_ATTACH;      
-        if (IsMsgAttach (extra)) 
-         mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
-                            extra->idxlen, extra->bdy,
-                            SENDREPLY);
-       else
-         ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
-
-      case OP_RECALL_MESSAGE:
-       CHECK_MODE(IsHeader (extra) && !IsAttach(extra));
-        CHECK_ATTACH;
-       ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
+    case OP_REPLY:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
+                           extra->idxlen, extra->bdy, SENDREPLY);
+      else
+        ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
 
-      case OP_GROUP_REPLY:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        CHECK_ATTACH;
-        if (IsMsgAttach (extra))
-         mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
-                            extra->idxlen, extra->bdy, SENDREPLY|SENDGROUPREPLY);
-        else
-         ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
+    case OP_RECALL_MESSAGE:
+      CHECK_MODE (IsHeader (extra) && !IsAttach (extra));
+      CHECK_ATTACH;
+      ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
 
-      case OP_LIST_REPLY:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        CHECK_ATTACH;        
-        if (IsMsgAttach (extra))
-         mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
-                            extra->idxlen, extra->bdy, SENDREPLY|SENDLISTREPLY);
-        else
-         ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
+    case OP_GROUP_REPLY:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
+                           extra->idxlen, extra->bdy,
+                           SENDREPLY | SENDGROUPREPLY);
+      else
+        ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx,
+                         extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
 
-      case OP_FORWARD_MESSAGE:
-       CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
-        CHECK_ATTACH;
-        if (IsMsgAttach (extra))
-         mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
-                              extra->idxlen, extra->bdy, 0);
-        else
-         ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
+    case OP_LIST_REPLY:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_reply (extra->fp, extra->hdr, extra->idx,
+                           extra->idxlen, extra->bdy,
+                           SENDREPLY | SENDLISTREPLY);
+      else
+        ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx,
+                         extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
 
-      case OP_DECRYPT_SAVE:
-        if (!WithCrypto)
-        {
-          ch = -1;
-          break;
-        }
-       /* fall through */
-      case OP_SAVE:
-       if (IsAttach (extra))
-       {
-         mutt_save_attachment_list (extra->fp, 0, extra->bdy, extra->hdr, NULL);
-         break;
-       }
-       /* fall through */
-      case OP_COPY_MESSAGE:
-      case OP_DECODE_SAVE:
-      case OP_DECODE_COPY:
-      case OP_DECRYPT_COPY:
-        if (!WithCrypto && ch == OP_DECRYPT_COPY)
-        {
+    case OP_FORWARD_MESSAGE:
+      CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
+      CHECK_ATTACH;
+      if (IsMsgAttach (extra))
+        mutt_attach_forward (extra->fp, extra->hdr, extra->idx,
+                             extra->idxlen, extra->bdy, 0);
+      else
+        ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
+
+    case OP_DECRYPT_SAVE:
+      if (!WithCrypto) {
+        ch = -1;
+        break;
+      }
+      /* fall through */
+    case OP_SAVE:
+      if (IsAttach (extra)) {
+        mutt_save_attachment_list (extra->fp, 0, extra->bdy, extra->hdr,
+                                   NULL);
+        break;
+      }
+      /* fall through */
+    case OP_COPY_MESSAGE:
+    case OP_DECODE_SAVE:
+    case OP_DECODE_COPY:
+    case OP_DECRYPT_COPY:
+      if (!WithCrypto && ch == OP_DECRYPT_COPY) {
+        ch = -1;
+        break;
+      }
+      CHECK_MODE (IsHeader (extra));
+      if (mutt_save_message (extra->hdr,
+                             (ch == OP_DECRYPT_SAVE) ||
+                             (ch == OP_SAVE) || (ch == OP_DECODE_SAVE),
+                             (ch == OP_DECODE_SAVE) || (ch == OP_DECODE_COPY),
+                             (ch == OP_DECRYPT_SAVE)
+                             || (ch == OP_DECRYPT_COPY) || 0, &redraw) == 0
+          && (ch == OP_SAVE || ch == OP_DECODE_SAVE
+              || ch == OP_DECRYPT_SAVE)) {
+        if (option (OPTRESOLVE)) {
           ch = -1;
-          break;
+          rc = OP_MAIN_NEXT_UNDELETED;
         }
-       CHECK_MODE(IsHeader (extra));
-       if (mutt_save_message (extra->hdr,
-                              (ch == OP_DECRYPT_SAVE) ||
-                              (ch == OP_SAVE) || (ch == OP_DECODE_SAVE),
-                              (ch == OP_DECODE_SAVE) || (ch == OP_DECODE_COPY),
-                              (ch == OP_DECRYPT_SAVE) || (ch == OP_DECRYPT_COPY) ||
-                              0,
-                              &redraw) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE
-                                                || ch == OP_DECRYPT_SAVE
-                                                ))
-       {
-         if (option (OPTRESOLVE))
-         {
-           ch = -1;
-           rc = OP_MAIN_NEXT_UNDELETED;
-         }
-         else
-           redraw |= REDRAW_STATUS | REDRAW_INDEX;
-       }
-       MAYBE_REDRAW (redraw);
-       break;
-
-      case OP_SHELL_ESCAPE:
-       mutt_shell_escape ();
-       MAYBE_REDRAW (redraw);
-       break;
-
-      case OP_TAG:
-       CHECK_MODE(IsHeader (extra));
-       mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged);
-
-       Context->last_tag = extra->hdr->tagged ? extra->hdr :
-         ((Context->last_tag == extra->hdr && !extra->hdr->tagged)
-          ? NULL : Context->last_tag);
-
-       redraw = REDRAW_STATUS | REDRAW_INDEX;
-       if (option (OPTRESOLVE))
-       {
-         ch = -1;
-         rc = OP_NEXT_ENTRY;
-       }
-       break;
-
-      case OP_TOGGLE_NEW:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+        else
+          redraw |= REDRAW_STATUS | REDRAW_INDEX;
+      }
+      MAYBE_REDRAW (redraw);
+      break;
+
+    case OP_SHELL_ESCAPE:
+      mutt_shell_escape ();
+      MAYBE_REDRAW (redraw);
+      break;
+
+    case OP_TAG:
+      CHECK_MODE (IsHeader (extra));
+      mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged);
+
+      Context->last_tag = extra->hdr->tagged ? extra->hdr :
+        ((Context->last_tag == extra->hdr && !extra->hdr->tagged)
+         ? NULL : Context->last_tag);
+
+      redraw = REDRAW_STATUS | REDRAW_INDEX;
+      if (option (OPTRESOLVE)) {
+        ch = -1;
+        rc = OP_NEXT_ENTRY;
+      }
+      break;
+
+    case OP_TOGGLE_NEW:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_SEEN);
+      CHECK_IMAP_ACL (IMAP_ACL_SEEN);
 #endif
 
-       if (extra->hdr->read || extra->hdr->old)
-         mutt_set_flag (Context, extra->hdr, M_NEW, 1);
-       else if (!first)
-         mutt_set_flag (Context, extra->hdr, M_READ, 1);
-       first = 0;
-        Context->msgnotreadyet = -1;
-       redraw = REDRAW_STATUS | REDRAW_INDEX;
-       if (option (OPTRESOLVE))
-       {
-         ch = -1;
-         rc = OP_MAIN_NEXT_UNDELETED;
-       }
-       break;
-
-      case OP_UNDELETE:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+      if (extra->hdr->read || extra->hdr->old)
+        mutt_set_flag (Context, extra->hdr, M_NEW, 1);
+      else if (!first)
+        mutt_set_flag (Context, extra->hdr, M_READ, 1);
+      first = 0;
+      Context->msgnotreadyet = -1;
+      redraw = REDRAW_STATUS | REDRAW_INDEX;
+      if (option (OPTRESOLVE)) {
+        ch = -1;
+        rc = OP_MAIN_NEXT_UNDELETED;
+      }
+      break;
+
+    case OP_UNDELETE:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-       mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
-       mutt_set_flag (Context, extra->hdr, M_PURGED, 0);
-       redraw = REDRAW_STATUS | REDRAW_INDEX;
-       if (option (OPTRESOLVE))
-       {
-         ch = -1;
-         rc = OP_NEXT_ENTRY;
-       }
-       break;
-
-      case OP_UNDELETE_THREAD:
-      case OP_UNDELETE_SUBTHREAD:
-       CHECK_MODE(IsHeader (extra));
-       CHECK_READONLY;
+      mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
+      mutt_set_flag (Context, extra->hdr, M_PURGED, 0);
+      redraw = REDRAW_STATUS | REDRAW_INDEX;
+      if (option (OPTRESOLVE)) {
+        ch = -1;
+        rc = OP_NEXT_ENTRY;
+      }
+      break;
+
+    case OP_UNDELETE_THREAD:
+    case OP_UNDELETE_SUBTHREAD:
+      CHECK_MODE (IsHeader (extra));
+      CHECK_READONLY;
 
 #ifdef USE_IMAP
-CHECK_IMAP_ACL(IMAP_ACL_DELETE);
+      CHECK_IMAP_ACL (IMAP_ACL_DELETE);
 #endif
 
-       r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
-                                 ch == OP_UNDELETE_THREAD ? 0 : 1)
-         + mutt_thread_set_flag (extra->hdr, M_PURGED, 0,
-                                 ch == OP_UNDELETE_THREAD ? 0 : 1);
-
-       if (r > -1)
-       {
-         if (option (OPTRESOLVE))
-         {
-           rc = (ch == OP_DELETE_THREAD) ?
-                                 OP_MAIN_NEXT_THREAD : OP_MAIN_NEXT_SUBTHREAD;
-           ch = -1;
-         }
-
-         if (!option (OPTRESOLVE) && PagerIndexLines)
-           redraw = REDRAW_FULL;
-         else
-           redraw = REDRAW_STATUS | REDRAW_INDEX;
-       }
-       break;
-
-      case OP_VERSION:
-       mutt_version ();
-       break;
-
-      case OP_BUFFY_LIST:
-       mutt_buffy_list ();
-    redraw |= REDRAW_SIDEBAR;
-       break;
-
-      case OP_VIEW_ATTACHMENTS:
-        if (flags & M_PAGER_ATTACHMENT)
-        {
-         ch = -1;
-         rc = OP_ATTACH_COLLAPSE;
-         break;
-       }
-       CHECK_MODE(IsHeader (extra));
-       mutt_view_attachments (extra->hdr);
-       if (extra->hdr->attach_del)
-         Context->changed = 1;
-       redraw = REDRAW_FULL;
-       break;
-
-
-      case OP_MAIL_KEY:
-        if (!(WithCrypto & APPLICATION_PGP))
-        {
+      r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
+                                ch == OP_UNDELETE_THREAD ? 0 : 1)
+        + mutt_thread_set_flag (extra->hdr, M_PURGED, 0,
+                                ch == OP_UNDELETE_THREAD ? 0 : 1);
+
+      if (r > -1) {
+        if (option (OPTRESOLVE)) {
+          rc = (ch == OP_DELETE_THREAD) ?
+            OP_MAIN_NEXT_THREAD : OP_MAIN_NEXT_SUBTHREAD;
           ch = -1;
-          break;
         }
-       CHECK_MODE(IsHeader(extra));
-        CHECK_ATTACH;
-       ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr);
-       redraw = REDRAW_FULL;
-       break;
 
+        if (!option (OPTRESOLVE) && PagerIndexLines)
+          redraw = REDRAW_FULL;
+        else
+          redraw = REDRAW_STATUS | REDRAW_INDEX;
+      }
+      break;
 
-      case OP_FORGET_PASSPHRASE:
-       crypt_forget_passphrase ();
-       break;
+    case OP_VERSION:
+      mutt_version ();
+      break;
 
-      case OP_EXTRACT_KEYS:
-        if (!WithCrypto)
-        {
-          ch = -1;
-          break;
-        }
-        CHECK_MODE(IsHeader(extra));
-       crypt_extract_keys_from_messages(extra->hdr);
-        redraw = REDRAW_FULL;
+    case OP_BUFFY_LIST:
+      mutt_buffy_list ();
+      redraw |= REDRAW_SIDEBAR;
+      break;
+
+    case OP_VIEW_ATTACHMENTS:
+      if (flags & M_PAGER_ATTACHMENT) {
+        ch = -1;
+        rc = OP_ATTACH_COLLAPSE;
+        break;
+      }
+      CHECK_MODE (IsHeader (extra));
+      mutt_view_attachments (extra->hdr);
+      if (extra->hdr->attach_del)
+        Context->changed = 1;
+      redraw = REDRAW_FULL;
+      break;
+
+
+    case OP_MAIL_KEY:
+      if (!(WithCrypto & APPLICATION_PGP)) {
+        ch = -1;
+        break;
+      }
+      CHECK_MODE (IsHeader (extra));
+      CHECK_ATTACH;
+      ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
+
+
+    case OP_FORGET_PASSPHRASE:
+      crypt_forget_passphrase ();
+      break;
+
+    case OP_EXTRACT_KEYS:
+      if (!WithCrypto) {
+        ch = -1;
         break;
+      }
+      CHECK_MODE (IsHeader (extra));
+      crypt_extract_keys_from_messages (extra->hdr);
+      redraw = REDRAW_FULL;
+      break;
 
-         case OP_SIDEBAR_SCROLL_UP:
-         case OP_SIDEBAR_SCROLL_DOWN:
-         case OP_SIDEBAR_NEXT:
-         case OP_SIDEBAR_NEXT_NEW:
-         case OP_SIDEBAR_PREV:
-         case OP_SIDEBAR_PREV_NEW:
-           scroll_sidebar(ch, MENU_PAGER);
-               break;
-      default:
-       ch = -1;
-       break;
+    case OP_SIDEBAR_SCROLL_UP:
+    case OP_SIDEBAR_SCROLL_DOWN:
+    case OP_SIDEBAR_NEXT:
+    case OP_SIDEBAR_NEXT_NEW:
+    case OP_SIDEBAR_PREV:
+    case OP_SIDEBAR_PREV_NEW:
+      scroll_sidebar (ch, MENU_PAGER);
+      break;
+    default:
+      ch = -1;
+      break;
     }
   }
 
   fclose (fp);
   if (IsHeader (extra))
     Context->msgnotreadyet = -1;
-    
+
   cleanup_quote (&QuoteList);
-  
-  for (i = 0; i < maxLine ; i++)
-  {
+
+  for (i = 0; i < maxLine; i++) {
     FREE (&(lineInfo[i].syntax));
     if (SearchCompiled && lineInfo[i].search)
       FREE (&(lineInfo[i].search));
   }
-  if (SearchCompiled)
-  {
+  if (SearchCompiled) {
     regfree (&SearchRE);
     SearchCompiled = 0;
   }
   FREE (&lineInfo);
   if (index)
-    mutt_menuDestroy(&index);
+    mutt_menuDestroy (&index);
   return (rc != -1 ? rc : 0);
 }
diff --git a/pager.h b/pager.h
index 762e0d3..8772f3f 100644 (file)
--- a/pager.h
+++ b/pager.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* dynamic internal flags */
 #define M_SHOWFLAT     (1<<0)
 #define M_SHOW         (M_SHOWCOLOR | M_SHOWFLAT)
 
 /* exported flags for mutt_(do_)?pager */
-#define M_PAGER_NSKIP          (1<<5)  /* preserve whitespace with smartwrap */
-#define M_PAGER_MARKER         (1<<6)  /* use markers if option is set */
-#define M_PAGER_RETWINCH       (1<<7)  /* need reformatting on SIGWINCH */
+#define M_PAGER_NSKIP          (1<<5)  /* preserve whitespace with smartwrap */
+#define M_PAGER_MARKER         (1<<6)  /* use markers if option is set */
+#define M_PAGER_RETWINCH       (1<<7)  /* need reformatting on SIGWINCH */
 #define M_PAGER_MESSAGE                (M_SHOWCOLOR | M_PAGER_MARKER)
 #define M_PAGER_ATTACHMENT     (1<<8)
 
 #define M_DISPLAYFLAGS (M_SHOW | M_PAGER_NSKIP | M_PAGER_MARKER)
 
-typedef struct
-{
-  CONTEXT *ctx;        /* current mailbox */
-  HEADER *hdr; /* current message */
-  BODY *bdy;   /* current attachment */
-  FILE *fp;    /* source stream */
-  ATTACHPTR **idx;     /* attachment information */
+typedef struct {
+  CONTEXT *ctx;                 /* current mailbox */
+  HEADER *hdr;                  /* current message */
+  BODY *bdy;                    /* current attachment */
+  FILE *fp;                     /* source stream */
+  ATTACHPTR **idx;              /* attachment information */
   short idxlen;
 } pager_t;
 
diff --git a/parse.c b/parse.c
index 6a07654..b8c322a 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
  * lines.  ``line'' must point to a dynamically allocated string; it is
  * increased if more space is required to fit the whole line.
  */
-static char *read_rfc822_line (FILE *f, char *line, size_t *linelen)
+static char *read_rfc822_line (FILE * f, char *line, size_t * linelen)
 {
   char *buf = line;
   char ch;
   size_t offset = 0;
 
-  FOREVER
-  {
-    if (fgets (buf, *linelen - offset, f) == NULL ||   /* end of file or */
-       (ISSPACE (*line) && !offset))                   /* end of headers */ 
-    {
+  FOREVER {
+    if (fgets (buf, *linelen - offset, f) == NULL ||    /* end of file or */
+        (ISSPACE (*line) && !offset)) { /* end of headers */
       *line = 0;
       return (line);
     }
 
     buf += strlen (buf) - 1;
-    if (*buf == '\n')
-    {
+    if (*buf == '\n') {
       /* we did get a full line. remove trailing space */
       while (ISSPACE (*buf))
-       *buf-- = 0;     /* we cannot come beyond line's beginning because
-                        * it begins with a non-space */
+        *buf-- = 0;             /* we cannot come beyond line's beginning because
+                                 * it begins with a non-space */
 
       /* check to see if the next line is a continuation line */
-      if ((ch = fgetc (f)) != ' ' && ch != '\t')
-      {
-       ungetc (ch, f);
-       return (line); /* next line is a separate header field or EOH */
+      if ((ch = fgetc (f)) != ' ' && ch != '\t') {
+        ungetc (ch, f);
+        return (line);          /* next line is a separate header field or EOH */
       }
 
       /* eat tabs and spaces from the beginning of the continuation line */
-      while ((ch = fgetc (f)) == ' ' || ch == '\t')
-       ;
+      while ((ch = fgetc (f)) == ' ' || ch == '\t');
       ungetc (ch, f);
-      *++buf = ' '; /* string is still terminated because we removed
-                      at least one whitespace char above */
+      *++buf = ' ';             /* string is still terminated because we removed
+                                   at least one whitespace char above */
     }
 
     buf++;
     offset = buf - line;
-    if (*linelen < offset + STRING)
-    {
+    if (*linelen < offset + STRING) {
       /* grow the buffer */
       *linelen += STRING;
       safe_realloc (&line, *linelen);
@@ -95,8 +89,7 @@ LIST *mutt_parse_references (char *s, int in_reply_to)
   int m, n = 0;
   char *o = NULL, *new, *at;
 
-  while ((s = strtok (s, " \t;")) != NULL)
-  {
+  while ((s = strtok (s, " \t;")) != NULL) {
     /*
      * some mail clients add other garbage besides message-ids, so do a quick
      * check to make sure this looks like a valid message-id
@@ -106,30 +99,25 @@ LIST *mutt_parse_references (char *s, int in_reply_to)
     t = NULL;
     new = NULL;
 
-    if (*s == '<')
-    {
+    if (*s == '<') {
       n = strlen (s);
-      if (s[n-1] != '>')
-      {
-       o = s;
-       s = NULL;
-       continue;
+      if (s[n - 1] != '>') {
+        o = s;
+        s = NULL;
+        continue;
       }
 
       new = safe_strdup (s);
     }
-    else if (o)
-    {
+    else if (o) {
       m = strlen (s);
-      if (s[m - 1] == '>')
-      {
-       new = safe_malloc (sizeof (char) * (n + m + 1));
-       strcpy (new, o);        /* __STRCPY_CHECKED__ */
-       strcpy (new + n, s);    /* __STRCPY_CHECKED__ */
+      if (s[m - 1] == '>') {
+        new = safe_malloc (sizeof (char) * (n + m + 1));
+        strcpy (new, o);        /* __STRCPY_CHECKED__ */
+        strcpy (new + n, s);    /* __STRCPY_CHECKED__ */
       }
     }
-    if (new)
-    {
+    if (new) {
       /* make sure that this really does look like a message-id.
        * it should have exactly one @, and if we're looking at
        * an in-reply-to header, make sure that the part before
@@ -137,14 +125,13 @@ LIST *mutt_parse_references (char *s, int in_reply_to)
        * an email address
        */
       if (!(at = strchr (new, '@')) || strchr (at + 1, '@')
-         || (in_reply_to && at - new <= 8))
-       FREE (&new);
-      else
-      {
-       t = (LIST *) safe_malloc (sizeof (LIST));
-       t->data = new;
-       t->next = lst;
-       lst = t;
+          || (in_reply_to && at - new <= 8))
+        FREE (&new);
+      else {
+        t = (LIST *) safe_malloc (sizeof (LIST));
+        t->data = new;
+        t->next = lst;
+        lst = t;
       }
     }
     o = NULL;
@@ -156,20 +143,23 @@ LIST *mutt_parse_references (char *s, int in_reply_to)
 
 int mutt_check_encoding (const char *c)
 {
-  if (ascii_strncasecmp ("7bit", c, sizeof ("7bit")-1) == 0)
+  if (ascii_strncasecmp ("7bit", c, sizeof ("7bit") - 1) == 0)
     return (ENC7BIT);
-  else if (ascii_strncasecmp ("8bit", c, sizeof ("8bit")-1) == 0)
+  else if (ascii_strncasecmp ("8bit", c, sizeof ("8bit") - 1) == 0)
     return (ENC8BIT);
-  else if (ascii_strncasecmp ("binary", c, sizeof ("binary")-1) == 0)
+  else if (ascii_strncasecmp ("binary", c, sizeof ("binary") - 1) == 0)
     return (ENCBINARY);
-  else if (ascii_strncasecmp ("quoted-printable", c, sizeof ("quoted-printable")-1) == 0)
+  else
+    if (ascii_strncasecmp
+        ("quoted-printable", c, sizeof ("quoted-printable") - 1) == 0)
     return (ENCQUOTEDPRINTABLE);
-  else if (ascii_strncasecmp ("base64", c, sizeof("base64")-1) == 0)
+  else if (ascii_strncasecmp ("base64", c, sizeof ("base64") - 1) == 0)
     return (ENCBASE64);
-  else if (ascii_strncasecmp ("x-uuencode", c, sizeof("x-uuencode")-1) == 0)
+  else if (ascii_strncasecmp ("x-uuencode", c, sizeof ("x-uuencode") - 1) ==
+           0)
     return (ENCUUENCODED);
 #ifdef SUN_ATTACHMENT
-  else if (ascii_strncasecmp ("uuencode", c, sizeof("uuencode")-1) == 0)
+  else if (ascii_strncasecmp ("uuencode", c, sizeof ("uuencode") - 1) == 0)
     return (ENCUUENCODED);
 #endif
   else
@@ -184,18 +174,16 @@ static PARAMETER *parse_parameters (const char *s)
   size_t i;
 
   dprint (2, (debugfile, "parse_parameters: `%s'\n", s));
-  
-  while (*s)
-  {
-    if ((p = strpbrk (s, "=;")) == NULL)
-    {
-      dprint(1, (debugfile, "parse_parameters: malformed parameter: %s\n", s));
+
+  while (*s) {
+    if ((p = strpbrk (s, "=;")) == NULL) {
+      dprint (1,
+              (debugfile, "parse_parameters: malformed parameter: %s\n", s));
       goto bail;
     }
 
     /* if we hit a ; now the parameter has no value, just skip it */
-    if (*p != ';')
-    {
+    if (*p != ';') {
       i = p - s;
 
       new = mutt_new_parameter ();
@@ -206,22 +194,20 @@ static PARAMETER *parse_parameters (const char *s)
 
       /* remove whitespace from the end of the attribute name */
       while (ISSPACE (new->attribute[--i]))
-       new->attribute[i] = 0;
+        new->attribute[i] = 0;
 
-      s = p + 1; /* skip over the = */
+      s = p + 1;                /* skip over the = */
       SKIPWS (s);
 
-      if (*s == '"')
-      {
+      if (*s == '"') {
         int state_ascii = 1;
-       s++;
-       for (i=0; *s && i < sizeof (buffer) - 1; i++, s++)
-       {
-         if (!option (OPTSTRICTMIME)) {
+
+        s++;
+        for (i = 0; *s && i < sizeof (buffer) - 1; i++, s++) {
+          if (!option (OPTSTRICTMIME)) {
             /* As iso-2022-* has a characer of '"' with non-ascii state,
-            * ignore it. */
-            if (*s == 0x1b && i < sizeof (buffer) - 2)
-            {
+             * ignore it. */
+            if (*s == 0x1b && i < sizeof (buffer) - 2) {
               if (s[1] == '(' && (s[2] == 'B' || s[2] == 'J'))
                 state_ascii = 1;
               else
@@ -230,63 +216,61 @@ static PARAMETER *parse_parameters (const char *s)
           }
           if (state_ascii && *s == '"')
             break;
-         if (*s == '\\')
-         {
-           /* Quote the next character */
-           buffer[i] = s[1];
-           if (!*++s)
-             break;
-         }
-         else
-           buffer[i] = *s;
-       }
-       buffer[i] = 0;
-       if (*s)
-         s++; /* skip over the " */
+          if (*s == '\\') {
+            /* Quote the next character */
+            buffer[i] = s[1];
+            if (!*++s)
+              break;
+          }
+          else
+            buffer[i] = *s;
+        }
+        buffer[i] = 0;
+        if (*s)
+          s++;                  /* skip over the " */
       }
-      else
-      {
-       for (i=0; *s && *s != ' ' && *s != ';' && i < sizeof (buffer) - 1; i++, s++)
-         buffer[i] = *s;
-       buffer[i] = 0;
+      else {
+        for (i = 0; *s && *s != ' ' && *s != ';' && i < sizeof (buffer) - 1;
+             i++, s++)
+          buffer[i] = *s;
+        buffer[i] = 0;
       }
 
       new->value = safe_strdup (buffer);
 
       dprint (2, (debugfile, "parse_parameter: `%s' = `%s'\n",
-                 new->attribute ? new->attribute : "",
-                 new->value ? new->value : ""));
-      
+                  new->attribute ? new->attribute : "",
+                  new->value ? new->value : ""));
+
       /* Add this parameter to the list */
-      if (head)
-      {
-       cur->next = new;
-       cur = cur->next;
+      if (head) {
+        cur->next = new;
+        cur = cur->next;
       }
       else
-       head = cur = new;
+        head = cur = new;
     }
-    else
-    {
-      dprint (1, (debugfile, "parse_parameters(): parameter with no value: %s\n", s));
+    else {
+      dprint (1,
+              (debugfile, "parse_parameters(): parameter with no value: %s\n",
+               s));
       s = p;
     }
 
     /* Find the next parameter */
     if (*s != ';' && (s = strchr (s, ';')) == NULL)
-       break; /* no more parameters */
+      break;                    /* no more parameters */
 
-    do
-    {
+    do {
       s++;
 
       /* Move past any leading whitespace */
       SKIPWS (s);
     }
-    while (*s == ';'); /* skip empty parameters */
-  }    
+    while (*s == ';');          /* skip empty parameters */
+  }
 
-  bail:
+bail:
 
   rfc2231_decode_parameters (&head);
   return (head);
@@ -298,7 +282,7 @@ int mutt_check_mime_type (const char *s)
     return TYPETEXT;
   else if (ascii_strcasecmp ("multipart", s) == 0)
     return TYPEMULTIPART;
-#ifdef SUN_ATTACHMENT 
+#ifdef SUN_ATTACHMENT
   else if (ascii_strcasecmp ("x-sun-attachment", s) == 0)
     return TYPEMULTIPART;
 #endif
@@ -318,42 +302,40 @@ int mutt_check_mime_type (const char *s)
     return TYPEOTHER;
 }
 
-void mutt_parse_content_type (char *s, BODY *ct)
+void mutt_parse_content_type (char *s, BODY * ct)
 {
   char *pc;
   char *subtype;
 
   FREE (&ct->subtype);
-  mutt_free_parameter(&ct->parameter);
+  mutt_free_parameter (&ct->parameter);
 
   /* First extract any existing parameters */
-  if ((pc = strchr(s, ';')) != NULL)
-  {
+  if ((pc = strchr (s, ';')) != NULL) {
     *pc++ = 0;
     while (*pc && ISSPACE (*pc))
       pc++;
-    ct->parameter = parse_parameters(pc);
+    ct->parameter = parse_parameters (pc);
 
     /* Some pre-RFC1521 gateways still use the "name=filename" convention,
      * but if a filename has already been set in the content-disposition,
      * let that take precedence, and don't set it here */
-    if ((pc = mutt_get_parameter( "name", ct->parameter)) != 0 && !ct->filename)
-      ct->filename = safe_strdup(pc);
-    
+    if ((pc = mutt_get_parameter ("name", ct->parameter)) != 0
+        && !ct->filename)
+      ct->filename = safe_strdup (pc);
+
 #ifdef SUN_ATTACHMENT
     /* this is deep and utter perversion */
     if ((pc = mutt_get_parameter ("conversions", ct->parameter)) != 0)
       ct->encoding = mutt_check_encoding (pc);
 #endif
-    
+
   }
-  
+
   /* Now get the subtype */
-  if ((subtype = strchr(s, '/')))
-  {
+  if ((subtype = strchr (s, '/'))) {
     *subtype++ = '\0';
-    for(pc = subtype; *pc && !ISSPACE(*pc) && *pc != ';'; pc++)
-      ;
+    for (pc = subtype; *pc && !ISSPACE (*pc) && *pc != ';'; pc++);
     *pc = '\0';
     ct->subtype = safe_strdup (subtype);
   }
@@ -363,16 +345,14 @@ void mutt_parse_content_type (char *s, BODY *ct)
 
 #ifdef SUN_ATTACHMENT
   if (ascii_strcasecmp ("x-sun-attachment", s) == 0)
-      ct->subtype = safe_strdup ("x-sun-attachment");
+    ct->subtype = safe_strdup ("x-sun-attachment");
 #endif
 
-  if (ct->type == TYPEOTHER)
-  {
+  if (ct->type == TYPEOTHER) {
     ct->xtype = safe_strdup (s);
   }
 
-  if (ct->subtype == NULL)
-  {
+  if (ct->subtype == NULL) {
     /* Some older non-MIME mailers (i.e., mailtool, elm) have a content-type
      * field, so we can attempt to convert the type to BODY here.
      */
@@ -382,8 +362,7 @@ void mutt_parse_content_type (char *s, BODY *ct)
       ct->subtype = safe_strdup ("basic");
     else if (ct->type == TYPEMESSAGE)
       ct->subtype = safe_strdup ("rfc822");
-    else if (ct->type == TYPEOTHER)
-    {
+    else if (ct->type == TYPEOTHER) {
       char buffer[SHORT_STRING];
 
       ct->type = TYPEAPPLICATION;
@@ -395,17 +374,17 @@ void mutt_parse_content_type (char *s, BODY *ct)
   }
 
   /* Default character set for text types. */
-  if (ct->type == TYPETEXT)
-  {
+  if (ct->type == TYPETEXT) {
     if (!(pc = mutt_get_parameter ("charset", ct->parameter)))
       mutt_set_parameter ("charset", option (OPTSTRICTMIME) ? "us-ascii" :
-                         (const char *) mutt_get_first_charset (AssumedCharset),
-                         &ct->parameter);
+                          (const char *)
+                          mutt_get_first_charset (AssumedCharset),
+                          &ct->parameter);
   }
 
 }
 
-static void parse_content_disposition (char *s, BODY *ct)
+static void parse_content_disposition (char *s, BODY * ct)
 {
   PARAMETER *parms;
 
@@ -417,11 +396,12 @@ static void parse_content_disposition (char *s, BODY *ct)
     ct->disposition = DISPATTACH;
 
   /* Check to see if a default filename was given */
-  if ((s = strchr (s, ';')) != NULL)
-  {
+  if ((s = strchr (s, ';')) != NULL) {
     s++;
     SKIPWS (s);
-    if ((s = mutt_get_parameter ("filename", (parms = parse_parameters (s)))) != 0)
+    if ((s =
+         mutt_get_parameter ("filename",
+                             (parms = parse_parameters (s)))) != 0)
       mutt_str_replace (&ct->filename, s);
     if ((s = mutt_get_parameter ("name", parms)) != 0)
       ct->form_name = safe_strdup (s);
@@ -436,71 +416,67 @@ static void parse_content_disposition (char *s, BODY *ct)
  *             otherwise
  */
 
-BODY *mutt_read_mime_header (FILE *fp, int digest)
+BODY *mutt_read_mime_header (FILE * fp, int digest)
 {
-  BODY *p = mutt_new_body();
+  BODY *p = mutt_new_body ();
   char *c;
   char *line = safe_malloc (LONG_STRING);
   size_t linelen = LONG_STRING;
-  
-  p->hdr_offset  = ftell(fp);
 
-  p->encoding    = ENC7BIT; /* default from RFC1521 */
-  p->type        = digest ? TYPEMESSAGE : TYPETEXT;
+  p->hdr_offset = ftell (fp);
+
+  p->encoding = ENC7BIT;        /* default from RFC1521 */
+  p->type = digest ? TYPEMESSAGE : TYPETEXT;
   p->disposition = DISPINLINE;
-  
-  while (*(line = read_rfc822_line (fp, line, &linelen)) != 0)
-  {
+
+  while (*(line = read_rfc822_line (fp, line, &linelen)) != 0) {
     /* Find the value of the current header */
-    if ((c = strchr (line, ':')))
-    {
+    if ((c = strchr (line, ':'))) {
       *c = 0;
       c++;
       SKIPWS (c);
-      if (!*c)
-      {
-       dprint (1, (debugfile, "mutt_read_mime_header(): skipping empty header field: %s\n", line));
-       continue;
+      if (!*c) {
+        dprint (1,
+                (debugfile,
+                 "mutt_read_mime_header(): skipping empty header field: %s\n",
+                 line));
+        continue;
       }
     }
-    else
-    {
-      dprint (1, (debugfile, "read_mime_header: bogus MIME header: %s\n", line));
+    else {
+      dprint (1,
+              (debugfile, "read_mime_header: bogus MIME header: %s\n", line));
       break;
     }
 
-    if (!ascii_strncasecmp ("content-", line, 8))
-    {
+    if (!ascii_strncasecmp ("content-", line, 8)) {
       if (!ascii_strcasecmp ("type", line + 8))
-       mutt_parse_content_type (c, p);
+        mutt_parse_content_type (c, p);
       else if (!ascii_strcasecmp ("transfer-encoding", line + 8))
-       p->encoding = mutt_check_encoding (c);
+        p->encoding = mutt_check_encoding (c);
       else if (!ascii_strcasecmp ("disposition", line + 8))
-       parse_content_disposition (c, p);
-      else if (!ascii_strcasecmp ("description", line + 8))
-      {
-       mutt_str_replace (&p->description, c);
-       rfc2047_decode (&p->description);
+        parse_content_disposition (c, p);
+      else if (!ascii_strcasecmp ("description", line + 8)) {
+        mutt_str_replace (&p->description, c);
+        rfc2047_decode (&p->description);
       }
-    } 
+    }
 #ifdef SUN_ATTACHMENT
-    else if (!ascii_strncasecmp ("x-sun-", line, 6))
-    {
+    else if (!ascii_strncasecmp ("x-sun-", line, 6)) {
       if (!ascii_strcasecmp ("data-type", line + 6))
         mutt_parse_content_type (c, p);
       else if (!ascii_strcasecmp ("encoding-info", line + 6))
         p->encoding = mutt_check_encoding (c);
       else if (!ascii_strcasecmp ("content-lines", line + 6))
         mutt_set_parameter ("content-lines", c, &(p->parameter));
-      else if (!ascii_strcasecmp ("data-description", line + 6))
-      {
-       mutt_str_replace (&p->description, c);
+      else if (!ascii_strcasecmp ("data-description", line + 6)) {
+        mutt_str_replace (&p->description, c);
         rfc2047_decode (&p->description);
       }
     }
 #endif
   }
-  p->offset = ftell (fp); /* Mark the start of the real data */
+  p->offset = ftell (fp);       /* Mark the start of the real data */
   if (p->type == TYPETEXT && !p->subtype)
     p->subtype = safe_strdup ("plain");
   else if (p->type == TYPEMESSAGE && !p->subtype)
@@ -511,46 +487,44 @@ BODY *mutt_read_mime_header (FILE *fp, int digest)
   return (p);
 }
 
-void mutt_parse_part (FILE *fp, BODY *b)
+void mutt_parse_part (FILE * fp, BODY * b)
 {
   char *bound = 0;
 
-  switch (b->type)
-  {
-    case TYPEMULTIPART:
+  switch (b->type) {
+  case TYPEMULTIPART:
 #ifdef SUN_ATTACHMENT
-      if ( !ascii_strcasecmp (b->subtype, "x-sun-attachment") )
-          bound = "--------";
-      else
+    if (!ascii_strcasecmp (b->subtype, "x-sun-attachment"))
+      bound = "--------";
+    else
 #endif
-          bound = mutt_get_parameter ("boundary", b->parameter);
+      bound = mutt_get_parameter ("boundary", b->parameter);
 
-      fseek (fp, b->offset, SEEK_SET);
-      b->parts =  mutt_parse_multipart (fp, bound, 
-                                       b->offset + b->length,
-                                       ascii_strcasecmp ("digest", b->subtype) == 0);
-      break;
+    fseek (fp, b->offset, SEEK_SET);
+    b->parts = mutt_parse_multipart (fp, bound,
+                                     b->offset + b->length,
+                                     ascii_strcasecmp ("digest",
+                                                       b->subtype) == 0);
+    break;
 
-    case TYPEMESSAGE:
-      if (b->subtype)
-      {
-       fseek (fp, b->offset, SEEK_SET);
-       if (mutt_is_message_type(b->type, b->subtype))
-         b->parts = mutt_parse_messageRFC822 (fp, b);
-       else if (ascii_strcasecmp (b->subtype, "external-body") == 0)
-         b->parts = mutt_read_mime_header (fp, 0);
-       else
-         return;
-      }
-      break;
+  case TYPEMESSAGE:
+    if (b->subtype) {
+      fseek (fp, b->offset, SEEK_SET);
+      if (mutt_is_message_type (b->type, b->subtype))
+        b->parts = mutt_parse_messageRFC822 (fp, b);
+      else if (ascii_strcasecmp (b->subtype, "external-body") == 0)
+        b->parts = mutt_read_mime_header (fp, 0);
+      else
+        return;
+    }
+    break;
 
-    default:
-      return;
+  default:
+    return;
   }
 
   /* try to recover from parsing error */
-  if (!b->parts)
-  {
+  if (!b->parts) {
     b->type = TYPETEXT;
     mutt_str_replace (&b->subtype, "plain");
   }
@@ -567,7 +541,7 @@ void mutt_parse_part (FILE *fp, BODY *b)
  * NOTE: this assumes that `parent->length' has been set!
  */
 
-BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
+BODY *mutt_parse_messageRFC822 (FILE * fp, BODY * parent)
 {
   BODY *msg;
 
@@ -585,7 +559,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
   if (msg->length < 0)
     msg->length = 0;
 
-  mutt_parse_part(fp, msg);
+  mutt_parse_part (fp, msg);
   return (msg);
 }
 
@@ -602,7 +576,8 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
  *     digest          1 if reading a multipart/digest, 0 otherwise
  */
 
-BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int digest)
+BODY *mutt_parse_multipart (FILE * fp, const char *boundary, long end_off,
+                            int digest)
 {
 #ifdef SUN_ATTACHMENT
   int lines;
@@ -611,32 +586,30 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
   char buffer[LONG_STRING];
   BODY *head = 0, *last = 0, *new = 0;
   int i;
-  int final = 0; /* did we see the ending boundary? */
+  int final = 0;                /* did we see the ending boundary? */
 
-  if (!boundary)
-  {
+  if (!boundary) {
     mutt_error _("multipart message has no boundary parameter!");
+
     return (NULL);
   }
 
   blen = mutt_strlen (boundary);
-  while (ftell (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL)
-  {
+  while (ftell (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL) {
     len = mutt_strlen (buffer);
 
-    crlf =  (len > 1 && buffer[len - 2] == '\r') ? 1 : 0;
+    crlf = (len > 1 && buffer[len - 2] == '\r') ? 1 : 0;
 
     if (buffer[0] == '-' && buffer[1] == '-' &&
-       mutt_strncmp (buffer + 2, boundary, blen) == 0)
-    {
-      if (last)
-      {
-       last->length = ftell (fp) - last->offset - len - 1 - crlf;
-       if (last->parts && last->parts->length == 0)
-         last->parts->length = ftell (fp) - last->parts->offset - len - 1 - crlf;
-       /* if the body is empty, we can end up with a -1 length */
-       if (last->length < 0)
-         last->length = 0;
+        mutt_strncmp (buffer + 2, boundary, blen) == 0) {
+      if (last) {
+        last->length = ftell (fp) - last->offset - len - 1 - crlf;
+        if (last->parts && last->parts->length == 0)
+          last->parts->length =
+            ftell (fp) - last->parts->offset - len - 1 - crlf;
+        /* if the body is empty, we can end up with a -1 length */
+        if (last->length < 0)
+          last->length = 0;
       }
 
       /* Remove any trailing whitespace, up to the length of the boundary */
@@ -644,41 +617,39 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
         buffer[i] = 0;
 
       /* Check for the end boundary */
-      if (mutt_strcmp (buffer + blen + 2, "--") == 0)
-      {
-       final = 1;
-       break; /* done parsing */
+      if (mutt_strcmp (buffer + blen + 2, "--") == 0) {
+        final = 1;
+        break;                  /* done parsing */
       }
-      else if (buffer[2 + blen] == 0)
-      {
-       new = mutt_read_mime_header (fp, digest);
+      else if (buffer[2 + blen] == 0) {
+        new = mutt_read_mime_header (fp, digest);
 
 #ifdef SUN_ATTACHMENT
         if (mutt_get_parameter ("content-lines", new->parameter)) {
-         for (lines = atoi(mutt_get_parameter ("content-lines", new->parameter));
-              lines; lines-- )
-            if (ftell (fp) >= end_off || fgets (buffer, LONG_STRING, fp) == NULL)
-              break;
-       }
+          for (lines =
+               atoi (mutt_get_parameter ("content-lines", new->parameter));
+               lines; lines--)
+            if (ftell (fp) >= end_off
+                || fgets (buffer, LONG_STRING, fp) == NULL)
+              break;
+        }
 #endif
-       
-       /*
-        * Consistency checking - catch
-        * bad attachment end boundaries
-        */
-       
-       if(new->offset > end_off)
-       {
-         mutt_free_body(&new);
-         break;
-       }
-       if (head)
-       {
-         last->next = new;
-         last = new;
-       }
-       else
-         last = head = new;
+
+        /*
+         * Consistency checking - catch
+         * bad attachment end boundaries
+         */
+
+        if (new->offset > end_off) {
+          mutt_free_body (&new);
+          break;
+        }
+        if (head) {
+          last->next = new;
+          last = new;
+        }
+        else
+          last = head = new;
       }
     }
   }
@@ -688,19 +659,20 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
     last->length = end_off - last->offset;
 
   /* parse recursive MIME parts */
-  for(last = head; last; last = last->next)
-    mutt_parse_part(fp, last);
-  
+  for (last = head; last; last = last->next)
+    mutt_parse_part (fp, last);
+
   return (head);
 }
 
-static const char *uncomment_timezone (char *buf, size_t buflen, const char *tz)
+static const char *uncomment_timezone (char *buf, size_t buflen,
+                                       const char *tz)
 {
   char *p;
   size_t len;
 
   if (*tz != '(')
-    return tz; /* no need to do anything */
+    return tz;                  /* no need to do anything */
   tz++;
   SKIPWS (tz);
   if ((p = strpbrk (tz, " )")) == NULL)
@@ -713,63 +685,94 @@ static const char *uncomment_timezone (char *buf, size_t buflen, const char *tz)
   return buf;
 }
 
-static struct tz_t
-{
+static struct tz_t {
   char tzname[5];
   unsigned char zhours;
   unsigned char zminutes;
-  unsigned char zoccident; /* west of UTC? */
-}
-TimeZones[] =
-{
-  { "aat",   1,  0, 1 }, /* Atlantic Africa Time */
-  { "adt",   4,  0, 0 }, /* Arabia DST */
-  { "ast",   3,  0, 0 }, /* Arabia */
-/*{ "ast",   4,  0, 1 },*/ /* Atlantic */
-  { "bst",   1,  0, 0 }, /* British DST */
-  { "cat",   1,  0, 0 }, /* Central Africa */
-  { "cdt",   5,  0, 1 },
-  { "cest",  2,  0, 0 }, /* Central Europe DST */
-  { "cet",   1,  0, 0 }, /* Central Europe */
-  { "cst",   6,  0, 1 },
-/*{ "cst",   8,  0, 0 },*/ /* China */
-/*{ "cst",   9, 30, 0 },*/ /* Australian Central Standard Time */
-  { "eat",   3,  0, 0 }, /* East Africa */
-  { "edt",   4,  0, 1 },
-  { "eest",  3,  0, 0 }, /* Eastern Europe DST */
-  { "eet",   2,  0, 0 }, /* Eastern Europe */
-  { "egst",  0,  0, 0 }, /* Eastern Greenland DST */
-  { "egt",   1,  0, 1 }, /* Eastern Greenland */
-  { "est",   5,  0, 1 },
-  { "gmt",   0,  0, 0 },
-  { "gst",   4,  0, 0 }, /* Presian Gulf */
-  { "hkt",   8,  0, 0 }, /* Hong Kong */
-  { "ict",   7,  0, 0 }, /* Indochina */
-  { "idt",   3,  0, 0 }, /* Israel DST */
-  { "ist",   2,  0, 0 }, /* Israel */
-/*{ "ist",   5, 30, 0 },*/ /* India */
-  { "jst",   9,  0, 0 }, /* Japan */
-  { "kst",   9,  0, 0 }, /* Korea */
-  { "mdt",   6,  0, 1 },
-  { "met",   1,  0, 0 }, /* this is now officially CET */
-  { "msd",   4,  0, 0 }, /* Moscow DST */
-  { "msk",   3,  0, 0 }, /* Moscow */
-  { "mst",   7,  0, 1 },
-  { "nzdt", 13,  0, 0 }, /* New Zealand DST */
-  { "nzst", 12,  0, 0 }, /* New Zealand */
-  { "pdt",   7,  0, 1 },
-  { "pst",   8,  0, 1 },
-  { "sat",   2,  0, 0 }, /* South Africa */
-  { "smt",   4,  0, 0 }, /* Seychelles */
-  { "sst",  11,  0, 1 }, /* Samoa */
-/*{ "sst",   8,  0, 0 },*/ /* Singapore */
-  { "utc",   0,  0, 0 },
-  { "wat",   0,  0, 0 }, /* West Africa */
-  { "west",  1,  0, 0 }, /* Western Europe DST */
-  { "wet",   0,  0, 0 }, /* Western Europe */
-  { "wgst",  2,  0, 1 }, /* Western Greenland DST */
-  { "wgt",   3,  0, 1 }, /* Western Greenland */
-  { "wst",   8,  0, 0 }, /* Western Australia */
+  unsigned char zoccident;      /* west of UTC? */
+} TimeZones[] = {
+  {
+  "aat", 1, 0, 1},              /* Atlantic Africa Time */
+  {
+  "adt", 4, 0, 0},              /* Arabia DST */
+  {
+  "ast", 3, 0, 0},              /* Arabia */
+    /*{ "ast",   4,  0, 1 }, *//* Atlantic */
+  {
+  "bst", 1, 0, 0},              /* British DST */
+  {
+  "cat", 1, 0, 0},              /* Central Africa */
+  {
+  "cdt", 5, 0, 1}, {
+  "cest", 2, 0, 0},             /* Central Europe DST */
+  {
+  "cet", 1, 0, 0},              /* Central Europe */
+  {
+  "cst", 6, 0, 1},
+    /*{ "cst",   8,  0, 0 }, *//* China */
+    /*{ "cst",   9, 30, 0 }, *//* Australian Central Standard Time */
+  {
+  "eat", 3, 0, 0},              /* East Africa */
+  {
+  "edt", 4, 0, 1}, {
+  "eest", 3, 0, 0},             /* Eastern Europe DST */
+  {
+  "eet", 2, 0, 0},              /* Eastern Europe */
+  {
+  "egst", 0, 0, 0},             /* Eastern Greenland DST */
+  {
+  "egt", 1, 0, 1},              /* Eastern Greenland */
+  {
+  "est", 5, 0, 1}, {
+  "gmt", 0, 0, 0}, {
+  "gst", 4, 0, 0},              /* Presian Gulf */
+  {
+  "hkt", 8, 0, 0},              /* Hong Kong */
+  {
+  "ict", 7, 0, 0},              /* Indochina */
+  {
+  "idt", 3, 0, 0},              /* Israel DST */
+  {
+  "ist", 2, 0, 0},              /* Israel */
+    /*{ "ist",   5, 30, 0 }, *//* India */
+  {
+  "jst", 9, 0, 0},              /* Japan */
+  {
+  "kst", 9, 0, 0},              /* Korea */
+  {
+  "mdt", 6, 0, 1}, {
+  "met", 1, 0, 0},              /* this is now officially CET */
+  {
+  "msd", 4, 0, 0},              /* Moscow DST */
+  {
+  "msk", 3, 0, 0},              /* Moscow */
+  {
+  "mst", 7, 0, 1}, {
+  "nzdt", 13, 0, 0},            /* New Zealand DST */
+  {
+  "nzst", 12, 0, 0},            /* New Zealand */
+  {
+  "pdt", 7, 0, 1}, {
+  "pst", 8, 0, 1}, {
+  "sat", 2, 0, 0},              /* South Africa */
+  {
+  "smt", 4, 0, 0},              /* Seychelles */
+  {
+  "sst", 11, 0, 1},             /* Samoa */
+    /*{ "sst",   8,  0, 0 }, *//* Singapore */
+  {
+  "utc", 0, 0, 0}, {
+  "wat", 0, 0, 0},              /* West Africa */
+  {
+  "west", 1, 0, 0},             /* Western Europe DST */
+  {
+  "wet", 0, 0, 0},              /* Western Europe */
+  {
+  "wgst", 2, 0, 1},             /* Western Greenland DST */
+  {
+  "wgt", 3, 0, 1},              /* Western Greenland */
+  {
+  "wst", 8, 0, 0},              /* Western Australia */
 };
 
 /* parses a date string in RFC822 format:
@@ -779,7 +782,7 @@ TimeZones[] =
  * This routine assumes that `h' has been initialized to 0.  the `timezone'
  * field is optional, defaulting to +0000 if missing.
  */
-time_t mutt_parse_date (const char *s, HEADER *h)
+time_t mutt_parse_date (const char *s, HEADER * h)
 {
   int count = 0;
   char *t;
@@ -799,7 +802,7 @@ time_t mutt_parse_date (const char *s, HEADER *h)
    */
 
   strfcpy (scratch, s, sizeof (scratch));
-  
+
   /* kill the day of the week, if it exists. */
   if ((t = strchr (scratch, ',')))
     t++;
@@ -809,110 +812,104 @@ time_t mutt_parse_date (const char *s, HEADER *h)
 
   memset (&tm, 0, sizeof (tm));
 
-  while ((t = strtok (t, " \t")) != NULL)
-  {
-    switch (count)
-    {
-      case 0: /* day of the month */
-       if (!isdigit ((unsigned char) *t))
-         return (-1);
-       tm.tm_mday = atoi (t);
-       if (tm.tm_mday > 31)
-         return (-1);
-       break;
-
-      case 1: /* month of the year */
-       if ((i = mutt_check_month (t)) < 0)
-         return (-1);
-       tm.tm_mon = i;
-       break;
-
-      case 2: /* year */
-       tm.tm_year = atoi (t);
-        if (tm.tm_year < 50)
-         tm.tm_year += 100;
-        else if (tm.tm_year >= 1900)
-         tm.tm_year -= 1900;
-       break;
-
-      case 3: /* time of day */
-       if (sscanf (t, "%d:%d:%d", &hour, &min, &sec) == 3)
-         ;
-       else if (sscanf (t, "%d:%d", &hour, &min) == 2)
-         sec = 0;
-       else
-       {
-         dprint(1, (debugfile, "parse_date: could not process time format: %s\n", t));
-         return(-1);
-       }
-       tm.tm_hour = hour;
-       tm.tm_min = min;
-       tm.tm_sec = sec;
-       break;
-
-      case 4: /* timezone */
-       /* sometimes we see things like (MST) or (-0700) so attempt to
-        * compensate by uncommenting the string if non-RFC822 compliant
-        */
-       ptz = uncomment_timezone (tzstr, sizeof (tzstr), t);
-
-       if (*ptz == '+' || *ptz == '-')
-       {
-         if (ptz[1] && ptz[2] && ptz[3] && ptz[4]
-             && isdigit ((unsigned char) ptz[1]) && isdigit ((unsigned char) ptz[2])
-             && isdigit ((unsigned char) ptz[3]) && isdigit ((unsigned char) ptz[4]))
-         {
-           zhours = (ptz[1] - '0') * 10 + (ptz[2] - '0');
-           zminutes = (ptz[3] - '0') * 10 + (ptz[4] - '0');
-
-           if (ptz[0] == '-')
-             zoccident = 1;
-         }
-       }
-       else
-       {
-         struct tz_t *tz;
-
-         tz = bsearch (ptz, TimeZones, sizeof TimeZones/sizeof (struct tz_t),
-                       sizeof (struct tz_t),
-                       (int (*)(const void *, const void *)) ascii_strcasecmp
-                       /* This is safe to do: A pointer to a struct equals
-                        * a pointer to its first element*/);
-
-         if (tz)
-         {
-           zhours = tz->zhours;
-           zminutes = tz->zminutes;
-           zoccident = tz->zoccident;
-         }
-
-         /* ad hoc support for the European MET (now officially CET) TZ */
-         if (ascii_strcasecmp (t, "MET") == 0)
-         {
-           if ((t = strtok (NULL, " \t")) != NULL)
-           {
-             if (!ascii_strcasecmp (t, "DST"))
-               zhours++;
-           }
-         }
-       }
-       tz_offset = zhours * 3600 + zminutes * 60;
-       if (!zoccident)
-         tz_offset = -tz_offset;
-       break;
+  while ((t = strtok (t, " \t")) != NULL) {
+    switch (count) {
+    case 0:                    /* day of the month */
+      if (!isdigit ((unsigned char) *t))
+        return (-1);
+      tm.tm_mday = atoi (t);
+      if (tm.tm_mday > 31)
+        return (-1);
+      break;
+
+    case 1:                    /* month of the year */
+      if ((i = mutt_check_month (t)) < 0)
+        return (-1);
+      tm.tm_mon = i;
+      break;
+
+    case 2:                    /* year */
+      tm.tm_year = atoi (t);
+      if (tm.tm_year < 50)
+        tm.tm_year += 100;
+      else if (tm.tm_year >= 1900)
+        tm.tm_year -= 1900;
+      break;
+
+    case 3:                    /* time of day */
+      if (sscanf (t, "%d:%d:%d", &hour, &min, &sec) == 3);
+      else if (sscanf (t, "%d:%d", &hour, &min) == 2)
+        sec = 0;
+      else {
+        dprint (1,
+                (debugfile, "parse_date: could not process time format: %s\n",
+                 t));
+        return (-1);
+      }
+      tm.tm_hour = hour;
+      tm.tm_min = min;
+      tm.tm_sec = sec;
+      break;
+
+    case 4:                    /* timezone */
+      /* sometimes we see things like (MST) or (-0700) so attempt to
+       * compensate by uncommenting the string if non-RFC822 compliant
+       */
+      ptz = uncomment_timezone (tzstr, sizeof (tzstr), t);
+
+      if (*ptz == '+' || *ptz == '-') {
+        if (ptz[1] && ptz[2] && ptz[3] && ptz[4]
+            && isdigit ((unsigned char) ptz[1])
+            && isdigit ((unsigned char) ptz[2])
+            && isdigit ((unsigned char) ptz[3])
+            && isdigit ((unsigned char) ptz[4])) {
+          zhours = (ptz[1] - '0') * 10 + (ptz[2] - '0');
+          zminutes = (ptz[3] - '0') * 10 + (ptz[4] - '0');
+
+          if (ptz[0] == '-')
+            zoccident = 1;
+        }
+      }
+      else {
+        struct tz_t *tz;
+
+        tz = bsearch (ptz, TimeZones, sizeof TimeZones / sizeof (struct tz_t),
+                      sizeof (struct tz_t),
+                      (int (*)(const void *, const void *)) ascii_strcasecmp
+                      /* This is safe to do: A pointer to a struct equals
+                       * a pointer to its first element*/ );
+
+        if (tz) {
+          zhours = tz->zhours;
+          zminutes = tz->zminutes;
+          zoccident = tz->zoccident;
+        }
+
+        /* ad hoc support for the European MET (now officially CET) TZ */
+        if (ascii_strcasecmp (t, "MET") == 0) {
+          if ((t = strtok (NULL, " \t")) != NULL) {
+            if (!ascii_strcasecmp (t, "DST"))
+              zhours++;
+          }
+        }
+      }
+      tz_offset = zhours * 3600 + zminutes * 60;
+      if (!zoccident)
+        tz_offset = -tz_offset;
+      break;
     }
     count++;
     t = 0;
   }
 
-  if (count < 4) /* don't check for missing timezone */
-  {
-    dprint(1,(debugfile, "parse_date(): error parsing date format, using received time\n"));
+  if (count < 4) {              /* don't check for missing timezone */
+    dprint (1,
+            (debugfile,
+             "parse_date(): error parsing date format, using received time\n"));
     return (-1);
   }
 
-  if (h)
-  {
+  if (h) {
     h->zhours = zhours;
     h->zminutes = zminutes;
     h->zoccident = zoccident;
@@ -930,25 +927,25 @@ static char *extract_message_id (const char *s)
 
   if ((s = strchr (s, '<')) == NULL || (p = strchr (s, '>')) == NULL)
     return (NULL);
-  l = (size_t)(p - s) + 1;
+  l = (size_t) (p - s) + 1;
   r = safe_malloc (l + 1);
   memcpy (r, s, l);
   r[l] = 0;
   return (r);
 }
 
-void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur)
+void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
 {
   MESSAGE *msg;
 
-  if (cur->content->type != TYPEMESSAGE && cur->content->type != TYPEMULTIPART)
-    return; /* nothing to do */
+  if (cur->content->type != TYPEMESSAGE
+      && cur->content->type != TYPEMULTIPART)
+    return;                     /* nothing to do */
 
   if (cur->content->parts)
-    return; /* The message was parsed earlier. */
+    return;                     /* The message was parsed earlier. */
 
-  if ((msg = mx_open_message (ctx, cur->msgno)))
-  {
+  if ((msg = mx_open_message (ctx, cur->msgno))) {
     mutt_parse_part (msg->fp, cur->content);
 
     if (WithCrypto)
@@ -958,215 +955,186 @@ void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur)
   }
 }
 
-int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed,
-                           short do_2047, LIST **lastp)
+int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
+                            short user_hdrs, short weed, short do_2047,
+                            LIST ** lastp)
 {
   int matched = 0;
   LIST *last = NULL;
-  
+
   if (lastp)
     last = *lastp;
-  
-  switch (ascii_tolower (line[0]))
-  {
-    case 'a':
-    if (ascii_strcasecmp (line+1, "pparently-to") == 0)
-    {
+
+  switch (ascii_tolower (line[0])) {
+  case 'a':
+    if (ascii_strcasecmp (line + 1, "pparently-to") == 0) {
       e->to = rfc822_parse_adrlist (e->to, p);
       matched = 1;
     }
-    else if (ascii_strcasecmp (line+1, "pparently-from") == 0)
-    {
+    else if (ascii_strcasecmp (line + 1, "pparently-from") == 0) {
       e->from = rfc822_parse_adrlist (e->from, p);
       matched = 1;
     }
     break;
-    
-    case 'b':
-    if (ascii_strcasecmp (line+1, "cc") == 0)
-    {
+
+  case 'b':
+    if (ascii_strcasecmp (line + 1, "cc") == 0) {
       e->bcc = rfc822_parse_adrlist (e->bcc, p);
       matched = 1;
     }
     break;
-    
-    case 'c':
-    if (ascii_strcasecmp (line+1, "c") == 0)
-    {
+
+  case 'c':
+    if (ascii_strcasecmp (line + 1, "c") == 0) {
       e->cc = rfc822_parse_adrlist (e->cc, p);
       matched = 1;
     }
-    else if (ascii_strncasecmp (line + 1, "ontent-", 7) == 0)
-    {
-      if (ascii_strcasecmp (line+8, "type") == 0)
-      {
-       if (hdr)
-         mutt_parse_content_type (p, hdr->content);
-       matched = 1;
+    else if (ascii_strncasecmp (line + 1, "ontent-", 7) == 0) {
+      if (ascii_strcasecmp (line + 8, "type") == 0) {
+        if (hdr)
+          mutt_parse_content_type (p, hdr->content);
+        matched = 1;
       }
-      else if (ascii_strcasecmp (line+8, "transfer-encoding") == 0)
-      {
-       if (hdr)
-         hdr->content->encoding = mutt_check_encoding (p);
-       matched = 1;
+      else if (ascii_strcasecmp (line + 8, "transfer-encoding") == 0) {
+        if (hdr)
+          hdr->content->encoding = mutt_check_encoding (p);
+        matched = 1;
       }
-      else if (ascii_strcasecmp (line+8, "length") == 0)
-      {
-       if (hdr)
-       {
-         if ((hdr->content->length = atoi (p)) < 0)
-           hdr->content->length = -1;
-       }
-       matched = 1;
+      else if (ascii_strcasecmp (line + 8, "length") == 0) {
+        if (hdr) {
+          if ((hdr->content->length = atoi (p)) < 0)
+            hdr->content->length = -1;
+        }
+        matched = 1;
       }
-      else if (ascii_strcasecmp (line+8, "description") == 0)
-      {
-       if (hdr)
-       {
-         mutt_str_replace (&hdr->content->description, p);
-         rfc2047_decode (&hdr->content->description);
-       }
-       matched = 1;
+      else if (ascii_strcasecmp (line + 8, "description") == 0) {
+        if (hdr) {
+          mutt_str_replace (&hdr->content->description, p);
+          rfc2047_decode (&hdr->content->description);
+        }
+        matched = 1;
       }
-      else if (ascii_strcasecmp (line+8, "disposition") == 0)
-      {
-       if (hdr)
-         parse_content_disposition (p, hdr->content);
-       matched = 1;
+      else if (ascii_strcasecmp (line + 8, "disposition") == 0) {
+        if (hdr)
+          parse_content_disposition (p, hdr->content);
+        matched = 1;
       }
     }
     break;
-    
-    case 'd':
-    if (!ascii_strcasecmp ("ate", line + 1))
-    {
+
+  case 'd':
+    if (!ascii_strcasecmp ("ate", line + 1)) {
       mutt_str_replace (&e->date, p);
       if (hdr)
-       hdr->date_sent = mutt_parse_date (p, hdr);
+        hdr->date_sent = mutt_parse_date (p, hdr);
       matched = 1;
     }
     break;
-    
-    case 'e':
+
+  case 'e':
     if (!ascii_strcasecmp ("xpires", line + 1) &&
-       hdr && mutt_parse_date (p, NULL) < time (NULL))
+        hdr && mutt_parse_date (p, NULL) < time (NULL))
       hdr->expired = 1;
     break;
-    
-    case 'f':
-    if (!ascii_strcasecmp ("rom", line + 1))
-    {
+
+  case 'f':
+    if (!ascii_strcasecmp ("rom", line + 1)) {
       e->from = rfc822_parse_adrlist (e->from, p);
       /* don't leave from info NULL if there's an invalid address (or
        * whatever) in From: field; mutt would just display it as empty
        * and mark mail/(esp.) news article as your own. aaargh! this
        * bothered me for _years_ */
-      if (!e->from)
-      {
+      if (!e->from) {
         e->from = rfc822_new_address ();
-        e->from->personal = safe_strdup (line+6);
+        e->from->personal = safe_strdup (line + 6);
       }
       matched = 1;
     }
 #ifdef USE_NNTP
-    else if (!mutt_strcasecmp (line+1, "ollowup-to"))
-    {
-      if (!e->followup_to)
-      {
-       mutt_remove_trailing_ws (p);
-       e->followup_to = safe_strdup (mutt_skip_whitespace (p));
+    else if (!mutt_strcasecmp (line + 1, "ollowup-to")) {
+      if (!e->followup_to) {
+        mutt_remove_trailing_ws (p);
+        e->followup_to = safe_strdup (mutt_skip_whitespace (p));
       }
       matched = 1;
     }
 #endif
     break;
-    
-    case 'i':
-    if (!ascii_strcasecmp (line+1, "n-reply-to"))
-    {
+
+  case 'i':
+    if (!ascii_strcasecmp (line + 1, "n-reply-to")) {
       mutt_free_list (&e->in_reply_to);
       e->in_reply_to = mutt_parse_references (p, 1);
       matched = 1;
     }
     break;
-    
-    case 'l':
-    if (!ascii_strcasecmp (line + 1, "ines"))
-    {
-      if (hdr)
-      {
-       hdr->lines = atoi (p);
-
-       /* 
-        * HACK - mutt has, for a very short time, produced negative
-        * Lines header values.  Ignore them. 
-        */
-       if (hdr->lines < 0)
-         hdr->lines = 0;
+
+  case 'l':
+    if (!ascii_strcasecmp (line + 1, "ines")) {
+      if (hdr) {
+        hdr->lines = atoi (p);
+
+        /* 
+         * HACK - mutt has, for a very short time, produced negative
+         * Lines header values.  Ignore them. 
+         */
+        if (hdr->lines < 0)
+          hdr->lines = 0;
       }
 
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "ist-Post"))
-    {
+    else if (!ascii_strcasecmp (line + 1, "ist-Post")) {
       /* RFC 2369.  FIXME: We should ignore whitespace, but don't. */
-      if (strncmp (p, "NO", 2))
-      {
-       char *beg, *end;
-       for (beg = strchr (p, '<'); beg; beg = strchr (end, ','))
-       {
-         ++beg;
-         if (!(end = strchr (beg, '>')))
-           break;
-         
-         /* Take the first mailto URL */
-         if (url_check_scheme (beg) == U_MAILTO)
-         {
-           FREE (&e->list_post);
-           e->list_post = mutt_substrdup (beg, end);
-           break;
-         }
-       }
+      if (strncmp (p, "NO", 2)) {
+        char *beg, *end;
+
+        for (beg = strchr (p, '<'); beg; beg = strchr (end, ',')) {
+          ++beg;
+          if (!(end = strchr (beg, '>')))
+            break;
+
+          /* Take the first mailto URL */
+          if (url_check_scheme (beg) == U_MAILTO) {
+            FREE (&e->list_post);
+            e->list_post = mutt_substrdup (beg, end);
+            break;
+          }
+        }
       }
       matched = 1;
     }
     break;
-    
-    case 'm':
-    if (!ascii_strcasecmp (line + 1, "ime-version"))
-    {
+
+  case 'm':
+    if (!ascii_strcasecmp (line + 1, "ime-version")) {
       if (hdr)
-       hdr->mime = 1;
+        hdr->mime = 1;
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "essage-id"))
-    {
+    else if (!ascii_strcasecmp (line + 1, "essage-id")) {
       /* We add a new "Message-Id:" when building a message */
       FREE (&e->message_id);
       e->message_id = extract_message_id (p);
       matched = 1;
     }
-    else if (!ascii_strncasecmp (line + 1, "ail-", 4))
-    {
-      if (!ascii_strcasecmp (line + 5, "reply-to"))
-      {
-       /* override the Reply-To: field */
-       rfc822_free_address (&e->reply_to);
-       e->reply_to = rfc822_parse_adrlist (e->reply_to, p);
-       matched = 1;
+    else if (!ascii_strncasecmp (line + 1, "ail-", 4)) {
+      if (!ascii_strcasecmp (line + 5, "reply-to")) {
+        /* override the Reply-To: field */
+        rfc822_free_address (&e->reply_to);
+        e->reply_to = rfc822_parse_adrlist (e->reply_to, p);
+        matched = 1;
       }
-      else if (!ascii_strcasecmp (line + 5, "followup-to"))
-      {
-       e->mail_followup_to = rfc822_parse_adrlist (e->mail_followup_to, p);
-       matched = 1;
+      else if (!ascii_strcasecmp (line + 5, "followup-to")) {
+        e->mail_followup_to = rfc822_parse_adrlist (e->mail_followup_to, p);
+        matched = 1;
       }
     }
     break;
-    
+
 #ifdef USE_NNTP
-    case 'n':
-    if (!mutt_strcasecmp (line + 1, "ewsgroups"))
-    {
+  case 'n':
+    if (!mutt_strcasecmp (line + 1, "ewsgroups")) {
       FREE (&e->newsgroups);
       mutt_remove_trailing_ws (p);
       e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
@@ -1175,154 +1143,132 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short
     break;
 #endif
 
-    case 'o':
+  case 'o':
     /* field `Organization:' saves only for pager! */
-    if (!mutt_strcasecmp (line + 1, "rganization"))
-    {
+    if (!mutt_strcasecmp (line + 1, "rganization")) {
       if (!e->organization && mutt_strcasecmp (p, "unknown"))
-       e->organization = safe_strdup (p);
+        e->organization = safe_strdup (p);
     }
     break;
 
-    case 'r':
-    if (!ascii_strcasecmp (line + 1, "eferences"))
-    {
+  case 'r':
+    if (!ascii_strcasecmp (line + 1, "eferences")) {
       mutt_free_list (&e->references);
       e->references = mutt_parse_references (p, 0);
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "eply-to"))
-    {
+    else if (!ascii_strcasecmp (line + 1, "eply-to")) {
       e->reply_to = rfc822_parse_adrlist (e->reply_to, p);
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "eturn-path"))
-    {
+    else if (!ascii_strcasecmp (line + 1, "eturn-path")) {
       e->return_path = rfc822_parse_adrlist (e->return_path, p);
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "eceived"))
-    {
-      if (hdr && !hdr->received)
-      {
-       char *d = strchr (p, ';');
-       
-       if (d)
-         hdr->received = mutt_parse_date (d + 1, NULL);
+    else if (!ascii_strcasecmp (line + 1, "eceived")) {
+      if (hdr && !hdr->received) {
+        char *d = strchr (p, ';');
+
+        if (d)
+          hdr->received = mutt_parse_date (d + 1, NULL);
       }
     }
     break;
-    
-    case 's':
-    if (!ascii_strcasecmp (line + 1, "ubject"))
-    {
+
+  case 's':
+    if (!ascii_strcasecmp (line + 1, "ubject")) {
       if (!e->subject)
-       e->subject = safe_strdup (p);
+        e->subject = safe_strdup (p);
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "ender"))
-    {
+    else if (!ascii_strcasecmp (line + 1, "ender")) {
       e->sender = rfc822_parse_adrlist (e->sender, p);
       matched = 1;
     }
-    else if (!ascii_strcasecmp (line + 1, "tatus"))
-    {
-      if (hdr)
-      {
-       while (*p)
-       {
-         switch(*p)
-         {
-           case 'r':
-           hdr->replied = 1;
-           break;
-           case 'O':
-             hdr->old = 1;
-           break;
-           case 'R':
-           hdr->read = 1;
-           break;
-         }
-         p++;
-       }
+    else if (!ascii_strcasecmp (line + 1, "tatus")) {
+      if (hdr) {
+        while (*p) {
+          switch (*p) {
+          case 'r':
+            hdr->replied = 1;
+            break;
+          case 'O':
+            hdr->old = 1;
+            break;
+          case 'R':
+            hdr->read = 1;
+            break;
+          }
+          p++;
+        }
       }
       matched = 1;
     }
     else if ((!ascii_strcasecmp ("upersedes", line + 1) ||
-             !ascii_strcasecmp ("upercedes", line + 1)) && hdr)
+              !ascii_strcasecmp ("upercedes", line + 1)) && hdr)
       e->supersedes = safe_strdup (p);
     break;
-    
-    case 't':
-    if (ascii_strcasecmp (line+1, "o") == 0)
-    {
+
+  case 't':
+    if (ascii_strcasecmp (line + 1, "o") == 0) {
       e->to = rfc822_parse_adrlist (e->to, p);
       matched = 1;
     }
     break;
-    
-    case 'x':
-    if (ascii_strcasecmp (line+1, "-status") == 0)
-    {
-      if (hdr)
-      {
-       while (*p)
-       {
-         switch (*p)
-         {
-           case 'A':
-           hdr->replied = 1;
-           break;
-           case 'D':
-           hdr->deleted = 1;
-           break;
-           case 'F':
-           hdr->flagged = 1;
-           break;
-           default:
-           break;
-         }
-         p++;
-       }
+
+  case 'x':
+    if (ascii_strcasecmp (line + 1, "-status") == 0) {
+      if (hdr) {
+        while (*p) {
+          switch (*p) {
+          case 'A':
+            hdr->replied = 1;
+            break;
+          case 'D':
+            hdr->deleted = 1;
+            break;
+          case 'F':
+            hdr->flagged = 1;
+            break;
+          default:
+            break;
+          }
+          p++;
+        }
       }
       matched = 1;
     }
-    else if (ascii_strcasecmp (line+1, "-label") == 0)
-    {
-      e->x_label = safe_strdup(p);
+    else if (ascii_strcasecmp (line + 1, "-label") == 0) {
+      e->x_label = safe_strdup (p);
       matched = 1;
     }
 #ifdef USE_NNTP
-    else if (!mutt_strcasecmp (line + 1, "-comment-to"))
-    {
+    else if (!mutt_strcasecmp (line + 1, "-comment-to")) {
       if (!e->x_comment_to)
-       e->x_comment_to = safe_strdup (p);
+        e->x_comment_to = safe_strdup (p);
       matched = 1;
     }
-    else if (!mutt_strcasecmp (line + 1, "ref"))
-    {
+    else if (!mutt_strcasecmp (line + 1, "ref")) {
       if (!e->xref)
-       e->xref = safe_strdup (p);
+        e->xref = safe_strdup (p);
       matched = 1;
     }
 #endif
-    
-    default:
+
+  default:
     break;
   }
-  
+
   /* Keep track of the user-defined headers */
-  if (!matched && user_hdrs)
-  {
+  if (!matched && user_hdrs) {
     /* restore the original line */
     line[strlen (line)] = ':';
-    
+
     if (weed && option (OPTWEED) && mutt_matches_ignore (line, Ignore)
-       && !mutt_matches_ignore (line, UnIgnore))
+        && !mutt_matches_ignore (line, UnIgnore))
       goto done;
 
-    if (last)
-    {
+    if (last) {
       last->next = mutt_new_list ();
       last = last->next;
     }
@@ -1333,13 +1279,13 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short
       rfc2047_decode (&last->data);
   }
 
-  done:
-  
+done:
+
   *lastp = last;
   return matched;
 }
-  
-  
+
+
 /* mutt_read_rfc822_header() -- parses a RFC822 header
  *
  * Args:
@@ -1358,29 +1304,27 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short
  * Returns:     newly allocated envelope structure.  You should free it by
  *              mutt_free_envelope() when envelope stay unneeded.
  */
-ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
-                                  short weed)
+ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs,
+                                   short weed)
 {
-  ENVELOPE *e = mutt_new_envelope();
+  ENVELOPE *e = mutt_new_envelope ();
   LIST *last = NULL;
   char *line = safe_malloc (LONG_STRING);
   char *p;
   long loc;
   int matched;
   size_t linelen = LONG_STRING;
-  char buf[LONG_STRING+1];
+  char buf[LONG_STRING + 1];
 
-  if (hdr)
-  {
-    if (hdr->content == NULL)
-    {
+  if (hdr) {
+    if (hdr->content == NULL) {
       hdr->content = mutt_new_body ();
 
       /* set the defaults from RFC1521 */
-      hdr->content->type        = TYPETEXT;
-      hdr->content->subtype     = safe_strdup ("plain");
-      hdr->content->encoding    = ENC7BIT;
-      hdr->content->length      = -1;
+      hdr->content->type = TYPETEXT;
+      hdr->content->subtype = safe_strdup ("plain");
+      hdr->content->encoding = ENC7BIT;
+      hdr->content->length = -1;
 
       /* RFC 2183 says this is arbitrary */
       hdr->content->disposition = DISPINLINE;
@@ -1388,70 +1332,60 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
   }
 
   while ((loc = ftell (f)),
-         *(line = read_rfc822_line (f, line, &linelen)) != 0)
-  {
+         *(line = read_rfc822_line (f, line, &linelen)) != 0) {
     matched = 0;
 
-    if ((p = strpbrk (line, ": \t")) == NULL || *p != ':')
-    {
+    if ((p = strpbrk (line, ": \t")) == NULL || *p != ':') {
       char return_path[LONG_STRING];
       time_t t;
 
       /* some bogus MTAs will quote the original "From " line */
       if (mutt_strncmp (">From ", line, 6) == 0)
-       continue; /* just ignore */
-      else if (is_from (line, return_path, sizeof (return_path), &t))
-      {
-       /* MH somtimes has the From_ line in the middle of the header! */
-       if (hdr && !hdr->received)
-         hdr->received = t - mutt_local_tz (t);
-       continue;
+        continue;               /* just ignore */
+      else if (is_from (line, return_path, sizeof (return_path), &t)) {
+        /* MH somtimes has the From_ line in the middle of the header! */
+        if (hdr && !hdr->received)
+          hdr->received = t - mutt_local_tz (t);
+        continue;
       }
 
       fseek (f, loc, 0);
-      break; /* end of header */
+      break;                    /* end of header */
     }
 
     *buf = '\0';
 
-    if (mutt_match_spam_list(line, SpamList, buf, sizeof(buf)))
-    {
-      if (!mutt_match_rx_list(line, NoSpamList))
-      {
-
-       /* if spam tag already exists, figure out how to amend it */
-       if (e->spam && *buf)
-       {
-         /* If SpamSep defined, append with separator */
-         if (SpamSep)
-         {
-           mutt_buffer_addstr(e->spam, SpamSep);
-           mutt_buffer_addstr(e->spam, buf);
-         }
-
-         /* else overwrite */
-         else
-         {
-           e->spam->dptr = e->spam->data;
-           *e->spam->dptr = '\0';
-           mutt_buffer_addstr(e->spam, buf);
-         }
-       }
-
-       /* spam tag is new, and match expr is non-empty; copy */
-       else if (!e->spam && *buf)
-       {
-         e->spam = mutt_buffer_from(NULL, buf);
-       }
-
-       /* match expr is empty; plug in null string if no existing tag */
-       else if (!e->spam)
-       {
-         e->spam = mutt_buffer_from(NULL, "");
-       }
-
-       if (e->spam && e->spam->data)
-          dprint(5, (debugfile, "p822: spam = %s\n", e->spam->data));
+    if (mutt_match_spam_list (line, SpamList, buf, sizeof (buf))) {
+      if (!mutt_match_rx_list (line, NoSpamList)) {
+
+        /* if spam tag already exists, figure out how to amend it */
+        if (e->spam && *buf) {
+          /* If SpamSep defined, append with separator */
+          if (SpamSep) {
+            mutt_buffer_addstr (e->spam, SpamSep);
+            mutt_buffer_addstr (e->spam, buf);
+          }
+
+          /* else overwrite */
+          else {
+            e->spam->dptr = e->spam->data;
+            *e->spam->dptr = '\0';
+            mutt_buffer_addstr (e->spam, buf);
+          }
+        }
+
+        /* spam tag is new, and match expr is non-empty; copy */
+        else if (!e->spam && *buf) {
+          e->spam = mutt_buffer_from (NULL, buf);
+        }
+
+        /* match expr is empty; plug in null string if no existing tag */
+        else if (!e->spam) {
+          e->spam = mutt_buffer_from (NULL, "");
+        }
+
+        if (e->spam && e->spam->data)
+          dprint (5, (debugfile, "p822: spam = %s\n", e->spam->data));
       }
     }
 
@@ -1459,16 +1393,16 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
     p++;
     SKIPWS (p);
     if (!*p)
-      continue; /* skip empty header fields */
+      continue;                 /* skip empty header fields */
+
+    matched =
+      mutt_parse_rfc822_line (e, hdr, line, p, user_hdrs, weed, 1, &last);
 
-    matched = mutt_parse_rfc822_line (e, hdr, line, p, user_hdrs, weed, 1, &last);
-    
   }
 
   FREE (&line);
 
-  if (hdr)
-  {
+  if (hdr) {
     hdr->content->hdr_offset = hdr->offset;
     hdr->content->offset = ftell (f);
 
@@ -1482,22 +1416,22 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
     rfc2047_decode_adrlist (e->return_path);
     rfc2047_decode_adrlist (e->sender);
 
-    if (e->subject)
-    {
+    if (e->subject) {
       regmatch_t pmatch[1];
 
       rfc2047_decode (&e->subject);
 
       if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
-       e->real_subj = e->subject + pmatch[0].rm_eo;
+        e->real_subj = e->subject + pmatch[0].rm_eo;
       else
-       e->real_subj = e->subject;
+        e->real_subj = e->subject;
     }
 
     /* check for missing or invalid date */
-    if (hdr->date_sent <= 0)
-    {
-      dprint(1,(debugfile,"read_rfc822_header(): no date found, using received time from msg separator\n"));
+    if (hdr->date_sent <= 0) {
+      dprint (1,
+              (debugfile,
+               "read_rfc822_header(): no date found, using received time from msg separator\n"));
       hdr->date_sent = hdr->received;
     }
   }
@@ -1505,26 +1439,24 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
   return (e);
 }
 
-ADDRESS *mutt_parse_adrlist (ADDRESS *p, const char *s)
+ADDRESS *mutt_parse_adrlist (ADDRESS * p, const char *s)
 {
   const char *q;
 
   /* check for a simple whitespace separated list of addresses */
-  if ((q = strpbrk (s, "\"<>():;,\\")) == NULL)
-  {
+  if ((q = strpbrk (s, "\"<>():;,\\")) == NULL) {
     char tmp[HUGE_STRING];
     char *r;
 
     strfcpy (tmp, s, sizeof (tmp));
     r = tmp;
-    while ((r = strtok (r, " \t")) != NULL)
-    {
+    while ((r = strtok (r, " \t")) != NULL) {
       p = rfc822_parse_adrlist (p, r);
       r = NULL;
     }
   }
   else
     p = rfc822_parse_adrlist (p, s);
-  
+
   return p;
 }
index e07a52c..9793fc2 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 
 #include "mutt_crypt.h"
 
-static int eat_regexp (pattern_t *pat, BUFFER *, BUFFER *);
-static int eat_date (pattern_t *pat, BUFFER *, BUFFER *);
-static int eat_range (pattern_t *pat, BUFFER *, BUFFER *);
+static int eat_regexp (pattern_t * pat, BUFFER *, BUFFER *);
+static int eat_date (pattern_t * pat, BUFFER *, BUFFER *);
+static int eat_range (pattern_t * pat, BUFFER *, BUFFER *);
 
-struct pattern_flags
-{
-  int tag;     /* character used to represent this op */
-  int op;      /* operation to perform */
+struct pattern_flags {
+  int tag;                      /* character used to represent this op */
+  int op;                       /* operation to perform */
   int class;
   int (*eat_arg) (pattern_t *, BUFFER *, BUFFER *);
-}
-Flags[] =
-{
-  { 'A', M_ALL,                        0,              NULL },
-  { 'b', M_BODY,               M_FULL_MSG,     eat_regexp },
-  { 'B', M_WHOLE_MSG,          M_FULL_MSG,     eat_regexp },
-  { 'c', M_CC,                 0,              eat_regexp },
-  { 'C', M_RECIPIENT,          0,              eat_regexp },
-  { 'd', M_DATE,               0,              eat_date },
-  { 'D', M_DELETED,            0,              NULL },
-  { 'e', M_SENDER,             0,              eat_regexp },
-  { 'E', M_EXPIRED,            0,              NULL },
-  { 'f', M_FROM,               0,              eat_regexp },
-  { 'F', M_FLAG,               0,              NULL },
-  { 'g', M_CRYPT_SIGN,                 0,              NULL },
-  { 'G', M_CRYPT_ENCRYPT,      0,              NULL },
-  { 'h', M_HEADER,             M_FULL_MSG,     eat_regexp },
-  { 'H', M_HORMEL,             0,              eat_regexp },
-  { 'i', M_ID,                 0,              eat_regexp },
-  { 'k', M_PGP_KEY,            0,              NULL },
-  { 'L', M_ADDRESS,            0,              eat_regexp },
-  { 'l', M_LIST,               0,              NULL },
-  { 'm', M_MESSAGE,            0,              eat_range },
-  { 'n', M_SCORE,              0,              eat_range },
-  { 'N', M_NEW,                        0,              NULL },
-  { 'O', M_OLD,                        0,              NULL },
-  { 'p', M_PERSONAL_RECIP,     0,              NULL },
-  { 'P', M_PERSONAL_FROM,      0,              NULL },
-  { 'Q', M_REPLIED,            0,              NULL },
-  { 'R', M_READ,               0,              NULL },
-  { 'r', M_DATE_RECEIVED,      0,              eat_date },
-  { 's', M_SUBJECT,            0,              eat_regexp },
-  { 'S', M_SUPERSEDED,         0,              NULL },
-  { 'T', M_TAG,                        0,              NULL },
-  { 't', M_TO,                 0,              eat_regexp },
-  { 'U', M_UNREAD,             0,              NULL },
-  { 'v', M_COLLAPSED,          0,              NULL },
-  { 'V', M_CRYPT_VERIFIED,      0,              NULL },
+} Flags[] = {
+  {
+  'A', M_ALL, 0, NULL}, {
+  'b', M_BODY, M_FULL_MSG, eat_regexp}, {
+  'B', M_WHOLE_MSG, M_FULL_MSG, eat_regexp}, {
+  'c', M_CC, 0, eat_regexp}, {
+  'C', M_RECIPIENT, 0, eat_regexp}, {
+  'd', M_DATE, 0, eat_date}, {
+  'D', M_DELETED, 0, NULL}, {
+  'e', M_SENDER, 0, eat_regexp}, {
+  'E', M_EXPIRED, 0, NULL}, {
+  'f', M_FROM, 0, eat_regexp}, {
+  'F', M_FLAG, 0, NULL}, {
+  'g', M_CRYPT_SIGN, 0, NULL}, {
+  'G', M_CRYPT_ENCRYPT, 0, NULL}, {
+  'h', M_HEADER, M_FULL_MSG, eat_regexp}, {
+  'H', M_HORMEL, 0, eat_regexp}, {
+  'i', M_ID, 0, eat_regexp}, {
+  'k', M_PGP_KEY, 0, NULL}, {
+  'L', M_ADDRESS, 0, eat_regexp}, {
+  'l', M_LIST, 0, NULL}, {
+  'm', M_MESSAGE, 0, eat_range}, {
+  'n', M_SCORE, 0, eat_range}, {
+  'N', M_NEW, 0, NULL}, {
+  'O', M_OLD, 0, NULL}, {
+  'p', M_PERSONAL_RECIP, 0, NULL}, {
+  'P', M_PERSONAL_FROM, 0, NULL}, {
+  'Q', M_REPLIED, 0, NULL}, {
+  'R', M_READ, 0, NULL}, {
+  'r', M_DATE_RECEIVED, 0, eat_date}, {
+  's', M_SUBJECT, 0, eat_regexp}, {
+  'S', M_SUPERSEDED, 0, NULL}, {
+  'T', M_TAG, 0, NULL}, {
+  't', M_TO, 0, eat_regexp}, {
+  'U', M_UNREAD, 0, NULL}, {
+  'v', M_COLLAPSED, 0, NULL}, {
+  'V', M_CRYPT_VERIFIED, 0, NULL},
 #ifdef USE_NNTP
-  { 'w', M_NEWSGROUPS,         0,              eat_regexp },
+  {
+  'w', M_NEWSGROUPS, 0, eat_regexp},
 #endif
-  { 'x', M_REFERENCE,          0,              eat_regexp },
-  { 'y', M_XLABEL,             0,              eat_regexp },
-  { 'z', M_SIZE,               0,              eat_range },
-  { '=', M_DUPLICATED,         0,              NULL },
-  { '$', M_UNREFERENCED,       0,              NULL },
-  { '*', M_REALNAME,           0,              NULL },
-  { 0 }
+  {
+  'x', M_REFERENCE, 0, eat_regexp}, {
+  'y', M_XLABEL, 0, eat_regexp}, {
+  'z', M_SIZE, 0, eat_range}, {
+  '=', M_DUPLICATED, 0, NULL}, {
+  '$', M_UNREFERENCED, 0, NULL}, {
+  '*', M_REALNAME, 0, NULL}, {
+  0}
 };
 
 static pattern_t *SearchPattern = NULL; /* current search pattern */
-static char LastSearch[STRING] = { 0 };        /* last pattern searched for */
-static char LastSearchExpn[LONG_STRING] = { 0 }; /* expanded version of
-                                                   LastSearch */
+static char LastSearch[STRING] = { 0 }; /* last pattern searched for */
+static char LastSearchExpn[LONG_STRING] = { 0 };        /* expanded version of
+                                                           LastSearch */
 
 #define M_MAXRANGE -1
 
@@ -117,8 +117,7 @@ int mutt_getvaluebychar (char ch, struct mapping_t *table)
 {
   int i;
 
-  for (i = 0; table[i].name; i++)
-  {
+  for (i = 0; table[i].name; i++) {
     if (ch == table[i].name[0])
       return table[i].value;
   }
@@ -129,17 +128,17 @@ int mutt_getvaluebychar (char ch, struct mapping_t *table)
 /* if no uppercase letters are given, do a case-insensitive search */
 int mutt_which_case (const char *s)
 {
-  while (*s)
-  {
+  while (*s) {
     if (isalpha ((unsigned char) *s) && isupper ((unsigned char) *s))
-      return 0; /* case-sensitive */
+      return 0;                 /* case-sensitive */
     s++;
   }
-  return REG_ICASE; /* case-insensitive */
+  return REG_ICASE;             /* case-insensitive */
 }
 
 static int
-msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno)
+msg_search (CONTEXT * ctx, regex_t * rx, char *buf, size_t blen, int op,
+            int msgno)
 {
   char tempfile[_POSIX_PATH_MAX];
   MESSAGE *msg = NULL;
@@ -150,42 +149,36 @@ msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno
   int match = 0;
   HEADER *h = ctx->hdrs[msgno];
 
-  if ((msg = mx_open_message (ctx, msgno)) != NULL)
-  {
-    if (option (OPTTHOROUGHSRC))
-    {
+  if ((msg = mx_open_message (ctx, msgno)) != NULL) {
+    if (option (OPTTHOROUGHSRC)) {
       /* decode the header / body */
       memset (&s, 0, sizeof (s));
       s.fpin = msg->fp;
       s.flags = M_CHARCONV;
       mutt_mktemp (tempfile);
-      if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL)
-      {
-       mutt_perror (tempfile);
-       return (0);
+      if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL) {
+        mutt_perror (tempfile);
+        return (0);
       }
 
       if (op != M_BODY)
-       mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
-
-      if (op != M_HEADER)
-      {
-       mutt_parse_mime_message (ctx, h);
-
-       if (WithCrypto && (h->security & ENCRYPT)
-            && !crypt_valid_passphrase(h->security))
-       {
-         mx_close_message (&msg);
-         if (fp)
-         {
-           fclose (fp);
-           unlink (tempfile);
-         }
-         return (0);
-       }
-
-       fseek (msg->fp, h->offset, 0);
-       mutt_body_handler (h->content, &s);
+        mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
+
+      if (op != M_HEADER) {
+        mutt_parse_mime_message (ctx, h);
+
+        if (WithCrypto && (h->security & ENCRYPT)
+            && !crypt_valid_passphrase (h->security)) {
+          mx_close_message (&msg);
+          if (fp) {
+            fclose (fp);
+            unlink (tempfile);
+          }
+          return (0);
+        }
+
+        fseek (msg->fp, h->offset, 0);
+        mutt_body_handler (h->content, &s);
       }
 
       fp = s.fpout;
@@ -194,40 +187,34 @@ msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno
       fstat (fileno (fp), &st);
       lng = (long) st.st_size;
     }
-    else
-    {
+    else {
       /* raw header / body */
       fp = msg->fp;
-      if (op != M_BODY)
-      {
-       fseek (fp, h->offset, 0);
-       lng = h->content->offset - h->offset;
+      if (op != M_BODY) {
+        fseek (fp, h->offset, 0);
+        lng = h->content->offset - h->offset;
       }
-      if (op != M_HEADER)
-      {
-       if (op == M_BODY)
-         fseek (fp, h->content->offset, 0);
-       lng += h->content->length;
+      if (op != M_HEADER) {
+        if (op == M_BODY)
+          fseek (fp, h->content->offset, 0);
+        lng += h->content->length;
       }
     }
 
     /* search the file "fp" */
-    while (lng > 0)
-    {
+    while (lng > 0) {
       if (fgets (buf, blen - 1, fp) == NULL)
-       break; /* don't loop forever */
-      if (regexec (rx, buf, 0, NULL, 0) == 0)
-      {
-       match = 1;
-       break;
+        break;                  /* don't loop forever */
+      if (regexec (rx, buf, 0, NULL, 0) == 0) {
+        match = 1;
+        break;
       }
       lng -= mutt_strlen (buf);
     }
-    
+
     mx_close_message (&msg);
 
-    if (option (OPTTHOROUGHSRC))
-    {
+    if (option (OPTTHOROUGHSRC)) {
       fclose (fp);
       unlink (tempfile);
     }
@@ -236,23 +223,23 @@ msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno
   return match;
 }
 
-int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err)
+int eat_regexp (pattern_t * pat, BUFFER * s, BUFFER * err)
 {
   BUFFER buf;
   int r;
 
   memset (&buf, 0, sizeof (buf));
   if (mutt_extract_token (&buf, s, M_TOKEN_PATTERN | M_TOKEN_COMMENT) != 0 ||
-      !buf.data)
-  {
+      !buf.data) {
     snprintf (err->data, err->dsize, _("Error in expression: %s"), s->dptr);
     return (-1);
   }
   pat->rx = safe_malloc (sizeof (regex_t));
-  r = REGCOMP (pat->rx, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case (buf.data));
+  r =
+    REGCOMP (pat->rx, buf.data,
+             REG_NEWLINE | REG_NOSUB | mutt_which_case (buf.data));
   FREE (&buf.data);
-  if (r)
-  {
+  if (r) {
     regerror (r, pat->rx, err->data, err->dsize);
     regfree (pat->rx);
     FREE (&pat->rx);
@@ -261,50 +248,43 @@ int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err)
   return 0;
 }
 
-int eat_range (pattern_t *pat, BUFFER *s, BUFFER *err)
+int eat_range (pattern_t * pat, BUFFER * s, BUFFER * err)
 {
   char *tmp;
   int do_exclusive = 0;
   int skip_quote = 0;
-  
+
   /*
    * If simple_search is set to "~m %s", the range will have double quotes 
    * around it...
    */
-  if (*s->dptr == '"')
-  {
+  if (*s->dptr == '"') {
     s->dptr++;
     skip_quote = 1;
   }
   if (*s->dptr == '<')
     do_exclusive = 1;
-  if ((*s->dptr != '-') && (*s->dptr != '<'))
-  {
+  if ((*s->dptr != '-') && (*s->dptr != '<')) {
     /* range minimum */
-    if (*s->dptr == '>')
-    {
+    if (*s->dptr == '>') {
       pat->max = M_MAXRANGE;
-      pat->min = strtol (s->dptr + 1, &tmp, 0) + 1; /* exclusive range */
+      pat->min = strtol (s->dptr + 1, &tmp, 0) + 1;     /* exclusive range */
     }
     else
       pat->min = strtol (s->dptr, &tmp, 0);
-    if (toupper ((unsigned char) *tmp) == 'K') /* is there a prefix? */
-    {
+    if (toupper ((unsigned char) *tmp) == 'K') {        /* is there a prefix? */
       pat->min *= 1024;
       tmp++;
     }
-    else if (toupper ((unsigned char) *tmp) == 'M')
-    {
+    else if (toupper ((unsigned char) *tmp) == 'M') {
       pat->min *= 1048576;
       tmp++;
     }
-    if (*s->dptr == '>')
-    {
+    if (*s->dptr == '>') {
       s->dptr = tmp;
       return 0;
     }
-    if (*tmp != '-')
-    {
+    if (*tmp != '-') {
       /* exact value */
       pat->max = pat->min;
       s->dptr = tmp;
@@ -312,23 +292,19 @@ int eat_range (pattern_t *pat, BUFFER *s, BUFFER *err)
     }
     tmp++;
   }
-  else
-  {
+  else {
     s->dptr++;
     tmp = s->dptr;
   }
-  
-  if (isdigit ((unsigned char) *tmp))
-  {
+
+  if (isdigit ((unsigned char) *tmp)) {
     /* range maximum */
     pat->max = strtol (tmp, &tmp, 0);
-    if (toupper ((unsigned char) *tmp) == 'K')
-    {
+    if (toupper ((unsigned char) *tmp) == 'K') {
       pat->max *= 1024;
       tmp++;
     }
-    else if (toupper ((unsigned char) *tmp) == 'M')
-    {
+    else if (toupper ((unsigned char) *tmp) == 'M') {
       pat->max *= 1048576;
       tmp++;
     }
@@ -346,20 +322,18 @@ int eat_range (pattern_t *pat, BUFFER *s, BUFFER *err)
   return 0;
 }
 
-static const char *getDate (const char *s, struct tm *t, BUFFER *err)
+static const char *getDate (const char *s, struct tm *t, BUFFER * err)
 {
   char *p;
   time_t now = time (NULL);
   struct tm *tm = localtime (&now);
 
   t->tm_mday = strtol (s, &p, 10);
-  if (t->tm_mday < 1 || t->tm_mday > 31)
-  {
+  if (t->tm_mday < 1 || t->tm_mday > 31) {
     snprintf (err->data, err->dsize, _("Invalid day of month: %s"), s);
     return NULL;
   }
-  if (*p != '/')
-  {
+  if (*p != '/') {
     /* fill in today's month and year */
     t->tm_mon = tm->tm_mon;
     t->tm_year = tm->tm_year;
@@ -367,19 +341,17 @@ static const char *getDate (const char *s, struct tm *t, BUFFER *err)
   }
   p++;
   t->tm_mon = strtol (p, &p, 10) - 1;
-  if (t->tm_mon < 0 || t->tm_mon > 11)
-  {
+  if (t->tm_mon < 0 || t->tm_mon > 11) {
     snprintf (err->data, err->dsize, _("Invalid month: %s"), p);
     return NULL;
   }
-  if (*p != '/')
-  {
+  if (*p != '/') {
     t->tm_year = tm->tm_year;
     return p;
   }
   p++;
   t->tm_year = strtol (p, &p, 10);
-  if (t->tm_year < 70) /* year 2000+ */
+  if (t->tm_year < 70)          /* year 2000+ */
     t->tm_year += 100;
   else if (t->tm_year > 1900)
     t->tm_year -= 1900;
@@ -394,25 +366,25 @@ static const char *get_offset (struct tm *tm, const char *s, int sign)
 {
   char *ps;
   int offset = strtol (s, &ps, 0);
+
   if ((sign < 0 && offset > 0) || (sign > 0 && offset < 0))
     offset = -offset;
 
-  switch (*ps)
-  {
-    case 'y':
-      tm->tm_year += offset;
-      break;
-    case 'm':
-      tm->tm_mon += offset;
-      break;
-    case 'w':
-      tm->tm_mday += 7 * offset;
-      break;
-    case 'd':
-      tm->tm_mday += offset;
-      break;
-    default:
-      return s;
+  switch (*ps) {
+  case 'y':
+    tm->tm_year += offset;
+    break;
+  case 'm':
+    tm->tm_mon += offset;
+    break;
+  case 'w':
+    tm->tm_mday += 7 * offset;
+    break;
+  case 'd':
+    tm->tm_mday += offset;
+    break;
+  default:
+    return s;
   }
   mutt_normalize_time (tm);
   return (ps + 1);
@@ -423,118 +395,109 @@ static void adjust_date_range (struct tm *min, struct tm *max)
   if (min->tm_year > max->tm_year
       || (min->tm_year == max->tm_year && min->tm_mon > max->tm_mon)
       || (min->tm_year == max->tm_year && min->tm_mon == max->tm_mon
-       && min->tm_mday > max->tm_mday))
-  {
+          && min->tm_mday > max->tm_mday)) {
     int tmp;
-    
+
     tmp = min->tm_year;
     min->tm_year = max->tm_year;
     max->tm_year = tmp;
-      
+
     tmp = min->tm_mon;
     min->tm_mon = max->tm_mon;
     max->tm_mon = tmp;
-      
+
     tmp = min->tm_mday;
     min->tm_mday = max->tm_mday;
     max->tm_mday = tmp;
-    
+
     min->tm_hour = min->tm_min = min->tm_sec = 0;
     max->tm_hour = 23;
     max->tm_min = max->tm_sec = 59;
   }
 }
 
-static const char * parse_date_range (const char* pc, struct tm *min,
-    struct tm *max, int haveMin, struct tm *baseMin, BUFFER *err)
+static const char *parse_date_range (const char *pc, struct tm *min,
+                                     struct tm *max, int haveMin,
+                                     struct tm *baseMin, BUFFER * err)
 {
-  int flag = M_PDR_NONE;       
-  while (*pc && ((flag & M_PDR_DONE) == 0))
-  {
+  int flag = M_PDR_NONE;
+
+  while (*pc && ((flag & M_PDR_DONE) == 0)) {
     const char *pt;
     char ch = *pc++;
+
     SKIPWS (pc);
-    switch (ch)
-    {
-      case '-':
+    switch (ch) {
+    case '-':
       {
-       /* try a range of absolute date minus offset of Ndwmy */
-       pt = get_offset (min, pc, -1);
-       if (pc == pt)
-       {
-         if (flag == M_PDR_NONE)
-         { /* nothing yet and no offset parsed => absolute date? */
-           if (!getDate (pc, max, err))
-             flag |= (M_PDR_ABSOLUTE | M_PDR_ERRORDONE);  /* done bad */
-           else
-           {
-             /* reestablish initial base minimum if not specified */
-             if (!haveMin)
-               memcpy (min, baseMin, sizeof(struct tm));
-             flag |= (M_PDR_ABSOLUTE | M_PDR_DONE);  /* done good */
-           }
-         }
-         else
-           flag |= M_PDR_ERRORDONE;
-       }
-       else
-       {
-         pc = pt;
-         if (flag == M_PDR_NONE && !haveMin)
-         { /* the very first "-3d" without a previous absolute date */
-           max->tm_year = min->tm_year;
-           max->tm_mon = min->tm_mon;
-           max->tm_mday = min->tm_mday;
-         }
-         flag |= M_PDR_MINUS;
-       }
+        /* try a range of absolute date minus offset of Ndwmy */
+        pt = get_offset (min, pc, -1);
+        if (pc == pt) {
+          if (flag == M_PDR_NONE) {     /* nothing yet and no offset parsed => absolute date? */
+            if (!getDate (pc, max, err))
+              flag |= (M_PDR_ABSOLUTE | M_PDR_ERRORDONE);       /* done bad */
+            else {
+              /* reestablish initial base minimum if not specified */
+              if (!haveMin)
+                memcpy (min, baseMin, sizeof (struct tm));
+              flag |= (M_PDR_ABSOLUTE | M_PDR_DONE);    /* done good */
+            }
+          }
+          else
+            flag |= M_PDR_ERRORDONE;
+        }
+        else {
+          pc = pt;
+          if (flag == M_PDR_NONE && !haveMin) { /* the very first "-3d" without a previous absolute date */
+            max->tm_year = min->tm_year;
+            max->tm_mon = min->tm_mon;
+            max->tm_mday = min->tm_mday;
+          }
+          flag |= M_PDR_MINUS;
+        }
       }
       break;
-      case '+':
-      { /* enlarge plusRange */
-       pt = get_offset (max, pc, 1);
-       if (pc == pt)
-         flag |= M_PDR_ERRORDONE;
-       else
-       {
-         pc = pt;
-         flag |= M_PDR_PLUS;
-       }
+    case '+':
+      {                         /* enlarge plusRange */
+        pt = get_offset (max, pc, 1);
+        if (pc == pt)
+          flag |= M_PDR_ERRORDONE;
+        else {
+          pc = pt;
+          flag |= M_PDR_PLUS;
+        }
       }
       break;
-      case '*':
-      { /* enlarge window in both directions */
-       pt = get_offset (min, pc, -1);
-       if (pc == pt)
-         flag |= M_PDR_ERRORDONE;
-       else
-       {
-         pc = get_offset (max, pc, 1);
-         flag |= M_PDR_WINDOW;
-       }
+    case '*':
+      {                         /* enlarge window in both directions */
+        pt = get_offset (min, pc, -1);
+        if (pc == pt)
+          flag |= M_PDR_ERRORDONE;
+        else {
+          pc = get_offset (max, pc, 1);
+          flag |= M_PDR_WINDOW;
+        }
       }
       break;
-      default:
-       flag |= M_PDR_ERRORDONE;
+    default:
+      flag |= M_PDR_ERRORDONE;
     }
     SKIPWS (pc);
   }
-  if ((flag & M_PDR_ERROR) && !(flag & M_PDR_ABSOLUTE))
-  { /* getDate has its own error message, don't overwrite it here */
-    snprintf (err->data, err->dsize, _("Invalid relative date: %s"), pc-1);
+  if ((flag & M_PDR_ERROR) && !(flag & M_PDR_ABSOLUTE)) {       /* getDate has its own error message, don't overwrite it here */
+    snprintf (err->data, err->dsize, _("Invalid relative date: %s"), pc - 1);
   }
   return ((flag & M_PDR_ERROR) ? NULL : pc);
 }
 
-static int eat_date (pattern_t *pat, BUFFER *s, BUFFER *err)
+static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err)
 {
   BUFFER buffer;
   struct tm min, max;
 
   memset (&buffer, 0, sizeof (buffer));
   if (mutt_extract_token (&buffer, s, M_TOKEN_COMMENT | M_TOKEN_PATTERN) != 0
-      || !buffer.data)
-  {
+      || !buffer.data) {
     strfcpy (err->data, _("error in expression"), err->dsize);
     return (-1);
   }
@@ -558,28 +521,25 @@ static int eat_date (pattern_t *pat, BUFFER *s, BUFFER *err)
   max.tm_min = 59;
   max.tm_sec = 59;
 
-  if (strchr ("<>=", buffer.data[0]))
-  {
+  if (strchr ("<>=", buffer.data[0])) {
     /* offset from current time
-       <3d     less than three days ago
-       >3d     more than three days ago
-       =3d     exactly three days ago */
+       <3d      less than three days ago
+       >3d      more than three days ago
+       =3d      exactly three days ago */
     time_t now = time (NULL);
     struct tm *tm = localtime (&now);
     int exact = 0;
 
-    if (buffer.data[0] == '<')
-    {
+    if (buffer.data[0] == '<') {
       memcpy (&min, tm, sizeof (min));
       tm = &min;
     }
-    else
-    {
+    else {
       memcpy (&max, tm, sizeof (max));
       tm = &max;
 
       if (buffer.data[0] == '=')
-       exact++;
+        exact++;
     }
     tm->tm_hour = 23;
     tm->tm_min = tm->tm_sec = 59;
@@ -587,61 +547,56 @@ static int eat_date (pattern_t *pat, BUFFER *s, BUFFER *err)
     /* force negative offset */
     get_offset (tm, buffer.data + 1, -1);
 
-    if (exact)
-    {
+    if (exact) {
       /* start at the beginning of the day in question */
       memcpy (&min, &max, sizeof (max));
       min.tm_hour = min.tm_sec = min.tm_min = 0;
     }
   }
-  else
-  {
+  else {
     const char *pc = buffer.data;
 
     int haveMin = FALSE;
     int untilNow = FALSE;
-    if (isdigit ((unsigned char)*pc))
-    {
+
+    if (isdigit ((unsigned char) *pc)) {
       /* mininum date specified */
-      if ((pc = getDate (pc, &min, err)) == NULL)
-      {
-       FREE (&buffer.data);
-       return (-1);
+      if ((pc = getDate (pc, &min, err)) == NULL) {
+        FREE (&buffer.data);
+        return (-1);
       }
       haveMin = TRUE;
       SKIPWS (pc);
-      if (*pc == '-')
-      {
+      if (*pc == '-') {
         const char *pt = pc + 1;
-       SKIPWS (pt);
-       untilNow = (*pt == '\0');
+
+        SKIPWS (pt);
+        untilNow = (*pt == '\0');
       }
     }
 
-    if (!untilNow)
-    { /* max date or relative range/window */
+    if (!untilNow) {            /* max date or relative range/window */
 
       struct tm baseMin;
 
-      if (!haveMin)
-      { /* save base minimum and set current date, e.g. for "-3d+1d" */
-       time_t now = time (NULL);
-       struct tm *tm = localtime (&now);
-       memcpy (&baseMin, &min, sizeof(baseMin));
-       memcpy (&min, tm, sizeof (min));
-       min.tm_hour = min.tm_sec = min.tm_min = 0;
+      if (!haveMin) {           /* save base minimum and set current date, e.g. for "-3d+1d" */
+        time_t now = time (NULL);
+        struct tm *tm = localtime (&now);
+
+        memcpy (&baseMin, &min, sizeof (baseMin));
+        memcpy (&min, tm, sizeof (min));
+        min.tm_hour = min.tm_sec = min.tm_min = 0;
       }
-      
+
       /* preset max date for relative offsets,
-        if nothing follows we search for messages on a specific day */
+         if nothing follows we search for messages on a specific day */
       max.tm_year = min.tm_year;
       max.tm_mon = min.tm_mon;
       max.tm_mday = min.tm_mday;
 
-      if (!parse_date_range (pc, &min, &max, haveMin, &baseMin, err))
-      { /* bail out on any parsing error */
-       FREE (&buffer.data);
-       return (-1);
+      if (!parse_date_range (pc, &min, &max, haveMin, &baseMin, err)) { /* bail out on any parsing error */
+        FREE (&buffer.data);
+        return (-1);
       }
     }
   }
@@ -667,35 +622,31 @@ static struct pattern_flags *lookup_tag (char tag)
   return NULL;
 }
 
-static /* const */ char *find_matching_paren (/* const */ char *s)
+static /* const */ char *find_matching_paren ( /* const */ char *s)
 {
   int level = 1;
 
-  for (; *s; s++)
-  {
+  for (; *s; s++) {
     if (*s == '(')
       level++;
-    else if (*s == ')')
-    {
+    else if (*s == ')') {
       level--;
       if (!level)
-       break;
+        break;
     }
   }
   return s;
 }
 
-void mutt_pattern_free (pattern_t **pat)
+void mutt_pattern_free (pattern_t ** pat)
 {
   pattern_t *tmp;
 
-  while (*pat)
-  {
+  while (*pat) {
     tmp = *pat;
     *pat = (*pat)->next;
 
-    if (tmp->rx)
-    {
+    if (tmp->rx) {
       regfree (tmp->rx);
       FREE (&tmp->rx);
     }
@@ -705,7 +656,7 @@ void mutt_pattern_free (pattern_t **pat)
   }
 }
 
-pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err)
+pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err)
 {
   pattern_t *curlist = NULL;
   pattern_t *tmp;
@@ -713,7 +664,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err)
   int not = 0;
   int alladdr = 0;
   int or = 0;
-  int implicit = 1;    /* used to detect logical AND operator */
+  int implicit = 1;             /* used to detect logical AND operator */
   struct pattern_flags *entry;
   char *p;
   char *buf;
@@ -723,144 +674,132 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err)
   ps.dptr = s;
   ps.dsize = mutt_strlen (s);
 
-  while (*ps.dptr)
-  {
+  while (*ps.dptr) {
     SKIPWS (ps.dptr);
-    switch (*ps.dptr)
-    {
-      case '^':
-       ps.dptr++;
-       alladdr = !alladdr;
-       break;
-      case '!':
-       ps.dptr++;
-       not = !not;
-       break;
-      case '|':
-       if (!or)
-       {
-         if (!curlist)
-         {
-           snprintf (err->data, err->dsize, _("error in pattern at: %s"), ps.dptr);
-           return NULL;
-         }
-         if (curlist->next)
-         {
-           /* A & B | C == (A & B) | C */
-           tmp = new_pattern ();
-           tmp->op = M_AND;
-           tmp->child = curlist;
-
-           curlist = tmp;
-           last = curlist;
-         }
-
-         or = 1;
-       }
-       ps.dptr++;
-       implicit = 0;
-       not = 0;
-       alladdr = 0;
-       break;
-      case '~':
-       if (implicit && or)
-       {
-         /* A | B & C == (A | B) & C */
-         tmp = new_pattern ();
-         tmp->op = M_OR;
-         tmp->child = curlist;
-         curlist = tmp;
-         last = tmp;
-         or = 0;
-       }
-
-       tmp = new_pattern ();
-       tmp->not = not;
-       tmp->alladdr = alladdr;
-       not = 0;
-       alladdr=0;
-
-       if (last)
-         last->next = tmp;
-       else
-         curlist = tmp;
-       last = tmp;
-
-       ps.dptr++; /* move past the ~ */
-       if ((entry = lookup_tag (*ps.dptr)) == NULL)
-       {
-         snprintf (err->data, err->dsize, _("%c: invalid command"), *ps.dptr);
-         mutt_pattern_free (&curlist);
-         return NULL;
-       }
-       if (entry->class && (flags & entry->class) == 0)
-       {
-         snprintf (err->data, err->dsize, _("%c: not supported in this mode"), *ps.dptr);
-         mutt_pattern_free (&curlist);
-         return NULL;
-       }
-       tmp->op = entry->op;
-
-       ps.dptr++; /* eat the operator and any optional whitespace */
-       SKIPWS (ps.dptr);
-
-       if (entry->eat_arg)
-       {
-         if (!*ps.dptr)
-         {
-           snprintf (err->data, err->dsize, _("missing parameter"));
-           mutt_pattern_free (&curlist);
-           return NULL;
-         }
-         if (entry->eat_arg (tmp, &ps, err) == -1)
-         {
-           mutt_pattern_free (&curlist);
-           return NULL;
-         }
-       }
-       implicit = 1;
-       break;
-      case '(':
-       p = find_matching_paren (ps.dptr + 1);
-       if (*p != ')')
-       {
-         snprintf (err->data, err->dsize, _("mismatched parenthesis: %s"), ps.dptr);
-         mutt_pattern_free (&curlist);
-         return NULL;
-       }
-       /* compile the sub-expression */
-       buf = mutt_substrdup (ps.dptr + 1, p);
-       if ((tmp = mutt_pattern_comp (buf, flags, err)) == NULL)
-       {
-         FREE (&buf);
-         mutt_pattern_free (&curlist);
-         return NULL;
-       }
-       FREE (&buf);
-       if (last)
-         last->next = tmp;
-       else
-         curlist = tmp;
-       last = tmp;
-       tmp->not ^= not;
-       tmp->alladdr |= alladdr;
-       not = 0;
-       alladdr = 0;
-       ps.dptr = p + 1; /* restore location */
-       break;
-      default:
-       snprintf (err->data, err->dsize, _("error in pattern at: %s"), ps.dptr);
-       mutt_pattern_free (&curlist);
-       return NULL;
+    switch (*ps.dptr) {
+    case '^':
+      ps.dptr++;
+      alladdr = !alladdr;
+      break;
+    case '!':
+      ps.dptr++;
+      not = !not;
+      break;
+    case '|':
+      if (!or) {
+        if (!curlist) {
+          snprintf (err->data, err->dsize, _("error in pattern at: %s"),
+                    ps.dptr);
+          return NULL;
+        }
+        if (curlist->next) {
+          /* A & B | C == (A & B) | C */
+          tmp = new_pattern ();
+          tmp->op = M_AND;
+          tmp->child = curlist;
+
+          curlist = tmp;
+          last = curlist;
+        }
+
+        or = 1;
+      }
+      ps.dptr++;
+      implicit = 0;
+      not = 0;
+      alladdr = 0;
+      break;
+    case '~':
+      if (implicit && or) {
+        /* A | B & C == (A | B) & C */
+        tmp = new_pattern ();
+        tmp->op = M_OR;
+        tmp->child = curlist;
+        curlist = tmp;
+        last = tmp;
+        or = 0;
+      }
+
+      tmp = new_pattern ();
+      tmp->not = not;
+      tmp->alladdr = alladdr;
+      not = 0;
+      alladdr = 0;
+
+      if (last)
+        last->next = tmp;
+      else
+        curlist = tmp;
+      last = tmp;
+
+      ps.dptr++;                /* move past the ~ */
+      if ((entry = lookup_tag (*ps.dptr)) == NULL) {
+        snprintf (err->data, err->dsize, _("%c: invalid command"), *ps.dptr);
+        mutt_pattern_free (&curlist);
+        return NULL;
+      }
+      if (entry->class && (flags & entry->class) == 0) {
+        snprintf (err->data, err->dsize, _("%c: not supported in this mode"),
+                  *ps.dptr);
+        mutt_pattern_free (&curlist);
+        return NULL;
+      }
+      tmp->op = entry->op;
+
+      ps.dptr++;                /* eat the operator and any optional whitespace */
+      SKIPWS (ps.dptr);
+
+      if (entry->eat_arg) {
+        if (!*ps.dptr) {
+          snprintf (err->data, err->dsize, _("missing parameter"));
+          mutt_pattern_free (&curlist);
+          return NULL;
+        }
+        if (entry->eat_arg (tmp, &ps, err) == -1) {
+          mutt_pattern_free (&curlist);
+          return NULL;
+        }
+      }
+      implicit = 1;
+      break;
+    case '(':
+      p = find_matching_paren (ps.dptr + 1);
+      if (*p != ')') {
+        snprintf (err->data, err->dsize, _("mismatched parenthesis: %s"),
+                  ps.dptr);
+        mutt_pattern_free (&curlist);
+        return NULL;
+      }
+      /* compile the sub-expression */
+      buf = mutt_substrdup (ps.dptr + 1, p);
+      if ((tmp = mutt_pattern_comp (buf, flags, err)) == NULL) {
+        FREE (&buf);
+        mutt_pattern_free (&curlist);
+        return NULL;
+      }
+      FREE (&buf);
+      if (last)
+        last->next = tmp;
+      else
+        curlist = tmp;
+      last = tmp;
+      tmp->not ^= not;
+      tmp->alladdr |= alladdr;
+      not = 0;
+      alladdr = 0;
+      ps.dptr = p + 1;          /* restore location */
+      break;
+    default:
+      snprintf (err->data, err->dsize, _("error in pattern at: %s"), ps.dptr);
+      mutt_pattern_free (&curlist);
+      return NULL;
     }
   }
-  if (!curlist)
-  {
+  if (!curlist) {
     strfcpy (err->data, _("empty pattern"), err->dsize);
     return NULL;
   }
-  if (curlist->next)
-  {
+  if (curlist->next) {
     tmp = new_pattern ();
     tmp->op = or ? M_OR : M_AND;
     tmp->child = curlist;
@@ -870,7 +809,8 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err)
 }
 
 static int
-perform_and (pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *hdr)
+perform_and (pattern_t * pat, pattern_exec_flag flags, CONTEXT * ctx,
+             HEADER * hdr)
 {
   for (; pat; pat = pat->next)
     if (mutt_pattern_exec (pat, flags, ctx, hdr) <= 0)
@@ -879,7 +819,8 @@ perform_and (pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *hdr)
 }
 
 static int
-perform_or (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *hdr)
+perform_or (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT * ctx,
+            HEADER * hdr)
 {
   for (; pat; pat = pat->next)
     if (mutt_pattern_exec (pat, flags, ctx, hdr) > 0)
@@ -887,32 +828,29 @@ perform_or (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER
   return 0;
 }
 
-static int match_adrlist (regex_t *rx, int match_personal, int alladdr,
-                         int n, ...)
+static int match_adrlist (regex_t * rx, int match_personal, int alladdr,
+                          int n, ...)
 {
   va_list ap;
   ADDRESS *a;
 
   va_start (ap, n);
-  for ( ; n ; n --)
-  {
-    for (a = va_arg (ap, ADDRESS *) ; a ; a = a->next)
-    {
-      if (alladdr^
-         ((a->mailbox && regexec (rx, a->mailbox, 0, NULL, 0) == 0) ||
-          (match_personal && a->personal &&
-           regexec (rx, a->personal, 0, NULL, 0) == 0)))
-      {
-       va_end (ap);
-       return (! alladdr); /* Found match, or non-match if alladdr */
+  for (; n; n--) {
+    for (a = va_arg (ap, ADDRESS *); a; a = a->next) {
+      if (alladdr ^
+          ((a->mailbox && regexec (rx, a->mailbox, 0, NULL, 0) == 0) ||
+           (match_personal && a->personal &&
+            regexec (rx, a->personal, 0, NULL, 0) == 0))) {
+        va_end (ap);
+        return (!alladdr);      /* Found match, or non-match if alladdr */
       }
     }
   }
   va_end (ap);
-  return alladdr; /* No matches, or all matches if alladdr */
+  return alladdr;               /* No matches, or all matches if alladdr */
 }
 
-static int match_reference (regex_t *rx, LIST *refs)
+static int match_reference (regex_t * rx, LIST * refs)
 {
   for (; refs; refs = refs->next)
     if (regexec (rx, refs->data, 0, NULL, 0) == 0)
@@ -920,48 +858,48 @@ static int match_reference (regex_t *rx, LIST *refs)
   return 0;
 }
 
-int mutt_is_list_recipient (int alladdr, ADDRESS *a1, ADDRESS *a2)
+int mutt_is_list_recipient (int alladdr, ADDRESS * a1, ADDRESS * a2)
 {
-  for (; a1 ; a1 = a1->next)
+  for (; a1; a1 = a1->next)
     if (alladdr ^ mutt_is_subscribed_list (a1))
-      return (! alladdr);
-  for (; a2 ; a2 = a2->next)
+      return (!alladdr);
+  for (; a2; a2 = a2->next)
     if (alladdr ^ mutt_is_subscribed_list (a2))
-      return (! alladdr);
+      return (!alladdr);
   return alladdr;
 }
 
-int mutt_is_list_cc (int alladdr, ADDRESS *a1, ADDRESS *a2)
+int mutt_is_list_cc (int alladdr, ADDRESS * a1, ADDRESS * a2)
 {
-  for (; a1 ; a1 = a1->next)
+  for (; a1; a1 = a1->next)
     if (alladdr ^ mutt_is_mail_list (a1))
-      return (! alladdr);
-  for (; a2 ; a2 = a2->next)
+      return (!alladdr);
+  for (; a2; a2 = a2->next)
     if (alladdr ^ mutt_is_mail_list (a2))
-      return (! alladdr);
+      return (!alladdr);
   return alladdr;
 }
 
-static int match_user (int alladdr, ADDRESS *a1, ADDRESS *a2)
+static int match_user (int alladdr, ADDRESS * a1, ADDRESS * a2)
 {
-  for (; a1 ; a1 = a1->next)
+  for (; a1; a1 = a1->next)
     if (alladdr ^ mutt_addr_is_user (a1))
-      return (! alladdr);
-  for (; a2 ; a2 = a2->next)
+      return (!alladdr);
+  for (; a2; a2 = a2->next)
     if (alladdr ^ mutt_addr_is_user (a2))
-      return (! alladdr);
+      return (!alladdr);
   return alladdr;
 }
 
 /* test if name is considered a real name, i.e. consists of at least 2
  * space-separated words of which none may end in a dot
  */
-static int valid_realname (const charname)
+static int valid_realname (const char *name)
 {
-  const charp = name;
+  const char *p = name;
   int ret = 0;
-  while (*p)
-  {
+
+  while (*p) {
     if (isspace (*p))
       ret++;
     else if (*p == '.')
@@ -975,139 +913,177 @@ static int valid_realname (const char* name)
 /* flags
        M_MATCH_FULL_ADDRESS    match both personal and machine address */
 int
-mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h)
+mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
+                   CONTEXT * ctx, HEADER * h)
 {
   char buf[STRING];
 
-  switch (pat->op)
-  {
-    case M_AND:
-      return (pat->not ^ (perform_and (pat->child, flags, ctx, h) > 0));
-    case M_OR:
-      return (pat->not ^ (perform_or (pat->child, flags, ctx, h) > 0));
-    case M_ALL:
-      return (!pat->not);
-    case M_EXPIRED:
-      return (pat->not ^ h->expired);
-    case M_SUPERSEDED:
-      return (pat->not ^ h->superseded);
-    case M_FLAG:
-      return (pat->not ^ h->flagged);
-    case M_TAG:
-      return (pat->not ^ h->tagged);
-    case M_NEW:
-      return (pat->not ? h->old || h->read : !(h->old || h->read));
-    case M_UNREAD:
-      return (pat->not ? h->read : !h->read);
-    case M_REPLIED:
-      return (pat->not ^ h->replied);
-    case M_OLD:
-      return (pat->not ? (!h->old || h->read) : (h->old && !h->read));
-    case M_READ:
-      return (pat->not ^ h->read);
-    case M_DELETED:
-      return (pat->not ^ h->deleted);
-    case M_MESSAGE:
-      return (pat->not ^ (h->msgno >= pat->min - 1 && (pat->max == M_MAXRANGE ||
-                                                  h->msgno <= pat->max - 1)));
-    case M_DATE:
-      return (pat->not ^ (h->date_sent >= pat->min && h->date_sent <= pat->max));
-    case M_DATE_RECEIVED:
-      return (pat->not ^ (h->received >= pat->min && h->received <= pat->max));
-    case M_BODY:
-    case M_HEADER:
-    case M_WHOLE_MSG:
-      return (pat->not ^ msg_search (ctx, pat->rx, buf, sizeof (buf), pat->op, h->msgno));
-    case M_SENDER:
-      return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 1, h->env->sender));
-    case M_FROM:
-      return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 1, h->env->from));
-    case M_TO:
-      return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 1, h->env->to));
-    case M_CC:
-      return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 1, h->env->cc));
-    case M_SUBJECT:
-      return (pat->not ^ (h->env && h->env->subject && regexec (pat->rx, h->env->subject, 0, NULL, 0) == 0));
-    case M_ID:
-      return (pat->not ^ (h->env && h->env->message_id && regexec (pat->rx, h->env->message_id, 0, NULL, 0) == 0));
-    case M_SCORE:
-      return (pat->not ^ (h->score >= pat->min && (pat->max == M_MAXRANGE ||
-                                                  h->score <= pat->max)));
-    case M_SIZE:
-      return (pat->not ^ (h->content->length >= pat->min && (pat->max == M_MAXRANGE || h->content->length <= pat->max)));
-    case M_REFERENCE:
-      return (pat->not ^ match_reference (pat->rx, h->env->references));
-    case M_ADDRESS:
-      return (pat->not ^ (h->env && match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 4, h->env->from,
-                                       h->env->sender, h->env->to, h->env->cc)));
-    case M_RECIPIENT:
-           return (pat->not ^ (h->env && match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
-                                       pat->alladdr, 2, h->env->to, h->env->cc)));
-    case M_LIST:
-      return (pat->not ^ (h->env && mutt_is_list_recipient (pat->alladdr, h->env->to, h->env->cc)));
-    case M_PERSONAL_RECIP:
-      return (pat->not ^ (h->env && match_user (pat->alladdr, h->env->to, h->env->cc)));
-    case M_PERSONAL_FROM:
-      return (pat->not ^ (h->env && match_user (pat->alladdr, h->env->from, NULL)));
-    case M_COLLAPSED:
-      return (pat->not ^ (h->collapsed && h->num_hidden > 1));
-   case M_CRYPT_SIGN:
-     if (!WithCrypto)
-       break;
-     return (pat->not ^ ((h->security & SIGN) ? 1 : 0));
-   case M_CRYPT_VERIFIED:
-     if (!WithCrypto)
-       break;
-     return (pat->not ^ ((h->security & GOODSIGN) ? 1 : 0));
-   case M_CRYPT_ENCRYPT:
-     if (!WithCrypto)
-       break;
-     return (pat->not ^ ((h->security & ENCRYPT) ? 1 : 0));
-   case M_PGP_KEY:
-     if (!(WithCrypto & APPLICATION_PGP))
-       break;
-     return (pat->not ^ ((h->security & APPLICATION_PGP) && (h->security & PGPKEY)));
-    case M_XLABEL:
-      return (pat->not ^ (h->env->x_label && regexec (pat->rx, h->env->x_label, 0, NULL, 0) == 0));
-    case M_HORMEL:
-      return (pat->not ^ (h->env->spam && h->env->spam->data && regexec (pat->rx, h->env->spam->data, 0, NULL, 0) == 0));
-    case M_DUPLICATED:
-      return (pat->not ^ (h->thread && h->thread->duplicate_thread));
-    case M_UNREFERENCED:
-      return (pat->not ^ (h->thread && !h->thread->child));
-    case M_REALNAME:
-      /* realname filter:
-       * we have a match if
-       * - From: matches $alternates
-       * - or we have an alias for current address
-       * - or From: contains valid email address _and_ name has >= 2 fields
-       */
-      return (pat->not ^ (h->env && h->env->from && (
-                            mutt_addr_is_user (h->env->from) ||
-                            (alias_reverse_lookup (h->env->from) != NULL) ||
-                            (h->env->from->personal && valid_realname (h->env->from->personal) && h->env->from->mailbox)
-                            )));
+  switch (pat->op) {
+  case M_AND:
+    return (pat->not ^ (perform_and (pat->child, flags, ctx, h) > 0));
+  case M_OR:
+    return (pat->not ^ (perform_or (pat->child, flags, ctx, h) > 0));
+  case M_ALL:
+    return (!pat->not);
+  case M_EXPIRED:
+    return (pat->not ^ h->expired);
+  case M_SUPERSEDED:
+    return (pat->not ^ h->superseded);
+  case M_FLAG:
+    return (pat->not ^ h->flagged);
+  case M_TAG:
+    return (pat->not ^ h->tagged);
+  case M_NEW:
+    return (pat->not ? h->old || h->read : !(h->old || h->read));
+  case M_UNREAD:
+    return (pat->not ? h->read : !h->read);
+  case M_REPLIED:
+    return (pat->not ^ h->replied);
+  case M_OLD:
+    return (pat->not ? (!h->old || h->read) : (h->old && !h->read));
+  case M_READ:
+    return (pat->not ^ h->read);
+  case M_DELETED:
+    return (pat->not ^ h->deleted);
+  case M_MESSAGE:
+    return (pat->not ^ (h->msgno >= pat->min - 1 && (pat->max == M_MAXRANGE ||
+                                                     h->msgno <=
+                                                     pat->max - 1)));
+  case M_DATE:
+    return (pat->
+            not ^ (h->date_sent >= pat->min && h->date_sent <= pat->max));
+  case M_DATE_RECEIVED:
+    return (pat->not ^ (h->received >= pat->min && h->received <= pat->max));
+  case M_BODY:
+  case M_HEADER:
+  case M_WHOLE_MSG:
+    return (pat->
+            not ^ msg_search (ctx, pat->rx, buf, sizeof (buf), pat->op,
+                              h->msgno));
+  case M_SENDER:
+    return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                      pat->alladdr, 1, h->env->sender));
+  case M_FROM:
+    return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                      pat->alladdr, 1, h->env->from));
+  case M_TO:
+    return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                      pat->alladdr, 1, h->env->to));
+  case M_CC:
+    return (pat->not ^ match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                      pat->alladdr, 1, h->env->cc));
+  case M_SUBJECT:
+    return (pat->
+            not ^ (h->env && h->env->subject
+                   && regexec (pat->rx, h->env->subject, 0, NULL, 0) == 0));
+  case M_ID:
+    return (pat->
+            not ^ (h->env && h->env->message_id
+                   && regexec (pat->rx, h->env->message_id, 0, NULL,
+                               0) == 0));
+  case M_SCORE:
+    return (pat->not ^ (h->score >= pat->min && (pat->max == M_MAXRANGE ||
+                                                 h->score <= pat->max)));
+  case M_SIZE:
+    return (pat->
+            not ^ (h->content->length >= pat->min
+                   && (pat->max == M_MAXRANGE
+                       || h->content->length <= pat->max)));
+  case M_REFERENCE:
+    return (pat->not ^ match_reference (pat->rx, h->env->references));
+  case M_ADDRESS:
+    return (pat->
+            not ^ (h->env
+                   && match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                     pat->alladdr, 4, h->env->from,
+                                     h->env->sender, h->env->to,
+                                     h->env->cc)));
+  case M_RECIPIENT:
+    return (pat->
+            not ^ (h->env
+                   && match_adrlist (pat->rx, flags & M_MATCH_FULL_ADDRESS,
+                                     pat->alladdr, 2, h->env->to,
+                                     h->env->cc)));
+  case M_LIST:
+    return (pat->
+            not ^ (h->env
+                   && mutt_is_list_recipient (pat->alladdr, h->env->to,
+                                              h->env->cc)));
+  case M_PERSONAL_RECIP:
+    return (pat->
+            not ^ (h->env
+                   && match_user (pat->alladdr, h->env->to, h->env->cc)));
+  case M_PERSONAL_FROM:
+    return (pat->
+            not ^ (h->env && match_user (pat->alladdr, h->env->from, NULL)));
+  case M_COLLAPSED:
+    return (pat->not ^ (h->collapsed && h->num_hidden > 1));
+  case M_CRYPT_SIGN:
+    if (!WithCrypto)
+      break;
+    return (pat->not ^ ((h->security & SIGN) ? 1 : 0));
+  case M_CRYPT_VERIFIED:
+    if (!WithCrypto)
+      break;
+    return (pat->not ^ ((h->security & GOODSIGN) ? 1 : 0));
+  case M_CRYPT_ENCRYPT:
+    if (!WithCrypto)
+      break;
+    return (pat->not ^ ((h->security & ENCRYPT) ? 1 : 0));
+  case M_PGP_KEY:
+    if (!(WithCrypto & APPLICATION_PGP))
+      break;
+    return (pat->not ^ ((h->security & APPLICATION_PGP)
+                        && (h->security & PGPKEY)));
+  case M_XLABEL:
+    return (pat->
+            not ^ (h->env->x_label
+                   && regexec (pat->rx, h->env->x_label, 0, NULL, 0) == 0));
+  case M_HORMEL:
+    return (pat->
+            not ^ (h->env->spam && h->env->spam->data
+                   && regexec (pat->rx, h->env->spam->data, 0, NULL,
+                               0) == 0));
+  case M_DUPLICATED:
+    return (pat->not ^ (h->thread && h->thread->duplicate_thread));
+  case M_UNREFERENCED:
+    return (pat->not ^ (h->thread && !h->thread->child));
+  case M_REALNAME:
+    /* realname filter:
+     * we have a match if
+     * - From: matches $alternates
+     * - or we have an alias for current address
+     * - or From: contains valid email address _and_ name has >= 2 fields
+     */
+    return (pat->
+            not ^ (h->env && h->env->from && (mutt_addr_is_user (h->env->from)
+                                              ||
+                                              (alias_reverse_lookup
+                                               (h->env->from) != NULL)
+                                              || (h->env->from->personal
+                                                  && valid_realname (h->env->
+                                                                     from->
+                                                                     personal)
+                                                  && h->env->from->mailbox)
+                   )));
 #ifdef USE_NNTP
-    case M_NEWSGROUPS:
-      return (pat->not ^ (h->env->newsgroups && regexec (pat->rx, h->env->newsgroups, 0, NULL, 0) == 0));
+  case M_NEWSGROUPS:
+    return (pat->
+            not ^ (h->env->newsgroups
+                   && regexec (pat->rx, h->env->newsgroups, 0, NULL,
+                               0) == 0));
 #endif
   }
   mutt_error (_("error: unknown op %d (report this error)."), pat->op);
   return (-1);
 }
 
-static void quote_simple(char *tmp, size_t len, const char *p)
+static void quote_simple (char *tmp, size_t len, const char *p)
 {
   int i = 0;
-  
+
   tmp[i++] = '"';
-  while (*p && i < len - 3)
-  {
+  while (*p && i < len - 3) {
     if (*p == '\\' || *p == '"')
       tmp[i++] = '\\';
     tmp[i++] = *p++;
@@ -1115,7 +1091,7 @@ static void quote_simple(char *tmp, size_t len, const char *p)
   tmp[i++] = '"';
   tmp[i] = 0;
 }
-  
+
 /* convert a simple search into a real request */
 void mutt_check_simple (char *s, size_t len, const char *simple)
 {
@@ -1124,12 +1100,10 @@ void mutt_check_simple (char *s, size_t len, const char *simple)
   /* XXX - is ascii_strcasecmp() right here, or should we use locale's
    * equivalences?
    */
-  
-  if (!strchr (s, '~')) /* yup, so spoof a real request */
-  {
+
+  if (!strchr (s, '~')) {       /* yup, so spoof a real request */
     /* convert old tokens into the new format */
-    if (ascii_strcasecmp ("all", s) == 0 ||
-       !mutt_strcmp ("^", s) || !mutt_strcmp (".", s)) /* ~A is more efficient */
+    if (ascii_strcasecmp ("all", s) == 0 || !mutt_strcmp ("^", s) || !mutt_strcmp (".", s))     /* ~A is more efficient */
       strfcpy (s, "~A", len);
     else if (ascii_strcasecmp ("del", s) == 0)
       strfcpy (s, "~D", len);
@@ -1147,9 +1121,8 @@ void mutt_check_simple (char *s, size_t len, const char *simple)
       strfcpy (s, "~T", len);
     else if (ascii_strcasecmp ("unread", s) == 0)
       strfcpy (s, "~U", len);
-    else
-    {
-      quote_simple (tmp, sizeof(tmp), s);
+    else {
+      quote_simple (tmp, sizeof (tmp), s);
       mutt_expand_fmt (s, len, simple, tmp);
     }
   }
@@ -1164,18 +1137,18 @@ int mutt_pattern_func (int op, char *prompt)
 
   strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
   if (prompt || op != M_LIMIT)
-  if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
-    return (-1);
+    if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0
+        || !buf[0])
+      return (-1);
 
   mutt_message _("Compiling search pattern...");
-  
+
   simple = safe_strdup (buf);
   mutt_check_simple (buf, sizeof (buf), NONULL (SimpleSearch));
 
   err.data = error;
   err.dsize = sizeof (error);
-  if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL)
-  {
+  if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL) {
     FREE (&simple);
     mutt_error ("%s", err.data);
     return (-1);
@@ -1185,51 +1158,47 @@ int mutt_pattern_func (int op, char *prompt)
 
 #define THIS_BODY Context->hdrs[i]->content
 
-  if (op == M_LIMIT)
-  {
-    Context->vcount    = 0;
-    Context->vsize     = 0;
+  if (op == M_LIMIT) {
+    Context->vcount = 0;
+    Context->vsize = 0;
     Context->collapsed = 0;
 
-    for (i = 0; i < Context->msgcount; i++)
-    {
+    for (i = 0; i < Context->msgcount; i++) {
       /* new limit pattern implicitly uncollapses all threads */
       Context->hdrs[i]->virtual = -1;
       Context->hdrs[i]->limited = 0;
       Context->hdrs[i]->collapsed = 0;
       Context->hdrs[i]->num_hidden = 0;
-      if (mutt_pattern_exec (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[i]))
-      {
-       Context->hdrs[i]->virtual = Context->vcount;
-       Context->hdrs[i]->limited = 1;
-       Context->v2r[Context->vcount] = i;
-       Context->vcount++;
-       Context->vsize+=THIS_BODY->length + THIS_BODY->offset -
-         THIS_BODY->hdr_offset;
+      if (mutt_pattern_exec
+          (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[i])) {
+        Context->hdrs[i]->virtual = Context->vcount;
+        Context->hdrs[i]->limited = 1;
+        Context->v2r[Context->vcount] = i;
+        Context->vcount++;
+        Context->vsize += THIS_BODY->length + THIS_BODY->offset -
+          THIS_BODY->hdr_offset;
       }
     }
   }
-  else
-  {
-    for (i = 0; i < Context->vcount; i++)
-    {
-      if (mutt_pattern_exec (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[Context->v2r[i]]))
-      {
-       switch (op)
-       {
-         case M_UNDELETE:
-           mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED,
-                          0);
-         case M_DELETE:
-           mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 
-                         (op == M_DELETE));
-           break;
-         case M_TAG:
-         case M_UNTAG:
-           mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_TAG, 
-                          (op == M_TAG));
-           break;
-       }
+  else {
+    for (i = 0; i < Context->vcount; i++) {
+      if (mutt_pattern_exec
+          (pat, M_MATCH_FULL_ADDRESS, Context,
+           Context->hdrs[Context->v2r[i]])) {
+        switch (op) {
+        case M_UNDELETE:
+          mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED,
+                         0);
+        case M_DELETE:
+          mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE,
+                         (op == M_DELETE));
+          break;
+        case M_TAG:
+        case M_UNTAG:
+          mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_TAG,
+                         (op == M_TAG));
+          break;
+        }
       }
     }
   }
@@ -1238,28 +1207,25 @@ int mutt_pattern_func (int op, char *prompt)
 
   mutt_clear_error ();
 
-  if (op == M_LIMIT)
-  {
+  if (op == M_LIMIT) {
     FREE (&Context->pattern);
-    if (Context->limit_pattern) 
+    if (Context->limit_pattern)
       mutt_pattern_free (&Context->limit_pattern);
-    if (!Context->vcount)
-    {
+    if (!Context->vcount) {
       mutt_error _("No messages matched criteria.");
+
 #if 0
       Context->vcount = Context->msgcount;
       /* restore full display */
-      for (i = 0; i < Context->msgcount; i++)
-      {
-       Context->hdrs[i]->virtual = i;
-       Context->v2r[i] = i;
+      for (i = 0; i < Context->msgcount; i++) {
+        Context->hdrs[i]->virtual = i;
+        Context->v2r[i] = i;
       }
 #endif
     }
-    else if (mutt_strncmp (buf, "~A", 2) != 0)
-    {
+    else if (mutt_strncmp (buf, "~A", 2) != 0) {
       Context->pattern = simple;
-      simple = NULL; /* don't clobber it */
+      simple = NULL;            /* don't clobber it */
       Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err);
     }
   }
@@ -1277,13 +1243,12 @@ int mutt_search_command (int cur, int op)
   BUFFER err;
   int incr;
   HEADER *h;
-  
-  if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
-  {
+
+  if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE) {
     strfcpy (buf, LastSearch, sizeof (buf));
     if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
-                     _("Reverse search for: "), buf, sizeof (buf),
-                     M_CLEAR | M_PATTERN) != 0 || !buf[0])
+                        _("Reverse search for: "), buf, sizeof (buf),
+                        M_CLEAR | M_PATTERN) != 0 || !buf[0])
       return (-1);
 
     if (op == OP_SEARCH)
@@ -1296,30 +1261,29 @@ int mutt_search_command (int cur, int op)
     strfcpy (temp, buf, sizeof (temp));
     mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch));
 
-    if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn))
-    {
+    if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn)) {
       set_option (OPTSEARCHINVALID);
       strfcpy (LastSearch, buf, sizeof (LastSearch));
       mutt_message _("Compiling search pattern...");
+
       mutt_pattern_free (&SearchPattern);
       err.data = error;
       err.dsize = sizeof (error);
-      if ((SearchPattern = mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL)
-      {
-       mutt_error ("%s", error);
-       return (-1);
+      if ((SearchPattern =
+           mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL) {
+        mutt_error ("%s", error);
+        return (-1);
       }
       mutt_clear_error ();
     }
   }
-  else if (!SearchPattern)
-  {
+  else if (!SearchPattern) {
     mutt_error _("No search pattern.");
+
     return (-1);
   }
 
-  if (option (OPTSEARCHINVALID))
-  {
+  if (option (OPTSEARCHINVALID)) {
     for (i = 0; i < Context->msgcount; i++)
       Context->hdrs[i]->searched = 0;
     unset_option (OPTSEARCHINVALID);
@@ -1329,49 +1293,48 @@ int mutt_search_command (int cur, int op)
   if (op == OP_SEARCH_OPPOSITE)
     incr = -incr;
 
-  for (i = cur + incr, j = 0 ; j != Context->vcount; j++)
-  {
-    if (i > Context->vcount - 1)
-    {
+  for (i = cur + incr, j = 0; j != Context->vcount; j++) {
+    if (i > Context->vcount - 1) {
       i = 0;
       if (option (OPTWRAPSEARCH))
-        mutt_message _("Search wrapped to top.");
-      else 
-      {
+        mutt_message (_("Search wrapped to top."));
+
+      else {
         mutt_message _("Search hit bottom without finding match");
-       return (-1);
+
+        return (-1);
       }
     }
-    else if (i < 0)
-    {
+    else if (i < 0) {
       i = Context->vcount - 1;
       if (option (OPTWRAPSEARCH))
-        mutt_message _("Search wrapped to bottom.");
-      else 
-      {
+        mutt_message (_("Search wrapped to bottom."));
+
+      else {
         mutt_message _("Search hit top without finding match");
-       return (-1);
+
+        return (-1);
       }
     }
 
     h = Context->hdrs[Context->v2r[i]];
-    if (h->searched)
-    {
+    if (h->searched) {
       /* if we've already evaulated this message, use the cached value */
       if (h->matched)
-       return i;
+        return i;
     }
-    else
-    {
+    else {
       /* remember that we've already searched this message */
       h->searched = 1;
-      if ((h->matched = (mutt_pattern_exec (SearchPattern, M_MATCH_FULL_ADDRESS, Context, h) > 0)))
-       return i;
+      if ((h->matched =
+           (mutt_pattern_exec
+            (SearchPattern, M_MATCH_FULL_ADDRESS, Context, h) > 0)))
+        return i;
     }
 
-    if (SigInt)
-    {
+    if (SigInt) {
       mutt_error _("Search interrupted.");
+
       SigInt = 0;
       return (-1);
     }
@@ -1380,5 +1343,6 @@ int mutt_search_command (int cur, int op)
   }
 
   mutt_error _("Not found.");
+
   return (-1);
 }
diff --git a/pgp.c b/pgp.c
index 929f489..c0c96c7 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -16,7 +16,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * This file contains all of the PGP routines necessary to sign, encrypt,
@@ -63,7 +63,7 @@
 
 
 char PgpPass[STRING];
-time_t PgpExptime = 0; /* when does the cached passphrase expire? */
+time_t PgpExptime = 0;          /* when does the cached passphrase expire? */
 
 void pgp_void_passphrase (void)
 {
@@ -75,23 +75,22 @@ int pgp_valid_passphrase (void)
 {
   time_t now = time (NULL);
 
-  if (pgp_use_gpg_agent())
-    {
-      *PgpPass = 0;
-      return 1; /* handled by gpg-agent */
-    }
+  if (pgp_use_gpg_agent ()) {
+    *PgpPass = 0;
+    return 1;                   /* handled by gpg-agent */
+  }
 
   if (now < PgpExptime)
     /* Use cached copy.  */
     return 1;
-  
+
   pgp_void_passphrase ();
 
-  if (mutt_get_password (_("Enter PGP passphrase:"), PgpPass, sizeof (PgpPass)) == 0)
-    {
-      PgpExptime = time (NULL) + PgpTimeout;
-      return (1);
-    }
+  if (mutt_get_password
+      (_("Enter PGP passphrase:"), PgpPass, sizeof (PgpPass)) == 0) {
+    PgpExptime = time (NULL) + PgpTimeout;
+    return (1);
+  }
   else
     PgpExptime = 0;
 
@@ -106,20 +105,21 @@ void pgp_forget_passphrase (void)
 
 int pgp_use_gpg_agent (void)
 {
-  return option (OPTUSEGPGAGENT) && getenv ("GPG_TTY") && getenv ("GPG_AGENT_INFO");
+  return option (OPTUSEGPGAGENT) && getenv ("GPG_TTY")
+    && getenv ("GPG_AGENT_INFO");
 }
 
-char *pgp_keyid(pgp_key_t k)
+char *pgp_keyid (pgp_key_t k)
 {
-  if((k->flags & KEYFLAG_SUBKEY) && k->parent && option(OPTPGPIGNORESUB))
+  if ((k->flags & KEYFLAG_SUBKEY) && k->parent && option (OPTPGPIGNORESUB))
     k = k->parent;
 
-  return _pgp_keyid(k);
+  return _pgp_keyid (k);
 }
 
-char *_pgp_keyid(pgp_key_t k)
+char *_pgp_keyid (pgp_key_t k)
 {
-  if(option(OPTPGPLONGIDS))
+  if (option (OPTPGPLONGIDS))
     return k->keyid;
   else
     return (k->keyid + 8);
@@ -133,37 +133,34 @@ char *_pgp_keyid(pgp_key_t k)
 
 /* Copy PGP output messages and look for signs of a good signature */
 
-static int pgp_copy_checksig (FILE *fpin, FILE *fpout)
+static int pgp_copy_checksig (FILE * fpin, FILE * fpout)
 {
   int rv = -1;
 
-  if (PgpGoodSign.pattern)
-  {
+  if (PgpGoodSign.pattern) {
     char *line = NULL;
     int lineno = 0;
     size_t linelen;
-    
-    while ((line = mutt_read_line (line, &linelen, fpin, &lineno)) != NULL)
-    {
-      if (regexec (PgpGoodSign.rx, line, 0, NULL, 0) == 0)
-      {
-       dprint (2, (debugfile, "pgp_copy_checksig: \"%s\" matches regexp.\n",
-                   line));
-       rv = 0;
+
+    while ((line = mutt_read_line (line, &linelen, fpin, &lineno)) != NULL) {
+      if (regexec (PgpGoodSign.rx, line, 0, NULL, 0) == 0) {
+        dprint (2, (debugfile, "pgp_copy_checksig: \"%s\" matches regexp.\n",
+                    line));
+        rv = 0;
       }
       else
-       dprint (2, (debugfile, "pgp_copy_checksig: \"%s\" doesn't match regexp.\n",
-                   line));
-      
+        dprint (2,
+                (debugfile,
+                 "pgp_copy_checksig: \"%s\" doesn't match regexp.\n", line));
+
       if (strncmp (line, "[GNUPG:] ", 9) == 0)
-       continue;
+        continue;
       fputs (line, fpout);
       fputc ('\n', fpout);
     }
     FREE (&line);
   }
-  else
-  {
+  else {
     dprint (2, (debugfile, "pgp_copy_checksig: No pattern.\n"));
     mutt_copy_stream (fpin, fpout);
     rv = 1;
@@ -185,55 +182,53 @@ static int pgp_copy_checksig (FILE *fpin, FILE *fpout)
  * existing versions of mutt.) 
  */
 
-static void pgp_copy_clearsigned (FILE *fpin, STATE *s, char *charset)
+static void pgp_copy_clearsigned (FILE * fpin, STATE * s, char *charset)
 {
   char buf[HUGE_STRING];
   short complete, armor_header;
-  
+
   FGETCONV *fc;
-  
+
   rewind (fpin);
-  
+
   fc = fgetconv_open (fpin, charset, Charset, M_ICONV_HOOK_FROM);
-  
+
   for (complete = 1, armor_header = 1;
        fgetconvs (buf, sizeof (buf), fc) != NULL;
-       complete = strchr (buf, '\n') != NULL)
-  {
-    if (!complete)
-    {
+       complete = strchr (buf, '\n') != NULL) {
+    if (!complete) {
       if (!armor_header)
-       state_puts (buf, s);
+        state_puts (buf, s);
       continue;
     }
 
     if (mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
       break;
-    
-    if (armor_header)
-    {
+
+    if (armor_header) {
       char *p = mutt_skip_whitespace (buf);
-      if (*p == '\0') 
-       armor_header = 0;
+
+      if (*p == '\0')
+        armor_header = 0;
       continue;
     }
-    
-    if (s->prefix) 
+
+    if (s->prefix)
       state_puts (s->prefix, s);
-    
+
     if (buf[0] == '-' && buf[1] == ' ')
       state_puts (buf + 2, s);
     else
       state_puts (buf, s);
   }
-  
+
   fgetconv_close (&fc);
 }
 
 
 /* Support for the Application/PGP Content Type. */
 
-void pgp_application_pgp_handler (BODY *m, STATE *s)
+void pgp_application_pgp_handler (BODY * m, STATE * s)
 {
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0, rv, rc;
@@ -250,137 +245,132 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
   short have_any_sigs = 0;
 
   char body_charset[STRING];
+
   mutt_get_body_charset (body_charset, sizeof (body_charset), m);
 
-  rc = 0;      /* silence false compiler warning if (s->flags & M_DISPLAY) */
+  rc = 0;                       /* silence false compiler warning if (s->flags & M_DISPLAY) */
 
   fseek (s->fpin, m->offset, 0);
   last_pos = m->offset;
-  
-  for (bytes = m->length; bytes > 0;)
-  {
+
+  for (bytes = m->length; bytes > 0;) {
     if (fgets (buf, sizeof (buf), s->fpin) == NULL)
       break;
-    
+
     offset = ftell (s->fpin);
-    bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
+    bytes -= (offset - last_pos);       /* don't rely on mutt_strlen(buf) */
     last_pos = offset;
-    
-    if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
-    {
+
+    if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0) {
       clearsign = 0;
       start_pos = last_pos;
 
       if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
         needpass = 1;
-      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
-      {
-       clearsign = 1;
+      else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0) {
+        clearsign = 1;
         needpass = 0;
       }
       else if (!option (OPTDONTHANDLEPGPKEYS) &&
-              mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
-      {
+               mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) {
         needpass = 0;
-        pgp_keyblock =1;
-      } 
-      else
-      {
-       /* XXX - we may wish to recode here */
-       if (s->prefix)
-         state_puts (s->prefix, s);
-       state_puts (buf, s);
-       continue;
+        pgp_keyblock = 1;
+      }
+      else {
+        /* XXX - we may wish to recode here */
+        if (s->prefix)
+          state_puts (s->prefix, s);
+        state_puts (buf, s);
+        continue;
       }
 
       have_any_sigs = have_any_sigs || (clearsign && (s->flags & M_VERIFY));
 
       /* Copy PGP material to temporary file */
       mutt_mktemp (tmpfname);
-      if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL)
-      {
-       mutt_perror (tmpfname);
-       return;
+      if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL) {
+        mutt_perror (tmpfname);
+        return;
       }
-      
+
       fputs (buf, tmpfp);
-      while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL)
-      {
-       offset = ftell (s->fpin);
-       bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
-       last_pos = offset;
-       
-       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)))
-         break;
+      while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) {
+        offset = ftell (s->fpin);
+        bytes -= (offset - last_pos);   /* don't rely on mutt_strlen(buf) */
+        last_pos = offset;
+
+        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)))
+          break;
       }
 
       /* leave tmpfp open in case we still need it - but flush it! */
       fflush (tmpfp);
-      
-      
+
+
       /* Invoke PGP if needed */
-      if (!clearsign || (s->flags & M_VERIFY))
-      {
-       mutt_mktemp (outfile);
-       if ((pgpout = safe_fopen (outfile, "w+")) == NULL)
-       {
-         mutt_perror (tmpfname);
-         return;
-       }
-       
-       if ((thepid = pgp_invoke_decode (&pgpin, NULL, &pgperr, -1,
-                                        fileno (pgpout), -1, tmpfname,
-                                        needpass)) == -1)
-       {
-         safe_fclose (&pgpout);
-         maybe_goodsig = 0;
-         pgpin = NULL;
-         pgperr = NULL;
-         state_attach_puts (_("[-- Error: unable to create PGP subprocess! --]\n"), s);
-       }
-       else /* PGP started successfully */
-       {
-         if (needpass)
-         {
-           if (!pgp_valid_passphrase ()) pgp_void_passphrase();
-            if (pgp_use_gpg_agent())
+      if (!clearsign || (s->flags & M_VERIFY)) {
+        mutt_mktemp (outfile);
+        if ((pgpout = safe_fopen (outfile, "w+")) == NULL) {
+          mutt_perror (tmpfname);
+          return;
+        }
+
+        if ((thepid = pgp_invoke_decode (&pgpin, NULL, &pgperr, -1,
+                                         fileno (pgpout), -1, tmpfname,
+                                         needpass)) == -1) {
+          safe_fclose (&pgpout);
+          maybe_goodsig = 0;
+          pgpin = NULL;
+          pgperr = NULL;
+          state_attach_puts (_
+                             ("[-- Error: unable to create PGP subprocess! --]\n"),
+                             s);
+        }
+        else {                  /* PGP started successfully */
+
+          if (needpass) {
+            if (!pgp_valid_passphrase ())
+              pgp_void_passphrase ();
+            if (pgp_use_gpg_agent ())
               *PgpPass = 0;
-           fprintf (pgpin, "%s\n", PgpPass);
-         }
-         
-         safe_fclose (&pgpin);
-
-         if (s->flags & M_DISPLAY)
-         {
-           crypt_current_time (s, "PGP");
-           rc = pgp_copy_checksig (pgperr, s->fpout);
-         }
-         
-         safe_fclose (&pgperr);
-         rv = mutt_wait_filter (thepid);
-         
-         if (s->flags & M_DISPLAY)
-         {
-           if (rc == 0) have_any_sigs = 1;
+            fprintf (pgpin, "%s\n", PgpPass);
+          }
+
+          safe_fclose (&pgpin);
+
+          if (s->flags & M_DISPLAY) {
+            crypt_current_time (s, "PGP");
+            rc = pgp_copy_checksig (pgperr, s->fpout);
+          }
+
+          safe_fclose (&pgperr);
+          rv = mutt_wait_filter (thepid);
+
+          if (s->flags & M_DISPLAY) {
+            if (rc == 0)
+              have_any_sigs = 1;
 /*
  * Sig is bad if
  * gpg_good_sign-pattern did not match || pgp_decode_command returned not 0
  * Sig _is_ correct if
  *  gpg_good_sign="" && pgp_decode_command returned 0
  */
-           if (rc == -1 || rv) maybe_goodsig = 0;
+            if (rc == -1 || rv)
+              maybe_goodsig = 0;
 
-           state_putc ('\n', s);
-           state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
-         }
-       }
+            state_putc ('\n', s);
+            state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
+          }
+        }
       }
-      
+
 
       /*
        * Now, copy cleartext to the screen.  NOTE - we expect that PGP
@@ -388,84 +378,80 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
        * seems to be a reasonable guess.
        */
 
-      if(s->flags & M_DISPLAY)
-      {
-       if (needpass)
-         state_attach_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
-       else if (pgp_keyblock)
-         state_attach_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"), s);
-       else
-         state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
+      if (s->flags & M_DISPLAY) {
+        if (needpass)
+          state_attach_puts (_("[-- BEGIN PGP MESSAGE --]\n\n"), s);
+        else if (pgp_keyblock)
+          state_attach_puts (_("[-- BEGIN PGP PUBLIC KEY BLOCK --]\n"), s);
+        else
+          state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
       }
 
-      if (clearsign)
-      {
-       rewind (tmpfp);
-       if (tmpfp) 
-         pgp_copy_clearsigned (tmpfp, s, body_charset);
+      if (clearsign) {
+        rewind (tmpfp);
+        if (tmpfp)
+          pgp_copy_clearsigned (tmpfp, s, body_charset);
       }
-      else if (pgpout)
-      {
-       FGETCONV *fc;
-       int c;
-       rewind (pgpout);
-       state_set_prefix (s);
-       fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
-       while ((c = fgetconv (fc)) != EOF)
-         state_prefix_putc (c, s);
-       fgetconv_close (&fc);
+      else if (pgpout) {
+        FGETCONV *fc;
+        int c;
+
+        rewind (pgpout);
+        state_set_prefix (s);
+        fc = fgetconv_open (pgpout, "utf-8", Charset, 0);
+        while ((c = fgetconv (fc)) != EOF)
+          state_prefix_putc (c, s);
+        fgetconv_close (&fc);
       }
 
-      if (s->flags & M_DISPLAY)
-      {
-       state_putc ('\n', s);
-       if (needpass)
-         state_attach_puts (_("[-- END PGP MESSAGE --]\n"), s);
-       else if (pgp_keyblock)
-         state_attach_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
-       else
-         state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
+      if (s->flags & M_DISPLAY) {
+        state_putc ('\n', s);
+        if (needpass)
+          state_attach_puts (_("[-- END PGP MESSAGE --]\n"), s);
+        else if (pgp_keyblock)
+          state_attach_puts (_("[-- END PGP PUBLIC KEY BLOCK --]\n"), s);
+        else
+          state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
       }
 
-      if (tmpfp)
-      {
-       safe_fclose (&tmpfp);
-       mutt_unlink (tmpfname);
+      if (tmpfp) {
+        safe_fclose (&tmpfp);
+        mutt_unlink (tmpfname);
       }
-      if (pgpout)
-      {
-       safe_fclose (&pgpout);
-       mutt_unlink (outfile);
+      if (pgpout) {
+        safe_fclose (&pgpout);
+        mutt_unlink (outfile);
       }
     }
-    else
-    {
+    else {
       /* XXX - we may wish to recode here */
       if (s->prefix)
-       state_puts (s->prefix, s);
+        state_puts (s->prefix, s);
       state_puts (buf, s);
     }
   }
 
   m->goodsig = (maybe_goodsig && have_any_sigs);
 
-  if (needpass == -1)
-  {
-    state_attach_puts (_("[-- Error: could not find beginning of PGP message! --]\n\n"), s);
+  if (needpass == -1) {
+    state_attach_puts (_
+                       ("[-- Error: could not find beginning of PGP message! --]\n\n"),
+                       s);
     return;
   }
 }
 
-static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
+static int pgp_check_traditional_one_body (FILE * fp, BODY * b,
+                                           int tagged_only)
 {
   char tempfile[_POSIX_PATH_MAX];
   char buf[HUGE_STRING];
   FILE *tfp;
-  
+
   short sgn = 0;
   short enc = 0;
   short key = 0;
-  
+
   if (b->type != TYPETEXT)
     return 0;
 
@@ -473,28 +459,24 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     return 0;
 
   mutt_mktemp (tempfile);
-  if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0)
-  {
+  if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0) {
     unlink (tempfile);
     return 0;
   }
-  
-  if ((tfp = fopen (tempfile, "r")) == NULL)
-  {
+
+  if ((tfp = fopen (tempfile, "r")) == NULL) {
     unlink (tempfile);
     return 0;
   }
-  
-  while (fgets (buf, sizeof (buf), tfp))
-  {
-    if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0)
-    {
+
+  while (fgets (buf, sizeof (buf), tfp)) {
+    if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0) {
       if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0)
-       enc = 1;
+        enc = 1;
       else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0)
-       sgn = 1;
+        sgn = 1;
       else if (mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
-       key = 1;
+        key = 1;
     }
   }
   safe_fclose (&tfp);
@@ -504,7 +486,7 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     return 0;
 
   /* fix the content type */
-  
+
   mutt_set_parameter ("format", "fixed", &b->parameter);
   if (enc)
     mutt_set_parameter ("x-action", "pgp-encrypted", &b->parameter);
@@ -512,83 +494,81 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
     mutt_set_parameter ("x-action", "pgp-signed", &b->parameter);
   else if (key)
     mutt_set_parameter ("x-action", "pgp-keys", &b->parameter);
-  
+
   return 1;
 }
 
-int pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+int pgp_check_traditional (FILE * fp, BODY * b, int tagged_only)
 {
   int rv = 0;
   int r;
-  for (; b; b = b->next)
-  {
+
+  for (; b; b = b->next) {
     if (is_multipart (b))
       rv = pgp_check_traditional (fp, b->parts, tagged_only) || rv;
-    else if (b->type == TYPETEXT)
-    {
+    else if (b->type == TYPETEXT) {
       if ((r = mutt_is_application_pgp (b)))
-       rv = rv || r;
+        rv = rv || r;
       else
-       rv = pgp_check_traditional_one_body (fp, b, tagged_only) || rv;
+        rv = pgp_check_traditional_one_body (fp, b, tagged_only) || rv;
     }
   }
 
   return rv;
 }
 
-     
 
 
 
-int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
+
+int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile)
 {
   char sigfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
   FILE *fp, *pgpout, *pgperr;
   pid_t thepid;
   int badsig = -1;
   int rv;
-  
+
   snprintf (sigfile, sizeof (sigfile), "%s.asc", tempfile);
-  
-  if(!(fp = safe_fopen (sigfile, "w")))
-  {
-    mutt_perror(sigfile);
+
+  if (!(fp = safe_fopen (sigfile, "w"))) {
+    mutt_perror (sigfile);
     return -1;
   }
-       
+
   fseek (s->fpin, sigbdy->offset, 0);
   mutt_copy_bytes (s->fpin, fp, sigbdy->length);
   fclose (fp);
-  
-  mutt_mktemp(pgperrfile);
-  if(!(pgperr = safe_fopen(pgperrfile, "w+")))
-  {
-    mutt_perror(pgperrfile);
-    unlink(sigfile);
+
+  mutt_mktemp (pgperrfile);
+  if (!(pgperr = safe_fopen (pgperrfile, "w+"))) {
+    mutt_perror (pgperrfile);
+    unlink (sigfile);
     return -1;
   }
-  
+
   crypt_current_time (s, "PGP");
-  
-  if((thepid = pgp_invoke_verify (NULL, &pgpout, NULL, 
-                                  -1, -1, fileno(pgperr),
-                                  tempfile, sigfile)) != -1)
-  {
+
+  if ((thepid = pgp_invoke_verify (NULL, &pgpout, NULL,
+                                   -1, -1, fileno (pgperr),
+                                   tempfile, sigfile)) != -1) {
     if (pgp_copy_checksig (pgpout, s->fpout) >= 0)
       badsig = 0;
-    
-    
+
+
     safe_fclose (&pgpout);
     fflush (pgperr);
     rewind (pgperr);
-    
-    if (pgp_copy_checksig  (pgperr, s->fpout) >= 0)
+
+    if (pgp_copy_checksig (pgperr, s->fpout) >= 0)
       badsig = 0;
 
     if ((rv = mutt_wait_filter (thepid)))
       badsig = -1;
-    
-     dprint (1, (debugfile, "pgp_verify_one: mutt_wait_filter returned %d.\n", rv));
+
+    dprint (1,
+            (debugfile, "pgp_verify_one: mutt_wait_filter returned %d.\n",
+             rv));
   }
 
   safe_fclose (&pgperr);
@@ -599,94 +579,85 @@ int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
   mutt_unlink (pgperrfile);
 
   dprint (1, (debugfile, "pgp_verify_one: returning %d.\n", badsig));
-  
+
   return badsig;
 }
 
 
 /* Extract pgp public keys from messages or attachments */
 
-void pgp_extract_keys_from_messages (HEADER *h)
+void pgp_extract_keys_from_messages (HEADER * h)
 {
   int i;
   char tempfname[_POSIX_PATH_MAX];
   FILE *fpout;
 
-  if (h)
-  {
+  if (h) {
     mutt_parse_mime_message (Context, h);
-    if(h->security & PGPENCRYPT && !pgp_valid_passphrase ())
+    if (h->security & PGPENCRYPT && !pgp_valid_passphrase ())
       return;
   }
 
   mutt_mktemp (tempfname);
-  if (!(fpout = safe_fopen (tempfname, "w")))
-  {
+  if (!(fpout = safe_fopen (tempfname, "w"))) {
     mutt_perror (tempfname);
     return;
   }
 
   set_option (OPTDONTHANDLEPGPKEYS);
-  
-  if (!h)
-  {
-    for (i = 0; i < Context->vcount; i++)
-    {
-      if (Context->hdrs[Context->v2r[i]]->tagged)
-      {
-       mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
-       if (Context->hdrs[Context->v2r[i]]->security & PGPENCRYPT
-          && !pgp_valid_passphrase())
-       {
-         fclose (fpout);
-         goto bailout;
-       }
-       mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], 
-                          M_CM_DECODE|M_CM_CHARCONV, 0);
+
+  if (!h) {
+    for (i = 0; i < Context->vcount; i++) {
+      if (Context->hdrs[Context->v2r[i]]->tagged) {
+        mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
+        if (Context->hdrs[Context->v2r[i]]->security & PGPENCRYPT
+            && !pgp_valid_passphrase ()) {
+          fclose (fpout);
+          goto bailout;
+        }
+        mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
+                           M_CM_DECODE | M_CM_CHARCONV, 0);
       }
     }
-  } 
-  else
-  {
+  }
+  else {
     mutt_parse_mime_message (Context, h);
-    if (h->security & PGPENCRYPT && !pgp_valid_passphrase())
-    {
+    if (h->security & PGPENCRYPT && !pgp_valid_passphrase ()) {
       fclose (fpout);
       goto bailout;
     }
-    mutt_copy_message (fpout, Context, h, M_CM_DECODE|M_CM_CHARCONV, 0);
+    mutt_copy_message (fpout, Context, h, M_CM_DECODE | M_CM_CHARCONV, 0);
   }
-      
+
   fclose (fpout);
   mutt_endwin (NULL);
   pgp_invoke_import (tempfname);
   mutt_any_key_to_continue (NULL);
 
-  bailout:
-  
+bailout:
+
   mutt_unlink (tempfname);
   unset_option (OPTDONTHANDLEPGPKEYS);
-  
+
 }
 
-static void pgp_extract_keys_from_attachment (FILE *fp, BODY *top)
+static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top)
 {
   STATE s;
   FILE *tempfp;
   char tempfname[_POSIX_PATH_MAX];
 
   mutt_mktemp (tempfname);
-  if (!(tempfp = safe_fopen (tempfname, "w")))
-  {
+  if (!(tempfp = safe_fopen (tempfname, "w"))) {
     mutt_perror (tempfname);
     return;
   }
 
   memset (&s, 0, sizeof (STATE));
-  
+
   s.fpin = fp;
   s.fpout = tempfp;
-  
+
   mutt_body_handler (top, &s);
 
   fclose (tempfp);
@@ -697,30 +668,29 @@ static void pgp_extract_keys_from_attachment (FILE *fp, BODY *top)
   mutt_unlink (tempfname);
 }
 
-void pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
+void pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top)
 {
-  if(!fp)
-  {
+  if (!fp) {
     mutt_error _("Internal error. Inform <roessler@does-not-exist.org>.");
+
     return;
   }
 
   mutt_endwin (NULL);
-  set_option(OPTDONTHANDLEPGPKEYS);
-  
-  for(; top; top = top->next)
-  {
-    if(!tag || top->tagged)
+  set_option (OPTDONTHANDLEPGPKEYS);
+
+  for (; top; top = top->next) {
+    if (!tag || top->tagged)
       pgp_extract_keys_from_attachment (fp, top);
-    
-    if(!tag)
+
+    if (!tag)
       break;
   }
-  
-  unset_option(OPTDONTHANDLEPGPKEYS);
+
+  unset_option (OPTDONTHANDLEPGPKEYS);
 }
 
-BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
+BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p)
 {
   char buf[LONG_STRING];
   FILE *pgpin, *pgpout, *pgperr, *pgptmp;
@@ -730,20 +700,18 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
   char pgperrfile[_POSIX_PATH_MAX];
   char pgptmpfile[_POSIX_PATH_MAX];
   pid_t thepid;
-  
+
   mutt_mktemp (pgperrfile);
-  if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL)
-  {
+  if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL) {
     mutt_perror (pgperrfile);
     return NULL;
   }
   unlink (pgperrfile);
 
   mutt_mktemp (pgptmpfile);
-  if((pgptmp = safe_fopen (pgptmpfile, "w")) == NULL)
-  {
+  if ((pgptmp = safe_fopen (pgptmpfile, "w")) == NULL) {
     mutt_perror (pgptmpfile);
-    fclose(pgperr);
+    fclose (pgperr);
     return NULL;
   }
 
@@ -756,40 +724,39 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
   fclose (pgptmp);
 
   if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1,
-                                   fileno (pgperr), pgptmpfile)) == -1)
-  {
+                                    fileno (pgperr), pgptmpfile)) == -1) {
     fclose (pgperr);
     unlink (pgptmpfile);
     if (s->flags & M_DISPLAY)
-      state_attach_puts (_("[-- Error: could not create a PGP subprocess! --]\n\n"), s);
+      state_attach_puts (_
+                         ("[-- Error: could not create a PGP subprocess! --]\n\n"),
+                         s);
     return (NULL);
   }
 
   /* send the PGP passphrase to the subprocess.  Never do this if the
      agent is active, because this might lead to a passphrase send as
      the message. */
-  if (!pgp_use_gpg_agent())
+  if (!pgp_use_gpg_agent ())
     fputs (PgpPass, pgpin);
   fputc ('\n', pgpin);
-  fclose(pgpin);
-  
+  fclose (pgpin);
+
   /* Read the output from PGP, and make sure to change CRLF to LF, otherwise
    * read_mime_header has a hard time parsing the message.
    */
-  while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL)
-  {
+  while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL) {
     len = mutt_strlen (buf);
     if (len > 1 && buf[len - 2] == '\r')
-      strcpy (buf + len - 2, "\n");    /* __STRCPY_CHECKED__ */
+      strcpy (buf + len - 2, "\n");     /* __STRCPY_CHECKED__ */
     fputs (buf, fpout);
   }
 
   fclose (pgpout);
   mutt_wait_filter (thepid);
-  mutt_unlink(pgptmpfile);
-  
-  if (s->flags & M_DISPLAY)
-  {
+  mutt_unlink (pgptmpfile);
+
+  if (s->flags & M_DISPLAY) {
     fflush (pgperr);
     rewind (pgperr);
     if (pgp_copy_checksig (pgperr, s->fpout) == 0 && p)
@@ -800,14 +767,13 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
 
   fflush (fpout);
   rewind (fpout);
-  
+
   if (fgetc (fpout) == EOF)
     return NULL;
 
   rewind (fpout);
-  
-  if ((tattach = mutt_read_mime_header (fpout, 0)) != NULL)
-  {
+
+  if ((tattach = mutt_read_mime_header (fpout, 0)) != NULL) {
     /*
      * Need to set the length of this body part.
      */
@@ -822,25 +788,24 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
   return (tattach);
 }
 
-int pgp_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
+int pgp_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
 {
   char tempfile[_POSIX_PATH_MAX];
   STATE s;
   BODY *p = b;
-  
-  if(!mutt_is_multipart_encrypted(b))
+
+  if (!mutt_is_multipart_encrypted (b))
     return -1;
 
-  if(!b->parts || !b->parts->next)
+  if (!b->parts || !b->parts->next)
     return -1;
-  
+
   b = b->parts->next;
-  
+
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
   mutt_mktemp (tempfile);
-  if ((*fpout = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((*fpout = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     return (-1);
   }
@@ -849,28 +814,28 @@ int pgp_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   *cur = pgp_decrypt_part (b, &s, *fpout, p);
 
   rewind (*fpout);
-  
+
   if (!*cur)
     return -1;
-  
+
   return (0);
 }
 
-void pgp_encrypted_handler (BODY *a, STATE *s)
+void pgp_encrypted_handler (BODY * a, STATE * s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout, *fpin;
   BODY *tattach;
   BODY *p = a;
-  
+
   a = a->parts;
-  if (!a || a->type != TYPEAPPLICATION || !a->subtype || 
+  if (!a || a->type != TYPEAPPLICATION || !a->subtype ||
       ascii_strcasecmp ("pgp-encrypted", a->subtype) != 0 ||
       !a->next || a->next->type != TYPEAPPLICATION || !a->next->subtype ||
-      ascii_strcasecmp ("octet-stream", a->next->subtype) != 0)
-  {
+      ascii_strcasecmp ("octet-stream", a->next->subtype) != 0) {
     if (s->flags & M_DISPLAY)
-      state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s);
+      state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"),
+                         s);
     return;
   }
 
@@ -880,19 +845,22 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
   a = a->next;
 
   mutt_mktemp (tempfile);
-  if ((fpout = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (tempfile, "w+")) == NULL) {
     if (s->flags & M_DISPLAY)
-      state_attach_puts (_("[-- Error: could not create temporary file! --]\n"), s);
+      state_attach_puts (_
+                         ("[-- Error: could not create temporary file! --]\n"),
+                         s);
     return;
   }
 
-  if (s->flags & M_DISPLAY) crypt_current_time (s, "PGP");
+  if (s->flags & M_DISPLAY)
+    crypt_current_time (s, "PGP");
 
-  if ((tattach = pgp_decrypt_part (a, s, fpout, p)) != NULL)
-  {
+  if ((tattach = pgp_decrypt_part (a, s, fpout, p)) != NULL) {
     if (s->flags & M_DISPLAY)
-      state_attach_puts (_("[-- The following data is PGP/MIME encrypted --]\n\n"), s);
+      state_attach_puts (_
+                         ("[-- The following data is PGP/MIME encrypted --]\n\n"),
+                         s);
 
     fpin = s->fpin;
     s->fpin = fpout;
@@ -905,12 +873,11 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
      * status.
      *
      */
-    
+
     if (mutt_is_multipart_signed (tattach) && !tattach->next)
       p->goodsig |= tattach->goodsig;
-    
-    if (s->flags & M_DISPLAY)
-    {
+
+    if (s->flags & M_DISPLAY) {
       state_puts ("\n", s);
       state_attach_puts (_("[-- End of PGP/MIME encrypted data --]\n"), s);
     }
@@ -919,7 +886,7 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
   }
 
   fclose (fpout);
-  mutt_unlink(tempfile);
+  mutt_unlink (tempfile);
 }
 
 /* ----------------------------------------------------------------------------
@@ -927,7 +894,7 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
  */
 
 
-BODY *pgp_sign_message (BODY *a)
+BODY *pgp_sign_message (BODY * a)
 {
   BODY *t;
   char buffer[LONG_STRING];
@@ -936,91 +903,84 @@ BODY *pgp_sign_message (BODY *a)
   int err = 0;
   int empty = 1;
   pid_t thepid;
-  
-  convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
+
+  convert_to_7bit (a);          /* Signed data _must_ be in 7-bit format. */
 
   mutt_mktemp (sigfile);
-  if ((fp = safe_fopen (sigfile, "w")) == NULL)
-  {
+  if ((fp = safe_fopen (sigfile, "w")) == NULL) {
     return (NULL);
   }
 
   mutt_mktemp (signedfile);
-  if ((sfp = safe_fopen(signedfile, "w")) == NULL)
-  {
-    mutt_perror(signedfile);
-    fclose(fp);
-    unlink(sigfile);
+  if ((sfp = safe_fopen (signedfile, "w")) == NULL) {
+    mutt_perror (signedfile);
+    fclose (fp);
+    unlink (sigfile);
     return NULL;
   }
-  
+
   mutt_write_mime_header (a, sfp);
   fputc ('\n', sfp);
   mutt_write_mime_body (a, sfp);
-  fclose(sfp);
-  
+  fclose (sfp);
+
   if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr,
-                                -1, -1, -1, signedfile)) == -1)
-  {
+                                 -1, -1, -1, signedfile)) == -1) {
     mutt_perror _("Can't open PGP subprocess!");
-    fclose(fp);
-    unlink(sigfile);
-    unlink(signedfile);
+
+    fclose (fp);
+    unlink (sigfile);
+    unlink (signedfile);
     return NULL;
   }
-  
-  if (!pgp_use_gpg_agent())
-     fputs(PgpPass, pgpin);
-  fputc('\n', pgpin);
-  fclose(pgpin);
-  
+
+  if (!pgp_use_gpg_agent ())
+    fputs (PgpPass, pgpin);
+  fputc ('\n', pgpin);
+  fclose (pgpin);
+
   /*
    * Read back the PGP signature.  Also, change MESSAGE=>SIGNATURE as
    * recommended for future releases of PGP.
    */
-  while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL)
-  {
+  while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL) {
     if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\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)
       fputs ("-----END PGP SIGNATURE-----\n", fp);
     else
       fputs (buffer, fp);
-    empty = 0; /* got some output, so we're ok */
+    empty = 0;                  /* got some output, so we're ok */
   }
 
   /* check for errors from PGP */
   err = 0;
-  while (fgets (buffer, sizeof (buffer) - 1, pgperr) != NULL)
-  {
+  while (fgets (buffer, sizeof (buffer) - 1, pgperr) != NULL) {
     err = 1;
     fputs (buffer, stdout);
   }
 
-  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
-    empty=1;
+  if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
+    empty = 1;
 
   fclose (pgperr);
   fclose (pgpout);
   unlink (signedfile);
-  
-  if (fclose (fp) != 0)
-  {
+
+  if (fclose (fp) != 0) {
     mutt_perror ("fclose");
     unlink (sigfile);
     return (NULL);
   }
 
-  if (err)
-  {
-    pgp_void_passphrase();
+  if (err) {
+    pgp_void_passphrase ();
     mutt_any_key_to_continue (NULL);
   }
 
-  if (empty)
-  {
+  if (empty) {
     unlink (sigfile);
-    return (NULL); /* fatal error while signing */
+    return (NULL);              /* fatal error while signing */
   }
 
   t = mutt_new_body ();
@@ -1045,7 +1005,7 @@ BODY *pgp_sign_message (BODY *a)
   t->use_disp = 0;
   t->disposition = DISPINLINE;
   t->encoding = ENC7BIT;
-  t->unlink = 1; /* ok to remove this file after sending. */
+  t->unlink = 1;                /* ok to remove this file after sending. */
 
   return (a);
 }
@@ -1060,14 +1020,14 @@ static short is_numerical_keyid (const char *s)
   while (*s)
     if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
       return 0;
-  
+
   return 1;
 }
 
 /* This routine attempts to find the keyids of the recipients of a message.
  * It returns NULL if any of the keys can not be found.
  */
-char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *pgp_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   char *keyID, *keylist = NULL, *t;
   size_t keylist_size = 0;
@@ -1080,16 +1040,21 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 
   const char *fqdn = mutt_fqdn (1);
 
-  for (i = 0; i < 3; i++) 
-  {
-    switch (i)
-    {
-      case 0: p = to; break;
-      case 1: p = cc; break;
-      case 2: p = bcc; break;
-      default: abort ();
+  for (i = 0; i < 3; i++) {
+    switch (i) {
+    case 0:
+      p = to;
+      break;
+    case 1:
+      p = cc;
+      break;
+    case 2:
+      p = bcc;
+      break;
+    default:
+      abort ();
     }
-    
+
     *last = rfc822_cpy_adr (p);
     while (*last)
       last = &((*last)->next);
@@ -1099,72 +1064,69 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
     rfc822_qualify (tmp, fqdn);
 
   tmp = mutt_remove_duplicates (tmp);
-  
-  for (p = tmp; p ; p = p->next)
-  {
+
+  for (p = tmp; p; p = p->next) {
     char buf[LONG_STRING];
 
     q = p;
     k_info = NULL;
 
-    if ((keyID = mutt_crypt_hook (p)) != NULL)
-    {
+    if ((keyID = mutt_crypt_hook (p)) != NULL) {
       int r;
-      snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
-      if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
-      {
-       if (is_numerical_keyid (keyID))
-       {
-         if (strncmp (keyID, "0x", 2) == 0)
-           keyID += 2;
-         goto bypass_selection;                /* you don't see this. */
-       }
-       
-       /* check for e-mail address */
-       if ((t = strchr (keyID, '@')) && 
-           (addr = rfc822_parse_adrlist (NULL, keyID)))
-       {
-         if (fqdn) rfc822_qualify (addr, fqdn);
-         q = addr;
-       }
-       else
-         k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
+
+      snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID,
+                p->mailbox);
+      if ((r = mutt_yesorno (buf, M_YES)) == M_YES) {
+        if (is_numerical_keyid (keyID)) {
+          if (strncmp (keyID, "0x", 2) == 0)
+            keyID += 2;
+          goto bypass_selection;        /* you don't see this. */
+        }
+
+        /* check for e-mail address */
+        if ((t = strchr (keyID, '@')) &&
+            (addr = rfc822_parse_adrlist (NULL, keyID))) {
+          if (fqdn)
+            rfc822_qualify (addr, fqdn);
+          q = addr;
+        }
+        else
+          k_info = pgp_getkeybystr (keyID, KEYFLAG_CANENCRYPT, PGP_PUBRING);
       }
-      else if (r == -1)
-      {
-       FREE (&keylist);
-       rfc822_free_address (&tmp);
-       rfc822_free_address (&addr);
-       return NULL;
+      else if (r == -1) {
+        FREE (&keylist);
+        rfc822_free_address (&tmp);
+        rfc822_free_address (&addr);
+        return NULL;
       }
     }
 
     if (k_info == NULL)
       pgp_invoke_getkeys (q);
 
-    if (k_info == NULL && (k_info = pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
-    {
+    if (k_info == NULL
+        && (k_info =
+            pgp_getkeybyaddr (q, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) {
       snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
 
       if ((key = pgp_ask_for_key (buf, q->mailbox,
-                                 KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL)
-      {
-       FREE (&keylist);
-       rfc822_free_address (&tmp);
-       rfc822_free_address (&addr);
-       return NULL;
+                                  KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) {
+        FREE (&keylist);
+        rfc822_free_address (&tmp);
+        rfc822_free_address (&addr);
+        return NULL;
       }
     }
     else
       key = k_info;
 
     keyID = pgp_keyid (key);
-    
+
   bypass_selection:
     keylist_size += mutt_strlen (keyID) + 4;
     safe_realloc (&keylist, keylist_size);
-    sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",        /* __SPRINTF_CHECKED__ */
-            keyID);
+    sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
+             keyID);
     keylist_used = mutt_strlen (keylist);
 
     pgp_free_key (&key);
@@ -1178,7 +1140,7 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 /* Warning: "a" is no longer freed in this routine, you need
  * to free it later.  This is necessary for $fcc_attach. */
 
-BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
+BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign)
 {
   char buf[LONG_STRING];
   char tempfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
@@ -1188,74 +1150,68 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   int err = 0;
   int empty = 0;
   pid_t thepid;
-  
+
   mutt_mktemp (tempfile);
-  if ((fpout = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     return (NULL);
   }
 
   mutt_mktemp (pgperrfile);
-  if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL)
-  {
+  if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL) {
     mutt_perror (pgperrfile);
-    unlink(tempfile);
-    fclose(fpout);
+    unlink (tempfile);
+    fclose (fpout);
     return NULL;
   }
   unlink (pgperrfile);
 
-  mutt_mktemp(pgpinfile);
-  if((fptmp = safe_fopen(pgpinfile, "w")) == NULL)
-  {
-    mutt_perror(pgpinfile);
-    unlink(tempfile);
-    fclose(fpout);
-    fclose(pgperr);
+  mutt_mktemp (pgpinfile);
+  if ((fptmp = safe_fopen (pgpinfile, "w")) == NULL) {
+    mutt_perror (pgpinfile);
+    unlink (tempfile);
+    fclose (fpout);
+    fclose (pgperr);
     return NULL;
   }
-  
+
   if (sign)
     convert_to_7bit (a);
-  
+
   mutt_write_mime_header (a, fptmp);
   fputc ('\n', fptmp);
   mutt_write_mime_body (a, fptmp);
-  fclose(fptmp);
-  
-  if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1, 
-                                   fileno (fpout), fileno (pgperr),
-                                   pgpinfile, keylist, sign)) == -1)
-  {
+  fclose (fptmp);
+
+  if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1,
+                                    fileno (fpout), fileno (pgperr),
+                                    pgpinfile, keylist, sign)) == -1) {
     fclose (pgperr);
-    unlink(pgpinfile);
+    unlink (pgpinfile);
     return (NULL);
   }
 
-  if (sign)
-  {
-    if (!pgp_use_gpg_agent())
-       fputs (PgpPass, pgpin);
+  if (sign) {
+    if (!pgp_use_gpg_agent ())
+      fputs (PgpPass, pgpin);
     fputc ('\n', pgpin);
   }
-  fclose(pgpin);
-  
-  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
-    empty=1;
+  fclose (pgpin);
+
+  if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
+    empty = 1;
+
+  unlink (pgpinfile);
 
-  unlink(pgpinfile);
-  
   fflush (fpout);
   rewind (fpout);
-  if(!empty)
+  if (!empty)
     empty = (fgetc (fpout) == EOF);
   fclose (fpout);
 
   fflush (pgperr);
   rewind (pgperr);
-  while (fgets (buf, sizeof (buf) - 1, pgperr) != NULL)
-  {
+  while (fgets (buf, sizeof (buf) - 1, pgperr) != NULL) {
     err = 1;
     fputs (buf, stdout);
   }
@@ -1265,8 +1221,7 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   if (err)
     mutt_any_key_to_continue (NULL);
 
-  if (empty)
-  {
+  if (empty) {
     /* fatal error while trying to encrypt message */
     unlink (tempfile);
     return (NULL);
@@ -1279,9 +1234,9 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   t->use_disp = 0;
   t->disposition = DISPINLINE;
 
-  mutt_generate_boundary(&t->parameter);
-  mutt_set_parameter("protocol", "application/pgp-encrypted", &t->parameter);
-  
+  mutt_generate_boundary (&t->parameter);
+  mutt_set_parameter ("protocol", "application/pgp-encrypted", &t->parameter);
+
   t->parts = mutt_new_body ();
   t->parts->type = TYPEAPPLICATION;
   t->parts->subtype = safe_strdup ("pgp-encrypted");
@@ -1294,24 +1249,24 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   t->parts->next->filename = safe_strdup (tempfile);
   t->parts->next->use_disp = 1;
   t->parts->next->disposition = DISPINLINE;
-  t->parts->next->unlink = 1; /* delete after sending the message */
+  t->parts->next->unlink = 1;   /* delete after sending the message */
   t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime can save */
 
   return (t);
 }
 
-BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
+BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist)
 {
   BODY *b;
 
   char pgpoutfile[_POSIX_PATH_MAX];
   char pgperrfile[_POSIX_PATH_MAX];
   char pgpinfile[_POSIX_PATH_MAX];
-  
+
   char body_charset[STRING];
   char *from_charset;
   const char *send_charset;
-  
+
   FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
   FILE *fp;
 
@@ -1326,16 +1281,14 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
     return NULL;
   if (ascii_strcasecmp (a->subtype, "plain"))
     return NULL;
-  
-  if ((fp = fopen (a->filename, "r")) == NULL)
-  {
+
+  if ((fp = fopen (a->filename, "r")) == NULL) {
     mutt_perror (a->filename);
     return NULL;
   }
-  
+
   mutt_mktemp (pgpinfile);
-  if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL)
-  {
+  if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL) {
     mutt_perror (pgpinfile);
     fclose (fp);
     return NULL;
@@ -1346,31 +1299,29 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
    * we have to convert from that to utf-8.  If noconv is not set,
    * we have to convert from $charset to utf-8.
    */
-  
+
   mutt_get_body_charset (body_charset, sizeof (body_charset), a);
   if (a->noconv)
     from_charset = body_charset;
-  else 
+  else
     from_charset = Charset;
-    
-  if (!mutt_is_us_ascii (body_charset))
-  {
+
+  if (!mutt_is_us_ascii (body_charset)) {
     int c;
     FGETCONV *fc;
-    
+
     if (flags & ENCRYPT)
       send_charset = "us-ascii";
     else
       send_charset = "utf-8";
-    
+
     fc = fgetconv_open (fp, from_charset, "utf-8", M_ICONV_HOOK_FROM);
     while ((c = fgetconv (fc)) != EOF)
       fputc (c, pgpin);
-    
+
     fgetconv_close (&fc);
   }
-  else
-  {
+  else {
     send_charset = "us-ascii";
     mutt_copy_stream (fp, pgpin);
   }
@@ -1380,25 +1331,23 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   mutt_mktemp (pgpoutfile);
   mutt_mktemp (pgperrfile);
   if ((pgpout = safe_fopen (pgpoutfile, "w+")) == NULL ||
-      (pgperr = safe_fopen (pgperrfile, "w+")) == NULL)
-  {
+      (pgperr = safe_fopen (pgperrfile, "w+")) == NULL) {
     mutt_perror (pgpout ? pgperrfile : pgpoutfile);
     unlink (pgpinfile);
-    if (pgpout) 
-    {
+    if (pgpout) {
       fclose (pgpout);
       unlink (pgpoutfile);
     }
     return NULL;
   }
-  
+
   unlink (pgperrfile);
 
-  if ((thepid = pgp_invoke_traditional (&pgpin, NULL, NULL, 
-                                       -1, fileno (pgpout), fileno (pgperr),
-                                       pgpinfile, keylist, flags)) == -1)
-  {
+  if ((thepid = pgp_invoke_traditional (&pgpin, NULL, NULL,
+                                        -1, fileno (pgpout), fileno (pgperr),
+                                        pgpinfile, keylist, flags)) == -1) {
     mutt_perror _("Can't invoke PGP");
+
     fclose (pgpout);
     fclose (pgperr);
     mutt_unlink (pgpinfile);
@@ -1406,14 +1355,14 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
     return NULL;
   }
 
-  if (pgp_use_gpg_agent())
+  if (pgp_use_gpg_agent ())
     *PgpPass = 0;
   if (flags & SIGN)
     fprintf (pgpin, "%s\n", PgpPass);
   fclose (pgpin);
 
-  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
-    empty=1;
+  if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
+    empty = 1;
 
   mutt_unlink (pgpinfile);
 
@@ -1422,43 +1371,42 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
 
   rewind (pgpout);
   rewind (pgperr);
-  
-  if(!empty)
+
+  if (!empty)
     empty = (fgetc (pgpout) == EOF);
   fclose (pgpout);
-  
+
   err = 0;
-  
-  while (fgets (buff, sizeof (buff), pgperr))
-  {
+
+  while (fgets (buff, sizeof (buff), pgperr)) {
     err = 1;
     fputs (buff, stdout);
   }
-  
+
   fclose (pgperr);
-  
+
   if (err)
     mutt_any_key_to_continue (NULL);
-  
-  if (empty)
-  {
+
+  if (empty) {
     unlink (pgpoutfile);
     return NULL;
   }
-    
+
   b = mutt_new_body ();
-  
+
   b->encoding = ENC7BIT;
 
   b->type = TYPETEXT;
   b->subtype = safe_strdup ("plain");
-  
-  mutt_set_parameter ("x-action", flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed",
-                     &b->parameter);
+
+  mutt_set_parameter ("x-action",
+                      flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed",
+                      &b->parameter);
   mutt_set_parameter ("charset", send_charset, &b->parameter);
-  
+
   b->filename = safe_strdup (pgpoutfile);
-  
+
 #if 0
   /* The following is intended to give a clue to some completely brain-dead 
    * "mail environments" which are typically used by large corporations.
@@ -1470,65 +1418,63 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
 #endif
 
   b->disposition = DISPINLINE;
-  b->unlink   = 1;
+  b->unlink = 1;
 
   b->noconv = 1;
   b->use_disp = 0;
-  
+
   if (!(flags & ENCRYPT))
     b->encoding = a->encoding;
-  
+
   return b;
 }
 
-int pgp_send_menu (HEADER *msg, int *redraw)
+int pgp_send_menu (HEADER * msg, int *redraw)
 {
   pgp_key_t p;
   char input_signas[SHORT_STRING];
 
   char prompt[LONG_STRING];
-  
+
   if (!(WithCrypto & APPLICATION_PGP))
     return msg->security;
 
   /* If autoinline and no crypto options set, then set inline. */
-  if (option (OPTPGPAUTOINLINE) && 
-      !((msg->security & APPLICATION_PGP) && (msg->security & (SIGN|ENCRYPT))))
+  if (option (OPTPGPAUTOINLINE) && !((msg->security & APPLICATION_PGP)
+                                     && (msg->security & (SIGN | ENCRYPT))))
     msg->security |= INLINE;
-  
-  snprintf (prompt, sizeof (prompt), 
-           _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s, or (c)lear? "),
-           (msg->security & INLINE) ? _("PGP/M(i)ME") : _("(i)nline"));
-  
-  switch (mutt_multi_choice (prompt, _("esabifc")))
-  {
-  case 1: /* (e)ncrypt */
+
+  snprintf (prompt, sizeof (prompt),
+            _("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, %s, or (c)lear? "),
+            (msg->security & INLINE) ? _("PGP/M(i)ME") : _("(i)nline"));
+
+  switch (mutt_multi_choice (prompt, _("esabifc"))) {
+  case 1:                      /* (e)ncrypt */
     msg->security |= ENCRYPT;
     msg->security &= ~SIGN;
     break;
 
-  case 2: /* (s)ign */
+  case 2:                      /* (s)ign */
     msg->security |= SIGN;
     msg->security &= ~ENCRYPT;
     break;
 
-  case 3: /* sign (a)s */
-    unset_option(OPTPGPCHECKTRUST);
+  case 3:                      /* sign (a)s */
+    unset_option (OPTPGPCHECKTRUST);
 
-    if ((p = pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN, PGP_PUBRING)))
-    {
-      snprintf (input_signas, sizeof (input_signas), "0x%s",
-                pgp_keyid (p));
+    if ((p =
+         pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN,
+                          PGP_PUBRING))) {
+      snprintf (input_signas, sizeof (input_signas), "0x%s", pgp_keyid (p));
       mutt_str_replace (&PgpSignAs, input_signas);
       pgp_free_key (&p);
-      
+
       msg->security |= SIGN;
-       
-      crypt_pgp_void_passphrase ();  /* probably need a different passphrase */
+
+      crypt_pgp_void_passphrase ();     /* probably need a different passphrase */
     }
 #if 0
-    else
-    {
+    else {
       msg->security &= ~SIGN;
     }
 #endif
@@ -1536,26 +1482,25 @@ int pgp_send_menu (HEADER *msg, int *redraw)
     *redraw = REDRAW_FULL;
     break;
 
-  case 4: /* (b)oth */
+  case 4:                      /* (b)oth */
     msg->security |= (ENCRYPT | SIGN);
     break;
 
-  case 5: /* (i)nline */
+  case 5:                      /* (i)nline */
     if ((msg->security & (ENCRYPT | SIGN)))
       msg->security ^= INLINE;
     else
       msg->security &= ~INLINE;
     break;
 
-  case 6: /* (f)orget it */
-  case 7: /* (c)lear     */
+  case 6:                      /* (f)orget it */
+  case 7:                      /* (c)lear     */
     msg->security = 0;
     break;
   }
 
-  if (msg->security)
-  {
-    if (! (msg->security & (ENCRYPT | SIGN)))
+  if (msg->security) {
+    if (!(msg->security & (ENCRYPT | SIGN)))
       msg->security = 0;
     else
       msg->security |= APPLICATION_PGP;
diff --git a/pgp.h b/pgp.h
index 3171872..577d894 100644 (file)
--- a/pgp.h
+++ b/pgp.h
@@ -26,7 +26,7 @@
 
 /* prototypes */
 
-int pgp_use_gpg_agent(void);
+int pgp_use_gpg_agent (void);
 
 int pgp_check_traditional (FILE *, BODY *, int);
 BODY *pgp_decrypt_part (BODY *, STATE *, FILE *, BODY *);
@@ -49,7 +49,7 @@ pgp_key_t pgp_get_candidates (pgp_ring_t, LIST *);
 pgp_key_t pgp_getkeybyaddr (ADDRESS *, short, pgp_ring_t);
 pgp_key_t pgp_getkeybystr (char *, short, pgp_ring_t);
 
-char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+char *pgp_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
 
 void pgp_forget_passphrase (void);
 void pgp_application_pgp_handler (BODY *, STATE *);
@@ -61,33 +61,33 @@ int pgp_valid_passphrase (void);
 
 /* The PGP invocation interface - not really beautiful. */
 
-pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *fname, short need_passphrase);
-pid_t pgp_invoke_verify (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *fname, const char *sig_fname);
-pid_t pgp_invoke_decrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                         int pgpinfd, int pgpoutfd, int pgperrfd, 
-                         const char *fname);
-pid_t pgp_invoke_sign (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                      int pgpinfd, int pgpoutfd, int pgperrfd, 
-                      const char *fname);
-pid_t pgp_invoke_encrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                         int pgpinfd, int pgpoutfd, int pgperrfd,
-                         const char *fname, const char *uids, int sign);
-pid_t pgp_invoke_export (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *uids);
-pid_t pgp_invoke_verify_key (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                            int pgpinfd, int pgpoutfd, int pgperrfd, 
-                            const char *uids);
-pid_t pgp_invoke_list_keys (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                           int pgpinfd, int pgpoutfd, int pgperrfd, 
-                           pgp_ring_t keyring, LIST *hints);
-pid_t pgp_invoke_traditional (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                         int pgpinfd, int pgpoutfd, int pgperrfd,
-                         const char *fname, const char *uids, int flags);
+pid_t pgp_invoke_decode (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *fname, short need_passphrase);
+pid_t pgp_invoke_verify (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *fname, const char *sig_fname);
+pid_t pgp_invoke_decrypt (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                          int pgpinfd, int pgpoutfd, int pgperrfd,
+                          const char *fname);
+pid_t pgp_invoke_sign (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                       int pgpinfd, int pgpoutfd, int pgperrfd,
+                       const char *fname);
+pid_t pgp_invoke_encrypt (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                          int pgpinfd, int pgpoutfd, int pgperrfd,
+                          const char *fname, const char *uids, int sign);
+pid_t pgp_invoke_export (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *uids);
+pid_t pgp_invoke_verify_key (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                             int pgpinfd, int pgpoutfd, int pgperrfd,
+                             const char *uids);
+pid_t pgp_invoke_list_keys (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                            int pgpinfd, int pgpoutfd, int pgperrfd,
+                            pgp_ring_t keyring, LIST * hints);
+pid_t pgp_invoke_traditional (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                              int pgpinfd, int pgpoutfd, int pgperrfd,
+                              const char *fname, const char *uids, int flags);
 
 
 void pgp_invoke_import (const char *fname);
@@ -100,6 +100,6 @@ BODY *pgp_traditional_encryptsign (BODY *, int, char *);
 BODY *pgp_encrypt_message (BODY *, char *, int);
 BODY *pgp_sign_message (BODY *);
 
-int pgp_send_menu (HEADER *msg, int *redraw);
+int pgp_send_menu (HEADER * msg, int *redraw);
 
 #endif /* CRYPT_BACKEND_CLASSIC_PGP */
index c15864f..b3a84c0 100644 (file)
 #include <unistd.h>
 #include <string.h>
 
-void print_usage(const char *progname) {
-       fprintf(stderr, "Command line usage: %s [flags] -- prefix [recipients]\n", progname);
-       exit(1);
+void print_usage (const char *progname)
+{
+  fprintf (stderr, "Command line usage: %s [flags] -- prefix [recipients]\n",
+           progname);
+  exit (1);
 }
 
-int main(int argc, char **argv) {
-       char **opts, **opt, *pfx;
-       int i;
-
-       if (argc <= 1) {
-               print_usage(argv[0]);
-        }
-
-       opts = malloc((2 * argc + 1) * sizeof (* opts));        /* __MEM_CHECKED__ */
-       if(!opts) {
-               perror(argv[0]);
-               exit(2);
-       }
-
-       if (argc < 2)
-       {
-         fprintf (stderr,
-                  "Command line usage: %s [flags] -- prefix [recipients]\n",
-                  argv[0]);
-         return 1;
-       }
-
-       opt = opts;
-       *opt++ = argv[1];
-       pfx = NULL;
-
-       for(i = 2; i < argc; ) {
-               if(!strcmp(argv[i], "--")) {
-                       i += 2;
-                       if(i > argc) {
-                               print_usage(argv[0]);
-                       }
-                       pfx = argv[i-1];
-               }
-               if(pfx)
-                       *opt++ = pfx;
-               *opt++ = argv[i++];
-       }
-       *opt = NULL;
-
-       execvp(opts[0], opts);
-       perror(argv[0]);
-       return 2;
+int main (int argc, char **argv)
+{
+  char **opts, **opt, *pfx;
+  int i;
+
+  if (argc <= 1) {
+    print_usage (argv[0]);
+  }
+
+  opts = malloc ((2 * argc + 1) * sizeof (*opts));      /* __MEM_CHECKED__ */
+  if (!opts) {
+    perror (argv[0]);
+    exit (2);
+  }
+
+  if (argc < 2) {
+    fprintf (stderr,
+             "Command line usage: %s [flags] -- prefix [recipients]\n",
+             argv[0]);
+    return 1;
+  }
+
+  opt = opts;
+  *opt++ = argv[1];
+  pfx = NULL;
+
+  for (i = 2; i < argc;) {
+    if (!strcmp (argv[i], "--")) {
+      i += 2;
+      if (i > argc) {
+        print_usage (argv[0]);
+      }
+      pfx = argv[i - 1];
+    }
+    if (pfx)
+      *opt++ = pfx;
+    *opt++ = argv[i++];
+  }
+  *opt = NULL;
+
+  execvp (opts[0], opts);
+  perror (argv[0]);
+  return 2;
 }
index ac3145a..9c6e89b 100644 (file)
@@ -17,7 +17,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /* This file contains the new pgp invocation code.  Note that this
  * is almost entirely format based.
  */
 
 struct pgp_command_context {
-  short need_passphrase;       /* %p */
-  const char *fname;           /* %f */
-  const char *sig_fname;       /* %s */
-  const char *signas;          /* %a */
-  const char *ids;             /* %r */
+  short need_passphrase;        /* %p */
+  const char *fname;            /* %f */
+  const char *sig_fname;        /* %s */
+  const char *signas;           /* %a */
+  const char *ids;              /* %r */
 };
 
 
 const char *_mutt_fmt_pgp_command (char *dest,
-                                  size_t destlen,
-                                  char op,
-                                  const char *src,
-                                  const char *prefix,
-                                  const char *ifstring,
-                                  const char *elsestring,
-                                  unsigned long data,
-                                  format_flag flags)
+                                   size_t destlen,
+                                   char op,
+                                   const char *src,
+                                   const char *prefix,
+                                   const char *ifstring,
+                                   const char *elsestring,
+                                   unsigned long data, format_flag flags)
 {
   char fmt[16];
   struct pgp_command_context *cctx = (struct pgp_command_context *) data;
   int optional = (flags & M_FORMAT_OPTIONAL);
-  
-  switch (op)
-  {
-    case 'r':
+
+  switch (op) {
+  case 'r':
     {
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->ids));
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->ids));
       }
       else if (!cctx->ids)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'a':
+
+  case 'a':
     {
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->signas));
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->signas));
       }
       else if (!cctx->signas)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 's':
+
+  case 's':
     {
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->sig_fname));
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->sig_fname));
       }
       else if (!cctx->sig_fname)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'f':
+
+  case 'f':
     {
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->fname));
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->fname));
       }
       else if (!cctx->fname)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'p':
+
+  case 'p':
     {
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, cctx->need_passphrase ? "PGPPASSFD=0" : "");
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt,
+                  cctx->need_passphrase ? "PGPPASSFD=0" : "");
       }
-      else if (!cctx->need_passphrase || pgp_use_gpg_agent())
-       optional = 0;
+      else if (!cctx->need_passphrase || pgp_use_gpg_agent ())
+        optional = 0;
       break;
     }
-    default:
+  default:
     {
       *dest = '\0';
       break;
@@ -139,16 +133,20 @@ const char *_mutt_fmt_pgp_command (char *dest,
   }
 
   if (optional)
-    mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_pgp_command, data, 0);
+    mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_pgp_command, data,
+                       0);
   else if (flags & M_FORMAT_OPTIONAL)
-    mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_pgp_command, data, 0);
+    mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_pgp_command, data,
+                       0);
 
   return (src);
 }
 
-void mutt_pgp_command (char *d, size_t dlen, struct pgp_command_context *cctx, const char *fmt)
+void mutt_pgp_command (char *d, size_t dlen, struct pgp_command_context *cctx,
+                       const char *fmt)
 {
-  mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command, (unsigned long) cctx, 0);
+  mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command,
+                     (unsigned long) cctx, 0);
   dprint (2, (debugfile, "mutt_pgp_command: %s\n", d));
 }
 
@@ -157,33 +155,32 @@ void mutt_pgp_command (char *d, size_t dlen, struct pgp_command_context *cctx, c
  */
 
 
-static pid_t pgp_invoke (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd,
-                        short need_passphrase,
-                        const char *fname,
-                        const char *sig_fname,
-                        const char *signas,
-                        const char *ids,
-                        const char *format)
+static pid_t pgp_invoke (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         short need_passphrase,
+                         const char *fname,
+                         const char *sig_fname,
+                         const char *signas,
+                         const char *ids, const char *format)
 {
   struct pgp_command_context cctx;
   char cmd[HUGE_STRING];
-  
+
   memset (&cctx, 0, sizeof (cctx));
 
   if (!format || !*format)
-    return (pid_t) -1;
-  
+    return (pid_t) - 1;
+
   cctx.need_passphrase = need_passphrase;
-  cctx.fname          = fname;
-  cctx.sig_fname       = sig_fname;
-  cctx.signas         = signas;
-  cctx.ids            = ids;
-  
+  cctx.fname = fname;
+  cctx.sig_fname = sig_fname;
+  cctx.signas = signas;
+  cctx.ids = ids;
+
   mutt_pgp_command (cmd, sizeof (cmd), &cctx, format);
-  
+
   return mutt_create_filter_fd (cmd, pgpin, pgpout, pgperr,
-                              pgpinfd, pgpoutfd, pgperrfd);
+                                pgpinfd, pgpoutfd, pgperrfd);
 }
 
 
@@ -195,66 +192,65 @@ static pid_t pgp_invoke (FILE **pgpin, FILE **pgpout, FILE **pgperr,
  */
 
 
-pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *fname, short need_passphrase)
+pid_t pgp_invoke_decode (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *fname, short need_passphrase)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    need_passphrase, fname, NULL, NULL, NULL, 
-                    PgpDecodeCommand);
+                     need_passphrase, fname, NULL, NULL, NULL,
+                     PgpDecodeCommand);
 }
 
-pid_t pgp_invoke_verify (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *fname, const char *sig_fname)
+pid_t pgp_invoke_verify (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *fname, const char *sig_fname)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    0, fname, sig_fname, NULL, NULL, PgpVerifyCommand);
+                     0, fname, sig_fname, NULL, NULL, PgpVerifyCommand);
 }
 
-pid_t pgp_invoke_decrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                         int pgpinfd, int pgpoutfd, int pgperrfd, 
-                         const char *fname)
+pid_t pgp_invoke_decrypt (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                          int pgpinfd, int pgpoutfd, int pgperrfd,
+                          const char *fname)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    1, fname, NULL, NULL, NULL, PgpDecryptCommand);
+                     1, fname, NULL, NULL, NULL, PgpDecryptCommand);
 }
 
-pid_t pgp_invoke_sign (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                      int pgpinfd, int pgpoutfd, int pgperrfd, 
-                      const char *fname)
+pid_t pgp_invoke_sign (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                       int pgpinfd, int pgpoutfd, int pgperrfd,
+                       const char *fname)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    1, fname, NULL, PgpSignAs, NULL, PgpSignCommand);
+                     1, fname, NULL, PgpSignAs, NULL, PgpSignCommand);
 }
 
 
-pid_t pgp_invoke_encrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                         int pgpinfd, int pgpoutfd, int pgperrfd,
-                         const char *fname, const char *uids, int sign)
+pid_t pgp_invoke_encrypt (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                          int pgpinfd, int pgpoutfd, int pgperrfd,
+                          const char *fname, const char *uids, int sign)
 {
   if (sign)
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                      1, fname, NULL, PgpSignAs, uids, 
-                      PgpEncryptSignCommand);
+                       1, fname, NULL, PgpSignAs, uids,
+                       PgpEncryptSignCommand);
   else
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                      0, fname, NULL, NULL, uids, 
-                      PgpEncryptOnlyCommand);
+                       0, fname, NULL, NULL, uids, PgpEncryptOnlyCommand);
 }
 
-pid_t pgp_invoke_traditional (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                             int pgpinfd, int pgpoutfd, int pgperrfd,
-                             const char *fname, const char *uids, int flags)
+pid_t pgp_invoke_traditional (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                              int pgpinfd, int pgpoutfd, int pgperrfd,
+                              const char *fname, const char *uids, int flags)
 {
   if (flags & ENCRYPT)
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                      flags & SIGN ? 1 : 0, fname, NULL, PgpSignAs, uids, 
-                      flags & SIGN ? PgpEncryptSignCommand : PgpEncryptOnlyCommand);
+                       flags & SIGN ? 1 : 0, fname, NULL, PgpSignAs, uids,
+                       flags & SIGN ? PgpEncryptSignCommand :
+                       PgpEncryptOnlyCommand);
   else
     return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                      1, fname, NULL, PgpSignAs, NULL,
-                      PgpClearSignCommand);
+                       1, fname, NULL, PgpSignAs, NULL, PgpClearSignCommand);
 }
 
 
@@ -263,17 +259,17 @@ void pgp_invoke_import (const char *fname)
   char _fname[_POSIX_PATH_MAX + SHORT_STRING];
   char cmd[HUGE_STRING];
   struct pgp_command_context cctx;
-  
+
   memset (&cctx, 0, sizeof (cctx));
-  
+
   mutt_quote_filename (_fname, sizeof (_fname), fname);
   cctx.fname = _fname;
-  
+
   mutt_pgp_command (cmd, sizeof (cmd), &cctx, PgpImportCommand);
   mutt_system (cmd);
 }
 
-void pgp_invoke_getkeys (ADDRESS *addr)
+void pgp_invoke_getkeys (ADDRESS * addr)
 {
   char buff[LONG_STRING];
   char tmp[LONG_STRING];
@@ -281,75 +277,75 @@ void pgp_invoke_getkeys (ADDRESS *addr)
   int devnull;
 
   char *personal;
-  
+
   struct pgp_command_context cctx;
 
-  if (!PgpGetkeysCommand) return;
-  
+  if (!PgpGetkeysCommand)
+    return;
+
   memset (&cctx, 0, sizeof (cctx));
 
   personal = addr->personal;
   addr->personal = NULL;
-  
+
   *tmp = '\0';
   mutt_addrlist_to_local (addr);
   rfc822_write_address_single (tmp, sizeof (tmp), addr, 0);
   mutt_quote_filename (buff, sizeof (buff), tmp);
 
   addr->personal = personal;
-  
+
   cctx.ids = buff;
-  
+
   mutt_pgp_command (cmd, sizeof (cmd), &cctx, PgpGetkeysCommand);
 
   devnull = open ("/dev/null", O_RDWR);
 
-  if (!isendwin ()) mutt_message  _("Fetching PGP key...");
+  if (!isendwin ())
+    mutt_message _("Fetching PGP key...");
 
   mutt_system (cmd);
 
-  if (!isendwin ()) mutt_clear_error ();
+  if (!isendwin ())
+    mutt_clear_error ();
 
   close (devnull);
 }
 
-pid_t pgp_invoke_export (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                        int pgpinfd, int pgpoutfd, int pgperrfd, 
-                        const char *uids)
+pid_t pgp_invoke_export (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                         int pgpinfd, int pgpoutfd, int pgperrfd,
+                         const char *uids)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    0, NULL, NULL, NULL, uids,
-                    PgpExportCommand);
+                     0, NULL, NULL, NULL, uids, PgpExportCommand);
 }
 
-pid_t pgp_invoke_verify_key (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                            int pgpinfd, int pgpoutfd, int pgperrfd, 
-                            const char *uids)
+pid_t pgp_invoke_verify_key (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                             int pgpinfd, int pgpoutfd, int pgperrfd,
+                             const char *uids)
 {
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    0, NULL, NULL, NULL, uids,
-                    PgpVerifyKeyCommand);
+                     0, NULL, NULL, NULL, uids, PgpVerifyKeyCommand);
 }
 
-pid_t pgp_invoke_list_keys (FILE **pgpin, FILE **pgpout, FILE **pgperr,
-                           int pgpinfd, int pgpoutfd, int pgperrfd, 
-                           pgp_ring_t keyring, LIST *hints)
+pid_t pgp_invoke_list_keys (FILE ** pgpin, FILE ** pgpout, FILE ** pgperr,
+                            int pgpinfd, int pgpoutfd, int pgperrfd,
+                            pgp_ring_t keyring, LIST * hints)
 {
   char uids[HUGE_STRING];
   char tmpuids[HUGE_STRING];
   char quoted[HUGE_STRING];
-  
+
   *uids = '\0';
-  
-  for (; hints; hints = hints->next)
-  {
+
+  for (; hints; hints = hints->next) {
     mutt_quote_filename (quoted, sizeof (quoted), (char *) hints->data);
     snprintf (tmpuids, sizeof (tmpuids), "%s %s", uids, quoted);
-    strcpy (uids, tmpuids);    /* __STRCPY_CHECKED__ */
+    strcpy (uids, tmpuids);     /* __STRCPY_CHECKED__ */
   }
 
   return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
-                    0, NULL, NULL, NULL, uids,
-                    keyring == PGP_SECRING ? PgpListSecringCommand :
-                    PgpListPubringCommand);
+                     0, NULL, NULL, NULL, uids,
+                     keyring == PGP_SECRING ? PgpListSecringCommand :
+                     PgpListPubringCommand);
 }
index aa68642..4fd24ac 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -43,8 +43,7 @@
 
 #ifdef CRYPT_BACKEND_CLASSIC_PGP
 
-struct pgp_cache
-{
+struct pgp_cache {
   char *what;
   char *dflt;
   struct pgp_cache *next;
@@ -87,7 +86,7 @@ static char pgp_flags (int flags)
     return 'd';
   else if (flags & KEYFLAG_CRITICAL)
     return 'c';
-  else 
+  else
     return ' ';
 }
 
@@ -113,21 +112,19 @@ static pgp_key_t pgp_principal_key (pgp_key_t key)
  * %[...] date of key using strftime(3)
  */
 
-typedef struct pgp_entry
-{
+typedef struct pgp_entry {
   size_t num;
   pgp_uid_t *uid;
 } pgp_entry_t;
 
 static const char *pgp_entry_fmt (char *dest,
-                                 size_t destlen,
-                                 char op,
-                                 const char *src,
-                                 const char *prefix,
-                                 const char *ifstring,
-                                 const char *elsestring,
-                                 unsigned long data,
-                                 format_flag flags)
+                                  size_t destlen,
+                                  char op,
+                                  const char *src,
+                                  const char *prefix,
+                                  const char *ifstring,
+                                  const char *elsestring,
+                                  unsigned long data, format_flag flags)
 {
   char fmt[16];
   pgp_entry_t *entry;
@@ -137,143 +134,129 @@ static const char *pgp_entry_fmt (char *dest,
   int optional = (flags & M_FORMAT_OPTIONAL);
 
   entry = (pgp_entry_t *) data;
-  uid   = entry->uid;
-  key   = uid->parent;
-  pkey  = pgp_principal_key (key);
+  uid = entry->uid;
+  key = uid->parent;
+  pkey = pgp_principal_key (key);
 
   if (isupper ((unsigned char) op))
     key = pkey;
 
   kflags = key->flags | (pkey->flags & KEYFLAG_RESTRICTIONS)
     | uid->flags;
-  
-  switch (ascii_tolower (op))
-  {
-    case '[':
-
-      {
-       const char *cp;
-       char buf2[SHORT_STRING], *p;
-       int do_locales;
-       struct tm *tm;
-       size_t len;
-
-       p = dest;
-
-       cp = src;
-       if (*cp == '!')
-       {
-         do_locales = 0;
-         cp++;
-       }
-       else
-         do_locales = 1;
-
-       len = destlen - 1;
-       while (len > 0 && *cp != ']')
-       {
-         if (*cp == '%')
-         {
-           cp++;
-           if (len >= 2)
-           {
-             *p++ = '%';
-             *p++ = *cp;
-             len -= 2;
-           }
-           else
-             break; /* not enough space */
-           cp++;
-         }
-         else
-         {
-           *p++ = *cp++;
-           len--;
-         }
-       }
-       *p = 0;
-
-       if (do_locales && Locale)
-         setlocale (LC_TIME, Locale);
-
-       tm = localtime (&key->gen_time);
-
-       strftime (buf2, sizeof (buf2), dest, tm);
-
-       if (do_locales)
-         setlocale (LC_TIME, "C");
-
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, buf2);
-       if (len > 0)
-         src = cp + 1;
-      }
-      break;
-    case 'n':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, entry->num);
-      }
-      break;
-    case 'k':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, _pgp_keyid (key));
-      }
-      break;
-    case 'u':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, uid->addr);
-      }
-      break;
-    case 'a':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, key->algorithm);
-      }
-      break;
-    case 'l':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, key->keylen);
-      }
-      break;
-    case 'f':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-       snprintf (dest, destlen, fmt, pgp_flags (kflags));
-      }
-      else if (!(kflags & (KEYFLAG_RESTRICTIONS)))
-        optional = 0;
-      break;
-    case 'c':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, pgp_key_abilities (kflags));
+
+  switch (ascii_tolower (op)) {
+  case '[':
+
+    {
+      const char *cp;
+      char buf2[SHORT_STRING], *p;
+      int do_locales;
+      struct tm *tm;
+      size_t len;
+
+      p = dest;
+
+      cp = src;
+      if (*cp == '!') {
+        do_locales = 0;
+        cp++;
       }
-      else if (!(kflags & (KEYFLAG_ABILITIES)))
-        optional = 0;
-      break;
-    case 't':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-       snprintf (dest, destlen, fmt, trust_flags[uid->trust & 0x03]);
+      else
+        do_locales = 1;
+
+      len = destlen - 1;
+      while (len > 0 && *cp != ']') {
+        if (*cp == '%') {
+          cp++;
+          if (len >= 2) {
+            *p++ = '%';
+            *p++ = *cp;
+            len -= 2;
+          }
+          else
+            break;              /* not enough space */
+          cp++;
+        }
+        else {
+          *p++ = *cp++;
+          len--;
+        }
       }
-      else if (!(uid->trust & 0x03))
-        /* undefined trust */
-        optional = 0;
-      break;
-    default:
-      *dest = '\0';
+      *p = 0;
+
+      if (do_locales && Locale)
+        setlocale (LC_TIME, Locale);
+
+      tm = localtime (&key->gen_time);
+
+      strftime (buf2, sizeof (buf2), dest, tm);
+
+      if (do_locales)
+        setlocale (LC_TIME, "C");
+
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, buf2);
+      if (len > 0)
+        src = cp + 1;
+    }
+    break;
+  case 'n':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, entry->num);
+    }
+    break;
+  case 'k':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, _pgp_keyid (key));
+    }
+    break;
+  case 'u':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, uid->addr);
+    }
+    break;
+  case 'a':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, key->algorithm);
+    }
+    break;
+  case 'l':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, key->keylen);
+    }
+    break;
+  case 'f':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      snprintf (dest, destlen, fmt, pgp_flags (kflags));
+    }
+    else if (!(kflags & (KEYFLAG_RESTRICTIONS)))
+      optional = 0;
+    break;
+  case 'c':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, pgp_key_abilities (kflags));
+    }
+    else if (!(kflags & (KEYFLAG_ABILITIES)))
+      optional = 0;
+    break;
+  case 't':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      snprintf (dest, destlen, fmt, trust_flags[uid->trust & 0x03]);
+    }
+    else if (!(uid->trust & 0x03))
+      /* undefined trust */
+      optional = 0;
+    break;
+  default:
+    *dest = '\0';
   }
 
   if (optional)
@@ -282,17 +265,17 @@ static const char *pgp_entry_fmt (char *dest,
     mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
   return (src);
 }
-      
+
 static void pgp_entry (char *s, size_t l, MUTTMENU * menu, int num)
 {
   pgp_uid_t **KeyTable = (pgp_uid_t **) menu->data;
   pgp_entry_t entry;
-  
+
   entry.uid = KeyTable[num];
   entry.num = num + 1;
 
-  mutt_FormatString (s, l, NONULL (PgpEntryFormat), pgp_entry_fmt, 
-                    (unsigned long) &entry, M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (s, l, NONULL (PgpEntryFormat), pgp_entry_fmt,
+                     (unsigned long) &entry, M_FORMAT_ARROWCURSOR);
 }
 
 static int _pgp_compare_address (const void *a, const void *b)
@@ -306,13 +289,13 @@ static int _pgp_compare_address (const void *a, const void *b)
     return r > 0;
   else
     return (mutt_strcasecmp (_pgp_keyid ((*s)->parent),
-                            _pgp_keyid ((*t)->parent)) > 0);
+                             _pgp_keyid ((*t)->parent)) > 0);
 }
 
 static int pgp_compare_address (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_pgp_compare_address (a, b)
-                                      : _pgp_compare_address (a, b));
+          : _pgp_compare_address (a, b));
 }
 
 
@@ -324,8 +307,8 @@ static int _pgp_compare_keyid (const void *a, const void *b)
   pgp_uid_t **s = (pgp_uid_t **) a;
   pgp_uid_t **t = (pgp_uid_t **) b;
 
-  if ((r = mutt_strcasecmp (_pgp_keyid ((*s)->parent), 
-                           _pgp_keyid ((*t)->parent))))
+  if ((r = mutt_strcasecmp (_pgp_keyid ((*s)->parent),
+                            _pgp_keyid ((*t)->parent))))
     return r > 0;
   else
     return (mutt_strcasecmp ((*s)->addr, (*t)->addr)) > 0;
@@ -334,7 +317,7 @@ static int _pgp_compare_keyid (const void *a, const void *b)
 static int pgp_compare_keyid (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_pgp_compare_keyid (a, b)
-                                      : _pgp_compare_keyid (a, b));
+          : _pgp_compare_keyid (a, b));
 }
 
 static int _pgp_compare_date (const void *a, const void *b)
@@ -351,7 +334,7 @@ static int _pgp_compare_date (const void *a, const void *b)
 static int pgp_compare_date (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_pgp_compare_date (a, b)
-                                      : _pgp_compare_date (a, b));
+          : _pgp_compare_date (a, b));
 }
 
 static int _pgp_compare_trust (const void *a, const void *b)
@@ -362,7 +345,7 @@ static int _pgp_compare_trust (const void *a, const void *b)
   pgp_uid_t **t = (pgp_uid_t **) b;
 
   if ((r = (((*s)->parent->flags & (KEYFLAG_RESTRICTIONS))
-           - ((*t)->parent->flags & (KEYFLAG_RESTRICTIONS)))))
+            - ((*t)->parent->flags & (KEYFLAG_RESTRICTIONS)))))
     return r > 0;
   if ((r = ((*s)->trust - (*t)->trust)))
     return r < 0;
@@ -372,28 +355,29 @@ static int _pgp_compare_trust (const void *a, const void *b)
     return r < 0;
   if ((r = mutt_strcasecmp ((*s)->addr, (*t)->addr)))
     return r > 0;
-  return (mutt_strcasecmp (_pgp_keyid ((*s)->parent), 
-                          _pgp_keyid ((*t)->parent))) > 0;
+  return (mutt_strcasecmp (_pgp_keyid ((*s)->parent),
+                           _pgp_keyid ((*t)->parent))) > 0;
 }
 
 static int pgp_compare_trust (const void *a, const void *b)
 {
   return ((PgpSortKeys & SORT_REVERSE) ? !_pgp_compare_trust (a, b)
-                                      : _pgp_compare_trust (a, b));
+          : _pgp_compare_trust (a, b));
 }
 
 static int pgp_key_is_valid (pgp_key_t k)
 {
   pgp_key_t pk = pgp_principal_key (k);
+
   if (k->flags & KEYFLAG_CANTUSE)
     return 0;
   if (pk->flags & KEYFLAG_CANTUSE)
     return 0;
-  
+
   return 1;
 }
 
-static int pgp_id_is_strong (pgp_uid_t *uid)
+static int pgp_id_is_strong (pgp_uid_t * uid)
 {
   if ((uid->trust & 3) < 3)
     return 0;
@@ -401,7 +385,7 @@ static int pgp_id_is_strong (pgp_uid_t *uid)
   return 1;
 }
 
-static int pgp_id_is_valid (pgp_uid_t *uid)
+static int pgp_id_is_valid (pgp_uid_t * uid)
 {
   if (!pgp_key_is_valid (uid->parent))
     return 0;
@@ -418,29 +402,29 @@ static int pgp_id_is_valid (pgp_uid_t *uid)
 
 #define PGP_KV_MATCH (PGP_KV_ADDR|PGP_KV_STRING)
 
-static int pgp_id_matches_addr (ADDRESS *addr, ADDRESS *u_addr, pgp_uid_t *uid)
+static int pgp_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr,
+                                pgp_uid_t * uid)
 {
   int rv = 0;
-  
+
   if (pgp_id_is_valid (uid))
     rv |= PGP_KV_VALID;
 
   if (pgp_id_is_strong (uid))
     rv |= PGP_KV_STRONGID;
-  
+
   if (addr->mailbox && u_addr->mailbox
       && mutt_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
     rv |= PGP_KV_ADDR;
-    
+
   if (addr->personal && u_addr->personal
       && mutt_strcasecmp (addr->personal, u_addr->personal) == 0)
     rv |= PGP_KV_STRING;
-  
+
   return rv;
 }
 
-static pgp_key_t pgp_select_key (pgp_key_t keys,
-                                 ADDRESS * p, const char *s)
+static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s)
 {
   int keymax;
   pgp_uid_t **KeyTable;
@@ -459,67 +443,62 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
   keymax = 0;
   KeyTable = NULL;
 
-  for (i = 0, kp = keys; kp; kp = kp->next)
-  {
-    if (!option (OPTPGPSHOWUNUSABLE) && (kp->flags & KEYFLAG_CANTUSE))
-    {
+  for (i = 0, kp = keys; kp; kp = kp->next) {
+    if (!option (OPTPGPSHOWUNUSABLE) && (kp->flags & KEYFLAG_CANTUSE)) {
       unusable = 1;
       continue;
     }
 
-    for (a = kp->address; a; a = a->next)
-    {
-      if (!option (OPTPGPSHOWUNUSABLE) && (a->flags & KEYFLAG_CANTUSE))
-      {
-       unusable = 1;
-       continue;
+    for (a = kp->address; a; a = a->next) {
+      if (!option (OPTPGPSHOWUNUSABLE) && (a->flags & KEYFLAG_CANTUSE)) {
+        unusable = 1;
+        continue;
       }
-      
-      if (i == keymax)
-      {
-       keymax += 5;
-       safe_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
+
+      if (i == keymax) {
+        keymax += 5;
+        safe_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
       }
-      
+
       KeyTable[i++] = a;
     }
   }
 
-  if (!i && unusable)
-  {
+  if (!i && unusable) {
     mutt_error _("All matching keys are expired, revoked, or disabled.");
+
     mutt_sleep (1);
     return NULL;
   }
 
-  switch (PgpSortKeys & SORT_MASK)
-  {
-    case SORT_DATE:
-      f = pgp_compare_date;
-      break;
-    case SORT_KEYID:
-      f = pgp_compare_keyid;
-      break;
-    case SORT_ADDRESS:
-      f = pgp_compare_address;
-      break;
-    case SORT_TRUST:
-    default:
-      f = pgp_compare_trust;
-      break;
+  switch (PgpSortKeys & SORT_MASK) {
+  case SORT_DATE:
+    f = pgp_compare_date;
+    break;
+  case SORT_KEYID:
+    f = pgp_compare_keyid;
+    break;
+  case SORT_ADDRESS:
+    f = pgp_compare_address;
+    break;
+  case SORT_TRUST:
+  default:
+    f = pgp_compare_trust;
+    break;
   }
   qsort (KeyTable, i, sizeof (pgp_uid_t *), f);
 
   helpstr[0] = 0;
   mutt_make_help (buf, sizeof (buf), _("Exit  "), MENU_PGP, OP_EXIT);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
   mutt_make_help (buf, sizeof (buf), _("Select  "), MENU_PGP,
-                 OP_GENERIC_SELECT_ENTRY);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
-  mutt_make_help (buf, sizeof (buf), _("Check key  "), MENU_PGP, OP_VERIFY_KEY);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+                  OP_GENERIC_SELECT_ENTRY);
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
+  mutt_make_help (buf, sizeof (buf), _("Check key  "), MENU_PGP,
+                  OP_VERIFY_KEY);
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
   mutt_make_help (buf, sizeof (buf), _("Help"), MENU_PGP, OP_HELP);
-  strcat (helpstr, buf);       /* __STRCAT_CHECKED__ */
+  strcat (helpstr, buf);        /* __STRCAT_CHECKED__ */
 
   menu = mutt_new_menu ();
   menu->max = i;
@@ -532,53 +511,55 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
     snprintf (buf, sizeof (buf), _("PGP keys matching <%s>."), p->mailbox);
   else
     snprintf (buf, sizeof (buf), _("PGP keys matching \"%s\"."), s);
-    
-  
+
+
   menu->title = buf;
 
   kp = NULL;
 
   mutt_clear_error ();
-  
-  while (!done)
-  {
-    switch (mutt_menuLoop (menu))
-    {
+
+  while (!done) {
+    switch (mutt_menuLoop (menu)) {
 
     case OP_VERIFY_KEY:
 
       mutt_mktemp (tempfile);
-      if ((devnull = fopen ("/dev/null", "w")) == NULL)        /* __FOPEN_CHECKED__ */
-      {
-       mutt_perror _("Can't open /dev/null");
-       break;
+      if ((devnull = fopen ("/dev/null", "w")) == NULL) {       /* __FOPEN_CHECKED__ */
+        mutt_perror _("Can't open /dev/null");
+
+        break;
       }
-      if ((fp = safe_fopen (tempfile, "w")) == NULL)
-      {
-       fclose (devnull);
-       mutt_perror _("Can't create temporary file");
-       break;
+      if ((fp = safe_fopen (tempfile, "w")) == NULL) {
+        fclose (devnull);
+        mutt_perror _("Can't create temporary file");
+
+        break;
       }
 
       mutt_message _("Invoking PGP...");
 
-      snprintf (tmpbuf, sizeof (tmpbuf), "0x%s", pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent)));
+      snprintf (tmpbuf, sizeof (tmpbuf), "0x%s",
+                pgp_keyid (pgp_principal_key
+                           (KeyTable[menu->current]->parent)));
 
       if ((thepid = pgp_invoke_verify_key (NULL, NULL, NULL, -1,
-                   fileno (fp), fileno (devnull), tmpbuf)) == -1)
-      {
-       mutt_perror _("Can't create filter");
-       unlink (tempfile);
-       fclose (fp);
-       fclose (devnull);
+                                           fileno (fp), fileno (devnull),
+                                           tmpbuf)) == -1) {
+        mutt_perror _("Can't create filter");
+
+        unlink (tempfile);
+        fclose (fp);
+        fclose (devnull);
       }
 
       mutt_wait_filter (thepid);
       fclose (fp);
       fclose (devnull);
       mutt_clear_error ();
-      snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), 
-               pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent)));
+      snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"),
+                pgp_keyid (pgp_principal_key
+                           (KeyTable[menu->current]->parent)));
       mutt_do_pager (cmd, tempfile, 0, NULL);
       menu->redraw = REDRAW_FULL;
 
@@ -593,44 +574,42 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
 
 
       /* XXX make error reporting more verbose */
-      
+
       if (option (OPTPGPCHECKTRUST))
-       if (!pgp_key_is_valid (KeyTable[menu->current]->parent))
-       {
-         mutt_error _("This key can't be used: expired/disabled/revoked.");
-         break;
-       }
-      
+        if (!pgp_key_is_valid (KeyTable[menu->current]->parent)) {
+          mutt_error _("This key can't be used: expired/disabled/revoked.");
+
+          break;
+        }
+
       if (option (OPTPGPCHECKTRUST) &&
-         (!pgp_id_is_valid (KeyTable[menu->current])
-          || !pgp_id_is_strong (KeyTable[menu->current])))
-      {
-       char *s = "";
-       char buff[LONG_STRING];
-       
-       if (KeyTable[menu->current]->flags & KEYFLAG_CANTUSE)
-         s = N_("ID is expired/disabled/revoked.");
-       else switch (KeyTable[menu->current]->trust & 0x03)
-       {
-         case 0:
-           s = N_("ID has undefined validity.");
-           break;
-         case 1:
-           s = N_("ID is not valid.");
-           break;
-         case 2:
-           s = N_("ID is only marginally valid.");
-           break;
-       }
-
-       snprintf (buff, sizeof (buff), _("%s Do you really want to use the key?"),
-                 _(s));
-
-       if (mutt_yesorno (buff, M_NO) != M_YES)
-       {
-         mutt_clear_error ();
-         break;
-       }
+          (!pgp_id_is_valid (KeyTable[menu->current])
+           || !pgp_id_is_strong (KeyTable[menu->current]))) {
+        char *s = "";
+        char buff[LONG_STRING];
+
+        if (KeyTable[menu->current]->flags & KEYFLAG_CANTUSE)
+          s = N_("ID is expired/disabled/revoked.");
+        else
+          switch (KeyTable[menu->current]->trust & 0x03) {
+          case 0:
+            s = N_("ID has undefined validity.");
+            break;
+          case 1:
+            s = N_("ID is not valid.");
+            break;
+          case 2:
+            s = N_("ID is only marginally valid.");
+            break;
+          }
+
+        snprintf (buff, sizeof (buff),
+                  _("%s Do you really want to use the key?"), _(s));
+
+        if (mutt_yesorno (buff, M_NO) != M_YES) {
+          mutt_clear_error ();
+          break;
+        }
       }
 
 # if 0
@@ -653,7 +632,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
   FREE (&KeyTable);
 
   set_option (OPTNEEDREDRAW);
-  
+
   return (kp);
 }
 
@@ -665,37 +644,32 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor,
   struct pgp_cache *l = NULL;
 
   mutt_clear_error ();
-  
+
   resp[0] = 0;
-  if (whatfor)
-  {
+  if (whatfor) {
 
     for (l = id_defaults; l; l = l->next)
-      if (!mutt_strcasecmp (whatfor, l->what))
-      {
-       strfcpy (resp, NONULL (l->dflt), sizeof (resp));
-       break;
+      if (!mutt_strcasecmp (whatfor, l->what)) {
+        strfcpy (resp, NONULL (l->dflt), sizeof (resp));
+        break;
       }
   }
 
 
-  FOREVER
-  {
+  FOREVER {
     resp[0] = 0;
     if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
       return NULL;
 
-    if (whatfor)
-    {
+    if (whatfor) {
       if (l)
-       mutt_str_replace (&l->dflt, resp);
-      else
-      {
-       l = safe_malloc (sizeof (struct pgp_cache));
-       l->next = id_defaults;
-       id_defaults = l;
-       l->what = safe_strdup (whatfor);
-       l->dflt = safe_strdup (resp);
+        mutt_str_replace (&l->dflt, resp);
+      else {
+        l = safe_malloc (sizeof (struct pgp_cache));
+        l->next = id_defaults;
+        id_defaults = l;
+        l->what = safe_strdup (whatfor);
+        l->dflt = safe_strdup (resp);
       }
     }
 
@@ -719,30 +693,32 @@ BODY *pgp_make_key_attachment (char *tempf)
   struct stat sb;
   pid_t thepid;
   pgp_key_t key;
+
   unset_option (OPTPGPCHECKTRUST);
 
-  key = pgp_ask_for_key (_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
+  key =
+    pgp_ask_for_key (_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
 
-  if (!key)    return NULL;
+  if (!key)
+    return NULL;
 
   snprintf (tmp, sizeof (tmp), "0x%s", pgp_keyid (pgp_principal_key (key)));
   pgp_free_key (&key);
-  
-  if (!tempf)
-  {
+
+  if (!tempf) {
     mutt_mktemp (tempfb);
     tempf = tempfb;
   }
 
-  if ((tempfp = safe_fopen (tempf, tempf == tempfb ? "w" : "a")) == NULL)
-  {
+  if ((tempfp = safe_fopen (tempf, tempf == tempfb ? "w" : "a")) == NULL) {
     mutt_perror _("Can't create temporary file");
+
     return NULL;
   }
 
-  if ((devnull = fopen ("/dev/null", "w")) == NULL)    /* __FOPEN_CHECKED__ */
-  {
+  if ((devnull = fopen ("/dev/null", "w")) == NULL) {   /* __FOPEN_CHECKED__ */
     mutt_perror _("Can't open /dev/null");
+
     fclose (tempfp);
     if (tempf == tempfb)
       unlink (tempf);
@@ -751,12 +727,12 @@ BODY *pgp_make_key_attachment (char *tempf)
 
   mutt_message _("Invoking pgp...");
 
-  
-  if ((thepid = 
+
+  if ((thepid =
        pgp_invoke_export (NULL, NULL, NULL, -1,
-                          fileno (tempfp), fileno (devnull), tmp)) == -1)
-  {
+                          fileno (tempfp), fileno (devnull), tmp)) == -1) {
     mutt_perror _("Can't create filter");
+
     unlink (tempf);
     fclose (tempfp);
     fclose (devnull);
@@ -784,7 +760,7 @@ BODY *pgp_make_key_attachment (char *tempf)
   return att;
 }
 
-static LIST *pgp_add_string_to_hints (LIST *hints, const char *str)
+static LIST *pgp_add_string_to_hints (LIST * hints, const char *str)
 {
   char *scratch;
   char *t;
@@ -793,8 +769,7 @@ static LIST *pgp_add_string_to_hints (LIST *hints, const char *str)
     return hints;
 
   for (t = strtok (scratch, " ,.:\"()<>\n"); t;
-                       t = strtok (NULL, " ,.:\"()<>\n"))
-  {
+       t = strtok (NULL, " ,.:\"()<>\n")) {
     if (strlen (t) > 3)
       hints = mutt_add_list (hints, t);
   }
@@ -817,9 +792,9 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
   ADDRESS *r, *p;
   LIST *hints = NULL;
 
-  int weak    = 0;
+  int weak = 0;
   int invalid = 0;
-  int multi   = 0;
+  int multi = 0;
   int this_key_has_strong;
   int this_key_has_weak;
   int this_key_has_invalid;
@@ -830,7 +805,7 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
   pgp_key_t matches = NULL;
   pgp_key_t *last = &matches;
   pgp_uid_t *q;
-  
+
   if (a && a->mailbox)
     hints = pgp_add_string_to_hints (hints, a->mailbox);
   if (a && a->personal)
@@ -840,58 +815,53 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
   keys = pgp_get_candidates (keyring, hints);
 
   mutt_free_list (&hints);
-  
+
   if (!keys)
     return NULL;
-  
+
   dprint (5, (debugfile, "pgp_getkeybyaddr: looking for %s <%s>.",
-             a->personal, a->mailbox));
+              a->personal, a->mailbox));
 
 
-  for (k = keys; k; k = kn)
-  {
+  for (k = keys; k; k = kn) {
     kn = k->next;
 
-    dprint (5, (debugfile, "  looking at key: %s\n",
-               pgp_keyid (k)));
+    dprint (5, (debugfile, "  looking at key: %s\n", pgp_keyid (k)));
 
-    if (abilities && !(k->flags & abilities))
-    {
+    if (abilities && !(k->flags & abilities)) {
       dprint (5, (debugfile, "  insufficient abilities: Has %x, want %x\n",
-                 k->flags, abilities));
+                  k->flags, abilities));
       continue;
     }
 
-    this_key_has_weak    = 0;  /* weak but valid match   */
+    this_key_has_weak = 0;      /* weak but valid match   */
     this_key_has_invalid = 0;   /* invalid match          */
-    this_key_has_strong  = 0;  /* strong and valid match */
-    match                = 0;   /* any match             */
+    this_key_has_strong = 0;    /* strong and valid match */
+    match = 0;                  /* any match              */
 
-    for (q = k->address; q; q = q->next)
-    {
+    for (q = k->address; q; q = q->next) {
       r = rfc822_parse_adrlist (NULL, q->addr);
 
-      for (p = r; p; p = p->next)
-      {
-       int validity = pgp_id_matches_addr (a, p, q);
-
-       if (validity & PGP_KV_MATCH)    /* something matches */
-         match = 1;
-
-       /* is this key a strong candidate? */
-       if ((validity & PGP_KV_VALID) && (validity & PGP_KV_STRONGID) 
-           && (validity & PGP_KV_ADDR))
-       {
-         if (the_valid_key && the_valid_key != k)
-           multi             = 1;
-         the_valid_key       = k;
-         this_key_has_strong = 1;
-       }
-       else if ((validity & PGP_KV_MATCH) && !(validity & PGP_KV_VALID))
-         this_key_has_invalid = 1;
-       else if ((validity & PGP_KV_MATCH) 
-                && (!(validity & PGP_KV_STRONGID) || !(validity & PGP_KV_ADDR)))
-         this_key_has_weak    = 1;
+      for (p = r; p; p = p->next) {
+        int validity = pgp_id_matches_addr (a, p, q);
+
+        if (validity & PGP_KV_MATCH)    /* something matches */
+          match = 1;
+
+        /* is this key a strong candidate? */
+        if ((validity & PGP_KV_VALID) && (validity & PGP_KV_STRONGID)
+            && (validity & PGP_KV_ADDR)) {
+          if (the_valid_key && the_valid_key != k)
+            multi = 1;
+          the_valid_key = k;
+          this_key_has_strong = 1;
+        }
+        else if ((validity & PGP_KV_MATCH) && !(validity & PGP_KV_VALID))
+          this_key_has_invalid = 1;
+        else if ((validity & PGP_KV_MATCH)
+                 && (!(validity & PGP_KV_STRONGID)
+                     || !(validity & PGP_KV_ADDR)))
+          this_key_has_weak = 1;
       }
 
       rfc822_free_address (&r);
@@ -901,22 +871,19 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
       invalid = 1;
     if (match && !this_key_has_strong && this_key_has_weak)
       weak = 1;
-    
-    if (match)
-    {
-      *last  = pgp_principal_key (k);
-      kn     = pgp_remove_key (&keys, *last);
-      last   = pgp_get_lastp (k);
+
+    if (match) {
+      *last = pgp_principal_key (k);
+      kn = pgp_remove_key (&keys, *last);
+      last = pgp_get_lastp (k);
     }
   }
 
   pgp_free_key (&keys);
-  
-  if (matches)
-  {
+
+  if (matches) {
     if (the_valid_key && !multi /* && !weak 
-       && !(invalid && option (OPTPGPSHOWUNUSABLE)) */)
-    {
+                                   && !(invalid && option (OPTPGPSHOWUNUSABLE)) */ ) {
       /*
        * There was precisely one strong match on a valid ID.
        * 
@@ -926,13 +893,12 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
       pgp_free_key (&matches);
       k = the_valid_key;
     }
-    else 
-    {
+    else {
       /* 
        * Else: Ask the user.
        */
       if ((k = pgp_select_key (matches, a, NULL)))
-       pgp_remove_key (&matches, k);
+        pgp_remove_key (&matches, k);
       pgp_free_key (&matches);
     }
 
@@ -953,54 +919,52 @@ pgp_key_t pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring)
   short match;
 
   mutt_message (_("Looking for keys matching \"%s\"..."), p);
-  
+
   hints = pgp_add_string_to_hints (hints, p);
   keys = pgp_get_candidates (keyring, hints);
   mutt_free_list (&hints);
 
   if (!keys)
     return NULL;
-  
-  
-  for (k = keys; k; k = kn)
-  {
+
+
+  for (k = keys; k; k = kn) {
     kn = k->next;
     if (abilities && !(k->flags & abilities))
       continue;
 
     match = 0;
-    
-    for (a = k->address; a; a = a->next)
-    {
-      dprint (5, (debugfile, "pgp_getkeybystr: matching \"%s\" against key %s, \"%s\": ",
-                 p, pgp_keyid (k), a->addr));
-      if (!*p || mutt_strcasecmp (p, pgp_keyid (k)) == 0 ||
-         (!mutt_strncasecmp (p, "0x", 2) && !mutt_strcasecmp (p + 2, pgp_keyid (k))) ||
-         (option (OPTPGPLONGIDS) && !mutt_strncasecmp (p, "0x", 2) &&
-          !mutt_strcasecmp (p + 2, k->keyid + 8)) ||
-         mutt_stristr (a->addr, p))
-      {
-       dprint (5, (debugfile, "match.\n"));
-       match = 1;
-       break;
+
+    for (a = k->address; a; a = a->next) {
+      dprint (5,
+              (debugfile,
+               "pgp_getkeybystr: matching \"%s\" against key %s, \"%s\": ", p,
+               pgp_keyid (k), a->addr));
+      if (!*p || mutt_strcasecmp (p, pgp_keyid (k)) == 0
+          || (!mutt_strncasecmp (p, "0x", 2)
+              && !mutt_strcasecmp (p + 2, pgp_keyid (k)))
+          || (option (OPTPGPLONGIDS) && !mutt_strncasecmp (p, "0x", 2)
+              && !mutt_strcasecmp (p + 2, k->keyid + 8))
+          || mutt_stristr (a->addr, p)) {
+        dprint (5, (debugfile, "match.\n"));
+        match = 1;
+        break;
       }
     }
-    
-    if (match)
-    {
+
+    if (match) {
       *last = pgp_principal_key (k);
-      kn    = pgp_remove_key (&keys, *last);
-      last  = pgp_get_lastp (k);
+      kn = pgp_remove_key (&keys, *last);
+      last = pgp_get_lastp (k);
     }
   }
 
   pgp_free_key (&keys);
 
-  if (matches)
-  {
+  if (matches) {
     if ((k = pgp_select_key (matches, NULL, p)))
       pgp_remove_key (&matches, k);
-    
+
     pgp_free_key (&matches);
     return k;
   }
index 258b1c3..eda1855 100644 (file)
--- a/pgplib.c
+++ b/pgplib.c
@@ -37,8 +37,7 @@
 
 const char *pgp_pkalgbytype (unsigned char type)
 {
-  switch (type)
-  {
+  switch (type) {
   case 1:
     return "RSA";
   case 2:
@@ -64,8 +63,7 @@ const char *pgp_pkalgbytype (unsigned char type)
 
 static const char *hashalgbytype (unsigned char type)
 {
-  switch (type)
-  {
+  switch (type) {
   case 1:
     return "MD5";
   case 2:
@@ -83,8 +81,7 @@ static const char *hashalgbytype (unsigned char type)
 
 short pgp_canencrypt (unsigned char type)
 {
-  switch (type)
-  {
+  switch (type) {
   case 1:
   case 2:
   case 16:
@@ -97,8 +94,7 @@ short pgp_canencrypt (unsigned char type)
 
 short pgp_cansign (unsigned char type)
 {
-  switch (type)
-  {
+  switch (type) {
   case 1:
   case 3:
   case 17:
@@ -121,19 +117,18 @@ short pgp_get_abilities (unsigned char type)
   return (pgp_canencrypt (type) << 1) | pgp_cansign (type);
 }
 
-void pgp_free_sig (pgp_sig_t **sigp)
+void pgp_free_sig (pgp_sig_t ** sigp)
 {
   pgp_sig_t *sp, *q;
-  
+
   if (!sigp || !*sigp)
     return;
-  
-  for (sp = *sigp; sp; sp = q)
-  {
+
+  for (sp = *sigp; sp; sp = q) {
     q = sp->next;
     FREE (&sp);
   }
-  
+
   *sigp = NULL;
 }
 
@@ -143,8 +138,7 @@ void pgp_free_uid (pgp_uid_t ** upp)
 
   if (!upp || !*upp)
     return;
-  for (up = *upp; up; up = q)
-  {
+  for (up = *upp; up; up = q) {
     q = up->next;
     pgp_free_sig (&up->sigs);
     FREE (&up->addr);
@@ -154,17 +148,16 @@ void pgp_free_uid (pgp_uid_t ** upp)
   *upp = NULL;
 }
 
-pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t parent)
+pgp_uid_t *pgp_copy_uids (pgp_uid_t * up, pgp_key_t parent)
 {
   pgp_uid_t *l = NULL;
   pgp_uid_t **lp = &l;
 
-  for (; up; up = up->next)
-  {
+  for (; up; up = up->next) {
     *lp = safe_calloc (1, sizeof (pgp_uid_t));
-    (*lp)->trust  = up->trust;
-    (*lp)->flags  = up->flags;
-    (*lp)->addr   = safe_strdup (up->addr);
+    (*lp)->trust = up->trust;
+    (*lp)->flags = up->flags;
+    (*lp)->addr = safe_strdup (up->addr);
     (*lp)->parent = parent;
     lp = &(*lp)->next;
   }
@@ -172,7 +165,7 @@ pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t parent)
   return l;
 }
 
-static void _pgp_free_key (pgp_key_t *kpp)
+static void _pgp_free_key (pgp_key_t * kpp)
 {
   pgp_key_t kp;
 
@@ -186,7 +179,7 @@ static void _pgp_free_key (pgp_key_t *kpp)
   FREE (kpp);
 }
 
-pgp_key_t pgp_remove_key (pgp_key_t *klist, pgp_key_t key)
+pgp_key_t pgp_remove_key (pgp_key_t * klist, pgp_key_t key)
 {
   pgp_key_t *last;
   pgp_key_t p, q, r;
@@ -214,7 +207,7 @@ pgp_key_t pgp_remove_key (pgp_key_t *klist, pgp_key_t key)
   return q;
 }
 
-void pgp_free_key (pgp_key_t *kpp)
+void pgp_free_key (pgp_key_t * kpp)
 {
   pgp_key_t p, q, r;
 
@@ -223,7 +216,7 @@ void pgp_free_key (pgp_key_t *kpp)
 
   if ((*kpp)->parent && (*kpp)->parent != *kpp)
     *kpp = (*kpp)->parent;
-  
+
   /* Order is important here:
    *
    * - First free all children.
@@ -232,10 +225,8 @@ void pgp_free_key (pgp_key_t *kpp)
    * - free ourselves.
    */
 
-  for (p = *kpp; p; p = q)
-  {
-    for (q = p->next; q && q->parent == p; q = r)
-    {
+  for (p = *kpp; p; p = q) {
+    for (q = p->next; q && q->parent == p; q = r) {
       r = q->next;
       _pgp_free_key (&q);
     }
@@ -247,4 +238,3 @@ void pgp_free_key (pgp_key_t *kpp)
 
   *kpp = NULL;
 }
-
index 9b2b5d5..4464fac 100644 (file)
--- a/pgplib.h
+++ b/pgplib.h
 #include "mutt_crypt.h"
 
 
-typedef struct pgp_signature
-{
+typedef struct pgp_signature {
   struct pgp_signature *next;
   unsigned char sigtype;
   unsigned long sid1;
   unsigned long sid2;
-}
-pgp_sig_t;
+} pgp_sig_t;
 
-struct pgp_keyinfo
-{
+struct pgp_keyinfo {
   char *keyid;
   struct pgp_uid *address;
   int flags;
@@ -44,28 +41,26 @@ struct pgp_keyinfo
   struct pgp_signature *sigs;
   struct pgp_keyinfo *next;
 
-  short fp_len;                          /* length of fingerprint.
-                                  * 20 for sha-1, 16 for md5.
-                                  */
-  unsigned char fingerprint[20];  /* large enough to hold SHA-1 and RIPEMD160
-                                     hashes (20 bytes), MD5 hashes just use the
-                                     first 16 bytes */
+  short fp_len;                 /* length of fingerprint.
+                                 * 20 for sha-1, 16 for md5.
+                                 */
+  unsigned char fingerprint[20];        /* large enough to hold SHA-1 and RIPEMD160
+                                           hashes (20 bytes), MD5 hashes just use the
+                                           first 16 bytes */
 };
+
 /* Note, that pgp_key_t is now pointer and declared in crypt.h */
 
-typedef struct pgp_uid
-{
+typedef struct pgp_uid {
   char *addr;
   short trust;
   int flags;
   struct pgp_keyinfo *parent;
   struct pgp_uid *next;
   struct pgp_signature *sigs;
-}
-pgp_uid_t;
+} pgp_uid_t;
 
-enum pgp_version
-{
+enum pgp_version {
   PGP_V2,
   PGP_V3,
   PGP_GPG,
@@ -76,14 +71,14 @@ enum pgp_version
 
 const char *pgp_pkalgbytype (unsigned char);
 
-pgp_key_t pgp_remove_key (pgp_key_t *, pgp_key_t );
-pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t );
+pgp_key_t pgp_remove_key (pgp_key_t *, pgp_key_t);
+pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t);
 
 short pgp_canencrypt (unsigned char);
 short pgp_cansign (unsigned char);
 short pgp_get_abilities (unsigned char);
 
-void pgp_free_key (pgp_key_t *kpp);
+void pgp_free_key (pgp_key_t * kpp);
 
 #define pgp_new_keyinfo() safe_calloc (sizeof *((pgp_key_t)0), 1)
 
index fb8d410..e178bfa 100644 (file)
 #include <string.h>
 #include <ctype.h>
 
-static struct 
-{
+static struct {
   short id;
   const char *name;
-} 
-HashAlgorithms[] = 
-{
-  { 1,         "pgp-md5"               },
-  { 2,         "pgp-sha1"              },
-  { 3,         "pgp-ripemd160"         },
-  { 5,         "pgp-md2"               },
-  { 6,         "pgp-tiger192"          },
-  { 7,         "pgp-haval-5-160"       },
-  { 8,         "pgp-sha256"            },
-  { 9,         "pgp-sha384"            },
-  { 10,                "pgp-sha512"            },
-  { -1,        NULL }
+} HashAlgorithms[] = {
+  {
+  1, "pgp-md5"}, {
+  2, "pgp-sha1"}, {
+  3, "pgp-ripemd160"}, {
+  5, "pgp-md2"}, {
+  6, "pgp-tiger192"}, {
+  7, "pgp-haval-5-160"}, {
+  8, "pgp-sha256"}, {
+  9, "pgp-sha384"}, {
+  10, "pgp-sha512"}, {
+  -1, NULL}
 };
 
 static const char *pgp_hash_to_micalg (short id)
 {
   int i;
-  
+
   for (i = 0; HashAlgorithms[i].id >= 0; i++)
     if (HashAlgorithms[i].id == id)
       return HashAlgorithms[i].name;
   return "x-unknown";
 }
 
-static void pgp_dearmor (FILE *in, FILE *out)
+static void pgp_dearmor (FILE * in, FILE * out)
 {
   char line[HUGE_STRING];
   long start;
@@ -73,86 +71,78 @@ static void pgp_dearmor (FILE *in, FILE *out)
   char *r;
 
   STATE state;
-  
+
   memset (&state, 0, sizeof (STATE));
   state.fpin = in;
   state.fpout = out;
-  
+
   /* find the beginning of ASCII armor */
-  
-  while ((r = fgets (line, sizeof (line), in)) != NULL)
-  {
+
+  while ((r = fgets (line, sizeof (line), in)) != NULL) {
     if (!strncmp (line, "-----BEGIN", 10))
       break;
   }
-  if (r == NULL)
-  {
-    dprint (1, (debugfile, "pgp_dearmor: Can't find begin of ASCII armor.\n"));
+  if (r == NULL) {
+    dprint (1,
+            (debugfile, "pgp_dearmor: Can't find begin of ASCII armor.\n"));
     return;
   }
 
   /* skip the armor header */
-  
-  while ((r = fgets (line, sizeof (line), in)) != NULL)
-  {
+
+  while ((r = fgets (line, sizeof (line), in)) != NULL) {
     SKIPWS (r);
-    if (!*r) break;
+    if (!*r)
+      break;
   }
-  if (r == NULL)
-  {
+  if (r == NULL) {
     dprint (1, (debugfile, "pgp_dearmor: Armor header doesn't end.\n"));
     return;
   }
-  
+
   /* actual data starts here */
   start = ftell (in);
-  
+
   /* find the checksum */
-  
-  while ((r = fgets (line, sizeof (line), in)) != NULL)
-  {
+
+  while ((r = fgets (line, sizeof (line), in)) != NULL) {
     if (*line == '=' || !strncmp (line, "-----END", 8))
       break;
   }
-  if (r == NULL)
-  {
+  if (r == NULL) {
     dprint (1, (debugfile, "pgp_dearmor: Can't find end of ASCII armor.\n"));
     return;
   }
-  
-  if ((end = ftell (in) - strlen (line)) < start)
-  {
+
+  if ((end = ftell (in) - strlen (line)) < start) {
     dprint (1, (debugfile, "pgp_dearmor: end < start???\n"));
     return;
   }
-  
-  if (fseek (in, start, SEEK_SET) == -1)
-  {
+
+  if (fseek (in, start, SEEK_SET) == -1) {
     dprint (1, (debugfile, "pgp_dearmor: Can't seekto start.\n"));
     return;
   }
 
-  mutt_decode_base64 (&state, end - start, 0, (iconv_t) -1);
+  mutt_decode_base64 (&state, end - start, 0, (iconv_t) - 1);
 }
 
 static short pgp_mic_from_packet (unsigned char *p, size_t len)
 {
   /* is signature? */
-  if ((p[0] & 0x3f) != PT_SIG)
-  {
+  if ((p[0] & 0x3f) != PT_SIG) {
     dprint (1, (debugfile, "pgp_mic_from_packet: tag = %d, want %d.\n",
-               p[0]&0x3f, PT_SIG));
+                p[0] & 0x3f, PT_SIG));
     return -1;
   }
-  
+
   if (len >= 18 && p[1] == 3)
     /* version 3 signature */
     return (short) p[17];
   else if (len >= 5 && p[1] == 4)
     /* version 4 signature */
     return (short) p[4];
-  else
-  {
+  else {
     dprint (1, (debugfile, "pgp_mic_from_packet: Bad signature packet.\n"));
     return -1;
   }
@@ -162,42 +152,38 @@ static short pgp_find_hash (const char *fname)
 {
   FILE *in = NULL;
   FILE *out = NULL;
-  
+
   char tempfile[_POSIX_PATH_MAX];
-  
+
   unsigned char *p;
   size_t l;
-  
+
   short rv = -1;
-  
+
   mutt_mktemp (tempfile);
-  if ((out = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((out = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     goto bye;
   }
   unlink (tempfile);
-  
-  if ((in = fopen (fname, "r")) == NULL)
-  {
+
+  if ((in = fopen (fname, "r")) == NULL) {
     mutt_perror (fname);
     goto bye;
   }
-  
+
   pgp_dearmor (in, out);
   rewind (out);
 
-  if ((p = pgp_read_packet (out, &l)) != NULL)
-  {
+  if ((p = pgp_read_packet (out, &l)) != NULL) {
     rv = pgp_mic_from_packet (p, l);
   }
-  else
-  {
+  else {
     dprint (1, (debugfile, "pgp_find_hash: No packet.\n"));
   }
-  
-  bye:
-  
+
+bye:
+
   safe_fclose (&in);
   safe_fclose (&out);
   pgp_release_packet ();
@@ -208,4 +194,3 @@ const char *pgp_micalg (const char *fname)
 {
   return pgp_hash_to_micalg (pgp_find_hash (fname));
 }
-
index 8a4e11e..3fd6ff3 100644 (file)
@@ -39,15 +39,13 @@ static size_t plen = 0;
 
 static int read_material (size_t material, size_t * used, FILE * fp)
 {
-  if (*used + material >= plen)
-  {
+  if (*used + material >= plen) {
     unsigned char *p;
     size_t nplen;
 
     nplen = *used + material + CHUNKSIZE;
 
-    if (!(p = realloc (pbuf, nplen)))  /* __MEM_CHECKED__ */
-    {
+    if (!(p = realloc (pbuf, nplen))) { /* __MEM_CHECKED__ */
       perror ("realloc");
       return -1;
     }
@@ -55,8 +53,7 @@ static int read_material (size_t material, size_t * used, FILE * fp)
     pbuf = p;
   }
 
-  if (fread (pbuf + *used, 1, material, fp) < material)
-  {
+  if (fread (pbuf + *used, 1, material, fp) < material) {
     perror ("fread");
     return -1;
   }
@@ -75,82 +72,73 @@ unsigned char *pgp_read_packet (FILE * fp, size_t * len)
 
   startpos = ftell (fp);
 
-  if (!plen)
-  {
+  if (!plen) {
     plen = CHUNKSIZE;
     pbuf = safe_malloc (plen);
   }
 
-  if (fread (&ctb, 1, 1, fp) < 1)
-  {
+  if (fread (&ctb, 1, 1, fp) < 1) {
     if (!feof (fp))
       perror ("fread");
     goto bail;
   }
 
-  if (!(ctb & 0x80))
-  {
+  if (!(ctb & 0x80)) {
     goto bail;
   }
 
-  if (ctb & 0x40)              /* handle PGP 5.0 packets. */
-  {
+  if (ctb & 0x40) {             /* handle PGP 5.0 packets. */
     int partial = 0;
+
     pbuf[0] = ctb;
     used++;
 
-    do
-    {
-      if (fread (&b, 1, 1, fp) < 1)
-      {
-       perror ("fread");
-       goto bail;
+    do {
+      if (fread (&b, 1, 1, fp) < 1) {
+        perror ("fread");
+        goto bail;
       }
 
-      if (b < 192)
-      {
-       material = b;
-       partial = 0;
-       /* material -= 1; */
+      if (b < 192) {
+        material = b;
+        partial = 0;
+        /* material -= 1; */
       }
-      else if (192 <= b && b <= 223)
-      {
-       material = (b - 192) * 256;
-       if (fread (&b, 1, 1, fp) < 1)
-       {
-         perror ("fread");
-         goto bail;
-       }
-       material += b + 192;
-       partial = 0;
-       /* material -= 2; */
+      else if (192 <= b && b <= 223) {
+        material = (b - 192) * 256;
+        if (fread (&b, 1, 1, fp) < 1) {
+          perror ("fread");
+          goto bail;
+        }
+        material += b + 192;
+        partial = 0;
+        /* material -= 2; */
       }
-      else if (b < 255)
-      {
-       material = 1 << (b & 0x1f);
-       partial = 1;
-       /* material -= 1; */
+      else if (b < 255) {
+        material = 1 << (b & 0x1f);
+        partial = 1;
+        /* material -= 1; */
       }
       else
-       /* b == 255 */
+        /* b == 255 */
       {
-       unsigned char buf[4];
-       if (fread (buf, 4, 1, fp) < 1)
-       {
-         perror ("fread");
-         goto bail;
-       }
-       /*assert( sizeof(material) >= 4 ); */
-       material = buf[0] << 24;
-       material |= buf[1] << 16;
-       material |= buf[2] << 8;
-       material |= buf[3];
-       partial = 0;
-       /* material -= 5; */
+        unsigned char buf[4];
+
+        if (fread (buf, 4, 1, fp) < 1) {
+          perror ("fread");
+          goto bail;
+        }
+        /*assert( sizeof(material) >= 4 ); */
+        material = buf[0] << 24;
+        material |= buf[1] << 16;
+        material |= buf[2] << 8;
+        material |= buf[3];
+        partial = 0;
+        /* material -= 5; */
       }
 
       if (read_material (material, &used, fp) == -1)
-       goto bail;
+        goto bail;
 
     }
     while (partial);
@@ -159,49 +147,46 @@ unsigned char *pgp_read_packet (FILE * fp, size_t * len)
     /* Old-Style PGP */
   {
     int bytes = 0;
+
     pbuf[0] = 0x80 | ((ctb >> 2) & 0x0f);
     used++;
 
-    switch (ctb & 0x03)
-    {
-      case 0:
+    switch (ctb & 0x03) {
+    case 0:
       {
-       if (fread (&b, 1, 1, fp) < 1)
-       {
-         perror ("fread");
-         goto bail;
-       }
-
-       material = b;
-       break;
+        if (fread (&b, 1, 1, fp) < 1) {
+          perror ("fread");
+          goto bail;
+        }
+
+        material = b;
+        break;
       }
 
-      case 1:
+    case 1:
       bytes = 2;
 
-      case 2:
+    case 2:
       {
-       int i;
+        int i;
 
-       if (!bytes)
-         bytes = 4;
+        if (!bytes)
+          bytes = 4;
 
-       material = 0;
+        material = 0;
 
-       for (i = 0; i < bytes; i++)
-       {
-         if (fread (&b, 1, 1, fp) < 1)
-         {
-           perror ("fread");
-           goto bail;
-         }
+        for (i = 0; i < bytes; i++) {
+          if (fread (&b, 1, 1, fp) < 1) {
+            perror ("fread");
+            goto bail;
+          }
 
-         material = (material << 8) + b;
-       }
-       break;
+          material = (material << 8) + b;
+        }
+        break;
       }
 
-      default:
+    default:
       goto bail;
     }
 
@@ -225,4 +210,3 @@ void pgp_release_packet (void)
   plen = 0;
   FREE (&pbuf);
 }
-
index 4b7fd64..5f63c98 100644 (file)
 #ifndef _PGPPACKET_H
 # define _PGPPACKET_H
 
-enum packet_tags
-{
-  PT_RES0 = 0,                 /* reserved */
-  PT_ESK,                      /* Encrypted Session Key */
-  PT_SIG,                      /* Signature Packet */
-  PT_CESK,                     /* Conventionally Encrypted Session Key Packet */
-  PT_OPS,                      /* One-Pass Signature Packet */
-  PT_SECKEY,                   /* Secret Key Packet */
-  PT_PUBKEY,                   /* Public Key Packet */
-  PT_SUBSECKEY,                        /* Secret Subkey Packet */
-  PT_COMPRESSED,               /* Compressed Data Packet */
-  PT_SKE,                      /* Symmetrically Encrypted Data Packet */
-  PT_MARKER,                   /* Marker Packet */
-  PT_LITERAL,                  /* Literal Data Packet */
-  PT_TRUST,                    /* Trust Packet */
-  PT_NAME,                     /* Name Packet */
-  PT_SUBKEY,                   /* Subkey Packet */
-  PT_RES15,                    /* Reserved */
-  PT_COMMENT                   /* Comment Packet */
+enum packet_tags {
+  PT_RES0 = 0,                  /* reserved */
+  PT_ESK,                       /* Encrypted Session Key */
+  PT_SIG,                       /* Signature Packet */
+  PT_CESK,                      /* Conventionally Encrypted Session Key Packet */
+  PT_OPS,                       /* One-Pass Signature Packet */
+  PT_SECKEY,                    /* Secret Key Packet */
+  PT_PUBKEY,                    /* Public Key Packet */
+  PT_SUBSECKEY,                 /* Secret Subkey Packet */
+  PT_COMPRESSED,                /* Compressed Data Packet */
+  PT_SKE,                       /* Symmetrically Encrypted Data Packet */
+  PT_MARKER,                    /* Marker Packet */
+  PT_LITERAL,                   /* Literal Data Packet */
+  PT_TRUST,                     /* Trust Packet */
+  PT_NAME,                      /* Name Packet */
+  PT_SUBKEY,                    /* Subkey Packet */
+  PT_RES15,                     /* Reserved */
+  PT_COMMENT                    /* Comment Packet */
 };
 
 unsigned char *pgp_read_packet (FILE * fp, size_t * len);
index 5c0a2ba..7e62d83 100644 (file)
@@ -51,7 +51,7 @@
 extern char *optarg;
 extern int optind;
 
-short Umask; /* dirty hack because we need Umask in lib.c but don't want globals.h there */
+short Umask;                    /* dirty hack because we need Umask in lib.c but don't want globals.h there */
 
 #include "sha1.h"
 #include "md5.h"
@@ -74,87 +74,89 @@ static short dump_signatures = 0;
 static short dump_fingerprints = 0;
 
 
-static void pgpring_find_candidates (char *ringfile, const char *hints[], int nhints);
+static void pgpring_find_candidates (char *ringfile, const char *hints[],
+                                     int nhints);
 static void pgpring_dump_keyblock (pgp_key_t p);
 
-int main (int argc, char * const argv[])
+int main (int argc, char *const argv[])
 {
   int c;
-  
+
   short version = 2;
   short secring = 0;
-  
+
   const char *_kring = NULL;
   char *env_pgppath, *env_home;
 
   char pgppath[_POSIX_PATH_MAX];
   char kring[_POSIX_PATH_MAX];
 
-  while ((c = getopt (argc, argv, "f25sk:S")) != EOF)
-  {
-    switch (c)
-    {
-      case 'S':
+  while ((c = getopt (argc, argv, "f25sk:S")) != EOF) {
+    switch (c) {
+    case 'S':
       {
-       dump_signatures = 1;
-       break;
+        dump_signatures = 1;
+        break;
       }
 
-      case 'f':
+    case 'f':
       {
-       dump_fingerprints = 1;
-       break;
+        dump_fingerprints = 1;
+        break;
       }
 
-      case 'k':
+    case 'k':
       {
-       _kring = optarg;
-       break;
+        _kring = optarg;
+        break;
       }
-      
-      case '2': case '5':
+
+    case '2':
+    case '5':
       {
-       version = c - '0';
-       break;
+        version = c - '0';
+        break;
       }
-      
-      case 's':
+
+    case 's':
       {
-       secring = 1;
-       break;
+        secring = 1;
+        break;
       }
-    
-      default:
+
+    default:
       {
-       fprintf (stderr, "usage: %s [-k <key ring> | [-2 | -5] [ -s] [-S] [-f]] [hints]\n",
-                argv[0]);
-       exit (1);
+        fprintf (stderr,
+                 "usage: %s [-k <key ring> | [-2 | -5] [ -s] [-S] [-f]] [hints]\n",
+                 argv[0]);
+        exit (1);
       }
     }
   }
 
   if (_kring)
     strfcpy (kring, _kring, sizeof (kring));
-  else
-  {
+  else {
     if ((env_pgppath = getenv ("PGPPATH")))
       strfcpy (pgppath, env_pgppath, sizeof (pgppath));
     else if ((env_home = getenv ("HOME")))
       snprintf (pgppath, sizeof (pgppath), "%s/.pgp", env_home);
-    else
-    {
+    else {
       fprintf (stderr, "%s: Can't determine your PGPPATH.\n", argv[0]);
       exit (1);
     }
-    
+
     if (secring)
-      snprintf (kring, sizeof (kring), "%s/secring.%s", pgppath, version == 2 ? "pgp" : "skr");
+      snprintf (kring, sizeof (kring), "%s/secring.%s", pgppath,
+                version == 2 ? "pgp" : "skr");
     else
-      snprintf (kring, sizeof (kring), "%s/pubring.%s", pgppath, version == 2 ? "pgp" : "pkr");
+      snprintf (kring, sizeof (kring), "%s/pubring.%s", pgppath,
+                version == 2 ? "pgp" : "pkr");
   }
-  
-  pgpring_find_candidates (kring, (const char**) argv + optind, argc - optind);
-    
+
+  pgpring_find_candidates (kring, (const char **) argv + optind,
+                           argc - optind);
+
   return 0;
 }
 
@@ -186,7 +188,7 @@ static void pgp_make_pgp2_fingerprint (unsigned char *buff,
 
   MD5Final (digest, &context);
 
-} /* pgp_make_pgp2_fingerprint() */
+}                               /* pgp_make_pgp2_fingerprint() */
 
 static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l)
 {
@@ -204,7 +206,7 @@ static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l)
   if (l < 12)
     return NULL;
 
-  p = pgp_new_keyinfo();
+  p = pgp_new_keyinfo ();
 
   for (i = 0, j = 2; i < 4; i++)
     gen_time = (gen_time << 8) + buff[j++];
@@ -223,16 +225,15 @@ static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l)
   p->algorithm = pgp_pkalgbytype (alg);
   p->flags |= pgp_get_abilities (alg);
 
-  if (dump_fingerprints)
-  {
+  if (dump_fingerprints) {
     /* j now points to the key material, which we need for the fingerprint */
     p->fp_len = MD5_DIGEST_LENGTH;
     pgp_make_pgp2_fingerprint (&buff[j], digest);
     memcpy (p->fingerprint, digest, MD5_DIGEST_LENGTH);
   }
-  else /* just to be usre */
+  else                          /* just to be usre */
     memset (p->fingerprint, 0, MD5_DIGEST_LENGTH);
-    
+
   expl = 0;
   for (i = 0; i < 2; i++)
     expl = (expl << 8) + buff[j++];
@@ -246,13 +247,12 @@ static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l)
 
   j += expl - 8;
 
-  for (k = 0; k < 2; k++)
-  {
+  for (k = 0; k < 2; k++) {
     for (id = 0, i = 0; i < 4; i++)
       id = (id << 8) + buff[j++];
 
     snprintf ((char *) scratch + k * 8, sizeof (scratch) - k * 8,
-             "%08lX", id);
+              "%08lX", id);
   }
 
   p->keyid = safe_strdup ((char *) scratch);
@@ -266,7 +266,7 @@ bailout:
 }
 
 static void pgp_make_pgp3_fingerprint (unsigned char *buff, size_t l,
-                                      unsigned char *digest)
+                                       unsigned char *digest)
 {
   unsigned char dummy;
   SHA1_CTX context;
@@ -290,12 +290,11 @@ static void pgp_make_pgp3_fingerprint (unsigned char *buff, size_t l,
 }
 
 static void skip_bignum (unsigned char *buff, size_t l, size_t j,
-                        size_t * toff, size_t n)
+                         size_t * toff, size_t n)
 {
   size_t len;
 
-  do
-  {
+  do {
     len = (buff[j] << 8) + buff[j + 1];
     j += (len + 7) / 8 + 2;
   }
@@ -348,14 +347,14 @@ static pgp_key_t pgp_parse_pgp3_key (unsigned char *buff, size_t l)
 
   pgp_make_pgp3_fingerprint (buff, j, digest);
   p->fp_len = SHA_DIGEST_LENGTH;
-  
-  for (k = 0; k < 2; k++)
-  {
+
+  for (k = 0; k < 2; k++) {
     for (id = 0, i = SHA_DIGEST_LENGTH - 8 + k * 4;
-        i < SHA_DIGEST_LENGTH + (k - 1) * 4; i++)
+         i < SHA_DIGEST_LENGTH + (k - 1) * 4; i++)
       id = (id << 8) + digest[i];
 
-    snprintf ((char *) scratch + k * 8, sizeof (scratch) - k * 8, "%08lX", id);
+    snprintf ((char *) scratch + k * 8, sizeof (scratch) - k * 8, "%08lX",
+              id);
   }
 
   p->keyid = safe_strdup ((char *) scratch);
@@ -368,8 +367,7 @@ static pgp_key_t pgp_parse_keyinfo (unsigned char *buff, size_t l)
   if (!buff || l < 2)
     return NULL;
 
-  switch (buff[1])
-  {
+  switch (buff[1]) {
   case 2:
   case 3:
     return pgp_parse_pgp2_key (buff, l);
@@ -381,7 +379,7 @@ static pgp_key_t pgp_parse_keyinfo (unsigned char *buff, size_t l)
 }
 
 static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l,
-                               pgp_key_t p, pgp_sig_t *s)
+                               pgp_key_t p, pgp_sig_t * s)
 {
   unsigned char sigtype;
   time_t sig_gen_time;
@@ -407,22 +405,21 @@ static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l,
   for (i = 0; i < 4; i++)
     signerid2 = (signerid2 << 8) + buff[j++];
 
-  
+
   if (sigtype == 0x20 || sigtype == 0x28)
     p->flags |= KEYFLAG_REVOKED;
 
-  if (s)
-  {
+  if (s) {
     s->sigtype = sigtype;
-    s->sid1    = signerid1;
-    s->sid2    = signerid2;
+    s->sid1 = signerid1;
+    s->sid2 = signerid2;
   }
-  
+
   return 0;
 }
 
 static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l,
-                               pgp_key_t p, pgp_sig_t *s)
+                               pgp_key_t p, pgp_sig_t * s)
 {
   unsigned char sigtype;
   unsigned char pkalg;
@@ -448,8 +445,7 @@ static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l,
   pkalg = buff[j++];
   hashalg = buff[j++];
 
-  for (ii = 0; ii < 2; ii++)
-  {
+  for (ii = 0; ii < 2; ii++) {
     size_t skl;
     size_t nextone;
 
@@ -460,87 +456,84 @@ static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l,
       break;
 
     nextone = j;
-    while (ml)
-    {
+    while (ml) {
       j = nextone;
       skl = buff[j++];
       if (!--ml)
-       break;
+        break;
 
-      if (skl >= 192)
-      {
-       skl = (skl - 192) * 256 + buff[j++] + 192;
-       if (!--ml)
-         break;
+      if (skl >= 192) {
+        skl = (skl - 192) * 256 + buff[j++] + 192;
+        if (!--ml)
+          break;
       }
 
       if ((int) ml - (int) skl < 0)
-       break;
+        break;
       ml -= skl;
 
       nextone = j + skl;
       skt = buff[j++];
 
-      switch (skt & 0x7f)
-      {
-       case 2:                 /* creation time */
-       {
-         if (skl < 4)
-           break;
-         sig_gen_time = 0;
-         for (i = 0; i < 4; i++)
-           sig_gen_time = (sig_gen_time << 8) + buff[j++];
-
-         break;
-       }
-       case 3:                 /* expiration time */
-       {
-         if (skl < 4)
-           break;
-         validity = 0;
-         for (i = 0; i < 4; i++)
-           validity = (validity << 8) + buff[j++];
-         break;
-       }
-       case 9:                 /* key expiration time */
-       {
-         if (skl < 4)
-           break;
-         key_validity = 0;
-         for (i = 0; i < 4; i++)
-           key_validity = (key_validity << 8) + buff[j++];
-         break;
-       }
-       case 16:                        /* issuer key ID */
-       {
-         if (skl < 8)
-           break;
-         signerid2 = signerid1 = 0;
-         for (i = 0; i < 4; i++)
-           signerid1 = (signerid1 << 8) + buff[j++];
-         for (i = 0; i < 4; i++)
-           signerid2 = (signerid2 << 8) + buff[j++];
-         
-         break;
-       }
-       case 10:                        /* CMR key */
-       break;
-       case 4:                         /* exportable */
-       case 5:                         /* trust */
-       case 6:                         /* regexp */
-       case 7:                         /* revocable */
-       case 11:                        /* Pref. symm. alg. */
-       case 12:                        /* revocation key */
-       case 20:                        /* notation data */
-       case 21:                        /* pref. hash */
-       case 22:                        /* pref. comp.alg. */
-       case 23:                        /* key server prefs. */
-       case 24:                        /* pref. key server */
-       default:
-       {
-         if (skt & 0x80)
-           have_critical_spks = 1;
-       }
+      switch (skt & 0x7f) {
+      case 2:                  /* creation time */
+        {
+          if (skl < 4)
+            break;
+          sig_gen_time = 0;
+          for (i = 0; i < 4; i++)
+            sig_gen_time = (sig_gen_time << 8) + buff[j++];
+
+          break;
+        }
+      case 3:                  /* expiration time */
+        {
+          if (skl < 4)
+            break;
+          validity = 0;
+          for (i = 0; i < 4; i++)
+            validity = (validity << 8) + buff[j++];
+          break;
+        }
+      case 9:                  /* key expiration time */
+        {
+          if (skl < 4)
+            break;
+          key_validity = 0;
+          for (i = 0; i < 4; i++)
+            key_validity = (key_validity << 8) + buff[j++];
+          break;
+        }
+      case 16:                 /* issuer key ID */
+        {
+          if (skl < 8)
+            break;
+          signerid2 = signerid1 = 0;
+          for (i = 0; i < 4; i++)
+            signerid1 = (signerid1 << 8) + buff[j++];
+          for (i = 0; i < 4; i++)
+            signerid2 = (signerid2 << 8) + buff[j++];
+
+          break;
+        }
+      case 10:                 /* CMR key */
+        break;
+      case 4:                  /* exportable */
+      case 5:                  /* trust */
+      case 6:                  /* regexp */
+      case 7:                  /* revocable */
+      case 11:                 /* Pref. symm. alg. */
+      case 12:                 /* revocation key */
+      case 20:                 /* notation data */
+      case 21:                 /* pref. hash */
+      case 22:                 /* pref. comp.alg. */
+      case 23:                 /* key server prefs. */
+      case 24:                 /* pref. key server */
+      default:
+        {
+          if (skt & 0x80)
+            have_critical_spks = 1;
+        }
       }
     }
     j = nextone;
@@ -553,30 +546,28 @@ static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l,
   if (have_critical_spks)
     p->flags |= KEYFLAG_CRITICAL;
 
-  if (s)
-  {
+  if (s) {
     s->sigtype = sigtype;
-    s->sid1    = signerid1;
-    s->sid2    = signerid2;
+    s->sid1 = signerid1;
+    s->sid2 = signerid2;
   }
 
-  
+
   return 0;
 
 }
 
 
 static int pgp_parse_sig (unsigned char *buff, size_t l,
-                          pgp_key_t p, pgp_sig_t *sig)
+                          pgp_key_t p, pgp_sig_t * sig)
 {
   if (!buff || l < 2 || !p)
     return -1;
 
-  switch (buff[1])
-  {
+  switch (buff[1]) {
   case 2:
   case 3:
-    return pgp_parse_pgp2_sig (buff, l, p, sig);      
+    return pgp_parse_pgp2_sig (buff, l, p, sig);
   case 4:
     return pgp_parse_pgp3_sig (buff, l, p, sig);
   default:
@@ -607,135 +598,127 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp)
   pgp_uid_t **addr = NULL;
   pgp_sig_t **lsig = NULL;
 
-  FGETPOS(fp,pos);
-  
-  while (!err && (buff = pgp_read_packet (fp, &l)) != NULL)
-  {
+  FGETPOS (fp, pos);
+
+  while (!err && (buff = pgp_read_packet (fp, &l)) != NULL) {
     last_pt = pt;
     pt = buff[0] & 0x3f;
 
     /* check if we have read the complete key block. */
-    
-    if ((pt == PT_SECKEY || pt == PT_PUBKEY) && root)
-    {
-      FSETPOS(fp, pos);
+
+    if ((pt == PT_SECKEY || pt == PT_PUBKEY) && root) {
+      FSETPOS (fp, pos);
       return root;
     }
-    
-    switch (pt)
-    {
-      case PT_SECKEY:
-      case PT_PUBKEY:
-      case PT_SUBKEY:
-      case PT_SUBSECKEY:
+
+    switch (pt) {
+    case PT_SECKEY:
+    case PT_PUBKEY:
+    case PT_SUBKEY:
+    case PT_SUBSECKEY:
       {
-       if (!(*last = p = pgp_parse_keyinfo (buff, l)))
-       {
-         err = 1;
-         break;
-       }
-
-       last = &p->next;
-       addr = &p->address;
-       lsig = &p->sigs;
-       
-       if (pt == PT_SUBKEY || pt == PT_SUBSECKEY)
-       {
-         p->flags |= KEYFLAG_SUBKEY;
-         if (p != root)
-         {
-           p->parent  = root;
-           p->address = pgp_copy_uids (root->address, p);
-           while (*addr) addr = &(*addr)->next;
-         }
-       }
-       
-       if (pt == PT_SECKEY || pt == PT_SUBSECKEY)
-         p->flags |= KEYFLAG_SECRET;
-
-       break;
+        if (!(*last = p = pgp_parse_keyinfo (buff, l))) {
+          err = 1;
+          break;
+        }
+
+        last = &p->next;
+        addr = &p->address;
+        lsig = &p->sigs;
+
+        if (pt == PT_SUBKEY || pt == PT_SUBSECKEY) {
+          p->flags |= KEYFLAG_SUBKEY;
+          if (p != root) {
+            p->parent = root;
+            p->address = pgp_copy_uids (root->address, p);
+            while (*addr)
+              addr = &(*addr)->next;
+          }
+        }
+
+        if (pt == PT_SECKEY || pt == PT_SUBSECKEY)
+          p->flags |= KEYFLAG_SECRET;
+
+        break;
       }
 
-      case PT_SIG:
+    case PT_SIG:
       {
-       if (lsig)
-       {
-         pgp_sig_t *signature = safe_calloc (sizeof (pgp_sig_t), 1);
-         *lsig = signature;
-         lsig = &signature->next;
-         
-         pgp_parse_sig (buff, l, p, signature);
-       }
-       break;
+        if (lsig) {
+          pgp_sig_t *signature = safe_calloc (sizeof (pgp_sig_t), 1);
+
+          *lsig = signature;
+          lsig = &signature->next;
+
+          pgp_parse_sig (buff, l, p, signature);
+        }
+        break;
       }
 
-      case PT_TRUST:
+    case PT_TRUST:
       {
-       if (p && (last_pt == PT_SECKEY || last_pt == PT_PUBKEY ||
-                 last_pt == PT_SUBKEY || last_pt == PT_SUBSECKEY))
-       {
-         if (buff[1] & 0x20)
-         {
-           p->flags |= KEYFLAG_DISABLED;
-         }
-       }
-       else if (last_pt == PT_NAME && uid)
-       {
-         uid->trust = buff[1];
-       }
-       break;
+        if (p && (last_pt == PT_SECKEY || last_pt == PT_PUBKEY ||
+                  last_pt == PT_SUBKEY || last_pt == PT_SUBSECKEY)) {
+          if (buff[1] & 0x20) {
+            p->flags |= KEYFLAG_DISABLED;
+          }
+        }
+        else if (last_pt == PT_NAME && uid) {
+          uid->trust = buff[1];
+        }
+        break;
       }
-      case PT_NAME:
+    case PT_NAME:
       {
-       char *chr;
+        char *chr;
+
 
+        if (!addr)
+          break;
 
-       if (!addr)
-         break;
+        chr = safe_malloc (l);
+        memcpy (chr, buff + 1, l - 1);
+        chr[l - 1] = '\0';
 
-       chr = safe_malloc (l);
-       memcpy (chr, buff + 1, l - 1);
-       chr[l - 1] = '\0';
 
+        *addr = uid = safe_calloc (1, sizeof (pgp_uid_t));      /* XXX */
+        uid->addr = chr;
+        uid->parent = p;
+        uid->trust = 0;
+        addr = &uid->next;
+        lsig = &uid->sigs;
 
-       *addr = uid = safe_calloc (1, sizeof (pgp_uid_t)); /* XXX */
-       uid->addr = chr;
-       uid->parent = p;
-       uid->trust = 0;
-       addr = &uid->next;
-       lsig = &uid->sigs;
-       
-       /* the following tags are generated by
-        * pgp 2.6.3in.
-        */
+        /* the following tags are generated by
+         * pgp 2.6.3in.
+         */
 
-       if (strstr (chr, "ENCR"))
-         p->flags |= KEYFLAG_PREFER_ENCRYPTION;
-       if (strstr (chr, "SIGN"))
-         p->flags |= KEYFLAG_PREFER_SIGNING;
+        if (strstr (chr, "ENCR"))
+          p->flags |= KEYFLAG_PREFER_ENCRYPTION;
+        if (strstr (chr, "SIGN"))
+          p->flags |= KEYFLAG_PREFER_SIGNING;
 
-       break;
+        break;
       }
     }
 
-    FGETPOS(fp,pos);
+    FGETPOS (fp, pos);
   }
 
   if (err)
     pgp_free_key (&root);
-  
-  return root;  
+
+  return root;
 }
 
-static int pgpring_string_matches_hint (const char *s, const char *hints[], int nhints)
+static int pgpring_string_matches_hint (const char *s, const char *hints[],
+                                        int nhints)
 {
   int i;
 
   if (!hints || !nhints)
     return 1;
 
-  for (i = 0; i < nhints; i++)
-  {
+  for (i = 0; i < nhints; i++) {
     if (mutt_stristr (s, hints[i]) != NULL)
       return 1;
   }
@@ -748,9 +731,11 @@ static int pgpring_string_matches_hint (const char *s, const char *hints[], int
  * matching IDs.
  */
 
-static void pgpring_find_candidates (char *ringfile, const char *hints[], int nhints)
+static void pgpring_find_candidates (char *ringfile, const char *hints[],
+                                     int nhints)
 {
   FILE *rfp;
+
 #ifdef HAVE_FGETPOS
   fpos_t pos, keypos;
 #else
@@ -762,9 +747,8 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
   size_t l = 0;
 
   short err = 0;
-  
-  if ((rfp = fopen (ringfile, "r")) == NULL)
-  {
+
+  if ((rfp = fopen (ringfile, "r")) == NULL) {
     char *error_buf;
     size_t error_buf_len;
 
@@ -776,22 +760,19 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
     return;
   }
 
-  FGETPOS(rfp,pos);
-  FGETPOS(rfp,keypos);
+  FGETPOS (rfp, pos);
+  FGETPOS (rfp, keypos);
 
-  while (!err && (buff = pgp_read_packet (rfp, &l)) != NULL)
-  {
+  while (!err && (buff = pgp_read_packet (rfp, &l)) != NULL) {
     pt = buff[0] & 0x3f;
-    
+
     if (l < 1)
       continue;
-    
-    if ((pt == PT_SECKEY) || (pt == PT_PUBKEY))
-    {
+
+    if ((pt == PT_SECKEY) || (pt == PT_PUBKEY)) {
       keypos = pos;
     }
-    else if (pt == PT_NAME)
-    {
+    else if (pt == PT_NAME) {
       char *tmp = safe_malloc (l);
 
       memcpy (tmp, buff + 1, l - 1);
@@ -799,25 +780,24 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
 
       /* mutt_decode_utf8_string (tmp, chs); */
 
-      if (pgpring_string_matches_hint (tmp, hints, nhints))
-      {
-       pgp_key_t p;
+      if (pgpring_string_matches_hint (tmp, hints, nhints)) {
+        pgp_key_t p;
 
-       FSETPOS(rfp, keypos);
+        FSETPOS (rfp, keypos);
 
-       /* Not bailing out here would lead us into an endless loop. */
+        /* Not bailing out here would lead us into an endless loop. */
 
-       if ((p = pgp_parse_keyblock (rfp)) == NULL)
-         err = 1;
-       
-       pgpring_dump_keyblock (p);
-       pgp_free_key (&p);
+        if ((p = pgp_parse_keyblock (rfp)) == NULL)
+          err = 1;
+
+        pgpring_dump_keyblock (p);
+        pgp_free_key (&p);
       }
 
       FREE (&tmp);
     }
 
-    FGETPOS(rfp,pos);
+    FGETPOS (rfp, pos);
   }
 
   fclose (rfp);
@@ -826,8 +806,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
 
 static void print_userid (const char *id)
 {
-  for (; id && *id; id++)
-  {
+  for (; id && *id; id++) {
     if (*id >= ' ' && *id <= 'z' && *id != ':')
       putchar (*id);
     else
@@ -835,7 +814,7 @@ static void print_userid (const char *id)
   }
 }
 
-static void print_fingerprint (pgp_key_t p) 
+static void print_fingerprint (pgp_key_t p)
 {
   int i = 0;
 
@@ -844,31 +823,32 @@ static void print_fingerprint (pgp_key_t p)
     printf ("%02X", p->fingerprint[i]);
   printf (":\n");
 
-} /* print_fingerprint() */
+}                               /* print_fingerprint() */
 
 
-static void pgpring_dump_signatures (pgp_sig_t *sig)
+static void pgpring_dump_signatures (pgp_sig_t * sig)
 {
-  for (; sig; sig = sig->next)
-  {
+  for (; sig; sig = sig->next) {
     if (sig->sigtype == 0x10 || sig->sigtype == 0x11 ||
-       sig->sigtype == 0x12 || sig->sigtype == 0x13)
+        sig->sigtype == 0x12 || sig->sigtype == 0x13)
       printf ("sig::::%08lX%08lX::::::%X:\n",
-             sig->sid1, sig->sid2, sig->sigtype);
+              sig->sid1, sig->sid2, sig->sigtype);
     else if (sig->sigtype == 0x20)
       printf ("rev::::%08lX%08lX::::::%X:\n",
-             sig->sid1, sig->sid2, sig->sigtype);
+              sig->sid1, sig->sid2, sig->sigtype);
   }
 }
 
 
 static char gnupg_trustletter (int t)
 {
-  switch (t)
-  {
-    case 1: return 'n';
-    case 2: return 'm';
-    case 3: return 'f';
+  switch (t) {
+  case 1:
+    return 'n';
+  case 2:
+    return 'm';
+  case 3:
+    return 'f';
   }
   return 'q';
 }
@@ -879,26 +859,23 @@ static void pgpring_dump_keyblock (pgp_key_t p)
   short first;
   struct tm *tp;
   time_t t;
-  
-  for (; p; p = p->next)
-  {
+
+  for (; p; p = p->next) {
     first = 1;
 
-    if (p->flags & KEYFLAG_SECRET)
-    {
+    if (p->flags & KEYFLAG_SECRET) {
       if (p->flags & KEYFLAG_SUBKEY)
-       printf ("ssb:");
+        printf ("ssb:");
       else
-       printf ("sec:");
+        printf ("sec:");
     }
-    else 
-    {
+    else {
       if (p->flags & KEYFLAG_SUBKEY)
-       printf ("sub:");
+        printf ("sub:");
       else
-       printf ("pub:");
+        printf ("pub:");
     }
-    
+
     if (p->flags & KEYFLAG_REVOKED)
       putchar ('r');
     if (p->flags & KEYFLAG_EXPIRED)
@@ -906,46 +883,43 @@ static void pgpring_dump_keyblock (pgp_key_t p)
     if (p->flags & KEYFLAG_DISABLED)
       putchar ('d');
 
-    for (uid = p->address; uid; uid = uid->next, first = 0)
-    {
-      if (!first)
-      {
-       printf ("uid:%c::::::::", gnupg_trustletter (uid->trust));
-       print_userid (uid->addr);
-       printf (":\n");
+    for (uid = p->address; uid; uid = uid->next, first = 0) {
+      if (!first) {
+        printf ("uid:%c::::::::", gnupg_trustletter (uid->trust));
+        print_userid (uid->addr);
+        printf (":\n");
       }
-      else
-      {
-       if (p->flags & KEYFLAG_SECRET)
-         putchar ('u');
-       else
-         putchar (gnupg_trustletter (uid->trust));
-
-       t = p->gen_time;
-       tp = gmtime (&t);
-
-       printf (":%d:%d:%s:%04d-%02d-%02d::::", p->keylen, p->numalg, p->keyid,
-               1900 + tp->tm_year, tp->tm_mon + 1, tp->tm_mday);
-       
-       print_userid (uid->addr);
-       printf ("::");
-
-       if(pgp_canencrypt(p->numalg))
-         putchar ('e');
-       if(pgp_cansign(p->numalg))
-         putchar ('s');
-       if (p->flags & KEYFLAG_DISABLED)
-         putchar ('D');
-       printf (":\n");
-
-       if (dump_fingerprints) 
+      else {
+        if (p->flags & KEYFLAG_SECRET)
+          putchar ('u');
+        else
+          putchar (gnupg_trustletter (uid->trust));
+
+        t = p->gen_time;
+        tp = gmtime (&t);
+
+        printf (":%d:%d:%s:%04d-%02d-%02d::::", p->keylen, p->numalg,
+                p->keyid, 1900 + tp->tm_year, tp->tm_mon + 1, tp->tm_mday);
+
+        print_userid (uid->addr);
+        printf ("::");
+
+        if (pgp_canencrypt (p->numalg))
+          putchar ('e');
+        if (pgp_cansign (p->numalg))
+          putchar ('s');
+        if (p->flags & KEYFLAG_DISABLED)
+          putchar ('D');
+        printf (":\n");
+
+        if (dump_fingerprints)
           print_fingerprint (p);
       }
-      
-      if (dump_signatures)
-      {
-       if (first) pgpring_dump_signatures (p->sigs);
-       pgpring_dump_signatures (uid->sigs);
+
+      if (dump_signatures) {
+        if (first)
+          pgpring_dump_signatures (p->sigs);
+        pgpring_dump_signatures (uid->sigs);
       }
     }
   }
@@ -958,5 +932,5 @@ static void pgpring_dump_keyblock (pgp_key_t p)
 
 char *mutt_gettext (const char *message)
 {
-  return (char *)message;
+  return (char *) message;
 }
diff --git a/pop.c b/pop.c
index 7136ab0..cb35c70 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -48,7 +48,7 @@ static int fetch_message (char *line, void *file)
  * -2 - invalid command or execution error,
  * -3 - error writing to tempfile
  */
-static int pop_read_header (POP_DATA *pop_data, HEADER *h)
+static int pop_read_header (POP_DATA * pop_data, HEADER * h)
 {
   FILE *f;
   int ret, index;
@@ -57,64 +57,58 @@ static int pop_read_header (POP_DATA *pop_data, HEADER *h)
   char tempfile[_POSIX_PATH_MAX];
 
   mutt_mktemp (tempfile);
-  if (!(f = safe_fopen (tempfile, "w+")))
-  {
+  if (!(f = safe_fopen (tempfile, "w+"))) {
     mutt_perror (tempfile);
     return -3;
   }
 
   snprintf (buf, sizeof (buf), "LIST %d\r\n", h->refno);
   ret = pop_query (pop_data, buf, sizeof (buf));
-  if (ret == 0)
-  {
+  if (ret == 0) {
     sscanf (buf, "+OK %d %ld", &index, &length);
 
     snprintf (buf, sizeof (buf), "TOP %d 0\r\n", h->refno);
     ret = pop_fetch_data (pop_data, buf, NULL, fetch_message, f);
 
-    if (pop_data->cmd_top == 2)
-    {
-      if (ret == 0)
-      {
-       pop_data->cmd_top = 1;
+    if (pop_data->cmd_top == 2) {
+      if (ret == 0) {
+        pop_data->cmd_top = 1;
 
-       dprint (1, (debugfile, "pop_read_header: set TOP capability\n"));
+        dprint (1, (debugfile, "pop_read_header: set TOP capability\n"));
       }
 
-      if (ret == -2)
-      {
-       pop_data->cmd_top = 0;
+      if (ret == -2) {
+        pop_data->cmd_top = 0;
 
-       dprint (1, (debugfile, "pop_read_header: unset TOP capability\n"));
-       snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
-               _("Command TOP is not supported by server."));
+        dprint (1, (debugfile, "pop_read_header: unset TOP capability\n"));
+        snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
+                  _("Command TOP is not supported by server."));
       }
     }
   }
 
-  switch (ret)
-  {
-    case 0:
+  switch (ret) {
+  case 0:
     {
       rewind (f);
       h->env = mutt_read_rfc822_header (f, h, 0, 0);
       h->content->length = length - h->content->offset + 1;
       rewind (f);
-      while (!feof (f))
-      {
-       h->content->length--;
-       fgets (buf, sizeof (buf), f);
+      while (!feof (f)) {
+        h->content->length--;
+        fgets (buf, sizeof (buf), f);
       }
       break;
     }
-    case -2:
+  case -2:
     {
       mutt_error ("%s", pop_data->err_msg);
       break;
     }
-    case -3:
+  case -3:
     {
       mutt_error _("Can't write header to temporary file!");
+
       break;
     }
   }
@@ -128,20 +122,21 @@ static int pop_read_header (POP_DATA *pop_data, HEADER *h)
 static int fetch_uidl (char *line, void *data)
 {
   int i, index;
-  CONTEXT *ctx = (CONTEXT *)data;
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  CONTEXT *ctx = (CONTEXT *) data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   sscanf (line, "%d %s", &index, line);
   for (i = 0; i < ctx->msgcount; i++)
     if (!mutt_strcmp (line, ctx->hdrs[i]->data))
       break;
 
-  if (i == ctx->msgcount)
-  {
-    dprint (1, (debugfile, "pop_fetch_headers: new header %d %s\n", index, line));
+  if (i == ctx->msgcount) {
+    dprint (1,
+            (debugfile, "pop_fetch_headers: new header %d %s\n", index,
+             line));
 
     if (i >= ctx->hdrmax)
-      mx_alloc_memory(ctx);
+      mx_alloc_memory (ctx);
 
     ctx->msgcount++;
     ctx->hdrs[i] = mutt_new_header ();
@@ -164,10 +159,10 @@ static int fetch_uidl (char *line, void *data)
  * -2 - invalid command or execution error,
  * -3 - error writing to tempfile
  */
-static int pop_fetch_headers (CONTEXT *ctx)
+static int pop_fetch_headers (CONTEXT * ctx)
 {
   int i, ret, old_count, new_count;
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   time (&pop_data->check_time);
   pop_data->clear_cache = 0;
@@ -180,39 +175,34 @@ static int pop_fetch_headers (CONTEXT *ctx)
   new_count = ctx->msgcount;
   ctx->msgcount = old_count;
 
-  if (pop_data->cmd_uidl == 2)
-  {
-    if (ret == 0)
-    {
+  if (pop_data->cmd_uidl == 2) {
+    if (ret == 0) {
       pop_data->cmd_uidl = 1;
 
       dprint (1, (debugfile, "pop_fetch_headers: set UIDL capability\n"));
     }
 
-    if (ret == -2 && pop_data->cmd_uidl == 2)
-    {
+    if (ret == -2 && pop_data->cmd_uidl == 2) {
       pop_data->cmd_uidl = 0;
 
       dprint (1, (debugfile, "pop_fetch_headers: unset UIDL capability\n"));
       snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
-             _("Command UIDL is not supported by server."));
+                _("Command UIDL is not supported by server."));
     }
   }
 
-  if (ret == 0)
-  {
+  if (ret == 0) {
     for (i = 0; i < old_count; i++)
       if (ctx->hdrs[i]->refno == -1)
-       ctx->hdrs[i]->deleted = 1;
+        ctx->hdrs[i]->deleted = 1;
 
-    for (i = old_count; i < new_count; i++)
-    {
+    for (i = old_count; i < new_count; i++) {
       mutt_message (_("Fetching message headers... [%d/%d]"),
-                   i + 1 - old_count, new_count - old_count);
+                    i + 1 - old_count, new_count - old_count);
 
       ret = pop_read_header (pop_data, ctx->hdrs[i]);
       if (ret < 0)
-       break;
+        break;
 
       ctx->msgcount++;
     }
@@ -221,8 +211,7 @@ static int pop_fetch_headers (CONTEXT *ctx)
       mx_update_context (ctx, i - old_count);
   }
 
-  if (ret < 0)
-  {
+  if (ret < 0) {
     for (i = ctx->msgcount; i < new_count; i++)
       mutt_free_header (&ctx->hdrs[i]);
     return ret;
@@ -233,7 +222,7 @@ static int pop_fetch_headers (CONTEXT *ctx)
 }
 
 /* open POP mailbox - fetch only headers */
-int pop_open_mailbox (CONTEXT *ctx)
+int pop_open_mailbox (CONTEXT * ctx)
 {
   int ret;
   char buf[LONG_STRING];
@@ -242,8 +231,7 @@ int pop_open_mailbox (CONTEXT *ctx)
   POP_DATA *pop_data;
   ciss_url_t url;
 
-  if (pop_parse_path (ctx->path, &acct))
-  {
+  if (pop_parse_path (ctx->path, &acct)) {
     mutt_error (_("%s is an invalid POP path"), ctx->path);
     mutt_sleep (2);
     return -1;
@@ -268,8 +256,7 @@ int pop_open_mailbox (CONTEXT *ctx)
 
   conn->data = pop_data;
 
-  FOREVER
-  {
+  FOREVER {
     if (pop_reconnect (ctx) < 0)
       return -1;
 
@@ -282,8 +269,7 @@ int pop_open_mailbox (CONTEXT *ctx)
     if (ret >= 0)
       return 0;
 
-    if (ret < -1)
-    {
+    if (ret < -1) {
       mutt_sleep (2);
       return -1;
     }
@@ -291,7 +277,7 @@ int pop_open_mailbox (CONTEXT *ctx)
 }
 
 /* delete all cached messages */
-static void pop_clear_cache (POP_DATA *pop_data)
+static void pop_clear_cache (POP_DATA * pop_data)
 {
   int i;
 
@@ -300,10 +286,8 @@ static void pop_clear_cache (POP_DATA *pop_data)
 
   dprint (1, (debugfile, "pop_clear_cache: delete cached messages\n"));
 
-  for (i = 0; i < POP_CACHE_LEN; i++)
-  {
-    if (pop_data->cache[i].path)
-    {
+  for (i = 0; i < POP_CACHE_LEN; i++) {
+    if (pop_data->cache[i].path) {
       unlink (pop_data->cache[i].path);
       FREE (&pop_data->cache[i].path);
     }
@@ -311,9 +295,9 @@ static void pop_clear_cache (POP_DATA *pop_data)
 }
 
 /* close POP mailbox */
-void pop_close_mailbox (CONTEXT *ctx)
+void pop_close_mailbox (CONTEXT * ctx)
 {
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   if (!pop_data)
     return;
@@ -335,50 +319,46 @@ void pop_close_mailbox (CONTEXT *ctx)
 }
 
 /* fetch message from POP server */
-int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
+int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
 {
   int ret;
   void *uidl;
   char buf[LONG_STRING];
   char path[_POSIX_PATH_MAX];
   char *m = _("Fetching message...");
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
   POP_CACHE *cache;
   HEADER *h = ctx->hdrs[msgno];
 
   /* see if we already have the message in our cache */
   cache = &pop_data->cache[h->index % POP_CACHE_LEN];
 
-  if (cache->path)
-  {
-    if (cache->index == h->index)
-    {
+  if (cache->path) {
+    if (cache->index == h->index) {
       /* yes, so just return a pointer to the message */
       msg->fp = fopen (cache->path, "r");
       if (msg->fp)
-       return 0;
+        return 0;
 
       mutt_perror (cache->path);
       mutt_sleep (2);
       return -1;
     }
-    else
-    {
+    else {
       /* clear the previous entry */
       unlink (cache->path);
       FREE (&cache->path);
     }
   }
 
-  FOREVER
-  {
+  FOREVER {
     if (pop_reconnect (ctx) < 0)
       return -1;
 
     /* verify that massage index is correct */
-    if (h->refno < 0)
-    {
-      mutt_error _("The message index is incorrect. Try reopening the mailbox.");
+    if (h->refno < 0) {
+      mutt_error
+        _("The message index is incorrect. Try reopening the mailbox.");
       mutt_sleep (2);
       return -1;
     }
@@ -387,8 +367,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
 
     mutt_mktemp (path);
     msg->fp = safe_fopen (path, "w+");
-    if (!msg->fp)
-    {
+    if (!msg->fp) {
       mutt_perror (path);
       mutt_sleep (2);
       return -1;
@@ -403,16 +382,15 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
     safe_fclose (&msg->fp);
     unlink (path);
 
-    if (ret == -2)
-    {
+    if (ret == -2) {
       mutt_error ("%s", pop_data->err_msg);
       mutt_sleep (2);
       return -1;
     }
 
-    if (ret == -3)
-    {
+    if (ret == -3) {
       mutt_error _("Can't write message to temporary file!");
+
       mutt_sleep (2);
       return -1;
     }
@@ -430,8 +408,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
   h->data = uidl;
   h->lines = 0;
   fgets (buf, sizeof (buf), msg->fp);
-  while (!feof (msg->fp))
-  {
+  while (!feof (msg->fp)) {
     ctx->hdrs[msgno]->lines++;
     fgets (buf, sizeof (buf), msg->fp);
   }
@@ -442,53 +419,47 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
   if (!WithCrypto)
     h->security = crypt_query (h->content);
 
-  mutt_clear_error();
+  mutt_clear_error ();
   rewind (msg->fp);
 
   return 0;
 }
 
 /* update POP mailbox - delete messages from server */
-int pop_sync_mailbox (CONTEXT *ctx, int *index_hint)
+int pop_sync_mailbox (CONTEXT * ctx, int *index_hint)
 {
   int i, ret;
   char buf[LONG_STRING];
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   pop_data->check_time = 0;
 
-  FOREVER
-  {
+  FOREVER {
     if (pop_reconnect (ctx) < 0)
       return -1;
 
     mutt_message (_("Marking %d messages deleted..."), ctx->deleted);
 
-    for (i = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++)
-    {
-      if (ctx->hdrs[i]->deleted)
-      {
-       snprintf (buf, sizeof (buf), "DELE %d\r\n", ctx->hdrs[i]->refno);
-       ret = pop_query (pop_data, buf, sizeof (buf));
+    for (i = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++) {
+      if (ctx->hdrs[i]->deleted) {
+        snprintf (buf, sizeof (buf), "DELE %d\r\n", ctx->hdrs[i]->refno);
+        ret = pop_query (pop_data, buf, sizeof (buf));
       }
     }
 
-    if (ret == 0)
-    {
+    if (ret == 0) {
       strfcpy (buf, "QUIT\r\n", sizeof (buf));
       ret = pop_query (pop_data, buf, sizeof (buf));
     }
 
-    if (ret == 0)
-    {
+    if (ret == 0) {
       pop_data->clear_cache = 1;
       pop_clear_cache (pop_data);
       pop_data->status = POP_DISCONNECTED;
       return 0;
     }
 
-    if (ret == -2)
-    {
+    if (ret == -2) {
       mutt_error ("%s", pop_data->err_msg);
       mutt_sleep (2);
       return -1;
@@ -497,10 +468,10 @@ int pop_sync_mailbox (CONTEXT *ctx, int *index_hint)
 }
 
 /* Check for new messages and fetch headers */
-int pop_check_mailbox (CONTEXT *ctx, int *index_hint)
+int pop_check_mailbox (CONTEXT * ctx, int *index_hint)
 {
   int ret;
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   if ((pop_data->check_time + PopCheckTimeout) > time (NULL))
     return 0;
@@ -541,24 +512,22 @@ void pop_fetch_mail (void)
   ACCOUNT acct;
   POP_DATA *pop_data;
 
-  if (!PopHost)
-  {
+  if (!PopHost) {
     mutt_error _("POP host is not defined.");
+
     return;
   }
 
   url = p = safe_calloc (strlen (PopHost) + 7, sizeof (char));
-  if (url_check_scheme (PopHost) == U_UNKNOWN)
-  {
-    strcpy (url, "pop://");    /* __STRCPY_CHECKED__ */
+  if (url_check_scheme (PopHost) == U_UNKNOWN) {
+    strcpy (url, "pop://");     /* __STRCPY_CHECKED__ */
     p = strchr (url, '\0');
   }
-  strcpy (p, PopHost);         /* __STRCPY_CHECKED__ */
+  strcpy (p, PopHost);          /* __STRCPY_CHECKED__ */
 
   ret = pop_parse_path (url, &acct);
   FREE (&url);
-  if (ret)
-  {
+  if (ret) {
     mutt_error (_("%s is an invalid POP path"), PopHost);
     return;
   }
@@ -570,8 +539,7 @@ void pop_fetch_mail (void)
   pop_data = safe_calloc (1, sizeof (POP_DATA));
   pop_data->conn = conn;
 
-  if (pop_open_connection (pop_data) < 0)
-  {
+  if (pop_open_connection (pop_data) < 0) {
     mutt_socket_free (pop_data->conn);
     FREE (&pop_data);
     return;
@@ -586,8 +554,7 @@ void pop_fetch_mail (void)
   ret = pop_query (pop_data, buffer, sizeof (buffer));
   if (ret == -1)
     goto fail;
-  if (ret == -2)
-  {
+  if (ret == -2) {
     mutt_error ("%s", pop_data->err_msg);
     goto finish;
   }
@@ -595,8 +562,7 @@ void pop_fetch_mail (void)
   sscanf (buffer, "+OK %d %d", &msgs, &bytes);
 
   /* only get unread messages */
-  if (msgs > 0 && option (OPTPOPLAST))
-  {
+  if (msgs > 0 && option (OPTPOPLAST)) {
     strfcpy (buffer, "LAST\r\n", sizeof (buffer));
     ret = pop_query (pop_data, buffer, sizeof (buffer));
     if (ret == -1)
@@ -605,70 +571,66 @@ void pop_fetch_mail (void)
       sscanf (buffer, "+OK %d", &last);
   }
 
-  if (msgs <= last)
-  {
+  if (msgs <= last) {
     mutt_message _("No new mail in POP mailbox.");
+
     goto finish;
   }
 
   if (mx_open_mailbox (NONULL (Spoolfile), M_APPEND, &ctx) == NULL)
     goto finish;
 
-  delanswer = query_quadoption (OPT_POPDELETE, _("Delete messages from server?"));
+  delanswer =
+    query_quadoption (OPT_POPDELETE, _("Delete messages from server?"));
 
-  snprintf (msgbuf, sizeof (msgbuf), _("Reading new messages (%d bytes)..."), bytes);
+  snprintf (msgbuf, sizeof (msgbuf), _("Reading new messages (%d bytes)..."),
+            bytes);
   mutt_message ("%s", msgbuf);
 
-  for (i = last + 1 ; i <= msgs ; i++)
-  {
+  for (i = last + 1; i <= msgs; i++) {
     if ((msg = mx_open_new_message (&ctx, NULL, M_ADD_FROM)) == NULL)
       ret = -3;
-    else
-    {
+    else {
       snprintf (buffer, sizeof (buffer), "RETR %d\r\n", i);
       ret = pop_fetch_data (pop_data, buffer, NULL, fetch_message, msg->fp);
       if (ret == -3)
-       rset = 1;
+        rset = 1;
 
-      if (ret == 0 && mx_commit_message (msg, &ctx) != 0)
-      {
-       rset = 1;
-       ret = -3;
+      if (ret == 0 && mx_commit_message (msg, &ctx) != 0) {
+        rset = 1;
+        ret = -3;
       }
 
       mx_close_message (&msg);
     }
 
-    if (ret == 0 && delanswer == M_YES)
-    {
+    if (ret == 0 && delanswer == M_YES) {
       /* delete the message on the server */
       snprintf (buffer, sizeof (buffer), "DELE %d\r\n", i);
       ret = pop_query (pop_data, buffer, sizeof (buffer));
     }
 
-    if (ret == -1)
-    {
+    if (ret == -1) {
       mx_close_mailbox (&ctx, NULL);
       goto fail;
     }
-    if (ret == -2)
-    {
+    if (ret == -2) {
       mutt_error ("%s", pop_data->err_msg);
       break;
     }
-    if (ret == -3)
-    {
+    if (ret == -3) {
       mutt_error _("Error while writing mailbox!");
+
       break;
     }
 
-    mutt_message (_("%s [%d of %d messages read]"), msgbuf, i - last, msgs - last);
+    mutt_message (_("%s [%d of %d messages read]"), msgbuf, i - last,
+                  msgs - last);
   }
 
   mx_close_mailbox (&ctx, NULL);
 
-  if (rset)
-  {
+  if (rset) {
     /* make sure no messages get deleted */
     strfcpy (buffer, "RSET\r\n", sizeof (buffer));
     if (pop_query (pop_data, buffer, sizeof (buffer)) == -1)
diff --git a/pop.h b/pop.h
index 027c20d..600d323 100644 (file)
--- a/pop.h
+++ b/pop.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _POP_H
 #define _POP_H 1
@@ -31,8 +31,7 @@
 /* maximal length of the server response (RFC1939) */
 #define POP_CMD_RESPONSE 512
 
-enum
-{
+enum {
   /* Status */
   POP_NONE = 0,
   POP_CONNECTED,
@@ -40,50 +39,46 @@ enum
   POP_BYE
 };
 
-typedef enum
-{
+typedef enum {
   POP_A_SUCCESS = 0,
   POP_A_SOCKET,
   POP_A_FAILURE,
   POP_A_UNAVAIL
 } pop_auth_res_t;
 
-typedef struct
-{
+typedef struct {
   unsigned int index;
   char *path;
 } POP_CACHE;
 
-typedef struct
-{
+typedef struct {
   CONNECTION *conn;
-  unsigned int status : 2;
-  unsigned int capabilities : 1;
-  unsigned int use_stls : 2;
-  unsigned int cmd_capa : 1;   /* optional command CAPA */
-  unsigned int cmd_stls : 1;   /* optional command STLS */
-  unsigned int cmd_user : 2;   /* optional command USER */
-  unsigned int cmd_uidl : 2;   /* optional command UIDL */
-  unsigned int cmd_top : 2;    /* optional command TOP */
-  unsigned int resp_codes : 1; /* server supports extended response codes */
-  unsigned int expire : 1;     /* expire is greater than 0 */
-  unsigned int clear_cache : 1;
+  unsigned int status:2;
+  unsigned int capabilities:1;
+  unsigned int use_stls:2;
+  unsigned int cmd_capa:1;      /* optional command CAPA */
+  unsigned int cmd_stls:1;      /* optional command STLS */
+  unsigned int cmd_user:2;      /* optional command USER */
+  unsigned int cmd_uidl:2;      /* optional command UIDL */
+  unsigned int cmd_top:2;       /* optional command TOP */
+  unsigned int resp_codes:1;    /* server supports extended response codes */
+  unsigned int expire:1;        /* expire is greater than 0 */
+  unsigned int clear_cache:1;
   size_t size;
   time_t check_time;
-  time_t login_delay;          /* minimal login delay  capability */
-  char *auth_list;             /* list of auth mechanisms */
+  time_t login_delay;           /* minimal login delay  capability */
+  char *auth_list;              /* list of auth mechanisms */
   char *timestamp;
   char err_msg[POP_CMD_RESPONSE];
   POP_CACHE cache[POP_CACHE_LEN];
 } POP_DATA;
 
-typedef struct
-{
+typedef struct {
   /* do authentication, using named method or any available if method is NULL */
   pop_auth_res_t (*authenticate) (POP_DATA *, const char *);
   /* name of authentication method supported, NULL means variable. If this
    * is not null, authenticate may ignore the second parameter. */
-  const charmethod;
+  const char *method;
 } pop_auth_t;
 
 /* pop_auth.c */
@@ -96,7 +91,8 @@ int pop_parse_path (const char *, ACCOUNT *);
 int pop_connect (POP_DATA *);
 int pop_open_connection (POP_DATA *);
 int pop_query_d (POP_DATA *, char *, size_t, char *);
-int pop_fetch_data (POP_DATA *, char *, char *, int (*funct) (char *, void *), void *);
+int pop_fetch_data (POP_DATA *, char *, char *, int (*funct) (char *, void *),
+                    void *);
 int pop_reconnect (CONTEXT *);
 void pop_logout (CONTEXT *);
 void pop_error (POP_DATA *, char *);
index 3491fb4..0aa49c9 100644 (file)
 
 #ifdef USE_SASL
 /* SASL authenticator */
-static pop_auth_res_t pop_auth_sasl (POP_DATA *pop_data, const char *method)
+static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method)
 {
   sasl_conn_t *saslconn;
   sasl_interact_t *interaction = NULL;
   int rc;
   char buf[LONG_STRING];
   char inbuf[LONG_STRING];
-  const char* mech;
+  const char *mech;
+
 #ifdef USE_SASL2
   const char *pc = NULL;
 #else
-  charpc = NULL;
+  char *pc = NULL;
 #endif
   unsigned int len, olen;
   unsigned char client_start;
 
-  if (mutt_sasl_client_new (pop_data->conn, &saslconn) < 0)
-  {
-    dprint (1, (debugfile, "pop_auth_sasl: Error allocating SASL connection.\n"));
+  if (mutt_sasl_client_new (pop_data->conn, &saslconn) < 0) {
+    dprint (1,
+            (debugfile,
+             "pop_auth_sasl: Error allocating SASL connection.\n"));
     return POP_A_FAILURE;
   }
 
   if (!method)
     method = pop_data->auth_list;
 
-  FOREVER
-  {
+  FOREVER {
 #ifdef USE_SASL2
-       rc = sasl_client_start(saslconn, method, &interaction, &pc, &olen, &mech);
+    rc =
+      sasl_client_start (saslconn, method, &interaction, &pc, &olen, &mech);
 #else
     rc = sasl_client_start (saslconn, method, NULL,
-                           &interaction, &pc, &olen, &mech);
+                            &interaction, &pc, &olen, &mech);
 #endif
     if (rc != SASL_INTERACT)
       break;
     mutt_sasl_interact (interaction);
   }
 
-  if (rc != SASL_OK && rc != SASL_CONTINUE)
-  {
-    dprint (1, (debugfile, "pop_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
+  if (rc != SASL_OK && rc != SASL_CONTINUE) {
+    dprint (1,
+            (debugfile,
+             "pop_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
 
     /* SASL doesn't support suggested mechanisms, so fall back */
     return POP_A_UNAVAIL;
@@ -96,12 +99,10 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA *pop_data, const char *method)
   olen = strlen (buf);
 
   /* looping protocol */
-  FOREVER
-  {
+  FOREVER {
     strfcpy (buf + olen, "\r\n", sizeof (buf) - olen);
     mutt_socket_write (pop_data->conn, buf);
-    if (mutt_socket_readln (inbuf, sizeof (inbuf), pop_data->conn) < 0)
-    {
+    if (mutt_socket_readln (inbuf, sizeof (inbuf), pop_data->conn) < 0) {
       sasl_dispose (&saslconn);
       pop_data->status = POP_DISCONNECTED;
       return POP_A_SOCKET;
@@ -112,23 +113,25 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA *pop_data, const char *method)
 
 #ifdef USE_SASL2
     if (!mutt_strncmp (inbuf, "+ ", 2)
-        && sasl_decode64 (inbuf, strlen (inbuf), buf, LONG_STRING-1, &len) != SASL_OK)
+        && sasl_decode64 (inbuf, strlen (inbuf), buf, LONG_STRING - 1,
+                          &len) != SASL_OK)
 #else
     if (!mutt_strncmp (inbuf, "+ ", 2)
         && sasl_decode64 (inbuf, strlen (inbuf), buf, &len) != SASL_OK)
 #endif
     {
-      dprint (1, (debugfile, "pop_auth_sasl: error base64-decoding server response.\n"));
+      dprint (1,
+              (debugfile,
+               "pop_auth_sasl: error base64-decoding server response.\n"));
       goto bail;
     }
 
     if (!client_start)
-      FOREVER
-      {
-       rc = sasl_client_step (saslconn, buf, len, &interaction, &pc, &olen);
-       if (rc != SASL_INTERACT)
-         break;
-       mutt_sasl_interact (interaction);
+      FOREVER {
+      rc = sasl_client_step (saslconn, buf, len, &interaction, &pc, &olen);
+      if (rc != SASL_INTERACT)
+        break;
+      mutt_sasl_interact (interaction);
       }
     else
       client_start = 0;
@@ -137,12 +140,12 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA *pop_data, const char *method)
       break;
 
     /* send out response, or line break if none needed */
-    if (pc)
-    {
-      if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK)
-      {
-       dprint (1, (debugfile, "pop_auth_sasl: error base64-encoding client response.\n"));
-       goto bail;
+    if (pc) {
+      if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) {
+        dprint (1,
+                (debugfile,
+                 "pop_auth_sasl: error base64-encoding client response.\n"));
+        goto bail;
       }
 
       /* sasl_client_st(art|ep) allocate pc with malloc, expect me to 
@@ -156,8 +159,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA *pop_data, const char *method)
   if (rc != SASL_OK)
     goto bail;
 
-  if (!mutt_strncmp (inbuf, "+OK", 3))
-  {
+  if (!mutt_strncmp (inbuf, "+OK", 3)) {
     mutt_sasl_setup_conn (pop_data->conn, saslconn);
     return POP_A_SUCCESS;
   }
@@ -166,14 +168,14 @@ bail:
   sasl_dispose (&saslconn);
 
   /* terminate SASL sessoin if the last responce is not +OK nor -ERR */
-  if (!mutt_strncmp (inbuf, "+ ", 2))
-  {
+  if (!mutt_strncmp (inbuf, "+ ", 2)) {
     snprintf (buf, sizeof (buf), "*\r\n");
     if (pop_query (pop_data, buf, sizeof (buf)) == -1)
       return POP_A_SOCKET;
   }
 
   mutt_error _("SASL authentication failed.");
+
   mutt_sleep (2);
 
   return POP_A_FAILURE;
@@ -181,21 +183,20 @@ bail:
 #endif
 
 /* Get the server timestamp for APOP authentication */
-void pop_apop_timestamp (POP_DATA *pop_data, char *buf)
+void pop_apop_timestamp (POP_DATA * pop_data, char *buf)
 {
   char *p1, *p2;
 
   FREE (&pop_data->timestamp);
 
-  if ((p1 = strchr (buf, '<')) && (p2 = strchr (p1, '>')))
-  {
+  if ((p1 = strchr (buf, '<')) && (p2 = strchr (p1, '>'))) {
     p2[1] = '\0';
     pop_data->timestamp = safe_strdup (p1);
   }
 }
 
 /* APOP authenticator */
-static pop_auth_res_t pop_auth_apop (POP_DATA *pop_data, const char *method)
+static pop_auth_res_t pop_auth_apop (POP_DATA * pop_data, const char *method)
 {
   MD5_CTX mdContext;
   unsigned char digest[16];
@@ -210,34 +211,35 @@ static pop_auth_res_t pop_auth_apop (POP_DATA *pop_data, const char *method)
 
   /* Compute the authentication hash to send to the server */
   MD5Init (&mdContext);
-  MD5Update (&mdContext, (unsigned char *)pop_data->timestamp,
-            strlen (pop_data->timestamp));
-  MD5Update (&mdContext, (unsigned char *)pop_data->conn->account.pass,
-            strlen (pop_data->conn->account.pass));
+  MD5Update (&mdContext, (unsigned char *) pop_data->timestamp,
+             strlen (pop_data->timestamp));
+  MD5Update (&mdContext, (unsigned char *) pop_data->conn->account.pass,
+             strlen (pop_data->conn->account.pass));
   MD5Final (digest, &mdContext);
 
   for (i = 0; i < sizeof (digest); i++)
     sprintf (hash + 2 * i, "%02x", digest[i]);
 
   /* Send APOP command to server */
-  snprintf (buf, sizeof (buf), "APOP %s %s\r\n", pop_data->conn->account.user, hash);
+  snprintf (buf, sizeof (buf), "APOP %s %s\r\n", pop_data->conn->account.user,
+            hash);
 
-  switch (pop_query (pop_data, buf, sizeof (buf)))
-  {
-    case 0:
-      return POP_A_SUCCESS;
-    case -1:
-      return POP_A_SOCKET;
+  switch (pop_query (pop_data, buf, sizeof (buf))) {
+  case 0:
+    return POP_A_SUCCESS;
+  case -1:
+    return POP_A_SOCKET;
   }
 
   mutt_error _("APOP authentication failed.");
+
   mutt_sleep (2);
 
   return POP_A_FAILURE;
 }
 
 /* USER authenticator */
-static pop_auth_res_t pop_auth_user (POP_DATA *pop_data, const char *method)
+static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method)
 {
   char buf[LONG_STRING];
   int ret;
@@ -250,42 +252,37 @@ static pop_auth_res_t pop_auth_user (POP_DATA *pop_data, const char *method)
   snprintf (buf, sizeof (buf), "USER %s\r\n", pop_data->conn->account.user);
   ret = pop_query (pop_data, buf, sizeof (buf));
 
-  if (pop_data->cmd_user == 2)
-  {
-    if (ret == 0)
-    {
+  if (pop_data->cmd_user == 2) {
+    if (ret == 0) {
       pop_data->cmd_user = 1;
 
       dprint (1, (debugfile, "pop_auth_user: set USER capability\n"));
     }
 
-    if (ret == -2)
-    {
+    if (ret == -2) {
       pop_data->cmd_user = 0;
 
       dprint (1, (debugfile, "pop_auth_user: unset USER capability\n"));
       snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
-              _("Command USER is not supported by server."));
+                _("Command USER is not supported by server."));
     }
   }
 
-  if (ret == 0)
-  {
+  if (ret == 0) {
     snprintf (buf, sizeof (buf), "PASS %s\r\n", pop_data->conn->account.pass);
-    ret = pop_query_d (pop_data, buf, sizeof (buf), 
+    ret = pop_query_d (pop_data, buf, sizeof (buf),
 #ifdef DEBUG
-       /* don't print the password unless we're at the ungodly debugging level */
-       debuglevel < M_SOCK_LOG_FULL ? "PASS *\r\n" :
+                       /* don't print the password unless we're at the ungodly debugging level */
+                       debuglevel < M_SOCK_LOG_FULL ? "PASS *\r\n" :
 #endif
-       NULL);
+                       NULL);
   }
 
-  switch (ret)
-  {
-    case 0:
-      return POP_A_SUCCESS;
-    case -1:
-      return POP_A_SOCKET;
+  switch (ret) {
+  case 0:
+    return POP_A_SUCCESS;
+  case -1:
+    return POP_A_SOCKET;
   }
 
   mutt_error ("%s %s", _("Login failed."), pop_data->err_msg);
@@ -296,11 +293,11 @@ static pop_auth_res_t pop_auth_user (POP_DATA *pop_data, const char *method)
 
 static pop_auth_t pop_authenticators[] = {
 #ifdef USE_SASL
-  { pop_auth_sasl, NULL },
+  {pop_auth_sasl, NULL},
 #endif
-  { pop_auth_apop, "apop" },
-  { pop_auth_user, "user" },
-  { NULL }
+  {pop_auth_apop, "apop"},
+  {pop_auth_user, "user"},
+  {NULL}
 };
 
 /*
@@ -310,13 +307,13 @@ static pop_auth_t pop_authenticators[] = {
  * -2 - login failed,
  * -3 - authentication canceled.
 */
-int pop_authenticate (POP_DATA* pop_data)
+int pop_authenticate (POP_DATA * pop_data)
 {
   ACCOUNT *acct = &pop_data->conn->account;
-  pop_auth_tauthenticator;
-  charmethods;
-  charcomma;
-  charmethod;
+  pop_auth_t *authenticator;
+  char *methods;
+  char *comma;
+  char *method;
   int attempts = 0;
   int ret = POP_A_UNAVAIL;
 
@@ -324,48 +321,42 @@ int pop_authenticate (POP_DATA* pop_data)
       mutt_account_getpass (acct) || !acct->pass[0])
     return -3;
 
-  if (PopAuthenticators && *PopAuthenticators)
-  {
+  if (PopAuthenticators && *PopAuthenticators) {
     /* Try user-specified list of authentication methods */
     methods = safe_strdup (PopAuthenticators);
     method = methods;
 
-    while (method)
-    {
+    while (method) {
       comma = strchr (method, ':');
       if (comma)
-       *comma++ = '\0';
+        *comma++ = '\0';
       dprint (2, (debugfile, "pop_authenticate: Trying method %s\n", method));
       authenticator = pop_authenticators;
 
-      while (authenticator->authenticate)
-      {
-       if (!authenticator->method ||
-           !ascii_strcasecmp (authenticator->method, method))
-       {
-         ret = authenticator->authenticate (pop_data, method);
-         if (ret == POP_A_SOCKET)
-           switch (pop_connect (pop_data))
-           {
-             case 0:
-             {
-               ret = authenticator->authenticate (pop_data, method);
-               break;
-             }
-             case -2:
-               ret = POP_A_FAILURE;
-           }
-
-         if (ret != POP_A_UNAVAIL)
-           attempts++;
-         if (ret == POP_A_SUCCESS || ret == POP_A_SOCKET ||
-             (ret == POP_A_FAILURE && !option (OPTPOPAUTHTRYALL)))
-         {
-           comma = NULL;
-           break;
-         }
-       }
-       authenticator++;
+      while (authenticator->authenticate) {
+        if (!authenticator->method ||
+            !ascii_strcasecmp (authenticator->method, method)) {
+          ret = authenticator->authenticate (pop_data, method);
+          if (ret == POP_A_SOCKET)
+            switch (pop_connect (pop_data)) {
+            case 0:
+              {
+                ret = authenticator->authenticate (pop_data, method);
+                break;
+              }
+            case -2:
+              ret = POP_A_FAILURE;
+            }
+
+          if (ret != POP_A_UNAVAIL)
+            attempts++;
+          if (ret == POP_A_SUCCESS || ret == POP_A_SOCKET ||
+              (ret == POP_A_FAILURE && !option (OPTPOPAUTHTRYALL))) {
+            comma = NULL;
+            break;
+          }
+        }
+        authenticator++;
       }
 
       method = comma;
@@ -373,46 +364,44 @@ int pop_authenticate (POP_DATA* pop_data)
 
     FREE (&methods);
   }
-  else
-  {
+  else {
     /* Fall back to default: any authenticator */
-    dprint (2, (debugfile, "pop_authenticate: Using any available method.\n"));
+    dprint (2,
+            (debugfile, "pop_authenticate: Using any available method.\n"));
     authenticator = pop_authenticators;
 
-    while (authenticator->authenticate)
-    {
+    while (authenticator->authenticate) {
       ret = authenticator->authenticate (pop_data, authenticator->method);
       if (ret == POP_A_SOCKET)
-       switch (pop_connect (pop_data))
-       {
-         case 0:
-         {
-           ret = authenticator->authenticate (pop_data, authenticator->method);
-           break;
-         }
-         case -2:
-           ret = POP_A_FAILURE;
-       }
+        switch (pop_connect (pop_data)) {
+        case 0:
+          {
+            ret =
+              authenticator->authenticate (pop_data, authenticator->method);
+            break;
+          }
+        case -2:
+          ret = POP_A_FAILURE;
+        }
 
       if (ret != POP_A_UNAVAIL)
-       attempts++;
+        attempts++;
       if (ret == POP_A_SUCCESS || ret == POP_A_SOCKET ||
-         (ret == POP_A_FAILURE && !option (OPTPOPAUTHTRYALL)))
-       break;
+          (ret == POP_A_FAILURE && !option (OPTPOPAUTHTRYALL)))
+        break;
 
       authenticator++;
     }
   }
 
-  switch (ret)
-  {
-    case POP_A_SUCCESS:
-      return 0;
-    case POP_A_SOCKET:
-      return -1;
-    case POP_A_UNAVAIL:
-      if (!attempts)
-       mutt_error (_("No authenticators available"));
+  switch (ret) {
+  case POP_A_SUCCESS:
+    return 0;
+  case POP_A_SOCKET:
+    return -1;
+  case POP_A_UNAVAIL:
+    if (!attempts)
+      mutt_error (_("No authenticators available"));
   }
 
   return -2;
index aa11eaa..c81b44e 100644 (file)
--- a/pop_lib.c
+++ b/pop_lib.c
@@ -33,7 +33,7 @@
 #include <ctype.h>
 
 /* given an POP mailbox name, return host, port, username and password */
-int pop_parse_path (const char* path, ACCOUNT* acct)
+int pop_parse_path (const char *path, ACCOUNT * acct)
 {
   ciss_url_t url;
   char *c;
@@ -47,10 +47,8 @@ int pop_parse_path (const char* path, ACCOUNT* acct)
   c = safe_strdup (path);
   url_parse_ciss (&url, c);
 
-  if (url.scheme == U_POP || url.scheme == U_POPS)
-  {
-    if (url.scheme == U_POPS)
-    {
+  if (url.scheme == U_POP || url.scheme == U_POPS) {
+    if (url.scheme == U_POPS) {
       acct->flags |= M_ACCT_SSL;
       acct->port = POP_SSL_PORT;
     }
@@ -64,15 +62,14 @@ int pop_parse_path (const char* path, ACCOUNT* acct)
 }
 
 /* Copy error message to err_msg buffer */
-void pop_error (POP_DATA *pop_data, char *msg)
+void pop_error (POP_DATA * pop_data, char *msg)
 {
   char *t, *c, *c2;
 
   t = strchr (pop_data->err_msg, '\0');
   c = msg;
 
-  if (!mutt_strncmp (msg, "-ERR ", 5))
-  {
+  if (!mutt_strncmp (msg, "-ERR ", 5)) {
     c2 = msg + 5;
     SKIPWS (c2);
 
@@ -87,11 +84,10 @@ void pop_error (POP_DATA *pop_data, char *msg)
 /* Parse CAPA output */
 static int fetch_capa (char *line, void *data)
 {
-  POP_DATA *pop_data = (POP_DATA *)data;
+  POP_DATA *pop_data = (POP_DATA *) data;
   char *c;
 
-  if (!ascii_strncasecmp (line, "SASL", 4))
-  {
+  if (!ascii_strncasecmp (line, "SASL", 4)) {
     FREE (&pop_data->auth_list);
     c = line + 4;
     SKIPWS (c);
@@ -116,20 +112,18 @@ static int fetch_capa (char *line, void *data)
 /* Fetch list of the authentication mechanisms */
 static int fetch_auth (char *line, void *data)
 {
-  POP_DATA *pop_data = (POP_DATA *)data;
+  POP_DATA *pop_data = (POP_DATA *) data;
 
-  if (!pop_data->auth_list)
-  {
+  if (!pop_data->auth_list) {
     pop_data->auth_list = safe_malloc (strlen (line) + 1);
     *pop_data->auth_list = '\0';
   }
-  else
-  {
+  else {
     safe_realloc (&pop_data->auth_list,
-           strlen (pop_data->auth_list) + strlen (line) + 2);
-    strcat (pop_data->auth_list, " "); /* __STRCAT_CHECKED__ */
+                  strlen (pop_data->auth_list) + strlen (line) + 2);
+    strcat (pop_data->auth_list, " ");  /* __STRCAT_CHECKED__ */
   }
-  strcat (pop_data->auth_list, line);  /* __STRCAT_CHECKED__ */
+  strcat (pop_data->auth_list, line);   /* __STRCAT_CHECKED__ */
 
   return 0;
 }
@@ -140,7 +134,7 @@ static int fetch_auth (char *line, void *data)
  * -1 - conection lost,
  * -2 - execution error.
 */
-static int pop_capabilities (POP_DATA *pop_data, int mode)
+static int pop_capabilities (POP_DATA * pop_data, int mode)
 {
   char buf[LONG_STRING];
 
@@ -149,8 +143,7 @@ static int pop_capabilities (POP_DATA *pop_data, int mode)
     return 0;
 
   /* init capabilities */
-  if (mode == 0)
-  {
+  if (mode == 0) {
     pop_data->cmd_capa = 0;
     pop_data->cmd_stls = 0;
     pop_data->cmd_user = 0;
@@ -163,24 +156,21 @@ static int pop_capabilities (POP_DATA *pop_data, int mode)
   }
 
   /* Execute CAPA command */
-  if (mode == 0 || pop_data->cmd_capa)
-  {
+  if (mode == 0 || pop_data->cmd_capa) {
     strfcpy (buf, "CAPA\r\n", sizeof (buf));
-    switch (pop_fetch_data (pop_data, buf, NULL, fetch_capa, pop_data))
-    {
-      case 0:
+    switch (pop_fetch_data (pop_data, buf, NULL, fetch_capa, pop_data)) {
+    case 0:
       {
-       pop_data->cmd_capa = 1;
-       break;
+        pop_data->cmd_capa = 1;
+        break;
       }
-      case -1:
-       return -1;
+    case -1:
+      return -1;
     }
   }
 
   /* CAPA not supported, use defaults */
-  if (mode == 0 && !pop_data->cmd_capa)
-  {
+  if (mode == 0 && !pop_data->cmd_capa) {
     pop_data->cmd_user = 2;
     pop_data->cmd_uidl = 2;
     pop_data->cmd_top = 2;
@@ -191,8 +181,7 @@ static int pop_capabilities (POP_DATA *pop_data, int mode)
   }
 
   /* Check capabilities */
-  if (mode == 2)
-  {
+  if (mode == 2) {
     char *msg = NULL;
 
     if (!pop_data->expire)
@@ -201,8 +190,7 @@ static int pop_capabilities (POP_DATA *pop_data, int mode)
       msg = _("Command TOP is not supported by server.");
     if (!pop_data->cmd_uidl)
       msg = _("Command UIDL is not supported by server.");
-    if (msg && pop_data->cmd_capa)
-    {
+    if (msg && pop_data->cmd_capa) {
       mutt_error (msg);
       return -2;
     }
@@ -218,22 +206,21 @@ static int pop_capabilities (POP_DATA *pop_data, int mode)
  * -1 - conection lost,
  * -2 - invalid response.
 */
-int pop_connect (POP_DATA *pop_data)
+int pop_connect (POP_DATA * pop_data)
 {
   char buf[LONG_STRING];
 
   pop_data->status = POP_NONE;
   if (mutt_socket_open (pop_data->conn) < 0 ||
-      mutt_socket_readln (buf, sizeof (buf), pop_data->conn) < 0)
-  {
-    mutt_error (_("Error connecting to server: %s"), pop_data->conn->account.host);
+      mutt_socket_readln (buf, sizeof (buf), pop_data->conn) < 0) {
+    mutt_error (_("Error connecting to server: %s"),
+                pop_data->conn->account.host);
     return -1;
   }
 
   pop_data->status = POP_CONNECTED;
 
-  if (mutt_strncmp (buf, "+OK", 3))
-  {
+  if (mutt_strncmp (buf, "+OK", 3)) {
     *pop_data->err_msg = '\0';
     pop_error (pop_data, buf);
     mutt_error ("%s", pop_data->err_msg);
@@ -252,15 +239,14 @@ int pop_connect (POP_DATA *pop_data)
  * -2 - invalid command or execution error,
  * -3 - authentication canceled.
 */
-int pop_open_connection (POP_DATA *pop_data)
+int pop_open_connection (POP_DATA * pop_data)
 {
   int ret;
   unsigned int n, size;
   char buf[LONG_STRING];
 
   ret = pop_connect (pop_data);
-  if (ret < 0)
-  {
+  if (ret < 0) {
     mutt_sleep (2);
     return ret;
   }
@@ -268,36 +254,31 @@ int pop_open_connection (POP_DATA *pop_data)
   ret = pop_capabilities (pop_data, 0);
   if (ret == -1)
     goto err_conn;
-  if (ret == -2)
-  {
+  if (ret == -2) {
     mutt_sleep (2);
     return -2;
   }
 
 #if (defined(USE_SSL) || defined(USE_GNUTLS)) && !defined(USE_NSS)
   /* Attempt STLS if available and desired. */
-  if (pop_data->cmd_stls && !pop_data->conn->ssf)
-  {
-    if (pop_data->use_stls == 0)
-    {
+  if (pop_data->cmd_stls && !pop_data->conn->ssf) {
+    if (pop_data->use_stls == 0) {
       ret = query_quadoption (OPT_SSLSTARTTLS,
-           _("Secure connection with TLS?"));
+                              _("Secure connection with TLS?"));
       if (ret == -1)
-       return -2;
+        return -2;
       pop_data->use_stls = 1;
       if (ret == M_YES)
-       pop_data->use_stls = 2;
+        pop_data->use_stls = 2;
     }
-    if (pop_data->use_stls == 2)
-    {
+    if (pop_data->use_stls == 2) {
       strfcpy (buf, "STLS\r\n", sizeof (buf));
       ret = pop_query (pop_data, buf, sizeof (buf));
       if (ret == -1)
-       goto err_conn;
-      if (ret != 0)
-      {
-       mutt_error ("%s", pop_data->err_msg);
-       mutt_sleep (2);
+        goto err_conn;
+      if (ret != 0) {
+        mutt_error ("%s", pop_data->err_msg);
+        mutt_sleep (2);
       }
 #ifdef USE_SSL
       else if (mutt_ssl_starttls (pop_data->conn))
@@ -305,21 +286,19 @@ int pop_open_connection (POP_DATA *pop_data)
       else if (mutt_gnutls_starttls (pop_data->conn))
 #endif
       {
-       mutt_error (_("Could not negotiate TLS connection"));
-       mutt_sleep (2);
-       return -2;
+        mutt_error (_("Could not negotiate TLS connection"));
+        mutt_sleep (2);
+        return -2;
       }
-      else
-      {
-       /* recheck capabilities after STLS completes */
-       ret = pop_capabilities (pop_data, 1);
-       if (ret == -1)
-         goto err_conn;
-       if (ret == -2)
-       {
-         mutt_sleep (2);
-         return -2;
-       }
+      else {
+        /* recheck capabilities after STLS completes */
+        ret = pop_capabilities (pop_data, 1);
+        if (ret == -1)
+          goto err_conn;
+        if (ret == -2) {
+          mutt_sleep (2);
+          return -2;
+        }
       }
     }
   }
@@ -337,8 +316,7 @@ int pop_open_connection (POP_DATA *pop_data)
   ret = pop_capabilities (pop_data, 2);
   if (ret == -1)
     goto err_conn;
-  if (ret == -2)
-  {
+  if (ret == -2) {
     mutt_sleep (2);
     return -2;
   }
@@ -348,8 +326,7 @@ int pop_open_connection (POP_DATA *pop_data)
   ret = pop_query (pop_data, buf, sizeof (buf));
   if (ret == -1)
     goto err_conn;
-  if (ret == -2)
-  {
+  if (ret == -2) {
     mutt_error ("%s", pop_data->err_msg);
     mutt_sleep (2);
     return ret;
@@ -362,29 +339,27 @@ int pop_open_connection (POP_DATA *pop_data)
 err_conn:
   pop_data->status = POP_DISCONNECTED;
   mutt_error _("Server closed connection!");
+
   mutt_sleep (2);
   return -1;
 }
 
 /* logout from POP server */
-void pop_logout (CONTEXT *ctx)
+void pop_logout (CONTEXT * ctx)
 {
   int ret = 0;
   char buf[LONG_STRING];
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
-  if (pop_data->status == POP_CONNECTED)
-  {
+  if (pop_data->status == POP_CONNECTED) {
     mutt_message _("Closing connection to POP server...");
 
-    if (ctx->readonly)
-    {
+    if (ctx->readonly) {
       strfcpy (buf, "RSET\r\n", sizeof (buf));
       ret = pop_query (pop_data, buf, sizeof (buf));
     }
 
-    if (ret != -1)
-    {
+    if (ret != -1) {
       strfcpy (buf, "QUIT\r\n", sizeof (buf));
       pop_query (pop_data, buf, sizeof (buf));
     }
@@ -402,7 +377,7 @@ void pop_logout (CONTEXT *ctx)
  * -1 - conection lost,
  * -2 - invalid command or execution error.
 */
-int pop_query_d (POP_DATA *pop_data, char *buf, size_t buflen, char *msg)
+int pop_query_d (POP_DATA * pop_data, char *buf, size_t buflen, char *msg)
 {
   int dbg = M_SOCK_LOG_CMD;
   char *c;
@@ -411,12 +386,11 @@ int pop_query_d (POP_DATA *pop_data, char *buf, size_t buflen, char *msg)
     return -1;
 
 #ifdef DEBUG
-    /* print msg instaed of real command */
-    if (msg)
-    {
-      dbg = M_SOCK_LOG_FULL;
-      dprint (M_SOCK_LOG_CMD, (debugfile, "> %s", msg));
-    }
+  /* print msg instaed of real command */
+  if (msg) {
+    dbg = M_SOCK_LOG_FULL;
+    dprint (M_SOCK_LOG_CMD, (debugfile, "> %s", msg));
+  }
 #endif
 
   mutt_socket_write_d (pop_data->conn, buf, dbg);
@@ -425,8 +399,7 @@ int pop_query_d (POP_DATA *pop_data, char *buf, size_t buflen, char *msg)
   *c = '\0';
   snprintf (pop_data->err_msg, sizeof (pop_data->err_msg), "%s: ", buf);
 
-  if (mutt_socket_readln (buf, buflen, pop_data->conn) < 0)
-  {
+  if (mutt_socket_readln (buf, buflen, pop_data->conn) < 0) {
     pop_data->status = POP_DISCONNECTED;
     return -1;
   }
@@ -446,8 +419,8 @@ int pop_query_d (POP_DATA *pop_data, char *buf, size_t buflen, char *msg)
  * -2 - invalid command or execution error,
  * -3 - error in funct(*line, *data)
  */
-int pop_fetch_data (POP_DATA *pop_data, char *query, char *msg,
-                   int (*funct) (char *, void *), void *data)
+int pop_fetch_data (POP_DATA * pop_data, char *query, char *msg,
+                    int (*funct) (char *, void *), void *data)
 {
   char buf[LONG_STRING];
   char *inbuf;
@@ -462,37 +435,34 @@ int pop_fetch_data (POP_DATA *pop_data, char *query, char *msg,
 
   inbuf = safe_malloc (sizeof (buf));
 
-  FOREVER
-  {
-    chunk = mutt_socket_readln_d (buf, sizeof (buf), pop_data->conn, M_SOCK_LOG_HDR);
-    if (chunk < 0)
-    {
+  FOREVER {
+    chunk =
+      mutt_socket_readln_d (buf, sizeof (buf), pop_data->conn,
+                            M_SOCK_LOG_HDR);
+    if (chunk < 0) {
       pop_data->status = POP_DISCONNECTED;
       ret = -1;
       break;
     }
 
     p = buf;
-    if (!lenbuf && buf[0] == '.')
-    {
+    if (!lenbuf && buf[0] == '.') {
       if (buf[1] != '.')
-       break;
+        break;
       p++;
     }
 
     strfcpy (inbuf + lenbuf, p, sizeof (buf));
 
-    if (chunk >= sizeof (buf))
-    {
+    if (chunk >= sizeof (buf)) {
       lenbuf += strlen (p);
     }
-    else
-    {
+    else {
       line++;
       if (msg && ReadInc && (line % ReadInc == 0))
-       mutt_message ("%s %d", msg, line);
+        mutt_message ("%s %d", msg, line);
       if (ret == 0 && funct (inbuf, data) < 0)
-       ret = -3;
+        ret = -3;
       lenbuf = 0;
     }
 
@@ -508,13 +478,11 @@ static int check_uidl (char *line, void *data)
 {
   int i;
   unsigned int index;
-  CONTEXT *ctx = (CONTEXT *)data;
+  CONTEXT *ctx = (CONTEXT *) data;
 
   sscanf (line, "%u %s", &index, line);
-  for (i = 0; i < ctx->msgcount; i++)
-  {
-    if (!mutt_strcmp (ctx->hdrs[i]->data, line))
-    {
+  for (i = 0; i < ctx->msgcount; i++) {
+    if (!mutt_strcmp (ctx->hdrs[i]->data, line)) {
       ctx->hdrs[i]->refno = index;
       break;
     }
@@ -524,34 +492,31 @@ static int check_uidl (char *line, void *data)
 }
 
 /* reconnect and verify idnexes if connection was lost */
-int pop_reconnect (CONTEXT *ctx)
+int pop_reconnect (CONTEXT * ctx)
 {
   int ret;
-  POP_DATA *pop_data = (POP_DATA *)ctx->data;
+  POP_DATA *pop_data = (POP_DATA *) ctx->data;
 
   if (pop_data->status == POP_CONNECTED)
     return 0;
   if (pop_data->status == POP_BYE)
     return -1;
 
-  FOREVER
-  {
+  FOREVER {
     mutt_socket_close (pop_data->conn);
 
     ret = pop_open_connection (pop_data);
-    if (ret == 0)
-    {
+    if (ret == 0) {
       char *msg = _("Verifying message indexes...");
       int i;
 
       for (i = 0; i < ctx->msgcount; i++)
-       ctx->hdrs[i]->refno = -1;
+        ctx->hdrs[i]->refno = -1;
 
       mutt_message (msg);
 
       ret = pop_fetch_data (pop_data, "UIDL\r\n", msg, check_uidl, ctx);
-      if (ret == -2)
-      {
+      if (ret == -2) {
         mutt_error ("%s", pop_data->err_msg);
         mutt_sleep (2);
       }
@@ -565,7 +530,8 @@ int pop_reconnect (CONTEXT *ctx)
       return -1;
 
     if (query_quadoption (OPT_POPRECONNECT,
-               _("Connection lost. Reconnect to POP server?")) != M_YES)
+                          _("Connection lost. Reconnect to POP server?")) !=
+        M_YES)
       return -1;
   }
 }
index 2d31835..0eeac68 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <sys/stat.h>
 
 static struct mapping_t PostponeHelp[] = {
-  { N_("Exit"),  OP_EXIT },
-  { N_("Del"),   OP_DELETE },
-  { N_("Undel"), OP_UNDELETE },
-  { N_("Help"),  OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("Del"), OP_DELETE},
+  {N_("Undel"), OP_UNDELETE},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
 
@@ -65,14 +65,12 @@ int mutt_num_postponed (int force)
   static time_t LastModify = 0;
   static char *OldPostponed = NULL;
 
-  if (UpdateNumPostponed)
-  {
+  if (UpdateNumPostponed) {
     UpdateNumPostponed = 0;
     force = 1;
   }
 
-  if (Postponed != OldPostponed)
-  {
+  if (Postponed != OldPostponed) {
     OldPostponed = Postponed;
     LastModify = 0;
     force = 1;
@@ -83,49 +81,47 @@ int mutt_num_postponed (int force)
 
 #ifdef USE_IMAP
   /* LastModify is useless for IMAP */
-  if (mx_is_imap (Postponed))
-  {
-    if (force)
-    {
+  if (mx_is_imap (Postponed)) {
+    if (force) {
       short newpc;
 
       newpc = imap_mailbox_check (Postponed, 0);
-      if (newpc >= 0)
-      {
-       PostCount = newpc;
-       dprint (2, (debugfile, "mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount));
+      if (newpc >= 0) {
+        PostCount = newpc;
+        dprint (2,
+                (debugfile,
+                 "mutt_num_postponed: %d postponed IMAP messages found.\n",
+                 PostCount));
       }
       else
-       dprint (2, (debugfile, "mutt_num_postponed: using old IMAP postponed count.\n"));
+        dprint (2,
+                (debugfile,
+                 "mutt_num_postponed: using old IMAP postponed count.\n"));
     }
     return PostCount;
   }
 #endif
 
-  if (stat (Postponed, &st) == -1)
-  {
-     PostCount = 0;
-     LastModify = 0;
-     return (0);
+  if (stat (Postponed, &st) == -1) {
+    PostCount = 0;
+    LastModify = 0;
+    return (0);
   }
 
-  if (S_ISDIR (st.st_mode))
-  {
+  if (S_ISDIR (st.st_mode)) {
     /* if we have a maildir mailbox, we need to stat the "new" dir */
 
     char buf[_POSIX_PATH_MAX];
 
     snprintf (buf, sizeof (buf), "%s/new", Postponed);
-    if (access (buf, F_OK) == 0 && stat (buf, &st) == -1)
-    {
+    if (access (buf, F_OK) == 0 && stat (buf, &st) == -1) {
       PostCount = 0;
       LastModify = 0;
       return 0;
     }
   }
 
-  if (LastModify < st.st_mtime)
-  {
+  if (LastModify < st.st_mtime) {
 #ifdef USE_NNTP
     int optnews = option (OPTNEWS);
 #endif
@@ -135,7 +131,7 @@ int mutt_num_postponed (int force)
       return (PostCount = 0);
 #ifdef USE_NNTP
     if (optnews)
-       unset_option (OPTNEWS);
+      unset_option (OPTNEWS);
 #endif
     if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
       PostCount = 0;
@@ -144,7 +140,7 @@ int mutt_num_postponed (int force)
     mx_fastclose_mailbox (&ctx);
 #ifdef USE_NNTP
     if (optnews)
-       set_option (OPTNEWS);
+      set_option (OPTNEWS);
 #endif
   }
 
@@ -156,18 +152,18 @@ void mutt_update_num_postponed (void)
   UpdateNumPostponed = 1;
 }
 
-static void post_entry (char *s, size_t slen, MUTTMENU *menu, int entry)
+static void post_entry (char *s, size_t slen, MUTTMENU * menu, int entry)
 {
   CONTEXT *ctx = (CONTEXT *) menu->data;
 
   _mutt_make_string (s, slen, NONULL (HdrFmt), ctx, ctx->hdrs[entry],
-                    M_FORMAT_ARROWCURSOR);
+                     M_FORMAT_ARROWCURSOR);
 }
 
 static HEADER *select_msg (void)
 {
   MUTTMENU *menu;
-  int i, done=0, r=-1;
+  int i, done = 0, r = -1;
   char helpstr[SHORT_STRING];
   short orig_sort;
 
@@ -177,46 +173,44 @@ static HEADER *select_msg (void)
   menu->max = PostContext->msgcount;
   menu->title = _("Postponed Messages");
   menu->data = PostContext;
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_POST, PostponeHelp);
+  menu->help =
+    mutt_compile_help (helpstr, sizeof (helpstr), MENU_POST, PostponeHelp);
 
   /* The postponed mailbox is setup to have sorting disabled, but the global
    * Sort variable may indicate something different.   Sorting has to be
    * disabled while the postpone menu is being displayed. */
   orig_sort = Sort;
   Sort = SORT_ORDER;
-  
-  while (!done)
-  {
-    switch (i = mutt_menuLoop (menu))
-    {
-      case OP_DELETE:
-      case OP_UNDELETE:
-       mutt_set_flag (PostContext, PostContext->hdrs[menu->current], M_DELETE, (i == OP_DELETE) ? 1 : 0);
-       PostCount = PostContext->msgcount - PostContext->deleted;
-       if (option (OPTRESOLVE) && menu->current < menu->max - 1)
-       {
-         menu->oldcurrent = menu->current;
-         menu->current++;
-         if (menu->current >= menu->top + menu->pagelen)
-         {
-           menu->top = menu->current;
-           menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-         }
-         else
-           menu->redraw |= REDRAW_MOTION_RESYNCH;
-       }
-       else
-         menu->redraw = REDRAW_CURRENT;
-       break;
-
-      case OP_GENERIC_SELECT_ENTRY:
-       r = menu->current;
-       done = 1;
-       break;
-
-      case OP_EXIT:
-       done = 1;
-       break;
+
+  while (!done) {
+    switch (i = mutt_menuLoop (menu)) {
+    case OP_DELETE:
+    case OP_UNDELETE:
+      mutt_set_flag (PostContext, PostContext->hdrs[menu->current], M_DELETE,
+                     (i == OP_DELETE) ? 1 : 0);
+      PostCount = PostContext->msgcount - PostContext->deleted;
+      if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
+        menu->oldcurrent = menu->current;
+        menu->current++;
+        if (menu->current >= menu->top + menu->pagelen) {
+          menu->top = menu->current;
+          menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+        }
+        else
+          menu->redraw |= REDRAW_MOTION_RESYNCH;
+      }
+      else
+        menu->redraw = REDRAW_CURRENT;
+      break;
+
+    case OP_GENERIC_SELECT_ENTRY:
+      r = menu->current;
+      done = 1;
+      break;
+
+    case OP_EXIT:
+      done = 1;
+      break;
     }
   }
 
@@ -239,7 +233,8 @@ static HEADER *select_msg (void)
  *     0               normal exit
  *     SENDREPLY       recalled message is a reply
  */
-int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size_t fcclen)
+int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc,
+                        size_t fcclen)
 {
   HEADER *h;
   int code = SENDPOSTPONED;
@@ -252,36 +247,33 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
   if (!Postponed)
     return (-1);
 
-  if ((PostContext = mx_open_mailbox (Postponed, M_NOSORT, NULL)) == NULL)
-  {
+  if ((PostContext = mx_open_mailbox (Postponed, M_NOSORT, NULL)) == NULL) {
     PostCount = 0;
     mutt_error _("No postponed messages.");
+
     return (-1);
   }
-  
-  if (! PostContext->msgcount)
-  {
+
+  if (!PostContext->msgcount) {
     PostCount = 0;
     mx_close_mailbox (PostContext, NULL);
     FREE (&PostContext);
     mutt_error _("No postponed messages.");
+
     return (-1);
   }
 
-  if (PostContext->msgcount == 1)
-  {
+  if (PostContext->msgcount == 1) {
     /* only one message, so just use that one. */
     h = PostContext->hdrs[0];
   }
-  else if ((h = select_msg ()) == NULL)
-  {
+  else if ((h = select_msg ()) == NULL) {
     mx_close_mailbox (PostContext, NULL);
     FREE (&PostContext);
     return (-1);
   }
 
-  if (mutt_prepare_template (NULL, PostContext, hdr, h, 0) < 0)
-  {
+  if (mutt_prepare_template (NULL, PostContext, hdr, h, 0) < 0) {
     mx_fastclose_mailbox (PostContext);
     FREE (&PostContext);
     return (-1);
@@ -304,35 +296,31 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
 
   FREE (&PostContext);
 
-  for (tmp = hdr->env->userhdrs; tmp; )
-  {
-    if (ascii_strncasecmp ("X-Mutt-References:", tmp->data, 18) == 0)
-    {
-      if (ctx)
-      {
-       /* if a mailbox is currently open, look to see if the orignal message
-          the user attempted to reply to is in this mailbox */
-       p = tmp->data + 18;
-       SKIPWS (p);
-       if (!ctx->id_hash)
-         ctx->id_hash = mutt_make_id_hash (ctx);
-       *cur = hash_find (ctx->id_hash, p);
+  for (tmp = hdr->env->userhdrs; tmp;) {
+    if (ascii_strncasecmp ("X-Mutt-References:", tmp->data, 18) == 0) {
+      if (ctx) {
+        /* if a mailbox is currently open, look to see if the orignal message
+           the user attempted to reply to is in this mailbox */
+        p = tmp->data + 18;
+        SKIPWS (p);
+        if (!ctx->id_hash)
+          ctx->id_hash = mutt_make_id_hash (ctx);
+        *cur = hash_find (ctx->id_hash, p);
       }
 
       /* Remove the X-Mutt-References: header field. */
       next = tmp->next;
       if (last)
-       last->next = tmp->next;
+        last->next = tmp->next;
       else
-       hdr->env->userhdrs = tmp->next;
+        hdr->env->userhdrs = tmp->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
       tmp = next;
       if (*cur)
-       code |= SENDREPLY;
+        code |= SENDREPLY;
     }
-    else if (ascii_strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0)
-    {
+    else if (ascii_strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0) {
       p = tmp->data + 11;
       SKIPWS (p);
       strfcpy (fcc, p, fcclen);
@@ -341,75 +329,71 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size
       /* remove the X-Mutt-Fcc: header field */
       next = tmp->next;
       if (last)
-       last->next = tmp->next;
+        last->next = tmp->next;
       else
-       hdr->env->userhdrs = tmp->next;
+        hdr->env->userhdrs = tmp->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
       tmp = next;
     }
     else if ((WithCrypto & APPLICATION_PGP)
-             && (mutt_strncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
-                                                      * by old mutt versions
-                                                      */
-                 || mutt_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0))
-    {
+             && (mutt_strncmp ("Pgp:", tmp->data, 4) == 0       /* this is generated
+                                                                 * by old mutt versions
+                                                                 */
+                 || mutt_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)) {
       hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
       hdr->security |= APPLICATION_PGP;
-       
+
       /* remove the pgp field */
       next = tmp->next;
       if (last)
-       last->next = tmp->next;
+        last->next = tmp->next;
       else
-       hdr->env->userhdrs = tmp->next;
+        hdr->env->userhdrs = tmp->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
       tmp = next;
     }
     else if ((WithCrypto & APPLICATION_SMIME)
-             && mutt_strncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0)
-    {
+             && mutt_strncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0) {
       hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
       hdr->security |= APPLICATION_SMIME;
-       
+
       /* remove the smime field */
       next = tmp->next;
       if (last)
-       last->next = tmp->next;
+        last->next = tmp->next;
       else
-       hdr->env->userhdrs = tmp->next;
+        hdr->env->userhdrs = tmp->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
       tmp = next;
     }
 
 #ifdef MIXMASTER
-    else if (mutt_strncmp ("X-Mutt-Mix:", tmp->data, 11) == 0)
-    {
+    else if (mutt_strncmp ("X-Mutt-Mix:", tmp->data, 11) == 0) {
       char *t;
+
       mutt_free_list (&hdr->chain);
-      
+
       t = strtok (tmp->data + 11, " \t\n");
-      while (t)
-      {
-       hdr->chain = mutt_add_list (hdr->chain, t);
-       t = strtok (NULL, " \t\n");
+      while (t) {
+        hdr->chain = mutt_add_list (hdr->chain, t);
+        t = strtok (NULL, " \t\n");
       }
-      
+
       next = tmp->next;
-      if (last) 
-       last->next = tmp->next;
+      if (last)
+        last->next = tmp->next;
       else
-       hdr->env->userhdrs = tmp->next;
+        hdr->env->userhdrs = tmp->next;
       tmp->next = NULL;
       mutt_free_list (&tmp);
       tmp = next;
     }
 #endif
 
-    else
-    {
+    else {
       last = tmp;
       tmp = tmp->next;
     }
@@ -427,93 +411,87 @@ int mutt_parse_crypt_hdr (char *p, int set_signas)
 
   if (!WithCrypto)
     return 0;
-   
+
   SKIPWS (p);
-  for (; *p; p++)
-  {    
-     
-    switch (*p)
-    {
-      case 'e':
-      case 'E':
-        pgp |= ENCRYPT;
-        break;
-
-      case 's':    
-      case 'S':
-        pgp |= SIGN;
-        q = pgp_sign_as;
-      
-        if (*(p+1) == '<')
-        {
-          for (p += 2; 
-              *p && *p != '>' && q < pgp_sign_as + sizeof (pgp_sign_as) - 1;
-               *q++ = *p++)
-           ;
-
-          if (*p!='>')
-          {
-            mutt_error _("Illegal PGP header");
-            return 0;
-          }
+  for (; *p; p++) {
+
+    switch (*p) {
+    case 'e':
+    case 'E':
+      pgp |= ENCRYPT;
+      break;
+
+    case 's':
+    case 'S':
+      pgp |= SIGN;
+      q = pgp_sign_as;
+
+      if (*(p + 1) == '<') {
+        for (p += 2;
+             *p && *p != '>' && q < pgp_sign_as + sizeof (pgp_sign_as) - 1;
+             *q++ = *p++);
+
+        if (*p != '>') {
+          mutt_error _("Illegal PGP header");
+
+          return 0;
         }
-       
-        *q = '\0';
-        break;
+      }
+
+      *q = '\0';
+      break;
 
       /* This used to be the micalg parameter.
        * 
        * It's no longer needed, so we just skip the parameter in order
        * to be able to recall old messages.
        */
-      case 'm':
-      case 'M':
-        if(*(p+1) == '<')
-        {
-         for (p += 2; *p && *p != '>'; p++)
-           ;
-         if(*p != '>')
-         {
-           mutt_error _("Illegal PGP header");
-           return 0;
-         }
-       }
-
-       break;
-         
-         
-      case 'c':
-      case 'C':
-       q = smime_cryptalg;
-       
-        if(*(p+1) == '<')
-       {
-         for(p += 2; *p && *p != '>' && q < smime_cryptalg + sizeof(smime_cryptalg) - 1;
-             *q++ = *p++)
-           ;
-         
-         if(*p != '>')
-         {
-           mutt_error _("Illegal S/MIME header");
-           return 0;
-         }
-       }
-
-       *q = '\0';
-       break;
-
-      case 'i':
-      case 'I':
-       pgp |= INLINE;
-       break;
-
-      default:
-        mutt_error _("Illegal PGP header");
-        return 0;
+    case 'm':
+    case 'M':
+      if (*(p + 1) == '<') {
+        for (p += 2; *p && *p != '>'; p++);
+        if (*p != '>') {
+          mutt_error _("Illegal PGP header");
+
+          return 0;
+        }
+      }
+
+      break;
+
+
+    case 'c':
+    case 'C':
+      q = smime_cryptalg;
+
+      if (*(p + 1) == '<') {
+        for (p += 2;
+             *p && *p != '>'
+             && q < smime_cryptalg + sizeof (smime_cryptalg) - 1;
+             *q++ = *p++);
+
+        if (*p != '>') {
+          mutt_error _("Illegal S/MIME header");
+
+          return 0;
+        }
+      }
+
+      *q = '\0';
+      break;
+
+    case 'i':
+    case 'I':
+      pgp |= INLINE;
+      break;
+
+    default:
+      mutt_error _("Illegal PGP header");
+      return 0;
     }
-     
+
   }
+
   /* the cryptalg field must not be empty */
   if ((WithCrypto & APPLICATION_SMIME) && *smime_cryptalg)
     mutt_str_replace (&SmimeCryptAlg, smime_cryptalg);
@@ -526,23 +504,24 @@ int mutt_parse_crypt_hdr (char *p, int set_signas)
 
 
 
-int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
-                              short weed)
+int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr,
+                           HEADER * hdr, short weed)
 {
   MESSAGE *msg = NULL;
   char file[_POSIX_PATH_MAX];
   BODY *b;
   FILE *bfp;
-  
+
   int rv = -1;
   STATE s;
-  
+
   memset (&s, 0, sizeof (s));
-  
+
   if (!fp && (msg = mx_open_message (ctx, hdr->msgno)) == NULL)
     return (-1);
 
-  if (!fp) fp = msg->fp;
+  if (!fp)
+    fp = msg->fp;
 
   bfp = fp;
 
@@ -555,28 +534,31 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
   mutt_parse_part (fp, newhdr->content);
 
   FREE (&newhdr->env->message_id);
-  FREE (&newhdr->env->mail_followup_to); /* really? */
+  FREE (&newhdr->env->mail_followup_to);        /* really? */
 
   /* decrypt pgp/mime encoded messages */
 
-  if ((WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security)
-      && mutt_is_multipart_encrypted (newhdr->content))
-  {
-    int ccap = WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security;
+  if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security)
+      && mutt_is_multipart_encrypted (newhdr->content)) {
+    int ccap =
+      WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security;
     newhdr->security |= ENCRYPT | ccap;
     if (!crypt_valid_passphrase (ccap))
       goto err;
 
     mutt_message _("Decrypting message...");
-    if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) 
-       || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) 
-       || b == NULL)
-    {
- err:
+
+    if (((ccap & APPLICATION_PGP)
+         && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
+        || ((ccap & APPLICATION_SMIME)
+            && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
+        || b == NULL) {
+    err:
       mx_close_message (&msg);
       mutt_free_envelope (&newhdr->env);
       mutt_free_body (&newhdr->content);
       mutt_error _("Decryption failed.");
+
       return -1;
     }
 
@@ -590,16 +572,18 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
    * remove a potential multipart/signed layer - useful when
    * resending messages 
    */
-  
-  if (WithCrypto && mutt_is_multipart_signed (newhdr->content))
-  {
+
+  if (WithCrypto && mutt_is_multipart_signed (newhdr->content)) {
     newhdr->security |= SIGN;
     if ((WithCrypto & APPLICATION_PGP)
-        && ascii_strcasecmp (mutt_get_parameter ("protocol", newhdr->content->parameter), "application/pgp-signature") == 0)
+        &&
+        ascii_strcasecmp (mutt_get_parameter
+                          ("protocol", newhdr->content->parameter),
+                          "application/pgp-signature") == 0)
       newhdr->security |= APPLICATION_PGP;
     else if ((WithCrypto & APPLICATION_SMIME))
       newhdr->security |= APPLICATION_SMIME;
-    
+
     /* destroy the signature */
     mutt_free_body (&newhdr->content->parts->next);
     newhdr->content = mutt_remove_multipart (newhdr->content);
@@ -620,23 +604,20 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
     newhdr->content = mutt_remove_multipart (newhdr->content);
 
   s.fpin = bfp;
-  
+
   /* create temporary files for all attachments */
-  for (b = newhdr->content; b; b = b->next)
-  {
-    
+  for (b = newhdr->content; b; b = b->next) {
+
     /* what follows is roughly a receive-mode variant of
      * mutt_get_tmp_attachment () from muttlib.c
      */
 
     file[0] = '\0';
-    if (b->filename)
-    {
+    if (b->filename) {
       strfcpy (file, b->filename, sizeof (file));
       b->d_filename = safe_strdup (b->filename);
     }
-    else
-    {
+    else {
       /* avoid Content-Disposition: header with temporary filename */
       b->use_disp = 0;
     }
@@ -645,28 +626,26 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
 
     s.flags = 0;
 
-    if (b->type == TYPETEXT)
-    {
-      if (!ascii_strcasecmp ("yes", mutt_get_parameter ("x-mutt-noconv", b->parameter)))
-       b->noconv = 1;
-      else
-      {
-       s.flags |= M_CHARCONV;
-       b->noconv = 0;
+    if (b->type == TYPETEXT) {
+      if (!ascii_strcasecmp
+          ("yes", mutt_get_parameter ("x-mutt-noconv", b->parameter)))
+        b->noconv = 1;
+      else {
+        s.flags |= M_CHARCONV;
+        b->noconv = 0;
       }
 
       mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
     }
 
-    mutt_adv_mktemp (file, sizeof(file));
+    mutt_adv_mktemp (file, sizeof (file));
     if ((s.fpout = safe_fopen (file, "w")) == NULL)
       goto bail;
 
-    
-    if ((WithCrypto & APPLICATION_PGP) 
-       && (mutt_is_application_pgp (b) & (ENCRYPT|SIGN)))
-    {
-      
+
+    if ((WithCrypto & APPLICATION_PGP)
+        && (mutt_is_application_pgp (b) & (ENCRYPT | SIGN))) {
+
       mutt_body_handler (b, &s);
 
       newhdr->security |= mutt_is_application_pgp (newhdr->content);
@@ -687,21 +666,22 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
     mutt_stamp_attachment (b);
 
     mutt_free_body (&b->parts);
-    if (b->hdr) b->hdr->content = NULL; /* avoid dangling pointer */
+    if (b->hdr)
+      b->hdr->content = NULL;   /* avoid dangling pointer */
   }
 
   /* Fix encryption flags. */
-  
+
   /* No inline if multipart. */
   if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next)
     newhdr->security &= ~INLINE;
-  
+
   /* Do we even support multiple mechanisms? */
-  newhdr->security &= WithCrypto | ~(APPLICATION_PGP|APPLICATION_SMIME);
-  
+  newhdr->security &= WithCrypto | ~(APPLICATION_PGP | APPLICATION_SMIME);
+
   /* Theoretically, both could be set. Take the one the user wants to set by default. */
-  if ((newhdr->security & APPLICATION_PGP) && (newhdr->security & APPLICATION_SMIME))
-  {
+  if ((newhdr->security & APPLICATION_PGP)
+      && (newhdr->security & APPLICATION_SMIME)) {
     if (option (OPTSMIMEISDEFAULT))
       newhdr->security &= ~APPLICATION_PGP;
     else
@@ -709,18 +689,19 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
   }
 
   rv = 0;
-  
-  bail:
-  
+
+bail:
+
   /* that's it. */
-  if (bfp != fp) fclose (bfp);
-  if (msg) mx_close_message (&msg);
-  
-  if (rv == -1)
-  {
+  if (bfp != fp)
+    fclose (bfp);
+  if (msg)
+    mx_close_message (&msg);
+
+  if (rv == -1) {
     mutt_free_envelope (&newhdr->env);
     mutt_free_body (&newhdr->content);
   }
-  
+
   return rv;
 }
index 8ea4388..f796c17 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #ifdef DEBUG
 #define dprint(N,X) do { if(debuglevel>=N) fprintf X; } while (0)
 #else
-#define dprint(N,X) 
+#define dprint(N,X)
 #endif
 
 #define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
 
 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
 void _mutt_make_string (char *, size_t, const char *, CONTEXT *,
-       HEADER *, format_flag);
+                        HEADER *, format_flag);
 
 int mutt_extract_token (BUFFER *, BUFFER *, int);
-BUFFER * mutt_buffer_init (BUFFER *);
-BUFFER * mutt_buffer_from (BUFFER *, char *);
-void mutt_buffer_free(BUFFER **);
-void mutt_buffer_add (BUFFER*, const char*, size_t);
-void mutt_buffer_addstr (BUFFER*, const char*);
-void mutt_buffer_addch (BUFFER*, char);
+BUFFER *mutt_buffer_init (BUFFER *);
+BUFFER *mutt_buffer_from (BUFFER *, char *);
+void mutt_buffer_free (BUFFER **);
+void mutt_buffer_add (BUFFER *, const char *, size_t);
+void mutt_buffer_addstr (BUFFER *, const char *);
+void mutt_buffer_addch (BUFFER *, char);
 
 #define mutt_system(x) _mutt_system(x,0)
 int _mutt_system (const char *, int);
@@ -58,10 +58,10 @@ int _mutt_aside_thread (HEADER *, short, short);
 
 #define mutt_collapse_thread(x,y) _mutt_traverse_thread (x,y,M_THREAD_COLLAPSE)
 #define mutt_uncollapse_thread(x,y) _mutt_traverse_thread (x,y,M_THREAD_UNCOLLAPSE)
-#define mutt_get_hidden(x,y)_mutt_traverse_thread (x,y,M_THREAD_GET_HIDDEN) 
+#define mutt_get_hidden(x,y)_mutt_traverse_thread (x,y,M_THREAD_GET_HIDDEN)
 #define mutt_thread_contains_unread(x,y) _mutt_traverse_thread (x,y,M_THREAD_UNREAD)
 #define mutt_thread_next_unread(x,y) _mutt_traverse_thread(x,y,M_THREAD_NEXT_UNREAD)
-int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag);
+int _mutt_traverse_thread (CONTEXT * ctx, HEADER * hdr, int flag);
 
 
 #define mutt_new_parameter() safe_calloc (1, sizeof (PARAMETER))
@@ -69,12 +69,15 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag);
 #define mutt_new_envelope() safe_calloc (1, sizeof (ENVELOPE))
 #define mutt_new_enter_state() safe_calloc (1, sizeof (ENTER_STATE))
 
-typedef const char * format_t (char *, size_t, char, const char *, const char *, const char *, const char *, unsigned long, format_flag);
+typedef const char *format_t (char *, size_t, char, const char *,
+                              const char *, const char *, const char *,
+                              unsigned long, format_flag);
 
-void mutt_FormatString (char *, size_t, const char *, format_t *, unsigned long, format_flag);
+void mutt_FormatString (char *, size_t, const char *, format_t *,
+                        unsigned long, format_flag);
 void mutt_parse_content_type (char *, BODY *);
 void mutt_generate_boundary (PARAMETER **);
-void mutt_delete_parameter (const char *attribute, PARAMETER **p);
+void mutt_delete_parameter (const char *attribute, PARAMETER ** p);
 void mutt_set_parameter (const char *, const char *, PARAMETER **);
 
 
@@ -100,27 +103,32 @@ BODY *mutt_parse_multipart (FILE *, const char *, long, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 
-CONTENT *mutt_get_content_info (const char *fname, BODY *b);
+CONTENT *mutt_get_content_info (const char *fname, BODY * b);
 
 HASH *mutt_make_id_hash (CONTEXT *);
 HASH *mutt_make_subj_hash (CONTEXT *);
 
-LIST *mutt_make_references(ENVELOPE *e);
+LIST *mutt_make_references (ENVELOPE * e);
 LIST *mutt_parse_references (char *, int);
 
 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
 HEADER *mutt_dup_header (HEADER *);
 
 #if USE_HCACHE
-void *mutt_hcache_open(const char *path, const char *folder);
-void mutt_hcache_close(void *db);
-HEADER *mutt_hcache_restore(const unsigned char *d, HEADER **oh);
-void *mutt_hcache_fetch(void *db, const char *filename, size_t (*keylen)(const char *fn));
-int mutt_hcache_store(void *db, const char *filename, HEADER *h, uint64_t uid_validity, size_t (*keylen)(const char *fn));
-int mutt_hcache_delete(void *db, const char *filename, size_t (*keylen)(const char *fn));
+void *mutt_hcache_open (const char *path, const char *folder);
+void mutt_hcache_close (void *db);
+HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh);
+void *mutt_hcache_fetch (void *db, const char *filename,
+                         size_t (*keylen) (const char *fn));
+int mutt_hcache_store (void *db, const char *filename, HEADER * h,
+                       uint64_t uid_validity,
+                       size_t (*keylen) (const char *fn));
+int mutt_hcache_delete (void *db, const char *filename,
+                        size_t (*keylen) (const char *fn));
 #endif /* USE_HCACHE */
 
-ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, int, int);
+ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *,
+                                  int, int);
 
 time_t mutt_decrease_mtime (const char *, struct stat *);
 time_t mutt_local_tz (time_t);
@@ -128,16 +136,14 @@ time_t mutt_mktime (struct tm *, int);
 time_t mutt_parse_date (const char *, HEADER *);
 int is_from (const char *, char *, size_t, time_t *);
 
-const char *mutt_attach_fmt (
-       char *dest,
-       size_t destlen,
-       char op,
-       const char *src,
-       const char *prefix,
-       const char *ifstring,
-       const char *elsestring,
-       unsigned long data,
-       format_flag flags);
+const char *mutt_attach_fmt (char *dest,
+                             size_t destlen,
+                             char op,
+                             const char *src,
+                             const char *prefix,
+                             const char *ifstring,
+                             const char *elsestring,
+                             unsigned long data, format_flag flags);
 
 
 char *mutt_charset_hook (const char *);
@@ -155,12 +161,13 @@ char *mutt_make_date (char *, size_t);
 
 const char *mutt_make_version (void);
 
-const char *mutt_fqdn(short);
+const char *mutt_fqdn (short);
 
 REGEXP *mutt_compile_regexp (const char *, int);
 
-void mutt_account_hook (const char* url);
-void mutt_add_to_reference_headers (ENVELOPE *env, ENVELOPE *curenv, LIST ***pp, LIST ***qq);
+void mutt_account_hook (const char *url);
+void mutt_add_to_reference_headers (ENVELOPE * env, ENVELOPE * curenv,
+                                    LIST *** pp, LIST *** qq);
 void mutt_adv_mktemp (char *, size_t);
 void mutt_alias_menu (char *, size_t, ALIAS *);
 void mutt_allow_interrupt (int);
@@ -168,16 +175,16 @@ void mutt_attach_init (BODY *);
 void mutt_block_signals (void);
 void mutt_block_signals_system (void);
 void mutt_body_handler (BODY *, STATE *);
-int  mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
+int mutt_bounce_message (FILE * fp, HEADER *, ADDRESS *);
 void mutt_break_thread (HEADER *);
 void mutt_buffy (char *, size_t);
-int  mutt_buffy_list (void);
+int mutt_buffy_list (void);
 void mutt_canonical_charset (char *, size_t, const char *);
 void mutt_check_rescore (CONTEXT *);
 void mutt_clear_error (void);
 void mutt_create_alias (ENVELOPE *, ADDRESS *);
 void mutt_decode_attachment (BODY *, STATE *);
-void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd);
+void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd);
 void mutt_default_save (char *, size_t, HEADER *);
 void mutt_display_address (ENVELOPE *);
 void mutt_display_sanitize (char *);
@@ -191,13 +198,14 @@ void mutt_expand_aliases_env (ENVELOPE *);
 void mutt_expand_file_fmt (char *, size_t, const char *, const char *);
 void mutt_expand_fmt (char *, size_t, const char *, const char *);
 void mutt_expand_link (char *, const char *, const char *);
-void mutt_fix_reply_recipients (ENVELOPE *env);
+void mutt_fix_reply_recipients (ENVELOPE * env);
 void mutt_folder_hook (char *);
-void mutt_format_string (char *, size_t, int, int, int, char, const char *, size_t, int);
+void mutt_format_string (char *, size_t, int, int, int, char, const char *,
+                         size_t, int);
 void mutt_format_s (char *, size_t, const char *, const char *);
 void mutt_format_s_tree (char *, size_t, const char *, const char *);
-void mutt_forward_intro (FILE *fp, HEADER *cur);
-void mutt_forward_trailer (FILE *fp);
+void mutt_forward_intro (FILE * fp, HEADER * cur);
+void mutt_forward_trailer (FILE * fp);
 void mutt_free_alias (ALIAS **);
 void mutt_free_body (BODY **);
 void mutt_free_color (int fg, int bg);
@@ -210,17 +218,19 @@ void mutt_generate_header (char *, size_t, HEADER *, int);
 void mutt_help (int);
 void mutt_draw_tree (CONTEXT *);
 void mutt_check_lookup_list (BODY *, char *, int);
-void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out);
-void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur);
+void mutt_make_attribution (CONTEXT * ctx, HEADER * cur, FILE * out);
+void mutt_make_forward_subject (ENVELOPE * env, CONTEXT * ctx, HEADER * cur);
 void mutt_make_help (char *, size_t, char *, int, int);
-void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, ENVELOPE *curenv);
-void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out);
+void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx,
+                                   HEADER * cur, ENVELOPE * curenv);
+void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out);
 void mutt_message_to_7bit (BODY *, FILE *);
+
 #define mutt_mktemp(a) _mutt_mktemp (a, __FILE__, __LINE__)
 void _mutt_mktemp (char *, const char *, int);
 void mutt_normalize_time (struct tm *);
 void mutt_paddstr (int, const char *);
-void mutt_parse_mime_message (CONTEXT *ctx, HEADER *);
+void mutt_parse_mime_message (CONTEXT * ctx, HEADER *);
 void mutt_parse_part (FILE *, BODY *);
 void mutt_perror (const char *);
 void mutt_prepare_envelope (ENVELOPE *, int);
@@ -232,30 +242,33 @@ void mutt_print_message (HEADER *);
 void mutt_print_patchlist (void);
 void mutt_query_exit (void);
 void mutt_query_menu (char *, size_t);
-void mutt_safe_path (char *s, size_t l, ADDRESS *a);
-void mutt_save_path (char *s, size_t l, ADDRESS *a);
+void mutt_safe_path (char *s, size_t l, ADDRESS * a);
+void mutt_save_path (char *s, size_t l, ADDRESS * a);
 void mutt_score_message (CONTEXT *, HEADER *, int);
 void mutt_select_fcc (char *, size_t, HEADER *);
+
 #define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,NULL,NULL)
 void _mutt_select_file (char *, size_t, int, char ***, int *);
 void mutt_message_hook (CONTEXT *, HEADER *, int);
 void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
+
 #define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
 void mutt_set_followup_to (ENVELOPE *);
 void mutt_shell_escape (void);
 void mutt_show_error (void);
 void mutt_signal_init (void);
-void mutt_stamp_attachment (BODY *a);
+void mutt_stamp_attachment (BODY * a);
 void mutt_tabs_to_spaces (char *);
 void mutt_tag_set_flag (int, int);
 void mutt_unblock_signals (void);
 void mutt_unblock_signals_system (int);
-void mutt_update_encoding (BODY *a);
+void mutt_update_encoding (BODY * a);
 void mutt_update_tree (ATTACHPTR **, short);
 void mutt_version (void);
 void mutt_view_attachments (HEADER *);
 void mutt_write_references (LIST *, FILE *);
-void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
+void mutt_write_address_list (ADDRESS * adr, FILE * fp, int linelen,
+                              int display);
 void mutt_set_virtual (CONTEXT *);
 
 int mutt_addr_is_user (ADDRESS *);
@@ -274,28 +287,33 @@ int mutt_check_key (const char *);
 int mutt_check_menu (const char *);
 int mutt_check_mime_type (const char *);
 int mutt_check_month (const char *);
-int mutt_check_overwrite (const char *, const char *, char *, size_t, int *, char **);
+int mutt_check_overwrite (const char *, const char *, char *, size_t, int *,
+                          char **);
 int mutt_check_traditional_pgp (HEADER *, int *);
 int mutt_command_complete (char *, size_t, int, int);
 int mutt_var_value_complete (char *, size_t, int);
 int mutt_complete (char *, size_t);
-int mutt_compose_attachment (BODY *a);
+int mutt_compose_attachment (BODY * a);
 int mutt_copy_body (FILE *, BODY **, BODY *);
 int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int);
-int mutt_display_message (HEADER *h);
-int mutt_edit_attachment(BODY *);
+int mutt_display_message (HEADER * h);
+int mutt_edit_attachment (BODY *);
 int mutt_edit_message (CONTEXT *, HEADER *);
-int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);
+int mutt_fetch_recips (ENVELOPE * out, ENVELOPE * in, int flags);
 int mutt_chscmp (const char *s, const char *chs);
+
 #define mutt_is_utf8(a) mutt_chscmp (a, "utf-8")
 #define mutt_is_us_ascii(a) mutt_chscmp (a, "us-ascii")
 int mutt_parent_message (CONTEXT *, HEADER *);
-int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short);
+int mutt_prepare_template (FILE *, CONTEXT *, HEADER *, HEADER *, short);
 int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
+
 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
-int _mutt_enter_fname (const char *, char *, size_t, int *, int, int, char ***, int *);
-int  mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
-int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, ENTER_STATE *);
+int _mutt_enter_fname (const char *, char *, size_t, int *, int, int,
+                       char ***, int *);
+int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
+int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *,
+                        ENTER_STATE *);
 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
 int _mutt_get_field (char *, char *, size_t, int, int, char ***, int *);
 int mutt_get_hook_type (const char *);
@@ -303,10 +321,11 @@ int mutt_get_password (char *, char *, size_t);
 int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, size_t);
 int mutt_get_tmp_attachment (BODY *);
 int mutt_index_menu (void);
-int mutt_invoke_mta (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
+int mutt_invoke_mta (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *,
+                     int);
 int mutt_is_autoview (BODY *, const char *);
 int mutt_is_mail_list (ADDRESS *);
-int mutt_is_message_type(int, const char *);
+int mutt_is_message_type (int, const char *);
 int mutt_is_list_cc (int, ADDRESS *, ADDRESS *);
 int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *);
 int mutt_is_subscribed_list (ADDRESS *);
@@ -330,50 +349,53 @@ int mutt_parse_mailboxes (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_mono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_push (BUFFER *, BUFFER *, unsigned long, BUFFER *);
-int mutt_parse_rc_line (/* const */ char *, BUFFER *, BUFFER *);
-int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p,
-  short user_hdrs, short weed, short do_2047, LIST **lastp);
+int mutt_parse_rc_line ( /* const */ char *, BUFFER *, BUFFER *);
+int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
+                            short user_hdrs, short weed, short do_2047,
+                            LIST ** lastp);
 int mutt_parse_score (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_unscore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_pattern_func (int, char *);
-int mutt_pipe_attachment (FILE *, BODY *, const char *, char *); 
+int mutt_pipe_attachment (FILE *, BODY *, const char *, char *);
 int mutt_print_attachment (FILE *, BODY *);
 int mutt_query_complete (char *, size_t);
-int mutt_query_variables (LIST *queries);
+int mutt_query_variables (LIST * queries);
 int mutt_save_attachment (FILE *, BODY *, char *, int, HEADER *);
 void _mutt_save_message (HEADER *, CONTEXT *, int, int, int);
 int mutt_save_message (HEADER *, int, int, int, int *);
 int mutt_search_command (int, int);
-int mutt_skipchars (const char*, const char*);
+int mutt_skipchars (const char *, const char *);
 int mutt_strwidth (const char *);
 int mutt_compose_menu (HEADER *, char *, size_t, HEADER *);
 int mutt_thread_set_flag (HEADER *, int, int, int);
 int mutt_update_list_file (char *, char *, char *, char *);
 int mutt_user_is_recipient (HEADER *);
 void mutt_update_num_postponed (void);
-int mutt_view_attachment (FILE*, BODY *, int, HEADER *, ATTACHPTR **, short);
+int mutt_view_attachment (FILE *, BODY *, int, HEADER *, ATTACHPTR **, short);
 int mutt_wait_filter (pid_t);
 int mutt_which_case (const char *);
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *);
+int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, int,
+                    char *);
 int mutt_write_mime_body (BODY *, FILE *);
 int mutt_write_mime_header (BODY *, FILE *);
 int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int);
 int mutt_yesorno (const char *, int);
-void mutt_set_header_color(CONTEXT *, HEADER *);
+void mutt_set_header_color (CONTEXT *, HEADER *);
 void mutt_sleep (short);
-int mutt_save_confirm (const char  *, struct stat *);
+int mutt_save_confirm (const char *, struct stat *);
 
 int mh_valid_message (const char *);
 
 pid_t mutt_create_filter (const char *, FILE **, FILE **, FILE **);
-pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int, int, int);
+pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int,
+                             int, int);
 
 ADDRESS *alias_reverse_lookup (ADDRESS *);
 
 /* base64.c */
-void mutt_to_base64 (unsigned char*, const unsigned char*, size_t, size_t);
-int mutt_from_base64 (char*, const char*);
+void mutt_to_base64 (unsigned char *, const unsigned char *, size_t, size_t);
+int mutt_from_base64 (char *, const char *);
 
 /* utf8.c */
 int mutt_wctoutf8 (char *s, unsigned int c);
@@ -392,10 +414,11 @@ int mutt_wctoutf8 (char *s, unsigned int c);
 
 #define new_pattern() safe_calloc(1, sizeof (pattern_t))
 
-int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h);
-pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err);
+int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
+                       CONTEXT * ctx, HEADER * h);
+pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err);
 void mutt_check_simple (char *s, size_t len, const char *simple);
-void mutt_pattern_free (pattern_t **pat);
+void mutt_pattern_free (pattern_t ** pat);
 
 /* ----------------------------------------------------------------------------
  * Prototypes for broken systems
@@ -469,7 +492,7 @@ extern int getopt ();
 extern int fputs ();
 extern int fputc ();
 extern int fclose ();
-extern int fprintf();
+extern int fprintf ();
 extern int printf ();
 extern int fgetc ();
 extern int tolower ();
@@ -510,5 +533,3 @@ int ioctl (int, int, ...);
 /* unsorted */
 void ci_bounce_message (HEADER *, int *);
 int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);
-
-
diff --git a/query.c b/query.c
index 90dc614..b9a4003 100644 (file)
--- a/query.c
+++ b/query.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <stdlib.h>
 #include <ctype.h>
 
-typedef struct query
-{
+typedef struct query {
   ADDRESS *addr;
   char *name;
   char *other;
   struct query *next;
 } QUERY;
 
-typedef struct entry
-{
+typedef struct entry {
   int tagged;
   QUERY *data;
 } ENTRY;
 
 static struct mapping_t QueryHelp[] = {
-  { N_("Exit"),   OP_EXIT },
-  { N_("Mail"),   OP_MAIL },
-  { N_("New Query"),  OP_QUERY },
-  { N_("Make Alias"), OP_CREATE_ALIAS },
-  { N_("Search"), OP_SEARCH },
-  { N_("Help"),   OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("Mail"), OP_MAIL},
+  {N_("New Query"), OP_QUERY},
+  {N_("Make Alias"), OP_CREATE_ALIAS},
+  {N_("Search"), OP_SEARCH},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
 /* Variables for outsizing output format */
 static int FirstColumn;
 static int SecondColumn;
 
-static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf);
+static void query_menu (char *buf, size_t buflen, QUERY * results,
+                        int retbuf);
 
-static ADDRESS *result_to_addr (QUERY *r)
+static ADDRESS *result_to_addr (QUERY * r)
 {
   static ADDRESS *tmp;
-  
+
   tmp = rfc822_cpy_adr (r->addr);
-  
-  if(!tmp->next && !tmp->personal)
+
+  if (!tmp->next && !tmp->personal)
     tmp->personal = safe_strdup (r->name);
-  
+
   mutt_addrlist_to_idna (tmp, NULL);
   return tmp;
 }
@@ -88,72 +87,65 @@ static QUERY *run_query (char *s, int quiet)
   int l;
 
 
-  mutt_expand_file_fmt (cmd, sizeof(cmd), QueryCmd, s);
+  mutt_expand_file_fmt (cmd, sizeof (cmd), QueryCmd, s);
 
-  if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0)
-  {
+  if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
     dprint (1, (debugfile, "unable to fork command: %s", cmd));
     return 0;
   }
   if (!quiet)
     mutt_message _("Waiting for response...");
+
   fgets (msg, sizeof (msg), fp);
   if ((p = strrchr (msg, '\n')))
     *p = '\0';
-  while ((buf = mutt_read_line (buf, &buflen, fp, &dummy)) != NULL)
-  {
-    if ((p = strtok(buf, "\t\n")))
-    {
-      if (first == NULL)
-      {
-       FirstColumn = 0;
-       SecondColumn = 0;
-       first = (QUERY *) safe_calloc (1, sizeof (QUERY));
-       cur = first;
+  while ((buf = mutt_read_line (buf, &buflen, fp, &dummy)) != NULL) {
+    if ((p = strtok (buf, "\t\n"))) {
+      if (first == NULL) {
+        FirstColumn = 0;
+        SecondColumn = 0;
+        first = (QUERY *) safe_calloc (1, sizeof (QUERY));
+        cur = first;
       }
-      else
-      {
-       cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY));
-       cur = cur->next;
+      else {
+        cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY));
+        cur = cur->next;
       }
 
       l = mutt_strwidth (p);
       if (l > SecondColumn)
-       SecondColumn = l;
-       
+        SecondColumn = l;
+
       cur->addr = rfc822_parse_adrlist (cur->addr, p);
-      p = strtok(NULL, "\t\n");
-      if (p)
-      {
-       l = mutt_strwidth (p);
-       if (l > FirstColumn)
-         FirstColumn = l;
-       cur->name = safe_strdup (p);
-       p = strtok(NULL, "\t\n");
-       if (p)
-       {
-         cur->other = safe_strdup (p);
-       }
+      p = strtok (NULL, "\t\n");
+      if (p) {
+        l = mutt_strwidth (p);
+        if (l > FirstColumn)
+          FirstColumn = l;
+        cur->name = safe_strdup (p);
+        p = strtok (NULL, "\t\n");
+        if (p) {
+          cur->other = safe_strdup (p);
+        }
       }
     }
   }
   FREE (&buf);
   fclose (fp);
-  if (mutt_wait_filter (thepid))
-  {
+  if (mutt_wait_filter (thepid)) {
     dprint (1, (debugfile, "Error: %s\n", msg));
-    if (!quiet)  mutt_error ("%s", msg);
+    if (!quiet)
+      mutt_error ("%s", msg);
   }
-  else
-  {
+  else {
     if (!quiet)
       mutt_message ("%s", msg);
   }
-  
+
   return first;
 }
 
-static int query_search (MUTTMENU *m, regex_t *re, int n)
+static int query_search (MUTTMENU * m, regex_t * re, int n)
 {
   ENTRY *table = (ENTRY *) m->data;
 
@@ -161,36 +153,34 @@ static int query_search (MUTTMENU *m, regex_t *re, int n)
     return 0;
   if (table[n].data->other && !regexec (re, table[n].data->other, 0, NULL, 0))
     return 0;
-  if (table[n].data->addr)
-  {
-    if (table[n].data->addr->personal && 
-       !regexec (re, table[n].data->addr->personal, 0, NULL, 0))
+  if (table[n].data->addr) {
+    if (table[n].data->addr->personal &&
+        !regexec (re, table[n].data->addr->personal, 0, NULL, 0))
       return 0;
     if (table[n].data->addr->mailbox &&
-       !regexec (re, table[n].data->addr->mailbox, 0, NULL, 0))
+        !regexec (re, table[n].data->addr->mailbox, 0, NULL, 0))
       return 0;
 #ifdef EXACT_ADDRESS
     if (table[n].data->addr->val &&
-       !regexec (re, table[n].data->addr->val, 0, NULL, 0))
+        !regexec (re, table[n].data->addr->val, 0, NULL, 0))
       return 0;
 #endif
   }
-  
+
   return REG_NOMATCH;
 }
 
 /* This is the callback routine from mutt_menuLoop() which is used to generate
  * a menu entry for the requested item number.
  */
-#define QUERY_MIN_COLUMN_LENGHT 20 /* Must be < 70/2 */
-static void query_entry (char *s, size_t slen, MUTTMENU *m, int num)
+#define QUERY_MIN_COLUMN_LENGHT 20      /* Must be < 70/2 */
+static void query_entry (char *s, size_t slen, MUTTMENU * m, int num)
 {
   ENTRY *table = (ENTRY *) m->data;
   char buf2[SHORT_STRING], buf[SHORT_STRING] = "";
 
   /* need a query format ... hard coded constants are not good */
-  while (FirstColumn + SecondColumn > 70)
-  {
+  while (FirstColumn + SecondColumn > 70) {
     FirstColumn = FirstColumn * 3 / 4;
     SecondColumn = SecondColumn * 3 / 4;
     if (FirstColumn < QUERY_MIN_COLUMN_LENGHT)
@@ -202,25 +192,23 @@ static void query_entry (char *s, size_t slen, MUTTMENU *m, int num)
   rfc822_write_address (buf, sizeof (buf), table[num].data->addr, 1);
 
   mutt_format_string (buf2, sizeof (buf2),
-                     FirstColumn + 2, FirstColumn + 2,
-                     0, ' ', table[num].data->name,
-                     mutt_strlen (table[num].data->name), 0);
-
-  snprintf (s, slen, " %c %3d %s %-*.*s %s", 
-           table[num].tagged ? '*':' ',
-           num+1,
-           buf2,
-           SecondColumn+2,
-           SecondColumn+2,
-           buf,
-           NONULL (table[num].data->other));
+                      FirstColumn + 2, FirstColumn + 2,
+                      0, ' ', table[num].data->name,
+                      mutt_strlen (table[num].data->name), 0);
+
+  snprintf (s, slen, " %c %3d %s %-*.*s %s",
+            table[num].tagged ? '*' : ' ',
+            num + 1,
+            buf2,
+            SecondColumn + 2,
+            SecondColumn + 2, buf, NONULL (table[num].data->other));
 }
 
-static int query_tag (MUTTMENU *menu, int n, int m)
+static int query_tag (MUTTMENU * menu, int n, int m)
 {
   ENTRY *cur = &((ENTRY *) menu->data)[n];
   int ot = cur->tagged;
-  
+
   cur->tagged = m >= 0 ? m : !cur->tagged;
   return cur->tagged - ot;
 }
@@ -230,18 +218,16 @@ int mutt_query_complete (char *buf, size_t buflen)
   QUERY *results = NULL;
   ADDRESS *tmpa;
 
-  if (!QueryCmd)
-  {
+  if (!QueryCmd) {
     mutt_error _("Query command not defined.");
+
     return 0;
   }
 
   results = run_query (buf, 1);
-  if (results)
-  {
+  if (results) {
     /* only one response? */
-    if (results->next == NULL)
-    {
+    if (results->next == NULL) {
       tmpa = result_to_addr (results);
       mutt_addrlist_to_local (tmpa);
       buf[0] = '\0';
@@ -258,25 +244,23 @@ int mutt_query_complete (char *buf, size_t buflen)
 
 void mutt_query_menu (char *buf, size_t buflen)
 {
-  if (!QueryCmd)
-  {
+  if (!QueryCmd) {
     mutt_error _("Query command not defined.");
+
     return;
   }
 
-  if (buf == NULL)
-  {
+  if (buf == NULL) {
     char buffer[STRING] = "";
 
     query_menu (buffer, sizeof (buffer), NULL, 0);
   }
-  else
-  {
+  else {
     query_menu (buf, buflen, NULL, 1);
   }
 }
 
-static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
+static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
 {
   MUTTMENU *menu;
   HEADER *msg = NULL;
@@ -295,225 +279,208 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
   menu->tag = query_tag;
   menu->menu = MENU_QUERY;
   menu->title = title;
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
+  menu->help =
+    mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
 
-  if (results == NULL)
-  {
+  if (results == NULL) {
     /* Prompt for Query */
-    if (mutt_get_field (_("Query: "), buf, buflen, 0) == 0 && buf[0])
-    {
+    if (mutt_get_field (_("Query: "), buf, buflen, 0) == 0 && buf[0]) {
       results = run_query (buf, 0);
     }
   }
 
-  if (results)
-  {
+  if (results) {
     snprintf (title, sizeof (title), _("Query '%s'"), buf);
 
     /* count the number of results */
     for (queryp = results; queryp; queryp = queryp->next)
       menu->max++;
 
-    menu->data = QueryTable = (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
+    menu->data = QueryTable =
+      (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
 
     for (i = 0, queryp = results; queryp; queryp = queryp->next, i++)
       QueryTable[i].data = queryp;
 
-    while (!done)
-    {
-      switch ((op = mutt_menuLoop (menu)))
-      {
-       case OP_QUERY_APPEND:
-       case OP_QUERY:
-         if (mutt_get_field (_("Query: "), buf, buflen, 0) == 0 && buf[0])
-         {
-           QUERY *newresults = NULL;
-
-           newresults = run_query (buf, 0);
-
-           menu->redraw = REDRAW_FULL;
-           if (newresults)
-           {
-             snprintf (title, sizeof (title), _("Query '%s'"), buf);
-
-             if (op == OP_QUERY)
-             {
-               queryp = results;
-               while (queryp)
-               {
-                 rfc822_free_address (&queryp->addr);
-                 FREE (&queryp->name);
-                 FREE (&queryp->other);
-                 results = queryp->next;
-                 FREE (&queryp);
-                 queryp = results;
-               }
-               results = newresults;
-               FREE (&QueryTable);
-             }
-             else
-             {
-               /* append */
-               for (queryp = results; queryp->next; queryp = queryp->next);
-
-               queryp->next = newresults;
-             }
-
-
-             menu->current = 0;
-             mutt_menuDestroy (&menu);
-             menu = mutt_new_menu ();
-             menu->make_entry = query_entry;
-             menu->search = query_search;
-             menu->tag = query_tag;
-             menu->menu = MENU_QUERY;
-             menu->title = title;
-             menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
-
-             /* count the number of results */
-             for (queryp = results; queryp; queryp = queryp->next)
-               menu->max++;
-
-             if (op == OP_QUERY)
-             {
-               menu->data = QueryTable = 
-                 (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
-
-               for (i = 0, queryp = results; queryp; 
-                    queryp = queryp->next, i++)
-                 QueryTable[i].data = queryp;
-             }
-             else
-             {
-               int clear = 0;
-
-               /* append */
-               safe_realloc (&QueryTable, menu->max * sizeof (ENTRY));
-
-               menu->data = QueryTable;
-
-               for (i = 0, queryp = results; queryp; 
-                    queryp = queryp->next, i++)
-               {
-                 /* once we hit new entries, clear/init the tag */
-                 if (queryp == newresults)
-                   clear = 1;
-
-                 QueryTable[i].data = queryp;
-                 if (clear)
-                   QueryTable[i].tagged = 0;
-               }
-             }
-           }
-         }
-         break;
-
-       case OP_CREATE_ALIAS:
-         if (menu->tagprefix)
-         {
-           ADDRESS *naddr = NULL;
-
-           for (i = 0; i < menu->max; i++)
-             if (QueryTable[i].tagged)
-             {
-               ADDRESS *a = result_to_addr(QueryTable[i].data);
-               rfc822_append (&naddr, a);
-               rfc822_free_address (&a);
-             }
-
-           mutt_create_alias (NULL, naddr);
-         }
-         else
-         {
-           ADDRESS *a = result_to_addr(QueryTable[menu->current].data);
-           mutt_create_alias (NULL, a);
-           rfc822_free_address (&a);
-         }
-         break;
-
-       case OP_GENERIC_SELECT_ENTRY:
-         if (retbuf)
-         {
-           done = 2;
-           break;
-         }
-         /* fall through to OP_MAIL */
-
-       case OP_MAIL:
-         msg = mutt_new_header ();
-         msg->env = mutt_new_envelope ();
-         if (!menu->tagprefix)
-         {
-           msg->env->to = result_to_addr(QueryTable[menu->current].data);
-         }
-         else
-         {
-           for (i = 0; i < menu->max; i++)
-             if (QueryTable[i].tagged)
-             {
-               ADDRESS *a = result_to_addr(QueryTable[i].data);
-               rfc822_append (&msg->env->to, a);
-               rfc822_free_address (&a);
-             }
-         }
-         ci_send_message (0, msg, NULL, Context, NULL);
-         menu->redraw = REDRAW_FULL;
-         break;
-
-       case OP_EXIT:
-         done = 1;
-         break;
+    while (!done) {
+      switch ((op = mutt_menuLoop (menu))) {
+      case OP_QUERY_APPEND:
+      case OP_QUERY:
+        if (mutt_get_field (_("Query: "), buf, buflen, 0) == 0 && buf[0]) {
+          QUERY *newresults = NULL;
+
+          newresults = run_query (buf, 0);
+
+          menu->redraw = REDRAW_FULL;
+          if (newresults) {
+            snprintf (title, sizeof (title), _("Query '%s'"), buf);
+
+            if (op == OP_QUERY) {
+              queryp = results;
+              while (queryp) {
+                rfc822_free_address (&queryp->addr);
+                FREE (&queryp->name);
+                FREE (&queryp->other);
+                results = queryp->next;
+                FREE (&queryp);
+                queryp = results;
+              }
+              results = newresults;
+              FREE (&QueryTable);
+            }
+            else {
+              /* append */
+              for (queryp = results; queryp->next; queryp = queryp->next);
+
+              queryp->next = newresults;
+            }
+
+
+            menu->current = 0;
+            mutt_menuDestroy (&menu);
+            menu = mutt_new_menu ();
+            menu->make_entry = query_entry;
+            menu->search = query_search;
+            menu->tag = query_tag;
+            menu->menu = MENU_QUERY;
+            menu->title = title;
+            menu->help =
+              mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY,
+                                 QueryHelp);
+
+            /* count the number of results */
+            for (queryp = results; queryp; queryp = queryp->next)
+              menu->max++;
+
+            if (op == OP_QUERY) {
+              menu->data = QueryTable =
+                (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
+
+              for (i = 0, queryp = results; queryp;
+                   queryp = queryp->next, i++)
+                QueryTable[i].data = queryp;
+            }
+            else {
+              int clear = 0;
+
+              /* append */
+              safe_realloc (&QueryTable, menu->max * sizeof (ENTRY));
+
+              menu->data = QueryTable;
+
+              for (i = 0, queryp = results; queryp;
+                   queryp = queryp->next, i++) {
+                /* once we hit new entries, clear/init the tag */
+                if (queryp == newresults)
+                  clear = 1;
+
+                QueryTable[i].data = queryp;
+                if (clear)
+                  QueryTable[i].tagged = 0;
+              }
+            }
+          }
+        }
+        break;
+
+      case OP_CREATE_ALIAS:
+        if (menu->tagprefix) {
+          ADDRESS *naddr = NULL;
+
+          for (i = 0; i < menu->max; i++)
+            if (QueryTable[i].tagged) {
+              ADDRESS *a = result_to_addr (QueryTable[i].data);
+
+              rfc822_append (&naddr, a);
+              rfc822_free_address (&a);
+            }
+
+          mutt_create_alias (NULL, naddr);
+        }
+        else {
+          ADDRESS *a = result_to_addr (QueryTable[menu->current].data);
+
+          mutt_create_alias (NULL, a);
+          rfc822_free_address (&a);
+        }
+        break;
+
+      case OP_GENERIC_SELECT_ENTRY:
+        if (retbuf) {
+          done = 2;
+          break;
+        }
+        /* fall through to OP_MAIL */
+
+      case OP_MAIL:
+        msg = mutt_new_header ();
+        msg->env = mutt_new_envelope ();
+        if (!menu->tagprefix) {
+          msg->env->to = result_to_addr (QueryTable[menu->current].data);
+        }
+        else {
+          for (i = 0; i < menu->max; i++)
+            if (QueryTable[i].tagged) {
+              ADDRESS *a = result_to_addr (QueryTable[i].data);
+
+              rfc822_append (&msg->env->to, a);
+              rfc822_free_address (&a);
+            }
+        }
+        ci_send_message (0, msg, NULL, Context, NULL);
+        menu->redraw = REDRAW_FULL;
+        break;
+
+      case OP_EXIT:
+        done = 1;
+        break;
       }
     }
 
     /* if we need to return the selected entries */
-    if (retbuf && (done == 2))
-    {
+    if (retbuf && (done == 2)) {
       int tagged = 0;
       size_t curpos = 0;
 
-      memset (buf, 0, buflen); 
+      memset (buf, 0, buflen);
 
       /* check for tagged entries */
-      for (i = 0; i < menu->max; i++)
-      {
-       if (QueryTable[i].tagged)
-       {
-         if (curpos == 0)
-         {
-           ADDRESS *tmpa = result_to_addr (QueryTable[i].data);
-           mutt_addrlist_to_local (tmpa);
-           tagged = 1;
-           rfc822_write_address (buf, buflen, tmpa, 0);
-           curpos = mutt_strlen (buf);
-           rfc822_free_address (&tmpa);
-         }
-         else if (curpos + 2 < buflen)
-         {
-           ADDRESS *tmpa = result_to_addr (QueryTable[i].data);
-           mutt_addrlist_to_local (tmpa);
-           strcat (buf, ", "); /* __STRCAT_CHECKED__ */
-           rfc822_write_address ((char *) buf + curpos + 1, buflen - curpos - 1,
-                                 tmpa, 0);
-           curpos = mutt_strlen (buf);
-           rfc822_free_address (&tmpa);
-         }
-       }
+      for (i = 0; i < menu->max; i++) {
+        if (QueryTable[i].tagged) {
+          if (curpos == 0) {
+            ADDRESS *tmpa = result_to_addr (QueryTable[i].data);
+
+            mutt_addrlist_to_local (tmpa);
+            tagged = 1;
+            rfc822_write_address (buf, buflen, tmpa, 0);
+            curpos = mutt_strlen (buf);
+            rfc822_free_address (&tmpa);
+          }
+          else if (curpos + 2 < buflen) {
+            ADDRESS *tmpa = result_to_addr (QueryTable[i].data);
+
+            mutt_addrlist_to_local (tmpa);
+            strcat (buf, ", "); /* __STRCAT_CHECKED__ */
+            rfc822_write_address ((char *) buf + curpos + 1,
+                                  buflen - curpos - 1, tmpa, 0);
+            curpos = mutt_strlen (buf);
+            rfc822_free_address (&tmpa);
+          }
+        }
       }
       /* then enter current message */
-      if (!tagged)
-      {
-       ADDRESS *tmpa = result_to_addr (QueryTable[menu->current].data);
-       mutt_addrlist_to_local (tmpa);
-       rfc822_write_address (buf, buflen, tmpa, 0);
-       rfc822_free_address (&tmpa);
+      if (!tagged) {
+        ADDRESS *tmpa = result_to_addr (QueryTable[menu->current].data);
+
+        mutt_addrlist_to_local (tmpa);
+        rfc822_write_address (buf, buflen, tmpa, 0);
+        rfc822_free_address (&tmpa);
       }
-      
+
     }
 
     queryp = results;
-    while (queryp)
-    {
+    while (queryp) {
       rfc822_free_address (&queryp->addr);
       FREE (&queryp->name);
       FREE (&queryp->other);
@@ -522,7 +489,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
       queryp = results;
     }
     FREE (&QueryTable);
-    
+
     /* tell whoever called me to redraw the screen when I return */
     set_option (OPTNEEDREDRAW);
   }
index e9da742..2c65fae 100644 (file)
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -52,69 +52,62 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
 }
 
 static struct mapping_t AttachHelp[] = {
-  { N_("Exit"),  OP_EXIT },
-  { N_("Save"),  OP_SAVE },
-  { N_("Pipe"),  OP_PIPE },
-  { N_("Print"), OP_PRINT },
-  { N_("Help"),  OP_HELP },
-  { NULL }
+  {N_("Exit"), OP_EXIT},
+  {N_("Save"), OP_SAVE},
+  {N_("Pipe"), OP_PIPE},
+  {N_("Print"), OP_PRINT},
+  {N_("Help"), OP_HELP},
+  {NULL}
 };
 
-int mutt_extract_path(char *filename, char *path)
+int mutt_extract_path (char *filename, char *path)
 {
-  char *tmp=safe_malloc(sizeof(char) * _POSIX_PATH_MAX);
+  char *tmp = safe_malloc (sizeof (char) * _POSIX_PATH_MAX);
   char *help_ptr;
-  
+
   help_ptr = tmp;
 
-  while(*filename != '\0')
-  {
-    if (*filename == '/')
-    {
-      *help_ptr++=*filename++;
-      *help_ptr++='\0';
-      strcat(path, tmp);
+  while (*filename != '\0') {
+    if (*filename == '/') {
+      *help_ptr++ = *filename++;
+      *help_ptr++ = '\0';
+      strcat (path, tmp);
       help_ptr = tmp;
     }
-    *help_ptr++=*filename++;
+    *help_ptr++ = *filename++;
   }
-  FREE(&tmp);
+  FREE (&tmp);
   return 0;
 }
 
-void mutt_update_tree (ATTACHPTR **idx, short idxlen)
+void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
 {
   char buf[STRING];
   char *s;
   int x;
 
-  for (x = 0; x < idxlen; x++)
-  {
+  for (x = 0; x < idxlen; x++) {
     idx[x]->num = x;
-    if (2 * (idx[x]->level + 2) < sizeof (buf))
-    {
-      if (idx[x]->level)
-      {
-       s = buf + 2 * (idx[x]->level - 1);
-       *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
-       *s++ = M_TREE_HLINE;
-       *s++ = M_TREE_RARROW;
+    if (2 * (idx[x]->level + 2) < sizeof (buf)) {
+      if (idx[x]->level) {
+        s = buf + 2 * (idx[x]->level - 1);
+        *s++ = (idx[x]->content->next) ? M_TREE_LTEE : M_TREE_LLCORNER;
+        *s++ = M_TREE_HLINE;
+        *s++ = M_TREE_RARROW;
       }
       else
-       s = buf;
+        s = buf;
       *s = 0;
     }
 
-    if (idx[x]->tree)
-    {
+    if (idx[x]->tree) {
       if (mutt_strcmp (idx[x]->tree, buf) != 0)
-       mutt_str_replace (&idx[x]->tree, buf);
+        mutt_str_replace (&idx[x]->tree, buf);
     }
     else
       idx[x]->tree = safe_strdup (buf);
 
-    if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level)
-    {
+    if (2 * (idx[x]->level + 2) < sizeof (buf) && idx[x]->level) {
       s = buf + 2 * (idx[x]->level - 1);
       *s++ = (idx[x]->content->next) ? '\005' : '\006';
       *s++ = '\006';
@@ -122,37 +115,36 @@ void mutt_update_tree (ATTACHPTR **idx, short idxlen)
   }
 }
 
-ATTACHPTR **mutt_gen_attach_list (BODY *m,
-                                 int parent_type,
-                                 ATTACHPTR **idx,
-                                 short *idxlen,
-                                 short *idxmax,
-                                 int level,
-                                 int compose)
+ATTACHPTR **mutt_gen_attach_list (BODY * m,
+                                  int parent_type,
+                                  ATTACHPTR ** idx,
+                                  short *idxlen,
+                                  short *idxmax, int level, int compose)
 {
   ATTACHPTR *new;
   int i;
-  
-  for (; m; m = m->next)
-  {
-    if (*idxlen == *idxmax)
-    {
+
+  for (; m; m = m->next) {
+    if (*idxlen == *idxmax) {
       safe_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
       for (i = *idxlen; i < *idxmax; i++)
-       idx[i] = NULL;
+        idx[i] = NULL;
     }
 
     if (m->type == TYPEMULTIPART && m->parts
-       && (compose || (parent_type == -1 && ascii_strcasecmp ("alternative", m->subtype)))
-        && (!(WithCrypto & APPLICATION_PGP) || !mutt_is_multipart_encrypted(m))
-       )
-    {
-      idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level, compose);
+        && (compose
+            || (parent_type == -1
+                && ascii_strcasecmp ("alternative", m->subtype)))
+        && (!(WithCrypto & APPLICATION_PGP)
+            || !mutt_is_multipart_encrypted (m))
+      ) {
+      idx =
+        mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level,
+                              compose);
     }
-    else
-    {
+    else {
       if (!idx[*idxlen])
-       idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
+        idx[*idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
 
       new = idx[(*idxlen)++];
       new->content = m;
@@ -161,14 +153,14 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m,
       new->level = level;
 
       /* We don't support multipart messages in the compose menu yet */
-      if (!compose && !m->collapsed && 
-         ((m->type == TYPEMULTIPART
-            && (!(WithCrypto & APPLICATION_PGP)
-                || !mutt_is_multipart_encrypted (m))
-           )
-          || mutt_is_message_type(m->type, m->subtype)))
-      {
-       idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level + 1, compose);
+      if (!compose && !m->collapsed &&
+          ((m->type == TYPEMULTIPART && (!(WithCrypto & APPLICATION_PGP)
+                                         || !mutt_is_multipart_encrypted (m))
+           )
+           || mutt_is_message_type (m->type, m->subtype))) {
+        idx =
+          mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax,
+                                level + 1, compose);
       }
     }
   }
@@ -195,14 +187,13 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m,
  * %u = unlink 
  */
 const char *mutt_attach_fmt (char *dest,
-    size_t destlen,
-    char op,
-    const char *src,
-    const char *prefix,
-    const char *ifstring,
-    const char *elsestring,
-    unsigned long data,
-    format_flag flags)
+                             size_t destlen,
+                             char op,
+                             const char *src,
+                             const char *prefix,
+                             const char *ifstring,
+                             const char *elsestring,
+                             unsigned long data, format_flag flags)
 {
   char fmt[16];
   char tmp[SHORT_STRING];
@@ -210,157 +201,149 @@ const char *mutt_attach_fmt (char *dest,
   ATTACHPTR *aptr = (ATTACHPTR *) data;
   int optional = (flags & M_FORMAT_OPTIONAL);
   size_t l;
-  
-  switch (op)
-  {
-    case 'C':
-      if (!optional)
-      {
-       if (mutt_is_text_part (aptr->content) &&
-           mutt_get_body_charset (charset, sizeof (charset), aptr->content))
-         mutt_format_s (dest, destlen, prefix, charset);
-       else
-         mutt_format_s (dest, destlen, prefix, "");
-      }
-      else if (!mutt_is_text_part (aptr->content) ||
-              !mutt_get_body_charset (charset, sizeof (charset), aptr->content))
-        optional = 0;
-      break;
-    case 'c':
-      /* XXX */
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
-       snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
-                 aptr->content->noconv ? 'n' : 'c');
-      }
-      else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
-        optional = 0;
-      break;
-    case 'd':
-      if(!optional)
-      {
-       if (aptr->content->description)
-       {
-         mutt_format_s (dest, destlen, prefix, aptr->content->description);
-         break;
-       }
-       if (mutt_is_message_type(aptr->content->type, aptr->content->subtype) &&
-           MsgFmt && aptr->content->hdr)
-       {
-         char s[SHORT_STRING];
-         _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
-                            M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR);
-         if (*s)
-         {
-           mutt_format_s (dest, destlen, prefix, s);
-           break;
-         }
-       }
-       if (!aptr->content->filename)
-       {
-         mutt_format_s (dest, destlen, prefix, "<no description>");
-         break;
-       }
-      }
-      else if(aptr->content->description || 
-             (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
-             && MsgFmt && aptr->content->hdr))
+
+  switch (op) {
+  case 'C':
+    if (!optional) {
+      if (mutt_is_text_part (aptr->content) &&
+          mutt_get_body_charset (charset, sizeof (charset), aptr->content))
+        mutt_format_s (dest, destlen, prefix, charset);
+      else
+        mutt_format_s (dest, destlen, prefix, "");
+    }
+    else if (!mutt_is_text_part (aptr->content) ||
+             !mutt_get_body_charset (charset, sizeof (charset),
+                                     aptr->content))
+      optional = 0;
+    break;
+  case 'c':
+    /* XXX */
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      snprintf (dest, destlen, fmt, aptr->content->type != TYPETEXT ||
+                aptr->content->noconv ? 'n' : 'c');
+    }
+    else if (aptr->content->type != TYPETEXT || aptr->content->noconv)
+      optional = 0;
+    break;
+  case 'd':
+    if (!optional) {
+      if (aptr->content->description) {
+        mutt_format_s (dest, destlen, prefix, aptr->content->description);
         break;
-    /* FALLS THROUGH TO 'f' */
-    case 'f':
-      if(!optional)
-      {
-       if (aptr->content->filename && *aptr->content->filename == '/')
-       {
-         char path[_POSIX_PATH_MAX];
-         
-         strfcpy (path, aptr->content->filename, sizeof (path));
-         mutt_pretty_mailbox (path);
-         mutt_format_s (dest, destlen, prefix, path);
-       }
-       else
-         mutt_format_s (dest, destlen, prefix, NONULL (aptr->content->filename));
       }
-      else if(!aptr->content->filename)
-        optional = 0;
-      break;
-    case 'D':
-      if(!optional)
-       snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
-      else if(!aptr->content->deleted)
-        optional = 0;
-      break;
-    case 'e':
-      if(!optional)
-       mutt_format_s (dest, destlen, prefix,
-                     ENCODING (aptr->content->encoding));
-      break;
-    case 'I':
-      if (!optional)
-      {
-         snprintf (dest, destlen, "%c",
-                 (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
+      if (mutt_is_message_type (aptr->content->type, aptr->content->subtype)
+          && MsgFmt && aptr->content->hdr) {
+        char s[SHORT_STRING];
+
+        _mutt_make_string (s, sizeof (s), MsgFmt, NULL, aptr->content->hdr,
+                           M_FORMAT_FORCESUBJ | M_FORMAT_MAKEPRINT |
+                           M_FORMAT_ARROWCURSOR);
+        if (*s) {
+          mutt_format_s (dest, destlen, prefix, s);
+          break;
+        }
       }
-      break;
-    case 'm':
-      if(!optional)
-       mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
-      break;
-    case 'M':
-      if(!optional)
-       mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
-      else if(!aptr->content->subtype)
-        optional = 0;
-      break;
-    case 'n':
-      if(!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, aptr->num + 1);
+      if (!aptr->content->filename) {
+        mutt_format_s (dest, destlen, prefix, "<no description>");
+        break;
       }
+    }
+    else if (aptr->content->description ||
+             (mutt_is_message_type
+              (aptr->content->type, aptr->content->subtype)
+              && MsgFmt && aptr->content->hdr))
       break;
-    case 's':
-      if (flags & M_FORMAT_STAT_FILE)
-      {
-       struct stat st;
-       stat (aptr->content->filename, &st);
-       l = st.st_size;
+    /* FALLS THROUGH TO 'f' */
+  case 'f':
+    if (!optional) {
+      if (aptr->content->filename && *aptr->content->filename == '/') {
+        char path[_POSIX_PATH_MAX];
+
+        strfcpy (path, aptr->content->filename, sizeof (path));
+        mutt_pretty_mailbox (path);
+        mutt_format_s (dest, destlen, prefix, path);
       }
       else
-        l = aptr->content->length;
-      
-      if(!optional)
-      {
-       mutt_pretty_size (tmp, sizeof(tmp), l);
-       mutt_format_s (dest, destlen, prefix, tmp);
-      }
-      else if (l == 0)
-        optional = 0;
+        mutt_format_s (dest, destlen, prefix,
+                       NONULL (aptr->content->filename));
+    }
+    else if (!aptr->content->filename)
+      optional = 0;
+    break;
+  case 'D':
+    if (!optional)
+      snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' ');
+    else if (!aptr->content->deleted)
+      optional = 0;
+    break;
+  case 'e':
+    if (!optional)
+      mutt_format_s (dest, destlen, prefix,
+                     ENCODING (aptr->content->encoding));
+    break;
+  case 'I':
+    if (!optional) {
+      snprintf (dest, destlen, "%c",
+                (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
+    }
+    break;
+  case 'm':
+    if (!optional)
+      mutt_format_s (dest, destlen, prefix, TYPE (aptr->content));
+    break;
+  case 'M':
+    if (!optional)
+      mutt_format_s (dest, destlen, prefix, aptr->content->subtype);
+    else if (!aptr->content->subtype)
+      optional = 0;
+    break;
+  case 'n':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, aptr->num + 1);
+    }
+    break;
+  case 's':
+    if (flags & M_FORMAT_STAT_FILE) {
+      struct stat st;
 
-      break;
-    case 't':
-      if(!optional)
-        snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
-      else if(!aptr->content->tagged)
-        optional = 0;
-      break;
-    case 'T':
-      if(!optional)
-       mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
-      else if (!aptr->tree)
-        optional = 0;
-      break;
-    case 'u':
-      if(!optional)
-        snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
-      else if (!aptr->content->unlink)
-        optional = 0;
-      break;
-    default:
-      *dest = 0;
+      stat (aptr->content->filename, &st);
+      l = st.st_size;
+    }
+    else
+      l = aptr->content->length;
+
+    if (!optional) {
+      mutt_pretty_size (tmp, sizeof (tmp), l);
+      mutt_format_s (dest, destlen, prefix, tmp);
+    }
+    else if (l == 0)
+      optional = 0;
+
+    break;
+  case 't':
+    if (!optional)
+      snprintf (dest, destlen, "%c", aptr->content->tagged ? '*' : ' ');
+    else if (!aptr->content->tagged)
+      optional = 0;
+    break;
+  case 'T':
+    if (!optional)
+      mutt_format_s_tree (dest, destlen, prefix, NONULL (aptr->tree));
+    else if (!aptr->tree)
+      optional = 0;
+    break;
+  case 'u':
+    if (!optional)
+      snprintf (dest, destlen, "%c", aptr->content->unlink ? '-' : ' ');
+    else if (!aptr->content->unlink)
+      optional = 0;
+    break;
+  default:
+    *dest = 0;
   }
-  
+
   if (optional)
     mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
   else if (flags & M_FORMAT_OPTIONAL)
@@ -368,16 +351,18 @@ const char *mutt_attach_fmt (char *dest,
   return (src);
 }
 
-void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num)
+void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR);
+  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+                     (unsigned long) (((ATTACHPTR **) menu->data)[num]),
+                     M_FORMAT_ARROWCURSOR);
 }
 
-int mutt_tag_attach (MUTTMENU *menu, int n, int m)
+int mutt_tag_attach (MUTTMENU * menu, int n, int m)
 {
   BODY *cur = ((ATTACHPTR **) menu->data)[n]->content;
   int ot = cur->tagged;
-  
+
   cur->tagged = (m >= 0 ? m : !cur->tagged);
   return cur->tagged - ot;
 }
@@ -387,108 +372,111 @@ int mutt_is_message_type (int type, const char *subtype)
   if (type != TYPEMESSAGE)
     return 0;
 
-  subtype = NONULL(subtype);
-  return (ascii_strcasecmp (subtype, "rfc822") == 0 || ascii_strcasecmp (subtype, "news") == 0);
+  subtype = NONULL (subtype);
+  return (ascii_strcasecmp (subtype, "rfc822") == 0
+          || ascii_strcasecmp (subtype, "news") == 0);
 }
 
-static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char **directory)
+static int mutt_query_save_attachment (FILE * fp, BODY * body, HEADER * hdr,
+                                       char **directory)
 {
   char *prompt;
   char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
-  char path[_POSIX_PATH_MAX]="";  
+  char path[_POSIX_PATH_MAX] = "";
   int is_message;
   int append = 0;
   int rc;
   int ret = -1;
-  
-  if (body->filename) 
-  {
+
+  if (body->filename) {
     if (directory && *directory)
-      mutt_concat_path (buf, *directory, mutt_basename (body->filename), sizeof (buf));
+      mutt_concat_path (buf, *directory, mutt_basename (body->filename),
+                        sizeof (buf));
     else
       strfcpy (buf, body->filename, sizeof (buf));
   }
-  else if(body->hdr &&
-         body->encoding != ENCBASE64 &&
-         body->encoding != ENCQUOTEDPRINTABLE &&
-         mutt_is_message_type(body->type, body->subtype))
-    mutt_default_save(buf, sizeof(buf), body->hdr);
+  else if (body->hdr &&
+           body->encoding != ENCBASE64 &&
+           body->encoding != ENCQUOTEDPRINTABLE &&
+           mutt_is_message_type (body->type, body->subtype))
+    mutt_default_save (buf, sizeof (buf), body->hdr);
   else
     buf[0] = 0;
 
   prompt = _("Save to file ('#' for last used folder): ");
-  while (prompt)
-  {
-    ret = mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR | M_LASTFOLDER);
+  while (prompt) {
+    ret =
+      mutt_get_field (prompt, buf, sizeof (buf),
+                      M_FILE | M_CLEAR | M_LASTFOLDER);
     if (((ret != 0) && (ret != 2)) || (!buf[0] && ret != 2))
       return -1;
 
-    if (ret == 2)
-    {
+    if (ret == 2) {
       char tmpbuf[_POSIX_PATH_MAX];
-      snprintf(tmpbuf,sizeof(tmpbuf),"%s%s",LastSaveFolder,buf);
+
+      snprintf (tmpbuf, sizeof (tmpbuf), "%s%s", LastSaveFolder, buf);
       strfcpy (buf, tmpbuf, sizeof (buf));
       ret = mutt_get_field (_("Save to file: ")
-                , buf, sizeof (buf), M_FILE);
+                            , buf, sizeof (buf), M_FILE);
       if ((ret != 0) || (!buf[0]))
         return -1;
-    }  
-    else
-    {
-      mutt_extract_path(buf,path);
+    }
+    else {
+      mutt_extract_path (buf, path);
       strfcpy (LastSaveFolder, path, sizeof (LastSaveFolder));
     }
-    
+
     prompt = NULL;
     mutt_expand_path (buf, sizeof (buf));
-    
-    is_message = (fp && 
-                 body->hdr && 
-                 body->encoding != ENCBASE64 && 
-                 body->encoding != ENCQUOTEDPRINTABLE && 
-                 mutt_is_message_type (body->type, body->subtype));
-    
-    if (is_message)
-    {
+
+    is_message = (fp &&
+                  body->hdr &&
+                  body->encoding != ENCBASE64 &&
+                  body->encoding != ENCQUOTEDPRINTABLE &&
+                  mutt_is_message_type (body->type, body->subtype));
+
+    if (is_message) {
       struct stat st;
-      
+
       /* check to make sure that this file is really the one the user wants */
-      if ((rc = mutt_save_confirm (buf, &st)) == 1)
-      {
+      if ((rc = mutt_save_confirm (buf, &st)) == 1) {
         prompt = _("Save to file: ");
         continue;
-      } 
+      }
       else if (rc == -1)
         return -1;
-      strfcpy(tfile, buf, sizeof(tfile));
+      strfcpy (tfile, buf, sizeof (tfile));
     }
-    else
-    {
-      if ((rc = mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile), &append, directory)) == -1)
+    else {
+      if ((rc =
+           mutt_check_overwrite (body->filename, buf, tfile, sizeof (tfile),
+                                 &append, directory)) == -1)
         return -1;
-      else if (rc == 1)
-      {
+      else if (rc == 1) {
         prompt = _("Save to file: ");
         continue;
       }
     }
-    
+
     mutt_message _("Saving...");
-    if (mutt_save_attachment (fp, body, tfile, append, (hdr || !is_message) ? hdr : body->hdr) == 0)
-    {
+
+    if (mutt_save_attachment
+        (fp, body, tfile, append,
+         (hdr || !is_message) ? hdr : body->hdr) == 0) {
       mutt_message _("Attachment saved.");
+
       return 0;
     }
-    else
-    {
+    else {
       prompt = _("Save to file: ");
       continue;
     }
   }
   return 0;
 }
-    
-void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTMENU *menu)
+
+void mutt_save_attachment_list (FILE * fp, int tag, BODY * top, HEADER * hdr,
+                                MUTTMENU * menu)
 {
   char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
   char *directory = NULL;
@@ -498,54 +486,45 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTM
 
   buf[0] = 0;
 
-  for (; top; top = top->next)
-  {
-    if (!tag || top->tagged)
-    {
-      if (!option (OPTATTACHSPLIT))
-      {
-       if (!buf[0])
-       {
-         int append = 0;
-
-         strfcpy (buf, NONULL (top->filename), sizeof (buf));
-         if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
-                                   M_FILE | M_CLEAR) != 0 || !buf[0])
-           return;
-         mutt_expand_path (buf, sizeof (buf));
-         if (mutt_check_overwrite (top->filename, buf, tfile,
-                                   sizeof (tfile), &append, NULL))
-           return;
-         rc = mutt_save_attachment (fp, top, tfile, append, hdr);
-         if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
-         {
-           fprintf(fpout, "%s", AttachSep);
-           fclose (fpout);
-         }
-       }
-       else
-       {
-         rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
-         if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
-         {
-           fprintf(fpout, "%s", AttachSep);
-           fclose (fpout);
-         }
-       }
+  for (; top; top = top->next) {
+    if (!tag || top->tagged) {
+      if (!option (OPTATTACHSPLIT)) {
+        if (!buf[0]) {
+          int append = 0;
+
+          strfcpy (buf, NONULL (top->filename), sizeof (buf));
+          if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
+                              M_FILE | M_CLEAR) != 0 || !buf[0])
+            return;
+          mutt_expand_path (buf, sizeof (buf));
+          if (mutt_check_overwrite (top->filename, buf, tfile,
+                                    sizeof (tfile), &append, NULL))
+            return;
+          rc = mutt_save_attachment (fp, top, tfile, append, hdr);
+          if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
+            fprintf (fpout, "%s", AttachSep);
+            fclose (fpout);
+          }
+        }
+        else {
+          rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
+          if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
+            fprintf (fpout, "%s", AttachSep);
+            fclose (fpout);
+          }
+        }
       }
-      else 
-      {
-       if (tag && menu && top->aptr)
-       {
-         menu->oldcurrent = menu->current;
-         menu->current = top->aptr->num;
-         menu_check_recenter (menu);
-         menu->redraw |= REDRAW_MOTION;
-
-         menu_redraw (menu);
-       }
-       if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
-         break;
+      else {
+        if (tag && menu && top->aptr) {
+          menu->oldcurrent = menu->current;
+          menu->current = top->aptr->num;
+          menu_check_recenter (menu);
+          menu->redraw |= REDRAW_MOTION;
+
+          menu_redraw (menu);
+        }
+        if (mutt_query_save_attachment (fp, top, hdr, &directory) == -1)
+          break;
       }
     }
     else if (top->parts)
@@ -556,31 +535,29 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTM
 
   FREE (&directory);
 
-  if (tag && menu)
-  {
+  if (tag && menu) {
     menu->oldcurrent = menu->current;
     menu->current = last;
     menu_check_recenter (menu);
     menu->redraw |= REDRAW_MOTION;
   }
-  
+
   if (!option (OPTATTACHSPLIT) && (rc == 0))
     mutt_message _("Attachment saved.");
 }
 
 static void
-mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter)
+mutt_query_pipe_attachment (char *command, FILE * fp, BODY * body, int filter)
 {
   char tfile[_POSIX_PATH_MAX];
-  char warning[STRING+_POSIX_PATH_MAX];
+  char warning[STRING + _POSIX_PATH_MAX];
 
-  if (filter)
-  {
+  if (filter) {
     snprintf (warning, sizeof (warning),
-             _("WARNING!  You are about to overwrite %s, continue?"),
-             body->filename);
+              _("WARNING!  You are about to overwrite %s, continue?"),
+              body->filename);
     if (mutt_yesorno (warning, M_NO) != M_YES) {
-      CLEARLINE (LINES-1);
+      CLEARLINE (LINES - 1);
       return;
     }
     mutt_mktemp (tfile);
@@ -588,38 +565,32 @@ mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter)
   else
     tfile[0] = 0;
 
-  if (mutt_pipe_attachment (fp, body, command, tfile))
-  {
-    if (filter)
-    {
+  if (mutt_pipe_attachment (fp, body, command, tfile)) {
+    if (filter) {
       mutt_unlink (body->filename);
       mutt_rename_file (tfile, body->filename);
       mutt_update_encoding (body);
       mutt_message _("Attachment filtered.");
     }
   }
-  else
-  {
+  else {
     if (filter && tfile[0])
       mutt_unlink (tfile);
   }
 }
 
-static void pipe_attachment (FILE *fp, BODY *b, STATE *state)
+static void pipe_attachment (FILE * fp, BODY * b, STATE * state)
 {
   FILE *ifp;
 
-  if (fp)
-  {
+  if (fp) {
     state->fpin = fp;
     mutt_decode_attachment (b, state);
     if (AttachSep)
       state_puts (AttachSep, state);
   }
-  else
-  {
-    if ((ifp = fopen (b->filename, "r")) == NULL)
-    {
+  else {
+    if ((ifp = fopen (b->filename, "r")) == NULL) {
       mutt_perror ("fopen");
       return;
     }
@@ -631,17 +602,15 @@ static void pipe_attachment (FILE *fp, BODY *b, STATE *state)
 }
 
 static void
-pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter,
-                     STATE *state)
+pipe_attachment_list (char *command, FILE * fp, int tag, BODY * top,
+                      int filter, STATE * state)
 {
-  for (; top; top = top->next)
-  {
-    if (!tag || top->tagged)
-    {
+  for (; top; top = top->next) {
+    if (!tag || top->tagged) {
       if (!filter && !option (OPTATTACHSPLIT))
-       pipe_attachment (fp, top, state);
+        pipe_attachment (fp, top, state);
       else
-       mutt_query_pipe_attachment (command, fp, top, filter);
+        mutt_query_pipe_attachment (command, fp, top, filter);
     }
     else if (top->parts)
       pipe_attachment_list (command, fp, tag, top->parts, filter, state);
@@ -650,26 +619,25 @@ pipe_attachment_list (char *command, FILE *fp, int tag, BODY *top, int filter,
   }
 }
 
-void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter)
+void mutt_pipe_attachment_list (FILE * fp, int tag, BODY * top, int filter)
 {
   STATE state;
   char buf[SHORT_STRING];
   pid_t thepid;
 
   if (fp)
-    filter = 0; /* sanity check: we can't filter in the recv case yet */
+    filter = 0;                 /* sanity check: we can't filter in the recv case yet */
 
   buf[0] = 0;
   memset (&state, 0, sizeof (STATE));
 
   if (mutt_get_field ((filter ? _("Filter through: ") : _("Pipe to: ")),
-                                 buf, sizeof (buf), M_CMD) != 0 || !buf[0])
+                      buf, sizeof (buf), M_CMD) != 0 || !buf[0])
     return;
 
   mutt_expand_path (buf, sizeof (buf));
 
-  if (!filter && !option (OPTATTACHSPLIT))
-  {
+  if (!filter && !option (OPTATTACHSPLIT)) {
     mutt_endwin (NULL);
     thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
     pipe_attachment_list (buf, fp, tag, top, filter, &state);
@@ -681,26 +649,21 @@ void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter)
     pipe_attachment_list (buf, fp, tag, top, filter, &state);
 }
 
-static int can_print (BODY *top, int tag)
+static int can_print (BODY * top, int tag)
 {
-  char type [STRING];
+  char type[STRING];
 
-  for (; top; top = top->next)
-  {
+  for (; top; top = top->next) {
     snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
-    if (!tag || top->tagged)
-    {
-      if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT))
-      {
-       if (ascii_strcasecmp ("text/plain", top->subtype) &&
-           ascii_strcasecmp ("application/postscript", top->subtype))
-       {
-         if (!mutt_can_decode (top))
-         {
-           mutt_error (_("I dont know how to print %s attachments!"), type);
-           return (0);
-         }
-       }
+    if (!tag || top->tagged) {
+      if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
+        if (ascii_strcasecmp ("text/plain", top->subtype) &&
+            ascii_strcasecmp ("application/postscript", top->subtype)) {
+          if (!mutt_can_decode (top)) {
+            mutt_error (_("I dont know how to print %s attachments!"), type);
+            return (0);
+          }
+        }
       }
     }
     else if (top->parts)
@@ -711,44 +674,41 @@ static int can_print (BODY *top, int tag)
   return (1);
 }
 
-static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state)
+static void print_attachment_list (FILE * fp, int tag, BODY * top,
+                                   STATE * state)
 {
-  char type [STRING];
+  char type[STRING];
 
 
-  for (; top; top = top->next)
-  {
-    if (!tag || top->tagged)
-    {
+  for (; top; top = top->next) {
+    if (!tag || top->tagged) {
       snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype);
-      if (!option (OPTATTACHSPLIT) && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT))
-      {
-       if (!ascii_strcasecmp ("text/plain", top->subtype) ||
-           !ascii_strcasecmp ("application/postscript", top->subtype))
-         pipe_attachment (fp, top, state);
-       else if (mutt_can_decode (top))
-       {
-         /* decode and print */
-
-         char newfile[_POSIX_PATH_MAX] = "";
-         FILE *ifp;
-
-         mutt_mktemp (newfile);
-         if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) == 0)
-         {
-           if ((ifp = fopen (newfile, "r")) != NULL)
-           {
-             mutt_copy_stream (ifp, state->fpout);
-             fclose (ifp);
-             if (AttachSep)
-               state_puts (AttachSep, state);
-           }
-         }
-         mutt_unlink (newfile);
-       }
+      if (!option (OPTATTACHSPLIT)
+          && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) {
+        if (!ascii_strcasecmp ("text/plain", top->subtype)
+            || !ascii_strcasecmp ("application/postscript", top->subtype))
+          pipe_attachment (fp, top, state);
+        else if (mutt_can_decode (top)) {
+          /* decode and print */
+
+          char newfile[_POSIX_PATH_MAX] = "";
+          FILE *ifp;
+
+          mutt_mktemp (newfile);
+          if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) ==
+              0) {
+            if ((ifp = fopen (newfile, "r")) != NULL) {
+              mutt_copy_stream (ifp, state->fpout);
+              fclose (ifp);
+              if (AttachSep)
+                state_puts (AttachSep, state);
+            }
+          }
+          mutt_unlink (newfile);
+        }
       }
       else
-       mutt_print_attachment (fp, top);
+        mutt_print_attachment (fp, top);
     }
     else if (top->parts)
       print_attachment_list (fp, tag, top->parts, state);
@@ -757,16 +717,19 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state)
   }
 }
 
-void mutt_print_attachment_list (FILE *fp, int tag, BODY *top)
+void mutt_print_attachment_list (FILE * fp, int tag, BODY * top)
 {
   STATE state;
-  
+
   pid_t thepid;
-  if (query_quadoption (OPT_PRINT, tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) != M_YES)
+
+  if (query_quadoption
+      (OPT_PRINT,
+       tag ? _("Print tagged attachment(s)?") : _("Print attachment?")) !=
+      M_YES)
     return;
 
-  if (!option (OPTATTACHSPLIT))
-  {
+  if (!option (OPTATTACHSPLIT)) {
     if (!can_print (top, tag))
       return;
     mutt_endwin (NULL);
@@ -782,96 +745,93 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top)
 }
 
 void
-mutt_update_attach_index (BODY *cur, ATTACHPTR ***idxp,
-                                     short *idxlen, short *idxmax,
-                                     MUTTMENU *menu)
+mutt_update_attach_index (BODY * cur, ATTACHPTR *** idxp,
+                          short *idxlen, short *idxmax, MUTTMENU * menu)
 {
   ATTACHPTR **idx = *idxp;
+
   while (--(*idxlen) >= 0)
     idx[(*idxlen)]->content = NULL;
   *idxlen = 0;
 
   idx = *idxp = mutt_gen_attach_list (cur, -1, idx, idxlen, idxmax, 0, 0);
-  
-  menu->max  = *idxlen;
+
+  menu->max = *idxlen;
   menu->data = *idxp;
 
   if (menu->current >= menu->max)
     menu->current = menu->max - 1;
   menu_check_recenter (menu);
   menu->redraw |= REDRAW_INDEX;
-  
+
 }
 
 
 int
-mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
-                         BODY *cur, ATTACHPTR ***idxp, short *idxlen, short *idxmax,
-                         int recv)
+mutt_attach_display_loop (MUTTMENU * menu, int op, FILE * fp, HEADER * hdr,
+                          BODY * cur, ATTACHPTR *** idxp, short *idxlen,
+                          short *idxmax, int recv)
 {
   ATTACHPTR **idx = *idxp;
+
 #if 0
   int old_optweed = option (OPTWEED);
+
   set_option (OPTWEED);
 #endif
-  
-  do
-  {
-    switch (op)
-    {
-      case OP_DISPLAY_HEADERS:
-       toggle_option (OPTWEED);
-       /* fall through */
-
-      case OP_VIEW_ATTACH:
-       op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
-                                  hdr, idx, *idxlen);
-       break;
-
-      case OP_NEXT_ENTRY:
-      case OP_MAIN_NEXT_UNDELETED: /* hack */
-       if (menu->current < menu->max - 1)
-       {
-         menu->current++;
-         op = OP_VIEW_ATTACH;
-       }
-       else
-         op = OP_NULL;
-       break;
-      case OP_PREV_ENTRY:
-      case OP_MAIN_PREV_UNDELETED: /* hack */
-       if (menu->current > 0)
-       {
-         menu->current--;
-         op = OP_VIEW_ATTACH;
-       }
-       else
-         op = OP_NULL;
-       break;
-      case OP_EDIT_TYPE:
-       /* when we edit the content-type, we should redisplay the attachment
-          immediately */
-       mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
-        if (idxmax)
-        {
-         mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
-         idx = *idxp;
-       }
+
+  do {
+    switch (op) {
+    case OP_DISPLAY_HEADERS:
+      toggle_option (OPTWEED);
+      /* fall through */
+
+    case OP_VIEW_ATTACH:
+      op = mutt_view_attachment (fp, idx[menu->current]->content, M_REGULAR,
+                                 hdr, idx, *idxlen);
+      break;
+
+    case OP_NEXT_ENTRY:
+    case OP_MAIN_NEXT_UNDELETED:       /* hack */
+      if (menu->current < menu->max - 1) {
+        menu->current++;
+        op = OP_VIEW_ATTACH;
+      }
+      else
+        op = OP_NULL;
+      break;
+    case OP_PREV_ENTRY:
+    case OP_MAIN_PREV_UNDELETED:       /* hack */
+      if (menu->current > 0) {
+        menu->current--;
         op = OP_VIEW_ATTACH;
-       break;
+      }
+      else
+        op = OP_NULL;
+      break;
+    case OP_EDIT_TYPE:
+      /* when we edit the content-type, we should redisplay the attachment
+         immediately */
+      mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
+      if (idxmax) {
+        mutt_update_attach_index (cur, idxp, idxlen, idxmax, menu);
+        idx = *idxp;
+      }
+      op = OP_VIEW_ATTACH;
+      break;
       /* functions which are passed through from the pager */
-      case OP_CHECK_TRADITIONAL:
-        if (!(WithCrypto & APPLICATION_PGP) || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED))
-        {
-          op = OP_NULL;
-          break;
-        }
-        /* fall through */
-      case OP_ATTACH_COLLAPSE:
-        if (recv)
-          return op;
-      default:
-       op = OP_NULL;
+    case OP_CHECK_TRADITIONAL:
+      if (!(WithCrypto & APPLICATION_PGP)
+          || (hdr && hdr->security & PGP_TRADITIONAL_CHECKED)) {
+        op = OP_NULL;
+        break;
+      }
+      /* fall through */
+    case OP_ATTACH_COLLAPSE:
+      if (recv)
+        return op;
+    default:
+      op = OP_NULL;
     }
   }
   while (op != OP_NULL);
@@ -883,16 +843,18 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, FILE *fp, HEADER *hdr,
   return op;
 }
 
-static void attach_collapse (BODY *b, short collapse, short init, short just_one)
+static void attach_collapse (BODY * b, short collapse, short init,
+                             short just_one)
 {
   short i;
-  for (; b; b = b->next)
-  {
+
+  for (; b; b = b->next) {
     i = init || b->collapsed;
     if (i && option (OPTDIGESTCOLLAPSE) && b->type == TYPEMULTIPART
-       && !ascii_strcasecmp (b->subtype, "digest"))
+        && !ascii_strcasecmp (b->subtype, "digest"))
       attach_collapse (b->parts, 1, 1, 0);
-    else if (b->type == TYPEMULTIPART || mutt_is_message_type (b->type, b->subtype))
+    else if (b->type == TYPEMULTIPART
+             || mutt_is_message_type (b->type, b->subtype))
       attach_collapse (b->parts, collapse, i, 0);
     b->collapsed = collapse;
     if (just_one)
@@ -900,18 +862,18 @@ static void attach_collapse (BODY *b, short collapse, short init, short just_one
   }
 }
 
-void mutt_attach_init (BODY *b)
+void mutt_attach_init (BODY * b)
 {
-  for (; b; b = b->next)
-  {
+  for (; b; b = b->next) {
     b->tagged = 0;
     b->collapsed = 0;
-    if (b->parts) 
+    if (b->parts)
       mutt_attach_init (b->parts);
   }
 }
 
-static const char *Function_not_permitted = N_("Function not permitted in attach-message mode.");
+static const char *Function_not_permitted =
+N_("Function not permitted in attach-message mode.");
 
 #define CHECK_ATTACH if(option(OPTATTACHMSG)) \
                     {\
@@ -923,7 +885,7 @@ static const char *Function_not_permitted = N_("Function not permitted in attach
 
 
 
-void mutt_view_attachments (HEADER *hdr)
+void mutt_view_attachments (HEADER * hdr)
 {
   int secured = 0;
   int need_secured = 0;
@@ -938,70 +900,66 @@ void mutt_view_attachments (HEADER *hdr)
   short idxmax = 0;
   int flags = 0;
   int op = OP_NULL;
-  
+
   /* make sure we have parsed this message */
   mutt_parse_mime_message (Context, hdr);
 
   mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
-  
+
   if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
     return;
 
 
   if (WithCrypto && ((hdr->security & ENCRYPT) ||
-                     (mutt_is_application_smime(hdr->content) & SMIMEOPAQUE)))
-  {
-    need_secured  = 1;
+                     (mutt_is_application_smime (hdr->content) &
+                      SMIMEOPAQUE))) {
+    need_secured = 1;
 
-    if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase(hdr->security))
-    {
+    if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
       mx_close_message (&msg);
       return;
     }
-    if ((WithCrypto & APPLICATION_SMIME) && (hdr->security & APPLICATION_SMIME))
-    {
+    if ((WithCrypto & APPLICATION_SMIME)
+        && (hdr->security & APPLICATION_SMIME)) {
       if (hdr->env)
-          crypt_smime_getkeys (hdr->env);
-
-      if (mutt_is_application_smime(hdr->content))
-      {
-        secured = ! crypt_smime_decrypt_mime (msg->fp, &fp,
-                                              hdr->content, &cur);
-       
-       /* S/MIME nesting */
-       if ((mutt_is_application_smime (cur) & SMIMEOPAQUE))
-       {
-         BODY *_cur = cur;
-         FILE *_fp = fp;
-         
-         fp = NULL; cur = NULL;
-         secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
-         
-         mutt_free_body (&_cur);
-         safe_fclose (&_fp);
-       }
+        crypt_smime_getkeys (hdr->env);
+
+      if (mutt_is_application_smime (hdr->content)) {
+        secured = !crypt_smime_decrypt_mime (msg->fp, &fp,
+                                             hdr->content, &cur);
+
+        /* S/MIME nesting */
+        if ((mutt_is_application_smime (cur) & SMIMEOPAQUE)) {
+          BODY *_cur = cur;
+          FILE *_fp = fp;
+
+          fp = NULL;
+          cur = NULL;
+          secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
+
+          mutt_free_body (&_cur);
+          safe_fclose (&_fp);
+        }
       }
       else
         need_secured = 0;
     }
-    if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP))
-    {
-      if (mutt_is_multipart_encrypted(hdr->content))
+    if ((WithCrypto & APPLICATION_PGP) && (hdr->security & APPLICATION_PGP)) {
+      if (mutt_is_multipart_encrypted (hdr->content))
         secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
       else
         need_secured = 0;
     }
 
-    if (need_secured && !secured)
-    {
+    if (need_secured && !secured) {
       mx_close_message (&msg);
       mutt_error _("Can't decrypt encrypted message!");
+
       return;
     }
   }
-  
-  if (!WithCrypto || !need_secured)
-  {
+
+  if (!WithCrypto || !need_secured) {
     fp = msg->fp;
     cur = hdr->content;
   }
@@ -1011,278 +969,276 @@ void mutt_view_attachments (HEADER *hdr)
   menu->title = _("Attachments");
   menu->make_entry = attach_entry;
   menu->tag = mutt_tag_attach;
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
+  menu->help =
+    mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
 
   mutt_attach_init (cur);
   attach_collapse (cur, 0, 1, 0);
   mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
 
-  FOREVER
-  {
+  FOREVER {
     if (op == OP_NULL)
       op = mutt_menuLoop (menu);
-    switch (op)
-    {
-      case OP_ATTACH_VIEW_MAILCAP:
-       mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
-                             hdr, idx, idxlen);
-       menu->redraw = REDRAW_FULL;
-       break;
-
-      case OP_ATTACH_VIEW_TEXT:
-       mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
-                             hdr, idx, idxlen);
-       menu->redraw = REDRAW_FULL;
-       break;
-
-      case OP_DISPLAY_HEADERS:
-      case OP_VIEW_ATTACH:
-        op = mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen, &idxmax, 1);
-        menu->redraw = REDRAW_FULL;
-        continue;
+    switch (op) {
+    case OP_ATTACH_VIEW_MAILCAP:
+      mutt_view_attachment (fp, idx[menu->current]->content, M_MAILCAP,
+                            hdr, idx, idxlen);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_ATTACH_COLLAPSE:
-        if (!idx[menu->current]->content->parts)
-        {
-         mutt_error _("There are no subparts to show!");
-         break;
-       }
-        if (!idx[menu->current]->content->collapsed)
-         attach_collapse (idx[menu->current]->content, 1, 0, 1);
-        else
-         attach_collapse (idx[menu->current]->content, 0, 1, 1);
-        mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
-        break;
-      
-      case OP_FORGET_PASSPHRASE:
-        crypt_forget_passphrase ();
-        break;
+    case OP_ATTACH_VIEW_TEXT:
+      mutt_view_attachment (fp, idx[menu->current]->content, M_AS_TEXT,
+                            hdr, idx, idxlen);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_DISPLAY_HEADERS:
+    case OP_VIEW_ATTACH:
+      op =
+        mutt_attach_display_loop (menu, op, fp, hdr, cur, &idx, &idxlen,
+                                  &idxmax, 1);
+      menu->redraw = REDRAW_FULL;
+      continue;
+
+    case OP_ATTACH_COLLAPSE:
+      if (!idx[menu->current]->content->parts) {
+        mutt_error _("There are no subparts to show!");
 
-      case OP_EXTRACT_KEYS:
-        if ((WithCrypto & APPLICATION_PGP))
-        {
-          crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix, 
-                   menu->tagprefix ? cur : idx[menu->current]->content);
-          menu->redraw = REDRAW_FULL;
-        }
-        break;
-      
-      case OP_CHECK_TRADITIONAL:
-        if ((WithCrypto & APPLICATION_PGP)
-            && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
-                                              : idx[menu->current]->content,
-                                      menu->tagprefix))
-        {
-         hdr->security = crypt_query (cur);
-         menu->redraw = REDRAW_FULL;
-       }
         break;
+      }
+      if (!idx[menu->current]->content->collapsed)
+        attach_collapse (idx[menu->current]->content, 1, 0, 1);
+      else
+        attach_collapse (idx[menu->current]->content, 0, 1, 1);
+      mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
+      break;
 
-      case OP_PRINT:
-       mutt_print_attachment_list (fp, menu->tagprefix, 
-                 menu->tagprefix ? cur : idx[menu->current]->content);
-       break;
+    case OP_FORGET_PASSPHRASE:
+      crypt_forget_passphrase ();
+      break;
 
-      case OP_PIPE:
-       mutt_pipe_attachment_list (fp, menu->tagprefix, 
-                 menu->tagprefix ? cur : idx[menu->current]->content, 0);
-       break;
+    case OP_EXTRACT_KEYS:
+      if ((WithCrypto & APPLICATION_PGP)) {
+        crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
+                                                     menu->
+                                                     tagprefix ? cur :
+                                                     idx[menu->current]->
+                                                     content);
+        menu->redraw = REDRAW_FULL;
+      }
+      break;
+
+    case OP_CHECK_TRADITIONAL:
+      if ((WithCrypto & APPLICATION_PGP)
+          && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
+                                          : idx[menu->current]->content,
+                                          menu->tagprefix)) {
+        hdr->security = crypt_query (cur);
+        menu->redraw = REDRAW_FULL;
+      }
+      break;
 
-      case OP_SAVE:
-       mutt_save_attachment_list (fp, menu->tagprefix, 
-                 menu->tagprefix ?  cur : idx[menu->current]->content, hdr, menu);
+    case OP_PRINT:
+      mutt_print_attachment_list (fp, menu->tagprefix,
+                                  menu->tagprefix ? cur : idx[menu->current]->
+                                  content);
+      break;
+
+    case OP_PIPE:
+      mutt_pipe_attachment_list (fp, menu->tagprefix,
+                                 menu->tagprefix ? cur : idx[menu->current]->
+                                 content, 0);
+      break;
 
-        if (!menu->tagprefix && option (OPTRESOLVE) && menu->current < menu->max - 1)
-         menu->current++;
-      
-        menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
-       break;
+    case OP_SAVE:
+      mutt_save_attachment_list (fp, menu->tagprefix,
+                                 menu->tagprefix ? cur : idx[menu->current]->
+                                 content, hdr, menu);
 
-      case OP_DELETE:
-       CHECK_READONLY;
+      if (!menu->tagprefix && option (OPTRESOLVE)
+          && menu->current < menu->max - 1)
+        menu->current++;
+
+      menu->redraw = REDRAW_MOTION_RESYNCH | REDRAW_FULL;
+      break;
+
+    case OP_DELETE:
+      CHECK_READONLY;
 
 #ifdef USE_POP
-       if (Context->magic == M_POP)
-       {
-         mutt_flushinp ();
-         mutt_error _("Can't delete attachment from POP server.");
-         break;
-       }
+      if (Context->magic == M_POP) {
+        mutt_flushinp ();
+        mutt_error _("Can't delete attachment from POP server.");
+
+        break;
+      }
 #endif
 
 #ifdef USE_NNTP
-       if (Context->magic == M_NNTP)
-       {
-         mutt_flushinp ();
-         mutt_error _("Can't delete attachment from newsserver.");
-         break;
-       }
+      if (Context->magic == M_NNTP) {
+        mutt_flushinp ();
+        mutt_error _("Can't delete attachment from newsserver.");
+
+        break;
+      }
 #endif
 
-        if (WithCrypto && hdr->security)
-        {
-         mutt_message _(
-           "Deletion of attachments from encrypted messages is unsupported.");
-       }
+      if (WithCrypto && hdr->security) {
+        mutt_message
+          _
+          ("Deletion of attachments from encrypted messages is unsupported.");
+      }
+      else {
+        if (!menu->tagprefix) {
+          if (idx[menu->current]->parent_type == TYPEMULTIPART) {
+            idx[menu->current]->content->deleted = 1;
+            if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
+              menu->current++;
+              menu->redraw = REDRAW_MOTION_RESYNCH;
+            }
+            else
+              menu->redraw = REDRAW_CURRENT;
+          }
+          else
+            mutt_message
+              _("Only deletion of multipart attachments is supported.");
+        }
+        else {
+          int x;
+
+          for (x = 0; x < menu->max; x++) {
+            if (idx[x]->content->tagged) {
+              if (idx[x]->parent_type == TYPEMULTIPART) {
+                idx[x]->content->deleted = 1;
+                menu->redraw = REDRAW_INDEX;
+              }
+              else
+                mutt_message
+                  _("Only deletion of multipart attachments is supported.");
+            }
+          }
+        }
+      }
+      break;
+
+    case OP_UNDELETE:
+      CHECK_READONLY;
+      if (!menu->tagprefix) {
+        idx[menu->current]->content->deleted = 0;
+        if (option (OPTRESOLVE) && menu->current < menu->max - 1) {
+          menu->current++;
+          menu->redraw = REDRAW_MOTION_RESYNCH;
+        }
         else
-        {
-         if (!menu->tagprefix)
-         {
-           if (idx[menu->current]->parent_type == TYPEMULTIPART)
-           {
-             idx[menu->current]->content->deleted = 1;
-             if (option (OPTRESOLVE) && menu->current < menu->max - 1)
-             {
-               menu->current++;
-               menu->redraw = REDRAW_MOTION_RESYNCH;
-             }
-             else
-               menu->redraw = REDRAW_CURRENT;
-           }
-           else
-             mutt_message _(
-               "Only deletion of multipart attachments is supported.");
-         }
-         else
-         {
-           int x;
-
-           for (x = 0; x < menu->max; x++)
-           {
-             if (idx[x]->content->tagged)
-             {
-               if (idx[x]->parent_type == TYPEMULTIPART)
-               {
-                 idx[x]->content->deleted = 1;
-                 menu->redraw = REDRAW_INDEX;
-               }
-               else
-                 mutt_message _(
-                   "Only deletion of multipart attachments is supported.");
-             }
-           }
-         }
-       }
-        break;
+          menu->redraw = REDRAW_CURRENT;
+      }
+      else {
+        int x;
+
+        for (x = 0; x < menu->max; x++) {
+          if (idx[x]->content->tagged) {
+            idx[x]->content->deleted = 0;
+            menu->redraw = REDRAW_INDEX;
+          }
+        }
+      }
+      break;
 
-      case OP_UNDELETE:
-       CHECK_READONLY;
-       if (!menu->tagprefix)
-       {
-        idx[menu->current]->content->deleted = 0;
-        if (option (OPTRESOLVE) && menu->current < menu->max - 1)
-        {
-          menu->current++;
-          menu->redraw = REDRAW_MOTION_RESYNCH;
-        }
-        else
-          menu->redraw = REDRAW_CURRENT;
-       }
-       else
-       {
-        int x;
-
-        for (x = 0; x < menu->max; x++)
-        {
-          if (idx[x]->content->tagged)
-          {
-            idx[x]->content->deleted = 0;
-            menu->redraw = REDRAW_INDEX;
-          }
-        }
-       }
-       break;
-
-      case OP_RESEND:
-        CHECK_ATTACH;
-        mutt_attach_resend (fp, hdr, idx, idxlen,
-                            menu->tagprefix ? NULL : idx[menu->current]->content);
-        menu->redraw = REDRAW_FULL;
-       break;
-      
-      case OP_BOUNCE_MESSAGE:
-        CHECK_ATTACH;
-        mutt_attach_bounce (fp, hdr, idx, idxlen,
-                            menu->tagprefix ? NULL : idx[menu->current]->content);
-        menu->redraw = REDRAW_FULL;
-       break;
+    case OP_RESEND:
+      CHECK_ATTACH;
+      mutt_attach_resend (fp, hdr, idx, idxlen,
+                          menu->tagprefix ? NULL : idx[menu->current]->
+                          content);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_BOUNCE_MESSAGE:
+      CHECK_ATTACH;
+      mutt_attach_bounce (fp, hdr, idx, idxlen,
+                          menu->tagprefix ? NULL : idx[menu->current]->
+                          content);
+      menu->redraw = REDRAW_FULL;
+      break;
 
-      case OP_FORWARD_MESSAGE:
-        CHECK_ATTACH;
-        mutt_attach_forward (fp, hdr, idx, idxlen,
-                            menu->tagprefix ? NULL : idx[menu->current]->content, 0);
+    case OP_FORWARD_MESSAGE:
+      CHECK_ATTACH;
+      mutt_attach_forward (fp, hdr, idx, idxlen,
+                           menu->tagprefix ? NULL : idx[menu->current]->
+                           content, 0);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+#ifdef USE_NNTP
+    case OP_FORWARD_TO_GROUP:
+      CHECK_ATTACH;
+      mutt_attach_forward (fp, hdr, idx, idxlen,
+                           menu->tagprefix ? NULL : idx[menu->current]->
+                           content, SENDNEWS);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_FOLLOWUP:
+      CHECK_ATTACH;
+
+      if (!idx[menu->current]->content->hdr->env->followup_to ||
+          mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to,
+                           "poster")
+          || query_quadoption (OPT_FOLLOWUPTOPOSTER,
+                               _("Reply by mail as poster prefers?")) !=
+          M_YES) {
+        mutt_attach_reply (fp, hdr, idx, idxlen,
+                           menu->tagprefix ? NULL : idx[menu->current]->
+                           content, SENDNEWS | SENDREPLY);
         menu->redraw = REDRAW_FULL;
         break;
-      
-#ifdef USE_NNTP
-      case OP_FORWARD_TO_GROUP:
-       CHECK_ATTACH;
-       mutt_attach_forward (fp, hdr, idx, idxlen,
-               menu->tagprefix ? NULL : idx[menu->current]->content, SENDNEWS);
-       menu->redraw = REDRAW_FULL;
-       break;
-
-      case OP_FOLLOWUP:
-       CHECK_ATTACH;
-
-       if (!idx[menu->current]->content->hdr->env->followup_to ||
-           mutt_strcasecmp (idx[menu->current]->content->hdr->env->followup_to, "poster") ||
-           query_quadoption (OPT_FOLLOWUPTOPOSTER,_("Reply by mail as poster prefers?")) != M_YES)
-       {
-         mutt_attach_reply (fp, hdr, idx, idxlen,
-               menu->tagprefix ? NULL : idx[menu->current]->content,
-               SENDNEWS|SENDREPLY);
-         menu->redraw = REDRAW_FULL;
-         break;
-       }
+      }
 #endif
 
-      case OP_REPLY:
-      case OP_GROUP_REPLY:
-      case OP_LIST_REPLY:
-
-        CHECK_ATTACH;
-      
-        flags = SENDREPLY | 
-         (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
-         (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
-        mutt_attach_reply (fp, hdr, idx, idxlen, 
-                          menu->tagprefix ? NULL : idx[menu->current]->content, flags);
-       menu->redraw = REDRAW_FULL;
-       break;
-
-      case OP_EDIT_TYPE:
-       mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
-        mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
-       break;
-
-      case OP_EXIT:
-       mx_close_message (&msg);
-       hdr->attach_del = 0;
-       while (idxmax-- > 0)
-       {
-         if (!idx[idxmax])
-           continue;
-         if (idx[idxmax]->content && idx[idxmax]->content->deleted)
-           hdr->attach_del = 1;
-         if (idx[idxmax]->content)
-           idx[idxmax]->content->aptr = NULL;
-         FREE (&idx[idxmax]->tree);
-         FREE (&idx[idxmax]);
-       }
-       if (hdr->attach_del)
-         hdr->changed = 1;
-       FREE (&idx);
-       idxmax = 0;
-
-        if (WithCrypto && need_secured && secured)
-       {
-         fclose (fp);
-         mutt_free_body (&cur);
-       }
-
-       mutt_menuDestroy  (&menu);
-       return;
+    case OP_REPLY:
+    case OP_GROUP_REPLY:
+    case OP_LIST_REPLY:
+
+      CHECK_ATTACH;
+
+      flags = SENDREPLY |
+        (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
+        (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
+      mutt_attach_reply (fp, hdr, idx, idxlen,
+                         menu->tagprefix ? NULL : idx[menu->current]->content,
+                         flags);
+      menu->redraw = REDRAW_FULL;
+      break;
+
+    case OP_EDIT_TYPE:
+      mutt_edit_content_type (hdr, idx[menu->current]->content, fp);
+      mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
+      break;
+
+    case OP_EXIT:
+      mx_close_message (&msg);
+      hdr->attach_del = 0;
+      while (idxmax-- > 0) {
+        if (!idx[idxmax])
+          continue;
+        if (idx[idxmax]->content && idx[idxmax]->content->deleted)
+          hdr->attach_del = 1;
+        if (idx[idxmax]->content)
+          idx[idxmax]->content->aptr = NULL;
+        FREE (&idx[idxmax]->tree);
+        FREE (&idx[idxmax]);
+      }
+      if (hdr->attach_del)
+        hdr->changed = 1;
+      FREE (&idx);
+      idxmax = 0;
+
+      if (WithCrypto && need_secured && secured) {
+        fclose (fp);
+        mutt_free_body (&cur);
+      }
+
+      mutt_menuDestroy (&menu);
+      return;
     }
 
     op = OP_NULL;
index 6a9d21e..b5733aa 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
 
 static short check_msg (BODY * b, short err)
 {
-  if (!mutt_is_message_type (b->type, b->subtype))
-  {
+  if (!mutt_is_message_type (b->type, b->subtype)) {
     if (err)
       mutt_error _("You may only bounce message/rfc822 parts.");
+
     return -1;
   }
   return 0;
 }
 
 static short check_all_msg (ATTACHPTR ** idx, short idxlen,
-                           BODY * cur, short err)
+                            BODY * cur, short err)
 {
   short i;
 
   if (cur && check_msg (cur, err) == -1)
     return -1;
-  else if (!cur)
-  {
-    for (i = 0; i < idxlen; i++)
-    {
-      if (idx[i]->content->tagged)
-      {
-       if (check_msg (idx[i]->content, err) == -1)
-         return -1;
+  else if (!cur) {
+    for (i = 0; i < idxlen; i++) {
+      if (idx[i]->content->tagged) {
+        if (check_msg (idx[i]->content, err) == -1)
+          return -1;
       }
     }
   }
@@ -74,8 +71,7 @@ static short check_all_msg (ATTACHPTR ** idx, short idxlen,
 
 /* can we decode all tagged attachments? */
 
-static short check_can_decode (ATTACHPTR ** idx, short idxlen, 
-                             BODY * cur)
+static short check_can_decode (ATTACHPTR ** idx, short idxlen, BODY * cur)
 {
   short i;
 
@@ -89,15 +85,15 @@ static short check_can_decode (ATTACHPTR ** idx, short idxlen,
   return 1;
 }
 
-static short count_tagged (ATTACHPTR **idx, short idxlen)
+static short count_tagged (ATTACHPTR ** idx, short idxlen)
 {
   short count = 0;
   short i;
-  
+
   for (i = 0; i < idxlen; i++)
     if (idx[i]->content->tagged)
       count++;
-  
+
   return count;
 }
 
@@ -105,8 +101,7 @@ static short count_tagged (ATTACHPTR **idx, short idxlen)
  * attachment.
  */
 
-static short count_tagged_children (ATTACHPTR ** idx, 
-                                   short idxlen, short i)
+static short count_tagged_children (ATTACHPTR ** idx, short idxlen, short i)
 {
   short level = idx[i]->level;
   short count = 0;
@@ -117,17 +112,17 @@ static short count_tagged_children (ATTACHPTR ** idx,
 
   return count;
 }
+\f
 
 
-\f
 /**
  **
  ** The bounce function, from the attachment menu
  **
  **/
 
-void mutt_attach_bounce (FILE * fp, HEADER * hdr, 
-          ATTACHPTR ** idx, short idxlen, BODY * cur)
+void mutt_attach_bounce (FILE * fp, HEADER * hdr,
+                         ATTACHPTR ** idx, short idxlen, BODY * cur)
 {
   short i;
   char prompt[STRING];
@@ -135,7 +130,7 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr,
   char *err = NULL;
   ADDRESS *adr = NULL;
   int ret = 0;
-  int p   = 0;
+  int p = 0;
 
   if (check_all_msg (idx, idxlen, cur, 1) == -1)
     return;
@@ -149,26 +144,25 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr,
     strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt));
 
   buf[0] = '\0';
-  if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS) 
+  if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS)
       || buf[0] == '\0')
     return;
 
-  if (!(adr = rfc822_parse_adrlist (adr, buf)))
-  {
+  if (!(adr = rfc822_parse_adrlist (adr, buf))) {
     mutt_error _("Error parsing address!");
+
     return;
   }
 
   adr = mutt_expand_aliases (adr);
-  
-  if (mutt_addrlist_to_idna (adr, &err) < 0)
-  {
+
+  if (mutt_addrlist_to_idna (adr, &err) < 0) {
     mutt_error (_("Bad IDN: '%s'"), err);
     FREE (&err);
     rfc822_free_address (&adr);
     return;
   }
-  
+
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), adr, 1);
 
@@ -176,49 +170,47 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr,
   /*
    * See commands.c.
    */
-  snprintf (prompt, sizeof (prompt) - 4, 
-   (p ? _("Bounce message to %s") : _("Bounce messages to %s")), buf);
-  
-  if (mutt_strwidth (prompt) > COLS - extra_space)
-  {
+  snprintf (prompt, sizeof (prompt) - 4,
+            (p ? _("Bounce message to %s") : _("Bounce messages to %s")),
+            buf);
+
+  if (mutt_strwidth (prompt) > COLS - extra_space) {
     mutt_format_string (prompt, sizeof (prompt) - 4,
-                       0, COLS-extra_space, 0, 0,
-                       prompt, sizeof (prompt), 0);
+                        0, COLS - extra_space, 0, 0,
+                        prompt, sizeof (prompt), 0);
     safe_strcat (prompt, sizeof (prompt), "...?");
   }
   else
     safe_strcat (prompt, sizeof (prompt), "?");
 
-  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES)
-  {
+  if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
     rfc822_free_address (&adr);
     CLEARLINE (LINES - 1);
     mutt_message (p ? _("Message not bounced.") : _("Messages not bounced."));
     return;
   }
-  
+
   CLEARLINE (LINES - 1);
-  
+
   if (cur)
     ret = mutt_bounce_message (fp, cur->hdr, adr);
-  else
-  {
-    for (i = 0; i < idxlen; i++)
-    {
+  else {
+    for (i = 0; i < idxlen; i++) {
       if (idx[i]->content->tagged)
-       if (mutt_bounce_message (fp, idx[i]->content->hdr, adr))
-         ret = 1;
+        if (mutt_bounce_message (fp, idx[i]->content->hdr, adr))
+          ret = 1;
     }
   }
 
   if (!ret)
     mutt_message (p ? _("Message bounced.") : _("Messages bounced."));
   else
-    mutt_error (p ? _("Error bouncing message!") : _("Error bouncing messages!"));
+    mutt_error (p ? _("Error bouncing message!") :
+                _("Error bouncing messages!"));
 }
+\f
 
 
-\f
 /**
  **
  ** resend-message, from the attachment menu 
@@ -226,8 +218,8 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr,
  **
  **/
 
-void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACHPTR ** idx, 
-                        short idxlen, BODY * cur)
+void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACHPTR ** idx,
+                         short idxlen, BODY * cur)
 {
   short i;
 
@@ -236,25 +228,24 @@ void mutt_attach_resend (FILE * fp, HEADER * hdr, ATTACHPTR ** idx,
 
   if (cur)
     mutt_resend_message (fp, Context, cur->hdr);
-  else
-  {
+  else {
     for (i = 0; i < idxlen; i++)
       if (idx[i]->content->tagged)
-       mutt_resend_message (fp, Context, idx[i]->content->hdr);
+        mutt_resend_message (fp, Context, idx[i]->content->hdr);
   }
 }
-
 \f
+
 /**
  **
  ** forward-message, from the attachment menu 
  **
  **/
-  
+
 /* try to find a common parent message for the tagged attachments. */
 
 static HEADER *find_common_parent (ATTACHPTR ** idx, short idxlen,
-                                  short nattach)
+                                   short nattach)
 {
   short i;
   short nchildren;
@@ -262,14 +253,13 @@ static HEADER *find_common_parent (ATTACHPTR ** idx, short idxlen,
   for (i = 0; i < idxlen; i++)
     if (idx[i]->content->tagged)
       break;
-  
-  while (--i >= 0)
-  {
-    if (mutt_is_message_type (idx[i]->content->type, idx[i]->content->subtype))
-    {
+
+  while (--i >= 0) {
+    if (mutt_is_message_type
+        (idx[i]->content->type, idx[i]->content->subtype)) {
       nchildren = count_tagged_children (idx, idxlen, i);
       if (nchildren == nattach)
-       return idx[i]->content->hdr;
+        return idx[i]->content->hdr;
     }
   }
 
@@ -284,12 +274,11 @@ static HEADER *find_common_parent (ATTACHPTR ** idx, short idxlen,
  * bit.  For now, it's not worth the effort.
  */
 
-static int is_parent (short i, ATTACHPTR **idx, short idxlen, BODY *cur)
+static int is_parent (short i, ATTACHPTR ** idx, short idxlen, BODY * cur)
 {
   short level = idx[i]->level;
 
-  while ((++i < idxlen) && idx[i]->level > level)
-  {
+  while ((++i < idxlen) && idx[i]->level > level) {
     if (idx[i]->content == cur)
       return 1;
   }
@@ -297,72 +286,67 @@ static int is_parent (short i, ATTACHPTR **idx, short idxlen, BODY *cur)
   return 0;
 }
 
-static HEADER *find_parent (ATTACHPTR **idx, short idxlen, BODY *cur, short nattach)
+static HEADER *find_parent (ATTACHPTR ** idx, short idxlen, BODY * cur,
+                            short nattach)
 {
   short i;
   HEADER *parent = NULL;
-  
-  if (cur)
-  {
-    for (i = 0; i < idxlen; i++)
-    {
-      if (mutt_is_message_type (idx[i]->content->type, idx[i]->content->subtype) 
-         && is_parent (i, idx, idxlen, cur))
-       parent = idx[i]->content->hdr;
+
+  if (cur) {
+    for (i = 0; i < idxlen; i++) {
+      if (mutt_is_message_type
+          (idx[i]->content->type, idx[i]->content->subtype)
+          && is_parent (i, idx, idxlen, cur))
+        parent = idx[i]->content->hdr;
       if (idx[i]->content == cur)
-       break;
+        break;
     }
   }
   else if (nattach)
     parent = find_common_parent (idx, idxlen, nattach);
-  
+
   return parent;
 }
 
 static void include_header (int quote, FILE * ifp,
-                           HEADER * hdr, FILE * ofp,
-                           char *_prefix)
+                            HEADER * hdr, FILE * ofp, char *_prefix)
 {
   int chflags = CH_DECODE;
   char prefix[SHORT_STRING];
-  
+
   if (option (OPTWEED))
     chflags |= CH_WEED | CH_REORDER;
 
-  if (quote)
-  {
+  if (quote) {
     if (_prefix)
       strfcpy (prefix, _prefix, sizeof (prefix));
     else if (!option (OPTTEXTFLOWED))
-      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), 
-                        Context, hdr, 0);
+      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix),
+                         Context, hdr, 0);
     else
       strfcpy (prefix, ">", sizeof (prefix));
 
     chflags |= CH_PREFIX;
   }
-  
+
   mutt_copy_header (ifp, hdr, ofp, chflags, quote ? prefix : NULL);
 }
 
 /* Attach all the body parts which can't be decoded. 
  * This code is shared by forwarding and replying. */
 
-static BODY ** copy_problematic_attachments (FILE *fp,
-                                            BODY **last, 
-                                            ATTACHPTR **idx, 
-                                            short idxlen,
-                                            short force)
+static BODY **copy_problematic_attachments (FILE * fp,
+                                            BODY ** last,
+                                            ATTACHPTR ** idx,
+                                            short idxlen, short force)
 {
   short i;
-  
-  for (i = 0; i < idxlen; i++)
-  {
-    if (idx[i]->content->tagged && 
-       (force || !mutt_can_decode (idx[i]->content)))
-    {
+
+  for (i = 0; i < idxlen; i++) {
+    if (idx[i]->content->tagged &&
+        (force || !mutt_can_decode (idx[i]->content))) {
       if (mutt_copy_body (fp, last, idx[i]->content) == -1)
-       return NULL;            /* XXXXX - may lead to crashes */
+        return NULL;            /* XXXXX - may lead to crashes */
       last = &((*last)->next);
     }
   }
@@ -375,9 +359,8 @@ static BODY ** copy_problematic_attachments (FILE *fp,
  */
 
 static void attach_forward_bodies (FILE * fp, HEADER * hdr,
-                                  ATTACHPTR ** idx, short idxlen,
-                                  BODY * cur,
-                                  short nattach, int flags)
+                                   ATTACHPTR ** idx, short idxlen,
+                                   BODY * cur, short nattach, int flags)
 {
   short i;
   short mime_fwd_all = 0;
@@ -402,7 +385,7 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
 
 
   parent = find_parent (idx, idxlen, cur, nattach);
-  
+
   if (parent == NULL)
     parent = hdr;
 
@@ -412,8 +395,7 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
   mutt_make_forward_subject (tmphdr->env, Context, parent);
 
   mutt_mktemp (tmpbody);
-  if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL)
-  {
+  if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) {
     mutt_error (_("Can't open temporary file %s."), tmpbody);
     return;
   }
@@ -422,17 +404,15 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
 
   /* prepare the prefix here since we'll need it later. */
 
-  if (option (OPTFORWQUOTE))
-  {
+  if (option (OPTFORWQUOTE)) {
     if (!option (OPTTEXTFLOWED))
       _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context,
-                        parent, 0);
+                         parent, 0);
     else
       strfcpy (prefix, ">", sizeof (prefix));
   }
-    
-  include_header (option (OPTFORWQUOTE), fp, parent,
-                 tmpfp, prefix);
+
+  include_header (option (OPTFORWQUOTE), fp, parent, tmpfp, prefix);
 
 
   /* 
@@ -444,8 +424,8 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
    */
 
   if ((!cur || mutt_can_decode (cur)) &&
-      (rc = query_quadoption (OPT_MIMEFWD, 
-                             _("Forward as attachments?"))) == M_YES)
+      (rc = query_quadoption (OPT_MIMEFWD,
+                              _("Forward as attachments?"))) == M_YES)
     mime_fwd_all = 1;
   else if (rc == -1)
     goto bail;
@@ -455,20 +435,21 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
    * this intuitive?
    */
 
-  if (!mime_fwd_all && !cur && (nattach > 1) 
-      && !check_can_decode (idx, idxlen, cur))
-  {
+  if (!mime_fwd_all && !cur && (nattach > 1)
+      && !check_can_decode (idx, idxlen, cur)) {
     if ((rc = query_quadoption (OPT_MIMEFWDREST,
-_("Can't decode all tagged attachments.  MIME-forward the others?"))) == -1)
+                                _
+                                ("Can't decode all tagged attachments.  MIME-forward the others?")))
+        == -1)
       goto bail;
     else if (rc == M_NO)
       mime_fwd_any = 0;
   }
 
   /* initialize a state structure */
-  
+
   memset (&st, 0, sizeof (st));
-  
+
   if (option (OPTFORWQUOTE))
     st.prefix = prefix;
   st.flags = M_CHARCONV;
@@ -480,56 +461,50 @@ _("Can't decode all tagged attachments.  MIME-forward the others?"))) == -1)
   /* where do we append new MIME parts? */
   last = &tmphdr->content;
 
-  if (cur)
-  {
+  if (cur) {
     /* single body case */
 
-    if (!mime_fwd_all && mutt_can_decode (cur))
-    {
+    if (!mime_fwd_all && mutt_can_decode (cur)) {
       mutt_body_handler (cur, &st);
       state_putc ('\n', &st);
     }
-    else
-    {
+    else {
       if (mutt_copy_body (fp, last, cur) == -1)
-       goto bail;
+        goto bail;
       last = &((*last)->next);
     }
   }
-  else
-  {
+  else {
     /* multiple body case */
 
-    if (!mime_fwd_all)
-    {
-      for (i = 0; i < idxlen; i++)
-      {
-       if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))
-       {
-         mutt_body_handler (idx[i]->content, &st);
-         state_putc ('\n', &st);
-       }
+    if (!mime_fwd_all) {
+      for (i = 0; i < idxlen; i++) {
+        if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content)) {
+          mutt_body_handler (idx[i]->content, &st);
+          state_putc ('\n', &st);
+        }
       }
     }
 
-    if (mime_fwd_any && 
-       (last = copy_problematic_attachments (fp, last, idx, idxlen, mime_fwd_all)) == NULL)
+    if (mime_fwd_any &&
+        (last =
+         copy_problematic_attachments (fp, last, idx, idxlen,
+                                       mime_fwd_all)) == NULL)
       goto bail;
   }
-  
+
   mutt_forward_trailer (tmpfp);
-  
+
   fclose (tmpfp);
   tmpfp = NULL;
 
   /* now that we have the template, send it. */
   ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
   return;
-  
-  bail:
-  
-  if (tmpfp)
-  {
+
+bail:
+
+  if (tmpfp) {
     fclose (tmpfp);
     mutt_unlink (tmpbody);
   }
@@ -549,8 +524,9 @@ _("Can't decode all tagged attachments.  MIME-forward the others?"))) == -1)
  * the attachment index. 
  */
 
-static void attach_forward_msgs (FILE * fp, HEADER * hdr, 
-              ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
+static void attach_forward_msgs (FILE * fp, HEADER * hdr,
+                                 ATTACHPTR ** idx, short idxlen, BODY * cur,
+                                 int flags)
 {
   HEADER *curhdr = NULL;
   HEADER *tmphdr;
@@ -563,16 +539,14 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
 
   int cmflags = 0;
   int chflags = CH_XMIT;
-  
+
   if (cur)
     curhdr = cur->hdr;
-  else
-  {
+  else {
     for (i = 0; i < idxlen; i++)
-      if (idx[i]->content->tagged)
-      {
-       curhdr = idx[i]->content->hdr;
-       break;
+      if (idx[i]->content->tagged) {
+        curhdr = idx[i]->content->hdr;
+        break;
       }
   }
 
@@ -583,100 +557,89 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
 
   tmpbody[0] = '\0';
 
-  if ((rc = query_quadoption (OPT_MIMEFWD, 
-                _("Forward MIME encapsulated?"))) == M_NO)
-  {
-    
+  if ((rc = query_quadoption (OPT_MIMEFWD,
+                              _("Forward MIME encapsulated?"))) == M_NO) {
+
     /* no MIME encapsulation */
-    
+
     mutt_mktemp (tmpbody);
-    if (!(tmpfp = safe_fopen (tmpbody, "w")))
-    {
+    if (!(tmpfp = safe_fopen (tmpbody, "w"))) {
       mutt_error (_("Can't create %s."), tmpbody);
       mutt_free_header (&tmphdr);
       return;
     }
 
-    if (option (OPTFORWQUOTE))
-    {
+    if (option (OPTFORWQUOTE)) {
       chflags |= CH_PREFIX;
       cmflags |= M_CM_PREFIX;
     }
 
-    if (option (OPTFORWDECODE))
-    {
+    if (option (OPTFORWDECODE)) {
       cmflags |= M_CM_DECODE | M_CM_CHARCONV;
-      if (option (OPTWEED))
-      {
-       chflags |= CH_WEED | CH_REORDER;
-       cmflags |= M_CM_WEED;
+      if (option (OPTWEED)) {
+        chflags |= CH_WEED | CH_REORDER;
+        cmflags |= M_CM_WEED;
       }
     }
-    
-    
-    if (cur)
-    {
-      /* mutt_message_hook (cur->hdr, M_MESSAGEHOOK); */ 
+
+
+    if (cur) {
+      /* mutt_message_hook (cur->hdr, M_MESSAGEHOOK); */
       mutt_forward_intro (tmpfp, cur->hdr);
-      _mutt_copy_message (tmpfp, fp, cur->hdr, cur->hdr->content, cmflags, chflags);
+      _mutt_copy_message (tmpfp, fp, cur->hdr, cur->hdr->content, cmflags,
+                          chflags);
       mutt_forward_trailer (tmpfp);
     }
-    else
-    {
-      for (i = 0; i < idxlen; i++)
-      {
-       if (idx[i]->content->tagged)
-       {
-         /* mutt_message_hook (idx[i]->content->hdr, M_MESSAGEHOOK); */ 
-         mutt_forward_intro (tmpfp, idx[i]->content->hdr);
-         _mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,
-                             idx[i]->content->hdr->content, cmflags, chflags);
-         mutt_forward_trailer (tmpfp);
-       }
+    else {
+      for (i = 0; i < idxlen; i++) {
+        if (idx[i]->content->tagged) {
+          /* mutt_message_hook (idx[i]->content->hdr, M_MESSAGEHOOK); */
+          mutt_forward_intro (tmpfp, idx[i]->content->hdr);
+          _mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,
+                              idx[i]->content->hdr->content, cmflags,
+                              chflags);
+          mutt_forward_trailer (tmpfp);
+        }
       }
     }
     fclose (tmpfp);
   }
-  else if (rc == M_YES)        /* do MIME encapsulation - we don't need to do much here */
-  {
+  else if (rc == M_YES) {       /* do MIME encapsulation - we don't need to do much here */
     last = &tmphdr->content;
     if (cur)
       mutt_copy_body (fp, last, cur);
-    else
-    {
+    else {
       for (i = 0; i < idxlen; i++)
-       if (idx[i]->content->tagged)
-       {
-         mutt_copy_body (fp, last, idx[i]->content);
-         last = &((*last)->next);
-       }
+        if (idx[i]->content->tagged) {
+          mutt_copy_body (fp, last, idx[i]->content);
+          last = &((*last)->next);
+        }
     }
   }
   else
     mutt_free_header (&tmphdr);
 
-  ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, 
-                  NULL, curhdr);
+  ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, NULL, curhdr);
 
 }
 
-void mutt_attach_forward (FILE * fp, HEADER * hdr, 
-                         ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
+void mutt_attach_forward (FILE * fp, HEADER * hdr,
+                          ATTACHPTR ** idx, short idxlen, BODY * cur,
+                          int flags)
 {
   short nattach;
-  
+
 
   if (check_all_msg (idx, idxlen, cur, 0) == 0)
     attach_forward_msgs (fp, hdr, idx, idxlen, cur, flags);
-  else
-  {
+  else {
     nattach = count_tagged (idx, idxlen);
     attach_forward_bodies (fp, hdr, idx, idxlen, cur, nattach, flags);
   }
 }
+\f
 
 
-\f
 /**
  ** 
  ** the various reply functions, from the attachment menu
@@ -696,68 +659,61 @@ void mutt_attach_forward (FILE * fp, HEADER * hdr,
  * 
  * Note that this code is horribly similar to envelope_defaults () from send.c.
  */
-  
+
 static int
-attach_reply_envelope_defaults (ENVELOPE *env, ATTACHPTR **idx, short idxlen,
-                               HEADER *parent, int flags)
+attach_reply_envelope_defaults (ENVELOPE * env, ATTACHPTR ** idx,
+                                short idxlen, HEADER * parent, int flags)
 {
   ENVELOPE *curenv = NULL;
   HEADER *curhdr = NULL;
   short i;
-  
-  if (!parent)
-  {
-    for (i = 0; i < idxlen; i++)
-    {
-      if (idx[i]->content->tagged)
-      {
-       curhdr = idx[i]->content->hdr;
-       curenv = curhdr->env;
-       break;
+
+  if (!parent) {
+    for (i = 0; i < idxlen; i++) {
+      if (idx[i]->content->tagged) {
+        curhdr = idx[i]->content->hdr;
+        curenv = curhdr->env;
+        break;
       }
     }
   }
-  else
-  {
+  else {
     curenv = parent->env;
     curhdr = parent;
   }
 
-  if (curenv == NULL  ||  curhdr == NULL)
-  {
+  if (curenv == NULL || curhdr == NULL) {
     mutt_error _("Can't find any tagged messages.");
+
     return -1;
   }
 
 #ifdef USE_NNTP
-  if ((flags & SENDNEWS))
-  {
+  if ((flags & SENDNEWS)) {
     /* in case followup set Newsgroups: with Followup-To: if it present */
     if (!env->newsgroups && curenv &&
-       mutt_strcasecmp (curenv->followup_to, "poster"))
+        mutt_strcasecmp (curenv->followup_to, "poster"))
       env->newsgroups = safe_strdup (curenv->followup_to);
   }
   else
 #endif
   {
-    if (parent)
-    {
+    if (parent) {
       if (mutt_fetch_recips (env, curenv, flags) == -1)
-       return -1;
+        return -1;
     }
-    else
-    {
-      for (i = 0; i < idxlen; i++)
-      {
-       if (idx[i]->content->tagged
-           && mutt_fetch_recips (env, idx[i]->content->hdr->env, flags) == -1)
-         return -1;
+    else {
+      for (i = 0; i < idxlen; i++) {
+        if (idx[i]->content->tagged
+            && mutt_fetch_recips (env, idx[i]->content->hdr->env,
+                                  flags) == -1)
+          return -1;
       }
     }
 
-    if ((flags & SENDLISTREPLY) && !env->to)
-    {
+    if ((flags & SENDLISTREPLY) && !env->to) {
       mutt_error _("No mailing lists found!");
+
       return (-1);
     }
 
@@ -767,36 +723,35 @@ attach_reply_envelope_defaults (ENVELOPE *env, ATTACHPTR **idx, short idxlen,
 
   if (parent)
     mutt_add_to_reference_headers (env, curenv, NULL, NULL);
-  else
-  {
+  else {
     LIST **p = NULL, **q = NULL;
-    
-    for (i = 0; i < idxlen; i++)
-    {
+
+    for (i = 0; i < idxlen; i++) {
       if (idx[i]->content->tagged)
-       mutt_add_to_reference_headers (env, idx[i]->content->hdr->env, &p, &q);
+        mutt_add_to_reference_headers (env, idx[i]->content->hdr->env, &p,
+                                       &q);
     }
   }
-  
+
   return 0;
 }
 
 
 /*  This is _very_ similar to send.c's include_reply(). */
 
-static void attach_include_reply (FILE *fp, FILE *tmpfp, HEADER *cur, int flags)
+static void attach_include_reply (FILE * fp, FILE * tmpfp, HEADER * cur,
+                                  int flags)
 {
   int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV;
   int chflags = CH_DECODE;
 
-  /* mutt_message_hook (cur, M_MESSAGEHOOK); */ 
-  
+  /* mutt_message_hook (cur, M_MESSAGEHOOK); */
+
   mutt_make_attribution (Context, cur, tmpfp);
-  
+
   if (!option (OPTHEADER))
     cmflags |= M_CM_NOHEADER;
-  if (option (OPTWEED))
-  {
+  if (option (OPTWEED)) {
     chflags |= CH_WEED;
     cmflags |= M_CM_WEED;
   }
@@ -804,13 +759,12 @@ static void attach_include_reply (FILE *fp, FILE *tmpfp, HEADER *cur, int flags)
   _mutt_copy_message (tmpfp, fp, cur, cur->content, cmflags, chflags);
   mutt_make_post_indent (Context, cur, tmpfp);
 }
-  
-void mutt_attach_reply (FILE * fp, HEADER * hdr, 
-                       ATTACHPTR ** idx, short idxlen, BODY * cur, 
-                       int flags)
+
+void mutt_attach_reply (FILE * fp, HEADER * hdr,
+                        ATTACHPTR ** idx, short idxlen, BODY * cur, int flags)
 {
   short mime_reply_any = 0;
-  
+
   short nattach = 0;
   HEADER *parent = NULL;
   HEADER *tmphdr = NULL;
@@ -819,10 +773,10 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
   STATE st;
   char tmpbody[_POSIX_PATH_MAX];
   FILE *tmpfp;
-  
+
   char prefix[SHORT_STRING];
   int rc;
-  
+
 #ifdef USE_NNTP
   if (flags & SENDNEWS)
     set_option (OPTNEWSSEND);
@@ -830,17 +784,17 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
     unset_option (OPTNEWSSEND);
 #endif
 
-  if (check_all_msg (idx, idxlen, cur, 0) == -1)
-  {
+  if (check_all_msg (idx, idxlen, cur, 0) == -1) {
     nattach = count_tagged (idx, idxlen);
     if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL)
       parent = hdr;
   }
 
-  if (nattach > 1 && !check_can_decode (idx, idxlen, cur))
-  {
+  if (nattach > 1 && !check_can_decode (idx, idxlen, cur)) {
     if ((rc = query_quadoption (OPT_MIMEFWDREST,
-      _("Can't decode all tagged attachments.  MIME-encapsulate the others?"))) == -1)
+                                _
+                                ("Can't decode all tagged attachments.  MIME-encapsulate the others?")))
+        == -1)
       return;
     else if (rc == M_YES)
       mime_reply_any = 1;
@@ -851,84 +805,75 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
   tmphdr = mutt_new_header ();
   tmphdr->env = mutt_new_envelope ();
 
-  if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen, 
-                                     parent ? parent : (cur ? cur->hdr : NULL), flags) == -1)
-  {
+  if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen,
+                                      parent ? parent : (cur ? cur->
+                                                         hdr : NULL),
+                                      flags) == -1) {
     mutt_free_header (&tmphdr);
     return;
   }
-  
+
   mutt_mktemp (tmpbody);
-  if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL)
-  {
+  if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) {
     mutt_error (_("Can't create %s."), tmpbody);
     mutt_free_header (&tmphdr);
     return;
   }
 
-  if (!parent)
-  {
+  if (!parent) {
     if (cur)
       attach_include_reply (fp, tmpfp, cur->hdr, flags);
-    else
-    {
-      for (i = 0; i < idxlen; i++)
-      {
-       if (idx[i]->content->tagged)
-         attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags);
+    else {
+      for (i = 0; i < idxlen; i++) {
+        if (idx[i]->content->tagged)
+          attach_include_reply (fp, tmpfp, idx[i]->content->hdr, flags);
       }
     }
   }
-  else
-  {
+  else {
     mutt_make_attribution (Context, parent, tmpfp);
-    
+
     memset (&st, 0, sizeof (STATE));
     st.fpin = fp;
     st.fpout = tmpfp;
 
     if (!option (OPTTEXTFLOWED))
-      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), 
-                        Context, parent, 0);
+      _mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix),
+                         Context, parent, 0);
     else
       strfcpy (prefix, ">", sizeof (prefix));
 
     st.prefix = prefix;
-    st.flags  = M_CHARCONV;
-    
-    if (option (OPTWEED)) 
+    st.flags = M_CHARCONV;
+
+    if (option (OPTWEED))
       st.flags |= M_WEED;
 
     if (option (OPTHEADER))
       include_header (1, fp, parent, tmpfp, prefix);
 
-    if (cur)
-    {
-      if (mutt_can_decode (cur))
-      {
-       mutt_body_handler (cur, &st);
-       state_putc ('\n', &st);
+    if (cur) {
+      if (mutt_can_decode (cur)) {
+        mutt_body_handler (cur, &st);
+        state_putc ('\n', &st);
       }
       else
-       mutt_copy_body (fp, &tmphdr->content, cur);
+        mutt_copy_body (fp, &tmphdr->content, cur);
     }
-    else
-    {
-      for (i = 0; i < idxlen; i++)
-      {
-       if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content))
-       {
-         mutt_body_handler (idx[i]->content, &st);
-         state_putc ('\n', &st);
-       }
+    else {
+      for (i = 0; i < idxlen; i++) {
+        if (idx[i]->content->tagged && mutt_can_decode (idx[i]->content)) {
+          mutt_body_handler (idx[i]->content, &st);
+          state_putc ('\n', &st);
+        }
       }
     }
 
     mutt_make_post_indent (Context, parent, tmpfp);
 
-    if (mime_reply_any && !cur && 
-       copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL)
-    {
+    if (mime_reply_any && !cur &&
+        copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen,
+                                      0) == NULL) {
       mutt_free_header (&tmphdr);
       fclose (tmpfp);
       return;
@@ -936,8 +881,7 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
   }
 
   fclose (tmpfp);
-  
+
   if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent) == 0)
     mutt_set_flag (Context, hdr, M_REPLIED, 1);
 }
-
diff --git a/regex.c b/regex.c
index 435b8ae..c6c9850 100644 (file)
--- a/regex.c
+++ b/regex.c
@@ -99,7 +99,7 @@
 #include "buffer.h"
 #include "syntax.h"
 
-#else  /* not emacs */
+#else /* not emacs */
 
 /* If we are not linking with Emacs proper,
    we can't use the relocating allocator
 #if defined (STDC_HEADERS) || defined (_LIBC)
 #include <stdlib.h>
 #else
-char *malloc ();        /* __MEM_CHECKED__ */
-char *realloc ();        /* __MEM_CHECKED__ */
+char *malloc ();                /* __MEM_CHECKED__ */
+char *realloc ();               /* __MEM_CHECKED__ */
 #endif
 
 /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
@@ -168,64 +168,64 @@ extern char *re_syntax_table;
 
 static char re_syntax_table[CHAR_SET_SIZE];
 
-enum { MUTT_ALNUM = 1, MUTT_ALPHA, MUTT_BLANK, MUTT_CNTRL, MUTT_DIGIT, MUTT_GRAPH,
-       MUTT_LOWER, MUTT_PRINT, MUTT_PUNCT, MUTT_SPACE, MUTT_UPPER, MUTT_XDIGIT,
-       MUTT_INVALID
-     };
+enum { MUTT_ALNUM =
+    1, MUTT_ALPHA, MUTT_BLANK, MUTT_CNTRL, MUTT_DIGIT, MUTT_GRAPH,
+  MUTT_LOWER, MUTT_PRINT, MUTT_PUNCT, MUTT_SPACE, MUTT_UPPER, MUTT_XDIGIT,
+  MUTT_INVALID
+};
 
-static int ctype(const char *name)
+static int ctype (const char *name)
 {
-  if (0==strcmp(name,"alnum"))
+  if (0 == strcmp (name, "alnum"))
     return MUTT_ALNUM;
-  if (0==strcmp(name,"alpha"))
+  if (0 == strcmp (name, "alpha"))
     return MUTT_ALPHA;
-  if (0==strcmp(name,"blank"))
+  if (0 == strcmp (name, "blank"))
     return MUTT_BLANK;
-  if (0==strcmp(name,"cntrl"))
+  if (0 == strcmp (name, "cntrl"))
     return MUTT_CNTRL;
-  if (0==strcmp(name,"digit"))
+  if (0 == strcmp (name, "digit"))
     return MUTT_DIGIT;
-  if (0==strcmp(name,"graph"))
+  if (0 == strcmp (name, "graph"))
     return MUTT_GRAPH;
-  if (0==strcmp(name,"lower"))
+  if (0 == strcmp (name, "lower"))
     return MUTT_LOWER;
-  if (0==strcmp(name,"print"))
+  if (0 == strcmp (name, "print"))
     return MUTT_PRINT;
-  if (0==strcmp(name,"punct"))
+  if (0 == strcmp (name, "punct"))
     return MUTT_PUNCT;
-  if (0==strcmp(name,"space"))
+  if (0 == strcmp (name, "space"))
     return MUTT_SPACE;
-  if (0==strcmp(name,"upper"))
+  if (0 == strcmp (name, "upper"))
     return MUTT_UPPER;
-  if (0==strcmp(name,"xdigit"))
+  if (0 == strcmp (name, "xdigit"))
     return MUTT_XDIGIT;
   return MUTT_INVALID;
 }
 
 
-static void
-init_syntax_once ()
+static void init_syntax_once ()
 {
-   register int c;
-   static int done = 0;
+  register int c;
+  static int done = 0;
 
-   if (done)
-     return;
+  if (done)
+    return;
 
-   bzero (re_syntax_table, sizeof re_syntax_table);
+  bzero (re_syntax_table, sizeof re_syntax_table);
 
-   for (c = 'a'; c <= 'z'; c++)
-     re_syntax_table[c] = Sword;
+  for (c = 'a'; c <= 'z'; c++)
+    re_syntax_table[c] = Sword;
 
-   for (c = 'A'; c <= 'Z'; c++)
-     re_syntax_table[c] = Sword;
+  for (c = 'A'; c <= 'Z'; c++)
+    re_syntax_table[c] = Sword;
 
-   for (c = '0'; c <= '9'; c++)
-     re_syntax_table[c] = Sword;
+  for (c = '0'; c <= '9'; c++)
+    re_syntax_table[c] = Sword;
 
-   re_syntax_table['_'] = Sword;
+  re_syntax_table['_'] = Sword;
 
-   done = 1;
+  done = 1;
 }
 
 #endif /* not SYNTAX_TABLE */
@@ -293,7 +293,7 @@ init_syntax_once ()
 #undef SIGN_EXTEND_CHAR
 #if __STDC__
 #define SIGN_EXTEND_CHAR(c) ((signed char) (c))
-#else  /* not __STDC__ */
+#else /* not __STDC__ */
 /* As in Harbison and Steele.  */
 #define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
 #endif
@@ -326,8 +326,8 @@ init_syntax_once ()
 #if HAVE_ALLOCA_H
 #include <alloca.h>
 #else /* not __GNUC__ or HAVE_ALLOCA_H */
-#if 0 /* It is a bad idea to declare alloca.  We always cast the result.  */
-#ifndef _AIX /* Already did AIX, up at the top.  */
+#if 0                           /* It is a bad idea to declare alloca.  We always cast the result.  */
+#ifndef _AIX                    /* Already did AIX, up at the top.  */
 char *alloca ();
 #endif /* not _AIX */
 #endif
@@ -345,7 +345,7 @@ char *alloca ();
    destination)
 
 /* No need to do anything to free, after alloca.  */
-#define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc warning.  */
+#define REGEX_FREE(arg) ((void)0)       /* Do nothing!  But inhibit gcc warning.  */
 
 #endif /* not REGEX_MALLOC */
 
@@ -394,7 +394,7 @@ char *alloca ();
   if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t)
 #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
 
-#define BYTEWIDTH 8 /* In bits.  */
+#define BYTEWIDTH 8             /* In bits.  */
 
 #define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
 
@@ -404,6 +404,7 @@ char *alloca ();
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 typedef char boolean;
+
 #define false 0
 #define true 1
 
@@ -414,136 +415,134 @@ static int re_match_2_internal ();
    command code can specify any interpretation whatsoever for its
    arguments.  Zero bytes may appear in the compiled regular expression.  */
 
-typedef enum
-{
+typedef enum {
   no_op = 0,
 
   /* Succeed right away--no more backtracking.  */
   succeed,
 
-        /* Followed by one byte giving n, then by n literal bytes.  */
+  /* Followed by one byte giving n, then by n literal bytes.  */
   exactn,
 
-        /* Matches any (more or less) character.  */
+  /* Matches any (more or less) character.  */
   anychar,
 
-        /* Matches any one char belonging to specified set.  First
-           following byte is number of bitmap bytes.  Then come bytes
-           for a bitmap saying which chars are in.  Bits in each byte
-           are ordered low-bit-first.  A character is in the set if its
-           bit is 1.  A character too large to have a bit in the map is
-           automatically not in the set.  */
+  /* Matches any one char belonging to specified set.  First
+     following byte is number of bitmap bytes.  Then come bytes
+     for a bitmap saying which chars are in.  Bits in each byte
+     are ordered low-bit-first.  A character is in the set if its
+     bit is 1.  A character too large to have a bit in the map is
+     automatically not in the set.  */
   charset,
 
-        /* Same parameters as charset, but match any character that is
-           not one of those specified.  */
+  /* Same parameters as charset, but match any character that is
+     not one of those specified.  */
   charset_not,
 
-        /* Start remembering the text that is matched, for storing in a
-           register.  Followed by one byte with the register number, in
-           the range 0 to one less than the pattern buffer's re_nsub
-           field.  Then followed by one byte with the number of groups
-           inner to this one.  (This last has to be part of the
-           start_memory only because we need it in the on_failure_jump
-           of re_match_2.)  */
+  /* Start remembering the text that is matched, for storing in a
+     register.  Followed by one byte with the register number, in
+     the range 0 to one less than the pattern buffer's re_nsub
+     field.  Then followed by one byte with the number of groups
+     inner to this one.  (This last has to be part of the
+     start_memory only because we need it in the on_failure_jump
+     of re_match_2.)  */
   start_memory,
 
-        /* Stop remembering the text that is matched and store it in a
-           memory register.  Followed by one byte with the register
-           number, in the range 0 to one less than `re_nsub' in the
-           pattern buffer, and one byte with the number of inner groups,
-           just like `start_memory'.  (We need the number of inner
-           groups here because we don't have any easy way of finding the
-           corresponding start_memory when we're at a stop_memory.)  */
+  /* Stop remembering the text that is matched and store it in a
+     memory register.  Followed by one byte with the register
+     number, in the range 0 to one less than `re_nsub' in the
+     pattern buffer, and one byte with the number of inner groups,
+     just like `start_memory'.  (We need the number of inner
+     groups here because we don't have any easy way of finding the
+     corresponding start_memory when we're at a stop_memory.)  */
   stop_memory,
 
-        /* Match a duplicate of something remembered. Followed by one
-           byte containing the register number.  */
+  /* Match a duplicate of something remembered. Followed by one
+     byte containing the register number.  */
   duplicate,
 
-        /* Fail unless at beginning of line.  */
+  /* Fail unless at beginning of line.  */
   begline,
 
-        /* Fail unless at end of line.  */
+  /* Fail unless at end of line.  */
   endline,
 
-        /* Succeeds if at beginning of buffer (if emacs) or at beginning
-           of string to be matched (if not).  */
+  /* Succeeds if at beginning of buffer (if emacs) or at beginning
+     of string to be matched (if not).  */
   begbuf,
 
-        /* Analogously, for end of buffer/string.  */
+  /* Analogously, for end of buffer/string.  */
   endbuf,
 
-        /* Followed by two byte relative address to which to jump.  */
+  /* Followed by two byte relative address to which to jump.  */
   jump,
 
-        /* Same as jump, but marks the end of an alternative.  */
+  /* Same as jump, but marks the end of an alternative.  */
   jump_past_alt,
 
-        /* Followed by two-byte relative address of place to resume at
-           in case of failure.  */
+  /* Followed by two-byte relative address of place to resume at
+     in case of failure.  */
   on_failure_jump,
 
-        /* Like on_failure_jump, but pushes a placeholder instead of the
-           current string position when executed.  */
+  /* Like on_failure_jump, but pushes a placeholder instead of the
+     current string position when executed.  */
   on_failure_keep_string_jump,
 
-        /* Throw away latest failure point and then jump to following
-           two-byte relative address.  */
+  /* Throw away latest failure point and then jump to following
+     two-byte relative address.  */
   pop_failure_jump,
 
-        /* Change to pop_failure_jump if know won't have to backtrack to
-           match; otherwise change to jump.  This is used to jump
-           back to the beginning of a repeat.  If what follows this jump
-           clearly won't match what the repeat does, such that we can be
-           sure that there is no use backtracking out of repetitions
-           already matched, then we change it to a pop_failure_jump.
-           Followed by two-byte address.  */
+  /* Change to pop_failure_jump if know won't have to backtrack to
+     match; otherwise change to jump.  This is used to jump
+     back to the beginning of a repeat.  If what follows this jump
+     clearly won't match what the repeat does, such that we can be
+     sure that there is no use backtracking out of repetitions
+     already matched, then we change it to a pop_failure_jump.
+     Followed by two-byte address.  */
   maybe_pop_jump,
 
-        /* Jump to following two-byte address, and push a dummy failure
-           point. This failure point will be thrown away if an attempt
-           is made to use it for a failure.  A `+' construct makes this
-           before the first repeat.  Also used as an intermediary kind
-           of jump when compiling an alternative.  */
+  /* Jump to following two-byte address, and push a dummy failure
+     point. This failure point will be thrown away if an attempt
+     is made to use it for a failure.  A `+' construct makes this
+     before the first repeat.  Also used as an intermediary kind
+     of jump when compiling an alternative.  */
   dummy_failure_jump,
 
-        /* Push a dummy failure point and continue.  Used at the end of
-           alternatives.  */
+  /* Push a dummy failure point and continue.  Used at the end of
+     alternatives.  */
   push_dummy_failure,
 
-        /* Followed by two-byte relative address and two-byte number n.
-           After matching N times, jump to the address upon failure.  */
+  /* Followed by two-byte relative address and two-byte number n.
+     After matching N times, jump to the address upon failure.  */
   succeed_n,
 
-        /* Followed by two-byte relative address, and two-byte number n.
-           Jump to the address N times, then fail.  */
+  /* Followed by two-byte relative address, and two-byte number n.
+     Jump to the address N times, then fail.  */
   jump_n,
 
-        /* Set the following two-byte relative address to the
-           subsequent two-byte number.  The address *includes* the two
-           bytes of number.  */
+  /* Set the following two-byte relative address to the
+     subsequent two-byte number.  The address *includes* the two
+     bytes of number.  */
   set_number_at,
 
-  wordchar,        /* Matches any word-constituent character.  */
-  notwordchar,        /* Matches any char that is not a word-constituent.  */
+  wordchar,                     /* Matches any word-constituent character.  */
+  notwordchar,                  /* Matches any char that is not a word-constituent.  */
 
-  wordbeg,        /* Succeeds if at word beginning.  */
-  wordend,        /* Succeeds if at word end.  */
-
-  wordbound,        /* Succeeds if at a word boundary.  */
-  notwordbound        /* Succeeds if not at a word boundary.  */
+  wordbeg,                      /* Succeeds if at word beginning.  */
+  wordend,                      /* Succeeds if at word end.  */
 
+  wordbound,                    /* Succeeds if at a word boundary.  */
+  notwordbound                  /* Succeeds if not at a word boundary.  */
 #ifdef emacs
-  ,before_dot,        /* Succeeds if before point.  */
-  at_dot,        /* Succeeds if at point.  */
-  after_dot,        /* Succeeds if after point.  */
+    , before_dot,               /* Succeeds if before point.  */
+  at_dot,                       /* Succeeds if at point.  */
+  after_dot,                    /* Succeeds if after point.  */
 
-        /* Matches any character whose syntax is specified.  Followed by
-           a byte which contains a syntax code, e.g., Sword.  */
+  /* Matches any character whose syntax is specified.  Followed by
+     a byte which contains a syntax code, e.g., Sword.  */
   syntaxspec,
 
-        /* Matches any character whose syntax is not that specified.  */
+  /* Matches any character whose syntax is not that specified.  */
   notsyntaxspec
 #endif /* emacs */
 } re_opcode_t;
@@ -579,17 +578,17 @@ typedef enum
 
 #ifdef DEBUG
 static void extract_number _RE_ARGS ((int *dest, unsigned char *source));
-static void
-extract_number (dest, source)
-    int *dest;
-    unsigned char *source;
+static void extract_number (dest, source)
+     int *dest;
+     unsigned char *source;
 {
   int temp = SIGN_EXTEND_CHAR (*(source + 1));
+
   *dest = *source & 0377;
   *dest += temp << 8;
 }
 
-#ifndef EXTRACT_MACROS /* To debug the macros.  */
+#ifndef EXTRACT_MACROS          /* To debug the macros.  */
 #undef EXTRACT_NUMBER
 #define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
 #endif /* not EXTRACT_MACROS */
@@ -608,10 +607,9 @@ extract_number (dest, source)
 #ifdef DEBUG
 static void extract_number_and_incr _RE_ARGS ((int *destination,
                                                unsigned char **source));
-static void
-extract_number_and_incr (destination, source)
-    int *destination;
-    unsigned char **source;
+static void extract_number_and_incr (destination, source)
+     int *destination;
+     unsigned char **source;
 {
   extract_number (destination, *source);
   *source += 2;
@@ -654,31 +652,26 @@ static int debug = 0;
 
 /* Print the fastmap in human-readable form.  */
 
-void
-print_fastmap (fastmap)
-    char *fastmap;
+void print_fastmap (fastmap)
+     char *fastmap;
 {
   unsigned was_a_range = 0;
   unsigned i = 0;
 
-  while (i < (1 << BYTEWIDTH))
-    {
-      if (fastmap[i++])
-        {
-          was_a_range = 0;
-          putchar (i - 1);
-          while (i < (1 << BYTEWIDTH)  &&  fastmap[i])
-            {
-              was_a_range = 1;
-              i++;
-            }
-          if (was_a_range)
-            {
-              printf ("-");
-              putchar (i - 1);
-            }
-        }
+  while (i < (1 << BYTEWIDTH)) {
+    if (fastmap[i++]) {
+      was_a_range = 0;
+      putchar (i - 1);
+      while (i < (1 << BYTEWIDTH) && fastmap[i]) {
+        was_a_range = 1;
+        i++;
+      }
+      if (was_a_range) {
+        printf ("-");
+        putchar (i - 1);
+      }
     }
+  }
   putchar ('\n');
 }
 
@@ -686,244 +679,234 @@ print_fastmap (fastmap)
 /* Print a compiled pattern string in human-readable form, starting at
    the START pointer into it and ending just before the pointer END.  */
 
-void
-print_partial_compiled_pattern (start, end)
-    unsigned char *start;
-    unsigned char *end;
+void print_partial_compiled_pattern (start, end)
+     unsigned char *start;
+     unsigned char *end;
 {
   int mcnt, mcnt2;
   unsigned char *p1;
   unsigned char *p = start;
   unsigned char *pend = end;
 
-  if (start == NULL)
-    {
-      printf ("(null)\n");
-      return;
-    }
+  if (start == NULL) {
+    printf ("(null)\n");
+    return;
+  }
 
   /* Loop over pattern commands.  */
-  while (p < pend)
-    {
-      printf ("%d:\t", p - start);
+  while (p < pend) {
+    printf ("%d:\t", p - start);
 
-      switch ((re_opcode_t) *p++)
-        {
-        case no_op:
-          printf ("/no_op");
-          break;
+    switch ((re_opcode_t) * p++) {
+    case no_op:
+      printf ("/no_op");
+      break;
 
-        case exactn:
-          mcnt = *p++;
-          printf ("/exactn/%d", mcnt);
-          do
-            {
-              putchar ('/');
-              putchar (*p++);
-            }
-          while (--mcnt);
-          break;
+    case exactn:
+      mcnt = *p++;
+      printf ("/exactn/%d", mcnt);
+      do {
+        putchar ('/');
+        putchar (*p++);
+      }
+      while (--mcnt);
+      break;
 
-        case start_memory:
-          mcnt = *p++;
-          printf ("/start_memory/%d/%d", mcnt, *p++);
-          break;
+    case start_memory:
+      mcnt = *p++;
+      printf ("/start_memory/%d/%d", mcnt, *p++);
+      break;
 
-        case stop_memory:
-          mcnt = *p++;
-          printf ("/stop_memory/%d/%d", mcnt, *p++);
-          break;
+    case stop_memory:
+      mcnt = *p++;
+      printf ("/stop_memory/%d/%d", mcnt, *p++);
+      break;
 
-        case duplicate:
-          printf ("/duplicate/%d", *p++);
-          break;
+    case duplicate:
+      printf ("/duplicate/%d", *p++);
+      break;
 
-        case anychar:
-          printf ("/anychar");
-          break;
+    case anychar:
+      printf ("/anychar");
+      break;
 
-        case charset:
-        case charset_not:
-          {
-            register int c, last = -100;
-            register int in_range = 0;
-
-            printf ("/charset [%s",
-                    (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
-
-            assert (p + *p < pend);
-
-            for (c = 0; c < 256; c++)
-              if (c / 8 < *p
-                  && (p[1 + (c/8)] & (1 << (c % 8))))
-                {
-                  /* Are we starting a range?  */
-                  if (last + 1 == c && ! in_range)
-                    {
-                      putchar ('-');
-                      in_range = 1;
-                    }
-                  /* Have we broken a range?  */
-                  else if (last + 1 != c && in_range)
-              {
-                      putchar (last);
-                      in_range = 0;
-                    }
-
-                  if (! in_range)
-                    putchar (c);
-
-                  last = c;
-              }
+    case charset:
+    case charset_not:
+      {
+        register int c, last = -100;
+        register int in_range = 0;
 
-            if (in_range)
+        printf ("/charset [%s",
+                (re_opcode_t) * (p - 1) == charset_not ? "^" : "");
+
+        assert (p + *p < pend);
+
+        for (c = 0; c < 256; c++)
+          if (c / 8 < *p && (p[1 + (c / 8)] & (1 << (c % 8)))) {
+            /* Are we starting a range?  */
+            if (last + 1 == c && !in_range) {
+              putchar ('-');
+              in_range = 1;
+            }
+            /* Have we broken a range?  */
+            else if (last + 1 != c && in_range) {
               putchar (last);
+              in_range = 0;
+            }
 
-            putchar (']');
+            if (!in_range)
+              putchar (c);
 
-            p += 1 + *p;
+            last = c;
           }
-          break;
 
-        case begline:
-          printf ("/begline");
-          break;
+        if (in_range)
+          putchar (last);
 
-        case endline:
-          printf ("/endline");
-          break;
+        putchar (']');
 
-        case on_failure_jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/on_failure_jump to %d", p + mcnt - start);
-          break;
+        p += 1 + *p;
+      }
+      break;
 
-        case on_failure_keep_string_jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
-          break;
+    case begline:
+      printf ("/begline");
+      break;
 
-        case dummy_failure_jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/dummy_failure_jump to %d", p + mcnt - start);
-          break;
+    case endline:
+      printf ("/endline");
+      break;
 
-        case push_dummy_failure:
-          printf ("/push_dummy_failure");
-          break;
+    case on_failure_jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/on_failure_jump to %d", p + mcnt - start);
+      break;
 
-        case maybe_pop_jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/maybe_pop_jump to %d", p + mcnt - start);
-          break;
+    case on_failure_keep_string_jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
+      break;
 
-        case pop_failure_jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/pop_failure_jump to %d", p + mcnt - start);
-          break;
+    case dummy_failure_jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/dummy_failure_jump to %d", p + mcnt - start);
+      break;
 
-        case jump_past_alt:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/jump_past_alt to %d", p + mcnt - start);
-          break;
+    case push_dummy_failure:
+      printf ("/push_dummy_failure");
+      break;
 
-        case jump:
-          extract_number_and_incr (&mcnt, &p);
-            printf ("/jump to %d", p + mcnt - start);
-          break;
+    case maybe_pop_jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/maybe_pop_jump to %d", p + mcnt - start);
+      break;
 
-        case succeed_n:
-          extract_number_and_incr (&mcnt, &p);
-          p1 = p + mcnt;
-          extract_number_and_incr (&mcnt2, &p);
-          printf ("/succeed_n to %d, %d times", p1 - start, mcnt2);
-          break;
+    case pop_failure_jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/pop_failure_jump to %d", p + mcnt - start);
+      break;
 
-        case jump_n:
-          extract_number_and_incr (&mcnt, &p);
-          p1 = p + mcnt;
-          extract_number_and_incr (&mcnt2, &p);
-          printf ("/jump_n to %d, %d times", p1 - start, mcnt2);
-          break;
+    case jump_past_alt:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/jump_past_alt to %d", p + mcnt - start);
+      break;
 
-        case set_number_at:
-          extract_number_and_incr (&mcnt, &p);
-          p1 = p + mcnt;
-          extract_number_and_incr (&mcnt2, &p);
-          printf ("/set_number_at location %d to %d", p1 - start, mcnt2);
-          break;
+    case jump:
+      extract_number_and_incr (&mcnt, &p);
+      printf ("/jump to %d", p + mcnt - start);
+      break;
 
-        case wordbound:
-          printf ("/wordbound");
-          break;
+    case succeed_n:
+      extract_number_and_incr (&mcnt, &p);
+      p1 = p + mcnt;
+      extract_number_and_incr (&mcnt2, &p);
+      printf ("/succeed_n to %d, %d times", p1 - start, mcnt2);
+      break;
 
-        case notwordbound:
-          printf ("/notwordbound");
-          break;
+    case jump_n:
+      extract_number_and_incr (&mcnt, &p);
+      p1 = p + mcnt;
+      extract_number_and_incr (&mcnt2, &p);
+      printf ("/jump_n to %d, %d times", p1 - start, mcnt2);
+      break;
 
-        case wordbeg:
-          printf ("/wordbeg");
-          break;
+    case set_number_at:
+      extract_number_and_incr (&mcnt, &p);
+      p1 = p + mcnt;
+      extract_number_and_incr (&mcnt2, &p);
+      printf ("/set_number_at location %d to %d", p1 - start, mcnt2);
+      break;
+
+    case wordbound:
+      printf ("/wordbound");
+      break;
+
+    case notwordbound:
+      printf ("/notwordbound");
+      break;
 
-        case wordend:
-          printf ("/wordend");
+    case wordbeg:
+      printf ("/wordbeg");
+      break;
+
+    case wordend:
+      printf ("/wordend");
 
 #ifdef emacs
-        case before_dot:
-          printf ("/before_dot");
-          break;
+    case before_dot:
+      printf ("/before_dot");
+      break;
 
-        case at_dot:
-          printf ("/at_dot");
-          break;
+    case at_dot:
+      printf ("/at_dot");
+      break;
 
-        case after_dot:
-          printf ("/after_dot");
-          break;
+    case after_dot:
+      printf ("/after_dot");
+      break;
 
-        case syntaxspec:
-          printf ("/syntaxspec");
-          mcnt = *p++;
-          printf ("/%d", mcnt);
-          break;
+    case syntaxspec:
+      printf ("/syntaxspec");
+      mcnt = *p++;
+      printf ("/%d", mcnt);
+      break;
 
-        case notsyntaxspec:
-          printf ("/notsyntaxspec");
-          mcnt = *p++;
-          printf ("/%d", mcnt);
-          break;
+    case notsyntaxspec:
+      printf ("/notsyntaxspec");
+      mcnt = *p++;
+      printf ("/%d", mcnt);
+      break;
 #endif /* emacs */
 
-        case wordchar:
-          printf ("/wordchar");
-          break;
-
-        case notwordchar:
-          printf ("/notwordchar");
-          break;
+    case wordchar:
+      printf ("/wordchar");
+      break;
 
-        case begbuf:
-          printf ("/begbuf");
-          break;
+    case notwordchar:
+      printf ("/notwordchar");
+      break;
 
-        case endbuf:
-          printf ("/endbuf");
-          break;
+    case begbuf:
+      printf ("/begbuf");
+      break;
 
-        default:
-          printf ("?%d", *(p-1));
-        }
+    case endbuf:
+      printf ("/endbuf");
+      break;
 
-      putchar ('\n');
+    default:
+      printf ("?%d", *(p - 1));
     }
 
+    putchar ('\n');
+  }
+
   printf ("%d:\tend of pattern.\n", p - start);
 }
 
 
-void
-print_compiled_pattern (bufp)
-    struct re_pattern_buffer *bufp;
+void print_compiled_pattern (bufp)
+     struct re_pattern_buffer *bufp;
 {
   unsigned char *buffer = bufp->buffer;
 
@@ -931,11 +914,10 @@ print_compiled_pattern (bufp)
   printf ("%ld bytes used/%ld bytes allocated.\n",
           bufp->used, bufp->allocated);
 
-  if (bufp->fastmap_accurate && bufp->fastmap)
-    {
-      printf ("fastmap: ");
-      print_fastmap (bufp->fastmap);
-    }
+  if (bufp->fastmap_accurate && bufp->fastmap) {
+    printf ("fastmap: ");
+    print_fastmap (bufp->fastmap);
+  }
 
   printf ("re_nsub: %d\t", bufp->re_nsub);
   printf ("regs_alloc: %d\t", bufp->regs_allocated);
@@ -949,35 +931,31 @@ print_compiled_pattern (bufp)
 }
 
 
-void
-print_double_string (where, string1, size1, string2, size2)
-    const char *where;
-    const char *string1;
-    const char *string2;
-    int size1;
-    int size2;
+void print_double_string (where, string1, size1, string2, size2)
+     const char *where;
+     const char *string1;
+     const char *string2;
+     int size1;
+     int size2;
 {
   int this_char;
 
   if (where == NULL)
     printf ("(null)");
-  else
-    {
-      if (FIRST_STRING_P (where))
-        {
-          for (this_char = where - string1; this_char < size1; this_char++)
-            putchar (string1[this_char]);
-
-          where = string2;
-        }
+  else {
+    if (FIRST_STRING_P (where)) {
+      for (this_char = where - string1; this_char < size1; this_char++)
+        putchar (string1[this_char]);
 
-      for (this_char = where - string2; this_char < size2; this_char++)
-        putchar (string2[this_char]);
+      where = string2;
     }
+
+    for (this_char = where - string2; this_char < size2; this_char++)
+      putchar (string2[this_char]);
+  }
 }
 
-void
-printchar (c)
+void printchar (c)
      int c;
 {
   putc (c, stderr);
@@ -1013,9 +991,8 @@ reg_syntax_t re_syntax_options;
    The argument SYNTAX is a bit mask comprised of the various bits
    defined in regex.h.  We return the old syntax.  */
 
-reg_syntax_t
-re_set_syntax (syntax)
-    reg_syntax_t syntax;
+reg_syntax_t re_set_syntax (syntax)
+     reg_syntax_t syntax;
 {
   reg_syntax_t ret = re_syntax_options;
 
@@ -1023,7 +1000,7 @@ re_set_syntax (syntax)
 #ifdef DEBUG
   if (syntax & RE_DEBUG)
     debug = 1;
-  else if (debug) /* was on but now is not */
+  else if (debug)               /* was on but now is not */
     debug = 0;
 #endif /* DEBUG */
   return ret;
@@ -1034,26 +1011,25 @@ re_set_syntax (syntax)
    POSIX doesn't require that we do anything for REG_NOERROR,
    but why not be nice?  */
 
-static const char *re_error_msgid[] =
-  {
-    gettext_noop ("Success"),        /* REG_NOERROR */
-    gettext_noop ("No match"),        /* REG_NOMATCH */
-    gettext_noop ("Invalid regular expression"), /* REG_BADPAT */
-    gettext_noop ("Invalid collation character"), /* REG_ECOLLATE */
-    gettext_noop ("Invalid character class name"), /* REG_ECTYPE */
-    gettext_noop ("Trailing backslash"), /* REG_EESCAPE */
-    gettext_noop ("Invalid back reference"), /* REG_ESUBREG */
-    gettext_noop ("Unmatched [ or [^"),        /* REG_EBRACK */
-    gettext_noop ("Unmatched ( or \\("), /* REG_EPAREN */
-    gettext_noop ("Unmatched \\{"), /* REG_EBRACE */
-    gettext_noop ("Invalid content of \\{\\}"), /* REG_BADBR */
-    gettext_noop ("Invalid range end"),        /* REG_ERANGE */
-    gettext_noop ("Memory exhausted"), /* REG_ESPACE */
-    gettext_noop ("Invalid preceding regular expression"), /* REG_BADRPT */
-    gettext_noop ("Premature end of regular expression"), /* REG_EEND */
-    gettext_noop ("Regular expression too big"), /* REG_ESIZE */
-    gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */
-  };
+static const char *re_error_msgid[] = {
+  gettext_noop ("Success"),     /* REG_NOERROR */
+  gettext_noop ("No match"),    /* REG_NOMATCH */
+  gettext_noop ("Invalid regular expression"),  /* REG_BADPAT */
+  gettext_noop ("Invalid collation character"), /* REG_ECOLLATE */
+  gettext_noop ("Invalid character class name"),        /* REG_ECTYPE */
+  gettext_noop ("Trailing backslash"),  /* REG_EESCAPE */
+  gettext_noop ("Invalid back reference"),      /* REG_ESUBREG */
+  gettext_noop ("Unmatched [ or [^"),   /* REG_EBRACK */
+  gettext_noop ("Unmatched ( or \\("),  /* REG_EPAREN */
+  gettext_noop ("Unmatched \\{"),       /* REG_EBRACE */
+  gettext_noop ("Invalid content of \\{\\}"),   /* REG_BADBR */
+  gettext_noop ("Invalid range end"),   /* REG_ERANGE */
+  gettext_noop ("Memory exhausted"),    /* REG_ESPACE */
+  gettext_noop ("Invalid preceding regular expression"),        /* REG_BADRPT */
+  gettext_noop ("Premature end of regular expression"), /* REG_EEND */
+  gettext_noop ("Regular expression too big"),  /* REG_ESIZE */
+  gettext_noop ("Unmatched ) or \\)"),  /* REG_ERPAREN */
+};
 \f
 /* Avoiding alloca during matching, to placate r_alloc.  */
 
@@ -1091,8 +1067,8 @@ static const char *re_error_msgid[] =
 #if (defined (C_ALLOCA) || defined (REGEX_MALLOC)) && defined (emacs)
 #undef MATCH_MAY_ALLOCATE
 #endif
-
 \f
+
 /* Failure stack declarations and macros; both re_compile_fastmap and
    re_match_2 use a failure stack.  These have to be macros because of
    REGEX_ALLOCATE_STACK.  */
@@ -1120,19 +1096,17 @@ long int re_max_failures = 4000;
 long int re_max_failures = 2000;
 #endif
 
-union fail_stack_elt
-{
+union fail_stack_elt {
   unsigned char *pointer;
   long int integer;
 };
 
 typedef union fail_stack_elt fail_stack_elt_t;
 
-typedef struct
-{
+typedef struct {
   fail_stack_elt_t *stack;
   unsigned long int size;
-  unsigned long int avail;                /* Offset of next open position.  */
+  unsigned long int avail;      /* Offset of next open position.  */
 } fail_stack_type;
 
 #else /* not INT_IS_16BIT */
@@ -1145,19 +1119,17 @@ int re_max_failures = 20000;
 int re_max_failures = 2000;
 #endif
 
-union fail_stack_elt
-{
+union fail_stack_elt {
   unsigned char *pointer;
   int integer;
 };
 
 typedef union fail_stack_elt fail_stack_elt_t;
 
-typedef struct
-{
+typedef struct {
   fail_stack_elt_t *stack;
   unsigned size;
-  unsigned avail;                        /* Offset of next open position.  */
+  unsigned avail;               /* Offset of next open position.  */
 } fail_stack_type;
 
 #endif /* INT_IS_16BIT */
@@ -1352,7 +1324,7 @@ typedef struct
 
 /* Individual items aside from the registers.  */
 #ifdef DEBUG
-#define NUM_NONREG_ITEMS 5 /* Includes failure point id.  */
+#define NUM_NONREG_ITEMS 5      /* Includes failure point id.  */
 #else
 #define NUM_NONREG_ITEMS 4
 #endif
@@ -1453,10 +1425,10 @@ typedef struct
                                                                         \
   set_regs_matched_done = 0;                                                \
   DEBUG_STATEMENT (nfailure_points_popped++);                                \
-} /* POP_FAILURE_POINT */
+}                               /* POP_FAILURE_POINT */
+\f
 
 
-\f
 /* Structure for per-register (a.k.a. per-group) information.
    Other register information, such as the
    starting and ending positions (which are addresses), and the list of
@@ -1471,18 +1443,16 @@ typedef struct
 
 /* Declarations and macros for re_match_2.  */
 
-typedef union
-{
+typedef union {
   fail_stack_elt_t word;
-  struct
-  {
-      /* This field is one if this group can match the empty string,
-         zero if not.  If not yet determined,  `MATCH_NULL_UNSET_VALUE'.  */
+  struct {
+    /* This field is one if this group can match the empty string,
+       zero if not.  If not yet determined,  `MATCH_NULL_UNSET_VALUE'.  */
 #define MATCH_NULL_UNSET_VALUE 3
-    unsigned match_null_string_p : 2;
-    unsigned is_active : 1;
-    unsigned matched_something : 1;
-    unsigned ever_matched_something : 1;
+    unsigned match_null_string_p:2;
+    unsigned is_active:1;
+    unsigned matched_something:1;
+    unsigned ever_matched_something:1;
   } bits;
 } register_info_type;
 
@@ -1514,30 +1484,31 @@ typedef union
 
 /* Registers are set to a sentinel when they haven't yet matched.  */
 static char reg_unset_dummy;
+
 #define REG_UNSET_VALUE (&reg_unset_dummy)
 #define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
 \f
 /* Subroutine declarations and macros for regex_compile.  */
 
-static reg_errcode_t regex_compile _RE_ARGS ((const char *pattern, size_t size,
-                                              reg_syntax_t syntax,
-                                              struct re_pattern_buffer *bufp));
-static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg));
-static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
-                                 int arg1, int arg2));
-static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
-                                  int arg, unsigned char *end));
-static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
-                                  int arg1, int arg2, unsigned char *end));
-static boolean at_begline_loc_p _RE_ARGS ((const char *pattern, const char *p,
-                                           reg_syntax_t syntax));
-static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend,
-                                           reg_syntax_t syntax));
-static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr,
-                                              const char *pend,
-                                              char *translate,
-                                              reg_syntax_t syntax,
-                                              unsigned char *b));
+static reg_errcode_t regex_compile
+_RE_ARGS ((const char *pattern, size_t size, reg_syntax_t syntax,
+           struct re_pattern_buffer * bufp));
+static void store_op1
+_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg));
+static void store_op2
+_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg1, int arg2));
+static void insert_op1
+_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg, unsigned char *end));
+static void insert_op2
+_RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg1, int arg2,
+           unsigned char *end));
+static boolean at_begline_loc_p
+_RE_ARGS ((const char *pattern, const char *p, reg_syntax_t syntax));
+static boolean at_endline_loc_p
+_RE_ARGS ((const char *p, const char *pend, reg_syntax_t syntax));
+static reg_errcode_t compile_range
+_RE_ARGS ((const char **p_ptr, const char *pend, char *translate,
+           reg_syntax_t syntax, unsigned char *b));
 
 /* Fetch the next character in the uncompiled pattern---translating it
    if necessary.  Also cast from a signed character in the constant
@@ -1693,8 +1664,7 @@ typedef unsigned regnum_t;
 /* int may be not enough when sizeof(int) == 2.  */
 typedef long pattern_offset_t;
 
-typedef struct
-{
+typedef struct {
   pattern_offset_t begalt_offset;
   pattern_offset_t fixup_alt_jump;
   pattern_offset_t inner_group_offset;
@@ -1703,11 +1673,10 @@ typedef struct
 } compile_stack_elt_t;
 
 
-typedef struct
-{
+typedef struct {
   compile_stack_elt_t *stack;
   unsigned size;
-  unsigned avail;                        /* Offset of next open position.  */
+  unsigned avail;               /* Offset of next open position.  */
 } compile_stack_type;
 
 
@@ -1756,7 +1725,7 @@ typedef struct
 
 # define IS_CHAR_CLASS(string) wctype (string)
 #else
-# define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */
+# define CHAR_CLASS_MAX_LENGTH  6       /* Namely, `xdigit'.  */
 
 # define IS_CHAR_CLASS(string)                                                \
    (STREQ (string, "alpha") || STREQ (string, "upper")                        \
@@ -1783,8 +1752,8 @@ static fail_stack_type fail_stack;
    but never make them smaller.  */
 static int regs_allocated_size;
 
-static const char **     regstart, **     regend;
-static const char ** old_regstart, ** old_regend;
+static const char **regstart, **regend;
+static const char **old_regstart, **old_regend;
 static const char **best_regstart, **best_regend;
 static register_info_type *reg_info;
 static const char **reg_dummy;
@@ -1793,24 +1762,24 @@ static register_info_type *reg_info_dummy;
 /* Make the register vectors big enough for NUM_REGS registers,
    but don't make them smaller.  */
 
-static
-regex_grow_registers (num_regs)
+static regex_grow_registers (num_regs)
      int num_regs;
 {
-  if (num_regs > regs_allocated_size)
-    {
-      RETALLOC_IF (regstart,         num_regs, const char *);
-      RETALLOC_IF (regend,         num_regs, const char *);
-      RETALLOC_IF (old_regstart, num_regs, const char *);
-      RETALLOC_IF (old_regend,         num_regs, const char *);
-      RETALLOC_IF (best_regstart, num_regs, const char *);
-      RETALLOC_IF (best_regend,         num_regs, const char *);
-      RETALLOC_IF (reg_info,         num_regs, register_info_type);
-      RETALLOC_IF (reg_dummy,         num_regs, const char *);
-      RETALLOC_IF (reg_info_dummy, num_regs, register_info_type);
-
-      regs_allocated_size = num_regs;
-    }
+  if (num_regs > regs_allocated_size) {
+    RETALLOC_IF (regstart, num_regs, const char *);
+    RETALLOC_IF (regend, num_regs, const char *);
+    RETALLOC_IF (old_regstart, num_regs, const char *);
+    RETALLOC_IF (old_regend, num_regs, const char *);
+    RETALLOC_IF (best_regstart, num_regs, const char *);
+    RETALLOC_IF (best_regend, num_regs, const char *);
+
+    RETALLOC_IF (reg_info, num_regs, register_info_type);
+    RETALLOC_IF (reg_dummy, num_regs, const char *);
+
+    RETALLOC_IF (reg_info_dummy, num_regs, register_info_type);
+
+    regs_allocated_size = num_regs;
+  }
 }
 
 #endif /* not MATCH_MAY_ALLOCATE */
@@ -1839,31 +1808,42 @@ static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type
 
 /* Return, freeing storage we allocated.  */
 #define FREE_STACK_RETURN(value)                \
-  return (free (compile_stack.stack), value)                /* __MEM_CHECKED__ */
+  return (free (compile_stack.stack), value)    /* __MEM_CHECKED__ */
 
 #ifndef HAVE_ISCTYPE
-static int isctype(char c, int desc)
+static int isctype (char c, int desc)
 {
   switch (desc) {
-    case MUTT_ALNUM: return ISALNUM(c);
-    case MUTT_ALPHA: return ISALPHA(c);
-    case MUTT_BLANK: return ISBLANK(c);
-    case MUTT_CNTRL: return ISCNTRL(c);
-    case MUTT_DIGIT: return ISDIGIT(c);
-    case MUTT_GRAPH: return ISGRAPH(c);
-    case MUTT_LOWER: return ISLOWER(c);
-    case MUTT_PRINT: return ISPRINT(c);
-    case MUTT_PUNCT: return ISPUNCT(c);
-    case MUTT_SPACE: return ISSPACE(c);
-    case MUTT_UPPER: return ISUPPER(c);
-    case MUTT_XDIGIT: return ISXDIGIT(c);
+  case MUTT_ALNUM:
+    return ISALNUM (c);
+  case MUTT_ALPHA:
+    return ISALPHA (c);
+  case MUTT_BLANK:
+    return ISBLANK (c);
+  case MUTT_CNTRL:
+    return ISCNTRL (c);
+  case MUTT_DIGIT:
+    return ISDIGIT (c);
+  case MUTT_GRAPH:
+    return ISGRAPH (c);
+  case MUTT_LOWER:
+    return ISLOWER (c);
+  case MUTT_PRINT:
+    return ISPRINT (c);
+  case MUTT_PUNCT:
+    return ISPUNCT (c);
+  case MUTT_SPACE:
+    return ISSPACE (c);
+  case MUTT_UPPER:
+    return ISUPPER (c);
+  case MUTT_XDIGIT:
+    return ISXDIGIT (c);
   }
-  return 0; /* false */
+  return 0;                     /* false */
 }
 #endif
 
-static reg_errcode_t
-regex_compile (pattern, size, syntax, bufp)
+static reg_errcode_t regex_compile (pattern, size, syntax, bufp)
      const char *pattern;
      size_t size;
      reg_syntax_t syntax;
@@ -1920,14 +1900,13 @@ regex_compile (pattern, size, syntax, bufp)
 
 #ifdef DEBUG
   DEBUG_PRINT1 ("\nCompiling pattern: ");
-  if (debug)
-    {
-      unsigned debug_count;
+  if (debug) {
+    unsigned debug_count;
 
-      for (debug_count = 0; debug_count < size; debug_count++)
-        putchar (pattern[debug_count]);
-      putchar ('\n');
-    }
+    for (debug_count = 0; debug_count < size; debug_count++)
+      putchar (pattern[debug_count]);
+    putchar ('\n');
+  }
 #endif /* DEBUG */
 
   /* Initialize the compile stack.  */
@@ -1953,939 +1932,911 @@ regex_compile (pattern, size, syntax, bufp)
 
 #if !defined (emacs) && !defined (SYNTAX_TABLE)
   /* Initialize the syntax table.  */
-   init_syntax_once ();
+  init_syntax_once ();
 #endif
 
-  if (bufp->allocated == 0)
-    {
-      if (bufp->buffer)
-        { /* If zero allocated, but buffer is non-null, try to realloc
-             enough space.  This loses if buffer's address is bogus, but
-             that is the user's responsibility.  */
-          RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
-        }
-      else
-        { /* Caller did not allocate a buffer.  Do it for them.  */
-          bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
-        }
-      if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE);
-
-      bufp->allocated = INIT_BUF_SIZE;
+  if (bufp->allocated == 0) {
+    if (bufp->buffer) {         /* If zero allocated, but buffer is non-null, try to realloc
+                                   enough space.  This loses if buffer's address is bogus, but
+                                   that is the user's responsibility.  */
+      RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
+    }
+    else {                      /* Caller did not allocate a buffer.  Do it for them.  */
+      bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
     }
+    if (!bufp->buffer)
+      FREE_STACK_RETURN (REG_ESPACE);
+
+    bufp->allocated = INIT_BUF_SIZE;
+  }
 
   begalt = b = bufp->buffer;
 
   /* Loop through the uncompiled pattern until we're at the end.  */
-  while (p != pend)
-    {
-      PATFETCH (c);
-
-      switch (c)
-        {
-        case '^':
-          {
-            if (   /* If at start of pattern, it's an operator.  */
-                   p == pattern + 1
-                   /* If context independent, it's an operator.  */
-                || syntax & RE_CONTEXT_INDEP_ANCHORS
-                   /* Otherwise, depends on what's come before.  */
-                || at_begline_loc_p (pattern, p, syntax))
-              BUF_PUSH (begline);
-            else
-              goto normal_char;
-          }
-          break;
+  while (p != pend) {
+    PATFETCH (c);
 
+    switch (c) {
+    case '^':
+      {
+        if (                    /* If at start of pattern, it's an operator.  */
+             p == pattern + 1
+             /* If context independent, it's an operator.  */
+             || syntax & RE_CONTEXT_INDEP_ANCHORS
+             /* Otherwise, depends on what's come before.  */
+             || at_begline_loc_p (pattern, p, syntax))
+          BUF_PUSH (begline);
+        else
+          goto normal_char;
+      }
+      break;
 
-        case '$':
-          {
-            if (   /* If at end of pattern, it's an operator.  */
-                   p == pend
-                   /* If context independent, it's an operator.  */
-                || syntax & RE_CONTEXT_INDEP_ANCHORS
-                   /* Otherwise, depends on what's next.  */
-                || at_endline_loc_p (p, pend, syntax))
-               BUF_PUSH (endline);
-             else
-               goto normal_char;
-           }
-           break;
-
-
-        case '+':
-        case '?':
-          if ((syntax & RE_BK_PLUS_QM)
-              || (syntax & RE_LIMITED_OPS))
-            goto normal_char;
-        handle_plus:
-        case '*':
-          /* If there is no previous pattern... */
-          if (!laststart)
-            {
-              if (syntax & RE_CONTEXT_INVALID_OPS)
-                FREE_STACK_RETURN (REG_BADRPT);
-              else if (!(syntax & RE_CONTEXT_INDEP_OPS))
-                goto normal_char;
-            }
 
-          {
-            /* Are we optimizing this jump?  */
-            boolean keep_string_p = false;
-
-            /* 1 means zero (many) matches is allowed.  */
-            char zero_times_ok = 0, many_times_ok = 0;
-
-            /* If there is a sequence of repetition chars, collapse it
-               down to just one (the right one).  We can't combine
-               interval operators with these because of, e.g., `a{2}*',
-               which should only match an even number of `a's.  */
-
-            for (;;)
-              {
-                zero_times_ok |= c != '+';
-                many_times_ok |= c != '?';
-
-                if (p == pend)
-                  break;
-
-                PATFETCH (c);
-
-                if (c == '*'
-                    || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
-                  ;
-
-                else if (syntax & RE_BK_PLUS_QM  &&  c == '\\')
-                  {
-                    if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
-
-                    PATFETCH (c1);
-                    if (!(c1 == '+' || c1 == '?'))
-                      {
-                        PATUNFETCH;
-                        PATUNFETCH;
-                        break;
-                      }
-
-                    c = c1;
-                  }
-                else
-                  {
-                    PATUNFETCH;
-                    break;
-                  }
-
-                /* If we get here, we found another repeat character.  */
-               }
-
-            /* Star, etc. applied to an empty pattern is equivalent
-               to an empty pattern.  */
-            if (!laststart)
-              break;
+    case '$':
+      {
+        if (                    /* If at end of pattern, it's an operator.  */
+             p == pend
+             /* If context independent, it's an operator.  */
+             || syntax & RE_CONTEXT_INDEP_ANCHORS
+             /* Otherwise, depends on what's next.  */
+             || at_endline_loc_p (p, pend, syntax))
+          BUF_PUSH (endline);
+        else
+          goto normal_char;
+      }
+      break;
 
-            /* Now we know whether or not zero matches is allowed
-               and also whether or not two or more matches is allowed.  */
-            if (many_times_ok)
-              { /* More than one repetition is allowed, so put in at the
-                   end a backward relative jump from `b' to before the next
-                   jump we're going to put in below (which jumps from
-                   laststart to after this jump).
-
-                   But if we are at the `*' in the exact sequence `.*\n',
-                   insert an unconditional jump backwards to the .,
-                   instead of the beginning of the loop.  This way we only
-                   push a failure point once, instead of every time
-                   through the loop.  */
-                assert (p - 1 > pattern);
-
-                /* Allocate the space for the jump.  */
-                GET_BUFFER_SPACE (3);
-
-                /* We know we are not at the first character of the pattern,
-                   because laststart was nonzero.  And we've already
-                   incremented `p', by the way, to be the character after
-                   the `*'.  Do we have to do something analogous here
-                   for null bytes, because of RE_DOT_NOT_NULL?  */
-                if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
-                    && zero_times_ok
-                    && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
-                    && !(syntax & RE_DOT_NEWLINE))
-                  { /* We have .*\n.  */
-                    STORE_JUMP (jump, b, laststart);
-                    keep_string_p = true;
-                  }
-                else
-                  /* Anything else.  */
-                  STORE_JUMP (maybe_pop_jump, b, laststart - 3);
-
-                /* We've added more stuff to the buffer.  */
-                b += 3;
-              }
 
-            /* On failure, jump from laststart to b + 3, which will be the
-               end of the buffer after this jump is inserted.  */
-            GET_BUFFER_SPACE (3);
-            INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
-                                       : on_failure_jump,
-                         laststart, b + 3);
-            pending_exact = 0;
-            b += 3;
+    case '+':
+    case '?':
+      if ((syntax & RE_BK_PLUS_QM)
+          || (syntax & RE_LIMITED_OPS))
+        goto normal_char;
+    handle_plus:
+    case '*':
+      /* If there is no previous pattern... */
+      if (!laststart) {
+        if (syntax & RE_CONTEXT_INVALID_OPS)
+          FREE_STACK_RETURN (REG_BADRPT);
+        else if (!(syntax & RE_CONTEXT_INDEP_OPS))
+          goto normal_char;
+      }
 
-            if (!zero_times_ok)
-              {
-                /* At least one repetition is required, so insert a
-                   `dummy_failure_jump' before the initial
-                   `on_failure_jump' instruction of the loop. This
-                   effects a skip over that instruction the first time
-                   we hit that loop.  */
-                GET_BUFFER_SPACE (3);
-                INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6);
-                b += 3;
-              }
-            }
-          break;
+      {
+        /* Are we optimizing this jump?  */
+        boolean keep_string_p = false;
 
+        /* 1 means zero (many) matches is allowed.  */
+        char zero_times_ok = 0, many_times_ok = 0;
 
-        case '.':
-          laststart = b;
-          BUF_PUSH (anychar);
-          break;
+        /* If there is a sequence of repetition chars, collapse it
+           down to just one (the right one).  We can't combine
+           interval operators with these because of, e.g., `a{2}*',
+           which should only match an even number of `a's.  */
 
+        for (;;) {
+          zero_times_ok |= c != '+';
+          many_times_ok |= c != '?';
 
-        case '[':
-          {
-            boolean had_char_class = false;
-
-            if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
-
-            /* Ensure that we have enough space to push a charset: the
-               opcode, the length count, and the bitset; 34 bytes in all.  */
-            GET_BUFFER_SPACE (34);
-
-            laststart = b;
-
-            /* We test `*p == '^' twice, instead of using an if
-               statement, so we only need one BUF_PUSH.  */
-            BUF_PUSH (*p == '^' ? charset_not : charset);
-            if (*p == '^')
-              p++;
-
-            /* Remember the first position in the bracket expression.  */
-            p1 = p;
-
-            /* Push the number of bytes in the bitmap.  */
-            BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
-
-            /* Clear the whole map.  */
-            bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
-
-            /* charset_not matches newline according to a syntax bit.  */
-            if ((re_opcode_t) b[-2] == charset_not
-                && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
-              SET_LIST_BIT ('\n');
-
-            /* Read in characters and ranges, setting map bits.  */
-            for (;;)
-              {
-                if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
-
-                PATFETCH (c);
-
-                /* \ might escape characters inside [...] and [^...].  */
-                if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
-                  {
-                    if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
-
-                    PATFETCH (c1);
-                    SET_LIST_BIT (c1);
-                    continue;
-                  }
-
-                /* Could be the end of the bracket expression.  If it's
-                   not (i.e., when the bracket expression is `[]' so
-                   far), the ']' character bit gets set way below.  */
-                if (c == ']' && p != p1 + 1)
-                  break;
-
-                /* Look ahead to see if it's a range when the last thing
-                   was a character class.  */
-                if (had_char_class && c == '-' && *p != ']')
-                  FREE_STACK_RETURN (REG_ERANGE);
-
-                /* Look ahead to see if it's a range when the last thing
-                   was a character: if this is a hyphen not at the
-                   beginning or the end of a list, then it's the range
-                   operator.  */
-                if (c == '-'
-                    && !(p - 2 >= pattern && p[-2] == '[')
-                    && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
-                    && *p != ']')
-                  {
-                    reg_errcode_t ret
-                      = compile_range (&p, pend, translate, syntax, b);
-                    if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
-                  }
-
-                else if (p[0] == '-' && p[1] != ']')
-                  { /* This handles ranges made up of characters only.  */
-                    reg_errcode_t ret;
-
-                    /* Move past the `-'.  */
-                    PATFETCH (c1);
-
-                    ret = compile_range (&p, pend, translate, syntax, b);
-                    if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
-                  }
-
-                /* See if we're at the beginning of a possible character
-                   class.  */
-
-                else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
-                  { /* Leave room for the null.  */
-                    char str[CHAR_CLASS_MAX_LENGTH + 1];
-
-                    PATFETCH (c);
-                    c1 = 0;
-
-                    /* If pattern is `[[:'.  */
-                    if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
-
-                    for (;;)
-                      {
-                        PATFETCH (c);
-                        if (c == ':' || c == ']' || p == pend
-                            || c1 == CHAR_CLASS_MAX_LENGTH)
-                          break;
-                        str[c1++] = c;
-                      }
-                    str[c1] = '\0';
-
-                    /* If isn't a word bracketed by `[:' and:`]':
-                       undo the ending character, the letters, and leave
-                       the leading `:' and `[' (but set bits for them).  */
-                    if (c == ':' && *p == ']')
-                      {
-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
-                        boolean is_lower = STREQ (str, "lower");
-                        boolean is_upper = STREQ (str, "upper");
-                        int wt;
-                        int ch;
+          if (p == pend)
+            break;
 
-                        wt = ctype (str);
-                        if (wt == 0)
-                          FREE_STACK_RETURN (REG_ECTYPE);
+          PATFETCH (c);
 
-                        /* Throw away the ] at the end of the character
-                           class.  */
-                        PATFETCH (c);
+          if (c == '*'
+              || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')));
 
-                        if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+          else if (syntax & RE_BK_PLUS_QM && c == '\\') {
+            if (p == pend)
+              FREE_STACK_RETURN (REG_EESCAPE);
 
-                        for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
-                          {
-                            if (isctype (ch, wt))
-                              SET_LIST_BIT (ch);
+            PATFETCH (c1);
+            if (!(c1 == '+' || c1 == '?')) {
+              PATUNFETCH;
+              PATUNFETCH;
+              break;
+            }
 
-                            if (translate && (is_upper || is_lower)
-                                && (ISUPPER (ch) || ISLOWER (ch)))
-                              SET_LIST_BIT (ch);
-                          }
+            c = c1;
+          }
+          else {
+            PATUNFETCH;
+            break;
+          }
 
-                        had_char_class = true;
-#else
-                        int ch;
-                        boolean is_alnum = STREQ (str, "alnum");
-                        boolean is_alpha = STREQ (str, "alpha");
-                        boolean is_blank = STREQ (str, "blank");
-                        boolean is_cntrl = STREQ (str, "cntrl");
-                        boolean is_digit = STREQ (str, "digit");
-                        boolean is_graph = STREQ (str, "graph");
-                        boolean is_lower = STREQ (str, "lower");
-                        boolean is_print = STREQ (str, "print");
-                        boolean is_punct = STREQ (str, "punct");
-                        boolean is_space = STREQ (str, "space");
-                        boolean is_upper = STREQ (str, "upper");
-                        boolean is_xdigit = STREQ (str, "xdigit");
-
-                        if (!IS_CHAR_CLASS (str))
-                          FREE_STACK_RETURN (REG_ECTYPE);
-
-                        /* Throw away the ] at the end of the character
-                           class.  */
-                        PATFETCH (c);
-
-                        if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
-
-                        for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
-                          {
-                            /* This was split into 3 if's to
-                               avoid an arbitrary limit in some compiler.  */
-                            if (   (is_alnum  && ISALNUM (ch))
-                                || (is_alpha  && ISALPHA (ch))
-                                || (is_blank  && ISBLANK (ch))
-                                || (is_cntrl  && ISCNTRL (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   (is_digit  && ISDIGIT (ch))
-                                || (is_graph  && ISGRAPH (ch))
-                                || (is_lower  && ISLOWER (ch))
-                                || (is_print  && ISPRINT (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   (is_punct  && ISPUNCT (ch))
-                                || (is_space  && ISSPACE (ch))
-                                || (is_upper  && ISUPPER (ch))
-                                || (is_xdigit && ISXDIGIT (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   translate && (is_upper || is_lower)
-                                && (ISUPPER (ch) || ISLOWER (ch)))
-                              SET_LIST_BIT (ch);
-                          }
-                        had_char_class = true;
-#endif        /* libc || wctype.h */
-                      }
-                    else
-                      {
-                        c1++;
-                        while (c1--)
-                          PATUNFETCH;
-                        SET_LIST_BIT ('[');
-                        SET_LIST_BIT (':');
-                        had_char_class = false;
-                      }
-                  }
-                else
-                  {
-                    had_char_class = false;
-                    SET_LIST_BIT (c);
-                  }
-              }
+          /* If we get here, we found another repeat character.  */
+        }
 
-            /* Discard any (non)matching list bytes that are all 0 at the
-               end of the map.  Decrease the map-length byte too.  */
-            while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
-              b[-1]--;
-            b += b[-1];
-          }
+        /* Star, etc. applied to an empty pattern is equivalent
+           to an empty pattern.  */
+        if (!laststart)
           break;
 
-
-        case '(':
-          if (syntax & RE_NO_BK_PARENS)
-            goto handle_open;
+        /* Now we know whether or not zero matches is allowed
+           and also whether or not two or more matches is allowed.  */
+        if (many_times_ok) {    /* More than one repetition is allowed, so put in at the
+                                   end a backward relative jump from `b' to before the next
+                                   jump we're going to put in below (which jumps from
+                                   laststart to after this jump).
+
+                                   But if we are at the `*' in the exact sequence `.*\n',
+                                   insert an unconditional jump backwards to the .,
+                                   instead of the beginning of the loop.  This way we only
+                                   push a failure point once, instead of every time
+                                   through the loop.  */
+          assert (p - 1 > pattern);
+
+          /* Allocate the space for the jump.  */
+          GET_BUFFER_SPACE (3);
+
+          /* We know we are not at the first character of the pattern,
+             because laststart was nonzero.  And we've already
+             incremented `p', by the way, to be the character after
+             the `*'.  Do we have to do something analogous here
+             for null bytes, because of RE_DOT_NOT_NULL?  */
+          if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
+              && zero_times_ok
+              && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
+              && !(syntax & RE_DOT_NEWLINE)) {  /* We have .*\n.  */
+            STORE_JUMP (jump, b, laststart);
+            keep_string_p = true;
+          }
           else
-            goto normal_char;
-
+            /* Anything else.  */
+            STORE_JUMP (maybe_pop_jump, b, laststart - 3);
 
-        case ')':
-          if (syntax & RE_NO_BK_PARENS)
-            goto handle_close;
-          else
-            goto normal_char;
+          /* We've added more stuff to the buffer.  */
+          b += 3;
+        }
 
+        /* On failure, jump from laststart to b + 3, which will be the
+           end of the buffer after this jump is inserted.  */
+        GET_BUFFER_SPACE (3);
+        INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
+                     : on_failure_jump, laststart, b + 3);
+        pending_exact = 0;
+        b += 3;
+
+        if (!zero_times_ok) {
+          /* At least one repetition is required, so insert a
+             `dummy_failure_jump' before the initial
+             `on_failure_jump' instruction of the loop. This
+             effects a skip over that instruction the first time
+             we hit that loop.  */
+          GET_BUFFER_SPACE (3);
+          INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6);
+          b += 3;
+        }
+      }
+      break;
 
-        case '\n':
-          if (syntax & RE_NEWLINE_ALT)
-            goto handle_alt;
-          else
-            goto normal_char;
 
+    case '.':
+      laststart = b;
+      BUF_PUSH (anychar);
+      break;
 
-        case '|':
-          if (syntax & RE_NO_BK_VBAR)
-            goto handle_alt;
-          else
-            goto normal_char;
 
+    case '[':
+      {
+        boolean had_char_class = false;
 
-        case '{':
-           if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
-             goto handle_interval;
-           else
-             goto normal_char;
-
-
-        case '\\':
-          if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
-
-          /* Do not translate the character after the \, so that we can
-             distinguish, e.g., \B from \b, even if we normally would
-             translate, e.g., B to b.  */
-          PATFETCH_RAW (c);
-
-          switch (c)
-            {
-            case '(':
-              if (syntax & RE_NO_BK_PARENS)
-                goto normal_backslash;
-
-            handle_open:
-              bufp->re_nsub++;
-              regnum++;
-
-              if (COMPILE_STACK_FULL)
-                {
-                  RETALLOC (compile_stack.stack, compile_stack.size << 1,
-                            compile_stack_elt_t);
-                  if (compile_stack.stack == NULL) return REG_ESPACE;
-
-                  compile_stack.size <<= 1;
-                }
-
-              /* These are the values to restore when we hit end of this
-                 group.  They are all relative offsets, so that if the
-                 whole pattern moves because of realloc, they will still
-                 be valid.  */
-              COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
-              COMPILE_STACK_TOP.fixup_alt_jump
-                = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
-              COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
-              COMPILE_STACK_TOP.regnum = regnum;
-
-              /* We will eventually replace the 0 with the number of
-                 groups inner to this one.  But do not push a
-                 start_memory for groups beyond the last one we can
-                 represent in the compiled pattern.  */
-              if (regnum <= MAX_REGNUM)
-                {
-                  COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
-                  BUF_PUSH_3 (start_memory, regnum, 0);
-                }
-
-              compile_stack.avail++;
-
-              fixup_alt_jump = 0;
-              laststart = 0;
-              begalt = b;
-              /* If we've reached MAX_REGNUM groups, then this open
-                 won't actually generate any code, so we'll have to
-                 clear pending_exact explicitly.  */
-              pending_exact = 0;
-              break;
+        if (p == pend)
+          FREE_STACK_RETURN (REG_EBRACK);
 
+        /* Ensure that we have enough space to push a charset: the
+           opcode, the length count, and the bitset; 34 bytes in all.  */
+        GET_BUFFER_SPACE (34);
 
-            case ')':
-              if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
-
-              if (COMPILE_STACK_EMPTY)
-                if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
-                  goto normal_backslash;
-                else
-                  FREE_STACK_RETURN (REG_ERPAREN);
-
-            handle_close:
-              if (fixup_alt_jump)
-                { /* Push a dummy failure point at the end of the
-                     alternative for a possible future
-                     `pop_failure_jump' to pop.  See comments at
-                     `push_dummy_failure' in `re_match_2'.  */
-                  BUF_PUSH (push_dummy_failure);
-
-                  /* We allocated space for this jump when we assigned
-                     to `fixup_alt_jump', in the `handle_alt' case below.  */
-                  STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
-                }
-
-              /* See similar code for backslashed left paren above.  */
-              if (COMPILE_STACK_EMPTY)
-                if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
-                  goto normal_char;
-                else
-                  FREE_STACK_RETURN (REG_ERPAREN);
-
-              /* Since we just checked for an empty stack above, this
-                 ``can't happen''.  */
-              assert (compile_stack.avail != 0);
-              {
-                /* We don't just want to restore into `regnum', because
-                   later groups should continue to be numbered higher,
-                   as in `(ab)c(de)' -- the second group is #2.  */
-                regnum_t this_group_regnum;
-
-                compile_stack.avail--;
-                begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
-                fixup_alt_jump
-                  = COMPILE_STACK_TOP.fixup_alt_jump
-                    ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
-                    : 0;
-                laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
-                this_group_regnum = COMPILE_STACK_TOP.regnum;
-                /* If we've reached MAX_REGNUM groups, then this open
-                   won't actually generate any code, so we'll have to
-                   clear pending_exact explicitly.  */
-                pending_exact = 0;
-
-                /* We're at the end of the group, so now we know how many
-                   groups were inside this one.  */
-                if (this_group_regnum <= MAX_REGNUM)
-                  {
-                    unsigned char *inner_group_loc
-                      = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
-
-                    *inner_group_loc = regnum - this_group_regnum;
-                    BUF_PUSH_3 (stop_memory, this_group_regnum,
-                                regnum - this_group_regnum);
-                  }
-              }
-              break;
+        laststart = b;
 
+        /* We test `*p == '^' twice, instead of using an if
+           statement, so we only need one BUF_PUSH.  */
+        BUF_PUSH (*p == '^' ? charset_not : charset);
+        if (*p == '^')
+          p++;
 
-            case '|':                                        /* `\|'.  */
-              if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
-                goto normal_backslash;
-            handle_alt:
-              if (syntax & RE_LIMITED_OPS)
-                goto normal_char;
-
-              /* Insert before the previous alternative a jump which
-                 jumps to this alternative if the former fails.  */
-              GET_BUFFER_SPACE (3);
-              INSERT_JUMP (on_failure_jump, begalt, b + 6);
-              pending_exact = 0;
-              b += 3;
-
-              /* The alternative before this one has a jump after it
-                 which gets executed if it gets matched.  Adjust that
-                 jump so it will jump to this alternative's analogous
-                 jump (put in below, which in turn will jump to the next
-                 (if any) alternative's such jump, etc.).  The last such
-                 jump jumps to the correct final destination.  A picture:
-                          _____ _____
-                          |   | |   |
-                          |   v |   v
-                         a | b   | c
-
-                 If we are at `b', then fixup_alt_jump right now points to a
-                 three-byte space after `a'.  We'll put in the jump, set
-                 fixup_alt_jump to right after `b', and leave behind three
-                 bytes which we'll fill in when we get to after `c'.  */
-
-              if (fixup_alt_jump)
-                STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
-
-              /* Mark and leave space for a jump after this alternative,
-                 to be filled in later either by next alternative or
-                 when know we're at the end of a series of alternatives.  */
-              fixup_alt_jump = b;
-              GET_BUFFER_SPACE (3);
-              b += 3;
-
-              laststart = 0;
-              begalt = b;
-              break;
+        /* Remember the first position in the bracket expression.  */
+        p1 = p;
 
+        /* Push the number of bytes in the bitmap.  */
+        BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
 
-            case '{':
-              /* If \{ is a literal.  */
-              if (!(syntax & RE_INTERVALS)
-                     /* If we're at `\{' and it's not the open-interval
-                        operator.  */
-                  || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
-                  || (p - 2 == pattern  &&  p == pend))
-                goto normal_backslash;
-
-            handle_interval:
-              {
-                /* If got here, then the syntax allows intervals.  */
-
-                /* At least (most) this many matches must be made.  */
-                int lower_bound = -1, upper_bound = -1;
-
-                beg_interval = p - 1;
-
-                if (p == pend)
-                  {
-                    if (syntax & RE_NO_BK_BRACES)
-                      goto unfetch_interval;
-                    else
-                      FREE_STACK_RETURN (REG_EBRACE);
-                  }
-
-                GET_UNSIGNED_NUMBER (lower_bound);
-
-                if (c == ',')
-                  {
-                    GET_UNSIGNED_NUMBER (upper_bound);
-                    if (upper_bound < 0) upper_bound = RE_DUP_MAX;
-                  }
-                else
-                  /* Interval such as `{1}' => match exactly once. */
-                  upper_bound = lower_bound;
-
-                if (lower_bound < 0 || upper_bound > RE_DUP_MAX
-                    || lower_bound > upper_bound)
-                  {
-                    if (syntax & RE_NO_BK_BRACES)
-                      goto unfetch_interval;
-                    else
-                      FREE_STACK_RETURN (REG_BADBR);
-                  }
-
-                if (!(syntax & RE_NO_BK_BRACES))
-                  {
-                    if (c != '\\') FREE_STACK_RETURN (REG_EBRACE);
-
-                    PATFETCH (c);
-                  }
-
-                if (c != '}')
-                  {
-                    if (syntax & RE_NO_BK_BRACES)
-                      goto unfetch_interval;
-                    else
-                      FREE_STACK_RETURN (REG_BADBR);
-                  }
-
-                /* We just parsed a valid interval.  */
-
-                /* If it's invalid to have no preceding re.  */
-                if (!laststart)
-                  {
-                    if (syntax & RE_CONTEXT_INVALID_OPS)
-                      FREE_STACK_RETURN (REG_BADRPT);
-                    else if (syntax & RE_CONTEXT_INDEP_OPS)
-                      laststart = b;
-                    else
-                      goto unfetch_interval;
-                  }
-
-                /* If the upper bound is zero, don't want to succeed at
-                   all; jump from `laststart' to `b + 3', which will be
-                   the end of the buffer after we insert the jump.  */
-                 if (upper_bound == 0)
-                   {
-                     GET_BUFFER_SPACE (3);
-                     INSERT_JUMP (jump, laststart, b + 3);
-                     b += 3;
-                   }
-
-                 /* Otherwise, we have a nontrivial interval.  When
-                    we're all done, the pattern will look like:
-                      set_number_at <jump count> <upper bound>
-                      set_number_at <succeed_n count> <lower bound>
-                      succeed_n <after jump addr> <succeed_n count>
-                      <body of loop>
-                      jump_n <succeed_n addr> <jump count>
-                    (The upper bound and `jump_n' are omitted if
-                    `upper_bound' is 1, though.)  */
-                 else
-                   { /* If the upper bound is > 1, we need to insert
-                        more at the end of the loop.  */
-                     unsigned nbytes = 10 + (upper_bound > 1) * 10;
-
-                     GET_BUFFER_SPACE (nbytes);
-
-                     /* Initialize lower bound of the `succeed_n', even
-                        though it will be set during matching by its
-                        attendant `set_number_at' (inserted next),
-                        because `re_compile_fastmap' needs to know.
-                        Jump to the `jump_n' we might insert below.  */
-                     INSERT_JUMP2 (succeed_n, laststart,
-                                   b + 5 + (upper_bound > 1) * 5,
-                                   lower_bound);
-                     b += 5;
-
-                     /* Code to initialize the lower bound.  Insert
-                        before the `succeed_n'.  The `5' is the last two
-                        bytes of this `set_number_at', plus 3 bytes of
-                        the following `succeed_n'.  */
-                     insert_op2 (set_number_at, laststart, 5, lower_bound, b);
-                     b += 5;
-
-                     if (upper_bound > 1)
-                       { /* More than one repetition is allowed, so
-                            append a backward jump to the `succeed_n'
-                            that starts this interval.
-
-                            When we've reached this during matching,
-                            we'll have matched the interval once, so
-                            jump back only `upper_bound - 1' times.  */
-                         STORE_JUMP2 (jump_n, b, laststart + 5,
-                                      upper_bound - 1);
-                         b += 5;
-
-                         /* The location we want to set is the second
-                            parameter of the `jump_n'; that is `b-2' as
-                            an absolute address.  `laststart' will be
-                            the `set_number_at' we're about to insert;
-                            `laststart+3' the number to set, the source
-                            for the relative address.  But we are
-                            inserting into the middle of the pattern --
-                            so everything is getting moved up by 5.
-                            Conclusion: (b - 2) - (laststart + 3) + 5,
-                            i.e., b - laststart.
-
-                            We insert this at the beginning of the loop
-                            so that if we fail during matching, we'll
-                            reinitialize the bounds.  */
-                         insert_op2 (set_number_at, laststart, b - laststart,
-                                     upper_bound - 1, b);
-                         b += 5;
-                       }
-                   }
-                pending_exact = 0;
-                beg_interval = NULL;
-              }
-              break;
+        /* Clear the whole map.  */
+        bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
 
-            unfetch_interval:
-              /* If an invalid interval, match the characters as literals.  */
-               assert (beg_interval);
-               p = beg_interval;
-               beg_interval = NULL;
+        /* charset_not matches newline according to a syntax bit.  */
+        if ((re_opcode_t) b[-2] == charset_not
+            && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
+          SET_LIST_BIT ('\n');
 
-               /* normal_char and normal_backslash need `c'.  */
-               PATFETCH (c);
+        /* Read in characters and ranges, setting map bits.  */
+        for (;;) {
+          if (p == pend)
+            FREE_STACK_RETURN (REG_EBRACK);
 
-               if (!(syntax & RE_NO_BK_BRACES))
-                 {
-                   if (p > pattern  &&  p[-1] == '\\')
-                     goto normal_backslash;
-                 }
-               goto normal_char;
+          PATFETCH (c);
 
-#ifdef emacs
-            /* There is no way to specify the before_dot and after_dot
-               operators.  rms says this is ok.  --karl  */
-            case '=':
-              BUF_PUSH (at_dot);
-              break;
+          /* \ might escape characters inside [...] and [^...].  */
+          if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') {
+            if (p == pend)
+              FREE_STACK_RETURN (REG_EESCAPE);
 
-            case 's':
-              laststart = b;
-              PATFETCH (c);
-              BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
-              break;
+            PATFETCH (c1);
+            SET_LIST_BIT (c1);
+            continue;
+          }
 
-            case 'S':
-              laststart = b;
-              PATFETCH (c);
-              BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
-              break;
-#endif /* emacs */
+          /* Could be the end of the bracket expression.  If it's
+             not (i.e., when the bracket expression is `[]' so
+             far), the ']' character bit gets set way below.  */
+          if (c == ']' && p != p1 + 1)
+            break;
 
+          /* Look ahead to see if it's a range when the last thing
+             was a character class.  */
+          if (had_char_class && c == '-' && *p != ']')
+            FREE_STACK_RETURN (REG_ERANGE);
+
+          /* Look ahead to see if it's a range when the last thing
+             was a character: if this is a hyphen not at the
+             beginning or the end of a list, then it's the range
+             operator.  */
+          if (c == '-' && !(p - 2 >= pattern && p[-2] == '[')
+              && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
+              && *p != ']') {
+            reg_errcode_t ret
+              = compile_range (&p, pend, translate, syntax, b);
+            if (ret != REG_NOERROR)
+              FREE_STACK_RETURN (ret);
+          }
 
-            case 'w':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              laststart = b;
-              BUF_PUSH (wordchar);
-              break;
+          else if (p[0] == '-' && p[1] != ']') {        /* This handles ranges made up of characters only.  */
+            reg_errcode_t ret;
 
+            /* Move past the `-'.  */
+            PATFETCH (c1);
 
-            case 'W':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              laststart = b;
-              BUF_PUSH (notwordchar);
-              break;
+            ret = compile_range (&p, pend, translate, syntax, b);
+            if (ret != REG_NOERROR)
+              FREE_STACK_RETURN (ret);
+          }
 
+          /* See if we're at the beginning of a possible character
+             class.  */
 
-            case '<':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (wordbeg);
-              break;
+          else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null.  */
+            char str[CHAR_CLASS_MAX_LENGTH + 1];
 
-            case '>':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (wordend);
-              break;
+            PATFETCH (c);
+            c1 = 0;
 
-            case 'b':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (wordbound);
-              break;
+            /* If pattern is `[[:'.  */
+            if (p == pend)
+              FREE_STACK_RETURN (REG_EBRACK);
 
-            case 'B':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (notwordbound);
-              break;
+            for (;;) {
+              PATFETCH (c);
+              if (c == ':' || c == ']' || p == pend
+                  || c1 == CHAR_CLASS_MAX_LENGTH)
+                break;
+              str[c1++] = c;
+            }
+            str[c1] = '\0';
 
-            case '`':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (begbuf);
-              break;
+            /* If isn't a word bracketed by `[:' and:`]':
+               undo the ending character, the letters, and leave
+               the leading `:' and `[' (but set bits for them).  */
+            if (c == ':' && *p == ']') {
+#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+              boolean is_lower = STREQ (str, "lower");
+              boolean is_upper = STREQ (str, "upper");
+              int wt;
+              int ch;
 
-            case '\'':
-              if (re_syntax_options & RE_NO_GNU_OPS)
-                goto normal_char;
-              BUF_PUSH (endbuf);
-              break;
+              wt = ctype (str);
+              if (wt == 0)
+                FREE_STACK_RETURN (REG_ECTYPE);
 
-            case '1': case '2': case '3': case '4': case '5':
-            case '6': case '7': case '8': case '9':
-              if (syntax & RE_NO_BK_REFS)
-                goto normal_char;
+              /* Throw away the ] at the end of the character
+                 class.  */
+              PATFETCH (c);
 
-              c1 = c - '0';
+              if (p == pend)
+                FREE_STACK_RETURN (REG_EBRACK);
 
-              if (c1 > regnum)
-                FREE_STACK_RETURN (REG_ESUBREG);
+              for (ch = 0; ch < 1 << BYTEWIDTH; ++ch) {
+                if (isctype (ch, wt))
+                  SET_LIST_BIT (ch);
 
-              /* Can't back reference to a subexpression if inside of it.  */
-              if (group_in_compile_stack (compile_stack, (regnum_t) c1))
-                goto normal_char;
+                if (translate && (is_upper || is_lower)
+                    && (ISUPPER (ch) || ISLOWER (ch)))
+                  SET_LIST_BIT (ch);
+              }
 
-              laststart = b;
-              BUF_PUSH_2 (duplicate, c1);
-              break;
+              had_char_class = true;
+#else
+              int ch;
+              boolean is_alnum = STREQ (str, "alnum");
+              boolean is_alpha = STREQ (str, "alpha");
+              boolean is_blank = STREQ (str, "blank");
+              boolean is_cntrl = STREQ (str, "cntrl");
+              boolean is_digit = STREQ (str, "digit");
+              boolean is_graph = STREQ (str, "graph");
+              boolean is_lower = STREQ (str, "lower");
+              boolean is_print = STREQ (str, "print");
+              boolean is_punct = STREQ (str, "punct");
+              boolean is_space = STREQ (str, "space");
+              boolean is_upper = STREQ (str, "upper");
+              boolean is_xdigit = STREQ (str, "xdigit");
+
+              if (!IS_CHAR_CLASS (str))
+                FREE_STACK_RETURN (REG_ECTYPE);
+
+              /* Throw away the ] at the end of the character
+                 class.  */
+              PATFETCH (c);
 
-
-            case '+':
-            case '?':
-              if (syntax & RE_BK_PLUS_QM)
-                goto handle_plus;
-              else
-                goto normal_backslash;
-
-            default:
-            normal_backslash:
-              /* You might think it would be useful for \ to mean
-                 not to translate; but if we don't translate it
-                 it will never match anything.  */
-              c = TRANSLATE (c);
-              goto normal_char;
+              if (p == pend)
+                FREE_STACK_RETURN (REG_EBRACK);
+
+              for (ch = 0; ch < 1 << BYTEWIDTH; ch++) {
+                /* This was split into 3 if's to
+                   avoid an arbitrary limit in some compiler.  */
+                if ((is_alnum && ISALNUM (ch))
+                    || (is_alpha && ISALPHA (ch))
+                    || (is_blank && ISBLANK (ch))
+                    || (is_cntrl && ISCNTRL (ch)))
+                  SET_LIST_BIT (ch);
+                if ((is_digit && ISDIGIT (ch))
+                    || (is_graph && ISGRAPH (ch))
+                    || (is_lower && ISLOWER (ch))
+                    || (is_print && ISPRINT (ch)))
+                  SET_LIST_BIT (ch);
+                if ((is_punct && ISPUNCT (ch))
+                    || (is_space && ISSPACE (ch))
+                    || (is_upper && ISUPPER (ch))
+                    || (is_xdigit && ISXDIGIT (ch)))
+                  SET_LIST_BIT (ch);
+                if (translate && (is_upper || is_lower)
+                    && (ISUPPER (ch) || ISLOWER (ch)))
+                  SET_LIST_BIT (ch);
+              }
+              had_char_class = true;
+#endif /* libc || wctype.h */
             }
-          break;
+            else {
+              c1++;
+              while (c1--)
+                PATUNFETCH;
+              SET_LIST_BIT ('[');
+              SET_LIST_BIT (':');
+              had_char_class = false;
+            }
+          }
+          else {
+            had_char_class = false;
+            SET_LIST_BIT (c);
+          }
+        }
+
+        /* Discard any (non)matching list bytes that are all 0 at the
+           end of the map.  Decrease the map-length byte too.  */
+        while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
+          b[-1]--;
+        b += b[-1];
+      }
+      break;
 
 
-        default:
-        /* Expects the character in `c'.  */
-        normal_char:
-              /* If no exactn currently being built.  */
-          if (!pending_exact
-
-              /* If last exactn not at current position.  */
-              || pending_exact + *pending_exact + 1 != b
-
-              /* We have only one byte following the exactn for the count.  */
-              || *pending_exact == (1 << BYTEWIDTH) - 1
-
-              /* If followed by a repetition operator.  */
-              || *p == '*' || *p == '^'
-              || ((syntax & RE_BK_PLUS_QM)
-                  ? *p == '\\' && (p[1] == '+' || p[1] == '?')
-                  : (*p == '+' || *p == '?'))
-              || ((syntax & RE_INTERVALS)
-                  && ((syntax & RE_NO_BK_BRACES)
-                      ? *p == '{'
-                      : (p[0] == '\\' && p[1] == '{'))))
-            {
-              /* Start building a new exactn.  */
+    case '(':
+      if (syntax & RE_NO_BK_PARENS)
+        goto handle_open;
+      else
+        goto normal_char;
+
+
+    case ')':
+      if (syntax & RE_NO_BK_PARENS)
+        goto handle_close;
+      else
+        goto normal_char;
+
+
+    case '\n':
+      if (syntax & RE_NEWLINE_ALT)
+        goto handle_alt;
+      else
+        goto normal_char;
+
+
+    case '|':
+      if (syntax & RE_NO_BK_VBAR)
+        goto handle_alt;
+      else
+        goto normal_char;
+
+
+    case '{':
+      if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
+        goto handle_interval;
+      else
+        goto normal_char;
+
+
+    case '\\':
+      if (p == pend)
+        FREE_STACK_RETURN (REG_EESCAPE);
+
+      /* Do not translate the character after the \, so that we can
+         distinguish, e.g., \B from \b, even if we normally would
+         translate, e.g., B to b.  */
+      PATFETCH_RAW (c);
+
+      switch (c) {
+      case '(':
+        if (syntax & RE_NO_BK_PARENS)
+          goto normal_backslash;
+
+      handle_open:
+        bufp->re_nsub++;
+        regnum++;
+
+        if (COMPILE_STACK_FULL) {
+          RETALLOC (compile_stack.stack, compile_stack.size << 1,
+                    compile_stack_elt_t);
+          if (compile_stack.stack == NULL)
+            return REG_ESPACE;
+
+          compile_stack.size <<= 1;
+        }
+
+        /* These are the values to restore when we hit end of this
+           group.  They are all relative offsets, so that if the
+           whole pattern moves because of realloc, they will still
+           be valid.  */
+        COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
+        COMPILE_STACK_TOP.fixup_alt_jump
+          = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
+        COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
+        COMPILE_STACK_TOP.regnum = regnum;
+
+        /* We will eventually replace the 0 with the number of
+           groups inner to this one.  But do not push a
+           start_memory for groups beyond the last one we can
+           represent in the compiled pattern.  */
+        if (regnum <= MAX_REGNUM) {
+          COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
+          BUF_PUSH_3 (start_memory, regnum, 0);
+        }
+
+        compile_stack.avail++;
+
+        fixup_alt_jump = 0;
+        laststart = 0;
+        begalt = b;
+        /* If we've reached MAX_REGNUM groups, then this open
+           won't actually generate any code, so we'll have to
+           clear pending_exact explicitly.  */
+        pending_exact = 0;
+        break;
+
+
+      case ')':
+        if (syntax & RE_NO_BK_PARENS)
+          goto normal_backslash;
+
+        if (COMPILE_STACK_EMPTY)
+          if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+            goto normal_backslash;
+          else
+            FREE_STACK_RETURN (REG_ERPAREN);
+
+      handle_close:
+        if (fixup_alt_jump) {   /* Push a dummy failure point at the end of the
+                                   alternative for a possible future
+                                   `pop_failure_jump' to pop.  See comments at
+                                   `push_dummy_failure' in `re_match_2'.  */
+          BUF_PUSH (push_dummy_failure);
+
+          /* We allocated space for this jump when we assigned
+             to `fixup_alt_jump', in the `handle_alt' case below.  */
+          STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
+        }
+
+        /* See similar code for backslashed left paren above.  */
+        if (COMPILE_STACK_EMPTY)
+          if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+            goto normal_char;
+          else
+            FREE_STACK_RETURN (REG_ERPAREN);
+
+        /* Since we just checked for an empty stack above, this
+           ``can't happen''.  */
+        assert (compile_stack.avail != 0);
+        {
+          /* We don't just want to restore into `regnum', because
+             later groups should continue to be numbered higher,
+             as in `(ab)c(de)' -- the second group is #2.  */
+          regnum_t this_group_regnum;
+
+          compile_stack.avail--;
+          begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
+          fixup_alt_jump
+            = COMPILE_STACK_TOP.fixup_alt_jump
+            ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 : 0;
+          laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
+          this_group_regnum = COMPILE_STACK_TOP.regnum;
+          /* If we've reached MAX_REGNUM groups, then this open
+             won't actually generate any code, so we'll have to
+             clear pending_exact explicitly.  */
+          pending_exact = 0;
+
+          /* We're at the end of the group, so now we know how many
+             groups were inside this one.  */
+          if (this_group_regnum <= MAX_REGNUM) {
+            unsigned char *inner_group_loc
+              = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
+
+            *inner_group_loc = regnum - this_group_regnum;
+            BUF_PUSH_3 (stop_memory, this_group_regnum,
+                        regnum - this_group_regnum);
+          }
+        }
+        break;
+
+
+      case '|':                /* `\|'.  */
+        if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
+          goto normal_backslash;
+      handle_alt:
+        if (syntax & RE_LIMITED_OPS)
+          goto normal_char;
+
+        /* Insert before the previous alternative a jump which
+           jumps to this alternative if the former fails.  */
+        GET_BUFFER_SPACE (3);
+        INSERT_JUMP (on_failure_jump, begalt, b + 6);
+        pending_exact = 0;
+        b += 3;
+
+        /* The alternative before this one has a jump after it
+           which gets executed if it gets matched.  Adjust that
+           jump so it will jump to this alternative's analogous
+           jump (put in below, which in turn will jump to the next
+           (if any) alternative's such jump, etc.).  The last such
+           jump jumps to the correct final destination.  A picture:
+           _____ _____
+           |   | |   |
+           |   v |   v
+           a | b   | c
+
+           If we are at `b', then fixup_alt_jump right now points to a
+           three-byte space after `a'.  We'll put in the jump, set
+           fixup_alt_jump to right after `b', and leave behind three
+           bytes which we'll fill in when we get to after `c'.  */
+
+        if (fixup_alt_jump)
+          STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
+
+        /* Mark and leave space for a jump after this alternative,
+           to be filled in later either by next alternative or
+           when know we're at the end of a series of alternatives.  */
+        fixup_alt_jump = b;
+        GET_BUFFER_SPACE (3);
+        b += 3;
+
+        laststart = 0;
+        begalt = b;
+        break;
+
+
+      case '{':
+        /* If \{ is a literal.  */
+        if (!(syntax & RE_INTERVALS)
+            /* If we're at `\{' and it's not the open-interval
+               operator.  */
+            || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+            || (p - 2 == pattern && p == pend))
+          goto normal_backslash;
+
+      handle_interval:
+        {
+          /* If got here, then the syntax allows intervals.  */
+
+          /* At least (most) this many matches must be made.  */
+          int lower_bound = -1, upper_bound = -1;
+
+          beg_interval = p - 1;
+
+          if (p == pend) {
+            if (syntax & RE_NO_BK_BRACES)
+              goto unfetch_interval;
+            else
+              FREE_STACK_RETURN (REG_EBRACE);
+          }
+
+          GET_UNSIGNED_NUMBER (lower_bound);
 
+          if (c == ',') {
+            GET_UNSIGNED_NUMBER (upper_bound);
+            if (upper_bound < 0)
+              upper_bound = RE_DUP_MAX;
+          }
+          else
+            /* Interval such as `{1}' => match exactly once. */
+            upper_bound = lower_bound;
+
+          if (lower_bound < 0 || upper_bound > RE_DUP_MAX
+              || lower_bound > upper_bound) {
+            if (syntax & RE_NO_BK_BRACES)
+              goto unfetch_interval;
+            else
+              FREE_STACK_RETURN (REG_BADBR);
+          }
+
+          if (!(syntax & RE_NO_BK_BRACES)) {
+            if (c != '\\')
+              FREE_STACK_RETURN (REG_EBRACE);
+
+            PATFETCH (c);
+          }
+
+          if (c != '}') {
+            if (syntax & RE_NO_BK_BRACES)
+              goto unfetch_interval;
+            else
+              FREE_STACK_RETURN (REG_BADBR);
+          }
+
+          /* We just parsed a valid interval.  */
+
+          /* If it's invalid to have no preceding re.  */
+          if (!laststart) {
+            if (syntax & RE_CONTEXT_INVALID_OPS)
+              FREE_STACK_RETURN (REG_BADRPT);
+            else if (syntax & RE_CONTEXT_INDEP_OPS)
               laststart = b;
+            else
+              goto unfetch_interval;
+          }
+
+          /* If the upper bound is zero, don't want to succeed at
+             all; jump from `laststart' to `b + 3', which will be
+             the end of the buffer after we insert the jump.  */
+          if (upper_bound == 0) {
+            GET_BUFFER_SPACE (3);
+            INSERT_JUMP (jump, laststart, b + 3);
+            b += 3;
+          }
 
-              BUF_PUSH_2 (exactn, 0);
-              pending_exact = b - 1;
+          /* Otherwise, we have a nontrivial interval.  When
+             we're all done, the pattern will look like:
+             set_number_at <jump count> <upper bound>
+             set_number_at <succeed_n count> <lower bound>
+             succeed_n <after jump addr> <succeed_n count>
+             <body of loop>
+             jump_n <succeed_n addr> <jump count>
+             (The upper bound and `jump_n' are omitted if
+             `upper_bound' is 1, though.)  */
+          else {                /* If the upper bound is > 1, we need to insert
+                                   more at the end of the loop.  */
+            unsigned nbytes = 10 + (upper_bound > 1) * 10;
+
+            GET_BUFFER_SPACE (nbytes);
+
+            /* Initialize lower bound of the `succeed_n', even
+               though it will be set during matching by its
+               attendant `set_number_at' (inserted next),
+               because `re_compile_fastmap' needs to know.
+               Jump to the `jump_n' we might insert below.  */
+            INSERT_JUMP2 (succeed_n, laststart,
+                          b + 5 + (upper_bound > 1) * 5, lower_bound);
+            b += 5;
+
+            /* Code to initialize the lower bound.  Insert
+               before the `succeed_n'.  The `5' is the last two
+               bytes of this `set_number_at', plus 3 bytes of
+               the following `succeed_n'.  */
+            insert_op2 (set_number_at, laststart, 5, lower_bound, b);
+            b += 5;
+
+            if (upper_bound > 1) {      /* More than one repetition is allowed, so
+                                           append a backward jump to the `succeed_n'
+                                           that starts this interval.
+
+                                           When we've reached this during matching,
+                                           we'll have matched the interval once, so
+                                           jump back only `upper_bound - 1' times.  */
+              STORE_JUMP2 (jump_n, b, laststart + 5, upper_bound - 1);
+              b += 5;
+
+              /* The location we want to set is the second
+                 parameter of the `jump_n'; that is `b-2' as
+                 an absolute address.  `laststart' will be
+                 the `set_number_at' we're about to insert;
+                 `laststart+3' the number to set, the source
+                 for the relative address.  But we are
+                 inserting into the middle of the pattern --
+                 so everything is getting moved up by 5.
+                 Conclusion: (b - 2) - (laststart + 3) + 5,
+                 i.e., b - laststart.
+
+                 We insert this at the beginning of the loop
+                 so that if we fail during matching, we'll
+                 reinitialize the bounds.  */
+              insert_op2 (set_number_at, laststart, b - laststart,
+                          upper_bound - 1, b);
+              b += 5;
             }
+          }
+          pending_exact = 0;
+          beg_interval = NULL;
+        }
+        break;
 
-          BUF_PUSH (c);
-          (*pending_exact)++;
-          break;
-        } /* switch (c) */
-    } /* while p != pend */
+      unfetch_interval:
+        /* If an invalid interval, match the characters as literals.  */
+        assert (beg_interval);
+        p = beg_interval;
+        beg_interval = NULL;
+
+        /* normal_char and normal_backslash need `c'.  */
+        PATFETCH (c);
+
+        if (!(syntax & RE_NO_BK_BRACES)) {
+          if (p > pattern && p[-1] == '\\')
+            goto normal_backslash;
+        }
+        goto normal_char;
+
+#ifdef emacs
+        /* There is no way to specify the before_dot and after_dot
+           operators.  rms says this is ok.  --karl  */
+      case '=':
+        BUF_PUSH (at_dot);
+        break;
+
+      case 's':
+        laststart = b;
+        PATFETCH (c);
+        BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
+        break;
+
+      case 'S':
+        laststart = b;
+        PATFETCH (c);
+        BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
+        break;
+#endif /* emacs */
+
+
+      case 'w':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        laststart = b;
+        BUF_PUSH (wordchar);
+        break;
+
+
+      case 'W':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        laststart = b;
+        BUF_PUSH (notwordchar);
+        break;
+
+
+      case '<':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (wordbeg);
+        break;
+
+      case '>':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (wordend);
+        break;
+
+      case 'b':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (wordbound);
+        break;
+
+      case 'B':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (notwordbound);
+        break;
+
+      case '`':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (begbuf);
+        break;
+
+      case '\'':
+        if (re_syntax_options & RE_NO_GNU_OPS)
+          goto normal_char;
+        BUF_PUSH (endbuf);
+        break;
+
+      case '1':
+      case '2':
+      case '3':
+      case '4':
+      case '5':
+      case '6':
+      case '7':
+      case '8':
+      case '9':
+        if (syntax & RE_NO_BK_REFS)
+          goto normal_char;
+
+        c1 = c - '0';
+
+        if (c1 > regnum)
+          FREE_STACK_RETURN (REG_ESUBREG);
+
+        /* Can't back reference to a subexpression if inside of it.  */
+        if (group_in_compile_stack (compile_stack, (regnum_t) c1))
+          goto normal_char;
+
+        laststart = b;
+        BUF_PUSH_2 (duplicate, c1);
+        break;
+
+
+      case '+':
+      case '?':
+        if (syntax & RE_BK_PLUS_QM)
+          goto handle_plus;
+        else
+          goto normal_backslash;
+
+      default:
+      normal_backslash:
+        /* You might think it would be useful for \ to mean
+           not to translate; but if we don't translate it
+           it will never match anything.  */
+        c = TRANSLATE (c);
+        goto normal_char;
+      }
+      break;
+
+
+    default:
+      /* Expects the character in `c'.  */
+    normal_char:
+      /* If no exactn currently being built.  */
+      if (!pending_exact
+          /* If last exactn not at current position.  */
+          || pending_exact + *pending_exact + 1 != b
+          /* We have only one byte following the exactn for the count.  */
+          || *pending_exact == (1 << BYTEWIDTH) - 1
+          /* If followed by a repetition operator.  */
+          || *p == '*' || *p == '^' || ((syntax & RE_BK_PLUS_QM)
+                                        ? *p == '\\' && (p[1] == '+'
+                                                         || p[1] == '?')
+                                        : (*p == '+' || *p == '?'))
+          || ((syntax & RE_INTERVALS)
+              && ((syntax & RE_NO_BK_BRACES)
+                  ? *p == '{' : (p[0] == '\\' && p[1] == '{')))) {
+        /* Start building a new exactn.  */
+
+        laststart = b;
+
+        BUF_PUSH_2 (exactn, 0);
+        pending_exact = b - 1;
+      }
+
+      BUF_PUSH (c);
+      (*pending_exact)++;
+      break;
+    }                           /* switch (c) */
+  }                             /* while p != pend */
 
 
   /* Through the pattern now.  */
@@ -2901,17 +2852,16 @@ regex_compile (pattern, size, syntax, bufp)
   if (syntax & RE_NO_POSIX_BACKTRACKING)
     BUF_PUSH (succeed);
 
-  free (compile_stack.stack);        /* __MEM_CHECKED__ */
+  free (compile_stack.stack);   /* __MEM_CHECKED__ */
 
   /* We have succeeded; set the length of the buffer.  */
   bufp->used = b - bufp->buffer;
 
 #ifdef DEBUG
-  if (debug)
-    {
-      DEBUG_PRINT1 ("\nCompiled pattern: \n");
-      print_compiled_pattern (bufp);
-    }
+  if (debug) {
+    DEBUG_PRINT1 ("\nCompiled pattern: \n");
+    print_compiled_pattern (bufp);
+  }
 #endif /* DEBUG */
 
 #ifndef MATCH_MAY_ALLOCATE
@@ -2924,49 +2874,49 @@ regex_compile (pattern, size, syntax, bufp)
     /* Since DOUBLE_FAIL_STACK refuses to double only if the current size
        is strictly greater than re_max_failures, the largest possible stack
        is 2 * re_max_failures failure points.  */
-    if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS))
-      {
-        fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
+    if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) {
+      fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
 
 #ifdef emacs
-        if (! fail_stack.stack)
-          fail_stack.stack
-            = (fail_stack_elt_t *) xmalloc (fail_stack.size
-                                            * sizeof (fail_stack_elt_t));
-        else
-          fail_stack.stack
-            = (fail_stack_elt_t *) xrealloc (fail_stack.stack,
-                                             (fail_stack.size
-                                              * sizeof (fail_stack_elt_t)));
+      if (!fail_stack.stack)
+        fail_stack.stack
+          = (fail_stack_elt_t *) xmalloc (fail_stack.size
+                                          * sizeof (fail_stack_elt_t));
+      else
+        fail_stack.stack
+          = (fail_stack_elt_t *) xrealloc (fail_stack.stack,
+                                           (fail_stack.size
+                                            * sizeof (fail_stack_elt_t)));
 #else /* not emacs */
-        if (! fail_stack.stack)
-          fail_stack.stack
-            = (fail_stack_elt_t *) malloc (fail_stack.size        /* __MEM_CHECKED__ */
-                                           * sizeof (fail_stack_elt_t));
-        else
-          fail_stack.stack
-            = (fail_stack_elt_t *) realloc (fail_stack.stack,        /* __MEM_CHECKED__ */
-                                            (fail_stack.size
-                                             * sizeof (fail_stack_elt_t)));
+      if (!fail_stack.stack)
+        fail_stack.stack = (fail_stack_elt_t *) malloc (fail_stack.size /* __MEM_CHECKED__ */
+                                                        *
+                                                        sizeof
+                                                        (fail_stack_elt_t));
+      else
+        fail_stack.stack = (fail_stack_elt_t *) realloc (fail_stack.stack,      /* __MEM_CHECKED__ */
+                                                         (fail_stack.size
+                                                          *
+                                                          sizeof
+                                                          (fail_stack_elt_t)));
 #endif /* not emacs */
-      }
+    }
 
     regex_grow_registers (num_regs);
   }
 #endif /* not MATCH_MAY_ALLOCATE */
 
   return REG_NOERROR;
-} /* regex_compile */
+}                               /* regex_compile */
 \f
 /* Subroutines for `regex_compile'.  */
 
 /* Store OP at LOC followed by two-byte integer parameter ARG.  */
 
-static void
-store_op1 (op, loc, arg)
-    re_opcode_t op;
-    unsigned char *loc;
-    int arg;
+static void store_op1 (op, loc, arg)
+     re_opcode_t op;
+     unsigned char *loc;
+     int arg;
 {
   *loc = (unsigned char) op;
   STORE_NUMBER (loc + 1, arg);
@@ -2975,11 +2925,10 @@ store_op1 (op, loc, arg)
 
 /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2.  */
 
-static void
-store_op2 (op, loc, arg1, arg2)
-    re_opcode_t op;
-    unsigned char *loc;
-    int arg1, arg2;
+static void store_op2 (op, loc, arg1, arg2)
+     re_opcode_t op;
+     unsigned char *loc;
+     int arg1, arg2;
 {
   *loc = (unsigned char) op;
   STORE_NUMBER (loc + 1, arg1);
@@ -2990,12 +2939,11 @@ store_op2 (op, loc, arg1, arg2)
 /* Copy the bytes from LOC to END to open up three bytes of space at LOC
    for OP followed by two-byte integer parameter ARG.  */
 
-static void
-insert_op1 (op, loc, arg, end)
-    re_opcode_t op;
-    unsigned char *loc;
-    int arg;
-    unsigned char *end;
+static void insert_op1 (op, loc, arg, end)
+     re_opcode_t op;
+     unsigned char *loc;
+     int arg;
+     unsigned char *end;
 {
   register unsigned char *pfrom = end;
   register unsigned char *pto = end + 3;
@@ -3009,12 +2957,11 @@ insert_op1 (op, loc, arg, end)
 
 /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2.  */
 
-static void
-insert_op2 (op, loc, arg1, arg2, end)
-    re_opcode_t op;
-    unsigned char *loc;
-    int arg1, arg2;
-    unsigned char *end;
+static void insert_op2 (op, loc, arg1, arg2, end)
+     re_opcode_t op;
+     unsigned char *loc;
+     int arg1, arg2;
+     unsigned char *end;
 {
   register unsigned char *pfrom = end;
   register unsigned char *pto = end + 5;
@@ -3030,18 +2977,17 @@ insert_op2 (op, loc, arg1, arg2, end)
    after an alternative or a begin-subexpression.  We assume there is at
    least one character before the ^.  */
 
-static boolean
-at_begline_loc_p (pattern, p, syntax)
-    const char *pattern, *p;
-    reg_syntax_t syntax;
+static boolean at_begline_loc_p (pattern, p, syntax)
+     const char *pattern, *p;
+     reg_syntax_t syntax;
 {
   const char *prev = p - 2;
   boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
 
   return
-       /* After a subexpression?  */
-       (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
-       /* After an alternative?  */
+    /* After a subexpression?  */
+    (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
+    /* After an alternative?  */
     || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
 }
 
@@ -3049,20 +2995,19 @@ at_begline_loc_p (pattern, p, syntax)
 /* The dual of at_begline_loc_p.  This one is for $.  We assume there is
    at least one character after the $, i.e., `P < PEND'.  */
 
-static boolean
-at_endline_loc_p (p, pend, syntax)
-    const char *p, *pend;
-    reg_syntax_t syntax;
+static boolean at_endline_loc_p (p, pend, syntax)
+     const char *p, *pend;
+     reg_syntax_t syntax;
 {
   const char *next = p;
   boolean next_backslash = *next == '\\';
   const char *next_next = p + 1 < pend ? p + 1 : 0;
 
   return
-       /* Before a subexpression?  */
-       (syntax & RE_NO_BK_PARENS ? *next == ')'
-        : next_backslash && next_next && *next_next == ')')
-       /* Before an alternative?  */
+    /* Before a subexpression?  */
+    (syntax & RE_NO_BK_PARENS ? *next == ')'
+     : next_backslash && next_next && *next_next == ')')
+    /* Before an alternative?  */
     || (syntax & RE_NO_BK_VBAR ? *next == '|'
         : next_backslash && next_next && *next_next == '|');
 }
@@ -3071,16 +3016,14 @@ at_endline_loc_p (p, pend, syntax)
 /* Returns true if REGNUM is in one of COMPILE_STACK's elements and
    false if it's not.  */
 
-static boolean
-group_in_compile_stack (compile_stack, regnum)
-    compile_stack_type compile_stack;
-    regnum_t regnum;
+static boolean group_in_compile_stack (compile_stack, regnum)
+     compile_stack_type compile_stack;
+     regnum_t regnum;
 {
   int this_element;
 
   for (this_element = compile_stack.avail - 1;
-       this_element >= 0;
-       this_element--)
+       this_element >= 0; this_element--)
     if (compile_stack.stack[this_element].regnum == regnum)
       return true;
 
@@ -3099,12 +3042,11 @@ group_in_compile_stack (compile_stack, regnum)
    We use these short variable names so we can use the same macros as
    `regex_compile' itself.  */
 
-static reg_errcode_t
-compile_range (p_ptr, pend, translate, syntax, b)
-    const char **p_ptr, *pend;
-    RE_TRANSLATE_TYPE translate;
-    reg_syntax_t syntax;
-    unsigned char *b;
+static reg_errcode_t compile_range (p_ptr, pend, translate, syntax, b)
+     const char **p_ptr, *pend;
+     RE_TRANSLATE_TYPE translate;
+     reg_syntax_t syntax;
+     unsigned char *b;
 {
   unsigned this_char;
 
@@ -3123,7 +3065,7 @@ compile_range (p_ptr, pend, translate, syntax, b)
      appropriate translation is done in the bit-setting loop below.  */
   /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *.  */
   range_start = ((const unsigned char *) p)[-2];
-  range_end   = ((const unsigned char *) p)[0];
+  range_end = ((const unsigned char *) p)[0];
 
   /* Have to increment the pointer into the pattern string, so the
      caller isn't still at the ending character.  */
@@ -3137,10 +3079,9 @@ compile_range (p_ptr, pend, translate, syntax, b)
      char' -- the range is inclusive, so if `range_end' == 0xff
      (assuming 8-bit characters), we would otherwise go into an infinite
      loop, since all characters <= 0xff.  */
-  for (this_char = range_start; this_char <= range_end; this_char++)
-    {
-      SET_LIST_BIT (TRANSLATE (this_char));
-    }
+  for (this_char = range_start; this_char <= range_end; this_char++) {
+    SET_LIST_BIT (TRANSLATE (this_char));
+  }
 
   return REG_NOERROR;
 }
@@ -3158,11 +3099,11 @@ compile_range (p_ptr, pend, translate, syntax, b)
 
    Returns 0 if we succeed, -2 if an internal error.   */
 
-int
-re_compile_fastmap (bufp)
+int re_compile_fastmap (bufp)
      struct re_pattern_buffer *bufp;
 {
   int j, k;
+
 #ifdef MATCH_MAY_ALLOCATE
   fail_stack_type fail_stack;
 #endif
@@ -3195,260 +3136,252 @@ re_compile_fastmap (bufp)
   assert (fastmap != NULL && p != NULL);
 
   INIT_FAIL_STACK ();
-  bzero (fastmap, 1 << BYTEWIDTH);  /* Assume nothing's valid.  */
-  bufp->fastmap_accurate = 1;            /* It will be when we're done.  */
+  bzero (fastmap, 1 << BYTEWIDTH);      /* Assume nothing's valid.  */
+  bufp->fastmap_accurate = 1;   /* It will be when we're done.  */
   bufp->can_be_null = 0;
 
-  while (1)
-    {
-      if (p == pend || *p == succeed)
-        {
-          /* We have reached the (effective) end of pattern.  */
-          if (!FAIL_STACK_EMPTY ())
-            {
-              bufp->can_be_null |= path_can_be_null;
+  while (1) {
+    if (p == pend || *p == succeed) {
+      /* We have reached the (effective) end of pattern.  */
+      if (!FAIL_STACK_EMPTY ()) {
+        bufp->can_be_null |= path_can_be_null;
 
-              /* Reset for next path.  */
-              path_can_be_null = true;
+        /* Reset for next path.  */
+        path_can_be_null = true;
 
-              p = fail_stack.stack[--fail_stack.avail].pointer;
+        p = fail_stack.stack[--fail_stack.avail].pointer;
 
-              continue;
-            }
-          else
-            break;
-        }
+        continue;
+      }
+      else
+        break;
+    }
 
-      /* We should never be about to go beyond the end of the pattern.  */
-      assert (p < pend);
+    /* We should never be about to go beyond the end of the pattern.  */
+    assert (p < pend);
 
-      switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
-        {
+    switch (SWITCH_ENUM_CAST ((re_opcode_t) * p++)) {
 
-        /* I guess the idea here is to simply not bother with a fastmap
-           if a backreference is used, since it's too hard to figure out
-           the fastmap for the corresponding group.  Setting
-           `can_be_null' stops `re_search_2' from using the fastmap, so
-           that is all we do.  */
-        case duplicate:
-          bufp->can_be_null = 1;
-          goto done;
+      /* I guess the idea here is to simply not bother with a fastmap
+         if a backreference is used, since it's too hard to figure out
+         the fastmap for the corresponding group.  Setting
+         `can_be_null' stops `re_search_2' from using the fastmap, so
+         that is all we do.  */
+    case duplicate:
+      bufp->can_be_null = 1;
+      goto done;
 
 
       /* Following are the cases which match a character.  These end
          with `break'.  */
 
-        case exactn:
-          fastmap[p[1]] = 1;
-          break;
+    case exactn:
+      fastmap[p[1]] = 1;
+      break;
 
 
-        case charset:
-          for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
-            if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
-              fastmap[j] = 1;
-          break;
+    case charset:
+      for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+        if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
+          fastmap[j] = 1;
+      break;
 
 
-        case charset_not:
-          /* Chars beyond end of map must be allowed.  */
-          for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
-            fastmap[j] = 1;
+    case charset_not:
+      /* Chars beyond end of map must be allowed.  */
+      for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
+        fastmap[j] = 1;
 
-          for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
-            if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
-              fastmap[j] = 1;
-          break;
+      for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+        if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
+          fastmap[j] = 1;
+      break;
 
 
-        case wordchar:
-          for (j = 0; j < (1 << BYTEWIDTH); j++)
-            if (SYNTAX (j) == Sword)
-              fastmap[j] = 1;
-          break;
+    case wordchar:
+      for (j = 0; j < (1 << BYTEWIDTH); j++)
+        if (SYNTAX (j) == Sword)
+          fastmap[j] = 1;
+      break;
 
 
-        case notwordchar:
-          for (j = 0; j < (1 << BYTEWIDTH); j++)
-            if (SYNTAX (j) != Sword)
-              fastmap[j] = 1;
-          break;
+    case notwordchar:
+      for (j = 0; j < (1 << BYTEWIDTH); j++)
+        if (SYNTAX (j) != Sword)
+          fastmap[j] = 1;
+      break;
 
 
-        case anychar:
-          {
-            int fastmap_newline = fastmap['\n'];
+    case anychar:
+      {
+        int fastmap_newline = fastmap['\n'];
 
-            /* `.' matches anything ...  */
-            for (j = 0; j < (1 << BYTEWIDTH); j++)
-              fastmap[j] = 1;
+        /* `.' matches anything ...  */
+        for (j = 0; j < (1 << BYTEWIDTH); j++)
+          fastmap[j] = 1;
 
-            /* ... except perhaps newline.  */
-            if (!(bufp->syntax & RE_DOT_NEWLINE))
-              fastmap['\n'] = fastmap_newline;
+        /* ... except perhaps newline.  */
+        if (!(bufp->syntax & RE_DOT_NEWLINE))
+          fastmap['\n'] = fastmap_newline;
 
-            /* Return if we have already set `can_be_null'; if we have,
-               then the fastmap is irrelevant.  Something's wrong here.  */
-            else if (bufp->can_be_null)
-              goto done;
+        /* Return if we have already set `can_be_null'; if we have,
+           then the fastmap is irrelevant.  Something's wrong here.  */
+        else if (bufp->can_be_null)
+          goto done;
 
-            /* Otherwise, have to check alternative paths.  */
-            break;
-          }
+        /* Otherwise, have to check alternative paths.  */
+        break;
+      }
 
 #ifdef emacs
-        case syntaxspec:
-          k = *p++;
-          for (j = 0; j < (1 << BYTEWIDTH); j++)
-            if (SYNTAX (j) == (enum syntaxcode) k)
-              fastmap[j] = 1;
-          break;
+    case syntaxspec:
+      k = *p++;
+      for (j = 0; j < (1 << BYTEWIDTH); j++)
+        if (SYNTAX (j) == (enum syntaxcode) k)
+          fastmap[j] = 1;
+      break;
 
 
-        case notsyntaxspec:
-          k = *p++;
-          for (j = 0; j < (1 << BYTEWIDTH); j++)
-            if (SYNTAX (j) != (enum syntaxcode) k)
-              fastmap[j] = 1;
-          break;
+    case notsyntaxspec:
+      k = *p++;
+      for (j = 0; j < (1 << BYTEWIDTH); j++)
+        if (SYNTAX (j) != (enum syntaxcode) k)
+          fastmap[j] = 1;
+      break;
 
 
       /* All cases after this match the empty string.  These end with
          `continue'.  */
 
 
-        case before_dot:
-        case at_dot:
-        case after_dot:
-          continue;
+    case before_dot:
+    case at_dot:
+    case after_dot:
+      continue;
 #endif /* emacs */
 
 
-        case no_op:
-        case begline:
-        case endline:
-        case begbuf:
-        case endbuf:
-        case wordbound:
-        case notwordbound:
-        case wordbeg:
-        case wordend:
-        case push_dummy_failure:
-          continue;
-
-
-        case jump_n:
-        case pop_failure_jump:
-        case maybe_pop_jump:
-        case jump:
-        case jump_past_alt:
-        case dummy_failure_jump:
-          EXTRACT_NUMBER_AND_INCR (j, p);
-          p += j;
-          if (j > 0)
-            continue;
-
-          /* Jump backward implies we just went through the body of a
-             loop and matched nothing.  Opcode jumped to should be
-             `on_failure_jump' or `succeed_n'.  Just treat it like an
-             ordinary jump.  For a * loop, it has pushed its failure
-             point already; if so, discard that as redundant.  */
-          if ((re_opcode_t) *p != on_failure_jump
-              && (re_opcode_t) *p != succeed_n)
-            continue;
+    case no_op:
+    case begline:
+    case endline:
+    case begbuf:
+    case endbuf:
+    case wordbound:
+    case notwordbound:
+    case wordbeg:
+    case wordend:
+    case push_dummy_failure:
+      continue;
 
-          p++;
-          EXTRACT_NUMBER_AND_INCR (j, p);
-          p += j;
-
-          /* If what's on the stack is where we are now, pop it.  */
-          if (!FAIL_STACK_EMPTY ()
-              && fail_stack.stack[fail_stack.avail - 1].pointer == p)
-            fail_stack.avail--;
-
-          continue;
-
-
-        case on_failure_jump:
-        case on_failure_keep_string_jump:
-        handle_on_failure_jump:
-          EXTRACT_NUMBER_AND_INCR (j, p);
-
-          /* For some patterns, e.g., `(a?)?', `p+j' here points to the
-             end of the pattern.  We don't want to push such a point,
-             since when we restore it above, entering the switch will
-             increment `p' past the end of the pattern.  We don't need
-             to push such a point since we obviously won't find any more
-             fastmap entries beyond `pend'.  Such a pattern can match
-             the null string, though.  */
-          if (p + j < pend)
-            {
-              if (!PUSH_PATTERN_OP (p + j, fail_stack))
-                {
-                  RESET_FAIL_STACK ();
-                  return -2;
-                }
-            }
-          else
-            bufp->can_be_null = 1;
 
-          if (succeed_n_p)
-            {
-              EXTRACT_NUMBER_AND_INCR (k, p);        /* Skip the n.  */
-              succeed_n_p = false;
-            }
+    case jump_n:
+    case pop_failure_jump:
+    case maybe_pop_jump:
+    case jump:
+    case jump_past_alt:
+    case dummy_failure_jump:
+      EXTRACT_NUMBER_AND_INCR (j, p);
+      p += j;
+      if (j > 0)
+        continue;
+
+      /* Jump backward implies we just went through the body of a
+         loop and matched nothing.  Opcode jumped to should be
+         `on_failure_jump' or `succeed_n'.  Just treat it like an
+         ordinary jump.  For a * loop, it has pushed its failure
+         point already; if so, discard that as redundant.  */
+      if ((re_opcode_t) * p != on_failure_jump
+          && (re_opcode_t) * p != succeed_n)
+        continue;
+
+      p++;
+      EXTRACT_NUMBER_AND_INCR (j, p);
+      p += j;
+
+      /* If what's on the stack is where we are now, pop it.  */
+      if (!FAIL_STACK_EMPTY ()
+          && fail_stack.stack[fail_stack.avail - 1].pointer == p)
+        fail_stack.avail--;
+
+      continue;
+
+
+    case on_failure_jump:
+    case on_failure_keep_string_jump:
+    handle_on_failure_jump:
+      EXTRACT_NUMBER_AND_INCR (j, p);
+
+      /* For some patterns, e.g., `(a?)?', `p+j' here points to the
+         end of the pattern.  We don't want to push such a point,
+         since when we restore it above, entering the switch will
+         increment `p' past the end of the pattern.  We don't need
+         to push such a point since we obviously won't find any more
+         fastmap entries beyond `pend'.  Such a pattern can match
+         the null string, though.  */
+      if (p + j < pend) {
+        if (!PUSH_PATTERN_OP (p + j, fail_stack)) {
+          RESET_FAIL_STACK ();
+          return -2;
+        }
+      }
+      else
+        bufp->can_be_null = 1;
 
-          continue;
+      if (succeed_n_p) {
+        EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n.  */
+        succeed_n_p = false;
+      }
 
+      continue;
 
-        case succeed_n:
-          /* Get to the number of times to succeed.  */
-          p += 2;
 
-          /* Increment p past the n for when k != 0.  */
-          EXTRACT_NUMBER_AND_INCR (k, p);
-          if (k == 0)
-            {
-              p -= 4;
-                succeed_n_p = true;  /* Spaghetti code alert.  */
-              goto handle_on_failure_jump;
-            }
-          continue;
+    case succeed_n:
+      /* Get to the number of times to succeed.  */
+      p += 2;
+
+      /* Increment p past the n for when k != 0.  */
+      EXTRACT_NUMBER_AND_INCR (k, p);
+      if (k == 0) {
+        p -= 4;
+        succeed_n_p = true;     /* Spaghetti code alert.  */
+        goto handle_on_failure_jump;
+      }
+      continue;
 
 
-        case set_number_at:
-          p += 4;
-          continue;
+    case set_number_at:
+      p += 4;
+      continue;
 
 
-        case start_memory:
-        case stop_memory:
-          p += 2;
-          continue;
+    case start_memory:
+    case stop_memory:
+      p += 2;
+      continue;
 
 
-        default:
-          abort (); /* We have listed all the cases.  */
-        } /* switch *p++ */
-
-      /* Getting here means we have found the possible starting
-         characters for one path of the pattern -- and that the empty
-         string does not match.  We need not follow this path further.
-         Instead, look at the next alternative (remembered on the
-         stack), or quit if no more.  The test at the top of the loop
-         does these things.  */
-      path_can_be_null = false;
-      p = pend;
-    } /* while p */
+    default:
+      abort ();                 /* We have listed all the cases.  */
+    }                           /* switch *p++ */
+
+    /* Getting here means we have found the possible starting
+       characters for one path of the pattern -- and that the empty
+       string does not match.  We need not follow this path further.
+       Instead, look at the next alternative (remembered on the
+       stack), or quit if no more.  The test at the top of the loop
+       does these things.  */
+    path_can_be_null = false;
+    p = pend;
+  }                             /* while p */
 
   /* Set `can_be_null' for the last path (also the first path, if the
      pattern is empty).  */
   bufp->can_be_null |= path_can_be_null;
 
- done:
+done:
   RESET_FAIL_STACK ();
   return 0;
-} /* re_compile_fastmap */
+}                               /* re_compile_fastmap */
 \f
 /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
    ENDS.  Subsequent matches using PATTERN_BUFFER and REGS will use
@@ -3463,26 +3396,23 @@ re_compile_fastmap (bufp)
    PATTERN_BUFFER will allocate its own register data, without
    freeing the old data.  */
 
-void
-re_set_registers (bufp, regs, num_regs, starts, ends)
-    struct re_pattern_buffer *bufp;
-    struct re_registers *regs;
-    unsigned num_regs;
-    regoff_t *starts, *ends;
+void re_set_registers (bufp, regs, num_regs, starts, ends)
+     struct re_pattern_buffer *bufp;
+     struct re_registers *regs;
+     unsigned num_regs;
+     regoff_t *starts, *ends;
 {
-  if (num_regs)
-    {
-      bufp->regs_allocated = REGS_REALLOCATE;
-      regs->num_regs = num_regs;
-      regs->start = starts;
-      regs->end = ends;
-    }
-  else
-    {
-      bufp->regs_allocated = REGS_UNALLOCATED;
-      regs->num_regs = 0;
-      regs->start = regs->end = (regoff_t *) 0;
-    }
+  if (num_regs) {
+    bufp->regs_allocated = REGS_REALLOCATE;
+    regs->num_regs = num_regs;
+    regs->start = starts;
+    regs->end = ends;
+  }
+  else {
+    bufp->regs_allocated = REGS_UNALLOCATED;
+    regs->num_regs = 0;
+    regs->start = regs->end = (regoff_t *) 0;
+  }
 }
 \f
 /* Searching routines.  */
@@ -3490,8 +3420,7 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
 /* Like re_search_2, below, but only one string is specified, and
    doesn't let you say where to stop matching. */
 
-int
-re_search (bufp, string, size, startpos, range, regs)
+int re_search (bufp, string, size, startpos, range, regs)
      struct re_pattern_buffer *bufp;
      const char *string;
      int size, startpos, range;
@@ -3524,7 +3453,8 @@ re_search (bufp, string, size, startpos, range, regs)
    stack overflow).  */
 
 int
-re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
+re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs,
+             stop)
      struct re_pattern_buffer *bufp;
      const char *string1, *string2;
      int size1, size2;
@@ -3553,23 +3483,21 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
 
   /* If the search isn't to be a backwards one, don't waste time in a
      search for a pattern that must be anchored.  */
-  if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
-    {
-      if (startpos > 0)
-        return -1;
-      else
-        range = 1;
-    }
+  if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) {
+    if (startpos > 0)
+      return -1;
+    else
+      range = 1;
+  }
 
 #ifdef emacs
   /* In a forward search for something that starts with \=.
      don't keep searching past point.  */
-  if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0)
-    {
-      range = PT - startpos;
-      if (range <= 0)
-        return -1;
-    }
+  if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) {
+    range = PT - startpos;
+    if (range <= 0)
+      return -1;
+  }
 #endif /* emacs */
 
   /* Update the fastmap now if not correct already.  */
@@ -3578,84 +3506,77 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
       return -2;
 
   /* Loop through the string, looking for a place to start matching.  */
-  for (;;)
-    {
-      /* If a fastmap is supplied, skip quickly over characters that
-         cannot be the start of a match.  If the pattern can match the
-         null string, however, we don't need to skip characters; we want
-         the first null string.  */
-      if (fastmap && startpos < total_size && !bufp->can_be_null)
-        {
-          if (range > 0)        /* Searching forwards.  */
-            {
-              register const char *d;
-              register int lim = 0;
-              int irange = range;
-
-              if (startpos < size1 && startpos + range >= size1)
-                lim = range - (size1 - startpos);
-
-              d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
-
-              /* Written out as an if-else to avoid testing `translate'
-                 inside the loop.  */
-              if (translate)
-                while (range > lim
-                       && !fastmap[(unsigned char)
-                                   translate[(unsigned char) *d++]])
-                  range--;
-              else
-                while (range > lim && !fastmap[(unsigned char) *d++])
-                  range--;
-
-              startpos += irange - range;
-            }
-          else                                /* Searching backwards.  */
-            {
-              register char c = (size1 == 0 || startpos >= size1
-                                 ? string2[startpos - size1]
-                                 : string1[startpos]);
-
-              if (!fastmap[(unsigned char) TRANSLATE (c)])
-                goto advance;
-            }
-        }
+  for (;;) {
+    /* If a fastmap is supplied, skip quickly over characters that
+       cannot be the start of a match.  If the pattern can match the
+       null string, however, we don't need to skip characters; we want
+       the first null string.  */
+    if (fastmap && startpos < total_size && !bufp->can_be_null) {
+      if (range > 0) {          /* Searching forwards.  */
+        register const char *d;
+        register int lim = 0;
+        int irange = range;
+
+        if (startpos < size1 && startpos + range >= size1)
+          lim = range - (size1 - startpos);
+
+        d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
+
+        /* Written out as an if-else to avoid testing `translate'
+           inside the loop.  */
+        if (translate)
+          while (range > lim && !fastmap[(unsigned char)
+                                         translate[(unsigned char) *d++]])
+            range--;
+        else
+          while (range > lim && !fastmap[(unsigned char) *d++])
+            range--;
 
-      /* If can't match the null string, and that's all we have left, fail.  */
-      if (range >= 0 && startpos == total_size && fastmap
-          && !bufp->can_be_null)
-        return -1;
+        startpos += irange - range;
+      }
+      else {                    /* Searching backwards.  */
+
+        register char c = (size1 == 0 || startpos >= size1
+                           ? string2[startpos - size1]
+                           : string1[startpos]);
+
+        if (!fastmap[(unsigned char) TRANSLATE (c)])
+          goto advance;
+      }
+    }
+
+    /* If can't match the null string, and that's all we have left, fail.  */
+    if (range >= 0 && startpos == total_size && fastmap && !bufp->can_be_null)
+      return -1;
 
-      val = re_match_2_internal (bufp, string1, size1, string2, size2,
-                                 startpos, regs, stop);
+    val = re_match_2_internal (bufp, string1, size1, string2, size2,
+                               startpos, regs, stop);
 #ifndef REGEX_MALLOC
 #ifdef C_ALLOCA
-      alloca (0);
+    alloca (0);
 #endif
 #endif
 
-      if (val >= 0)
-        return startpos;
+    if (val >= 0)
+      return startpos;
 
-      if (val == -2)
-        return -2;
+    if (val == -2)
+      return -2;
 
-    advance:
-      if (!range)
-        break;
-      else if (range > 0)
-        {
-          range--;
-          startpos++;
-        }
-      else
-        {
-          range++;
-          startpos--;
-        }
+  advance:
+    if (!range)
+      break;
+    else if (range > 0) {
+      range--;
+      startpos++;
     }
-  return -1;
-} /* re_search_2 */
+    else {
+      range++;
+      startpos--;
+    }
+  }
+  return -1;
+}                               /* re_search_2 */
 \f
 /* This converts PTR, a pointer into one of the search strings `string1'
    and `string2' into an offset from the beginning of that string.  */
@@ -3723,7 +3644,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
     FREE_VAR (reg_info_dummy);                                                \
   } while (0)
 #else
-#define FREE_VARIABLES() ((void)0) /* Do nothing!  But inhibit gcc warning.  */
+#define FREE_VARIABLES() ((void)0)      /* Do nothing!  But inhibit gcc warning.  */
 #endif /* not MATCH_MAY_ALLOCATE */
 
 /* These values must meet several constraints.  They must not be valid
@@ -3738,11 +3659,10 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
 \f
 /* Matching routines.  */
 
-#ifndef emacs   /* Emacs never uses this.  */
+#ifndef emacs                   /* Emacs never uses this.  */
 /* re_match is like re_match_2 except it takes only a single string.  */
 
-int
-re_match (bufp, string, size, pos, regs)
+int re_match (bufp, string, size, pos, regs)
      struct re_pattern_buffer *bufp;
      const char *string;
      int size, pos;
@@ -3750,6 +3670,7 @@ re_match (bufp, string, size, pos, regs)
 {
   int result = re_match_2_internal (bufp, NULL, 0, string, size,
                                     pos, regs, size);
+
 #ifndef REGEX_MALLOC
 #ifdef C_ALLOCA
   alloca (0);
@@ -3761,15 +3682,16 @@ re_match (bufp, string, size, pos, regs)
 
 static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p,
                                                     unsigned char *end,
-                                                register_info_type *reg_info));
-static boolean alt_match_null_string_p _RE_ARGS ((unsigned char *p,
-                                                  unsigned char *end,
-                                                register_info_type *reg_info));
-static boolean common_op_match_null_string_p _RE_ARGS ((unsigned char **p,
-                                                        unsigned char *end,
-                                                register_info_type *reg_info));
-static int bcmp_translate _RE_ARGS ((const char *s1, const char *s2,
-                                     int len, char *translate));
+                                                    register_info_type *
+                                                    reg_info));
+static boolean alt_match_null_string_p
+_RE_ARGS ((unsigned char *p, unsigned char *end,
+           register_info_type * reg_info));
+static boolean common_op_match_null_string_p
+_RE_ARGS ((unsigned char **p, unsigned char *end,
+           register_info_type * reg_info));
+static int bcmp_translate
+_RE_ARGS ((const char *s1, const char *s2, int len, char *translate));
 
 /* re_match_2 matches the compiled pattern in BUFP against the
    the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
@@ -3784,8 +3706,7 @@ static int bcmp_translate _RE_ARGS ((const char *s1, const char *s2,
    failure stack overflowing).  Otherwise, we return the length of the
    matched substring.  */
 
-int
-re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
      struct re_pattern_buffer *bufp;
      const char *string1, *string2;
      int size1, size2;
@@ -3795,6 +3716,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
 {
   int result = re_match_2_internal (bufp, string1, size1, string2, size2,
                                     pos, regs, stop);
+
 #ifndef REGEX_MALLOC
 #ifdef C_ALLOCA
   alloca (0);
@@ -3848,7 +3770,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      scanning the strings.  If the latter is zero, the failure point is
      a ``dummy''; if a failure happens and the failure point is a dummy,
      it gets discarded and the next next one is tried.  */
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global.  */
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, this is global.  */
   fail_stack_type fail_stack;
 #endif
 #ifdef DEBUG
@@ -3878,7 +3800,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      matching and the regnum-th regend points to right after where we
      stopped matching the regnum-th subexpression.  (The zeroth register
      keeps track of what the whole pattern matches.)  */
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, these are global.  */
   const char **regstart, **regend;
 #endif
 
@@ -3887,7 +3809,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      restored because it will have been set to wherever in the string we
      are when we last see its open-group operator.  Similarly for a
      register's end.  */
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, these are global.  */
   const char **old_regstart, **old_regend;
 #endif
 
@@ -3897,7 +3819,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      matched any of the pattern so far this time through the reg_num-th
      subexpression.  These two fields get reset each time through any
      loop their register is in.  */
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global.  */
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, this is global.  */
   register_info_type *reg_info;
 #endif
 
@@ -3906,7 +3828,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      This happens as we backtrack through the failure points, which in
      turn happens only if we have not yet matched the entire string. */
   unsigned best_regs_set = false;
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
+
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, these are global.  */
   const char **best_regstart, **best_regend;
 #endif
 
@@ -3924,7 +3847,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
   int set_regs_matched_done = 0;
 
   /* Used when we pop values we don't care about.  */
-#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
+#ifdef MATCH_MAY_ALLOCATE       /* otherwise, these are global.  */
   const char **reg_dummy;
   register_info_type *reg_info_dummy;
 #endif
@@ -3944,79 +3867,73 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      there are groups, we include space for register 0 (the whole
      pattern), even though we never use it, since it simplifies the
      array indexing.  We should fix this.  */
-  if (bufp->re_nsub)
-    {
-      regstart = REGEX_TALLOC (num_regs, const char *);
-      regend = REGEX_TALLOC (num_regs, const char *);
-      old_regstart = REGEX_TALLOC (num_regs, const char *);
-      old_regend = REGEX_TALLOC (num_regs, const char *);
-      best_regstart = REGEX_TALLOC (num_regs, const char *);
-      best_regend = REGEX_TALLOC (num_regs, const char *);
-      reg_info = REGEX_TALLOC (num_regs, register_info_type);
-      reg_dummy = REGEX_TALLOC (num_regs, const char *);
-      reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);
-
-      if (!(regstart && regend && old_regstart && old_regend && reg_info
-            && best_regstart && best_regend && reg_dummy && reg_info_dummy))
-        {
-          FREE_VARIABLES ();
-          return -2;
-        }
-    }
-  else
-    {
-      /* We must initialize all our variables to NULL, so that
-         `FREE_VARIABLES' doesn't try to free them.  */
-      regstart = regend = old_regstart = old_regend = best_regstart
-        = best_regend = reg_dummy = NULL;
-      reg_info = reg_info_dummy = (register_info_type *) NULL;
+  if (bufp->re_nsub) {
+    regstart = REGEX_TALLOC (num_regs, const char *);
+    regend = REGEX_TALLOC (num_regs, const char *);
+    old_regstart = REGEX_TALLOC (num_regs, const char *);
+    old_regend = REGEX_TALLOC (num_regs, const char *);
+    best_regstart = REGEX_TALLOC (num_regs, const char *);
+    best_regend = REGEX_TALLOC (num_regs, const char *);
+
+    reg_info = REGEX_TALLOC (num_regs, register_info_type);
+    reg_dummy = REGEX_TALLOC (num_regs, const char *);
+
+    reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);
+
+    if (!(regstart && regend && old_regstart && old_regend && reg_info
+          && best_regstart && best_regend && reg_dummy && reg_info_dummy)) {
+      FREE_VARIABLES ();
+      return -2;
     }
+  }
+  else {
+    /* We must initialize all our variables to NULL, so that
+       `FREE_VARIABLES' doesn't try to free them.  */
+    regstart = regend = old_regstart = old_regend = best_regstart
+      = best_regend = reg_dummy = NULL;
+    reg_info = reg_info_dummy = (register_info_type *) NULL;
+  }
 #endif /* MATCH_MAY_ALLOCATE */
 
   /* The starting position is bogus.  */
-  if (pos < 0 || pos > size1 + size2)
-    {
-      FREE_VARIABLES ();
-      return -1;
-    }
+  if (pos < 0 || pos > size1 + size2) {
+    FREE_VARIABLES ();
+    return -1;
+  }
 
   /* Initialize subexpression text positions to -1 to mark ones that no
      start_memory/stop_memory has been seen for. Also initialize the
      register information struct.  */
-  for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
-    {
-      regstart[mcnt] = regend[mcnt]
-        = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
-
-      REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
-      IS_ACTIVE (reg_info[mcnt]) = 0;
-      MATCHED_SOMETHING (reg_info[mcnt]) = 0;
-      EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
-    }
+  for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++) {
+    regstart[mcnt] = regend[mcnt]
+      = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
+
+    REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
+    IS_ACTIVE (reg_info[mcnt]) = 0;
+    MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+    EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+  }
 
   /* We move `string1' into `string2' if the latter's empty -- but not if
      `string1' is null.  */
-  if (size2 == 0 && string1 != NULL)
-    {
-      string2 = string1;
-      size2 = size1;
-      string1 = 0;
-      size1 = 0;
-    }
+  if (size2 == 0 && string1 != NULL) {
+    string2 = string1;
+    size2 = size1;
+    string1 = 0;
+    size1 = 0;
+  }
   end1 = string1 + size1;
   end2 = string2 + size2;
 
   /* Compute where to stop matching, within the two strings.  */
-  if (stop <= size1)
-    {
-      end_match_1 = string1 + stop;
-      end_match_2 = string2;
-    }
-  else
-    {
-      end_match_1 = end1;
-      end_match_2 = string2 + stop - size1;
-    }
+  if (stop <= size1) {
+    end_match_1 = string1 + stop;
+    end_match_2 = string2;
+  }
+  else {
+    end_match_1 = end1;
+    end_match_2 = string2 + stop - size1;
+  }
 
   /* `p' scans through the pattern as `d' scans through the data.
      `dend' is the end of the input string that `d' points within.  `d'
@@ -4024,16 +3941,14 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
      this happens before fetching; therefore, at the beginning of the
      loop, `d' can be pointing at the end of a string, but it cannot
      equal `string2'.  */
-  if (size1 > 0 && pos <= size1)
-    {
-      d = string1 + pos;
-      dend = end_match_1;
-    }
-  else
-    {
-      d = string2 + pos - size1;
-      dend = end_match_2;
-    }
+  if (size1 > 0 && pos <= size1) {
+    d = string1 + pos;
+    dend = end_match_1;
+  }
+  else {
+    d = string2 + pos - size1;
+    dend = end_match_2;
+  }
 
   DEBUG_PRINT1 ("The compiled pattern is:\n");
   DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
@@ -4044,1156 +3959,1100 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
   /* This loops over pattern commands.  It exits by returning from the
      function if the match is complete, or it drops through if the match
      fails at this starting point in the input data.  */
-  for (;;)
-    {
+  for (;;) {
 #ifdef _LIBC
-      DEBUG_PRINT2 ("\n%p: ", p);
+    DEBUG_PRINT2 ("\n%p: ", p);
 #else
-      DEBUG_PRINT2 ("\n0x%x: ", p);
+    DEBUG_PRINT2 ("\n0x%x: ", p);
 #endif
 
-      if (p == pend)
-        { /* End of pattern means we might have succeeded.  */
-          DEBUG_PRINT1 ("end of pattern ... ");
-
-          /* If we haven't matched the entire string, and we want the
-             longest match, try backtracking.  */
-          if (d != end_match_2)
-            {
-              /* 1 if this match ends in the same string (string1 or string2)
-                 as the best previous match.  */
-              boolean same_str_p = (FIRST_STRING_P (match_end)
-                                    == MATCHING_IN_FIRST_STRING);
-              /* 1 if this match is the best seen so far.  */
-              boolean best_match_p;
-
-              /* AIX compiler got confused when this was combined
-                 with the previous declaration.  */
-              if (same_str_p)
-                best_match_p = d > match_end;
-              else
-                best_match_p = !MATCHING_IN_FIRST_STRING;
-
-              DEBUG_PRINT1 ("backtracking.\n");
-
-              if (!FAIL_STACK_EMPTY ())
-                { /* More failure points to try.  */
-
-                  /* If exceeds best match so far, save it.  */
-                  if (!best_regs_set || best_match_p)
-                    {
-                      best_regs_set = true;
-                      match_end = d;
-
-                      DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
-
-                      for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
-                        {
-                          best_regstart[mcnt] = regstart[mcnt];
-                          best_regend[mcnt] = regend[mcnt];
-                        }
-                    }
-                  goto fail;
-                }
-
-              /* If no failure points, don't restore garbage.  And if
-                 last match is real best match, don't restore second
-                 best one. */
-              else if (best_regs_set && !best_match_p)
-                {
-                  restore_best_regs:
-                  /* Restore best match.  It may happen that `dend ==
-                     end_match_1' while the restored d is in string2.
-                     For example, the pattern `x.*y.*z' against the
-                     strings `x-' and `y-z-', if the two strings are
-                     not consecutive in memory.  */
-                  DEBUG_PRINT1 ("Restoring best registers.\n");
-
-                  d = match_end;
-                  dend = ((d >= string1 && d <= end1)
-                           ? end_match_1 : end_match_2);
-
-                  for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
-                    {
-                      regstart[mcnt] = best_regstart[mcnt];
-                      regend[mcnt] = best_regend[mcnt];
-                    }
-                }
-            } /* d != end_match_2 */
-
-        succeed_label:
-          DEBUG_PRINT1 ("Accepting match.\n");
-
-          /* If caller wants register contents data back, do it.  */
-          if (regs && !bufp->no_sub)
-            {
-              /* Have the register data arrays been allocated?  */
-              if (bufp->regs_allocated == REGS_UNALLOCATED)
-                { /* No.  So allocate them with malloc.  We need one
-                     extra element beyond `num_regs' for the `-1' marker
-                     GNU code uses.  */
-                  regs->num_regs = MAX (RE_NREGS, num_regs + 1);
-                  regs->start = TALLOC (regs->num_regs, regoff_t);
-                  regs->end = TALLOC (regs->num_regs, regoff_t);
-                  if (regs->start == NULL || regs->end == NULL)
-                    {
-                      FREE_VARIABLES ();
-                      return -2;
-                    }
-                  bufp->regs_allocated = REGS_REALLOCATE;
-                }
-              else if (bufp->regs_allocated == REGS_REALLOCATE)
-                { /* Yes.  If we need more elements than were already
-                     allocated, reallocate them.  If we need fewer, just
-                     leave it alone.  */
-                  if (regs->num_regs < num_regs + 1)
-                    {
-                      regs->num_regs = num_regs + 1;
-                      RETALLOC (regs->start, regs->num_regs, regoff_t);
-                      RETALLOC (regs->end, regs->num_regs, regoff_t);
-                      if (regs->start == NULL || regs->end == NULL)
-                        {
-                          FREE_VARIABLES ();
-                          return -2;
-                        }
-                    }
-                }
-              else
-                {
-                  /* These braces fend off a "empty body in an else-statement"
-                     warning under GCC when assert expands to nothing.  */
-                  assert (bufp->regs_allocated == REGS_FIXED);
-                }
-
-              /* Convert the pointer data in `regstart' and `regend' to
-                 indices.  Register zero has to be set differently,
-                 since we haven't kept track of any info for it.  */
-              if (regs->num_regs > 0)
-                {
-                  regs->start[0] = pos;
-                  regs->end[0] = (MATCHING_IN_FIRST_STRING
-                                  ? ((regoff_t) (d - string1))
-                                  : ((regoff_t) (d - string2 + size1)));
-                }
-
-              /* Go through the first `min (num_regs, regs->num_regs)'
-                 registers, since that is all we initialized.  */
-              for (mcnt = 1; (unsigned) mcnt < MIN (num_regs, regs->num_regs);
-                   mcnt++)
-                {
-                  if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
-                    regs->start[mcnt] = regs->end[mcnt] = -1;
-                  else
-                    {
-                      regs->start[mcnt]
-                        = (regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
-                      regs->end[mcnt]
-                        = (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
-                    }
-                }
-
-              /* If the regs structure we return has more elements than
-                 were in the pattern, set the extra elements to -1.  If
-                 we (re)allocated the registers, this is the case,
-                 because we always allocate enough to have at least one
-                 -1 at the end.  */
-              for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
-                regs->start[mcnt] = regs->end[mcnt] = -1;
-            } /* regs && !bufp->no_sub */
-
-          DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
-                        nfailure_points_pushed, nfailure_points_popped,
-                        nfailure_points_pushed - nfailure_points_popped);
-          DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
-
-          mcnt = d - pos - (MATCHING_IN_FIRST_STRING
-                            ? string1
-                            : string2 - size1);
-
-          DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
-
-          FREE_VARIABLES ();
-          return mcnt;
-        }
+    if (p == pend) {            /* End of pattern means we might have succeeded.  */
+      DEBUG_PRINT1 ("end of pattern ... ");
 
-      /* Otherwise match next pattern command.  */
-      switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
-        {
-        /* Ignore these.  Used to ignore the n of succeed_n's which
-           currently have n == 0.  */
-        case no_op:
-          DEBUG_PRINT1 ("EXECUTING no_op.\n");
-          break;
+      /* If we haven't matched the entire string, and we want the
+         longest match, try backtracking.  */
+      if (d != end_match_2) {
+        /* 1 if this match ends in the same string (string1 or string2)
+           as the best previous match.  */
+        boolean same_str_p = (FIRST_STRING_P (match_end)
+                              == MATCHING_IN_FIRST_STRING);
+
+        /* 1 if this match is the best seen so far.  */
+        boolean best_match_p;
+
+        /* AIX compiler got confused when this was combined
+           with the previous declaration.  */
+        if (same_str_p)
+          best_match_p = d > match_end;
+        else
+          best_match_p = !MATCHING_IN_FIRST_STRING;
+
+        DEBUG_PRINT1 ("backtracking.\n");
+
+        if (!FAIL_STACK_EMPTY ()) {     /* More failure points to try.  */
+
+          /* If exceeds best match so far, save it.  */
+          if (!best_regs_set || best_match_p) {
+            best_regs_set = true;
+            match_end = d;
 
-        case succeed:
-          DEBUG_PRINT1 ("EXECUTING succeed.\n");
-          goto succeed_label;
-
-        /* Match the next n pattern characters exactly.  The following
-           byte in the pattern defines n, and the n bytes after that
-           are the characters to match.  */
-        case exactn:
-          mcnt = *p++;
-          DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
-
-          /* This is written out as an if-else so we don't waste time
-             testing `translate' inside the loop.  */
-          if (translate)
-            {
-              do
-                {
-                  PREFETCH ();
-                  if ((unsigned char) translate[(unsigned char) *d++]
-                      != (unsigned char) *p++)
-                    goto fail;
-                }
-              while (--mcnt);
+            DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
+
+            for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++) {
+              best_regstart[mcnt] = regstart[mcnt];
+              best_regend[mcnt] = regend[mcnt];
             }
-          else
-            {
-              do
-                {
-                  PREFETCH ();
-                  if (*d++ != (char) *p++) goto fail;
-                }
-              while (--mcnt);
+          }
+          goto fail;
+        }
+
+        /* If no failure points, don't restore garbage.  And if
+           last match is real best match, don't restore second
+           best one. */
+        else if (best_regs_set && !best_match_p) {
+        restore_best_regs:
+          /* Restore best match.  It may happen that `dend ==
+             end_match_1' while the restored d is in string2.
+             For example, the pattern `x.*y.*z' against the
+             strings `x-' and `y-z-', if the two strings are
+             not consecutive in memory.  */
+          DEBUG_PRINT1 ("Restoring best registers.\n");
+
+          d = match_end;
+          dend = ((d >= string1 && d <= end1)
+                  ? end_match_1 : end_match_2);
+
+          for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++) {
+            regstart[mcnt] = best_regstart[mcnt];
+            regend[mcnt] = best_regend[mcnt];
+          }
+        }
+      }                         /* d != end_match_2 */
+
+    succeed_label:
+      DEBUG_PRINT1 ("Accepting match.\n");
+
+      /* If caller wants register contents data back, do it.  */
+      if (regs && !bufp->no_sub) {
+        /* Have the register data arrays been allocated?  */
+        if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No.  So allocate them with malloc.  We need one
+                                                           extra element beyond `num_regs' for the `-1' marker
+                                                           GNU code uses.  */
+          regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+          regs->start = TALLOC (regs->num_regs, regoff_t);
+          regs->end = TALLOC (regs->num_regs, regoff_t);
+          if (regs->start == NULL || regs->end == NULL) {
+            FREE_VARIABLES ();
+            return -2;
+          }
+          bufp->regs_allocated = REGS_REALLOCATE;
+        }
+        else if (bufp->regs_allocated == REGS_REALLOCATE) {     /* Yes.  If we need more elements than were already
+                                                                   allocated, reallocate them.  If we need fewer, just
+                                                                   leave it alone.  */
+          if (regs->num_regs < num_regs + 1) {
+            regs->num_regs = num_regs + 1;
+            RETALLOC (regs->start, regs->num_regs, regoff_t);
+            RETALLOC (regs->end, regs->num_regs, regoff_t);
+            if (regs->start == NULL || regs->end == NULL) {
+              FREE_VARIABLES ();
+              return -2;
             }
-          SET_REGS_MATCHED ();
-          break;
+          }
+        }
+        else {
+          /* These braces fend off a "empty body in an else-statement"
+             warning under GCC when assert expands to nothing.  */
+          assert (bufp->regs_allocated == REGS_FIXED);
+        }
 
+        /* Convert the pointer data in `regstart' and `regend' to
+           indices.  Register zero has to be set differently,
+           since we haven't kept track of any info for it.  */
+        if (regs->num_regs > 0) {
+          regs->start[0] = pos;
+          regs->end[0] = (MATCHING_IN_FIRST_STRING
+                          ? ((regoff_t) (d - string1))
+                          : ((regoff_t) (d - string2 + size1)));
+        }
 
-        /* Match any character except possibly a newline or a null.  */
-        case anychar:
-          DEBUG_PRINT1 ("EXECUTING anychar.\n");
+        /* Go through the first `min (num_regs, regs->num_regs)'
+           registers, since that is all we initialized.  */
+        for (mcnt = 1; (unsigned) mcnt < MIN (num_regs, regs->num_regs);
+             mcnt++) {
+          if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
+            regs->start[mcnt] = regs->end[mcnt] = -1;
+          else {
+            regs->start[mcnt]
+              = (regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
+            regs->end[mcnt]
+              = (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
+          }
+        }
 
-          PREFETCH ();
+        /* If the regs structure we return has more elements than
+           were in the pattern, set the extra elements to -1.  If
+           we (re)allocated the registers, this is the case,
+           because we always allocate enough to have at least one
+           -1 at the end.  */
+        for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
+          regs->start[mcnt] = regs->end[mcnt] = -1;
+      }                         /* regs && !bufp->no_sub */
+
+      DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
+                    nfailure_points_pushed, nfailure_points_popped,
+                    nfailure_points_pushed - nfailure_points_popped);
+      DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
+
+      mcnt = d - pos - (MATCHING_IN_FIRST_STRING ? string1 : string2 - size1);
+
+      DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
 
-          if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
-              || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
+      FREE_VARIABLES ();
+      return mcnt;
+    }
+
+    /* Otherwise match next pattern command.  */
+    switch (SWITCH_ENUM_CAST ((re_opcode_t) * p++)) {
+      /* Ignore these.  Used to ignore the n of succeed_n's which
+         currently have n == 0.  */
+    case no_op:
+      DEBUG_PRINT1 ("EXECUTING no_op.\n");
+      break;
+
+    case succeed:
+      DEBUG_PRINT1 ("EXECUTING succeed.\n");
+      goto succeed_label;
+
+      /* Match the next n pattern characters exactly.  The following
+         byte in the pattern defines n, and the n bytes after that
+         are the characters to match.  */
+    case exactn:
+      mcnt = *p++;
+      DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
+
+      /* This is written out as an if-else so we don't waste time
+         testing `translate' inside the loop.  */
+      if (translate) {
+        do {
+          PREFETCH ();
+          if ((unsigned char) translate[(unsigned char) *d++]
+              != (unsigned char) *p++)
             goto fail;
+        }
+        while (--mcnt);
+      }
+      else {
+        do {
+          PREFETCH ();
+          if (*d++ != (char) *p++)
+            goto fail;
+        }
+        while (--mcnt);
+      }
+      SET_REGS_MATCHED ();
+      break;
 
-          SET_REGS_MATCHED ();
-          DEBUG_PRINT2 ("  Matched `%d'.\n", *d);
-          d++;
-          break;
 
+      /* Match any character except possibly a newline or a null.  */
+    case anychar:
+      DEBUG_PRINT1 ("EXECUTING anychar.\n");
 
-        case charset:
-        case charset_not:
-          {
-            register unsigned char c;
-            boolean not = (re_opcode_t) *(p - 1) == charset_not;
+      PREFETCH ();
 
-            DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
+      if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
+          || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
+        goto fail;
 
-            PREFETCH ();
-            c = TRANSLATE (*d); /* The character to match.  */
+      SET_REGS_MATCHED ();
+      DEBUG_PRINT2 ("  Matched `%d'.\n", *d);
+      d++;
+      break;
 
-            /* Cast to `unsigned' instead of `unsigned char' in case the
-               bit list is a full 32 bytes long.  */
-            if (c < (unsigned) (*p * BYTEWIDTH)
-                && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-              not = !not;
 
-            p += 1 + *p;
+    case charset:
+    case charset_not:
+      {
+        register unsigned char c;
+        boolean not = (re_opcode_t) * (p - 1) == charset_not;
 
-            if (!not) goto fail;
+        DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
 
-            SET_REGS_MATCHED ();
-            d++;
-            break;
-          }
+        PREFETCH ();
+        c = TRANSLATE (*d);     /* The character to match.  */
 
+        /* Cast to `unsigned' instead of `unsigned char' in case the
+           bit list is a full 32 bytes long.  */
+        if (c < (unsigned) (*p * BYTEWIDTH)
+            && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+          not = !not;
 
-        /* The beginning of a group is represented by start_memory.
-           The arguments are the register number in the next byte, and the
-           number of groups inner to this one in the next.  The text
-           matched within the group is recorded (in the internal
-           registers data structure) under the register number.  */
-        case start_memory:
-          DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]);
+        p += 1 + *p;
 
-          /* Find out if this group can match the empty string.  */
-          p1 = p;                /* To send to group_match_null_string_p.  */
+        if (!not)
+          goto fail;
 
-          if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
-            REG_MATCH_NULL_STRING_P (reg_info[*p])
-              = group_match_null_string_p (&p1, pend, reg_info);
+        SET_REGS_MATCHED ();
+        d++;
+        break;
+      }
 
-          /* Save the position in the string where we were the last time
-             we were at this open-group operator in case the group is
-             operated upon by a repetition operator, e.g., with `(a*)*b'
-             against `ab'; then we want to ignore where we are now in
-             the string in case this attempt to match fails.  */
-          old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
-                             ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
-                             : regstart[*p];
-          DEBUG_PRINT2 ("  old_regstart: %d\n",
-                         POINTER_TO_OFFSET (old_regstart[*p]));
 
-          regstart[*p] = d;
-          DEBUG_PRINT2 ("  regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
+      /* The beginning of a group is represented by start_memory.
+         The arguments are the register number in the next byte, and the
+         number of groups inner to this one in the next.  The text
+         matched within the group is recorded (in the internal
+         registers data structure) under the register number.  */
+    case start_memory:
+      DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]);
 
-          IS_ACTIVE (reg_info[*p]) = 1;
-          MATCHED_SOMETHING (reg_info[*p]) = 0;
+      /* Find out if this group can match the empty string.  */
+      p1 = p;                   /* To send to group_match_null_string_p.  */
 
-          /* Clear this whenever we change the register activity status.  */
-          set_regs_matched_done = 0;
+      if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
+        REG_MATCH_NULL_STRING_P (reg_info[*p])
+          = group_match_null_string_p (&p1, pend, reg_info);
 
-          /* This is the new highest active register.  */
-          highest_active_reg = *p;
+      /* Save the position in the string where we were the last time
+         we were at this open-group operator in case the group is
+         operated upon by a repetition operator, e.g., with `(a*)*b'
+         against `ab'; then we want to ignore where we are now in
+         the string in case this attempt to match fails.  */
+      old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+        ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
+        : regstart[*p];
+      DEBUG_PRINT2 ("  old_regstart: %d\n",
+                    POINTER_TO_OFFSET (old_regstart[*p]));
 
-          /* If nothing was active before, this is the new lowest active
-             register.  */
-          if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
-            lowest_active_reg = *p;
+      regstart[*p] = d;
+      DEBUG_PRINT2 ("  regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
 
-          /* Move past the register number and inner group count.  */
-          p += 2;
-          just_past_start_mem = p;
+      IS_ACTIVE (reg_info[*p]) = 1;
+      MATCHED_SOMETHING (reg_info[*p]) = 0;
 
-          break;
+      /* Clear this whenever we change the register activity status.  */
+      set_regs_matched_done = 0;
 
+      /* This is the new highest active register.  */
+      highest_active_reg = *p;
 
-        /* The stop_memory opcode represents the end of a group.  Its
-           arguments are the same as start_memory's: the register
-           number, and the number of inner groups.  */
-        case stop_memory:
-          DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
-
-          /* We need to save the string position the last time we were at
-             this close-group operator in case the group is operated
-             upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
-             against `aba'; then we want to ignore where we are now in
-             the string in case this attempt to match fails.  */
-          old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
-                           ? REG_UNSET (regend[*p]) ? d : regend[*p]
-                           : regend[*p];
-          DEBUG_PRINT2 ("      old_regend: %d\n",
-                         POINTER_TO_OFFSET (old_regend[*p]));
-
-          regend[*p] = d;
-          DEBUG_PRINT2 ("      regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
-
-          /* This register isn't active anymore.  */
-          IS_ACTIVE (reg_info[*p]) = 0;
-
-          /* Clear this whenever we change the register activity status.  */
-          set_regs_matched_done = 0;
-
-          /* If this was the only register active, nothing is active
-             anymore.  */
-          if (lowest_active_reg == highest_active_reg)
-            {
-              lowest_active_reg = NO_LOWEST_ACTIVE_REG;
-              highest_active_reg = NO_HIGHEST_ACTIVE_REG;
-            }
-          else
-            { /* We must scan for the new highest active register, since
-                 it isn't necessarily one less than now: consider
-                 (a(b)c(d(e)f)g).  When group 3 ends, after the f), the
-                 new highest active register is 1.  */
-              unsigned char r = *p - 1;
-              while (r > 0 && !IS_ACTIVE (reg_info[r]))
-                r--;
-
-              /* If we end up at register zero, that means that we saved
-                 the registers as the result of an `on_failure_jump', not
-                 a `start_memory', and we jumped to past the innermost
-                 `stop_memory'.  For example, in ((.)*) we save
-                 registers 1 and 2 as a result of the *, but when we pop
-                 back to the second ), we are at the stop_memory 1.
-                 Thus, nothing is active.  */
-              if (r == 0)
-                {
-                  lowest_active_reg = NO_LOWEST_ACTIVE_REG;
-                  highest_active_reg = NO_HIGHEST_ACTIVE_REG;
-                }
-              else
-                highest_active_reg = r;
-            }
+      /* If nothing was active before, this is the new lowest active
+         register.  */
+      if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+        lowest_active_reg = *p;
 
-          /* If just failed to match something this time around with a
-             group that's operated on by a repetition operator, try to
-             force exit from the ``loop'', and restore the register
-             information for this group that we had before trying this
-             last match.  */
-          if ((!MATCHED_SOMETHING (reg_info[*p])
-               || just_past_start_mem == p - 1)
-              && (p + 2) < pend)
-            {
-              boolean is_a_jump_n = false;
-
-              p1 = p + 2;
-              mcnt = 0;
-              switch ((re_opcode_t) *p1++)
-                {
-                  case jump_n:
-                    is_a_jump_n = true;
-                  case pop_failure_jump:
-                  case maybe_pop_jump:
-                  case jump:
-                  case dummy_failure_jump:
-                    EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-                    if (is_a_jump_n)
-                      p1 += 2;
-                    break;
-
-                  default:
-                    /* do nothing */ ;
-                }
-              p1 += mcnt;
-
-              /* If the next operation is a jump backwards in the pattern
-                 to an on_failure_jump right before the start_memory
-                 corresponding to this stop_memory, exit from the loop
-                 by forcing a failure after pushing on the stack the
-                 on_failure_jump's jump in the pattern, and d.  */
-              if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump
-                  && (re_opcode_t) p1[3] == start_memory && p1[4] == *p)
-                {
-                  /* If this group ever matched anything, then restore
-                     what its registers were before trying this last
-                     failed match, e.g., with `(a*)*b' against `ab' for
-                     regstart[1], and, e.g., with `((a*)*(b*)*)*'
-                     against `aba' for regend[3].
-
-                     Also restore the registers for inner groups for,
-                     e.g., `((a*)(b*))*' against `aba' (register 3 would
-                     otherwise get trashed).  */
-
-                  if (EVER_MATCHED_SOMETHING (reg_info[*p]))
-                    {
-                      unsigned r;
-
-                      EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
-
-                      /* Restore this and inner groups' (if any) registers.  */
-                      for (r = *p; r < (unsigned) *p + (unsigned) *(p + 1);
-                           r++)
-                        {
-                          regstart[r] = old_regstart[r];
-
-                          /* xx why this test?  */
-                          if (old_regend[r] >= regstart[r])
-                            regend[r] = old_regend[r];
-                        }
-                    }
-                  p1++;
-                  EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-                  PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
-
-                  goto fail;
-                }
-            }
+      /* Move past the register number and inner group count.  */
+      p += 2;
+      just_past_start_mem = p;
 
-          /* Move past the register number and the inner group count.  */
-          p += 2;
-          break;
+      break;
 
 
-        /* \<digit> has been turned into a `duplicate' command which is
-           followed by the numeric value of <digit> as the register number.  */
-        case duplicate:
-          {
-            register const char *d2, *dend2;
-            int regno = *p++;   /* Get which register to match against.  */
-            DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
-
-            /* Can't back reference a group which we've never matched.  */
-            if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
-              goto fail;
-
-            /* Where in input to try to start matching.  */
-            d2 = regstart[regno];
-
-            /* Where to stop matching; if both the place to start and
-               the place to stop matching are in the same string, then
-               set to the place to stop, otherwise, for now have to use
-               the end of the first string.  */
-
-            dend2 = ((FIRST_STRING_P (regstart[regno])
-                      == FIRST_STRING_P (regend[regno]))
-                     ? regend[regno] : end_match_1);
-            for (;;)
-              {
-                /* If necessary, advance to next segment in register
-                   contents.  */
-                while (d2 == dend2)
-                  {
-                    if (dend2 == end_match_2) break;
-                    if (dend2 == regend[regno]) break;
-
-                    /* End of string1 => advance to string2. */
-                    d2 = string2;
-                    dend2 = regend[regno];
-                  }
-                /* At end of register contents => success */
-                if (d2 == dend2) break;
-
-                /* If necessary, advance to next segment in data.  */
-                PREFETCH ();
-
-                /* How many characters left in this segment to match.  */
-                mcnt = dend - d;
-
-                /* Want how many consecutive characters we can match in
-                   one shot, so, if necessary, adjust the count.  */
-                if (mcnt > dend2 - d2)
-                  mcnt = dend2 - d2;
-
-                /* Compare that many; failure if mismatch, else move
-                   past them.  */
-                if (translate
-                    ? bcmp_translate (d, d2, mcnt, translate)
-                    : bcmp (d, d2, mcnt))
-                  goto fail;
-                d += mcnt, d2 += mcnt;
-
-                /* Do this because we've match some characters.  */
-                SET_REGS_MATCHED ();
-              }
-          }
-          break;
+      /* The stop_memory opcode represents the end of a group.  Its
+         arguments are the same as start_memory's: the register
+         number, and the number of inner groups.  */
+    case stop_memory:
+      DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
+
+      /* We need to save the string position the last time we were at
+         this close-group operator in case the group is operated
+         upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
+         against `aba'; then we want to ignore where we are now in
+         the string in case this attempt to match fails.  */
+      old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+        ? REG_UNSET (regend[*p]) ? d : regend[*p]
+        : regend[*p];
+      DEBUG_PRINT2 ("      old_regend: %d\n",
+                    POINTER_TO_OFFSET (old_regend[*p]));
+
+      regend[*p] = d;
+      DEBUG_PRINT2 ("      regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
+
+      /* This register isn't active anymore.  */
+      IS_ACTIVE (reg_info[*p]) = 0;
+
+      /* Clear this whenever we change the register activity status.  */
+      set_regs_matched_done = 0;
+
+      /* If this was the only register active, nothing is active
+         anymore.  */
+      if (lowest_active_reg == highest_active_reg) {
+        lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+        highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+      }
+      else {                    /* We must scan for the new highest active register, since
+                                   it isn't necessarily one less than now: consider
+                                   (a(b)c(d(e)f)g).  When group 3 ends, after the f), the
+                                   new highest active register is 1.  */
+        unsigned char r = *p - 1;
+
+        while (r > 0 && !IS_ACTIVE (reg_info[r]))
+          r--;
+
+        /* If we end up at register zero, that means that we saved
+           the registers as the result of an `on_failure_jump', not
+           a `start_memory', and we jumped to past the innermost
+           `stop_memory'.  For example, in ((.)*) we save
+           registers 1 and 2 as a result of the *, but when we pop
+           back to the second ), we are at the stop_memory 1.
+           Thus, nothing is active.  */
+        if (r == 0) {
+          lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+          highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+        }
+        else
+          highest_active_reg = r;
+      }
 
+      /* If just failed to match something this time around with a
+         group that's operated on by a repetition operator, try to
+         force exit from the ``loop'', and restore the register
+         information for this group that we had before trying this
+         last match.  */
+      if ((!MATCHED_SOMETHING (reg_info[*p])
+           || just_past_start_mem == p - 1)
+          && (p + 2) < pend) {
+        boolean is_a_jump_n = false;
+
+        p1 = p + 2;
+        mcnt = 0;
+        switch ((re_opcode_t) * p1++) {
+        case jump_n:
+          is_a_jump_n = true;
+        case pop_failure_jump:
+        case maybe_pop_jump:
+        case jump:
+        case dummy_failure_jump:
+          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+          if (is_a_jump_n)
+            p1 += 2;
+          break;
 
-        /* begline matches the empty string at the beginning of the string
-           (unless `not_bol' is set in `bufp'), and, if
-           `newline_anchor' is set, after newlines.  */
-        case begline:
-          DEBUG_PRINT1 ("EXECUTING begline.\n");
+        default:
+          /* do nothing */ ;
+        }
+        p1 += mcnt;
 
-          if (AT_STRINGS_BEG (d))
-            {
-              if (!bufp->not_bol) break;
-            }
-          else if (d[-1] == '\n' && bufp->newline_anchor)
-            {
-              break;
+        /* If the next operation is a jump backwards in the pattern
+           to an on_failure_jump right before the start_memory
+           corresponding to this stop_memory, exit from the loop
+           by forcing a failure after pushing on the stack the
+           on_failure_jump's jump in the pattern, and d.  */
+        if (mcnt < 0 && (re_opcode_t) * p1 == on_failure_jump
+            && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) {
+          /* If this group ever matched anything, then restore
+             what its registers were before trying this last
+             failed match, e.g., with `(a*)*b' against `ab' for
+             regstart[1], and, e.g., with `((a*)*(b*)*)*'
+             against `aba' for regend[3].
+
+             Also restore the registers for inner groups for,
+             e.g., `((a*)(b*))*' against `aba' (register 3 would
+             otherwise get trashed).  */
+
+          if (EVER_MATCHED_SOMETHING (reg_info[*p])) {
+            unsigned r;
+
+            EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
+
+            /* Restore this and inner groups' (if any) registers.  */
+            for (r = *p; r < (unsigned) *p + (unsigned) *(p + 1); r++) {
+              regstart[r] = old_regstart[r];
+
+              /* xx why this test?  */
+              if (old_regend[r] >= regstart[r])
+                regend[r] = old_regend[r];
             }
-          /* In all other cases, we fail.  */
+          }
+          p1++;
+          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+          PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
+
           goto fail;
+        }
+      }
 
+      /* Move past the register number and the inner group count.  */
+      p += 2;
+      break;
 
-        /* endline is the dual of begline.  */
-        case endline:
-          DEBUG_PRINT1 ("EXECUTING endline.\n");
 
-          if (AT_STRINGS_END (d))
-            {
-              if (!bufp->not_eol) break;
-            }
+      /* \<digit> has been turned into a `duplicate' command which is
+         followed by the numeric value of <digit> as the register number.  */
+    case duplicate:
+      {
+        register const char *d2, *dend2;
+        int regno = *p++;       /* Get which register to match against.  */
 
-          /* We have to ``prefetch'' the next character.  */
-          else if ((d == end1 ? *string2 : *d) == '\n'
-                   && bufp->newline_anchor)
-            {
-              break;
-            }
+        DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
+
+        /* Can't back reference a group which we've never matched.  */
+        if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
           goto fail;
 
+        /* Where in input to try to start matching.  */
+        d2 = regstart[regno];
+
+        /* Where to stop matching; if both the place to start and
+           the place to stop matching are in the same string, then
+           set to the place to stop, otherwise, for now have to use
+           the end of the first string.  */
+
+        dend2 = ((FIRST_STRING_P (regstart[regno])
+                  == FIRST_STRING_P (regend[regno]))
+                 ? regend[regno] : end_match_1);
+        for (;;) {
+          /* If necessary, advance to next segment in register
+             contents.  */
+          while (d2 == dend2) {
+            if (dend2 == end_match_2)
+              break;
+            if (dend2 == regend[regno])
+              break;
 
-        /* Match at the very beginning of the data.  */
-        case begbuf:
-          DEBUG_PRINT1 ("EXECUTING begbuf.\n");
-          if (AT_STRINGS_BEG (d))
+            /* End of string1 => advance to string2. */
+            d2 = string2;
+            dend2 = regend[regno];
+          }
+          /* At end of register contents => success */
+          if (d2 == dend2)
             break;
-          goto fail;
 
+          /* If necessary, advance to next segment in data.  */
+          PREFETCH ();
+
+          /* How many characters left in this segment to match.  */
+          mcnt = dend - d;
+
+          /* Want how many consecutive characters we can match in
+             one shot, so, if necessary, adjust the count.  */
+          if (mcnt > dend2 - d2)
+            mcnt = dend2 - d2;
+
+          /* Compare that many; failure if mismatch, else move
+             past them.  */
+          if (translate ? bcmp_translate (d, d2, mcnt, translate)
+              : bcmp (d, d2, mcnt))
+            goto fail;
+          d += mcnt, d2 += mcnt;
+
+          /* Do this because we've match some characters.  */
+          SET_REGS_MATCHED ();
+        }
+      }
+      break;
+
+
+      /* begline matches the empty string at the beginning of the string
+         (unless `not_bol' is set in `bufp'), and, if
+         `newline_anchor' is set, after newlines.  */
+    case begline:
+      DEBUG_PRINT1 ("EXECUTING begline.\n");
+
+      if (AT_STRINGS_BEG (d)) {
+        if (!bufp->not_bol)
+          break;
+      }
+      else if (d[-1] == '\n' && bufp->newline_anchor) {
+        break;
+      }
+      /* In all other cases, we fail.  */
+      goto fail;
+
+
+      /* endline is the dual of begline.  */
+    case endline:
+      DEBUG_PRINT1 ("EXECUTING endline.\n");
+
+      if (AT_STRINGS_END (d)) {
+        if (!bufp->not_eol)
+          break;
+      }
+
+      /* We have to ``prefetch'' the next character.  */
+      else if ((d == end1 ? *string2 : *d) == '\n' && bufp->newline_anchor) {
+        break;
+      }
+      goto fail;
 
-        /* Match at the very end of the data.  */
-        case endbuf:
-          DEBUG_PRINT1 ("EXECUTING endbuf.\n");
-          if (AT_STRINGS_END (d))
-            break;
-          goto fail;
 
+      /* Match at the very beginning of the data.  */
+    case begbuf:
+      DEBUG_PRINT1 ("EXECUTING begbuf.\n");
+      if (AT_STRINGS_BEG (d))
+        break;
+      goto fail;
 
-        /* on_failure_keep_string_jump is used to optimize `.*\n'.  It
-           pushes NULL as the value for the string on the stack.  Then
-           `pop_failure_point' will keep the current value for the
-           string, instead of restoring it.  To see why, consider
-           matching `foo\nbar' against `.*\n'.  The .* matches the foo;
-           then the . fails against the \n.  But the next thing we want
-           to do is match the \n against the \n; if we restored the
-           string value, we would be back at the foo.
-
-           Because this is used only in specific cases, we don't need to
-           check all the things that `on_failure_jump' does, to make
-           sure the right things get saved on the stack.  Hence we don't
-           share its code.  The only reason to push anything on the
-           stack at all is that otherwise we would have to change
-           `anychar's code to do something besides goto fail in this
-           case; that seems worse than this.  */
-        case on_failure_keep_string_jump:
-          DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
-
-          EXTRACT_NUMBER_AND_INCR (mcnt, p);
+
+      /* Match at the very end of the data.  */
+    case endbuf:
+      DEBUG_PRINT1 ("EXECUTING endbuf.\n");
+      if (AT_STRINGS_END (d))
+        break;
+      goto fail;
+
+
+      /* on_failure_keep_string_jump is used to optimize `.*\n'.  It
+         pushes NULL as the value for the string on the stack.  Then
+         `pop_failure_point' will keep the current value for the
+         string, instead of restoring it.  To see why, consider
+         matching `foo\nbar' against `.*\n'.  The .* matches the foo;
+         then the . fails against the \n.  But the next thing we want
+         to do is match the \n against the \n; if we restored the
+         string value, we would be back at the foo.
+
+         Because this is used only in specific cases, we don't need to
+         check all the things that `on_failure_jump' does, to make
+         sure the right things get saved on the stack.  Hence we don't
+         share its code.  The only reason to push anything on the
+         stack at all is that otherwise we would have to change
+         `anychar's code to do something besides goto fail in this
+         case; that seems worse than this.  */
+    case on_failure_keep_string_jump:
+      DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
+
+      EXTRACT_NUMBER_AND_INCR (mcnt, p);
 #ifdef _LIBC
-          DEBUG_PRINT3 (" %d (to %p):\n", mcnt, p + mcnt);
+      DEBUG_PRINT3 (" %d (to %p):\n", mcnt, p + mcnt);
 #else
-          DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
+      DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
 #endif
 
-          PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
-          break;
+      PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
+      break;
 
 
-        /* Uses of on_failure_jump:
+      /* Uses of on_failure_jump:
 
-           Each alternative starts with an on_failure_jump that points
-           to the beginning of the next alternative.  Each alternative
-           except the last ends with a jump that in effect jumps past
-           the rest of the alternatives.  (They really jump to the
-           ending jump of the following alternative, because tensioning
-           these jumps is a hassle.)
+         Each alternative starts with an on_failure_jump that points
+         to the beginning of the next alternative.  Each alternative
+         except the last ends with a jump that in effect jumps past
+         the rest of the alternatives.  (They really jump to the
+         ending jump of the following alternative, because tensioning
+         these jumps is a hassle.)
 
-           Repeats start with an on_failure_jump that points past both
-           the repetition text and either the following jump or
-           pop_failure_jump back to this on_failure_jump.  */
-        case on_failure_jump:
-        on_failure:
-          DEBUG_PRINT1 ("EXECUTING on_failure_jump");
+         Repeats start with an on_failure_jump that points past both
+         the repetition text and either the following jump or
+         pop_failure_jump back to this on_failure_jump.  */
+    case on_failure_jump:
+    on_failure:
+      DEBUG_PRINT1 ("EXECUTING on_failure_jump");
 
-          EXTRACT_NUMBER_AND_INCR (mcnt, p);
+      EXTRACT_NUMBER_AND_INCR (mcnt, p);
 #ifdef _LIBC
-          DEBUG_PRINT3 (" %d (to %p)", mcnt, p + mcnt);
+      DEBUG_PRINT3 (" %d (to %p)", mcnt, p + mcnt);
 #else
-          DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
+      DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
 #endif
 
-          /* If this on_failure_jump comes right before a group (i.e.,
-             the original * applied to a group), save the information
-             for that group and all inner ones, so that if we fail back
-             to this point, the group's information will be correct.
-             For example, in \(a*\)*\1, we need the preceding group,
-             and in \(zz\(a*\)b*\)\2, we need the inner group.  */
-
-          /* We can't use `p' to check ahead because we push
-             a failure point to `p + mcnt' after we do this.  */
-          p1 = p;
-
-          /* We need to skip no_op's before we look for the
-             start_memory in case this on_failure_jump is happening as
-             the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
-             against aba.  */
-          while (p1 < pend && (re_opcode_t) *p1 == no_op)
-            p1++;
-
-          if (p1 < pend && (re_opcode_t) *p1 == start_memory)
-            {
-              /* We have a new highest active register now.  This will
-                 get reset at the start_memory we are about to get to,
-                 but we will have saved all the registers relevant to
-                 this repetition op, as described above.  */
-              highest_active_reg = *(p1 + 1) + *(p1 + 2);
-              if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
-                lowest_active_reg = *(p1 + 1);
-            }
+      /* If this on_failure_jump comes right before a group (i.e.,
+         the original * applied to a group), save the information
+         for that group and all inner ones, so that if we fail back
+         to this point, the group's information will be correct.
+         For example, in \(a*\)*\1, we need the preceding group,
+         and in \(zz\(a*\)b*\)\2, we need the inner group.  */
+
+      /* We can't use `p' to check ahead because we push
+         a failure point to `p + mcnt' after we do this.  */
+      p1 = p;
+
+      /* We need to skip no_op's before we look for the
+         start_memory in case this on_failure_jump is happening as
+         the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
+         against aba.  */
+      while (p1 < pend && (re_opcode_t) * p1 == no_op)
+        p1++;
+
+      if (p1 < pend && (re_opcode_t) * p1 == start_memory) {
+        /* We have a new highest active register now.  This will
+           get reset at the start_memory we are about to get to,
+           but we will have saved all the registers relevant to
+           this repetition op, as described above.  */
+        highest_active_reg = *(p1 + 1) + *(p1 + 2);
+        if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+          lowest_active_reg = *(p1 + 1);
+      }
 
-          DEBUG_PRINT1 (":\n");
-          PUSH_FAILURE_POINT (p + mcnt, d, -2);
-          break;
+      DEBUG_PRINT1 (":\n");
+      PUSH_FAILURE_POINT (p + mcnt, d, -2);
+      break;
 
 
-        /* A smart repeat ends with `maybe_pop_jump'.
-           We change it to either `pop_failure_jump' or `jump'.  */
-        case maybe_pop_jump:
-          EXTRACT_NUMBER_AND_INCR (mcnt, p);
-          DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
-          {
-            register unsigned char *p2 = p;
-
-            /* Compare the beginning of the repeat with what in the
-               pattern follows its end. If we can establish that there
-               is nothing that they would both match, i.e., that we
-               would have to backtrack because of (as in, e.g., `a*a')
-               then we can change to pop_failure_jump, because we'll
-               never have to backtrack.
-
-               This is not true in the case of alternatives: in
-               `(a|ab)*' we do need to backtrack to the `ab' alternative
-               (e.g., if the string was `ab').  But instead of trying to
-               detect that here, the alternative has put on a dummy
-               failure point which is what we will end up popping.  */
-
-            /* Skip over open/close-group commands.
-               If what follows this loop is a ...+ construct,
-               look at what begins its body, since we will have to
-               match at least one of that.  */
-            while (1)
-              {
-                if (p2 + 2 < pend
-                    && ((re_opcode_t) *p2 == stop_memory
-                        || (re_opcode_t) *p2 == start_memory))
-                  p2 += 3;
-                else if (p2 + 6 < pend
-                         && (re_opcode_t) *p2 == dummy_failure_jump)
-                  p2 += 6;
-                else
-                  break;
-              }
+      /* A smart repeat ends with `maybe_pop_jump'.
+         We change it to either `pop_failure_jump' or `jump'.  */
+    case maybe_pop_jump:
+      EXTRACT_NUMBER_AND_INCR (mcnt, p);
+      DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
+      {
+        register unsigned char *p2 = p;
+
+        /* Compare the beginning of the repeat with what in the
+           pattern follows its end. If we can establish that there
+           is nothing that they would both match, i.e., that we
+           would have to backtrack because of (as in, e.g., `a*a')
+           then we can change to pop_failure_jump, because we'll
+           never have to backtrack.
+
+           This is not true in the case of alternatives: in
+           `(a|ab)*' we do need to backtrack to the `ab' alternative
+           (e.g., if the string was `ab').  But instead of trying to
+           detect that here, the alternative has put on a dummy
+           failure point which is what we will end up popping.  */
+
+        /* Skip over open/close-group commands.
+           If what follows this loop is a ...+ construct,
+           look at what begins its body, since we will have to
+           match at least one of that.  */
+        while (1) {
+          if (p2 + 2 < pend
+              && ((re_opcode_t) * p2 == stop_memory
+                  || (re_opcode_t) * p2 == start_memory))
+            p2 += 3;
+          else if (p2 + 6 < pend && (re_opcode_t) * p2 == dummy_failure_jump)
+            p2 += 6;
+          else
+            break;
+        }
 
-            p1 = p + mcnt;
-            /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
-               to the `maybe_finalize_jump' of this case.  Examine what
-               follows.  */
-
-            /* If we're at the end of the pattern, we can change.  */
-            if (p2 == pend)
-              {
-                /* Consider what happens when matching ":\(.*\)"
-                   against ":/".  I don't really understand this code
-                   yet.  */
-                  p[-3] = (unsigned char) pop_failure_jump;
-                DEBUG_PRINT1
-                  ("  End of pattern: change to `pop_failure_jump'.\n");
-              }
+        p1 = p + mcnt;
+        /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
+           to the `maybe_finalize_jump' of this case.  Examine what
+           follows.  */
+
+        /* If we're at the end of the pattern, we can change.  */
+        if (p2 == pend) {
+          /* Consider what happens when matching ":\(.*\)"
+             against ":/".  I don't really understand this code
+             yet.  */
+          p[-3] = (unsigned char) pop_failure_jump;
+          DEBUG_PRINT1 ("  End of pattern: change to `pop_failure_jump'.\n");
+        }
 
-            else if ((re_opcode_t) *p2 == exactn
-                     || (bufp->newline_anchor && (re_opcode_t) *p2 == endline))
-              {
-                register unsigned char c
-                  = *p2 == (unsigned char) endline ? '\n' : p2[2];
-
-                if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
-                  {
-                      p[-3] = (unsigned char) pop_failure_jump;
-                    DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n",
-                                  c, p1[5]);
-                  }
-
-                else if ((re_opcode_t) p1[3] == charset
-                         || (re_opcode_t) p1[3] == charset_not)
-                  {
-                    int not = (re_opcode_t) p1[3] == charset_not;
-
-                    if (c < (unsigned char) (p1[4] * BYTEWIDTH)
-                        && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
-                      not = !not;
-
-                    /* `not' is equal to 1 if c would match, which means
-                        that we can't change to pop_failure_jump.  */
-                    if (!not)
-                      {
-                          p[-3] = (unsigned char) pop_failure_jump;
-                        DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
-                      }
-                  }
-              }
-            else if ((re_opcode_t) *p2 == charset)
-              {
+        else if ((re_opcode_t) * p2 == exactn
+                 || (bufp->newline_anchor && (re_opcode_t) * p2 == endline)) {
+          register unsigned char c
+            = *p2 == (unsigned char) endline ? '\n' : p2[2];
+
+          if ((re_opcode_t) p1[3] == exactn && p1[5] != c) {
+            p[-3] = (unsigned char) pop_failure_jump;
+            DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n", c, p1[5]);
+          }
+
+          else if ((re_opcode_t) p1[3] == charset
+                   || (re_opcode_t) p1[3] == charset_not) {
+            int not = (re_opcode_t) p1[3] == charset_not;
+
+            if (c < (unsigned char) (p1[4] * BYTEWIDTH)
+                && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+              not = !not;
+
+            /* `not' is equal to 1 if c would match, which means
+               that we can't change to pop_failure_jump.  */
+            if (!not) {
+              p[-3] = (unsigned char) pop_failure_jump;
+              DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
+            }
+          }
+        }
+        else if ((re_opcode_t) * p2 == charset) {
 #ifdef DEBUG
-                register unsigned char c
-                  = *p2 == (unsigned char) endline ? '\n' : p2[2];
+          register unsigned char c
+            = *p2 == (unsigned char) endline ? '\n' : p2[2];
 #endif
 
 #if 0
-                if ((re_opcode_t) p1[3] == exactn
-                    && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
-                          && (p2[2 + p1[5] / BYTEWIDTH]
-                              & (1 << (p1[5] % BYTEWIDTH)))))
+          if ((re_opcode_t) p1[3] == exactn
+              && !((int) p2[1] * BYTEWIDTH > (int) p1[5]
+                   && (p2[2 + p1[5] / BYTEWIDTH]
+                       & (1 << (p1[5] % BYTEWIDTH)))))
 #else
-                if ((re_opcode_t) p1[3] == exactn
-                    && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4]
-                          && (p2[2 + p1[4] / BYTEWIDTH]
-                              & (1 << (p1[4] % BYTEWIDTH)))))
+          if ((re_opcode_t) p1[3] == exactn
+              && !((int) p2[1] * BYTEWIDTH > (int) p1[4]
+                   && (p2[2 + p1[4] / BYTEWIDTH]
+                       & (1 << (p1[4] % BYTEWIDTH)))))
 #endif
-                  {
-                      p[-3] = (unsigned char) pop_failure_jump;
-                    DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n",
-                                  c, p1[5]);
-                  }
-
-                else if ((re_opcode_t) p1[3] == charset_not)
-                  {
-                    int idx;
-                    /* We win if the charset_not inside the loop
-                       lists every character listed in the charset after.  */
-                    for (idx = 0; idx < (int) p2[1]; idx++)
-                      if (! (p2[2 + idx] == 0
-                             || (idx < (int) p1[4]
-                                 && ((p2[2 + idx] & ~ p1[5 + idx]) == 0))))
-                        break;
-
-                    if (idx == p2[1])
-                      {
-                          p[-3] = (unsigned char) pop_failure_jump;
-                        DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
-                      }
-                  }
-                else if ((re_opcode_t) p1[3] == charset)
-                  {
-                    int idx;
-                    /* We win if the charset inside the loop
-                       has no overlap with the one after the loop.  */
-                    for (idx = 0;
-                         idx < (int) p2[1] && idx < (int) p1[4];
-                         idx++)
-                      if ((p2[2 + idx] & p1[5 + idx]) != 0)
-                        break;
-
-                    if (idx == p2[1] || idx == p1[4])
-                      {
-                          p[-3] = (unsigned char) pop_failure_jump;
-                        DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
-                      }
-                  }
-              }
+          {
+            p[-3] = (unsigned char) pop_failure_jump;
+            DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n", c, p1[5]);
           }
-          p -= 2;                /* Point at relative address again.  */
-          if ((re_opcode_t) p[-1] != pop_failure_jump)
-            {
-              p[-1] = (unsigned char) jump;
-              DEBUG_PRINT1 ("  Match => jump.\n");
-              goto unconditional_jump;
-            }
-        /* Note fall through.  */
 
+          else if ((re_opcode_t) p1[3] == charset_not) {
+            int idx;
 
-        /* The end of a simple repeat has a pop_failure_jump back to
-           its matching on_failure_jump, where the latter will push a
-           failure point.  The pop_failure_jump takes off failure
-           points put on by this pop_failure_jump's matching
-           on_failure_jump; we got through the pattern to here from the
-           matching on_failure_jump, so didn't fail.  */
-        case pop_failure_jump:
-          {
-            /* We need to pass separate storage for the lowest and
-               highest registers, even though we don't care about the
-               actual values.  Otherwise, we will restore only one
-               register from the stack, since lowest will == highest in
-               `pop_failure_point'.  */
-            active_reg_t dummy_low_reg, dummy_high_reg;
-            unsigned char *pdummy;
-            const char *sdummy;
-
-            DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
-            POP_FAILURE_POINT (sdummy, pdummy,
-                               dummy_low_reg, dummy_high_reg,
-                               reg_dummy, reg_dummy, reg_info_dummy);
+            /* We win if the charset_not inside the loop
+               lists every character listed in the charset after.  */
+            for (idx = 0; idx < (int) p2[1]; idx++)
+              if (!(p2[2 + idx] == 0 || (idx < (int) p1[4]
+                                         && ((p2[2 + idx] & ~p1[5 + idx]) ==
+                                             0))))
+                break;
+
+            if (idx == p2[1]) {
+              p[-3] = (unsigned char) pop_failure_jump;
+              DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
+            }
+          }
+          else if ((re_opcode_t) p1[3] == charset) {
+            int idx;
+
+            /* We win if the charset inside the loop
+               has no overlap with the one after the loop.  */
+            for (idx = 0; idx < (int) p2[1] && idx < (int) p1[4]; idx++)
+              if ((p2[2 + idx] & p1[5 + idx]) != 0)
+                break;
+
+            if (idx == p2[1] || idx == p1[4]) {
+              p[-3] = (unsigned char) pop_failure_jump;
+              DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
+            }
           }
-          /* Note fall through.  */
+        }
+      }
+      p -= 2;                   /* Point at relative address again.  */
+      if ((re_opcode_t) p[-1] != pop_failure_jump) {
+        p[-1] = (unsigned char) jump;
+        DEBUG_PRINT1 ("  Match => jump.\n");
+        goto unconditional_jump;
+      }
+      /* Note fall through.  */
+
 
-        unconditional_jump:
+      /* The end of a simple repeat has a pop_failure_jump back to
+         its matching on_failure_jump, where the latter will push a
+         failure point.  The pop_failure_jump takes off failure
+         points put on by this pop_failure_jump's matching
+         on_failure_jump; we got through the pattern to here from the
+         matching on_failure_jump, so didn't fail.  */
+    case pop_failure_jump:
+      {
+        /* We need to pass separate storage for the lowest and
+           highest registers, even though we don't care about the
+           actual values.  Otherwise, we will restore only one
+           register from the stack, since lowest will == highest in
+           `pop_failure_point'.  */
+        active_reg_t dummy_low_reg, dummy_high_reg;
+        unsigned char *pdummy;
+        const char *sdummy;
+
+        DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
+        POP_FAILURE_POINT (sdummy, pdummy,
+                           dummy_low_reg, dummy_high_reg,
+                           reg_dummy, reg_dummy, reg_info_dummy);
+      }
+      /* Note fall through.  */
+
+    unconditional_jump:
 #ifdef _LIBC
-          DEBUG_PRINT2 ("\n%p: ", p);
+      DEBUG_PRINT2 ("\n%p: ", p);
 #else
-          DEBUG_PRINT2 ("\n0x%x: ", p);
+      DEBUG_PRINT2 ("\n0x%x: ", p);
 #endif
-          /* Note fall through.  */
+      /* Note fall through.  */
 
-        /* Unconditionally jump (without popping any failure points).  */
-        case jump:
-          EXTRACT_NUMBER_AND_INCR (mcnt, p);        /* Get the amount to jump.  */
-          DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
-          p += mcnt;                                /* Do the jump.  */
+      /* Unconditionally jump (without popping any failure points).  */
+    case jump:
+      EXTRACT_NUMBER_AND_INCR (mcnt, p);        /* Get the amount to jump.  */
+      DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
+      p += mcnt;                /* Do the jump.  */
 #ifdef _LIBC
-          DEBUG_PRINT2 ("(to %p).\n", p);
+      DEBUG_PRINT2 ("(to %p).\n", p);
 #else
-          DEBUG_PRINT2 ("(to 0x%x).\n", p);
+      DEBUG_PRINT2 ("(to 0x%x).\n", p);
 #endif
-          break;
-
-
-        /* We need this opcode so we can detect where alternatives end
-           in `group_match_null_string_p' et al.  */
-        case jump_past_alt:
-          DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
-          goto unconditional_jump;
+      break;
 
 
-        /* Normally, the on_failure_jump pushes a failure point, which
-           then gets popped at pop_failure_jump.  We will end up at
-           pop_failure_jump, also, and with a pattern of, say, `a+', we
-           are skipping over the on_failure_jump, so we have to push
-           something meaningless for pop_failure_jump to pop.  */
-        case dummy_failure_jump:
-          DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
-          /* It doesn't matter what we push for the string here.  What
-             the code at `fail' tests is the value for the pattern.  */
-          PUSH_FAILURE_POINT (0, 0, -2);
-          goto unconditional_jump;
-
-
-        /* At the end of an alternative, we need to push a dummy failure
-           point in case we are followed by a `pop_failure_jump', because
-           we don't want the failure point for the alternative to be
-           popped.  For example, matching `(a|ab)*' against `aab'
-           requires that we match the `ab' alternative.  */
-        case push_dummy_failure:
-          DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
-          /* See comments just above at `dummy_failure_jump' about the
-             two zeroes.  */
-          PUSH_FAILURE_POINT (0, 0, -2);
-          break;
+      /* We need this opcode so we can detect where alternatives end
+         in `group_match_null_string_p' et al.  */
+    case jump_past_alt:
+      DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
+      goto unconditional_jump;
+
+
+      /* Normally, the on_failure_jump pushes a failure point, which
+         then gets popped at pop_failure_jump.  We will end up at
+         pop_failure_jump, also, and with a pattern of, say, `a+', we
+         are skipping over the on_failure_jump, so we have to push
+         something meaningless for pop_failure_jump to pop.  */
+    case dummy_failure_jump:
+      DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
+      /* It doesn't matter what we push for the string here.  What
+         the code at `fail' tests is the value for the pattern.  */
+      PUSH_FAILURE_POINT (0, 0, -2);
+      goto unconditional_jump;
+
+
+      /* At the end of an alternative, we need to push a dummy failure
+         point in case we are followed by a `pop_failure_jump', because
+         we don't want the failure point for the alternative to be
+         popped.  For example, matching `(a|ab)*' against `aab'
+         requires that we match the `ab' alternative.  */
+    case push_dummy_failure:
+      DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
+      /* See comments just above at `dummy_failure_jump' about the
+         two zeroes.  */
+      PUSH_FAILURE_POINT (0, 0, -2);
+      break;
 
-        /* Have to succeed matching what follows at least n times.
-           After that, handle like `on_failure_jump'.  */
-        case succeed_n:
-          EXTRACT_NUMBER (mcnt, p + 2);
-          DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
-
-          assert (mcnt >= 0);
-          /* Originally, this is how many times we HAVE to succeed.  */
-          if (mcnt > 0)
-            {
-               mcnt--;
-               p += 2;
-               STORE_NUMBER_AND_INCR (p, mcnt);
+      /* Have to succeed matching what follows at least n times.
+         After that, handle like `on_failure_jump'.  */
+    case succeed_n:
+      EXTRACT_NUMBER (mcnt, p + 2);
+      DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
+
+      assert (mcnt >= 0);
+      /* Originally, this is how many times we HAVE to succeed.  */
+      if (mcnt > 0) {
+        mcnt--;
+        p += 2;
+        STORE_NUMBER_AND_INCR (p, mcnt);
 #ifdef _LIBC
-               DEBUG_PRINT3 ("  Setting %p to %d.\n", p - 2, mcnt);
+        DEBUG_PRINT3 ("  Setting %p to %d.\n", p - 2, mcnt);
 #else
-               DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p - 2, mcnt);
+        DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p - 2, mcnt);
 #endif
-            }
-          else if (mcnt == 0)
-            {
+      }
+      else if (mcnt == 0) {
 #ifdef _LIBC
-              DEBUG_PRINT2 ("  Setting two bytes from %p to no_op.\n", p+2);
+        DEBUG_PRINT2 ("  Setting two bytes from %p to no_op.\n", p + 2);
 #else
-              DEBUG_PRINT2 ("  Setting two bytes from 0x%x to no_op.\n", p+2);
+        DEBUG_PRINT2 ("  Setting two bytes from 0x%x to no_op.\n", p + 2);
 #endif
-              p[2] = (unsigned char) no_op;
-              p[3] = (unsigned char) no_op;
-              goto on_failure;
-            }
-          break;
+        p[2] = (unsigned char) no_op;
+        p[3] = (unsigned char) no_op;
+        goto on_failure;
+      }
+      break;
 
-        case jump_n:
-          EXTRACT_NUMBER (mcnt, p + 2);
-          DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
-
-          /* Originally, this is how many times we CAN jump.  */
-          if (mcnt)
-            {
-               mcnt--;
-               STORE_NUMBER (p + 2, mcnt);
+    case jump_n:
+      EXTRACT_NUMBER (mcnt, p + 2);
+      DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
+
+      /* Originally, this is how many times we CAN jump.  */
+      if (mcnt) {
+        mcnt--;
+        STORE_NUMBER (p + 2, mcnt);
 #ifdef _LIBC
-               DEBUG_PRINT3 ("  Setting %p to %d.\n", p + 2, mcnt);
+        DEBUG_PRINT3 ("  Setting %p to %d.\n", p + 2, mcnt);
 #else
-               DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p + 2, mcnt);
+        DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p + 2, mcnt);
 #endif
-               goto unconditional_jump;
-            }
-          /* If don't have to jump any more, skip over the rest of command.  */
-          else
-            p += 4;
-          break;
+        goto unconditional_jump;
+      }
+      /* If don't have to jump any more, skip over the rest of command.  */
+      else
+        p += 4;
+      break;
 
-        case set_number_at:
-          {
-            DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
+    case set_number_at:
+      {
+        DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
 
-            EXTRACT_NUMBER_AND_INCR (mcnt, p);
-            p1 = p + mcnt;
-            EXTRACT_NUMBER_AND_INCR (mcnt, p);
+        EXTRACT_NUMBER_AND_INCR (mcnt, p);
+        p1 = p + mcnt;
+        EXTRACT_NUMBER_AND_INCR (mcnt, p);
 #ifdef _LIBC
-            DEBUG_PRINT3 ("  Setting %p to %d.\n", p1, mcnt);
+        DEBUG_PRINT3 ("  Setting %p to %d.\n", p1, mcnt);
 #else
-            DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p1, mcnt);
+        DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p1, mcnt);
 #endif
-            STORE_NUMBER (p1, mcnt);
-            break;
-          }
+        STORE_NUMBER (p1, mcnt);
+        break;
+      }
 
 #if 0
-        /* The DEC Alpha C compiler 3.x generates incorrect code for the
-           test  WORDCHAR_P (d - 1) != WORDCHAR_P (d)  in the expansion of
-           AT_WORD_BOUNDARY, so this code is disabled.  Expanding the
-           macro and introducing temporary variables works around the bug.  */
-
-        case wordbound:
-          DEBUG_PRINT1 ("EXECUTING wordbound.\n");
-          if (AT_WORD_BOUNDARY (d))
-            break;
-          goto fail;
-
-        case notwordbound:
-          DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
-          if (AT_WORD_BOUNDARY (d))
-            goto fail;
-          break;
-#else
-        case wordbound:
-        {
-          boolean prevchar, thischar;
+      /* The DEC Alpha C compiler 3.x generates incorrect code for the
+         test  WORDCHAR_P (d - 1) != WORDCHAR_P (d)  in the expansion of
+         AT_WORD_BOUNDARY, so this code is disabled.  Expanding the
+         macro and introducing temporary variables works around the bug.  */
 
-          DEBUG_PRINT1 ("EXECUTING wordbound.\n");
-          if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
-            break;
-
-          prevchar = WORDCHAR_P (d - 1);
-          thischar = WORDCHAR_P (d);
-          if (prevchar != thischar)
-            break;
-          goto fail;
-        }
+    case wordbound:
+      DEBUG_PRINT1 ("EXECUTING wordbound.\n");
+      if (AT_WORD_BOUNDARY (d))
+        break;
+      goto fail;
 
-      case notwordbound:
-        {
-          boolean prevchar, thischar;
+    case notwordbound:
+      DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
+      if (AT_WORD_BOUNDARY (d))
+        goto fail;
+      break;
+#else
+    case wordbound:
+      {
+        boolean prevchar, thischar;
 
-          DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
-          if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
-            goto fail;
+        DEBUG_PRINT1 ("EXECUTING wordbound.\n");
+        if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
+          break;
 
-          prevchar = WORDCHAR_P (d - 1);
-          thischar = WORDCHAR_P (d);
-          if (prevchar != thischar)
-            goto fail;
+        prevchar = WORDCHAR_P (d - 1);
+        thischar = WORDCHAR_P (d);
+        if (prevchar != thischar)
           break;
-        }
-#endif
+        goto fail;
+      }
 
-        case wordbeg:
-          DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
-          if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
-            break;
+    case notwordbound:
+      {
+        boolean prevchar, thischar;
+
+        DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
+        if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
           goto fail;
 
-        case wordend:
-          DEBUG_PRINT1 ("EXECUTING wordend.\n");
-          if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
-              && (!WORDCHAR_P (d) || AT_STRINGS_END (d)))
-            break;
+        prevchar = WORDCHAR_P (d - 1);
+        thischar = WORDCHAR_P (d);
+        if (prevchar != thischar)
           goto fail;
+        break;
+      }
+#endif
 
-#ifdef emacs
-          case before_dot:
-          DEBUG_PRINT1 ("EXECUTING before_dot.\n");
-           if (PTR_CHAR_POS ((unsigned char *) d) >= point)
-              goto fail;
-            break;
+    case wordbeg:
+      DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
+      if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
+        break;
+      goto fail;
 
-          case at_dot:
-          DEBUG_PRINT1 ("EXECUTING at_dot.\n");
-           if (PTR_CHAR_POS ((unsigned char *) d) != point)
-              goto fail;
-            break;
+    case wordend:
+      DEBUG_PRINT1 ("EXECUTING wordend.\n");
+      if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
+          && (!WORDCHAR_P (d) || AT_STRINGS_END (d)))
+        break;
+      goto fail;
 
-          case after_dot:
-          DEBUG_PRINT1 ("EXECUTING after_dot.\n");
-          if (PTR_CHAR_POS ((unsigned char *) d) <= point)
-              goto fail;
-            break;
+#ifdef emacs
+    case before_dot:
+      DEBUG_PRINT1 ("EXECUTING before_dot.\n");
+      if (PTR_CHAR_POS ((unsigned char *) d) >= point)
+        goto fail;
+      break;
 
-        case syntaxspec:
-          DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
-          mcnt = *p++;
-          goto matchsyntax;
+    case at_dot:
+      DEBUG_PRINT1 ("EXECUTING at_dot.\n");
+      if (PTR_CHAR_POS ((unsigned char *) d) != point)
+        goto fail;
+      break;
 
-        case wordchar:
-          DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
-          mcnt = (int) Sword;
-        matchsyntax:
-          PREFETCH ();
-          /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
-          d++;
-          if (SYNTAX (d[-1]) != (enum syntaxcode) mcnt)
-            goto fail;
-          SET_REGS_MATCHED ();
-          break;
+    case after_dot:
+      DEBUG_PRINT1 ("EXECUTING after_dot.\n");
+      if (PTR_CHAR_POS ((unsigned char *) d) <= point)
+        goto fail;
+      break;
 
-        case notsyntaxspec:
-          DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
-          mcnt = *p++;
-          goto matchnotsyntax;
+    case syntaxspec:
+      DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
+      mcnt = *p++;
+      goto matchsyntax;
+
+    case wordchar:
+      DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
+      mcnt = (int) Sword;
+    matchsyntax:
+      PREFETCH ();
+      /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
+      d++;
+      if (SYNTAX (d[-1]) != (enum syntaxcode) mcnt)
+        goto fail;
+      SET_REGS_MATCHED ();
+      break;
 
-        case notwordchar:
-          DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
-          mcnt = (int) Sword;
-        matchnotsyntax:
-          PREFETCH ();
-          /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
-          d++;
-          if (SYNTAX (d[-1]) == (enum syntaxcode) mcnt)
-            goto fail;
-          SET_REGS_MATCHED ();
-          break;
+    case notsyntaxspec:
+      DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
+      mcnt = *p++;
+      goto matchnotsyntax;
+
+    case notwordchar:
+      DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
+      mcnt = (int) Sword;
+    matchnotsyntax:
+      PREFETCH ();
+      /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
+      d++;
+      if (SYNTAX (d[-1]) == (enum syntaxcode) mcnt)
+        goto fail;
+      SET_REGS_MATCHED ();
+      break;
 
 #else /* not emacs */
-        case wordchar:
-          DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
-          PREFETCH ();
-          if (!WORDCHAR_P (d))
-            goto fail;
-          SET_REGS_MATCHED ();
-          d++;
-          break;
+    case wordchar:
+      DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
+      PREFETCH ();
+      if (!WORDCHAR_P (d))
+        goto fail;
+      SET_REGS_MATCHED ();
+      d++;
+      break;
 
-        case notwordchar:
-          DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
-          PREFETCH ();
-          if (WORDCHAR_P (d))
-            goto fail;
-          SET_REGS_MATCHED ();
-          d++;
-          break;
+    case notwordchar:
+      DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
+      PREFETCH ();
+      if (WORDCHAR_P (d))
+        goto fail;
+      SET_REGS_MATCHED ();
+      d++;
+      break;
 #endif /* not emacs */
 
-        default:
-          abort ();
-        }
-      continue;  /* Successfully executed one pattern command; keep going.  */
+    default:
+      abort ();
+    }
+    continue;                   /* Successfully executed one pattern command; keep going.  */
 
 
     /* We goto here if a matching operation fails. */
-    fail:
-      if (!FAIL_STACK_EMPTY ())
-        { /* A restart point is known.  Restore to that state.  */
-          DEBUG_PRINT1 ("\nFAIL:\n");
-          POP_FAILURE_POINT (d, p,
-                             lowest_active_reg, highest_active_reg,
-                             regstart, regend, reg_info);
-
-          /* If this failure point is a dummy, try the next one.  */
-          if (!p)
-            goto fail;
-
-          /* If we failed to the end of the pattern, don't examine *p.  */
-          assert (p <= pend);
-          if (p < pend)
-            {
-              boolean is_a_jump_n = false;
-
-              /* If failed to a backwards jump that's part of a repetition
-                 loop, need to pop this failure point and use the next one.  */
-              switch ((re_opcode_t) *p)
-                {
-                case jump_n:
-                  is_a_jump_n = true;
-                case maybe_pop_jump:
-                case pop_failure_jump:
-                case jump:
-                  p1 = p + 1;
-                  EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-                  p1 += mcnt;
-
-                  if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
-                      || (!is_a_jump_n
-                          && (re_opcode_t) *p1 == on_failure_jump))
-                    goto fail;
-                  break;
-                default:
-                  /* do nothing */ ;
-                }
-            }
+  fail:
+    if (!FAIL_STACK_EMPTY ()) { /* A restart point is known.  Restore to that state.  */
+      DEBUG_PRINT1 ("\nFAIL:\n");
+      POP_FAILURE_POINT (d, p,
+                         lowest_active_reg, highest_active_reg,
+                         regstart, regend, reg_info);
+
+      /* If this failure point is a dummy, try the next one.  */
+      if (!p)
+        goto fail;
+
+      /* If we failed to the end of the pattern, don't examine *p.  */
+      assert (p <= pend);
+      if (p < pend) {
+        boolean is_a_jump_n = false;
+
+        /* If failed to a backwards jump that's part of a repetition
+           loop, need to pop this failure point and use the next one.  */
+        switch ((re_opcode_t) * p) {
+        case jump_n:
+          is_a_jump_n = true;
+        case maybe_pop_jump:
+        case pop_failure_jump:
+        case jump:
+          p1 = p + 1;
+          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+          p1 += mcnt;
 
-          if (d >= string1 && d <= end1)
-            dend = end_match_1;
+          if ((is_a_jump_n && (re_opcode_t) * p1 == succeed_n)
+              || (!is_a_jump_n && (re_opcode_t) * p1 == on_failure_jump))
+            goto fail;
+          break;
+        default:
+          /* do nothing */ ;
         }
-      else
-        break;   /* Matching at this starting point really fails.  */
-    } /* for (;;) */
+      }
+
+      if (d >= string1 && d <= end1)
+        dend = end_match_1;
+    }
+    else
+      break;                    /* Matching at this starting point really fails.  */
+  }                             /* for (;;) */
 
   if (best_regs_set)
     goto restore_best_regs;
 
   FREE_VARIABLES ();
 
-  return -1;                                 /* Failure to match.  */
-} /* re_match_2 */
+  return -1;                    /* Failure to match.  */
+}                               /* re_match_2 */
 \f
 /* Subroutine definitions for re_match_2.  */
 
@@ -5208,145 +5067,136 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
 
    We don't handle duplicates properly (yet).  */
 
-static boolean
-group_match_null_string_p (p, end, reg_info)
-    unsigned char **p, *end;
-    register_info_type *reg_info;
+static boolean group_match_null_string_p (p, end, reg_info)
+     unsigned char **p, *end;
+     register_info_type *reg_info;
 {
   int mcnt;
+
   /* Point to after the args to the start_memory.  */
   unsigned char *p1 = *p + 2;
 
-  while (p1 < end)
-    {
-      /* Skip over opcodes that can match nothing, and return true or
-         false, as appropriate, when we get to one that can't, or to the
-         matching stop_memory.  */
+  while (p1 < end) {
+    /* Skip over opcodes that can match nothing, and return true or
+       false, as appropriate, when we get to one that can't, or to the
+       matching stop_memory.  */
 
-      switch ((re_opcode_t) *p1)
-        {
-        /* Could be either a loop or a series of alternatives.  */
-        case on_failure_jump:
-          p1++;
-          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+    switch ((re_opcode_t) * p1) {
+      /* Could be either a loop or a series of alternatives.  */
+    case on_failure_jump:
+      p1++;
+      EXTRACT_NUMBER_AND_INCR (mcnt, p1);
 
-          /* If the next operation is not a jump backwards in the
-             pattern.  */
-
-          if (mcnt >= 0)
-            {
-              /* Go through the on_failure_jumps of the alternatives,
-                 seeing if any of the alternatives cannot match nothing.
-                 The last alternative starts with only a jump,
-                 whereas the rest start with on_failure_jump and end
-                 with a jump, e.g., here is the pattern for `a|b|c':
-
-                 /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
-                 /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
-                 /exactn/1/c
-
-                 So, we have to first go through the first (n-1)
-                 alternatives and then deal with the last one separately.  */
-
-
-              /* Deal with the first (n-1) alternatives, which start
-                 with an on_failure_jump (see above) that jumps to right
-                 past a jump_past_alt.  */
-
-              while ((re_opcode_t) p1[mcnt-3] == jump_past_alt)
-                {
-                  /* `mcnt' holds how many bytes long the alternative
-                     is, including the ending `jump_past_alt' and
-                     its number.  */
-
-                  if (!alt_match_null_string_p (p1, p1 + mcnt - 3,
-                                                      reg_info))
-                    return false;
-
-                  /* Move to right after this alternative, including the
-                     jump_past_alt.  */
-                  p1 += mcnt;
-
-                  /* Break if it's the beginning of an n-th alternative
-                     that doesn't begin with an on_failure_jump.  */
-                  if ((re_opcode_t) *p1 != on_failure_jump)
-                    break;
-
-                  /* Still have to check that it's not an n-th
-                     alternative that starts with an on_failure_jump.  */
-                  p1++;
-                  EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-                  if ((re_opcode_t) p1[mcnt-3] != jump_past_alt)
-                    {
-                      /* Get to the beginning of the n-th alternative.  */
-                      p1 -= 3;
-                      break;
-                    }
-                }
-
-              /* Deal with the last alternative: go back and get number
-                 of the `jump_past_alt' just before it.  `mcnt' contains
-                 the length of the alternative.  */
-              EXTRACT_NUMBER (mcnt, p1 - 2);
-
-              if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info))
-                return false;
-
-              p1 += mcnt;        /* Get past the n-th alternative.  */
-            } /* if mcnt > 0 */
-          break;
+      /* If the next operation is not a jump backwards in the
+         pattern.  */
 
+      if (mcnt >= 0) {
+        /* Go through the on_failure_jumps of the alternatives,
+           seeing if any of the alternatives cannot match nothing.
+           The last alternative starts with only a jump,
+           whereas the rest start with on_failure_jump and end
+           with a jump, e.g., here is the pattern for `a|b|c':
 
-        case stop_memory:
-          assert (p1[1] == **p);
-          *p = p1 + 2;
-          return true;
+           /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
+           /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
+           /exactn/1/c
 
+           So, we have to first go through the first (n-1)
+           alternatives and then deal with the last one separately.  */
 
-        default:
-          if (!common_op_match_null_string_p (&p1, end, reg_info))
+
+        /* Deal with the first (n-1) alternatives, which start
+           with an on_failure_jump (see above) that jumps to right
+           past a jump_past_alt.  */
+
+        while ((re_opcode_t) p1[mcnt - 3] == jump_past_alt) {
+          /* `mcnt' holds how many bytes long the alternative
+             is, including the ending `jump_past_alt' and
+             its number.  */
+
+          if (!alt_match_null_string_p (p1, p1 + mcnt - 3, reg_info))
             return false;
+
+          /* Move to right after this alternative, including the
+             jump_past_alt.  */
+          p1 += mcnt;
+
+          /* Break if it's the beginning of an n-th alternative
+             that doesn't begin with an on_failure_jump.  */
+          if ((re_opcode_t) * p1 != on_failure_jump)
+            break;
+
+          /* Still have to check that it's not an n-th
+             alternative that starts with an on_failure_jump.  */
+          p1++;
+          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+          if ((re_opcode_t) p1[mcnt - 3] != jump_past_alt) {
+            /* Get to the beginning of the n-th alternative.  */
+            p1 -= 3;
+            break;
+          }
         }
-    } /* while p1 < end */
+
+        /* Deal with the last alternative: go back and get number
+           of the `jump_past_alt' just before it.  `mcnt' contains
+           the length of the alternative.  */
+        EXTRACT_NUMBER (mcnt, p1 - 2);
+
+        if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info))
+          return false;
+
+        p1 += mcnt;             /* Get past the n-th alternative.  */
+      }                         /* if mcnt > 0 */
+      break;
+
+
+    case stop_memory:
+      assert (p1[1] == **p);
+      *p = p1 + 2;
+      return true;
+
+
+    default:
+      if (!common_op_match_null_string_p (&p1, end, reg_info))
+        return false;
+    }
+  }                             /* while p1 < end */
 
   return false;
-} /* group_match_null_string_p */
+}                               /* group_match_null_string_p */
 
 
 /* Similar to group_match_null_string_p, but doesn't deal with alternatives:
    It expects P to be the first byte of a single alternative and END one
    byte past the last. The alternative can contain groups.  */
 
-static boolean
-alt_match_null_string_p (p, end, reg_info)
-    unsigned char *p, *end;
-    register_info_type *reg_info;
+static boolean alt_match_null_string_p (p, end, reg_info)
+     unsigned char *p, *end;
+     register_info_type *reg_info;
 {
   int mcnt;
   unsigned char *p1 = p;
 
-  while (p1 < end)
-    {
-      /* Skip over opcodes that can match nothing, and break when we get
-         to one that can't.  */
+  while (p1 < end) {
+    /* Skip over opcodes that can match nothing, and break when we get
+       to one that can't.  */
 
-      switch ((re_opcode_t) *p1)
-        {
-        /* It's a loop.  */
-        case on_failure_jump:
-          p1++;
-          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-          p1 += mcnt;
-          break;
+    switch ((re_opcode_t) * p1) {
+      /* It's a loop.  */
+    case on_failure_jump:
+      p1++;
+      EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+      p1 += mcnt;
+      break;
 
-        default:
-          if (!common_op_match_null_string_p (&p1, end, reg_info))
-            return false;
-        }
-    }  /* while p1 < end */
+    default:
+      if (!common_op_match_null_string_p (&p1, end, reg_info))
+        return false;
+    }
+  }                             /* while p1 < end */
 
   return true;
-} /* alt_match_null_string_p */
+}                               /* alt_match_null_string_p */
 
 
 /* Deals with the ops common to group_match_null_string_p and
@@ -5354,107 +5204,104 @@ alt_match_null_string_p (p, end, reg_info)
 
    Sets P to one after the op and its arguments, if any.  */
 
-static boolean
-common_op_match_null_string_p (p, end, reg_info)
-    unsigned char **p, *end;
-    register_info_type *reg_info;
+static boolean common_op_match_null_string_p (p, end, reg_info)
+     unsigned char **p, *end;
+     register_info_type *reg_info;
 {
   int mcnt;
   boolean ret;
   int reg_no;
   unsigned char *p1 = *p;
 
-  switch ((re_opcode_t) *p1++)
-    {
-    case no_op:
-    case begline:
-    case endline:
-    case begbuf:
-    case endbuf:
-    case wordbeg:
-    case wordend:
-    case wordbound:
-    case notwordbound:
+  switch ((re_opcode_t) * p1++) {
+  case no_op:
+  case begline:
+  case endline:
+  case begbuf:
+  case endbuf:
+  case wordbeg:
+  case wordend:
+  case wordbound:
+  case notwordbound:
 #ifdef emacs
-    case before_dot:
-    case at_dot:
-    case after_dot:
+  case before_dot:
+  case at_dot:
+  case after_dot:
 #endif
-      break;
+    break;
 
-    case start_memory:
-      reg_no = *p1;
-      assert (reg_no > 0 && reg_no <= MAX_REGNUM);
-      ret = group_match_null_string_p (&p1, end, reg_info);
+  case start_memory:
+    reg_no = *p1;
+    assert (reg_no > 0 && reg_no <= MAX_REGNUM);
+    ret = group_match_null_string_p (&p1, end, reg_info);
 
-      /* Have to set this here in case we're checking a group which
-         contains a group and a back reference to it.  */
+    /* Have to set this here in case we're checking a group which
+       contains a group and a back reference to it.  */
 
-      if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
-        REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;
+    if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
+      REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;
 
-      if (!ret)
-        return false;
-      break;
+    if (!ret)
+      return false;
+    break;
 
     /* If this is an optimized succeed_n for zero times, make the jump.  */
-    case jump:
-      EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-      if (mcnt >= 0)
-        p1 += mcnt;
-      else
-        return false;
-      break;
+  case jump:
+    EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+    if (mcnt >= 0)
+      p1 += mcnt;
+    else
+      return false;
+    break;
 
-    case succeed_n:
-      /* Get to the number of times to succeed.  */
-      p1 += 2;
-      EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+  case succeed_n:
+    /* Get to the number of times to succeed.  */
+    p1 += 2;
+    EXTRACT_NUMBER_AND_INCR (mcnt, p1);
 
-      if (mcnt == 0)
-        {
-          p1 -= 4;
-          EXTRACT_NUMBER_AND_INCR (mcnt, p1);
-          p1 += mcnt;
-        }
-      else
-        return false;
-      break;
+    if (mcnt == 0) {
+      p1 -= 4;
+      EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+      p1 += mcnt;
+    }
+    else
+      return false;
+    break;
 
-    case duplicate:
-      if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
-        return false;
-      break;
+  case duplicate:
+    if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
+      return false;
+    break;
 
-    case set_number_at:
-      p1 += 4;
+  case set_number_at:
+    p1 += 4;
 
-    default:
-      /* All other opcodes mean we cannot match the empty string.  */
-      return false;
+  default:
+    /* All other opcodes mean we cannot match the empty string.  */
+    return false;
   }
 
   *p = p1;
   return true;
-} /* common_op_match_null_string_p */
+}                               /* common_op_match_null_string_p */
 
 
 /* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
    bytes; nonzero otherwise.  */
 
-static int
-bcmp_translate (s1, s2, len, translate)
+static int bcmp_translate (s1, s2, len, translate)
      const char *s1, *s2;
      register int len;
      RE_TRANSLATE_TYPE translate;
 {
   register const unsigned char *p1 = (const unsigned char *) s1;
   register const unsigned char *p2 = (const unsigned char *) s2;
-  while (len)
-    {
-      if (translate[*p1++] != translate[*p2++]) return 1;
-      len--;
-    }
+
+  while (len) {
+    if (translate[*p1++] != translate[*p2++])
+      return 1;
+    len--;
+  }
   return 0;
 }
 \f
@@ -5469,8 +5316,7 @@ bcmp_translate (s1, s2, len, translate)
 
    We call regex_compile to do the actual compilation.  */
 
-const char *
-re_compile_pattern (pattern, length, bufp)
+const char *re_compile_pattern (pattern, length, bufp)
      const char *pattern;
      size_t length;
      struct re_pattern_buffer *bufp;
@@ -5509,31 +5355,29 @@ char *
 /* Make these definitions weak in libc, so POSIX programs can redefine
    these names if they don't use our functions, and still use
    regcomp/regexec below without link errors.  */
-weak_function
+     weak_function
 #endif
 re_comp (s)
-    const char *s;
+     const char *s;
 {
   reg_errcode_t ret;
 
-  if (!s)
-    {
-      if (!re_comp_buf.buffer)
-        return gettext ("No previous regular expression");
-      return 0;
-    }
+  if (!s) {
+    if (!re_comp_buf.buffer)
+      return gettext ("No previous regular expression");
+    return 0;
+  }
 
-  if (!re_comp_buf.buffer)
-    {
-      re_comp_buf.buffer = (unsigned char *) malloc (200);        /* __MEM_CHECKED__ */
-      if (re_comp_buf.buffer == NULL)
-        return gettext (re_error_msgid[(int) REG_ESPACE]);
-      re_comp_buf.allocated = 200;
+  if (!re_comp_buf.buffer) {
+    re_comp_buf.buffer = (unsigned char *) malloc (200);        /* __MEM_CHECKED__ */
+    if (re_comp_buf.buffer == NULL)
+      return gettext (re_error_msgid[(int) REG_ESPACE]);
+    re_comp_buf.allocated = 200;
 
-      re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);        /* __MEM_CHECKED__ */
-      if (re_comp_buf.fastmap == NULL)
-        return gettext (re_error_msgid[(int) REG_ESPACE]);
-    }
+    re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);     /* __MEM_CHECKED__ */
+    if (re_comp_buf.fastmap == NULL)
+      return gettext (re_error_msgid[(int) REG_ESPACE]);
+  }
 
   /* Since `re_exec' always passes NULL for the `regs' argument, we
      don't need to initialize the pattern buffer fields which affect it.  */
@@ -5553,12 +5397,13 @@ re_comp (s)
 
 int
 #ifdef _LIBC
-weak_function
+    weak_function
 #endif
 re_exec (s)
-    const char *s;
+     const char *s;
 {
   const int len = strlen (s);
+
   return
     0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
 }
@@ -5603,16 +5448,15 @@ re_exec (s)
    It returns 0 if it succeeds, nonzero if it doesn't.  (See regex.h for
    the return codes and their meanings.)  */
 
-int
-regcomp (preg, pattern, cflags)
-    regex_t *preg;
-    const char *pattern;
-    int cflags;
+int regcomp (preg, pattern, cflags)
+     regex_t *preg;
+     const char *pattern;
+     int cflags;
 {
   reg_errcode_t ret;
   reg_syntax_t syntax
     = (cflags & REG_EXTENDED) ?
-      RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
+    RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
 
   /* regex_compile will allocate the space for the compiled pattern.  */
   preg->buffer = 0;
@@ -5625,31 +5469,30 @@ regcomp (preg, pattern, cflags)
      every character.  */
   preg->fastmap = 0;
 
-  if (cflags & REG_ICASE)
-    {
-      unsigned i;
+  if (cflags & REG_ICASE) {
+    unsigned i;
 
-      preg->translate
-        = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE        /* __MEM_CHECKED__ */
-                                      * sizeof (*(RE_TRANSLATE_TYPE)0));
-      if (preg->translate == NULL)
-        return (int) REG_ESPACE;
+    preg->translate = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE /* __MEM_CHECKED__ */
+                                                  *
+                                                  sizeof (*(RE_TRANSLATE_TYPE)
+                                                          0));
+    if (preg->translate == NULL)
+      return (int) REG_ESPACE;
 
-      /* Map uppercase characters to corresponding lowercase ones.  */
-      for (i = 0; i < CHAR_SET_SIZE; i++)
-        preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
-    }
+    /* Map uppercase characters to corresponding lowercase ones.  */
+    for (i = 0; i < CHAR_SET_SIZE; i++)
+      preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
+  }
   else
     preg->translate = NULL;
 
   /* If REG_NEWLINE is set, newlines are treated differently.  */
-  if (cflags & REG_NEWLINE)
-    { /* REG_NEWLINE implies neither . nor [^...] match newline.  */
-      syntax &= ~RE_DOT_NEWLINE;
-      syntax |= RE_HAT_LISTS_NOT_NEWLINE;
-      /* It also changes the matching behavior.  */
-      preg->newline_anchor = 1;
-    }
+  if (cflags & REG_NEWLINE) {   /* REG_NEWLINE implies neither . nor [^...] match newline.  */
+    syntax &= ~RE_DOT_NEWLINE;
+    syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+    /* It also changes the matching behavior.  */
+    preg->newline_anchor = 1;
+  }
   else
     preg->newline_anchor = 0;
 
@@ -5661,7 +5504,8 @@ regcomp (preg, pattern, cflags)
 
   /* POSIX doesn't distinguish between an unmatched open-group and an
      unmatched close-group: both are REG_EPAREN.  */
-  if (ret == REG_ERPAREN) ret = REG_EPAREN;
+  if (ret == REG_ERPAREN)
+    ret = REG_EPAREN;
 
   return (int) ret;
 }
@@ -5681,13 +5525,12 @@ regcomp (preg, pattern, cflags)
 
    We return 0 if we find a match and REG_NOMATCH if not.  */
 
-int
-regexec (preg, string, nmatch, pmatch, eflags)
-    const regex_t *preg;
-    const char *string;
-    size_t nmatch;
-    regmatch_t pmatch[];
-    int eflags;
+int regexec (preg, string, nmatch, pmatch, eflags)
+     const regex_t *preg;
+     const char *string;
+     size_t nmatch;
+     regmatch_t pmatch[];
+     int eflags;
 {
   int ret;
   struct re_registers regs;
@@ -5705,14 +5548,13 @@ regexec (preg, string, nmatch, pmatch, eflags)
      matching routines.  */
   private_preg.regs_allocated = REGS_FIXED;
 
-  if (want_reg_info)
-    {
-      regs.num_regs = nmatch;
-      regs.start = TALLOC (nmatch, regoff_t);
-      regs.end = TALLOC (nmatch, regoff_t);
-      if (regs.start == NULL || regs.end == NULL)
-        return (int) REG_NOMATCH;
-    }
+  if (want_reg_info) {
+    regs.num_regs = nmatch;
+    regs.start = TALLOC (nmatch, regoff_t);
+    regs.end = TALLOC (nmatch, regoff_t);
+    if (regs.start == NULL || regs.end == NULL)
+      return (int) REG_NOMATCH;
+  }
 
   /* Perform the searching operation.  */
   ret = re_search (&private_preg, string, len,
@@ -5720,24 +5562,21 @@ regexec (preg, string, nmatch, pmatch, eflags)
                    want_reg_info ? &regs : (struct re_registers *) 0);
 
   /* Copy the register information to the POSIX structure.  */
-  if (want_reg_info)
-    {
-      if (ret >= 0)
-        {
-          unsigned r;
-
-          for (r = 0; r < nmatch; r++)
-            {
-              pmatch[r].rm_so = regs.start[r];
-              pmatch[r].rm_eo = regs.end[r];
-            }
-        }
+  if (want_reg_info) {
+    if (ret >= 0) {
+      unsigned r;
 
-      /* If we needed the temporary register info, free the space now.  */
-      free (regs.start);        /* __MEM_CHECKED__ */
-      free (regs.end);                /* __MEM_CHECKED__ */
+      for (r = 0; r < nmatch; r++) {
+        pmatch[r].rm_so = regs.start[r];
+        pmatch[r].rm_eo = regs.end[r];
+      }
     }
 
+    /* If we needed the temporary register info, free the space now.  */
+    free (regs.start);          /* __MEM_CHECKED__ */
+    free (regs.end);            /* __MEM_CHECKED__ */
+  }
+
   /* We want zero return to mean success, unlike `re_search'.  */
   return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
 }
@@ -5746,19 +5585,17 @@ regexec (preg, string, nmatch, pmatch, eflags)
 /* Returns a message corresponding to an error code, ERRCODE, returned
    from either regcomp or regexec.   We don't use PREG here.  */
 
-size_t
-regerror (errcode, preg, errbuf, errbuf_size)
-    int errcode;
-    const regex_t *preg;
-    char *errbuf;
-    size_t errbuf_size;
+size_t regerror (errcode, preg, errbuf, errbuf_size)
+     int errcode;
+     const regex_t *preg;
+     char *errbuf;
+     size_t errbuf_size;
 {
   const char *msg;
   size_t msg_size;
 
-  if (errcode < 0
-      || errcode >= (int) (sizeof (re_error_msgid)
-                           / sizeof (re_error_msgid[0])))
+  if (errcode < 0 || errcode >= (int) (sizeof (re_error_msgid)
+                                       / sizeof (re_error_msgid[0])))
     /* Only error codes returned by the rest of the code should be passed
        to this routine.  If we are given anything else, or if other regex
        code generates an invalid error code, then the program has a bug.
@@ -5767,18 +5604,16 @@ regerror (errcode, preg, errbuf, errbuf_size)
 
   msg = gettext (re_error_msgid[errcode]);
 
-  msg_size = strlen (msg) + 1; /* Includes the null.  */
+  msg_size = strlen (msg) + 1;  /* Includes the null.  */
 
-  if (errbuf_size != 0)
-    {
-      if (msg_size > errbuf_size)
-        {
-          strncpy (errbuf, msg, errbuf_size - 1);
-          errbuf[errbuf_size - 1] = 0;
-        }
-      else
-        strcpy (errbuf, msg);        /* __STRCPY_CHECKED__ */
+  if (errbuf_size != 0) {
+    if (msg_size > errbuf_size) {
+      strncpy (errbuf, msg, errbuf_size - 1);
+      errbuf[errbuf_size - 1] = 0;
     }
+    else
+      strcpy (errbuf, msg);     /* __STRCPY_CHECKED__ */
+  }
 
   return msg_size;
 }
@@ -5786,9 +5621,8 @@ regerror (errcode, preg, errbuf, errbuf_size)
 
 /* Free dynamically allocated space used by PREG.  */
 
-void
-regfree (preg)
-    regex_t *preg;
+void regfree (preg)
+     regex_t *preg;
 {
   if (preg->buffer != NULL)
     free (preg->buffer);        /* __MEM_CHECKED__ */
@@ -5798,12 +5632,12 @@ regfree (preg)
   preg->used = 0;
 
   if (preg->fastmap != NULL)
-    free (preg->fastmap);        /* __MEM_CHECKED__ */
+    free (preg->fastmap);       /* __MEM_CHECKED__ */
   preg->fastmap = NULL;
   preg->fastmap_accurate = 0;
 
   if (preg->translate != NULL)
-    free (preg->translate);        /* __MEM_CHECKED__ */
+    free (preg->translate);     /* __MEM_CHECKED__ */
   preg->translate = NULL;
 }
 
index ec8e98a..5d68c73 100644 (file)
@@ -17,7 +17,7 @@
  *     License along with this program; if not, write to the Free
  *     Software Foundation, Inc., 59 Temple Place - Suite 330,
  *     Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * Mixmaster support for Mutt
 
 #ifdef MIXMASTER
 
-struct coord
-{
+struct coord {
   short r, c;
 };
 
-static REMAILER **mix_type2_list (size_t *l);
+static REMAILER **mix_type2_list (size_t * l);
 static REMAILER *mix_new_remailer (void);
-static const char *mix_format_caps (REMAILER *r);
-static int mix_chain_add (MIXCHAIN *chain, const char *s, REMAILER **type2_list);
+static const char *mix_format_caps (REMAILER * r);
+static int mix_chain_add (MIXCHAIN * chain, const char *s,
+                          REMAILER ** type2_list);
 static int mix_get_caps (const char *capstr);
 static void mix_add_entry (REMAILER ***, REMAILER *, size_t *, size_t *);
-static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num);
-static void mix_free_remailer (REMAILER **r);
-static void mix_free_type2_list (REMAILER ***ttlp);
-static void mix_redraw_ce (REMAILER **type2_list, struct coord *coords, MIXCHAIN *chain, int i, short selected);
-static void mix_redraw_chain (REMAILER **type2_list, struct coord *coords, MIXCHAIN *chain, int cur);
+static void mix_entry (char *b, size_t blen, MUTTMENU * menu, int num);
+static void mix_free_remailer (REMAILER ** r);
+static void mix_free_type2_list (REMAILER *** ttlp);
+static void mix_redraw_ce (REMAILER ** type2_list, struct coord *coords,
+                           MIXCHAIN * chain, int i, short selected);
+static void mix_redraw_chain (REMAILER ** type2_list, struct coord *coords,
+                              MIXCHAIN * chain, int cur);
 static void mix_redraw_head (MIXCHAIN *);
-static void mix_screen_coordinates (REMAILER **type2_list, struct coord **, MIXCHAIN *, int);
+static void mix_screen_coordinates (REMAILER ** type2_list, struct coord **,
+                                    MIXCHAIN *, int);
 
 static int mix_get_caps (const char *capstr)
 {
   int caps = 0;
 
-  while (*capstr)
-  {
-    switch (*capstr)
-    {
-      case 'C':
-       caps |= MIX_CAP_COMPRESS;
-        break;
-      
-      case 'M':
-        caps |= MIX_CAP_MIDDLEMAN;
-        break;
-      
-      case 'N':
+  while (*capstr) {
+    switch (*capstr) {
+    case 'C':
+      caps |= MIX_CAP_COMPRESS;
+      break;
+
+    case 'M':
+      caps |= MIX_CAP_MIDDLEMAN;
+      break;
+
+    case 'N':
       {
-       switch (*++capstr)
-       {
-         case 'm':
-           caps |= MIX_CAP_NEWSMAIL;
-           break;
-         
-         case 'p':
-           caps |= MIX_CAP_NEWSPOST;
-           break;
-         
-       }
+        switch (*++capstr) {
+        case 'm':
+          caps |= MIX_CAP_NEWSMAIL;
+          break;
+
+        case 'p':
+          caps |= MIX_CAP_NEWSPOST;
+          break;
+
+        }
       }
     }
-    
-    if (*capstr) capstr++;
+
+    if (*capstr)
+      capstr++;
   }
-  
+
   return caps;
 }
 
-static void mix_add_entry (REMAILER ***type2_list, REMAILER *entry,
-                          size_t *slots, size_t *used)
+static void mix_add_entry (REMAILER *** type2_list, REMAILER * entry,
+                           size_t * slots, size_t * used)
 {
-  if (*used == *slots)
-  {
+  if (*used == *slots) {
     *slots += 5;
     safe_realloc (type2_list, sizeof (REMAILER *) * (*slots));
   }
-  
+
   (*type2_list)[(*used)++] = entry;
-  if (entry) entry->num = *used;
+  if (entry)
+    entry->num = *used;
 }
 
 static REMAILER *mix_new_remailer (void)
@@ -120,18 +121,18 @@ static REMAILER *mix_new_remailer (void)
   return safe_calloc (1, sizeof (REMAILER));
 }
 
-static void mix_free_remailer (REMAILER **r)
+static void mix_free_remailer (REMAILER ** r)
 {
   FREE (&(*r)->shortname);
   FREE (&(*r)->addr);
   FREE (&(*r)->ver);
-  
+
   FREE (r);
 }
 
 /* parse the type2.list as given by mixmaster -T */
 
-static REMAILER **mix_type2_list (size_t *l)
+static REMAILER **mix_type2_list (size_t * l)
 {
   FILE *fp;
   pid_t mm_pid;
@@ -140,44 +141,44 @@ static REMAILER **mix_type2_list (size_t *l)
   char cmd[HUGE_STRING + _POSIX_PATH_MAX];
   char line[HUGE_STRING];
   char *t;
-  
+
   REMAILER **type2_list = NULL, *p;
   size_t slots = 0, used = 0;
 
   if (!l)
     return NULL;
-  
+
   if ((devnull = open ("/dev/null", O_RDWR)) == -1)
     return NULL;
-  
+
   snprintf (cmd, sizeof (cmd), "%s -T", Mixmaster);
-  
-  if ((mm_pid = mutt_create_filter_fd (cmd, NULL, &fp, NULL, devnull, -1, devnull)) == -1)
-  {
+
+  if ((mm_pid =
+       mutt_create_filter_fd (cmd, NULL, &fp, NULL, devnull, -1,
+                              devnull)) == -1) {
     close (devnull);
     return NULL;
   }
 
   /* first, generate the "random" remailer */
-  
+
   p = mix_new_remailer ();
   p->shortname = safe_strdup ("<random>");
   mix_add_entry (&type2_list, p, &slots, &used);
-  
-  while (fgets (line, sizeof (line), fp))
-  {
+
+  while (fgets (line, sizeof (line), fp)) {
     p = mix_new_remailer ();
-    
+
     if (!(t = strtok (line, " \t\n")))
       goto problem;
-    
+
     p->shortname = safe_strdup (t);
-    
+
     if (!(t = strtok (NULL, " \t\n")))
       goto problem;
 
     p->addr = safe_strdup (t);
-    
+
     if (!(t = strtok (NULL, " \t\n")))
       goto problem;
 
@@ -185,37 +186,37 @@ static REMAILER **mix_type2_list (size_t *l)
       goto problem;
 
     p->ver = safe_strdup (t);
-    
+
     if (!(t = strtok (NULL, " \t\n")))
       goto problem;
 
     p->caps = mix_get_caps (t);
-    
+
     mix_add_entry (&type2_list, p, &slots, &used);
     continue;
-    
-    problem:
+
+  problem:
     mix_free_remailer (&p);
   }
-  
+
   *l = used;
 
   mix_add_entry (&type2_list, NULL, &slots, &used);
   mutt_wait_filter (mm_pid);
 
   close (devnull);
-  
+
   return type2_list;
 }
 
-static void mix_free_type2_list (REMAILER ***ttlp)
+static void mix_free_type2_list (REMAILER *** ttlp)
 {
   int i;
   REMAILER **type2_list = *ttlp;
-  
+
   for (i = 0; type2_list[i]; i++)
     mix_free_remailer (&type2_list[i]);
-  
+
   FREE (type2_list);
 }
 
@@ -225,68 +226,61 @@ static void mix_free_type2_list (REMAILER ***ttlp)
 #define MIX_MAXROW  (LINES - 3)
 
 
-static void mix_screen_coordinates (REMAILER **type2_list,
-                                   struct coord **coordsp,
-                                   MIXCHAIN *chain,
-                                   int i)
+static void mix_screen_coordinates (REMAILER ** type2_list,
+                                    struct coord **coordsp,
+                                    MIXCHAIN * chain, int i)
 {
   short c, r, oc;
   struct coord *coords;
 
   if (!chain->cl)
     return;
-  
+
   safe_realloc (coordsp, sizeof (struct coord) * chain->cl);
-  
+
   coords = *coordsp;
-  
-  if (i)
-  {
-    c = coords[i-1].c + strlen (type2_list[chain->ch[i-1]]->shortname) + 2;
-    r = coords[i-1].r;
+
+  if (i) {
+    c =
+      coords[i - 1].c + strlen (type2_list[chain->ch[i - 1]]->shortname) + 2;
+    r = coords[i - 1].r;
   }
-  else
-  {
+  else {
     r = MIX_VOFFSET;
     c = MIX_HOFFSET;
   }
-    
-  
-  for (; i < chain->cl; i++)
-  {
+
+
+  for (; i < chain->cl; i++) {
     oc = c;
     c += strlen (type2_list[chain->ch[i]]->shortname) + 2;
 
-    if (c  >= COLS)
-    {
+    if (c >= COLS) {
       oc = c = MIX_HOFFSET;
       r++;
     }
-    
+
     coords[i].c = oc;
     coords[i].r = r;
-    
+
   }
-  
+
 }
 
-static void mix_redraw_ce (REMAILER **type2_list,
-                          struct coord *coords,
-                          MIXCHAIN *chain,
-                          int i,
-                          short selected)
+static void mix_redraw_ce (REMAILER ** type2_list,
+                           struct coord *coords,
+                           MIXCHAIN * chain, int i, short selected)
 {
   if (!coords || !chain)
     return;
-  
-  if (coords[i].r < MIX_MAXROW)
-  {
-    
+
+  if (coords[i].r < MIX_MAXROW) {
+
     if (selected)
       SETCOLOR (MT_COLOR_INDICATOR);
     else
       SETCOLOR (MT_COLOR_NORMAL);
-    
+
     mvaddstr (coords[i].r, coords[i].c, type2_list[chain->ch[i]]->shortname);
     SETCOLOR (MT_COLOR_NORMAL);
 
@@ -295,18 +289,15 @@ static void mix_redraw_ce (REMAILER **type2_list,
   }
 }
 
-static void mix_redraw_chain (REMAILER **type2_list,
-                             struct coord *coords,
-                             MIXCHAIN *chain,
-                             int cur)
+static void mix_redraw_chain (REMAILER ** type2_list,
+                              struct coord *coords, MIXCHAIN * chain, int cur)
 {
   int i;
-  
+
   SETCOLOR (MT_COLOR_NORMAL);
   BKGDSET (MT_COLOR_NORMAL);
-  
-  for (i = MIX_VOFFSET; i < MIX_MAXROW; i++)
-  {
+
+  for (i = MIX_VOFFSET; i < MIX_MAXROW; i++) {
     move (i, 0);
     clrtoeol ();
   }
@@ -315,57 +306,54 @@ static void mix_redraw_chain (REMAILER **type2_list,
     mix_redraw_ce (type2_list, coords, chain, i, i == cur);
 }
 
-static void mix_redraw_head (MIXCHAIN *chain)
+static void mix_redraw_head (MIXCHAIN * chain)
 {
   SETCOLOR (MT_COLOR_STATUS);
-  mvprintw (MIX_VOFFSET - 1, 0, "-- Remailer chain [Length: %d]", chain ? chain->cl : 0);
-  
+  mvprintw (MIX_VOFFSET - 1, 0, "-- Remailer chain [Length: %d]",
+            chain ? chain->cl : 0);
+
   BKGDSET (MT_COLOR_STATUS);
   clrtoeol ();
-  
+
   BKGDSET (MT_COLOR_NORMAL);
   SETCOLOR (MT_COLOR_NORMAL);
 }
 
-static const char *mix_format_caps (REMAILER *r)
+static const char *mix_format_caps (REMAILER * r)
 {
   static char capbuff[10];
   char *t = capbuff;
-  
+
   if (r->caps & MIX_CAP_COMPRESS)
     *t++ = 'C';
   else
     *t++ = ' ';
-  
+
   if (r->caps & MIX_CAP_MIDDLEMAN)
     *t++ = 'M';
   else
     *t++ = ' ';
-  
-  if (r->caps & MIX_CAP_NEWSPOST)
-  {
+
+  if (r->caps & MIX_CAP_NEWSPOST) {
     *t++ = 'N';
     *t++ = 'p';
   }
-  else
-  {
+  else {
     *t++ = ' ';
     *t++ = ' ';
   }
-   
-  if (r->caps & MIX_CAP_NEWSMAIL)
-  {
+
+  if (r->caps & MIX_CAP_NEWSMAIL) {
     *t++ = 'N';
     *t++ = 'm';
   }
-  else
-  {
+  else {
     *t++ = ' ';
     *t++ = ' ';
   }
-  
+
   *t = '\0';
-  
+
   return capbuff;
 }
 
@@ -380,56 +368,50 @@ static const char *mix_format_caps (REMAILER *r)
  */
 
 static const char *mix_entry_fmt (char *dest,
-                                 size_t destlen,
-                                 char op,
-                                 const char *src,
-                                 const char *prefix,
-                                 const char *ifstring,
-                                 const char *elsestring,
-                                 unsigned long data,
-                                 format_flag flags)
+                                  size_t destlen,
+                                  char op,
+                                  const char *src,
+                                  const char *prefix,
+                                  const char *ifstring,
+                                  const char *elsestring,
+                                  unsigned long data, format_flag flags)
 {
   char fmt[16];
   REMAILER *remailer = (REMAILER *) data;
   int optional = (flags & M_FORMAT_OPTIONAL);
 
-  switch (op)
-  {
-    case 'n':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (dest, destlen, fmt, remailer->num);
-      }
-      break;
-    case 'c':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, mix_format_caps(remailer));
-      }
-      break;
-    case 's':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL(remailer->shortname));
-      }
-      else if (!remailer->shortname)
-        optional = 0;
-      break;
-    case 'a':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL(remailer->addr));
-      }
-      else if (!remailer->addr)
-        optional = 0;
-      break;
-    
-    default:
-      *dest = '\0';
+  switch (op) {
+  case 'n':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (dest, destlen, fmt, remailer->num);
+    }
+    break;
+  case 'c':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, mix_format_caps (remailer));
+    }
+    break;
+  case 's':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, NONULL (remailer->shortname));
+    }
+    else if (!remailer->shortname)
+      optional = 0;
+    break;
+  case 'a':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (dest, destlen, fmt, NONULL (remailer->addr));
+    }
+    else if (!remailer->addr)
+      optional = 0;
+    break;
+
+  default:
+    *dest = '\0';
   }
 
   if (optional)
@@ -440,100 +422,96 @@ static const char *mix_entry_fmt (char *dest,
 }
 
 
-  
-static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num)
+
+static void mix_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
   REMAILER **type2_list = (REMAILER **) menu->data;
+
   mutt_FormatString (b, blen, NONULL (MixEntryFormat), mix_entry_fmt,
-                    (unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
+                     (unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
 }
 
-static int mix_chain_add (MIXCHAIN *chain, const char *s, 
-                         REMAILER **type2_list)
+static int mix_chain_add (MIXCHAIN * chain, const char *s,
+                          REMAILER ** type2_list)
 {
   int i;
-  
+
   if (chain->cl >= MAXMIXES)
     return -1;
-  
-  if (!mutt_strcmp (s, "0") || !ascii_strcasecmp (s, "<random>"))
-  {
+
+  if (!mutt_strcmp (s, "0") || !ascii_strcasecmp (s, "<random>")) {
     chain->ch[chain->cl++] = 0;
     return 0;
   }
 
-  for (i = 0; type2_list[i]; i++)
-  {
-    if (!ascii_strcasecmp (s, type2_list[i]->shortname))
-    {
+  for (i = 0; type2_list[i]; i++) {
+    if (!ascii_strcasecmp (s, type2_list[i]->shortname)) {
       chain->ch[chain->cl++] = i;
       return 0;
     }
   }
-  
+
   /* replace unknown remailers by <random> */
-  
+
   if (!type2_list[i])
     chain->ch[chain->cl++] = 0;
 
   return 0;
 }
 
-static struct mapping_t RemailerHelp[] = 
-{
-  { N_("Append"), OP_MIX_APPEND },
-  { N_("Insert"), OP_MIX_INSERT },
-  { N_("Delete"), OP_MIX_DELETE },
-  { N_("Abort"),  OP_EXIT       },
-  { N_("OK"),     OP_MIX_USE    },
-  { NULL }
+static struct mapping_t RemailerHelp[] = {
+  {N_("Append"), OP_MIX_APPEND},
+  {N_("Insert"), OP_MIX_INSERT},
+  {N_("Delete"), OP_MIX_DELETE},
+  {N_("Abort"), OP_EXIT},
+  {N_("OK"), OP_MIX_USE},
+  {NULL}
 };
-  
 
-void mix_make_chain (LIST **chainp, int *redraw)
+
+void mix_make_chain (LIST ** chainp, int *redraw)
 {
   LIST *p;
   MIXCHAIN *chain;
   int c_cur = 0, c_old = 0;
   int m_len;
   short c_redraw = 1;
-  
+
   REMAILER **type2_list = NULL;
   size_t ttll = 0;
-  
+
   struct coord *coords = NULL;
-  
+
   MUTTMENU *menu;
   char helpstr[SHORT_STRING];
   short loop = 1;
   int op;
-  
+
   int i, j;
   char *t;
 
-  if (!(type2_list = mix_type2_list (&ttll)))
-  {
+  if (!(type2_list = mix_type2_list (&ttll))) {
     mutt_error _("Can't get mixmaster's type2.list!");
+
     return;
   }
 
   *redraw = REDRAW_FULL;
-  
+
   chain = safe_calloc (sizeof (MIXCHAIN), 1);
   for (p = *chainp; p; p = p->next)
     mix_chain_add (chain, (char *) p->data, type2_list);
 
   mutt_free_list (chainp);
-  
+
   /* safety check */
-  for (i = 0; i < chain->cl; i++)
-  {
+  for (i = 0; i < chain->cl; i++) {
     if (chain->ch[i] >= ttll)
       chain->ch[i] = 0;
   }
-  
+
   mix_screen_coordinates (type2_list, &coords, chain, 0);
-  
+
   menu = mutt_new_menu ();
   menu->menu = MENU_MIX;
   menu->max = ttll;
@@ -541,161 +519,151 @@ void mix_make_chain (LIST **chainp, int *redraw)
   menu->tag = NULL;
   menu->title = _("Select a remailer chain.");
   menu->data = type2_list;
-  menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MIX, RemailerHelp);
+  menu->help =
+    mutt_compile_help (helpstr, sizeof (helpstr), MENU_MIX, RemailerHelp);
 
   m_len = menu->pagelen = MIX_VOFFSET - menu->offset - 1;
-  
-  while (loop) 
-  {
-    if (menu->pagelen != m_len)
-    {
+
+  while (loop) {
+    if (menu->pagelen != m_len) {
       menu->pagelen = m_len;
       menu->redraw = REDRAW_FULL;
     }
-    
-    if (c_redraw)
-    {
+
+    if (c_redraw) {
       mix_redraw_head (chain);
       mix_redraw_chain (type2_list, coords, chain, c_cur);
       c_redraw = 0;
     }
-    else if (c_cur != c_old)
-    {
+    else if (c_cur != c_old) {
       mix_redraw_ce (type2_list, coords, chain, c_old, 0);
       mix_redraw_ce (type2_list, coords, chain, c_cur, 1);
     }
-    
+
     c_old = c_cur;
-    
-    switch ((op = mutt_menuLoop (menu)))
-    {
-      case OP_REDRAW:
+
+    switch ((op = mutt_menuLoop (menu))) {
+    case OP_REDRAW:
       {
-       menu_redraw_status (menu);
-       mix_redraw_head (chain);
-       mix_screen_coordinates (type2_list, &coords, chain, 0);
-       mix_redraw_chain (type2_list, coords, chain, c_cur);
-       menu->pagelen = m_len = MIX_VOFFSET - menu->offset - 1;
-       break;
+        menu_redraw_status (menu);
+        mix_redraw_head (chain);
+        mix_screen_coordinates (type2_list, &coords, chain, 0);
+        mix_redraw_chain (type2_list, coords, chain, c_cur);
+        menu->pagelen = m_len = MIX_VOFFSET - menu->offset - 1;
+        break;
       }
-      
-      case OP_EXIT:
+
+    case OP_EXIT:
       {
-       chain->cl = 0;
-       loop = 0;
-       break;
+        chain->cl = 0;
+        loop = 0;
+        break;
       }
 
-      case OP_MIX_USE:
+    case OP_MIX_USE:
       {
-       if (!chain->cl)
-       {
-         chain->cl++;
-         chain->ch[0] = menu->current;
-         mix_screen_coordinates (type2_list, &coords, chain, c_cur);
-         c_redraw = 1;
-       }
-       
-       if (chain->cl && chain->ch[chain->cl - 1] && 
-           (type2_list[chain->ch[chain->cl-1]]->caps & MIX_CAP_MIDDLEMAN))
-       {
-         mutt_error ( _("Error: %s can't be used as the final remailer of a chain."),
-                   type2_list[chain->ch[chain->cl - 1]]->shortname);
-       }
-       else
-       {
-         loop = 0;
-       }
-       break;
+        if (!chain->cl) {
+          chain->cl++;
+          chain->ch[0] = menu->current;
+          mix_screen_coordinates (type2_list, &coords, chain, c_cur);
+          c_redraw = 1;
+        }
+
+        if (chain->cl && chain->ch[chain->cl - 1] &&
+            (type2_list[chain->ch[chain->cl - 1]]->caps & MIX_CAP_MIDDLEMAN))
+        {
+          mutt_error (_
+                      ("Error: %s can't be used as the final remailer of a chain."),
+                      type2_list[chain->ch[chain->cl - 1]]->shortname);
+        }
+        else {
+          loop = 0;
+        }
+        break;
       }
 
-      case OP_GENERIC_SELECT_ENTRY:
-      case OP_MIX_APPEND:
+    case OP_GENERIC_SELECT_ENTRY:
+    case OP_MIX_APPEND:
       {
-       if (chain->cl < MAXMIXES && c_cur < chain->cl)
-         c_cur++;
+        if (chain->cl < MAXMIXES && c_cur < chain->cl)
+          c_cur++;
       }
       /* fallthrough */
-      case OP_MIX_INSERT:
+    case OP_MIX_INSERT:
       {
-       if (chain->cl < MAXMIXES)
-       {
-         chain->cl++;
-         for (i = chain->cl - 1; i > c_cur; i--)
-           chain->ch[i] = chain->ch[i-1];
-         
-         chain->ch[c_cur] = menu->current;
-         mix_screen_coordinates (type2_list, &coords, chain, c_cur);
-         c_redraw = 1;
-       }
-       else
-         mutt_error ( _("Mixmaster chains are limited to %d elements."),
-                   MAXMIXES);
-       
-       break;
+        if (chain->cl < MAXMIXES) {
+          chain->cl++;
+          for (i = chain->cl - 1; i > c_cur; i--)
+            chain->ch[i] = chain->ch[i - 1];
+
+          chain->ch[c_cur] = menu->current;
+          mix_screen_coordinates (type2_list, &coords, chain, c_cur);
+          c_redraw = 1;
+        }
+        else
+          mutt_error (_("Mixmaster chains are limited to %d elements."),
+                      MAXMIXES);
+
+        break;
       }
-      
-      case OP_MIX_DELETE:
+
+    case OP_MIX_DELETE:
       {
-       if (chain->cl)
-       {
-         chain->cl--;
-         
-         for (i = c_cur; i < chain->cl; i++)
-           chain->ch[i] = chain->ch[i+1];
-
-         if (c_cur == chain->cl && c_cur)
-           c_cur--;
-         
-         mix_screen_coordinates (type2_list, &coords, chain, c_cur);
-         c_redraw = 1;
-       }
-       else
-       {
-         mutt_error _("The remailer chain is already empty.");
-       }
-       break;
+        if (chain->cl) {
+          chain->cl--;
+
+          for (i = c_cur; i < chain->cl; i++)
+            chain->ch[i] = chain->ch[i + 1];
+
+          if (c_cur == chain->cl && c_cur)
+            c_cur--;
+
+          mix_screen_coordinates (type2_list, &coords, chain, c_cur);
+          c_redraw = 1;
+        }
+        else {
+          mutt_error _("The remailer chain is already empty.");
+        }
+        break;
       }
-      
-      case OP_MIX_CHAIN_PREV:
+
+    case OP_MIX_CHAIN_PREV:
       {
-       if (c_cur) 
-         c_cur--;
-       else
-         mutt_error _("You already have the first chain element selected.");
-       
-       break;
+        if (c_cur)
+          c_cur--;
+        else
+          mutt_error _("You already have the first chain element selected.");
+
+        break;
       }
-      
-      case OP_MIX_CHAIN_NEXT:
+
+    case OP_MIX_CHAIN_NEXT:
       {
-       if (chain->cl && c_cur < chain->cl - 1)
-         c_cur++;
-       else
-         mutt_error _("You already have the last chain element selected.");
-       
-       break;
+        if (chain->cl && c_cur < chain->cl - 1)
+          c_cur++;
+        else
+          mutt_error _("You already have the last chain element selected.");
+
+        break;
       }
     }
   }
-  
+
   mutt_menuDestroy (&menu);
 
   /* construct the remailer list */
-  
-  if (chain->cl)
-  {
-    for (i = 0; i < chain->cl; i++)
-    {
+
+  if (chain->cl) {
+    for (i = 0; i < chain->cl; i++) {
       if ((j = chain->ch[i]))
-       t = type2_list[j]->shortname;
+        t = type2_list[j]->shortname;
       else
-       t = "*";
-      
+        t = "*";
+
       *chainp = mutt_add_list (*chainp, t);
     }
   }
-  
+
   mix_free_type2_list (&type2_list);
   FREE (&coords);
   FREE (&chain);
@@ -703,15 +671,15 @@ void mix_make_chain (LIST **chainp, int *redraw)
 
 /* some safety checks before piping the message to mixmaster */
 
-int mix_check_message (HEADER *msg)
+int mix_check_message (HEADER * msg)
 {
   const char *fqdn;
   short need_hostname = 0;
   ADDRESS *p;
-  
-  if (msg->env->cc || msg->env->bcc)
-  {
+
+  if (msg->env->cc || msg->env->bcc) {
     mutt_error _("Mixmaster doesn't accept Cc or Bcc headers.");
+
     return -1;
   }
 
@@ -721,24 +689,22 @@ int mix_check_message (HEADER *msg)
    * use_domain won't be respected at this point, hidden_host will.
    */
 
-  for (p = msg->env->to; p; p = p->next)
-  {
-    if (!p->group && strchr (p->mailbox, '@') == NULL)
-    {
+  for (p = msg->env->to; p; p = p->next) {
+    if (!p->group && strchr (p->mailbox, '@') == NULL) {
       need_hostname = 1;
       break;
     }
   }
-    
-  if (need_hostname)
-  {
-    
-    if (!(fqdn = mutt_fqdn (1)))
-    {
-      mutt_error _("Please set the hostname variable to a proper value when using mixmaster!");
+
+  if (need_hostname) {
+
+    if (!(fqdn = mutt_fqdn (1))) {
+      mutt_error
+        _
+        ("Please set the hostname variable to a proper value when using mixmaster!");
       return (-1);
     }
-  
+
     /* Cc and Bcc are empty at this point. */
     rfc822_qualify (msg->env->to, fqdn);
     rfc822_qualify (msg->env->reply_to, fqdn);
@@ -748,7 +714,7 @@ int mix_check_message (HEADER *msg)
   return 0;
 }
 
-int mix_send_message (LIST *chain, const char *tempfile)
+int mix_send_message (LIST * chain, const char *tempfile)
 {
   char cmd[HUGE_STRING];
   char tmp[HUGE_STRING];
@@ -756,9 +722,8 @@ int mix_send_message (LIST *chain, const char *tempfile)
   int i;
 
   snprintf (cmd, sizeof (cmd), "cat %s | %s -m ", tempfile, Mixmaster);
-  
-  for (i = 0; chain; chain = chain->next, i = 1)
-  {
+
+  for (i = 0; chain; chain = chain->next, i = 1) {
     strfcpy (tmp, cmd, sizeof (tmp));
     mutt_quote_filename (cd_quoted, sizeof (cd_quoted), (char *) chain->data);
     snprintf (cmd, sizeof (cmd), "%s%s%s", tmp, i ? "," : " -l ", cd_quoted);
@@ -766,12 +731,10 @@ int mix_send_message (LIST *chain, const char *tempfile)
 
   if (!option (OPTNOCURSES))
     mutt_endwin (NULL);
-  
-  if ((i = mutt_system (cmd)))
-  {
+
+  if ((i = mutt_system (cmd))) {
     fprintf (stderr, _("Error sending message, child exited %d.\n"), i);
-    if (!option (OPTNOCURSES))
-    {
+    if (!option (OPTNOCURSES)) {
       mutt_any_key_to_continue (NULL);
       mutt_error _("Error sending message.");
     }
@@ -780,6 +743,6 @@ int mix_send_message (LIST *chain, const char *tempfile)
   unlink (tempfile);
   return i;
 }
-  
+
 
 #endif
index c746917..746cb4a 100644 (file)
@@ -17,7 +17,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * Mixmaster support for Mutt
@@ -34,8 +34,7 @@
 
 #define MAXMIXES 19
 
-struct type2
-{
+struct type2 {
   int num;
   char *shortname;
   char *addr;
@@ -46,8 +45,7 @@ struct type2
 typedef struct type2 REMAILER;
 
 
-struct mixchain
-{
+struct mixchain {
   size_t cl;
   int ch[MAXMIXES];
 };
@@ -55,7 +53,7 @@ struct mixchain
 typedef struct mixchain MIXCHAIN;
 
 int mix_send_message (LIST *, const char *);
-int mix_check_message (HEADER *msg);
+int mix_check_message (HEADER * msg);
 void mix_make_chain (LIST **, int *);
 
 #endif /* MIXMASTER */
index 81cd729..c098050 100644 (file)
--- a/resize.c
+++ b/resize.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -42,32 +42,28 @@ void mutt_resize_screen (void)
   char *cp;
   int fd;
   struct winsize w;
+
 #ifdef HAVE_RESIZETERM
   int SLtt_Screen_Rows, SLtt_Screen_Cols;
 #endif
 
   SLtt_Screen_Rows = -1;
   SLtt_Screen_Cols = -1;
-  if ((fd = open ("/dev/tty", O_RDONLY)) != -1)
-  {
-    if (ioctl (fd, TIOCGWINSZ, &w) != -1)
-    {
+  if ((fd = open ("/dev/tty", O_RDONLY)) != -1) {
+    if (ioctl (fd, TIOCGWINSZ, &w) != -1) {
       SLtt_Screen_Rows = w.ws_row;
       SLtt_Screen_Cols = w.ws_col;
     }
     close (fd);
   }
-  if (SLtt_Screen_Rows <= 0)
-  {
-    if ((cp = getenv ("LINES")) != NULL)
-    {
+  if (SLtt_Screen_Rows <= 0) {
+    if ((cp = getenv ("LINES")) != NULL) {
       SLtt_Screen_Rows = atoi (cp);
     }
     else
       SLtt_Screen_Rows = 24;
   }
-  if (SLtt_Screen_Cols <= 0)
-  {
+  if (SLtt_Screen_Cols <= 0) {
     if ((cp = getenv ("COLUMNS")) != NULL)
       SLtt_Screen_Cols = atoi (cp);
     else
index 56577e7..4236b6c 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /* 
  * rfc1524 defines a format for the Multimedia Mail Configuration, which
  * In addition, this function returns a 0 if the command works on a file,
  * and 1 if the command works on a pipe.
  */
-int rfc1524_expand_command (BODY *a, char *filename, char *_type,
-    char *command, int clen)
+int rfc1524_expand_command (BODY * a, char *filename, char *_type,
+                            char *command, int clen)
 {
-  int x=0,y=0;
+  int x = 0, y = 0;
   int needspipe = TRUE;
   char buf[LONG_STRING];
   char type[LONG_STRING];
-  
+
   strfcpy (type, _type, sizeof (type));
-  
+
   if (option (OPTMAILCAPSANITIZE))
     mutt_sanitize_filename (type, 0);
 
-  while (command[x] && x<clen && y<sizeof(buf)) 
-  {
+  while (command[x] && x < clen && y < sizeof (buf)) {
     if (command[x] == '\\') {
       x++;
       buf[y++] = command[x++];
     }
-    else if (command[x] == '%') 
-    {
+    else if (command[x] == '%') {
       x++;
-      if (command[x] == '{') 
-      {
-       char param[STRING];
-       char pvalue[STRING];
-       char *_pvalue;
-       int z = 0;
-
-       x++;
-       while (command[x] && command[x] != '}' && z<sizeof(param))
-         param[z++] = command[x++];
-       param[z] = '\0';
-       
-       _pvalue = mutt_get_parameter (param, a->parameter);
-       strfcpy (pvalue, NONULL(_pvalue), sizeof (pvalue));
-       if (option (OPTMAILCAPSANITIZE))
-         mutt_sanitize_filename (pvalue, 0);
-       
-       y += mutt_quote_filename (buf + y, sizeof (buf) - y, pvalue);
+      if (command[x] == '{') {
+        char param[STRING];
+        char pvalue[STRING];
+        char *_pvalue;
+        int z = 0;
+
+        x++;
+        while (command[x] && command[x] != '}' && z < sizeof (param))
+          param[z++] = command[x++];
+        param[z] = '\0';
+
+        _pvalue = mutt_get_parameter (param, a->parameter);
+        strfcpy (pvalue, NONULL (_pvalue), sizeof (pvalue));
+        if (option (OPTMAILCAPSANITIZE))
+          mutt_sanitize_filename (pvalue, 0);
+
+        y += mutt_quote_filename (buf + y, sizeof (buf) - y, pvalue);
       }
-      else if (command[x] == 's' && filename != NULL)
-      {
-       y += mutt_quote_filename (buf + y, sizeof (buf) - y, filename);
-       needspipe = FALSE;
+      else if (command[x] == 's' && filename != NULL) {
+        y += mutt_quote_filename (buf + y, sizeof (buf) - y, filename);
+        needspipe = FALSE;
       }
-      else if (command[x] == 't')
-      {
-       y += mutt_quote_filename (buf + y, sizeof (buf) - y, type);
+      else if (command[x] == 't') {
+        y += mutt_quote_filename (buf + y, sizeof (buf) - y, type);
       }
       x++;
     }
@@ -125,16 +120,13 @@ static char *get_field (char *s)
   if (!s)
     return NULL;
 
-  while ((ch = strpbrk (s, ";\\")) != NULL)
-  {
-    if (*ch == '\\')
-    {
+  while ((ch = strpbrk (s, ";\\")) != NULL) {
+    if (*ch == '\\') {
       s = ch + 1;
       if (*s)
-       s++;
+        s++;
     }
-    else
-    {
+    else {
       *ch++ = 0;
       SKIPWS (ch);
       break;
@@ -145,32 +137,27 @@ static char *get_field (char *s)
 }
 
 static int get_field_text (char *field, char **entry,
-                          char *type, char *filename, int line)
+                           char *type, char *filename, int line)
 {
   field = mutt_skip_whitespace (field);
-  if (*field == '=')
-  {
-    if (entry)
-    {
+  if (*field == '=') {
+    if (entry) {
       field++;
       field = mutt_skip_whitespace (field);
       mutt_str_replace (entry, field);
     }
     return 1;
   }
-  else 
-  {
+  else {
     mutt_error (_("Improperly formated entry for type %s in \"%s\" line %d"),
-               type, filename, line);
+                type, filename, line);
     return 0;
   }
 }
 
-static int rfc1524_mailcap_parse (BODY *a,
-                                 char *filename,
-                                 char *type, 
-                                 rfc1524_entry *entry,
-                                 int opt)
+static int rfc1524_mailcap_parse (BODY * a,
+                                  char *filename,
+                                  char *type, rfc1524_entry * entry, int opt)
 {
   FILE *fp;
   char *buf = NULL;
@@ -201,28 +188,24 @@ static int rfc1524_mailcap_parse (BODY *a,
     return FALSE;
   btlen = ch - type;
 
-  if ((fp = fopen (filename, "r")) != NULL)
-  {
-    while (!found && (buf = mutt_read_line (buf, &buflen, fp, &line)) != NULL)
-    {
+  if ((fp = fopen (filename, "r")) != NULL) {
+    while (!found && (buf = mutt_read_line (buf, &buflen, fp, &line)) != NULL) {
       /* ignore comments */
       if (*buf == '#')
-       continue;
+        continue;
       dprint (2, (debugfile, "mailcap entry: %s\n", buf));
 
       /* check type */
       ch = get_field (buf);
-      if (ascii_strcasecmp (buf, type) &&
-         (ascii_strncasecmp (buf, type, btlen) ||
-          (buf[btlen] != 0 &&                  /* implicit wild */
-           mutt_strcmp (buf + btlen, "/*"))))  /* wildsubtype */
-       continue;
+      if (ascii_strcasecmp (buf, type) && (ascii_strncasecmp (buf, type, btlen) || (buf[btlen] != 0 &&  /* implicit wild */
+                                                                                    mutt_strcmp (buf + btlen, "/*"))))  /* wildsubtype */
+        continue;
 
       /* next field is the viewcommand */
       field = ch;
       ch = get_field (ch);
       if (entry)
-       entry->command = safe_strdup (field);
+        entry->command = safe_strdup (field);
 
       /* parse the optional fields */
       found = TRUE;
@@ -231,133 +214,117 @@ static int rfc1524_mailcap_parse (BODY *a,
       editcommand = FALSE;
       printcommand = FALSE;
 
-      while (ch)
-      {
-       field = ch;
-       ch = get_field (ch);
-       dprint (2, (debugfile, "field: %s\n", field));
-
-       if (!ascii_strcasecmp (field, "needsterminal"))
-       {
-         if (entry)
-           entry->needsterminal = TRUE;
-       }
-       else if (!ascii_strcasecmp (field, "copiousoutput"))
-       {
-         copiousoutput = TRUE;
-         if (entry)
-           entry->copiousoutput = TRUE;
-       }
-       else if (!ascii_strncasecmp (field, "composetyped", 12))
-       {
-         /* this compare most occur before compose to match correctly */
-         if (get_field_text (field + 12, entry ? &entry->composetypecommand : NULL,
-                             type, filename, line))
-           composecommand = TRUE;
-       }
-       else if (!ascii_strncasecmp (field, "compose", 7))
-       {
-         if (get_field_text (field + 7, entry ? &entry->composecommand : NULL,
-                             type, filename, line))
-           composecommand = TRUE;
-       }
-       else if (!ascii_strncasecmp (field, "print", 5))
-       {
-         if (get_field_text (field + 5, entry ? &entry->printcommand : NULL,
-                             type, filename, line))
-           printcommand = TRUE;
-       }
-       else if (!ascii_strncasecmp (field, "edit", 4))
-       {
-         if (get_field_text (field + 4, entry ? &entry->editcommand : NULL,
-                             type, filename, line))
-           editcommand = TRUE;
-       }
-       else if (!ascii_strncasecmp (field, "nametemplate", 12))
-       {
-         get_field_text (field + 12, entry ? &entry->nametemplate : NULL,
-                         type, filename, line);
-       }
-       else if (!ascii_strncasecmp (field, "x-convert", 9))
-       {
-         get_field_text (field + 9, entry ? &entry->convert : NULL,
-                         type, filename, line);
-       }
-       else if (!ascii_strncasecmp (field, "test", 4))
-       {
-         /* 
-          * This routine executes the given test command to determine
-          * if this is the right entry.
-          */
-         char *test_command = NULL;
-         size_t len;
-
-         if (get_field_text (field + 4, &test_command, type, filename, line)
-             && test_command)
-         {
-           len = mutt_strlen (test_command) + STRING;
-           safe_realloc (&test_command, len);
-           rfc1524_expand_command (a, a->filename, type, test_command, len);
-           if (mutt_system (test_command))
-           {
-             /* a non-zero exit code means test failed */
-             found = FALSE;
-           }
-           FREE (&test_command);
-         }
-       }
-      } /* while (ch) */
-
-      if (opt == M_AUTOVIEW)
-      {
-       if (!copiousoutput)
-         found = FALSE;
+      while (ch) {
+        field = ch;
+        ch = get_field (ch);
+        dprint (2, (debugfile, "field: %s\n", field));
+
+        if (!ascii_strcasecmp (field, "needsterminal")) {
+          if (entry)
+            entry->needsterminal = TRUE;
+        }
+        else if (!ascii_strcasecmp (field, "copiousoutput")) {
+          copiousoutput = TRUE;
+          if (entry)
+            entry->copiousoutput = TRUE;
+        }
+        else if (!ascii_strncasecmp (field, "composetyped", 12)) {
+          /* this compare most occur before compose to match correctly */
+          if (get_field_text
+              (field + 12, entry ? &entry->composetypecommand : NULL, type,
+               filename, line))
+            composecommand = TRUE;
+        }
+        else if (!ascii_strncasecmp (field, "compose", 7)) {
+          if (get_field_text
+              (field + 7, entry ? &entry->composecommand : NULL, type,
+               filename, line))
+            composecommand = TRUE;
+        }
+        else if (!ascii_strncasecmp (field, "print", 5)) {
+          if (get_field_text (field + 5, entry ? &entry->printcommand : NULL,
+                              type, filename, line))
+            printcommand = TRUE;
+        }
+        else if (!ascii_strncasecmp (field, "edit", 4)) {
+          if (get_field_text (field + 4, entry ? &entry->editcommand : NULL,
+                              type, filename, line))
+            editcommand = TRUE;
+        }
+        else if (!ascii_strncasecmp (field, "nametemplate", 12)) {
+          get_field_text (field + 12, entry ? &entry->nametemplate : NULL,
+                          type, filename, line);
+        }
+        else if (!ascii_strncasecmp (field, "x-convert", 9)) {
+          get_field_text (field + 9, entry ? &entry->convert : NULL,
+                          type, filename, line);
+        }
+        else if (!ascii_strncasecmp (field, "test", 4)) {
+          /* 
+           * This routine executes the given test command to determine
+           * if this is the right entry.
+           */
+          char *test_command = NULL;
+          size_t len;
+
+          if (get_field_text (field + 4, &test_command, type, filename, line)
+              && test_command) {
+            len = mutt_strlen (test_command) + STRING;
+            safe_realloc (&test_command, len);
+            rfc1524_expand_command (a, a->filename, type, test_command, len);
+            if (mutt_system (test_command)) {
+              /* a non-zero exit code means test failed */
+              found = FALSE;
+            }
+            FREE (&test_command);
+          }
+        }
+      }                         /* while (ch) */
+
+      if (opt == M_AUTOVIEW) {
+        if (!copiousoutput)
+          found = FALSE;
       }
-      else if (opt == M_COMPOSE)
-      {
-       if (!composecommand)
-         found = FALSE;
+      else if (opt == M_COMPOSE) {
+        if (!composecommand)
+          found = FALSE;
       }
-      else if (opt == M_EDIT)
-      {
-       if (!editcommand)
-         found = FALSE;
+      else if (opt == M_EDIT) {
+        if (!editcommand)
+          found = FALSE;
       }
-      else if (opt == M_PRINT)
-      {
-       if (!printcommand)
-         found = FALSE;
+      else if (opt == M_PRINT) {
+        if (!printcommand)
+          found = FALSE;
       }
-      
-      if (!found)
-      {
-       /* reset */
-       if (entry)
-       {
-         FREE (&entry->command);
-         FREE (&entry->composecommand);
-         FREE (&entry->composetypecommand);
-         FREE (&entry->editcommand);
-         FREE (&entry->printcommand);
-         FREE (&entry->nametemplate);
-         FREE (&entry->convert);
-         entry->needsterminal = 0;
-         entry->copiousoutput = 0;
-       }
+
+      if (!found) {
+        /* reset */
+        if (entry) {
+          FREE (&entry->command);
+          FREE (&entry->composecommand);
+          FREE (&entry->composetypecommand);
+          FREE (&entry->editcommand);
+          FREE (&entry->printcommand);
+          FREE (&entry->nametemplate);
+          FREE (&entry->convert);
+          entry->needsterminal = 0;
+          entry->copiousoutput = 0;
+        }
       }
-    } /* while (!found && (buf = mutt_read_line ())) */
+    }                           /* while (!found && (buf = mutt_read_line ())) */
     fclose (fp);
-  } /* if ((fp = fopen ())) */
+  }                             /* if ((fp = fopen ())) */
   FREE (&buf);
   return found;
 }
 
-rfc1524_entry *rfc1524_new_entry(void)
+rfc1524_entry *rfc1524_new_entry (void)
 {
-  return (rfc1524_entry *)safe_calloc(1, sizeof(rfc1524_entry));
+  return (rfc1524_entry *) safe_calloc (1, sizeof (rfc1524_entry));
 }
 
-void rfc1524_free_entry(rfc1524_entry **entry)
+void rfc1524_free_entry (rfc1524_entry ** entry)
 {
   rfc1524_entry *p = *entry;
 
@@ -377,7 +344,8 @@ void rfc1524_free_entry(rfc1524_entry **entry)
  * in *entry, and returns 1.  On failure (not found), returns 0.
  * If entry == NULL just return 1 if the given type is found.
  */
-int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt)
+int rfc1524_mailcap_lookup (BODY * a, char *type, rfc1524_entry * entry,
+                            int opt)
 {
   char path[_POSIX_PATH_MAX];
   int x;
@@ -390,19 +358,17 @@ int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt)
    * and overriden by the MAILCAPS environment variable, and, just to be nice, 
    * we'll make it specifiable in .muttrc
    */
-  if (!curr || !*curr)
-  {
+  if (!curr || !*curr) {
     mutt_error _("No mailcap path specified");
+
     return 0;
   }
 
   mutt_check_lookup_list (a, type, SHORT_STRING);
 
-  while (!found && *curr)
-  {
+  while (!found && *curr) {
     x = 0;
-    while (*curr && *curr != ':' && x < sizeof (path) - 1)
-    {
+    while (*curr && *curr != ':' && x < sizeof (path) - 1) {
       path[x++] = *curr;
       curr++;
     }
@@ -411,11 +377,11 @@ int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt)
 
     if (!x)
       continue;
-    
+
     path[x] = '\0';
     mutt_expand_path (path, sizeof (path));
 
-    dprint(2,(debugfile,"Checking mailcap file: %s\n",path));
+    dprint (2, (debugfile, "Checking mailcap file: %s\n", path));
     found = rfc1524_mailcap_parse (a, path, type, entry, opt);
   }
 
@@ -437,71 +403,65 @@ int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt)
  * Returns 1 if newfile specified
  */
 
-static void strnfcpy(char *d, char *s, size_t siz, size_t len)
+static void strnfcpy (char *d, char *s, size_t siz, size_t len)
 {
-  if(len > siz)
+  if (len > siz)
     len = siz - 1;
-  strfcpy(d, s, len);
+  strfcpy (d, s, len);
 }
 
 int rfc1524_expand_filename (char *nametemplate,
-                            char *oldfile, 
-                            char *newfile,
-                            size_t nflen)
+                             char *oldfile, char *newfile, size_t nflen)
 {
   int i, j, k, ps, r;
   char *s;
-  short lmatch = 0, rmatch = 0; 
+  short lmatch = 0, rmatch = 0;
   char left[_POSIX_PATH_MAX];
   char right[_POSIX_PATH_MAX];
-  
+
   newfile[0] = 0;
 
   /* first, ignore leading path components.
    */
-  
+
   if (nametemplate && (s = strrchr (nametemplate, '/')))
     nametemplate = s + 1;
 
   if (oldfile && (s = strrchr (oldfile, '/')))
     oldfile = s + 1;
-    
-  if (!nametemplate)
-  {
+
+  if (!nametemplate) {
     if (oldfile)
       strfcpy (newfile, oldfile, nflen);
   }
-  else if (!oldfile)
-  {
+  else if (!oldfile) {
     mutt_expand_fmt (newfile, nflen, nametemplate, "mutt");
   }
-  else /* oldfile && nametemplate */
-  {
+  else {                        /* oldfile && nametemplate */
+
 
     /* first, compare everything left from the "%s" 
      * (if there is one).
      */
-    
-    lmatch = 1; ps = 0;
-    for(i = 0; nametemplate[i]; i++)
-    {
-      if(nametemplate[i] == '%' && nametemplate[i+1] == 's')
-      { 
-       ps = 1;
-       break;
+
+    lmatch = 1;
+    ps = 0;
+    for (i = 0; nametemplate[i]; i++) {
+      if (nametemplate[i] == '%' && nametemplate[i + 1] == 's') {
+        ps = 1;
+        break;
       }
 
       /* note that the following will _not_ read beyond oldfile's end. */
 
-      if(lmatch && nametemplate[i] != oldfile[i])
-       lmatch = 0;
+      if (lmatch && nametemplate[i] != oldfile[i])
+        lmatch = 0;
     }
 
-    if(ps)
-    {
-      
+    if (ps) {
+
       /* If we had a "%s", check the rest. */
-      
+
       /* now, for the right part: compare everything right from 
        * the "%s" to the final part of oldfile.
        * 
@@ -514,47 +474,48 @@ int rfc1524_expand_filename (char *nametemplate,
        *   must not be counted again.  That's done by the
        *   condition (j >= (lmatch ? i : 0)).
        */
-      
+
       rmatch = 1;
 
-      for(r = 0, j = mutt_strlen(oldfile) - 1, k = mutt_strlen(nametemplate) - 1 ;
-         j >= (lmatch ? i : 0) && k >= i + 2;
-         j--, k--)
-      {
-       if(nametemplate[k] != oldfile[j])
-       {
-         rmatch = 0;
-         break;
-       }
+      for (r = 0, j = mutt_strlen (oldfile) - 1, k =
+           mutt_strlen (nametemplate) - 1;
+           j >= (lmatch ? i : 0) && k >= i + 2; j--, k--) {
+        if (nametemplate[k] != oldfile[j]) {
+          rmatch = 0;
+          break;
+        }
       }
-      
+
       /* Now, check if we had a full match. */
-      
-      if(k >= i + 2)
-       rmatch = 0;
-      
-      if(lmatch) *left = 0;
-      else strnfcpy(left, nametemplate, sizeof(left), i);
-      
-      if(rmatch) *right = 0;
-      else strfcpy(right, nametemplate + i + 2, sizeof(right));
-      
-      snprintf(newfile, nflen, "%s%s%s", left, oldfile, right);
+
+      if (k >= i + 2)
+        rmatch = 0;
+
+      if (lmatch)
+        *left = 0;
+      else
+        strnfcpy (left, nametemplate, sizeof (left), i);
+
+      if (rmatch)
+        *right = 0;
+      else
+        strfcpy (right, nametemplate + i + 2, sizeof (right));
+
+      snprintf (newfile, nflen, "%s%s%s", left, oldfile, right);
     }
-    else
-    {
+    else {
       /* no "%s" in the name template. */
-      strfcpy(newfile, nametemplate, nflen);
+      strfcpy (newfile, nametemplate, nflen);
     }
   }
-  
-  mutt_adv_mktemp(newfile, nflen);
 
-  if(rmatch && lmatch)
+  mutt_adv_mktemp (newfile, nflen);
+
+  if (rmatch && lmatch)
     return 0;
-  else 
+  else
     return 1;
-  
+
 }
 
 /* If rfc1524_expand_command() is used on a recv'd message, then
@@ -577,14 +538,13 @@ int _mutt_rename_file (char *oldfile, char *newfile, int overwrite)
     return 1;
   if (!overwrite && access (newfile, F_OK) == 0)
     return 2;
-  if ((ofp = fopen (oldfile,"r")) == NULL)
+  if ((ofp = fopen (oldfile, "r")) == NULL)
     return 3;
-  if ((nfp = safe_fopen (newfile,"w")) == NULL)
-  {
-    fclose(ofp);
+  if ((nfp = safe_fopen (newfile, "w")) == NULL) {
+    fclose (ofp);
     return 3;
   }
-  mutt_copy_stream (ofp,nfp);
+  mutt_copy_stream (ofp, nfp);
   fclose (nfp);
   fclose (ofp);
   mutt_unlink (oldfile);
index bc24e96..8892648 100644 (file)
--- a/rfc1524.h
+++ b/rfc1524.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef _RFC1524_H
 #define _RFC1524_H
 
 typedef struct rfc1524_mailcap_entry {
-/*  char *contenttype; */ /* we don't need this, as we search for it */
+  /*  char *contenttype; *//* we don't need this, as we search for it */
   char *command;
   char *testcommand;
   char *composecommand;
@@ -29,9 +29,9 @@ typedef struct rfc1524_mailcap_entry {
   char *printcommand;
   char *nametemplate;
   char *convert;
-/*  char *description; */ /* we don't need this */
-  unsigned int needsterminal : 1;  /* endwin() and system */
-  unsigned int copiousoutput : 1;  /* needs pager, basically */
+  /*  char *description; *//* we don't need this */
+  unsigned int needsterminal:1; /* endwin() and system */
+  unsigned int copiousoutput:1; /* needs pager, basically */
 } rfc1524_entry;
 
 rfc1524_entry *rfc1524_new_entry (void);
index f5155b4..9ab46e7 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -42,7 +42,7 @@
 #endif
 
 #define ENCWORD_LEN_MAX 75
-#define ENCWORD_LEN_MIN 9 /* strlen ("=?.?.?.?=") */
+#define ENCWORD_LEN_MIN 9       /* strlen ("=?.?.?.?=") */
 
 #define HSPACE(x) ((x) == '\0' || (x) == ' ' || (x) == '\t')
 
@@ -55,7 +55,7 @@ typedef size_t (*encoder_t) (char *, ICONV_CONST char *, size_t,
 
 static size_t convert_string (ICONV_CONST char *f, size_t flen,
                               const char *from, const char *to,
-                              char **t, size_t *tlen)
+                              char **t, size_t * tlen)
 {
   iconv_t cd;
   char *buf, *ob;
@@ -63,21 +63,20 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen,
   int e;
 
   cd = mutt_iconv_open (to, from, 0);
-  if (cd == (iconv_t)(-1))
-    return (size_t)(-1);
+  if (cd == (iconv_t) (-1))
+    return (size_t) (-1);
   obl = 4 * flen + 1;
   ob = buf = safe_malloc (obl);
   n = iconv (cd, &f, &flen, &ob, &obl);
-  if (n == (size_t)(-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t)(-1))
-  {
+  if (n == (size_t) (-1) || iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) {
     e = errno;
     FREE (&buf);
     iconv_close (cd);
     errno = e;
-    return (size_t)(-1);
+    return (size_t) (-1);
   }
   *ob = '\0';
-  
+
   *tlen = ob - buf;
 
   safe_realloc (&buf, ob - buf + 1);
@@ -88,15 +87,14 @@ static size_t convert_string (ICONV_CONST char *f, size_t flen,
 }
 
 char *mutt_choose_charset (const char *fromcode, const char *charsets,
-                      char *u, size_t ulen, char **d, size_t *dlen)
+                           char *u, size_t ulen, char **d, size_t * dlen)
 {
   char canonical_buff[LONG_STRING];
   char *e = 0, *tocode = 0;
   size_t elen = 0, bestn = 0;
   const char *p, *q;
 
-  for (p = charsets; p; p = q ? q + 1 : 0)
-  {
+  for (p = charsets; p; p = q ? q + 1 : 0) {
     char *s, *t;
     size_t slen, n;
 
@@ -115,16 +113,14 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets,
     t[n] = '\0';
 
     n = convert_string (u, ulen, fromcode, t, &s, &slen);
-    if (n == (size_t)(-1))
+    if (n == (size_t) (-1))
       continue;
 
-    if (!tocode || n < bestn)
-    {
+    if (!tocode || n < bestn) {
       bestn = n;
       FREE (&tocode);
       tocode = t;
-      if (d)
-      {
+      if (d) {
         FREE (&e);
         e = s;
       }
@@ -134,19 +130,17 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets,
       if (!bestn)
         break;
     }
-    else
-    {
+    else {
       FREE (&t);
       FREE (&s);
     }
   }
-  if (tocode)
-  {
+  if (tocode) {
     if (d)
       *d = e;
     if (dlen)
       *dlen = elen;
-    
+
     mutt_canonical_charset (canonical_buff, sizeof (canonical_buff), tocode);
     mutt_str_replace (&tocode, canonical_buff);
   }
@@ -161,28 +155,24 @@ static size_t b_encoder (char *s, ICONV_CONST char *d, size_t dlen,
   memcpy (s, "=?", 2), s += 2;
   memcpy (s, tocode, strlen (tocode)), s += strlen (tocode);
   memcpy (s, "?B?", 3), s += 3;
-  for (;;)
-  {
+  for (;;) {
     if (!dlen)
       break;
-    else if (dlen == 1)
-    {
+    else if (dlen == 1) {
       *s++ = B64Chars[(*d >> 2) & 0x3f];
       *s++ = B64Chars[(*d & 0x03) << 4];
       *s++ = '=';
       *s++ = '=';
       break;
     }
-    else if (dlen == 2)
-    {
+    else if (dlen == 2) {
       *s++ = B64Chars[(*d >> 2) & 0x3f];
       *s++ = B64Chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
       *s++ = B64Chars[(d[1] & 0x0f) << 2];
       *s++ = '=';
       break;
     }
-    else
-    {
+    else {
       *s++ = B64Chars[(*d >> 2) & 0x3f];
       *s++ = B64Chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
       *s++ = B64Chars[((d[1] & 0x0f) << 2) | ((d[2] >> 6) & 0x03)];
@@ -203,13 +193,12 @@ static size_t q_encoder (char *s, ICONV_CONST char *d, size_t dlen,
   memcpy (s, "=?", 2), s += 2;
   memcpy (s, tocode, strlen (tocode)), s += strlen (tocode);
   memcpy (s, "?Q?", 3), s += 3;
-  while (dlen--)
-  {
+  while (dlen--) {
     unsigned char c = *d++;
+
     if (c == ' ')
       *s++ = '_';
-    else if (c >= 0x7f || c < 0x20 || c == '_' ||  strchr (MimeSpecials, c))
-    {
+    else if (c >= 0x7f || c < 0x20 || c == '_' || strchr (MimeSpecials, c)) {
       *s++ = '=';
       *s++ = hex[(c & 0xf0) >> 4];
       *s++ = hex[c & 0x0f];
@@ -232,7 +221,7 @@ static size_t q_encoder (char *s, ICONV_CONST char *d, size_t dlen,
  */
 static size_t try_block (ICONV_CONST char *d, size_t dlen,
                          const char *fromcode, const char *tocode,
-                         encoder_t *encoder, size_t *wlen)
+                         encoder_t * encoder, size_t * wlen)
 {
   char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
   iconv_t cd;
@@ -241,14 +230,12 @@ static size_t try_block (ICONV_CONST char *d, size_t dlen,
   size_t ibl, obl;
   int count, len, len_b, len_q;
 
-  if (fromcode)
-  {
+  if (fromcode) {
     cd = mutt_iconv_open (tocode, fromcode, 0);
-    assert (cd != (iconv_t)(-1));
+    assert (cd != (iconv_t) (-1));
     ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - strlen (tocode);
-    if (iconv (cd, &ib, &ibl, &ob, &obl) == (size_t)(-1) ||
-        iconv (cd, 0, 0, &ob, &obl) == (size_t)(-1))
-    {
+    if (iconv (cd, &ib, &ibl, &ob, &obl) == (size_t) (-1) ||
+        iconv (cd, 0, 0, &ob, &obl) == (size_t) (-1)) {
       assert (errno == E2BIG);
       iconv_close (cd);
       assert (ib > d);
@@ -256,8 +243,7 @@ static size_t try_block (ICONV_CONST char *d, size_t dlen,
     }
     iconv_close (cd);
   }
-  else
-  {
+  else {
     if (dlen > sizeof (buf1) - strlen (tocode))
       return sizeof (buf1) - strlen (tocode) + 1;
     memcpy (buf1, d, dlen);
@@ -265,9 +251,9 @@ static size_t try_block (ICONV_CONST char *d, size_t dlen,
   }
 
   count = 0;
-  for (p = buf1; p < ob; p++)
-  {
+  for (p = buf1; p < ob; p++) {
     unsigned char c = *p;
+
     assert (strchr (MimeSpecials, '?'));
     if (c >= 0x7f || c < 0x20 || *p == '_' ||
         (c != ' ' && strchr (MimeSpecials, *p)))
@@ -282,14 +268,12 @@ static size_t try_block (ICONV_CONST char *d, size_t dlen,
   if (!ascii_strcasecmp (tocode, "ISO-2022-JP"))
     len_q = ENCWORD_LEN_MAX + 1;
 
-  if (len_b < len_q && len_b <= ENCWORD_LEN_MAX)
-  {
+  if (len_b < len_q && len_b <= ENCWORD_LEN_MAX) {
     *encoder = b_encoder;
     *wlen = len_b;
     return 0;
   }
-  else if (len_q <= ENCWORD_LEN_MAX)
-  {
+  else if (len_q <= ENCWORD_LEN_MAX) {
     *encoder = q_encoder;
     *wlen = len_q;
     return 0;
@@ -312,14 +296,13 @@ static size_t encode_block (char *s, char *d, size_t dlen,
   char *ob;
   size_t ibl, obl, n1, n2;
 
-  if (fromcode)
-  {
+  if (fromcode) {
     cd = mutt_iconv_open (tocode, fromcode, 0);
-    assert (cd != (iconv_t)(-1));
+    assert (cd != (iconv_t) (-1));
     ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - strlen (tocode);
     n1 = iconv (cd, &ib, &ibl, &ob, &obl);
     n2 = iconv (cd, 0, 0, &ob, &obl);
-    assert (n1 != (size_t)(-1) && n2 != (size_t)(-1));
+    assert (n1 != (size_t) (-1) && n2 != (size_t) (-1));
     iconv_close (cd);
     return (*encoder) (s, buf1, ob - buf1, tocode);
   }
@@ -335,14 +318,13 @@ static size_t encode_block (char *s, char *d, size_t dlen,
  */
 static size_t choose_block (char *d, size_t dlen, int col,
                             const char *fromcode, const char *tocode,
-                            encoder_t *encoder, size_t *wlen)
+                            encoder_t * encoder, size_t * wlen)
 {
   size_t n, nn;
   int utf8 = fromcode && !ascii_strcasecmp (fromcode, "UTF-8");
 
   n = dlen;
-  for (;;)
-  {
+  for (;;) {
     assert (d + n > d);
     nn = try_block (d, n, fromcode, tocode, encoder, wlen);
     if (!nn && (col + *wlen <= ENCWORD_LEN_MAX + 1 || n <= 1))
@@ -350,7 +332,7 @@ static size_t choose_block (char *d, size_t dlen, int col,
     n = (nn ? nn : n) - 1;
     assert (n > 0);
     if (utf8)
-      while (n > 1 && CONTINUATION_BYTE(d[n]))
+      while (n > 1 && CONTINUATION_BYTE (d[n]))
         --n;
   }
   return n;
@@ -368,7 +350,7 @@ static size_t choose_block (char *d, size_t dlen, int col,
  */
 static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
                            const char *fromcode, const char *charsets,
-                           char **e, size_t *elen, char *specials)
+                           char **e, size_t * elen, char *specials)
 {
   int ret = 0;
   char *buf;
@@ -382,9 +364,8 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   char *icode = "UTF-8";
 
   /* Try to convert to UTF-8. */
-  if (convert_string (d, dlen, fromcode, icode, &u, &ulen))
-  {
-    ret = 1; 
+  if (convert_string (d, dlen, fromcode, icode, &u, &ulen)) {
+    ret = 1;
     icode = 0;
     u = safe_malloc ((ulen = dlen) + 1);
     memcpy (u, d, dlen);
@@ -393,17 +374,16 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
 
   /* Find earliest and latest things we must encode. */
   s0 = s1 = t0 = t1 = 0;
-  for (t = u; t < u + ulen; t++)
-  {
-    if ((*t & 0x80) || 
-        (*t == '=' && t[1] == '?' && (t == u || HSPACE(*(t-1)))))
-    {
-      if (!t0) t0 = t;
+  for (t = u; t < u + ulen; t++) {
+    if ((*t & 0x80) ||
+        (*t == '=' && t[1] == '?' && (t == u || HSPACE (*(t - 1))))) {
+      if (!t0)
+        t0 = t;
       t1 = t;
     }
-    else if (specials && strchr (specials, *t))
-    {
-      if (!s0) s0 = t;
+    else if (specials && strchr (specials, *t)) {
+      if (!s0)
+        s0 = t;
       s1 = t;
     }
   }
@@ -414,8 +394,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   if (t1 && s1 && s1 > t1)
     t1 = s1;
 
-  if (!t0)
-  {
+  if (!t0) {
     /* No encoding is required. */
     *e = u;
     *elen = ulen;
@@ -424,8 +403,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
 
   /* Choose target charset. */
   tocode = fromcode;
-  if (icode)
-  {
+  if (icode) {
     if ((tocode1 = mutt_choose_charset (icode, charsets, u, ulen, 0, 0)))
       tocode = tocode1;
     else
@@ -435,21 +413,22 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   /* Hack to avoid labelling 8-bit data as us-ascii. */
   if (!icode && mutt_is_us_ascii (tocode))
     tocode = "unknown-8bit";
-  
+
   /* Adjust t0 for maximum length of line. */
   t = u + (ENCWORD_LEN_MAX + 1) - col - ENCWORD_LEN_MIN;
-  if (t < u)  t = u;
-  if (t < t0) t0 = t;
-  
+  if (t < u)
+    t = u;
+  if (t < t0)
+    t0 = t;
+
 
   /* Adjust t0 until we can encode a character after a space. */
-  for (; t0 > u; t0--)
-  {
-    if (!HSPACE(*(t0-1)))
+  for (; t0 > u; t0--) {
+    if (!HSPACE (*(t0 - 1)))
       continue;
     t = t0 + 1;
     if (icode)
-      while (t < u + ulen && CONTINUATION_BYTE(*t))
+      while (t < u + ulen && CONTINUATION_BYTE (*t))
         ++t;
     if (!try_block (t0, t - t0, icode, tocode, &encoder, &wlen) &&
         col + (t0 - u) + wlen <= ENCWORD_LEN_MAX + 1)
@@ -457,13 +436,12 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   }
 
   /* Adjust t1 until we can encode a character before a space. */
-  for (; t1 < u + ulen; t1++)
-  {
-    if (!HSPACE(*t1))
+  for (; t1 < u + ulen; t1++) {
+    if (!HSPACE (*t1))
       continue;
     t = t1 - 1;
     if (icode)
-      while (CONTINUATION_BYTE(*t))
+      while (CONTINUATION_BYTE (*t))
         --t;
     if (!try_block (t, t1 - t, icode, tocode, &encoder, &wlen) &&
         1 + wlen + (u + ulen - t1) <= ENCWORD_LEN_MAX + 1)
@@ -481,30 +459,26 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   col += t0 - u;
 
   t = t0;
-  for (;;)
-  {
+  for (;;) {
     /* Find how much we can encode. */
     n = choose_block (t, t1 - t, col, icode, tocode, &encoder, &wlen);
-    if (n == t1 - t)
-    {
+    if (n == t1 - t) {
       /* See if we can fit the us-ascii suffix, too. */
       if (col + wlen + (u + ulen - t1) <= ENCWORD_LEN_MAX + 1)
         break;
       n = t1 - t - 1;
       if (icode)
-        while (CONTINUATION_BYTE(t[n]))
+        while (CONTINUATION_BYTE (t[n]))
           --n;
       assert (t + n >= t);
-      if (!n)
-      {
+      if (!n) {
         /* This should only happen in the really stupid case where the
            only word that needs encoding is one character long, but
            there is too much us-ascii stuff after it to use a single
            encoded word. We add the next word to the encoded region
            and try again. */
         assert (t1 < u + ulen);
-        for (t1++; t1 < u + ulen && !HSPACE(*t1); t1++)
-          ;
+        for (t1++; t1 < u + ulen && !HSPACE (*t1); t1++);
         continue;
       }
       n = choose_block (t, n, col, icode, tocode, &encoder, &wlen);
@@ -512,8 +486,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
 
     /* Add to output buffer. */
 #define LINEBREAK "\n\t"
-    if (bufpos + wlen + strlen (LINEBREAK) > buflen)
-    {
+    if (bufpos + wlen + strlen (LINEBREAK) > buflen) {
       buflen = bufpos + wlen + strlen (LINEBREAK);
       safe_realloc (&buf, buflen);
     }
@@ -541,7 +514,7 @@ static int rfc2047_encode (ICONV_CONST char *d, size_t dlen, int col,
   FREE (&u);
 
   buf[buflen] = '\0';
-  
+
   *e = buf;
   *elen = buflen + 1;
   return ret;
@@ -568,13 +541,12 @@ void _rfc2047_encode_string (char **pd, int encode_specials, int col)
   *pd = e;
 }
 
-void rfc2047_encode_adrlist (ADDRESS *addr, const char *tag)
+void rfc2047_encode_adrlist (ADDRESS * addr, const char *tag)
 {
   ADDRESS *ptr = addr;
   int col = tag ? strlen (tag) + 2 : 32;
-  
-  while (ptr)
-  {
+
+  while (ptr) {
     if (ptr->personal)
       _rfc2047_encode_string (&ptr->personal, 1, col);
 #ifdef EXACT_ADDRESS
@@ -595,79 +567,69 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len)
 
   pd = d0 = safe_malloc (strlen (s));
 
-  for (pp = s; (pp1 = strchr (pp, '?')); pp = pp1 + 1)
-  {
+  for (pp = s; (pp1 = strchr (pp, '?')); pp = pp1 + 1) {
     count++;
-    switch (count)
-    {
-      case 2:
-        /* ignore language specification a la RFC 2231 */        
-        t = pp1;
-        if ((t1 = memchr (pp, '*', t - pp)))
-          t = t1;
-        charset = safe_malloc (t - pp + 1);
-        memcpy (charset, pp, t - pp);
-        charset[t-pp] = '\0';
-        break;
-      case 3:
-        if (toupper ((unsigned char) *pp) == 'Q')
-          enc = ENCQUOTEDPRINTABLE;
-        else if (toupper ((unsigned char) *pp) == 'B')
-          enc = ENCBASE64;
-        else
-        {
-          FREE (&charset);
-          FREE (&d0);
-          return (-1);
-        }
-        break;
-      case 4:
-        if (enc == ENCQUOTEDPRINTABLE)
-        {
-          for (; pp < pp1; pp++)
-          {
-            if (*pp == '_')
-              *pd++ = ' ';
-            else if (*pp == '=' &&
-                     (!(pp[1] & ~127) && hexval(pp[1]) != -1) &&
-                     (!(pp[2] & ~127) && hexval(pp[2]) != -1))
-            {
-              *pd++ = (hexval(pp[1]) << 4) | hexval(pp[2]);
-              pp += 2;
-            }
-            else
-              *pd++ = *pp;
+    switch (count) {
+    case 2:
+      /* ignore language specification a la RFC 2231 */
+      t = pp1;
+      if ((t1 = memchr (pp, '*', t - pp)))
+        t = t1;
+      charset = safe_malloc (t - pp + 1);
+      memcpy (charset, pp, t - pp);
+      charset[t - pp] = '\0';
+      break;
+    case 3:
+      if (toupper ((unsigned char) *pp) == 'Q')
+        enc = ENCQUOTEDPRINTABLE;
+      else if (toupper ((unsigned char) *pp) == 'B')
+        enc = ENCBASE64;
+      else {
+        FREE (&charset);
+        FREE (&d0);
+        return (-1);
+      }
+      break;
+    case 4:
+      if (enc == ENCQUOTEDPRINTABLE) {
+        for (; pp < pp1; pp++) {
+          if (*pp == '_')
+            *pd++ = ' ';
+          else if (*pp == '=' &&
+                   (!(pp[1] & ~127) && hexval (pp[1]) != -1) &&
+                   (!(pp[2] & ~127) && hexval (pp[2]) != -1)) {
+            *pd++ = (hexval (pp[1]) << 4) | hexval (pp[2]);
+            pp += 2;
           }
-          *pd = 0;
+          else
+            *pd++ = *pp;
         }
-        else if (enc == ENCBASE64)
-        {
-          int c, b = 0, k = 0;
-
-          for (; pp < pp1; pp++)
-          {
-            if (*pp == '=')
-              break;
-            if ((*pp & ~127) || (c = base64val(*pp)) == -1)
-              continue;
-            if (k + 6 >= 8)
-            {
-              k -= 2;
-              *pd++ = b | (c >> k);
-              b = c << (8 - k);
-            }
-            else
-            {
-              b |= c << (k + 2);
-              k += 6;
-            }
+        *pd = 0;
+      }
+      else if (enc == ENCBASE64) {
+        int c, b = 0, k = 0;
+
+        for (; pp < pp1; pp++) {
+          if (*pp == '=')
+            break;
+          if ((*pp & ~127) || (c = base64val (*pp)) == -1)
+            continue;
+          if (k + 6 >= 8) {
+            k -= 2;
+            *pd++ = b | (c >> k);
+            b = c << (8 - k);
+          }
+          else {
+            b |= c << (k + 2);
+            k += 6;
           }
-          *pd = 0;
         }
-        break;
+        *pd = 0;
+      }
+      break;
     }
   }
-  
+
   if (charset)
     mutt_convert_string (&d0, charset, Charset, M_ICONV_HOOK_FROM);
   strfcpy (d, d0, len);
@@ -687,18 +649,13 @@ static const char *find_encoded_word (const char *s, const char **x)
   const char *p, *q;
 
   q = s;
-  while ((p = strstr (q, "=?")))
-  {
+  while ((p = strstr (q, "=?"))) {
     for (q = p + 2;
-         0x20 < *q && *q < 0x7f && !strchr ("()<>@,;:\"/[]?.=", *q);
-         q++)
-      ;
+         0x20 < *q && *q < 0x7f && !strchr ("()<>@,;:\"/[]?.=", *q); q++);
     if (q[0] != '?' || !strchr ("BbQq", q[1]) || q[2] != '?')
       continue;
-    for (q = q + 3; 0x20 <= *q && *q < 0x7f && *q != '?'; q++)
-      ;
-    if (q[0] != '?' || q[1] != '=')
-    {
+    for (q = q + 3; 0x20 <= *q && *q < 0x7f && *q != '?'; q++);
+    if (q[0] != '?' || q[1] != '=') {
       --q;
       continue;
     }
@@ -720,13 +677,12 @@ static size_t lwslen (const char *s, size_t n)
     return 0;
 
   for (; p < s + n; p++)
-    if (!strchr (" \t\r\n", *p))
-    {
-      len = (size_t)(p - s);
+    if (!strchr (" \t\r\n", *p)) {
+      len = (size_t) (p - s);
       break;
     }
-  if (strchr ("\r\n", *(p-1))) /* LWS doesn't end with CRLF */
-    len = (size_t)0;
+  if (strchr ("\r\n", *(p - 1)))        /* LWS doesn't end with CRLF */
+    len = (size_t) 0;
   return len;
 }
 
@@ -739,13 +695,12 @@ static size_t lwsrlen (const char *s, size_t n)
   if (n <= 0)
     return 0;
 
-  if (strchr ("\r\n", *p)) /* LWS doesn't end with CRLF */
-    return (size_t)0;
+  if (strchr ("\r\n", *p))      /* LWS doesn't end with CRLF */
+    return (size_t) 0;
 
   for (; p >= s; p--)
-    if (!strchr (" \t\r\n", *p))
-    {
-      len = (size_t)(s + n - 1 - p);
+    if (!strchr (" \t\r\n", *p)) {
+      len = (size_t) (s + n - 1 - p);
       break;
     }
   return len;
@@ -766,38 +721,31 @@ void rfc2047_decode (char **pd)
   if (!s || !*s)
     return;
 
-  dlen = 4 * strlen (s); /* should be enough */
+  dlen = 4 * strlen (s);        /* should be enough */
   d = d0 = safe_malloc (dlen + 1);
 
-  while (*s && dlen > 0)
-  {
-    if (!(p = find_encoded_word (s, &q)))
-    {
+  while (*s && dlen > 0) {
+    if (!(p = find_encoded_word (s, &q))) {
       /* no encoded words */
-      if (!option (OPTSTRICTMIME))
-      {
+      if (!option (OPTSTRICTMIME)) {
         n = mutt_strlen (s);
-        if (found_encoded && (m = lwslen (s, n)) != 0)
-        {
+        if (found_encoded && (m = lwslen (s, n)) != 0) {
           if (m != n)
             *d = ' ', d++, dlen--;
           n -= m, s += m;
         }
-        if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
-        {
+        if (ascii_strcasecmp (AssumedCharset, "us-ascii")) {
           char *t;
           size_t tlen;
 
           t = safe_malloc (n + 1);
           strfcpy (t, s, n + 1);
-          if (mutt_convert_nonmime_string (&t) == 0)
-          {
+          if (mutt_convert_nonmime_string (&t) == 0) {
             tlen = mutt_strlen (t);
             strncpy (d, t, tlen);
             d += tlen;
           }
-          else
-          {
+          else {
             strncpy (d, s, n);
             d += n;
           }
@@ -810,22 +758,18 @@ void rfc2047_decode (char **pd)
       break;
     }
 
-    if (p != s)
-    {
+    if (p != s) {
       n = (size_t) (p - s);
       /* ignore spaces between encoded words
        * and linear white spaces between encoded word and *text */
-      if (!option (OPTSTRICTMIME))
-      {
-        if (found_encoded && (m = lwslen (s, n)) != 0)
-        {
+      if (!option (OPTSTRICTMIME)) {
+        if (found_encoded && (m = lwslen (s, n)) != 0) {
           if (m != n)
             *d = ' ', d++, dlen--;
           n -= m, s += m;
         }
 
-        if ((m = n - lwsrlen (s, n)) != 0)
-        {
+        if ((m = n - lwsrlen (s, n)) != 0) {
           if (m > dlen)
             m = dlen;
           memcpy (d, s, m);
@@ -835,8 +779,7 @@ void rfc2047_decode (char **pd)
             *d = ' ', d++, dlen--;
         }
       }
-      else if (!found_encoded || strspn (s, " \t\r\n") != n)
-      {
+      else if (!found_encoded || strspn (s, " \t\r\n") != n) {
         if (n > dlen)
           n = dlen;
         memcpy (d, s, n);
@@ -859,10 +802,9 @@ void rfc2047_decode (char **pd)
   mutt_str_adjust (pd);
 }
 
-void rfc2047_decode_adrlist (ADDRESS *a)
+void rfc2047_decode_adrlist (ADDRESS * a)
 {
-  while (a)
-  {
+  while (a) {
     if (a->personal)
       rfc2047_decode (&a->personal);
 #ifdef EXACT_ADDRESS
index f6e0bbf..39dd9b5 100644 (file)
--- a/rfc2047.h
+++ b/rfc2047.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 char *mutt_choose_charset (const char *fromcode, const char *charsets,
-                     char *u, size_t ulen, char **d, size_t *dlen);
+                           char *u, size_t ulen, char **d, size_t * dlen);
 
 void _rfc2047_encode_string (char **, int, int);
 void rfc2047_encode_adrlist (ADDRESS *, const char *);
index 3e49484..19a4add 100644 (file)
--- a/rfc2231.c
+++ b/rfc2231.c
 #include <string.h>
 #include <stdlib.h>
 
-struct rfc2231_parameter
-{
+struct rfc2231_parameter {
   char *attribute;
   char *value;
-  int  index;
-  int  encoded;
-  struct rfc2231_parameter 
-       *next;
+  int index;
+  int encoded;
+  struct rfc2231_parameter
+                   *next;
 };
 
 static char *rfc2231_get_charset (char *, char *, size_t);
 static struct rfc2231_parameter *rfc2231_new_parameter (void);
 static void rfc2231_decode_one (char *, char *);
 static void rfc2231_free_parameter (struct rfc2231_parameter **);
-static void rfc2231_join_continuations (PARAMETER **, struct rfc2231_parameter *);
-static void rfc2231_list_insert (struct rfc2231_parameter **, struct rfc2231_parameter *);
+static void rfc2231_join_continuations (PARAMETER **,
+                                        struct rfc2231_parameter *);
+static void rfc2231_list_insert (struct rfc2231_parameter **,
+                                 struct rfc2231_parameter *);
 
-static void purge_empty_parameters (PARAMETER **headp)
+static void purge_empty_parameters (PARAMETER ** headp)
 {
   PARAMETER *p, *q, **last;
-  
-  for (last = headp, p = *headp; p; p = q)
-  {
+
+  for (last = headp, p = *headp; p; p = q) {
     q = p->next;
-    if (!p->attribute || !p->value)
-    {
+    if (!p->attribute || !p->value) {
       *last = q;
       p->next = NULL;
       mutt_free_parameter (&p);
@@ -79,7 +78,7 @@ static void purge_empty_parameters (PARAMETER **headp)
 }
 
 
-void rfc2231_decode_parameters (PARAMETER **headp)
+void rfc2231_decode_parameters (PARAMETER ** headp)
 {
   PARAMETER *head = NULL;
   PARAMETER **last;
@@ -93,20 +92,19 @@ void rfc2231_decode_parameters (PARAMETER **headp)
 
   int encoded;
   int index;
-  short dirty = 0;     /* set to 1 when we may have created
-                        * empty parameters.
-                        */
-  
-  if (!headp) return;
+  short dirty = 0;              /* set to 1 when we may have created
+                                 * empty parameters.
+                                 */
+
+  if (!headp)
+    return;
 
   purge_empty_parameters (headp);
-  
-  for (last = &head, p = *headp; p; p = q)
-  {
+
+  for (last = &head, p = *headp; p; p = q) {
     q = p->next;
 
-    if (!(s = strchr (p->attribute, '*')))
-    {
+    if (!(s = strchr (p->attribute, '*'))) {
 
       /* 
        * Using RFC 2047 encoding in MIME parameters is explicitly
@@ -116,9 +114,8 @@ void rfc2231_decode_parameters (PARAMETER **headp)
        */
 
       if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?"))
-       rfc2047_decode (&p->value);
-      else if (!option (OPTSTRICTMIME))
-      {
+        rfc2047_decode (&p->value);
+      else if (!option (OPTSTRICTMIME)) {
         if (ascii_strcasecmp (AssumedCharset, "us-ascii"))
           mutt_convert_nonmime_string (&p->value);
       }
@@ -127,10 +124,9 @@ void rfc2231_decode_parameters (PARAMETER **headp)
       last = &p->next;
       p->next = NULL;
     }
-    else if (*(s + 1) == '\0')
-    {
+    else if (*(s + 1) == '\0') {
       *s = '\0';
-      
+
       s = rfc2231_get_charset (p->value, charset, sizeof (charset));
       rfc2231_decode_one (p->value, s);
       mutt_convert_string (&p->value, charset, Charset, M_ICONV_HOOK_FROM);
@@ -138,14 +134,13 @@ void rfc2231_decode_parameters (PARAMETER **headp)
       *last = p;
       last = &p->next;
       p->next = NULL;
-      
+
       dirty = 1;
     }
-    else
-    {
-      *s = '\0'; s++; /* let s point to the first character of index. */
-      for (t = s; *t && isdigit ((unsigned char) *t); t++)
-       ;
+    else {
+      *s = '\0';
+      s++;                      /* let s point to the first character of index. */
+      for (t = s; *t && isdigit ((unsigned char) *t); t++);
       encoded = (*t == '*');
       *t = '\0';
 
@@ -156,7 +151,7 @@ void rfc2231_decode_parameters (PARAMETER **headp)
       conttmp->value = p->value;
       conttmp->encoded = encoded;
       conttmp->index = index;
-      
+
       p->attribute = NULL;
       p->value = NULL;
       FREE (&p);
@@ -165,18 +160,17 @@ void rfc2231_decode_parameters (PARAMETER **headp)
     }
   }
 
-  if (conthead)
-  {
+  if (conthead) {
     rfc2231_join_continuations (last, conthead);
     dirty = 1;
   }
-  
+
   *headp = head;
-  
+
   if (dirty)
     purge_empty_parameters (headp);
 }
-  
+
 static struct rfc2231_parameter *rfc2231_new_parameter (void)
 {
   return safe_calloc (sizeof (struct rfc2231_parameter), 1);
@@ -184,8 +178,7 @@ static struct rfc2231_parameter *rfc2231_new_parameter (void)
 
 static void rfc2231_free_parameter (struct rfc2231_parameter **p)
 {
-  if (*p)
-  {
+  if (*p) {
     FREE (&(*p)->attribute);
     FREE (&(*p)->value);
     FREE (p);
@@ -195,16 +188,15 @@ static void rfc2231_free_parameter (struct rfc2231_parameter **p)
 static char *rfc2231_get_charset (char *value, char *charset, size_t chslen)
 {
   char *t, *u;
-  
-  if (!(t = strchr (value, '\'')))
-  {
+
+  if (!(t = strchr (value, '\''))) {
     charset[0] = '\0';
     return value;
   }
-  
+
   *t = '\0';
   strfcpy (charset, value, chslen);
-  
+
   if ((u = strchr (t + 1, '\'')))
     return u + 1;
   else
@@ -215,19 +207,17 @@ static void rfc2231_decode_one (char *dest, char *src)
 {
   char *d;
 
-  for (d = dest; *src; src++)
-  {
+  for (d = dest; *src; src++) {
     if (*src == '%' &&
         isxdigit ((unsigned char) *(src + 1)) &&
-        isxdigit ((unsigned char) *(src + 2)))
-    {
+        isxdigit ((unsigned char) *(src + 2))) {
       *d++ = (hexval (*(src + 1)) << 4) | (hexval (*(src + 2)));
       src += 2;
     }
     else
       *d++ = *src;
   }
-  
+
   *d = '\0';
 }
 
@@ -238,30 +228,30 @@ static void rfc2231_decode_one (char *dest, char *src)
  */
 
 static void rfc2231_list_insert (struct rfc2231_parameter **list,
-                                struct rfc2231_parameter *par)
+                                 struct rfc2231_parameter *par)
 {
   struct rfc2231_parameter **last = list;
   struct rfc2231_parameter *p = *list, *q;
   int c;
-  
-  while (p)
-  {
+
+  while (p) {
     last = &p->next;
-    q = p; p = p->next;
+    q = p;
+    p = p->next;
 
     c = strcmp (par->value, q->value);
     if ((c > 0) || (c == 0 && par->index >= q->index))
       break;
   }
-  
+
   par->next = p;
   *last = par;
 }
 
 /* process continuation parameters */
 
-static void rfc2231_join_continuations (PARAMETER **head,
-                                       struct rfc2231_parameter *par)
+static void rfc2231_join_continuations (PARAMETER ** head,
+                                        struct rfc2231_parameter *par)
 {
   struct rfc2231_parameter *q;
 
@@ -272,11 +262,11 @@ static void rfc2231_join_continuations (PARAMETER **head,
   int encoded;
 
   size_t l, vl;
-  
-  while (par)
-  {
-    value = NULL; l = 0;
-    
+
+  while (par) {
+    value = NULL;
+    l = 0;
+
     strfcpy (attribute, par->attribute, sizeof (attribute));
 
     if ((encoded = par->encoded))
@@ -284,27 +274,25 @@ static void rfc2231_join_continuations (PARAMETER **head,
     else
       valp = par->value;
 
-    do 
-    {
+    do {
       if (encoded && par->encoded)
-       rfc2231_decode_one (par->value, valp);
-      
+        rfc2231_decode_one (par->value, valp);
+
       vl = strlen (par->value);
-      
+
       safe_realloc (&value, l + vl + 1);
-      strcpy (value + l, par->value);  /* __STRCPY_CHECKED__ */
+      strcpy (value + l, par->value);   /* __STRCPY_CHECKED__ */
       l += vl;
 
       q = par->next;
       rfc2231_free_parameter (&par);
       if ((par = q))
-       valp = par->value;
+        valp = par->value;
     } while (par && !strcmp (par->attribute, attribute));
-    
-    if (value)
-    {
+
+    if (value) {
       if (encoded)
-       mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM);
+        mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM);
       *head = mutt_new_parameter ();
       (*head)->attribute = safe_strdup (attribute);
       (*head)->value = value;
@@ -329,14 +317,13 @@ int rfc2231_encode_string (char **pd)
   for (s = *pd; *s; s++)
     if (*s & 0x80)
       break;
-  
+
   if (!*s)
     return 0;
-  
+
   if (!Charset || !SendCharset ||
       !(charset = mutt_choose_charset (Charset, SendCharset,
-                                 *pd, strlen (*pd), &d, &dlen)))
-  {
+                                       *pd, strlen (*pd), &d, &dlen))) {
     charset = safe_strdup (Charset ? Charset : "unknown-8bit");
     d = *pd;
     dlen = strlen (d);
@@ -351,20 +338,18 @@ int rfc2231_encode_string (char **pd)
     else if (strchr (MimeSpecials, *s) || strchr ("*'%", *s))
       ++ext;
 
-  if (encode)
-  {
-    e = safe_malloc (dlen + 2*ext + strlen (charset) + 3);
-    sprintf (e, "%s''", charset);      /* __SPRINTF_CHECKED__ */
+  if (encode) {
+    e = safe_malloc (dlen + 2 * ext + strlen (charset) + 3);
+    sprintf (e, "%s''", charset);       /* __SPRINTF_CHECKED__ */
     t = e + strlen (e);
     for (s = d, slen = dlen; slen; s++, slen--)
       if (*s < 0x20 || *s >= 0x7f ||
-         strchr (MimeSpecials, *s) || strchr ("*'%", *s))
-      {
-       sprintf (t, "%%%02X", (unsigned char)*s);
-       t += 3;
+          strchr (MimeSpecials, *s) || strchr ("*'%", *s)) {
+        sprintf (t, "%%%02X", (unsigned char) *s);
+        t += 3;
       }
       else
-       *t++ = *s;
+        *t++ = *s;
     *t = '\0';
 
     if (d != *pd)
@@ -372,14 +357,12 @@ int rfc2231_encode_string (char **pd)
     FREE (pd);
     *pd = e;
   }
-  else if (d != *pd)
-  {
+  else if (d != *pd) {
     FREE (pd);
     *pd = d;
   }
-  
+
   FREE (&charset);
-  
+
   return encode;
 }
-
index ccf01cc..a3cf592 100644 (file)
--- a/rfc2231.h
+++ b/rfc2231.h
@@ -21,4 +21,3 @@
 
 void rfc2231_decode_parameters (PARAMETER **);
 int rfc2231_encode_string (char **);
-
index 12318db..cc13a67 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -46,6 +46,7 @@
 
 
 const char RFC822Specials[] = "@.,:;<>[]\\\"()";
+
 #define is_special(x) strchr(RFC822Specials,x)
 
 int RFC822Error = 0;
@@ -64,30 +65,26 @@ void rfc822_dequote_comment (char *s)
 {
   char *w = s;
 
-  for (; *s; s++)
-  {
-    if (*s == '\\')
-    {
+  for (; *s; s++) {
+    if (*s == '\\') {
       if (!*++s)
-       break; /* error? */
+        break;                  /* error? */
       *w++ = *s;
     }
-    else if (*s != '\"')
-    {
+    else if (*s != '\"') {
       if (w != s)
-       *w = *s;
+        *w = *s;
       w++;
     }
   }
   *w = 0;
 }
 
-void rfc822_free_address (ADDRESS **p)
+void rfc822_free_address (ADDRESS ** p)
 {
   ADDRESS *t;
 
-  while (*p)
-  {
+  while (*p) {
     t = *p;
     *p = (*p)->next;
 #ifdef EXACT_ADDRESS
@@ -99,62 +96,54 @@ void rfc822_free_address (ADDRESS **p)
   }
 }
 
-static const char *
-parse_comment (const char *s,
-              char *comment, size_t *commentlen, size_t commentmax)
+static const char *parse_comment (const char *s,
+                                  char *comment, size_t * commentlen,
+                                  size_t commentmax)
 {
   int level = 1;
-  
-  while (*s && level)
-  {
+
+  while (*s && level) {
     if (*s == '(')
       level++;
-    else if (*s == ')')
-    {
-      if (--level == 0)
-      {
-       s++;
-       break;
+    else if (*s == ')') {
+      if (--level == 0) {
+        s++;
+        break;
       }
     }
-    else if (*s == '\\')
-    {
+    else if (*s == '\\') {
       if (!*++s)
-       break;
+        break;
     }
     if (*commentlen < commentmax)
       comment[(*commentlen)++] = *s;
     s++;
   }
-  if (level)
-  {
+  if (level) {
     RFC822Error = ERR_MISMATCH_PAREN;
     return NULL;
   }
   return s;
 }
 
-static const char *
-parse_quote (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
+static const char *parse_quote (const char *s, char *token, size_t * tokenlen,
+                                size_t tokenmax)
 {
   if (*tokenlen < tokenmax)
     token[(*tokenlen)++] = '"';
-  while (*s)
-  {
+  while (*s) {
     if (*tokenlen < tokenmax)
       token[*tokenlen] = *s;
-    if (*s == '"')
-    {
+    if (*s == '"') {
       (*tokenlen)++;
       return (s + 1);
     }
-    if (*s == '\\')
-    {
+    if (*s == '\\') {
       if (!*++s)
-       break;
+        break;
 
       if (*tokenlen < tokenmax)
-       token[*tokenlen] = *s;
+        token[*tokenlen] = *s;
     }
     (*tokenlen)++;
     s++;
@@ -163,21 +152,19 @@ parse_quote (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
   return NULL;
 }
 
-static const char *
-next_token (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
+static const char *next_token (const char *s, char *token, size_t * tokenlen,
+                               size_t tokenmax)
 {
   if (*s == '(')
     return (parse_comment (s + 1, token, tokenlen, tokenmax));
   if (*s == '"')
     return (parse_quote (s + 1, token, tokenlen, tokenmax));
-  if (is_special (*s))
-  {
+  if (is_special (*s)) {
     if (*tokenlen < tokenmax)
       token[(*tokenlen)++] = *s;
     return (s + 1);
   }
-  while (*s)
-  {
+  while (*s) {
     if (ISSPACE ((unsigned char) *s) || is_special (*s))
       break;
     if (*tokenlen < tokenmax)
@@ -187,23 +174,22 @@ next_token (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
   return s;
 }
 
-static const char *
-parse_mailboxdomain (const char *s, const char *nonspecial,
-                    char *mailbox, size_t *mailboxlen, size_t mailboxmax,
-                    char *comment, size_t *commentlen, size_t commentmax)
+static const char *parse_mailboxdomain (const char *s, const char *nonspecial,
+                                        char *mailbox, size_t * mailboxlen,
+                                        size_t mailboxmax, char *comment,
+                                        size_t * commentlen,
+                                        size_t commentmax)
 {
   const char *ps;
 
-  while (*s)
-  {
+  while (*s) {
     SKIPWS (s);
     if (strchr (nonspecial, *s) == NULL && is_special (*s))
       return s;
 
-    if (*s == '(')
-    {
+    if (*s == '(') {
       if (*commentlen && *commentlen < commentmax)
-       comment[(*commentlen)++] = ' ';
+        comment[(*commentlen)++] = ' ';
       ps = next_token (s, comment, commentlen, commentmax);
     }
     else
@@ -216,25 +202,24 @@ parse_mailboxdomain (const char *s, const char *nonspecial,
   return s;
 }
 
-static const char *
-parse_address (const char *s,
-               char *token, size_t *tokenlen, size_t tokenmax,
-              char *comment, size_t *commentlen, size_t commentmax,
-              ADDRESS *addr)
+static const char *parse_address (const char *s,
+                                  char *token, size_t * tokenlen,
+                                  size_t tokenmax, char *comment,
+                                  size_t * commentlen, size_t commentmax,
+                                  ADDRESS * addr)
 {
   s = parse_mailboxdomain (s, ".\"(\\",
-                          token, tokenlen, tokenmax,
-                          comment, commentlen, commentmax);
+                           token, tokenlen, tokenmax,
+                           comment, commentlen, commentmax);
   if (!s)
     return NULL;
 
-  if (*s == '@')
-  {
+  if (*s == '@') {
     if (*tokenlen < tokenmax)
       token[(*tokenlen)++] = '@';
     s = parse_mailboxdomain (s + 1, ".([]\\",
-                            token, tokenlen, tokenmax,
-                            comment, commentlen, commentmax);
+                             token, tokenlen, tokenmax,
+                             comment, commentlen, commentmax);
     if (!s)
       return NULL;
   }
@@ -242,8 +227,7 @@ parse_address (const char *s,
   terminate_string (token, *tokenlen, tokenmax);
   addr->mailbox = safe_strdup (token);
 
-  if (*commentlen && !addr->personal)
-  {
+  if (*commentlen && !addr->personal) {
     terminate_string (comment, *commentlen, commentmax);
     addr->personal = safe_strdup (comment);
   }
@@ -251,10 +235,9 @@ parse_address (const char *s,
   return s;
 }
 
-static const char *
-parse_route_addr (const char *s,
-                 char *comment, size_t *commentlen, size_t commentmax,
-                 ADDRESS *addr)
+static const char *parse_route_addr (const char *s,
+                                     char *comment, size_t * commentlen,
+                                     size_t commentmax, ADDRESS * addr)
 {
   char token[STRING];
   size_t tokenlen = 0;
@@ -262,20 +245,17 @@ parse_route_addr (const char *s,
   SKIPWS (s);
 
   /* find the end of the route */
-  if (*s == '@')
-  {
-    while (s && *s == '@')
-    {
+  if (*s == '@') {
+    while (s && *s == '@') {
       if (tokenlen < sizeof (token) - 1)
-       token[tokenlen++] = '@';
+        token[tokenlen++] = '@';
       s = parse_mailboxdomain (s + 1, ",.\\[](", token,
-                              &tokenlen, sizeof (token) - 1,
-                              comment, commentlen, commentmax);
+                               &tokenlen, sizeof (token) - 1,
+                               comment, commentlen, commentmax);
     }
-    if (!s || *s != ':')
-    {
+    if (!s || *s != ':') {
       RFC822Error = ERR_BAD_ROUTE;
-      return NULL; /* invalid route */
+      return NULL;              /* invalid route */
     }
 
     if (tokenlen < sizeof (token) - 1)
@@ -283,11 +263,12 @@ parse_route_addr (const char *s,
     s++;
   }
 
-  if ((s = parse_address (s, token, &tokenlen, sizeof (token) - 1, comment, commentlen, commentmax, addr)) == NULL)
+  if ((s =
+       parse_address (s, token, &tokenlen, sizeof (token) - 1, comment,
+                      commentlen, commentmax, addr)) == NULL)
     return NULL;
 
-  if (*s != '>')
-  {
+  if (*s != '>') {
     RFC822Error = ERR_BAD_ROUTE_ADDR;
     return NULL;
   }
@@ -299,17 +280,17 @@ parse_route_addr (const char *s,
   return s;
 }
 
-static const char *
-parse_addr_spec (const char *s,
-                char *comment, size_t *commentlen, size_t commentmax,
-                ADDRESS *addr)
+static const char *parse_addr_spec (const char *s,
+                                    char *comment, size_t * commentlen,
+                                    size_t commentmax, ADDRESS * addr)
 {
   char token[STRING];
   size_t tokenlen = 0;
 
-  s = parse_address (s, token, &tokenlen, sizeof (token) - 1, comment, commentlen, commentmax, addr);
-  if (s && *s && *s != ',' && *s != ';')
-  {
+  s =
+    parse_address (s, token, &tokenlen, sizeof (token) - 1, comment,
+                   commentlen, commentmax, addr);
+  if (s && *s && *s != ',' && *s != ';') {
     RFC822Error = ERR_BAD_ADDR_SPEC;
     return NULL;
   }
@@ -317,13 +298,12 @@ parse_addr_spec (const char *s,
 }
 
 static void
-add_addrspec (ADDRESS **top, ADDRESS **last, const char *phrase,
-             char *comment, size_t *commentlen, size_t commentmax)
+add_addrspec (ADDRESS ** top, ADDRESS ** last, const char *phrase,
+              char *comment, size_t * commentlen, size_t commentmax)
 {
   ADDRESS *cur = rfc822_new_address ();
-  
-  if (parse_addr_spec (phrase, comment, commentlen, commentmax, cur) == NULL)
-  {
+
+  if (parse_addr_spec (phrase, comment, commentlen, commentmax, cur) == NULL) {
     rfc822_free_address (&cur);
     return;
   }
@@ -335,14 +315,14 @@ add_addrspec (ADDRESS **top, ADDRESS **last, const char *phrase,
   *last = cur;
 }
 
-ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
+ADDRESS *rfc822_parse_adrlist (ADDRESS * top, const char *s)
 {
   int ws_pending;
   const char *begin, *ps;
   char comment[STRING], phrase[STRING];
   size_t phraselen = 0, commentlen = 0;
   ADDRESS *cur, *last = NULL;
-  
+
   RFC822Error = 0;
 
   last = top;
@@ -350,27 +330,24 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
     last = last->next;
 
   ws_pending = isspace ((unsigned char) *s);
-  
+
   SKIPWS (s);
   begin = s;
-  while (*s)
-  {
-    if (*s == ',')
-    {
-      if (phraselen)
-      {
-       terminate_buffer (phrase, phraselen);
-       add_addrspec (&top, &last, phrase, comment, &commentlen, sizeof (comment) - 1);
+  while (*s) {
+    if (*s == ',') {
+      if (phraselen) {
+        terminate_buffer (phrase, phraselen);
+        add_addrspec (&top, &last, phrase, comment, &commentlen,
+                      sizeof (comment) - 1);
       }
-      else if (commentlen && last && !last->personal)
-      {
-       terminate_buffer (comment, commentlen);
-       last->personal = safe_strdup (comment);
+      else if (commentlen && last && !last->personal) {
+        terminate_buffer (comment, commentlen);
+        last->personal = safe_strdup (comment);
       }
 
 #ifdef EXACT_ADDRESS
       if (last && !last->val)
-       last->val = mutt_substrdup (begin, s);
+        last->val = mutt_substrdup (begin, s);
 #endif
       commentlen = 0;
       phraselen = 0;
@@ -378,28 +355,27 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
       begin = s;
       SKIPWS (begin);
     }
-    else if (*s == '(')
-    {
+    else if (*s == '(') {
       if (commentlen && commentlen < sizeof (comment) - 1)
-       comment[commentlen++] = ' ';
-      if ((ps = next_token (s, comment, &commentlen, sizeof (comment) - 1)) == NULL)
-      {
-       rfc822_free_address (&top);
-       return NULL;
+        comment[commentlen++] = ' ';
+      if ((ps =
+           next_token (s, comment, &commentlen,
+                       sizeof (comment) - 1)) == NULL) {
+        rfc822_free_address (&top);
+        return NULL;
       }
       s = ps;
     }
-    else if (*s == ':')
-    {
+    else if (*s == ':') {
       cur = rfc822_new_address ();
       terminate_buffer (phrase, phraselen);
       cur->mailbox = safe_strdup (phrase);
       cur->group = 1;
 
       if (last)
-       last->next = cur;
+        last->next = cur;
       else
-       top = cur;
+        top = cur;
       last = cur;
 
 #ifdef EXACT_ADDRESS
@@ -412,29 +388,26 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
       begin = s;
       SKIPWS (begin);
     }
-    else if (*s == ';')
-    {
-      if (phraselen)
-      {
-       terminate_buffer (phrase, phraselen);
-       add_addrspec (&top, &last, phrase, comment, &commentlen, sizeof (comment) - 1);
+    else if (*s == ';') {
+      if (phraselen) {
+        terminate_buffer (phrase, phraselen);
+        add_addrspec (&top, &last, phrase, comment, &commentlen,
+                      sizeof (comment) - 1);
       }
-      else if (commentlen && last && !last->personal)
-      {
-       terminate_buffer (comment, commentlen);
-       last->personal = safe_strdup (comment);
+      else if (commentlen && last && !last->personal) {
+        terminate_buffer (comment, commentlen);
+        last->personal = safe_strdup (comment);
       }
 #ifdef EXACT_ADDRESS
       if (last && !last->val)
-       last->val = mutt_substrdup (begin, s);
+        last->val = mutt_substrdup (begin, s);
 #endif
 
       /* add group terminator */
       cur = rfc822_new_address ();
-      if (last)
-      {
-       last->next = cur;
-       last = cur;
+      if (last) {
+        last->next = cur;
+        last = cur;
       }
 
       phraselen = 0;
@@ -443,58 +416,55 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
       begin = s;
       SKIPWS (begin);
     }
-    else if (*s == '<')
-    {
+    else if (*s == '<') {
       terminate_buffer (phrase, phraselen);
       cur = rfc822_new_address ();
-      if (phraselen)
-      {
-       if (cur->personal)
-         FREE (&cur->personal);
-       /* if we get something like "Michael R. Elkins" remove the quotes */
-       rfc822_dequote_comment (phrase);
-       cur->personal = safe_strdup (phrase);
+      if (phraselen) {
+        if (cur->personal)
+          FREE (&cur->personal);
+        /* if we get something like "Michael R. Elkins" remove the quotes */
+        rfc822_dequote_comment (phrase);
+        cur->personal = safe_strdup (phrase);
       }
-      if ((ps = parse_route_addr (s + 1, comment, &commentlen, sizeof (comment) - 1, cur)) == NULL)
-      {
-       rfc822_free_address (&top);
-       rfc822_free_address (&cur);
-       return NULL;
+      if ((ps =
+           parse_route_addr (s + 1, comment, &commentlen,
+                             sizeof (comment) - 1, cur)) == NULL) {
+        rfc822_free_address (&top);
+        rfc822_free_address (&cur);
+        return NULL;
       }
 
       if (last)
-       last->next = cur;
+        last->next = cur;
       else
-       top = cur;
+        top = cur;
       last = cur;
 
       phraselen = 0;
       commentlen = 0;
       s = ps;
     }
-    else
-    {
+    else {
       if (phraselen && phraselen < sizeof (phrase) - 1 && ws_pending)
-       phrase[phraselen++] = ' ';
-      if ((ps = next_token (s, phrase, &phraselen, sizeof (phrase) - 1)) == NULL)
-      {
-       rfc822_free_address (&top);
-       return NULL;
+        phrase[phraselen++] = ' ';
+      if ((ps =
+           next_token (s, phrase, &phraselen, sizeof (phrase) - 1)) == NULL) {
+        rfc822_free_address (&top);
+        return NULL;
       }
       s = ps;
     }
     ws_pending = isspace ((unsigned char) *s);
     SKIPWS (s);
   }
-  
-  if (phraselen)
-  {
+
+  if (phraselen) {
     terminate_buffer (phrase, phraselen);
     terminate_buffer (comment, commentlen);
-    add_addrspec (&top, &last, phrase, comment, &commentlen, sizeof (comment) - 1);
+    add_addrspec (&top, &last, phrase, comment, &commentlen,
+                  sizeof (comment) - 1);
   }
-  else if (commentlen && last && !last->personal)
-  {
+  else if (commentlen && last && !last->personal) {
     terminate_buffer (comment, commentlen);
     last->personal = safe_strdup (comment);
   }
@@ -506,15 +476,14 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
   return top;
 }
 
-void rfc822_qualify (ADDRESS *addr, const char *host)
+void rfc822_qualify (ADDRESS * addr, const char *host)
 {
   char *p;
 
   for (; addr; addr = addr->next)
-    if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL)
-    {
+    if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) {
       p = safe_malloc (mutt_strlen (addr->mailbox) + mutt_strlen (host) + 2);
-      sprintf (p, "%s@%s", addr->mailbox, host);       /* __SPRINTF_CHECKED__ */
+      sprintf (p, "%s@%s", addr->mailbox, host);        /* __SPRINTF_CHECKED__ */
       FREE (&addr->mailbox);
       addr->mailbox = p;
     }
@@ -523,18 +492,15 @@ void rfc822_qualify (ADDRESS *addr, const char *host)
 void
 rfc822_cat (char *buf, size_t buflen, const char *value, const char *specials)
 {
-  if (strpbrk (value, specials))
-  {
+  if (strpbrk (value, specials)) {
     char tmp[256], *pc = tmp;
     size_t tmplen = sizeof (tmp) - 3;
 
     *pc++ = '"';
-    for (; *value && tmplen > 1; value++)
-    {
-      if (*value == '\\' || *value == '"')
-      {
-       *pc++ = '\\';
-       tmplen--;
+    for (; *value && tmplen > 1; value++) {
+      if (*value == '\\' || *value == '"') {
+        *pc++ = '\\';
+        tmplen--;
       }
       *pc++ = *value;
       tmplen--;
@@ -547,31 +513,29 @@ rfc822_cat (char *buf, size_t buflen, const char *value, const char *specials)
     strfcpy (buf, value, buflen);
 }
 
-void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr,
-                                 int display)
+void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS * addr,
+                                  int display)
 {
   size_t len;
   char *pbuf = buf;
   char *pc;
-  
+
   if (!addr)
     return;
 
-  buflen--; /* save room for the terminal nul */
+  buflen--;                     /* save room for the terminal nul */
 
 #ifdef EXACT_ADDRESS
-  if (addr->val)
-  {
+  if (addr->val) {
     if (!buflen)
       goto done;
     strfcpy (pbuf, addr->val, buflen);
     len = mutt_strlen (pbuf);
     pbuf += len;
     buflen -= len;
-    if (addr->group)
-    {
+    if (addr->group) {
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = ':';
       buflen--;
       *pbuf = 0;
@@ -580,37 +544,32 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr,
   }
 #endif
 
-  if (addr->personal)
-  {
-    if (strpbrk (addr->personal, RFC822Specials))
-    {
+  if (addr->personal) {
+    if (strpbrk (addr->personal, RFC822Specials)) {
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = '"';
       buflen--;
-      for (pc = addr->personal; *pc && buflen > 0; pc++)
-      {
-       if (*pc == '"' || *pc == '\\')
-       {
-         if (!buflen)
-           goto done;
-         *pbuf++ = '\\';
-         buflen--;
-       }
-       if (!buflen)
-         goto done;
-       *pbuf++ = *pc;
-       buflen--;
+      for (pc = addr->personal; *pc && buflen > 0; pc++) {
+        if (*pc == '"' || *pc == '\\') {
+          if (!buflen)
+            goto done;
+          *pbuf++ = '\\';
+          buflen--;
+        }
+        if (!buflen)
+          goto done;
+        *pbuf++ = *pc;
+        buflen--;
       }
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = '"';
       buflen--;
     }
-    else
-    {
+    else {
       if (!buflen)
-       goto done;
+        goto done;
       strfcpy (pbuf, addr->personal, buflen);
       len = mutt_strlen (pbuf);
       pbuf += len;
@@ -623,58 +582,50 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr,
     buflen--;
   }
 
-  if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
-  {
+  if (addr->personal || (addr->mailbox && *addr->mailbox == '@')) {
     if (!buflen)
       goto done;
     *pbuf++ = '<';
     buflen--;
   }
 
-  if (addr->mailbox)
-  {
+  if (addr->mailbox) {
     if (!buflen)
       goto done;
-    if (ascii_strcmp (addr->mailbox, "@") && !display)
-    {
+    if (ascii_strcmp (addr->mailbox, "@") && !display) {
       strfcpy (pbuf, addr->mailbox, buflen);
       len = mutt_strlen (pbuf);
     }
-    else if (ascii_strcmp (addr->mailbox, "@") && display)
-    {
+    else if (ascii_strcmp (addr->mailbox, "@") && display) {
       strfcpy (pbuf, mutt_addr_for_display (addr), buflen);
       len = mutt_strlen (pbuf);
     }
-    else
-    {
+    else {
       *pbuf = '\0';
       len = 0;
     }
     pbuf += len;
     buflen -= len;
 
-    if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
-    {
+    if (addr->personal || (addr->mailbox && *addr->mailbox == '@')) {
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = '>';
       buflen--;
     }
 
-    if (addr->group)
-    {
+    if (addr->group) {
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = ':';
       buflen--;
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = ' ';
       buflen--;
     }
   }
-  else
-  {
+  else {
     if (!buflen)
       goto done;
     *pbuf++ = ';';
@@ -687,17 +638,17 @@ done:
 }
 
 /* note: it is assumed that `buf' is nul terminated! */
-void rfc822_write_address (char *buf, size_t buflen, ADDRESS *addr, int display)
+void rfc822_write_address (char *buf, size_t buflen, ADDRESS * addr,
+                           int display)
 {
   char *pbuf = buf;
   size_t len = mutt_strlen (buf);
-  
-  buflen--; /* save room for the terminal nul */
 
-  if (len > 0)
-  {
+  buflen--;                     /* save room for the terminal nul */
+
+  if (len > 0) {
     if (len > buflen)
-      return; /* safety check for bogus arguments */
+      return;                   /* safety check for bogus arguments */
 
     pbuf += len;
     buflen -= len;
@@ -711,8 +662,7 @@ void rfc822_write_address (char *buf, size_t buflen, ADDRESS *addr, int display)
     buflen--;
   }
 
-  for (; addr && buflen > 0; addr = addr->next)
-  {
+  for (; addr && buflen > 0; addr = addr->next) {
     /* use buflen+1 here because we already saved space for the trailing
        nul char, and the subroutine can make use of it */
     rfc822_write_address_single (pbuf, buflen + 1, addr, display);
@@ -725,14 +675,13 @@ void rfc822_write_address (char *buf, size_t buflen, ADDRESS *addr, int display)
 
     /* if there is another address, and its not a group mailbox name or
        group terminator, add a comma to separate the addresses */
-    if (addr->next && addr->next->mailbox && !addr->group)
-    {
+    if (addr->next && addr->next->mailbox && !addr->group) {
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = ',';
       buflen--;
       if (!buflen)
-       goto done;
+        goto done;
       *pbuf++ = ' ';
       buflen--;
     }
@@ -742,7 +691,7 @@ done:
 }
 
 /* this should be rfc822_cpy_adr */
-ADDRESS *rfc822_cpy_adr_real (ADDRESS *addr)
+ADDRESS *rfc822_cpy_adr_real (ADDRESS * addr)
 {
   ADDRESS *p = rfc822_new_address ();
 
@@ -756,14 +705,12 @@ ADDRESS *rfc822_cpy_adr_real (ADDRESS *addr)
 }
 
 /* this should be rfc822_cpy_adrlist */
-ADDRESS *rfc822_cpy_adr (ADDRESS *addr)
+ADDRESS *rfc822_cpy_adr (ADDRESS * addr)
 {
   ADDRESS *top = NULL, *last = NULL;
-  
-  for (; addr; addr = addr->next)
-  {
-    if (last)
-    {
+
+  for (; addr; addr = addr->next) {
+    if (last) {
       last->next = rfc822_cpy_adr_real (addr);
       last = last->next;
     }
@@ -774,7 +721,7 @@ ADDRESS *rfc822_cpy_adr (ADDRESS *addr)
 }
 
 /* append list 'b' to list 'a' and return the last element in the new list */
-ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b)
+ADDRESS *rfc822_append (ADDRESS ** a, ADDRESS * b)
 {
   ADDRESS *tmp = *a;
 
@@ -794,7 +741,7 @@ ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b)
 #ifdef TESTING
 int safe_free (void **p)
 {
-  free(*p);            /* __MEM_CHECKED__ */
+  free (*p);                    /* __MEM_CHECKED__ */
   *p = 0;
 }
 
@@ -802,12 +749,14 @@ int main (int argc, char **argv)
 {
   ADDRESS *list;
   char buf[256];
+
 # if 0
-  char *str = "michael, Michael Elkins <me@mutt.org>, testing a really complex address: this example <@contains.a.source.route,@with.multiple.hosts:address@example.com>;, lothar@of.the.hillpeople (lothar)";
+  char *str =
+    "michael, Michael Elkins <me@mutt.org>, testing a really complex address: this example <@contains.a.source.route,@with.multiple.hosts:address@example.com>;, lothar@of.the.hillpeople (lothar)";
 # else
   char *str = "a b c ";
 # endif
-  
+
   list = rfc822_parse_adrlist (NULL, str);
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), list);
index d141ba8..6956966 100644 (file)
--- a/rfc822.h
+++ b/rfc822.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef rfc822_h
 #define rfc822_h
 
 /* possible values for RFC822Error */
-enum
-{
+enum {
   ERR_MEMORY = 1,
   ERR_MISMATCH_PAREN,
   ERR_MISMATCH_QUOTE,
@@ -30,27 +29,25 @@ enum
   ERR_BAD_ADDR_SPEC
 };
 
-typedef struct address_t
-{
+typedef struct address_t {
 #ifdef EXACT_ADDRESS
-  char *val;           /* value of address as parsed */
+  char *val;                    /* value of address as parsed */
 #endif
-  char *personal;      /* real name of address */
-  char *mailbox;       /* mailbox and host address */
-  int group;           /* group mailbox? */
+  char *personal;               /* real name of address */
+  char *mailbox;                /* mailbox and host address */
+  int group;                    /* group mailbox? */
   struct address_t *next;
-}
-ADDRESS;
+} ADDRESS;
 
 void rfc822_free_address (ADDRESS **);
 void rfc822_qualify (ADDRESS *, const char *);
 ADDRESS *rfc822_parse_adrlist (ADDRESS *, const char *s);
-ADDRESS *rfc822_cpy_adr (ADDRESS *addr);
-ADDRESS *rfc822_cpy_adr_real (ADDRESS *addr);
-ADDRESS *rfc822_append (ADDRESS **a, ADDRESS *b);
+ADDRESS *rfc822_cpy_adr (ADDRESS * addr);
+ADDRESS *rfc822_cpy_adr_real (ADDRESS * addr);
+ADDRESS *rfc822_append (ADDRESS ** a, ADDRESS * b);
 void rfc822_write_address (char *, size_t, ADDRESS *, int);
 void rfc822_write_address_single (char *, size_t, ADDRESS *, int);
-void rfc822_free_address (ADDRESS **addr);
+void rfc822_free_address (ADDRESS ** addr);
 void rfc822_cat (char *, size_t, const char *, const char *);
 
 extern int RFC822Error;
diff --git a/score.c b/score.c
index 3913aa8..227e7fa 100644 (file)
--- a/score.c
+++ b/score.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #include <string.h>
 #include <stdlib.h>
 
-typedef struct score_t
-{
+typedef struct score_t {
   char *str;
   pattern_t *pat;
   int val;
-  int exact;           /* if this rule matches, don't evaluate any more */
+  int exact;                    /* if this rule matches, don't evaluate any more */
   struct score_t *next;
 } SCORE;
 
 SCORE *Score = NULL;
 
-void mutt_check_rescore (CONTEXT *ctx)
+void mutt_check_rescore (CONTEXT * ctx)
 {
   int i;
 
-  if (option (OPTNEEDRESCORE) && option (OPTSCORE))
-  {
+  if (option (OPTNEEDRESCORE) && option (OPTSCORE)) {
     if ((Sort & SORT_MASK) == SORT_SCORE ||
-       (SortAux & SORT_MASK) == SORT_SCORE)
-    {
+        (SortAux & SORT_MASK) == SORT_SCORE) {
       set_option (OPTNEEDRESORT);
       if ((Sort & SORT_MASK) == SORT_THREADS)
-       set_option (OPTSORTSUBTHREADS);
+        set_option (OPTSORTSUBTHREADS);
     }
 
     /* must redraw the index since the user might have %N in it */
     set_option (OPTFORCEREDRAWINDEX);
     set_option (OPTFORCEREDRAWPAGER);
 
-    for (i = 0; ctx && i < ctx->msgcount; i++)
-    {
+    for (i = 0; ctx && i < ctx->msgcount; i++) {
       mutt_score_message (ctx, ctx->hdrs[i], 1);
       ctx->hdrs[i]->pair = 0;
     }
@@ -63,23 +59,22 @@ void mutt_check_rescore (CONTEXT *ctx)
   unset_option (OPTNEEDRESCORE);
 }
 
-int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_score (BUFFER * buf, BUFFER * s, unsigned long data,
+                      BUFFER * err)
 {
   SCORE *ptr, *last;
   char *pattern, *pc;
   struct pattern_t *pat;
 
   mutt_extract_token (buf, s, 0);
-  if (!MoreArgs (s))
-  {
+  if (!MoreArgs (s)) {
     strfcpy (err->data, _("score: too few arguments"), err->dsize);
     return (-1);
   }
   pattern = buf->data;
   memset (buf, 0, sizeof (BUFFER));
   mutt_extract_token (buf, s, 0);
-  if (MoreArgs (s))
-  {
+  if (MoreArgs (s)) {
     FREE (&pattern);
     strfcpy (err->data, _("score: too many arguments"), err->dsize);
     return (-1);
@@ -90,10 +85,8 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   for (ptr = Score, last = NULL; ptr; last = ptr, ptr = ptr->next)
     if (mutt_strcmp (pattern, ptr->str) == 0)
       break;
-  if (!ptr)
-  {
-    if ((pat = mutt_pattern_comp (pattern, 0, err)) == NULL)
-    {
+  if (!ptr) {
+    if ((pat = mutt_pattern_comp (pattern, 0, err)) == NULL) {
       FREE (&pattern);
       return (-1);
     }
@@ -106,8 +99,7 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
     ptr->str = pattern;
   }
   pc = buf->data;
-  if (*pc == '=')
-  {
+  if (*pc == '=') {
     ptr->exact = 1;
     pc++;
   }
@@ -116,26 +108,23 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
   return 0;
 }
 
-void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx)
+void mutt_score_message (CONTEXT * ctx, HEADER * hdr, int upd_ctx)
 {
   SCORE *tmp;
 
-  hdr->score = 0; /* in case of re-scoring */
-  for (tmp = Score; tmp; tmp = tmp->next)
-  {
-    if (mutt_pattern_exec (tmp->pat, 0, NULL, hdr) > 0)
-    {
-      if (tmp->exact || tmp->val == 9999 || tmp->val == -9999)
-      {
-       hdr->score = tmp->val;
-       break;
+  hdr->score = 0;               /* in case of re-scoring */
+  for (tmp = Score; tmp; tmp = tmp->next) {
+    if (mutt_pattern_exec (tmp->pat, 0, NULL, hdr) > 0) {
+      if (tmp->exact || tmp->val == 9999 || tmp->val == -9999) {
+        hdr->score = tmp->val;
+        break;
       }
       hdr->score += tmp->val;
     }
   }
   if (hdr->score < 0)
     hdr->score = 0;
-  
+
   if (hdr->score <= ScoreThresholdDelete)
     _mutt_set_flag (ctx, hdr, M_DELETE, 1, upd_ctx);
   if (hdr->score <= ScoreThresholdRead)
@@ -144,39 +133,34 @@ void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx)
     _mutt_set_flag (ctx, hdr, M_FLAG, 1, upd_ctx);
 }
 
-int mutt_parse_unscore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
+int mutt_parse_unscore (BUFFER * buf, BUFFER * s, unsigned long data,
+                        BUFFER * err)
 {
   SCORE *tmp, *last = NULL;
 
-  while (MoreArgs (s))
-  {
+  while (MoreArgs (s)) {
     mutt_extract_token (buf, s, 0);
-    if (!mutt_strcmp ("*", buf->data))
-    {
-      for (tmp = Score; tmp; )
-      {
-       last = tmp;
-       tmp = tmp->next;
-       mutt_pattern_free (&last->pat);
-       FREE (&last);
+    if (!mutt_strcmp ("*", buf->data)) {
+      for (tmp = Score; tmp;) {
+        last = tmp;
+        tmp = tmp->next;
+        mutt_pattern_free (&last->pat);
+        FREE (&last);
       }
       Score = NULL;
     }
-    else
-    {
-      for (tmp = Score; tmp; last = tmp, tmp = tmp->next)
-      {
-       if (!mutt_strcmp (buf->data, tmp->str))
-       {
-         if (last)
-           last->next = tmp->next;
-         else
-           Score = tmp->next;
-         mutt_pattern_free (&tmp->pat);
-         FREE (&tmp);
-         /* there should only be one score per pattern, so we can stop here */
-         break;
-       }
+    else {
+      for (tmp = Score; tmp; last = tmp, tmp = tmp->next) {
+        if (!mutt_strcmp (buf->data, tmp->str)) {
+          if (last)
+            last->next = tmp->next;
+          else
+            Score = tmp->next;
+          mutt_pattern_free (&tmp->pat);
+          FREE (&tmp);
+          /* there should only be one score per pattern, so we can stop here */
+          break;
+        }
       }
     }
   }
diff --git a/send.c b/send.c
index c687492..8f09f36 100644 (file)
--- a/send.c
+++ b/send.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 
-static void append_signature (FILE *f)
+static void append_signature (FILE * f)
 {
   FILE *tmpfp;
   pid_t thepid;
 
   if (SignOffString) {
-    fprintf(f,"\n%s",SignOffString);
+    fprintf (f, "\n%s", SignOffString);
   }
 
-  if (Signature && (tmpfp = mutt_open_read (Signature, &thepid)))
-  {
+  if (Signature && (tmpfp = mutt_open_read (Signature, &thepid))) {
     if (option (OPTSIGDASHES))
       fputs ("\n-- \n", f);
     else if (SignOffString)
-      fputs("\n",f);
+      fputs ("\n", f);
     mutt_copy_stream (tmpfp, f);
     fclose (tmpfp);
     if (thepid != -1)
@@ -76,7 +75,7 @@ static void append_signature (FILE *f)
 }
 
 /* compare two e-mail addresses and return 1 if they are equivalent */
-static int mutt_addrcmp (ADDRESS *a, ADDRESS *b)
+static int mutt_addrcmp (ADDRESS * a, ADDRESS * b)
 {
   if (!a->mailbox || !b->mailbox)
     return 0;
@@ -86,10 +85,9 @@ static int mutt_addrcmp (ADDRESS *a, ADDRESS *b)
 }
 
 /* search an e-mail address in a list */
-static int mutt_addrsrc (ADDRESS *a, ADDRESS *lst)
+static int mutt_addrsrc (ADDRESS * a, ADDRESS * lst)
 {
-  for (; lst; lst = lst->next)
-  {
+  for (; lst; lst = lst->next) {
     if (mutt_addrcmp (a, lst))
       return (1);
   }
@@ -97,37 +95,31 @@ static int mutt_addrsrc (ADDRESS *a, ADDRESS *lst)
 }
 
 /* removes addresses from "b" which are contained in "a" */
-static ADDRESS *mutt_remove_xrefs (ADDRESS *a, ADDRESS *b)
+static ADDRESS *mutt_remove_xrefs (ADDRESS * a, ADDRESS * b)
 {
   ADDRESS *top, *p, *prev = NULL;
 
   top = b;
-  while (b)
-  {
-    for (p = a; p; p = p->next)
-    {
+  while (b) {
+    for (p = a; p; p = p->next) {
       if (mutt_addrcmp (p, b))
-       break;
+        break;
     }
-    if (p)
-    {
-      if (prev)
-      {
-       prev->next = b->next;
-       b->next = NULL;
-       rfc822_free_address (&b);
-       b = prev;
+    if (p) {
+      if (prev) {
+        prev->next = b->next;
+        b->next = NULL;
+        rfc822_free_address (&b);
+        b = prev;
       }
-      else
-      {
-       top = top->next;
-       b->next = NULL;
-       rfc822_free_address (&b);
-       b = top;
+      else {
+        top = top->next;
+        b->next = NULL;
+        rfc822_free_address (&b);
+        b = top;
       }
     }
-    else
-    {
+    else {
       prev = b;
       b = b->next;
     }
@@ -138,16 +130,13 @@ static ADDRESS *mutt_remove_xrefs (ADDRESS *a, ADDRESS *b)
 /* remove any address which matches the current user.  if `leave_only' is
  * nonzero, don't remove the user's address if it is the only one in the list
  */
-static ADDRESS *remove_user (ADDRESS *a, int leave_only)
+static ADDRESS *remove_user (ADDRESS * a, int leave_only)
 {
   ADDRESS *top = NULL, *last = NULL;
 
-  while (a)
-  {
-    if (!mutt_addr_is_user (a))
-    {
-      if (top)
-      {
+  while (a) {
+    if (!mutt_addr_is_user (a)) {
+      if (top) {
         last->next = a;
         last = last->next;
       }
@@ -156,54 +145,47 @@ static ADDRESS *remove_user (ADDRESS *a, int leave_only)
       a = a->next;
       last->next = NULL;
     }
-    else
-    {
+    else {
       ADDRESS *tmp = a;
-      
+
       a = a->next;
-      if (!leave_only || a || last)
-      {
-       tmp->next = NULL;
-       rfc822_free_address (&tmp);
+      if (!leave_only || a || last) {
+        tmp->next = NULL;
+        rfc822_free_address (&tmp);
       }
       else
-       last = top = tmp;
+        last = top = tmp;
     }
   }
   return top;
 }
 
-static ADDRESS *find_mailing_lists (ADDRESS *t, ADDRESS *c)
+static ADDRESS *find_mailing_lists (ADDRESS * t, ADDRESS * c)
 {
   ADDRESS *top = NULL, *ptr = NULL;
 
-  for (; t || c; t = c, c = NULL)
-  {
-    for (; t; t = t->next)
-    {
-      if (mutt_is_mail_list (t) && !t->group)
-      {
-       if (top)
-       {
-         ptr->next = rfc822_cpy_adr_real (t);
-         ptr = ptr->next;
-       }
-       else
-         ptr = top = rfc822_cpy_adr_real (t);
+  for (; t || c; t = c, c = NULL) {
+    for (; t; t = t->next) {
+      if (mutt_is_mail_list (t) && !t->group) {
+        if (top) {
+          ptr->next = rfc822_cpy_adr_real (t);
+          ptr = ptr->next;
+        }
+        else
+          ptr = top = rfc822_cpy_adr_real (t);
       }
     }
   }
   return top;
 }
 
-static int edit_address (ADDRESS **a, /* const */ char *field)
+static int edit_address (ADDRESS ** a, /* const */ char *field)
 {
   char buf[HUGE_STRING];
   char *err = NULL;
   int idna_ok = 0;
-  
-  do
-  {
+
+  do {
     buf[0] = 0;
     mutt_addrlist_to_local (*a);
     rfc822_write_address (buf, sizeof (buf), *a, 0);
@@ -211,27 +193,25 @@ static int edit_address (ADDRESS **a, /* const */ char *field)
       return (-1);
     rfc822_free_address (a);
     *a = mutt_expand_aliases (mutt_parse_adrlist (NULL, buf));
-    if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0)
-    {
+    if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0) {
       mutt_error (_("Error: '%s' is a bad IDN."), err);
       mutt_refresh ();
       mutt_sleep (2);
       FREE (&err);
     }
-  } 
+  }
   while (idna_ok != 0);
   return 0;
 }
 
-static int edit_envelope (ENVELOPE *en, int flags)
+static int edit_envelope (ENVELOPE * en, int flags)
 {
   char buf[HUGE_STRING];
   LIST *uh = UserHeader;
   regmatch_t pat_match[1];
 
 #ifdef USE_NNTP
-  if (option (OPTNEWSSEND))
-  {
+  if (option (OPTNEWSSEND)) {
     if (en->newsgroups)
       strfcpy (buf, en->newsgroups, sizeof (buf));
     else
@@ -245,7 +225,8 @@ static int edit_envelope (ENVELOPE *en, int flags)
       strfcpy (buf, en->followup_to, sizeof (buf));
     else
       buf[0] = 0;
-    if (option (OPTASKFOLLOWUP) && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
+    if (option (OPTASKFOLLOWUP)
+        && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0)
       return (-1);
     FREE (&en->followup_to);
     en->followup_to = safe_strdup (buf);
@@ -254,7 +235,8 @@ static int edit_envelope (ENVELOPE *en, int flags)
       strfcpy (buf, en->x_comment_to, sizeof (buf));
     else
       buf[0] = 0;
-    if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO) && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
+    if (option (OPTXCOMMENTTO) && option (OPTASKXCOMMENTTO)
+        && mutt_get_field ("X-Comment-To: ", buf, sizeof (buf), 0) != 0)
       return (-1);
     FREE (&en->x_comment_to);
     en->x_comment_to = safe_strdup (buf);
@@ -270,25 +252,21 @@ static int edit_envelope (ENVELOPE *en, int flags)
       return (-1);
   }
 
-  if (en->subject)
-  {
+  if (en->subject) {
     if (option (OPTFASTREPLY))
       return (0);
     else
       strfcpy (buf, en->subject, sizeof (buf));
   }
-  else
-  {
+  else {
     char *p;
 
     buf[0] = 0;
-    for (; uh; uh = uh->next)
-    {
-      if (ascii_strncasecmp ("subject:", uh->data, 8) == 0)
-      {
-       p = uh->data + 8;
-       SKIPWS (p);
-       strncpy (buf, p, sizeof (buf));
+    for (; uh; uh = uh->next) {
+      if (ascii_strncasecmp ("subject:", uh->data, 8) == 0) {
+        p = uh->data + 8;
+        SKIPWS (p);
+        strncpy (buf, p, sizeof (buf));
       }
     }
   }
@@ -296,19 +274,26 @@ static int edit_envelope (ENVELOPE *en, int flags)
   if ((flags & (SENDREPLY)) && option (OPTSTRIPWAS) && StripWasRegexp.rx &&
       regexec (StripWasRegexp.rx, buf, 1, pat_match, 0) == 0) {
     unsigned int pos = pat_match->rm_so;
+
     if (ascii_strncasecmp (buf, "re: ", pos) != 0) {
-      buf[pos] = '\0';                  /* kill match */
+      buf[pos] = '\0';          /* kill match */
       while (pos-- && buf[pos] == ' ')
-        buf[pos] = '\0';                /* remove trailing spaces */
-    } else {
+        buf[pos] = '\0';        /* remove trailing spaces */
+    }
+    else {
       mutt_error (_("Ignoring $strip_was: Subject would be empty."));
       sleep (2);
     }
   }
-  if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) != 0 ||
-      (!buf[0] && query_quadoption (OPT_SUBJECT, _("No subject, abort?")) != M_NO))
-  {
+  if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) != 0 || (!buf[0]
+                                                                  &&
+                                                                  query_quadoption
+                                                                  (OPT_SUBJECT,
+                                                                   _
+                                                                   ("No subject, abort?"))
+                                                                  != M_NO)) {
     mutt_message _("No subject, aborting.");
+
     return (-1);
   }
   mutt_str_replace (&en->subject, buf);
@@ -324,12 +309,11 @@ char *nntp_get_header (const char *s)
 }
 #endif
 
-static void process_user_recips (ENVELOPE *env)
+static void process_user_recips (ENVELOPE * env)
 {
   LIST *uh = UserHeader;
 
-  for (; uh; uh = uh->next)
-  {
+  for (; uh; uh = uh->next) {
     if (ascii_strncasecmp ("to:", uh->data, 3) == 0)
       env->to = rfc822_parse_adrlist (env->to, uh->data + 3);
     else if (ascii_strncasecmp ("cc:", uh->data, 3) == 0)
@@ -347,7 +331,7 @@ static void process_user_recips (ENVELOPE *env)
   }
 }
 
-static void process_user_header (ENVELOPE *env)
+static void process_user_header (ENVELOPE * env)
 {
   LIST *uh = UserHeader;
   LIST *last = env->userhdrs;
@@ -356,55 +340,48 @@ static void process_user_header (ENVELOPE *env)
     while (last->next)
       last = last->next;
 
-  for (; uh; uh = uh->next)
-  {
-    if (ascii_strncasecmp ("from:", uh->data, 5) == 0)
-    {
+  for (; uh; uh = uh->next) {
+    if (ascii_strncasecmp ("from:", uh->data, 5) == 0) {
       /* User has specified a default From: address.  Remove default address */
       rfc822_free_address (&env->from);
       env->from = rfc822_parse_adrlist (env->from, uh->data + 5);
     }
-    else if (ascii_strncasecmp ("reply-to:", uh->data, 9) == 0)
-    {
+    else if (ascii_strncasecmp ("reply-to:", uh->data, 9) == 0) {
       rfc822_free_address (&env->reply_to);
       env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9);
     }
     else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0)
       mutt_str_replace (&env->message_id, uh->data + 11);
     else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
-            ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
-            ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
+             ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
+             ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
 #ifdef USE_NNTP
-            ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
-            ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
-            ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
+             ascii_strncasecmp ("newsgroups:", uh->data, 11) != 0 &&
+             ascii_strncasecmp ("followup-to:", uh->data, 12) != 0 &&
+             ascii_strncasecmp ("x-comment-to:", uh->data, 13) != 0 &&
 #endif
-            ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
-            ascii_strncasecmp ("subject:", uh->data, 8) != 0)
-    {
-      if (last)
-      {
-       last->next = mutt_new_list ();
-       last = last->next;
+             ascii_strncasecmp ("supersedes:", uh->data, 11) != 0 &&
+             ascii_strncasecmp ("subject:", uh->data, 8) != 0) {
+      if (last) {
+        last->next = mutt_new_list ();
+        last = last->next;
       }
       else
-       last = env->userhdrs = mutt_new_list ();
+        last = env->userhdrs = mutt_new_list ();
       last->data = safe_strdup (uh->data);
     }
   }
 }
 
-LIST *mutt_copy_list (LIST *p)
+LIST *mutt_copy_list (LIST * p)
 {
-  LIST *t, *r=NULL, *l=NULL;
+  LIST *t, *r = NULL, *l = NULL;
 
-  for (; p; p = p->next)
-  {
+  for (; p; p = p->next) {
     t = (LIST *) safe_malloc (sizeof (LIST));
     t->data = safe_strdup (p->data);
     t->next = NULL;
-    if (l)
-    {
+    if (l) {
       r->next = t;
       r = r->next;
     }
@@ -414,10 +391,10 @@ LIST *mutt_copy_list (LIST *p)
   return (l);
 }
 
-void mutt_forward_intro (FILE *fp, HEADER *cur)
+void mutt_forward_intro (FILE * fp, HEADER * cur)
 {
   char buffer[STRING];
-  
+
   fputs ("----- Forwarded message from ", fp);
   buffer[0] = 0;
   rfc822_write_address (buffer, sizeof (buffer), cur->env->from, 1);
@@ -425,32 +402,29 @@ void mutt_forward_intro (FILE *fp, HEADER *cur)
   fputs (" -----\n\n", fp);
 }
 
-void mutt_forward_trailer (FILE *fp)
+void mutt_forward_trailer (FILE * fp)
 {
   fputs ("\n----- End forwarded message -----\n", fp);
 }
 
 
-static int include_forward (CONTEXT *ctx, HEADER *cur, FILE *out)
+static int include_forward (CONTEXT * ctx, HEADER * cur, FILE * out)
 {
   int chflags = CH_DECODE, cmflags = 0;
-  
+
   mutt_parse_mime_message (ctx, cur);
   mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
 
-  if (WithCrypto && (cur->security & ENCRYPT) && option (OPTFORWDECODE))
-  {
+  if (WithCrypto && (cur->security & ENCRYPT) && option (OPTFORWDECODE)) {
     /* make sure we have the user's passphrase before proceeding... */
     crypt_valid_passphrase (cur->security);
   }
 
   mutt_forward_intro (out, cur);
 
-  if (option (OPTFORWDECODE))
-  {
+  if (option (OPTFORWDECODE)) {
     cmflags |= M_CM_DECODE | M_CM_CHARCONV;
-    if (option (OPTWEED))
-    {
+    if (option (OPTWEED)) {
       chflags |= CH_WEED | CH_REORDER;
       cmflags |= M_CM_WEED;
     }
@@ -463,48 +437,46 @@ static int include_forward (CONTEXT *ctx, HEADER *cur, FILE *out)
   return 0;
 }
 
-void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out)
+void mutt_make_attribution (CONTEXT * ctx, HEADER * cur, FILE * out)
 {
   char buffer[STRING];
-  if (Attribution)
-  {
+
+  if (Attribution) {
     mutt_make_string (buffer, sizeof (buffer), Attribution, ctx, cur);
     fputs (buffer, out);
     fputc ('\n', out);
   }
 }
 
-void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out)
+void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out)
 {
   char buffer[STRING];
-  if (PostIndentString)
-  {
+
+  if (PostIndentString) {
     mutt_make_string (buffer, sizeof (buffer), PostIndentString, ctx, cur);
     fputs (buffer, out);
     fputc ('\n', out);
   }
 }
 
-static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out)
+static int include_reply (CONTEXT * ctx, HEADER * cur, FILE * out)
 {
   int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV | M_CM_REPLYING;
   int chflags = CH_DECODE;
 
-  if (WithCrypto && (cur->security & ENCRYPT))
-  {
+  if (WithCrypto && (cur->security & ENCRYPT)) {
     /* make sure we have the user's passphrase before proceeding... */
     crypt_valid_passphrase (cur->security);
   }
 
   mutt_parse_mime_message (ctx, cur);
   mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
-  
+
   mutt_make_attribution (ctx, cur, out);
-  
+
   if (!option (OPTHEADER))
     cmflags |= M_CM_NOHEADER;
-  if (option (OPTWEED))
-  {
+  if (option (OPTWEED)) {
     chflags |= CH_WEED | CH_REORDER;
     cmflags |= M_CM_WEED;
   }
@@ -512,17 +484,16 @@ static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out)
   mutt_copy_message (out, ctx, cur, cmflags, chflags);
 
   mutt_make_post_indent (ctx, cur, out);
-  
+
   return 0;
 }
 
-static int default_to (ADDRESS **to, ENVELOPE *env, int flags, int hmfupto)
+static int default_to (ADDRESS ** to, ENVELOPE * env, int flags, int hmfupto)
 {
   char prompt[STRING];
   ADDRESS *tmp;
 
-  if (flags && env->mail_followup_to && hmfupto == M_YES) 
-  {
+  if (flags && env->mail_followup_to && hmfupto == M_YES) {
     rfc822_append (to, env->mail_followup_to);
     return 0;
   }
@@ -538,7 +509,8 @@ static int default_to (ADDRESS **to, ENVELOPE *env, int flags, int hmfupto)
    */
   if (!(flags & SENDGROUPREPLY) && mutt_is_list_cc (0, env->to, env->cc)) {
     switch (query_quadoption (OPT_LISTREPLY,
-            _("Message came from a mailing list. Reply to author only?")))
+                              _
+                              ("Message came from a mailing list. Reply to author only?")))
     {
     case M_NO:
       tmp = find_mailing_lists (env->to, env->cc);
@@ -546,23 +518,20 @@ static int default_to (ADDRESS **to, ENVELOPE *env, int flags, int hmfupto)
       rfc822_free_address (&tmp);
       return 0;
     case -1:
-      return -1; /* abort */
+      return -1;                /* abort */
     }
   }
 
-  if (!option(OPTREPLYSELF) && mutt_addr_is_user (env->from))
-  {
+  if (!option (OPTREPLYSELF) && mutt_addr_is_user (env->from)) {
     /* mail is from the user, assume replying to recipients */
     rfc822_append (to, env->to);
   }
-  else if (env->reply_to)
-  {
-    if ((mutt_addrcmp (env->from, env->reply_to) && !env->reply_to->next) || 
-       (option (OPTIGNORELISTREPLYTO) &&
-       mutt_is_mail_list (env->reply_to) &&
-       (mutt_addrsrc (env->reply_to, env->to) ||
-       mutt_addrsrc (env->reply_to, env->cc))))
-    {
+  else if (env->reply_to) {
+    if ((mutt_addrcmp (env->from, env->reply_to) && !env->reply_to->next) ||
+        (option (OPTIGNORELISTREPLYTO) &&
+         mutt_is_mail_list (env->reply_to) &&
+         (mutt_addrsrc (env->reply_to, env->to) ||
+          mutt_addrsrc (env->reply_to, env->cc)))) {
       /* If the Reply-To: address is a mailing list, assume that it was
        * put there by the mailing list, and use the From: address
        * 
@@ -573,30 +542,26 @@ static int default_to (ADDRESS **to, ENVELOPE *env, int flags, int hmfupto)
        */
       rfc822_append (to, env->from);
     }
-    else if (!(mutt_addrcmp (env->from, env->reply_to) && 
-              !env->reply_to->next) &&
-            quadoption (OPT_REPLYTO) != M_YES)
-    {
+    else if (!(mutt_addrcmp (env->from, env->reply_to) &&
+               !env->reply_to->next) && quadoption (OPT_REPLYTO) != M_YES) {
       /* There are quite a few mailing lists which set the Reply-To:
        * header field to the list address, which makes it quite impossible
        * to send a message to only the sender of the message.  This
        * provides a way to do that.
        */
       snprintf (prompt, sizeof (prompt), _("Reply to %s%s?"),
-               env->reply_to->mailbox, 
-               env->reply_to->next?",...":"");
-      switch (query_quadoption (OPT_REPLYTO, prompt))
-      {
+                env->reply_to->mailbox, env->reply_to->next ? ",..." : "");
+      switch (query_quadoption (OPT_REPLYTO, prompt)) {
       case M_YES:
-       rfc822_append (to, env->reply_to);
-       break;
+        rfc822_append (to, env->reply_to);
+        break;
 
       case M_NO:
-       rfc822_append (to, env->from);
-       break;
+        rfc822_append (to, env->from);
+        break;
 
       default:
-       return (-1); /* abort */
+        return (-1);            /* abort */
       }
     }
     else
@@ -608,39 +573,36 @@ static int default_to (ADDRESS **to, ENVELOPE *env, int flags, int hmfupto)
   return (0);
 }
 
-int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags)
+int mutt_fetch_recips (ENVELOPE * out, ENVELOPE * in, int flags)
 {
   char prompt[STRING];
   ADDRESS *tmp;
   int hmfupto = -1;
 
-  if ((flags & (SENDLISTREPLY|SENDGROUPREPLY)) && in->mail_followup_to)
-  {
+  if ((flags & (SENDLISTREPLY | SENDGROUPREPLY)) && in->mail_followup_to) {
     snprintf (prompt, sizeof (prompt), _("Follow-up to %s%s?"),
-             in->mail_followup_to->mailbox,
-             in->mail_followup_to->next ? ",..." : "");
+              in->mail_followup_to->mailbox,
+              in->mail_followup_to->next ? ",..." : "");
 
     if ((hmfupto = query_quadoption (OPT_MFUPTO, prompt)) == -1)
       return -1;
   }
 
-  if (flags & SENDLISTREPLY)
-  {
+  if (flags & SENDLISTREPLY) {
     tmp = find_mailing_lists (in->to, in->cc);
     rfc822_append (&out->to, tmp);
     rfc822_free_address (&tmp);
 
     if (in->mail_followup_to && hmfupto == M_YES &&
         default_to (&out->cc, in, flags & SENDLISTREPLY, hmfupto) == -1)
-      return (-1); /* abort */
+      return (-1);              /* abort */
   }
-  else
-  {
+  else {
     if (default_to (&out->to, in, flags & SENDGROUPREPLY, hmfupto) == -1)
-      return (-1); /* abort */
+      return (-1);              /* abort */
 
-    if ((flags & SENDGROUPREPLY) && (!in->mail_followup_to || hmfupto != M_YES))
-    {
+    if ((flags & SENDGROUPREPLY)
+        && (!in->mail_followup_to || hmfupto != M_YES)) {
       /* if(!mutt_addr_is_user(in->to)) */
       rfc822_append (&out->cc, in->to);
       rfc822_append (&out->cc, in->cc);
@@ -649,7 +611,7 @@ int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags)
   return 0;
 }
 
-LIST *mutt_make_references(ENVELOPE *e)
+LIST *mutt_make_references (ENVELOPE * e)
 {
   LIST *t = NULL, *l = NULL;
 
@@ -657,110 +619,113 @@ LIST *mutt_make_references(ENVELOPE *e)
     l = mutt_copy_list (e->references);
   else
     l = mutt_copy_list (e->in_reply_to);
-  
-  if (e->message_id)
-  {
-    t = mutt_new_list();
-    t->data = safe_strdup(e->message_id);
+
+  if (e->message_id) {
+    t = mutt_new_list ();
+    t->data = safe_strdup (e->message_id);
     t->next = l;
     l = t;
   }
-  
+
   return l;
 }
 
-void mutt_fix_reply_recipients (ENVELOPE *env)
+void mutt_fix_reply_recipients (ENVELOPE * env)
 {
   mutt_expand_aliases_env (env);
 
-  if (! option (OPTMETOO))
-  {
+  if (!option (OPTMETOO)) {
     /* the order is important here.  do the CC: first so that if the
      * the user is the only recipient, it ends up on the TO: field
      */
     env->cc = remove_user (env->cc, (env->to == NULL));
     env->to = remove_user (env->to, (env->cc == NULL));
   }
-  
+
   /* the CC field can get cluttered, especially with lists */
   env->to = mutt_remove_duplicates (env->to);
   env->cc = mutt_remove_duplicates (env->cc);
   env->cc = mutt_remove_xrefs (env->to, env->cc);
 }
 
-void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur)
+void mutt_make_forward_subject (ENVELOPE * env, CONTEXT * ctx, HEADER * cur)
 {
   char buffer[STRING];
 
   /* set the default subject for the message. */
-  mutt_make_string (buffer, sizeof (buffer), NONULL(ForwFmt), ctx, cur);
+  mutt_make_string (buffer, sizeof (buffer), NONULL (ForwFmt), ctx, cur);
   mutt_str_replace (&env->subject, buffer);
 }
 
-void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx,
-                                   HEADER *cur, ENVELOPE *curenv)
+void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx,
+                                   HEADER * cur, ENVELOPE * curenv)
 {
   /* This takes precedence over a subject that might have
    * been taken from a List-Post header.  Is that correct?
    */
-  if (curenv->real_subj)
-  {
+  if (curenv->real_subj) {
     FREE (&env->subject);
     env->subject = safe_malloc (mutt_strlen (curenv->real_subj) + 5);
-    sprintf (env->subject, "Re: %s", curenv->real_subj);       /* __SPRINTF_CHECKED__ */
+    sprintf (env->subject, "Re: %s", curenv->real_subj);        /* __SPRINTF_CHECKED__ */
   }
   else if (!env->subject)
     env->subject = safe_strdup ("Re: your mail");
-  
+
 #ifdef USE_NNTP
   if (option (OPTNEWSSEND) && option (OPTXCOMMENTTO) && curenv->from)
     env->x_comment_to = safe_strdup (mutt_get_name (curenv->from));
 #endif
 }
 
-void mutt_add_to_reference_headers (ENVELOPE *env, ENVELOPE *curenv, LIST ***pp, LIST ***qq)
+void mutt_add_to_reference_headers (ENVELOPE * env, ENVELOPE * curenv,
+                                    LIST *** pp, LIST *** qq)
 {
   LIST **p = NULL, **q = NULL;
 
-  if (pp) p = *pp;
-  if (qq) q = *qq;
-  
-  if (!p) p = &env->references;
-  if (!q) q = &env->in_reply_to;
-  
-  while (*p) p = &(*p)->next;
-  while (*q) q = &(*q)->next;
-  
+  if (pp)
+    p = *pp;
+  if (qq)
+    q = *qq;
+
+  if (!p)
+    p = &env->references;
+  if (!q)
+    q = &env->in_reply_to;
+
+  while (*p)
+    p = &(*p)->next;
+  while (*q)
+    q = &(*q)->next;
+
   *p = mutt_make_references (curenv);
-  
-  if (curenv->message_id)
-  {
-    *q = mutt_new_list();
+
+  if (curenv->message_id) {
+    *q = mutt_new_list ();
     (*q)->data = safe_strdup (curenv->message_id);
   }
-  
-  if (pp) *pp = p;
-  if (qq) *qq = q;
-  
+
+  if (pp)
+    *pp = p;
+  if (qq)
+    *qq = q;
+
 }
 
-static void 
-mutt_make_reference_headers (ENVELOPE *curenv, ENVELOPE *env, CONTEXT *ctx)
+static void
+mutt_make_reference_headers (ENVELOPE * curenv, ENVELOPE * env, CONTEXT * ctx)
 {
   env->references = NULL;
   env->in_reply_to = NULL;
-  
-  if (!curenv)
-  {
+
+  if (!curenv) {
     HEADER *h;
     LIST **p = NULL, **q = NULL;
     int i;
-    
-    for(i = 0; i < ctx->vcount; i++)
-    {
+
+    for (i = 0; i < ctx->vcount; i++) {
       h = ctx->hdrs[ctx->v2r[i]];
       if (h->tagged)
-       mutt_add_to_reference_headers (env, h->env, &p, &q);
+        mutt_add_to_reference_headers (env, h->env, &p, &q);
     }
   }
   else
@@ -768,63 +733,57 @@ mutt_make_reference_headers (ENVELOPE *curenv, ENVELOPE *env, CONTEXT *ctx)
 }
 
 static int
-envelope_defaults (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, int flags)
+envelope_defaults (ENVELOPE * env, CONTEXT * ctx, HEADER * cur, int flags)
 {
   ENVELOPE *curenv = NULL;
   int i = 0, tag = 0;
 
-  if (!cur)
-  {
+  if (!cur) {
     tag = 1;
     for (i = 0; i < ctx->vcount; i++)
-      if (ctx->hdrs[ctx->v2r[i]]->tagged)
-      {
-       cur = ctx->hdrs[ctx->v2r[i]];
-       curenv = cur->env;
-       break;
+      if (ctx->hdrs[ctx->v2r[i]]->tagged) {
+        cur = ctx->hdrs[ctx->v2r[i]];
+        curenv = cur->env;
+        break;
       }
 
-    if (!cur)
-    {
+    if (!cur) {
       /* This could happen if the user tagged some messages and then did
        * a limit such that none of the tagged message are visible.
        */
       mutt_error _("No tagged messages are visible!");
+
       return (-1);
     }
   }
   else
     curenv = cur->env;
 
-  if (flags & SENDREPLY)
-  {
+  if (flags & SENDREPLY) {
 #ifdef USE_NNTP
-    if ((flags & SENDNEWS))
-    {
+    if ((flags & SENDNEWS)) {
       /* in case followup set Newsgroups: with Followup-To: if it present */
       if (!env->newsgroups && curenv &&
-         mutt_strcasecmp (curenv->followup_to, "poster"))
-       env->newsgroups = safe_strdup (curenv->followup_to);
+          mutt_strcasecmp (curenv->followup_to, "poster"))
+        env->newsgroups = safe_strdup (curenv->followup_to);
     }
     else
 #endif
-    if (tag)
-    {
+    if (tag) {
       HEADER *h;
 
-      for (i = 0; i < ctx->vcount; i++)
-      {
-       h = ctx->hdrs[ctx->v2r[i]];
-       if (h->tagged && mutt_fetch_recips (env, h->env, flags) == -1)
-         return -1;
+      for (i = 0; i < ctx->vcount; i++) {
+        h = ctx->hdrs[ctx->v2r[i]];
+        if (h->tagged && mutt_fetch_recips (env, h->env, flags) == -1)
+          return -1;
       }
     }
     else if (mutt_fetch_recips (env, curenv, flags) == -1)
       return -1;
 
-    if ((flags & SENDLISTREPLY) && !env->to)
-    {
+    if ((flags & SENDLISTREPLY) && !env->to) {
       mutt_error _("No mailing lists found!");
+
       return (-1);
     }
 
@@ -837,98 +796,88 @@ envelope_defaults (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, int flags)
   return (0);
 }
 
-static int
-generate_body (FILE *tempfp,   /* stream for outgoing message */
-              HEADER *msg,     /* header for outgoing message */
-              int flags,       /* compose mode */
-              CONTEXT *ctx,    /* current mailbox */
-              HEADER *cur)     /* current message */
-{
+static int generate_body (FILE * tempfp,        /* stream for outgoing message */
+                          HEADER * msg, /* header for outgoing message */
+                          int flags,    /* compose mode */
+                          CONTEXT * ctx,        /* current mailbox */
+                          HEADER * cur)
+{                               /* current message */
   int i;
   HEADER *h;
   BODY *tmp;
 
-  if (flags & SENDREPLY)
-  {
-    if ((i = query_quadoption (OPT_INCLUDE, _("Include message in reply?"))) == -1)
+  if (flags & SENDREPLY) {
+    if ((i =
+         query_quadoption (OPT_INCLUDE,
+                           _("Include message in reply?"))) == -1)
       return (-1);
 
-    if (i == M_YES)
-    {
+    if (i == M_YES) {
       mutt_message _("Including quoted message...");
-      if (!cur)
-      {
-       for (i = 0; i < ctx->vcount; i++)
-       {
-         h = ctx->hdrs[ctx->v2r[i]];
-         if (h->tagged)
-         {
-           if (include_reply (ctx, h, tempfp) == -1)
-           {
-             mutt_error _("Could not include all requested messages!");
-             return (-1);
-           }
-           fputc ('\n', tempfp);
-         }
-       }
+
+      if (!cur) {
+        for (i = 0; i < ctx->vcount; i++) {
+          h = ctx->hdrs[ctx->v2r[i]];
+          if (h->tagged) {
+            if (include_reply (ctx, h, tempfp) == -1) {
+              mutt_error _("Could not include all requested messages!");
+
+              return (-1);
+            }
+            fputc ('\n', tempfp);
+          }
+        }
       }
       else
-       include_reply (ctx, cur, tempfp);
+        include_reply (ctx, cur, tempfp);
 
     }
   }
-  else if (flags & SENDFORWARD)
-  {
-    if ((i = query_quadoption (OPT_MIMEFWD, _("Forward as attachment?"))) == M_YES)
-    {
+  else if (flags & SENDFORWARD) {
+    if ((i =
+         query_quadoption (OPT_MIMEFWD,
+                           _("Forward as attachment?"))) == M_YES) {
       BODY *last = msg->content;
 
       mutt_message _("Preparing forwarded message...");
-      
+
       while (last && last->next)
-       last = last->next;
+        last = last->next;
 
-      if (cur)
-      {
-       tmp = mutt_make_message_attach (ctx, cur, 0);
-       if (last)
-         last->next = tmp;
-       else
-         msg->content = tmp;
+      if (cur) {
+        tmp = mutt_make_message_attach (ctx, cur, 0);
+        if (last)
+          last->next = tmp;
+        else
+          msg->content = tmp;
       }
-      else
-      {
-       for (i = 0; i < ctx->vcount; i++)
-       {
-         if (ctx->hdrs[ctx->v2r[i]]->tagged)
-         {
-           tmp = mutt_make_message_attach (ctx, ctx->hdrs[ctx->v2r[i]], 0);
-           if (last)
-           {
-             last->next = tmp;
-             last = tmp;
-           }
-           else
-             last = msg->content = tmp;
-         }
-       }
+      else {
+        for (i = 0; i < ctx->vcount; i++) {
+          if (ctx->hdrs[ctx->v2r[i]]->tagged) {
+            tmp = mutt_make_message_attach (ctx, ctx->hdrs[ctx->v2r[i]], 0);
+            if (last) {
+              last->next = tmp;
+              last = tmp;
+            }
+            else
+              last = msg->content = tmp;
+          }
+        }
       }
     }
-    else if (i != -1)
-    {
+    else if (i != -1) {
       if (cur)
-       include_forward (ctx, cur, tempfp);
+        include_forward (ctx, cur, tempfp);
       else
-       for (i=0; i < ctx->vcount; i++)
-         if (ctx->hdrs[ctx->v2r[i]]->tagged)
-           include_forward (ctx, ctx->hdrs[ctx->v2r[i]], tempfp);
+        for (i = 0; i < ctx->vcount; i++)
+          if (ctx->hdrs[ctx->v2r[i]]->tagged)
+            include_forward (ctx, ctx->hdrs[ctx->v2r[i]], tempfp);
     }
     else if (i == -1)
       return -1;
   }
   /* if (WithCrypto && (flags & SENDKEY)) */
-  else if ((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)) 
-  {
+  else if ((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)) {
     BODY *tmp;
 
     if ((WithCrypto & APPLICATION_PGP)
@@ -944,7 +893,7 @@ generate_body (FILE *tempfp,        /* stream for outgoing message */
   return (0);
 }
 
-void mutt_set_followup_to (ENVELOPE *e)
+void mutt_set_followup_to (ENVELOPE * e)
 {
   ADDRESS *t = NULL;
   ADDRESS *from;
@@ -957,18 +906,15 @@ void mutt_set_followup_to (ENVELOPE *e)
   if (!option (OPTFOLLOWUPTO))
     return;
 #ifdef USE_NNTP
-  if (option (OPTNEWSSEND))
-  {
+  if (option (OPTNEWSSEND)) {
     if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
       e->followup_to = safe_strdup (e->newsgroups);
     return;
   }
 #endif
 
-  if (!e->mail_followup_to)
-  {
-    if (mutt_is_list_cc (0, e->to, e->cc))
-    {
+  if (!e->mail_followup_to) {
+    if (mutt_is_list_cc (0, e->to, e->cc)) {
       /* 
        * this message goes to known mailing lists, so create a proper
        * mail-followup-to header
@@ -988,28 +934,25 @@ void mutt_set_followup_to (ENVELOPE *e)
      * but makes sure list-reply has the desired effect.
      */
 
-    if (e->mail_followup_to && !mutt_is_list_recipient (0, e->to, e->cc))
-    {
+    if (e->mail_followup_to && !mutt_is_list_recipient (0, e->to, e->cc)) {
       if (e->reply_to)
-       from = rfc822_cpy_adr (e->reply_to);
+        from = rfc822_cpy_adr (e->reply_to);
       else if (e->from)
-       from = rfc822_cpy_adr (e->from);
+        from = rfc822_cpy_adr (e->from);
       else
-       from = mutt_default_from ();
-      
-      if (from)
-      {
-       /* Normally, this loop will not even be entered. */
-       for (t = from; t && t->next; t = t->next)
-         ;
-       
-       t->next = e->mail_followup_to;  /* t cannot be NULL at this point. */
-       e->mail_followup_to = from;
+        from = mutt_default_from ();
+
+      if (from) {
+        /* Normally, this loop will not even be entered. */
+        for (t = from; t && t->next; t = t->next);
+
+        t->next = e->mail_followup_to;  /* t cannot be NULL at this point. */
+        e->mail_followup_to = from;
       }
     }
-    
+
     e->mail_followup_to = mutt_remove_duplicates (e->mail_followup_to);
-    
+
   }
 }
 
@@ -1017,27 +960,23 @@ void mutt_set_followup_to (ENVELOPE *e)
 /* 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 */
-static ADDRESS *set_reverse_name (ENVELOPE *env)
+static ADDRESS *set_reverse_name (ENVELOPE * env)
 {
   ADDRESS *tmp;
 
-  for (tmp = env->to; tmp; tmp = tmp->next)
-  {
+  for (tmp = env->to; tmp; tmp = tmp->next) {
     if (mutt_addr_is_user (tmp))
       break;
   }
-  if (!tmp)
-  {
-    for (tmp = env->cc; tmp; tmp = tmp->next)
-    {
+  if (!tmp) {
+    for (tmp = env->cc; tmp; tmp = tmp->next) {
       if (mutt_addr_is_user (tmp))
-       break;
+        break;
     }
   }
   if (!tmp && mutt_addr_is_user (env->from))
     tmp = env->from;
-  if (tmp)
-  {
+  if (tmp) {
     tmp = rfc822_cpy_adr_real (tmp);
     if (!option (OPTREVREAL))
       FREE (&tmp->personal);
@@ -1050,7 +989,7 @@ static ADDRESS *set_reverse_name (ENVELOPE *env)
 ADDRESS *mutt_default_from (void)
 {
   ADDRESS *adr;
-  const char *fqdn = mutt_fqdn(1);
+  const char *fqdn = mutt_fqdn (1);
 
   /* 
    * Note: We let $from override $realname here.  Is this the right
@@ -1059,50 +998,48 @@ ADDRESS *mutt_default_from (void)
 
   if (From)
     adr = rfc822_cpy_adr_real (From);
-  else if (option (OPTUSEDOMAIN))
-  {
+  else if (option (OPTUSEDOMAIN)) {
     adr = rfc822_new_address ();
-    adr->mailbox = safe_malloc (mutt_strlen (Username) + mutt_strlen (fqdn) + 2);
-    sprintf (adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn));   /* __SPRINTF_CHECKED__ */
+    adr->mailbox =
+      safe_malloc (mutt_strlen (Username) + mutt_strlen (fqdn) + 2);
+    sprintf (adr->mailbox, "%s@%s", NONULL (Username), NONULL (fqdn));  /* __SPRINTF_CHECKED__ */
   }
-  else
-  {
+  else {
     adr = rfc822_new_address ();
-    adr->mailbox = safe_strdup (NONULL(Username));
+    adr->mailbox = safe_strdup (NONULL (Username));
   }
-  
+
   return (adr);
 }
 
-static int send_message (HEADER *msg)
-{  
+static int send_message (HEADER * msg)
+{
   char tempfile[_POSIX_PATH_MAX];
   FILE *tempfp;
   int i;
-  
+
   /* Write out the message in MIME form. */
   mutt_mktemp (tempfile);
   if ((tempfp = safe_fopen (tempfile, "w")) == NULL)
     return (-1);
 
 #ifdef MIXMASTER
-  mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0, msg->chain ? 1 : 0);
+  mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0,
+                            msg->chain ? 1 : 0);
 #endif
 #ifndef MIXMASTER
   mutt_write_rfc822_header (tempfp, msg->env, msg->content, 0, 0);
 #endif
-  
-  fputc ('\n', tempfp); /* tie off the header. */
 
-  if ((mutt_write_mime_body (msg->content, tempfp) == -1))
-  {
-    fclose(tempfp);
+  fputc ('\n', tempfp);         /* tie off the header. */
+
+  if ((mutt_write_mime_body (msg->content, tempfp) == -1)) {
+    fclose (tempfp);
     unlink (tempfile);
     return (-1);
   }
-  
-  if (fclose (tempfp) != 0)
-  {
+
+  if (fclose (tempfp) != 0) {
     mutt_perror (tempfile);
     unlink (tempfile);
     return (-1);
@@ -1113,20 +1050,19 @@ static int send_message (HEADER *msg)
     return mix_send_message (msg->chain, tempfile);
 #endif
 
-  i = mutt_invoke_mta (msg->env->from, msg->env->to, msg->env->cc, 
-                           msg->env->bcc, tempfile, (msg->content->encoding == ENC8BIT));
+  i = mutt_invoke_mta (msg->env->from, msg->env->to, msg->env->cc,
+                       msg->env->bcc, tempfile,
+                       (msg->content->encoding == ENC8BIT));
   return (i);
 }
 
 /* rfc2047 encode the content-descriptions */
-static void encode_descriptions (BODY *b, short recurse)
+static void encode_descriptions (BODY * b, short recurse)
 {
   BODY *t;
 
-  for (t = b; t; t = t->next)
-  {
-    if (t->description)
-    {
+  for (t = b; t; t = t->next) {
+    if (t->description) {
       rfc2047_encode_string (&t->description);
     }
     if (recurse && t->parts)
@@ -1135,14 +1071,12 @@ static void encode_descriptions (BODY *b, short recurse)
 }
 
 /* rfc2047 decode them in case of an error */
-static void decode_descriptions (BODY *b)
+static void decode_descriptions (BODY * b)
 {
   BODY *t;
-  
-  for (t = b; t; t = t->next)
-  {
-    if (t->description)
-    {
+
+  for (t = b; t; t = t->next) {
+    if (t->description) {
       rfc2047_decode (&t->description);
     }
     if (t->parts)
@@ -1150,25 +1084,24 @@ static void decode_descriptions (BODY *b)
   }
 }
 
-int mutt_resend_message (FILE *fp, CONTEXT *ctx, HEADER *cur)
+int mutt_resend_message (FILE * fp, CONTEXT * ctx, HEADER * cur)
 {
   HEADER *msg = mutt_new_header ();
-  
+
   if (mutt_prepare_template (fp, ctx, msg, cur, 1) < 0)
     return -1;
-  
+
   return ci_send_message (SENDRESEND, msg, NULL, ctx, cur);
 }
 
-int
-ci_send_message (int flags,            /* send mode */
-                HEADER *msg,           /* template to use for new message */
-                char *tempfile,        /* file specified by -i or -H */
-                CONTEXT *ctx,          /* current mailbox */
-                HEADER *cur)           /* current message */
-{
+int ci_send_message (int flags, /* send mode */
+                     HEADER * msg,      /* template to use for new message */
+                     char *tempfile,    /* file specified by -i or -H */
+                     CONTEXT * ctx,     /* current mailbox */
+                     HEADER * cur)
+{                               /* current message */
   char buffer[LONG_STRING];
-  char fcc[_POSIX_PATH_MAX] = ""; /* where to copy this message */
+  char fcc[_POSIX_PATH_MAX] = "";       /* where to copy this message */
   FILE *tempfp = NULL;
   BODY *pbody;
   int i, killfrom = 0;
@@ -1178,12 +1111,13 @@ ci_send_message (int flags,             /* send mode */
   BODY *save_content = NULL;
   BODY *clear_content = NULL;
   char *pgpkeylist = NULL;
+
   /* save current value of "pgp_sign_as" */
   char *signas = NULL;
   char *tag = NULL, *err = NULL;
 
   int rv = -1;
-  
+
 #ifdef USE_NNTP
   if (flags & SENDNEWS)
     set_option (OPTNEWSSEND);
@@ -1192,59 +1126,54 @@ ci_send_message (int flags,             /* send mode */
 #endif
 
   if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
-      mutt_num_postponed (1))
-  {
+      mutt_num_postponed (1)) {
     /* If the user is composing a new message, check to see if there
      * are any postponed messages first.
      */
-    if ((i = query_quadoption (OPT_RECALL, _("Recall postponed message?"))) == -1)
+    if ((i =
+         query_quadoption (OPT_RECALL, _("Recall postponed message?"))) == -1)
       return rv;
 
-    if(i == M_YES)
+    if (i == M_YES)
       flags |= SENDPOSTPONED;
   }
-  
-  
+
+
   if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))
-    signas = safe_strdup(PgpSignAs);
+    signas = safe_strdup (PgpSignAs);
 
   /* Delay expansion of aliases until absolutely necessary--shouldn't
    * be necessary unless we are prompting the user or about to execute a
    * send-hook.
    */
 
-  if (!msg)
-  {
+  if (!msg) {
     msg = mutt_new_header ();
 
-    if (flags == SENDPOSTPONED)
-    {
-      if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
-       goto cleanup;
+    if (flags == SENDPOSTPONED) {
+      if ((flags =
+           mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
+        goto cleanup;
 #ifdef USE_NNTP
       /*
        * If postponed message is a news article, it have
        * a "Newsgroups:" header line, then set appropriate flag.
        */
-      if (msg->env->newsgroups)
-      {
-       flags |= SENDNEWS;
-       set_option (OPTNEWSSEND);
+      if (msg->env->newsgroups) {
+        flags |= SENDNEWS;
+        set_option (OPTNEWSSEND);
       }
-      else
-      {
-       flags &= ~SENDNEWS;
-       unset_option (OPTNEWSSEND);
+      else {
+        flags &= ~SENDNEWS;
+        unset_option (OPTNEWSSEND);
       }
 #endif
     }
 
-    if (flags & (SENDPOSTPONED|SENDRESEND))
-    {
-      if ((tempfp = safe_fopen (msg->content->filename, "a+")) == NULL)
-      {
-       mutt_perror (msg->content->filename);
-       goto cleanup;
+    if (flags & (SENDPOSTPONED | SENDRESEND)) {
+      if ((tempfp = safe_fopen (msg->content->filename, "a+")) == NULL) {
+        mutt_perror (msg->content->filename);
+        goto cleanup;
       }
     }
 
@@ -1253,51 +1182,49 @@ ci_send_message (int flags,             /* send mode */
   }
 
   /* Parse and use an eventual list-post header */
-  if ((flags & SENDLISTREPLY) 
-      && cur && cur->env && cur->env->list_post) 
-  {
+  if ((flags & SENDLISTREPLY)
+      && cur && cur->env && cur->env->list_post) {
     /* Use any list-post header as a template */
     url_parse_mailto (msg->env, NULL, cur->env->list_post);
     /* We don't let them set the sender's address. */
     rfc822_free_address (&msg->env->from);
   }
-  
-  if (! (flags & (SENDKEY | SENDPOSTPONED | SENDRESEND)))
-  {
+
+  if (!(flags & (SENDKEY | SENDPOSTPONED | SENDRESEND))) {
     pbody = mutt_new_body ();
     pbody->next = msg->content; /* don't kill command-line attachments */
     msg->content = pbody;
-    
+
     mutt_parse_content_type (ContentType, msg->content);
     msg->content->unlink = 1;
     msg->content->use_disp = 0;
     msg->content->disposition = DISPINLINE;
-    if (option (OPTTEXTFLOWED) && msg->content->type == TYPETEXT && !ascii_strcasecmp (msg->content->subtype, "plain"))
+    if (option (OPTTEXTFLOWED) && msg->content->type == TYPETEXT
+        && !ascii_strcasecmp (msg->content->subtype, "plain"))
       mutt_set_parameter ("format", "flowed", &msg->content->parameter);
-    
-    if (!tempfile)
-    {
+
+    if (!tempfile) {
       mutt_mktemp (buffer);
       tempfp = safe_fopen (buffer, "w+");
       msg->content->filename = safe_strdup (buffer);
     }
-    else
-    {
+    else {
       tempfp = safe_fopen (tempfile, "a+");
       msg->content->filename = safe_strdup (tempfile);
     }
 
-    if (!tempfp)
-    {
-      dprint(1,(debugfile, "newsend_message: can't create tempfile %s (errno=%d)\n", msg->content->filename, errno));
+    if (!tempfp) {
+      dprint (1,
+              (debugfile,
+               "newsend_message: can't create tempfile %s (errno=%d)\n",
+               msg->content->filename, errno));
       mutt_perror (msg->content->filename);
       goto cleanup;
     }
   }
 
   /* this is handled here so that the user can match ~f in send-hook */
-  if (cur && option (OPTREVNAME) && !(flags & (SENDPOSTPONED|SENDRESEND)))
-  {
+  if (cur && option (OPTREVNAME) && !(flags & (SENDPOSTPONED | SENDRESEND))) {
     /* we shouldn't have to worry about freeing `msg->env->from' before
      * setting it here since this code will only execute when doing some
      * sort of reply.  the pointer will only be set when using the -H command
@@ -1313,23 +1240,21 @@ ci_send_message (int flags,             /* send mode */
     msg->env->from = set_reverse_name (cur->env);
   }
 
-  if (!msg->env->from && option (OPTUSEFROM) && !(flags & (SENDPOSTPONED|SENDRESEND)))
+  if (!msg->env->from && option (OPTUSEFROM)
+      && !(flags & (SENDPOSTPONED | SENDRESEND)))
     msg->env->from = mutt_default_from ();
 
-  if (flags & SENDBATCH) 
-  {
+  if (flags & SENDBATCH) {
     mutt_copy_stream (stdin, tempfp);
-    if (option (OPTHDRS))
-    {
+    if (option (OPTHDRS)) {
       process_user_recips (msg->env);
       process_user_header (msg->env);
     }
     mutt_expand_aliases_env (msg->env);
   }
-  else if (! (flags & (SENDPOSTPONED|SENDRESEND)))
-  {
+  else if (!(flags & (SENDPOSTPONED | SENDRESEND))) {
     if ((flags & (SENDREPLY | SENDFORWARD)) && ctx &&
-       envelope_defaults (msg->env, ctx, cur, flags) == -1)
+        envelope_defaults (msg->env, ctx, cur, flags) == -1)
       goto cleanup;
 
     if (option (OPTHDRS))
@@ -1339,16 +1264,16 @@ ci_send_message (int flags,             /* send mode */
     mutt_fix_reply_recipients (msg->env);
 
 #ifdef USE_NNTP
-    if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP && !msg->env->newsgroups)
-      msg->env->newsgroups = safe_strdup (((NNTP_DATA *)ctx->data)->group);
+    if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP
+        && !msg->env->newsgroups)
+      msg->env->newsgroups = safe_strdup (((NNTP_DATA *) ctx->data)->group);
 #endif
 
-    if (! (flags & SENDMAILX) &&
-       ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
-       ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
-    {
+    if (!(flags & SENDMAILX) &&
+        !(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
+        !((flags & SENDREPLY) && option (OPTFASTREPLY))) {
       if (edit_envelope (msg->env, flags) == -1)
-       goto cleanup;
+        goto cleanup;
     }
 
     /* the from address must be set here regardless of whether or not
@@ -1356,14 +1281,12 @@ ci_send_message (int flags,             /* send mode */
      * patterns will work.  if $use_from is unset, the from address is killed
      * after send-hooks are evaulated */
 
-    if (!msg->env->from)
-    {
+    if (!msg->env->from) {
       msg->env->from = mutt_default_from ();
       killfrom = 1;
     }
 
-    if ((flags & SENDREPLY) && cur)
-    {
+    if ((flags & SENDREPLY) && cur) {
       /* change setting based upon message we are replying to */
       mutt_message_hook (ctx, cur, M_REPLYHOOK);
 
@@ -1376,7 +1299,7 @@ ci_send_message (int flags,               /* send mode */
     }
 
     /* change settings based upon recipients */
-    
+
     mutt_message_hook (NULL, msg, M_SENDHOOK);
 
     /*
@@ -1387,8 +1310,7 @@ ci_send_message (int flags,               /* send mode */
      */
     msg->replied = 0;
 
-    if (killfrom)
-    {
+    if (killfrom) {
       rfc822_free_address (&msg->env->from);
       killfrom = 0;
     }
@@ -1397,15 +1319,19 @@ ci_send_message (int flags,             /* send mode */
       process_user_header (msg->env);
 
 
-    if (option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0))
+    if (option (OPTSIGONTOP)
+        && (!(flags & (SENDMAILX | SENDKEY)) && Editor
+            && mutt_strcmp (Editor, "builtin") != 0))
       append_signature (tempfp);
 
     /* include replies/forwarded messages, unless we are given a template */
-    if (!tempfile && (ctx || !(flags & (SENDREPLY|SENDFORWARD)))
-       && generate_body (tempfp, msg, flags, ctx, cur) == -1)
+    if (!tempfile && (ctx || !(flags & (SENDREPLY | SENDFORWARD)))
+        && generate_body (tempfp, msg, flags, ctx, cur) == -1)
       goto cleanup;
 
-    if (!option (OPTSIGONTOP) && (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0))
+    if (!option (OPTSIGONTOP)
+        && (!(flags & (SENDMAILX | SENDKEY)) && Editor
+            && mutt_strcmp (Editor, "builtin") != 0))
       append_signature (tempfp);
 
     /* 
@@ -1413,29 +1339,27 @@ ci_send_message (int flags,             /* send mode */
      * can take effect.
      */
 
-    if (WithCrypto && !(flags & SENDMAILX))
-    {
+    if (WithCrypto && !(flags & SENDMAILX)) {
       if (option (OPTCRYPTAUTOSIGN))
-       msg->security |= SIGN;
+        msg->security |= SIGN;
       if (option (OPTCRYPTAUTOENCRYPT))
-       msg->security |= ENCRYPT;
+        msg->security |= ENCRYPT;
       if (option (OPTCRYPTREPLYENCRYPT) && cur && (cur->security & ENCRYPT))
-       msg->security |= ENCRYPT;
+        msg->security |= ENCRYPT;
       if (option (OPTCRYPTREPLYSIGN) && cur && (cur->security & SIGN))
-       msg->security |= SIGN;
-      if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur && (cur->security & ENCRYPT))
-       msg->security |= SIGN;
-      if (WithCrypto & APPLICATION_PGP && (msg->security & (ENCRYPT | SIGN)))
-      {
-       if (option (OPTPGPAUTOINLINE))
-         msg->security |= INLINE;
-       if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))
-         msg->security |= INLINE;
+        msg->security |= SIGN;
+      if (option (OPTCRYPTREPLYSIGNENCRYPTED) && cur
+          && (cur->security & ENCRYPT))
+        msg->security |= SIGN;
+      if (WithCrypto & APPLICATION_PGP && (msg->security & (ENCRYPT | SIGN))) {
+        if (option (OPTPGPAUTOINLINE))
+          msg->security |= INLINE;
+        if (option (OPTPGPREPLYINLINE) && cur && (cur->security & INLINE))
+          msg->security |= INLINE;
       }
     }
 
-    if (WithCrypto && msg->security)
-    {
+    if (WithCrypto && msg->security) {
       /* 
        * When reypling / forwarding, use the original message's
        * crypto system.  According to the documentation,
@@ -1445,63 +1369,61 @@ ci_send_message (int flags,             /* send mode */
        * make much sense. Should we have an option to completely
        * disable individual mechanisms at run-time?
        */
-      if (cur)
-      {
-       if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP) 
-           && (cur->security & APPLICATION_PGP))
-         msg->security |= APPLICATION_PGP;
-       else if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME)
-                && (cur->security & APPLICATION_SMIME))
-         msg->security |= APPLICATION_SMIME;
+      if (cur) {
+        if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP)
+            && (cur->security & APPLICATION_PGP))
+          msg->security |= APPLICATION_PGP;
+        else if ((WithCrypto & APPLICATION_SMIME)
+                 && option (OPTCRYPTAUTOSMIME)
+                 && (cur->security & APPLICATION_SMIME))
+          msg->security |= APPLICATION_SMIME;
       }
-      
+
       /*
        * No crypto mechanism selected? Use availability + smime_is_default
        * for the decision. 
        */
-      if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP)))
-      {
-       if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME) 
-           && option (OPTSMIMEISDEFAULT))
-         msg->security |= APPLICATION_SMIME;
-       else if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP))
-         msg->security |= APPLICATION_PGP;
-       else if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME))
-         msg->security |= APPLICATION_SMIME;
+      if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP))) {
+        if ((WithCrypto & APPLICATION_SMIME) && option (OPTCRYPTAUTOSMIME)
+            && option (OPTSMIMEISDEFAULT))
+          msg->security |= APPLICATION_SMIME;
+        else if ((WithCrypto & APPLICATION_PGP) && option (OPTCRYPTAUTOPGP))
+          msg->security |= APPLICATION_PGP;
+        else if ((WithCrypto & APPLICATION_SMIME)
+                 && option (OPTCRYPTAUTOSMIME))
+          msg->security |= APPLICATION_SMIME;
       }
     }
-    
+
     /* No permissible mechanisms found.  Don't sign or encrypt. */
-    if (!(msg->security & (APPLICATION_SMIME|APPLICATION_PGP)))
+    if (!(msg->security & (APPLICATION_SMIME | APPLICATION_PGP)))
       msg->security = 0;
   }
-  
+
   /* 
    * This hook is even called for postponed messages, and can, e.g., be
    * used for setting the editor, the sendmail path, or the
    * envelope sender.
    */
   mutt_message_hook (NULL, msg, M_SEND2HOOK);
-  
+
   /* wait until now to set the real name portion of our return address so
      that $realname can be set in a send-hook */
   if (msg->env->from && !msg->env->from->personal
-      && !(flags & (SENDRESEND|SENDPOSTPONED)))
+      && !(flags & (SENDRESEND | SENDPOSTPONED)))
     msg->env->from->personal = safe_strdup (Realname);
 
   if (!((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY)))
     safe_fclose (&tempfp);
 
-  if (flags & SENDMAILX)
-  {
+  if (flags & SENDMAILX) {
     if (mutt_builtin_editor (msg->content->filename, msg, cur) == -1)
       goto cleanup;
   }
-  else if (! (flags & SENDBATCH))
-  {
+  else if (!(flags & SENDBATCH)) {
     struct stat st;
     time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL);
-    
+
     mutt_update_encoding (msg->content);
 
     /*
@@ -1514,111 +1436,111 @@ ci_send_message (int flags,           /* send mode */
      *    setting of $forward_edit because the user probably needs to add the
      *    recipients.
      */
-    if (! (flags & SENDKEY) &&
-       ((flags & SENDFORWARD) == 0 ||
-        (option (OPTEDITHDRS) && option (OPTAUTOEDIT)) ||
-        query_quadoption (OPT_FORWEDIT, _("Edit forwarded message?")) == M_YES))
-    {
+    if (!(flags & SENDKEY) &&
+        ((flags & SENDFORWARD) == 0 ||
+         (option (OPTEDITHDRS) && option (OPTAUTOEDIT)) ||
+         query_quadoption (OPT_FORWEDIT,
+                           _("Edit forwarded message?")) == M_YES)) {
       /* If the this isn't a text message, look for a mailcap edit command */
       if (mutt_needs_mailcap (msg->content))
-       mutt_edit_attachment (msg->content);
+        mutt_edit_attachment (msg->content);
       else if (!Editor || mutt_strcmp ("builtin", Editor) == 0)
-       mutt_builtin_editor (msg->content->filename, msg, cur);
-      else if (option (OPTEDITHDRS))
-      {
-       mutt_env_to_local (msg->env);
-       mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc));
-       mutt_env_to_idna (msg->env, NULL, NULL);
+        mutt_builtin_editor (msg->content->filename, msg, cur);
+      else if (option (OPTEDITHDRS)) {
+        mutt_env_to_local (msg->env);
+        mutt_edit_headers (Editor, msg->content->filename, msg, fcc,
+                           sizeof (fcc));
+        mutt_env_to_idna (msg->env, NULL, NULL);
       }
       else
-       mutt_edit_file (Editor, msg->content->filename);
-      
+        mutt_edit_file (Editor, msg->content->filename);
+
       mutt_message_hook (NULL, msg, M_SEND2HOOK);
     }
 
-    if (! (flags & (SENDPOSTPONED | SENDFORWARD | SENDKEY | SENDRESEND)))
-    {
-      if (stat (msg->content->filename, &st) == 0)
-      {
-       /* if the file was not modified, bail out now */
-       if (mtime == st.st_mtime && !msg->content->next &&
-           query_quadoption (OPT_ABORT, _("Abort unmodified message?")) == M_YES)
-       {
-         mutt_message _("Aborted unmodified message.");
-         goto cleanup;
-       }
+    if (!(flags & (SENDPOSTPONED | SENDFORWARD | SENDKEY | SENDRESEND))) {
+      if (stat (msg->content->filename, &st) == 0) {
+        /* if the file was not modified, bail out now */
+        if (mtime == st.st_mtime && !msg->content->next &&
+            query_quadoption (OPT_ABORT,
+                              _("Abort unmodified message?")) == M_YES) {
+          mutt_message _("Aborted unmodified message.");
+
+          goto cleanup;
+        }
       }
       else
-       mutt_perror (msg->content->filename);
+        mutt_perror (msg->content->filename);
     }
   }
 
   /* specify a default fcc.  if we are in batchmode, only save a copy of
    * the message if the value of $copy is yes or ask-yes */
 
-  if (!fcc[0] && !(flags & (SENDPOSTPONED)) && (!(flags & SENDBATCH) || (quadoption (OPT_COPY) & 0x1)))
-  {
+  if (!fcc[0] && !(flags & (SENDPOSTPONED))
+      && (!(flags & SENDBATCH) || (quadoption (OPT_COPY) & 0x1))) {
     /* set the default FCC */
-    if (!msg->env->from)
-    {
+    if (!msg->env->from) {
       msg->env->from = mutt_default_from ();
-      killfrom = 1; /* no need to check $use_from because if the user specified
-                      a from address it would have already been set by now */
+      killfrom = 1;             /* no need to check $use_from because if the user specified
+                                   a from address it would have already been set by now */
     }
     mutt_select_fcc (fcc, sizeof (fcc), msg);
-    if (killfrom)
-    {
+    if (killfrom) {
       rfc822_free_address (&msg->env->from);
       killfrom = 0;
     }
   }
 
-  
+
   mutt_update_encoding (msg->content);
 
-  if (! (flags & (SENDMAILX | SENDBATCH)))
-  {
-main_loop:
+  if (!(flags & (SENDMAILX | SENDBATCH))) {
+  main_loop:
 
-    fcc_error = 0; /* reset value since we may have failed before */
+    fcc_error = 0;              /* reset value since we may have failed before */
     mutt_pretty_mailbox (fcc);
     i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur);
-    if (i == -1)
-    {
+    if (i == -1) {
       /* abort */
 #ifdef USE_NNTP
       if (flags & SENDNEWS)
-       mutt_message _("Article not posted.");
+        mutt_message (_("Article not posted."));
+
       else
 #endif
-      mutt_message _("Mail not sent.");
+        mutt_message _("Mail not sent.");
       goto cleanup;
     }
-    else if (i == 1)
-    {
+    else if (i == 1) {
       /* postpone the message until later. */
       if (msg->content->next)
-       msg->content = mutt_make_multipart (msg->content);
+        msg->content = mutt_make_multipart (msg->content);
 
       /*
        * make sure the message is written to the right part of a maildir 
        * postponed folder.
        */
-      msg->read = 0; msg->old = 0;
+      msg->read = 0;
+      msg->old = 0;
 
       encode_descriptions (msg->content, 1);
       mutt_prepare_envelope (msg->env, 0);
-      mutt_env_to_idna (msg->env, NULL, NULL); /* Handle bad IDNAs the next time. */
-
-      if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur && (flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc) < 0)
-      {
-       msg->content = mutt_remove_multipart (msg->content);
-       decode_descriptions (msg->content);
-       mutt_unprepare_envelope (msg->env);
-       goto main_loop;
+      mutt_env_to_idna (msg->env, NULL, NULL);  /* Handle bad IDNAs the next time. */
+
+      if (!Postponed
+          || mutt_write_fcc (NONULL (Postponed), msg,
+                             (cur
+                              && (flags & SENDREPLY)) ? cur->env->
+                             message_id : NULL, 1, fcc) < 0) {
+        msg->content = mutt_remove_multipart (msg->content);
+        decode_descriptions (msg->content);
+        mutt_unprepare_envelope (msg->env);
+        goto main_loop;
       }
       mutt_update_num_postponed ();
       mutt_message _("Message postponed.");
+
       goto cleanup;
     }
   }
@@ -1626,48 +1548,48 @@ main_loop:
 #ifdef USE_NNTP
   if (!(flags & SENDNEWS))
 #endif
-  if (!msg->env->to && !msg->env->cc && !msg->env->bcc)
-  {
-    if (! (flags & SENDBATCH))
-    {
-      mutt_error _("No recipients are specified!");
-      goto main_loop;
-    }
-    else
-    {
-      puts _("No recipients were specified.");
-      goto cleanup;
+    if (!msg->env->to && !msg->env->cc && !msg->env->bcc) {
+      if (!(flags & SENDBATCH)) {
+        mutt_error _("No recipients are specified!");
+
+        goto main_loop;
+      }
+      else {
+        puts _("No recipients were specified.");
+
+        goto cleanup;
+      }
     }
-  }
 
-  if (mutt_env_to_idna (msg->env, &tag, &err))
-  {
+  if (mutt_env_to_idna (msg->env, &tag, &err)) {
     mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
     FREE (&err);
     if (!(flags & SENDBATCH))
       goto main_loop;
-    else 
+    else
       goto cleanup;
   }
-  
-  if (!msg->env->subject && ! (flags & SENDBATCH) &&
-      (i = query_quadoption (OPT_SUBJECT, _("No subject, abort sending?"))) != M_NO)
-  {
+
+  if (!msg->env->subject && !(flags & SENDBATCH) &&
+      (i =
+       query_quadoption (OPT_SUBJECT,
+                         _("No subject, abort sending?"))) != M_NO) {
     /* if the abort is automatic, print an error message */
     if (quadoption (OPT_SUBJECT) == M_YES)
       mutt_error _("No subject specified.");
+
     goto main_loop;
   }
 #ifdef USE_NNTP
-  if ((flags & SENDNEWS) && !msg->env->subject)
-  {
+  if ((flags & SENDNEWS) && !msg->env->subject) {
     mutt_error _("No subject specified.");
+
     goto main_loop;
   }
 
-  if ((flags & SENDNEWS) && !msg->env->newsgroups)
-  {
+  if ((flags & SENDNEWS) && !msg->env->newsgroups) {
     mutt_error _("No newsgroup specified.");
+
     goto main_loop;
   }
 #endif
@@ -1682,37 +1604,34 @@ main_loop:
    */
 
   encode_descriptions (msg->content, 1);
-  
+
   /*
    * Make sure that clear_content and free_clear_content are
    * properly initialized -- we may visit this particular place in
    * the code multiple times, including after a failed call to
    * mutt_protect().
    */
-  
+
   clear_content = NULL;
   free_clear_content = 0;
-  
-  if (WithCrypto)
-  {
-    if (msg->security)  
-    {
+
+  if (WithCrypto) {
+    if (msg->security) {
       /* save the decrypted attachments */
       clear_content = msg->content;
-  
+
       if ((crypt_get_keys (msg, &pgpkeylist) == -1) ||
-          mutt_protect (msg, pgpkeylist) == -1)
-      {
+          mutt_protect (msg, pgpkeylist) == -1) {
         msg->content = mutt_remove_multipart (msg->content);
-        
-       FREE (&pgpkeylist);
-        
+
+        FREE (&pgpkeylist);
+
         decode_descriptions (msg->content);
         goto main_loop;
       }
       encode_descriptions (msg->content, 0);
     }
-  
+
     /* 
      * at this point, msg->content is one of the following three things:
      * - multipart/signed.  In this case, clear_content is a child.
@@ -1721,9 +1640,9 @@ main_loop:
      * - application/pgp.  In this case, clear_content exists independently.
      * - something else.  In this case, it's the same as clear_content.
      */
-  
+
     /* This is ugly -- lack of "reporting back" from mutt_protect(). */
-    
+
     if (clear_content && (msg->content != clear_content)
         && (msg->content->parts != clear_content))
       free_clear_content = 1;
@@ -1738,7 +1657,7 @@ main_loop:
 
   mutt_expand_path (fcc, sizeof (fcc));
 
-  
+
   /* Don't save a copy when we are in batch-mode, and the FCC
    * folder is on an IMAP server: This would involve possibly lots
    * of user interaction, which is not available in batch mode. 
@@ -1753,8 +1672,7 @@ main_loop:
     fcc[0] = '\0';
 #endif
 
-  if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0)
-  {
+  if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0) {
     BODY *tmpbody = msg->content;
     BODY *save_sig = NULL;
     BODY *save_parts = NULL;
@@ -1763,67 +1681,58 @@ main_loop:
       msg->content = clear_content;
 
     /* check to see if the user wants copies of all attachments */
-    if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART)
-    {
+    if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART) {
       if (WithCrypto
           && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 ||
-              mutt_strcmp (msg->content->subtype, "signed") == 0))
-      {
-       if (clear_content->type == TYPEMULTIPART)
-       {
-         if(!(msg->security & ENCRYPT) && (msg->security & SIGN))
-         {
-           /* save initial signature and attachments */
-           save_sig = msg->content->parts->next;
-           save_parts = clear_content->parts->next;
-         }
-
-         /* this means writing only the main part */
-         msg->content = clear_content->parts;
-
-         if (mutt_protect (msg, pgpkeylist) == -1)
-         {
-           /* we can't do much about it at this point, so
-            * fallback to saving the whole thing to fcc
-            */
-           msg->content = tmpbody;
-           save_sig = NULL;
-           goto full_fcc;
-         }
-
-         save_content = msg->content;
-       }
+              mutt_strcmp (msg->content->subtype, "signed") == 0)) {
+        if (clear_content->type == TYPEMULTIPART) {
+          if (!(msg->security & ENCRYPT) && (msg->security & SIGN)) {
+            /* save initial signature and attachments */
+            save_sig = msg->content->parts->next;
+            save_parts = clear_content->parts->next;
+          }
+
+          /* this means writing only the main part */
+          msg->content = clear_content->parts;
+
+          if (mutt_protect (msg, pgpkeylist) == -1) {
+            /* we can't do much about it at this point, so
+             * fallback to saving the whole thing to fcc
+             */
+            msg->content = tmpbody;
+            save_sig = NULL;
+            goto full_fcc;
+          }
+
+          save_content = msg->content;
+        }
       }
       else
-       msg->content = msg->content->parts;
+        msg->content = msg->content->parts;
     }
 
-full_fcc:
-    if (msg->content)
-    {
+  full_fcc:
+    if (msg->content) {
       /* update received time so that when storing to a mbox-style folder
        * the From_ line contains the current time instead of when the
        * message was first postponed.
        */
       msg->received = time (NULL);
-      if (mutt_write_fcc (fcc, msg, NULL, 0, NULL) == -1)
-      {
-       /*
-        * Error writing FCC, we should abort sending.
-        */
-       fcc_error = 1;
+      if (mutt_write_fcc (fcc, msg, NULL, 0, NULL) == -1) {
+        /*
+         * Error writing FCC, we should abort sending.
+         */
+        fcc_error = 1;
       }
     }
 
     msg->content = tmpbody;
 
-    if (WithCrypto && save_sig)
-    {
+    if (WithCrypto && save_sig) {
       /* cleanup the second signature structures */
-      if (save_content->parts)
-      {
-       mutt_free_body (&save_content->parts->next);
-       save_content->parts = NULL;
+      if (save_content->parts) {
+        mutt_free_body (&save_content->parts->next);
+        save_content->parts = NULL;
       }
       mutt_free_body (&save_content);
 
@@ -1831,8 +1740,7 @@ full_fcc:
       msg->content->parts->next = save_sig;
       msg->content->parts->parts->next = save_parts;
     }
-    else if (WithCrypto && save_content)
-    {
+    else if (WithCrypto && save_content) {
       /* destroy the new encrypted body. */
       mutt_free_body (&save_content);
     }
@@ -1845,23 +1753,18 @@ full_fcc:
    * the send failed as well so we give the user a chance to fix the
    * error.
    */
-  if (fcc_error || (i = send_message (msg)) == -1)
-  {
-    if (!(flags & SENDBATCH))
-    {
-      if (!WithCrypto)
-        ;
-      else if ((msg->security & ENCRYPT) || 
-               ((msg->security & SIGN)
-                && msg->content->type == TYPEAPPLICATION))
-      {
-       mutt_free_body (&msg->content); /* destroy PGP data */
-       msg->content = clear_content;   /* restore clear text. */
+  if (fcc_error || (i = send_message (msg)) == -1) {
+    if (!(flags & SENDBATCH)) {
+      if (!WithCrypto);
+      else if ((msg->security & ENCRYPT) || ((msg->security & SIGN)
+                                             && msg->content->type ==
+                                             TYPEAPPLICATION)) {
+        mutt_free_body (&msg->content); /* destroy PGP data */
+        msg->content = clear_content;   /* restore clear text. */
       }
-      else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART)
-      {
-       mutt_free_body (&msg->content->parts->next);         /* destroy sig */
-       msg->content = mutt_remove_multipart (msg->content); 
+      else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART) {
+        mutt_free_body (&msg->content->parts->next);    /* destroy sig */
+        msg->content = mutt_remove_multipart (msg->content);
       }
 
       msg->content = mutt_remove_multipart (msg->content);
@@ -1869,55 +1772,52 @@ full_fcc:
       mutt_unprepare_envelope (msg->env);
       goto main_loop;
     }
-    else
-    {
+    else {
       puts _("Could not send the message.");
+
       goto cleanup;
     }
   }
-  else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
+  else if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
     mutt_message (i != 0 ? _("Sending in background.") :
 #ifdef USE_NNTP
-                 (flags & SENDNEWS) ? _("Article posted.") : _("Mail sent."));
+                  (flags & SENDNEWS) ? _("Article posted.") :
+                  _("Mail sent."));
 #else
-                 _("Mail sent."));
+                  _("Mail sent."));
 #endif
 
   if (WithCrypto && (msg->security & ENCRYPT))
     FREE (&pgpkeylist);
-  
+
   if (WithCrypto && free_clear_content)
     mutt_free_body (&clear_content);
 
-  if (flags & SENDREPLY)
-  {
+  if (flags & SENDREPLY) {
     if (cur && ctx)
       mutt_set_flag (ctx, cur, M_REPLIED, 1);
-    else if (!(flags & SENDPOSTPONED) && ctx && ctx->tagged)
-    {
+    else if (!(flags & SENDPOSTPONED) && ctx && ctx->tagged) {
       for (i = 0; i < ctx->vcount; i++)
-       if (ctx->hdrs[ctx->v2r[i]]->tagged)
-         mutt_set_flag (ctx, ctx->hdrs[ctx->v2r[i]], M_REPLIED, 1);
+        if (ctx->hdrs[ctx->v2r[i]]->tagged)
+          mutt_set_flag (ctx, ctx->hdrs[ctx->v2r[i]], M_REPLIED, 1);
     }
   }
 
 
   rv = 0;
-  
+
 cleanup:
 
-  if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))
-  {
-    if(signas)
-    {
+  if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) {
+    if (signas) {
       FREE (&PgpSignAs);
       PgpSignAs = signas;
     }
   }
-   
+
   safe_fclose (&tempfp);
   mutt_free_header (&msg);
-  
+
   return rv;
 }
 
index 9ebab5e..cedcd9e 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #define _SENDLIB_C 1
 
 
 extern char RFC822Specials[];
 
-static struct sysexits
-{
+static struct sysexits {
   int v;
   const char *str;
-} 
-sysexits_h[] = 
-{
+} sysexits_h[] = {
 #ifdef EX_USAGE
-  { 0xff & EX_USAGE, "Bad usage." },
+  {
+  0xff & EX_USAGE, "Bad usage."},
 #endif
 #ifdef EX_DATAERR
-  { 0xff & EX_DATAERR, "Data format error." },
+  {
+  0xff & EX_DATAERR, "Data format error."},
 #endif
 #ifdef EX_NOINPUT
-  { 0xff & EX_NOINPUT, "Cannot open input." },
+  {
+  0xff & EX_NOINPUT, "Cannot open input."},
 #endif
 #ifdef EX_NOUSER
-  { 0xff & EX_NOUSER, "User unknown." },
+  {
+  0xff & EX_NOUSER, "User unknown."},
 #endif
 #ifdef EX_NOHOST
-  { 0xff & EX_NOHOST, "Host unknown." },
+  {
+  0xff & EX_NOHOST, "Host unknown."},
 #endif
 #ifdef EX_UNAVAILABLE
-  { 0xff & EX_UNAVAILABLE, "Service unavailable." },
+  {
+  0xff & EX_UNAVAILABLE, "Service unavailable."},
 #endif
 #ifdef EX_SOFTWARE
-  { 0xff & EX_SOFTWARE, "Internal error." },
+  {
+  0xff & EX_SOFTWARE, "Internal error."},
 #endif
 #ifdef EX_OSERR
-  { 0xff & EX_OSERR, "Operating system error." },
+  {
+  0xff & EX_OSERR, "Operating system error."},
 #endif
 #ifdef EX_OSFILE
-  { 0xff & EX_OSFILE, "System file missing." },
+  {
+  0xff & EX_OSFILE, "System file missing."},
 #endif
 #ifdef EX_CANTCREAT
-  { 0xff & EX_CANTCREAT, "Can't create output." },
+  {
+  0xff & EX_CANTCREAT, "Can't create output."},
 #endif
 #ifdef EX_IOERR
-  { 0xff & EX_IOERR, "I/O error." },
+  {
+  0xff & EX_IOERR, "I/O error."},
 #endif
 #ifdef EX_TEMPFAIL
-  { 0xff & EX_TEMPFAIL, "Deferred." },
+  {
+  0xff & EX_TEMPFAIL, "Deferred."},
 #endif
 #ifdef EX_PROTOCOL
-  { 0xff & EX_PROTOCOL, "Remote protocol error." },
+  {
+  0xff & EX_PROTOCOL, "Remote protocol error."},
 #endif
 #ifdef EX_NOPERM
-  { 0xff & EX_NOPERM, "Insufficient permission." },
+  {
+  0xff & EX_NOPERM, "Insufficient permission."},
 #endif
 #ifdef EX_CONFIG
-  { 0xff & EX_NOPERM, "Local configuration error." },
+  {
+  0xff & EX_NOPERM, "Local configuration error."},
 #endif
-  { S_ERR, "Exec error." },
-  { -1, NULL}
+  {
+  S_ERR, "Exec error."}, {
+  -1, NULL}
 };
 
-    
+
 
 #define DISPOSITION(X) X==DISPATTACH?"attachment":"inline"
 
@@ -143,37 +156,33 @@ char B64Chars[64] = {
 
 static char MsgIdPfx = 'A';
 
-static void transform_to_7bit (BODY *a, FILE *fpin);
+static void transform_to_7bit (BODY * a, FILE * fpin);
 
-static void encode_quoted (FGETCONV * fc, FILE *fout, int istext)
+static void encode_quoted (FGETCONV * fc, FILE * fout, int istext)
 {
   int c, linelen = 0;
   char line[77], savechar;
 
-  while ((c = fgetconv (fc)) != EOF)
-  {
+  while ((c = fgetconv (fc)) != EOF) {
     /* Wrap the line if needed. */
-    if (linelen == 76 && ((istext && c != '\n') || !istext))
-    {
+    if (linelen == 76 && ((istext && c != '\n') || !istext)) {
       /* If the last character is "quoted", then be sure to move all three
        * characters to the next line.  Otherwise, just move the last
        * character...
        */
-      if (line[linelen-3] == '=')
-      {
-        line[linelen-3] = 0;
-        fputs (line, fout);      
+      if (line[linelen - 3] == '=') {
+        line[linelen - 3] = 0;
+        fputs (line, fout);
         fputs ("=\n", fout);
         line[linelen] = 0;
         line[0] = '=';
-        line[1] = line[linelen-2];
-        line[2] = line[linelen-1];
+        line[1] = line[linelen - 2];
+        line[2] = line[linelen - 1];
         linelen = 3;
       }
-      else
-      {
-        savechar = line[linelen-1];
-        line[linelen-1] = '=';
+      else {
+        savechar = line[linelen - 1];
+        line[linelen - 1] = '=';
         line[linelen] = 0;
         fputs (line, fout);
         fputc ('\n', fout);
@@ -183,69 +192,60 @@ static void encode_quoted (FGETCONV * fc, FILE *fout, int istext)
     }
 
     /* Escape lines that begin with/only contain "the message separator". */
-    if (linelen == 4 && !mutt_strncmp ("From", line, 4))
-    {
+    if (linelen == 4 && !mutt_strncmp ("From", line, 4)) {
       strfcpy (line, "=46rom", sizeof (line));
       linelen = 6;
     }
-    else if (linelen == 4 && !mutt_strncmp ("from", line, 4))
-    {
+    else if (linelen == 4 && !mutt_strncmp ("from", line, 4)) {
       strfcpy (line, "=66rom", sizeof (line));
       linelen = 6;
     }
-    else if (linelen == 1 && line[0] == '.')
-    {
+    else if (linelen == 1 && line[0] == '.') {
       strfcpy (line, "=2E", sizeof (line));
       linelen = 3;
     }
 
 
-    if (c == '\n' && istext)
-    {
+    if (c == '\n' && istext) {
       /* Check to make sure there is no trailing space on this line. */
-      if (linelen > 0 && (line[linelen-1] == ' ' || line[linelen-1] == '\t'))
-      {
-        if (linelen < 74)
-       {
-          sprintf (line+linelen-1, "=%2.2X", (unsigned char) line[linelen-1]);
+      if (linelen > 0
+          && (line[linelen - 1] == ' ' || line[linelen - 1] == '\t')) {
+        if (linelen < 74) {
+          sprintf (line + linelen - 1, "=%2.2X",
+                   (unsigned char) line[linelen - 1]);
           fputs (line, fout);
         }
-        else
-       {
-          int savechar = line[linelen-1];
+        else {
+          int savechar = line[linelen - 1];
 
-          line[linelen-1] = '=';
+          line[linelen - 1] = '=';
           line[linelen] = 0;
           fputs (line, fout);
           fprintf (fout, "\n=%2.2X", (unsigned char) savechar);
         }
       }
-      else
-      {
+      else {
         line[linelen] = 0;
         fputs (line, fout);
       }
       fputc ('\n', fout);
       linelen = 0;
     }
-    else if (c != 9 && (c < 32 || c > 126 || c == '='))
-    {
+    else if (c != 9 && (c < 32 || c > 126 || c == '=')) {
       /* Check to make sure there is enough room for the quoted character.
        * If not, wrap to the next line.
        */
-      if (linelen > 73)
-      {
+      if (linelen > 73) {
         line[linelen++] = '=';
         line[linelen] = 0;
         fputs (line, fout);
         fputc ('\n', fout);
         linelen = 0;
       }
-      sprintf (line+linelen,"=%2.2X", (unsigned char) c);
+      sprintf (line + linelen, "=%2.2X", (unsigned char) c);
       linelen += 3;
     }
-    else
-    {
+    else {
       /* Don't worry about wrapping the line here.  That will happen during
        * the next iteration when I'll also know what the next character is.
        */
@@ -254,17 +254,15 @@ static void encode_quoted (FGETCONV * fc, FILE *fout, int istext)
   }
 
   /* Take care of anything left in the buffer */
-  if (linelen > 0)
-  {
-    if (line[linelen-1] == ' ' || line[linelen-1] == '\t')
-    {
+  if (linelen > 0) {
+    if (line[linelen - 1] == ' ' || line[linelen - 1] == '\t') {
       /* take care of trailing whitespace */
       if (linelen < 74)
-        sprintf (line+linelen-1, "=%2.2X", (unsigned char) line[linelen-1]);
-      else
-      {
-        savechar = line[linelen-1];
-        line[linelen-1] = '=';
+        sprintf (line + linelen - 1, "=%2.2X",
+                 (unsigned char) line[linelen - 1]);
+      else {
+        savechar = line[linelen - 1];
+        line[linelen - 1] = '=';
         line[linelen] = 0;
         fputs (line, fout);
         fputc ('\n', fout);
@@ -281,84 +279,82 @@ static char b64_buffer[3];
 static short b64_num;
 static short b64_linelen;
 
-static void b64_flush(FILE *fout)
+static void b64_flush (FILE * fout)
 {
   short i;
 
-  if(!b64_num)
+  if (!b64_num)
     return;
 
-  if(b64_linelen >= 72)
-  {
-    fputc('\n', fout);
+  if (b64_linelen >= 72) {
+    fputc ('\n', fout);
     b64_linelen = 0;
   }
-  
-  for(i = b64_num; i < 3; i++)
+
+  for (i = b64_num; i < 3; i++)
     b64_buffer[i] = '\0';
-  
-  fputc(B64Chars[(b64_buffer[0] >> 2) & 0x3f], fout); 
+
+  fputc (B64Chars[(b64_buffer[0] >> 2) & 0x3f], fout);
   b64_linelen++;
-  fputc(B64Chars[((b64_buffer[0] & 0x3) << 4) | ((b64_buffer[1] >> 4) & 0xf) ], fout);
+  fputc (B64Chars
+         [((b64_buffer[0] & 0x3) << 4) | ((b64_buffer[1] >> 4) & 0xf)], fout);
   b64_linelen++;
-  
-  if(b64_num > 1)
-  {
-    fputc(B64Chars[((b64_buffer[1] & 0xf) << 2) | ((b64_buffer[2] >> 6) & 0x3) ], fout);
+
+  if (b64_num > 1) {
+    fputc (B64Chars
+           [((b64_buffer[1] & 0xf) << 2) | ((b64_buffer[2] >> 6) & 0x3)],
+           fout);
     b64_linelen++;
-    if(b64_num > 2)
-    {
-      fputc(B64Chars[b64_buffer[2] & 0x3f], fout);
+    if (b64_num > 2) {
+      fputc (B64Chars[b64_buffer[2] & 0x3f], fout);
       b64_linelen++;
     }
   }
-  
-  while(b64_linelen % 4)
-  {
-    fputc('=', fout);
+
+  while (b64_linelen % 4) {
+    fputc ('=', fout);
     b64_linelen++;
   }
-  
+
   b64_num = 0;
 }
-    
-  
-static void b64_putc(char c, FILE *fout)
+
+
+static void b64_putc (char c, FILE * fout)
 {
-  if(b64_num == 3)
-    b64_flush(fout);
-  
+  if (b64_num == 3)
+    b64_flush (fout);
+
   b64_buffer[b64_num++] = c;
 }
-  
-  
-static void encode_base64 (FGETCONV * fc, FILE *fout, int istext)
+
+
+static void encode_base64 (FGETCONV * fc, FILE * fout, int istext)
 {
   int ch, ch1 = EOF;
-  
+
   b64_num = b64_linelen = 0;
-  
-  while ((ch = fgetconv (fc)) != EOF)
-  {
+
+  while ((ch = fgetconv (fc)) != EOF) {
     if (istext && ch == '\n' && ch1 != '\r')
-      b64_putc('\r', fout);
-    b64_putc(ch, fout);
+      b64_putc ('\r', fout);
+    b64_putc (ch, fout);
     ch1 = ch;
   }
-  b64_flush(fout);
-  fputc('\n', fout);
+  b64_flush (fout);
+  fputc ('\n', fout);
 }
 
-static void encode_8bit (FGETCONV *fc, FILE *fout, int istext)
+static void encode_8bit (FGETCONV * fc, FILE * fout, int istext)
 {
   int ch;
-  
+
   while ((ch = fgetconv (fc)) != EOF)
     fputc (ch, fout);
 }
-  
 
-int mutt_write_mime_header (BODY *a, FILE *f)
+
+int mutt_write_mime_header (BODY * a, FILE * f)
 {
   PARAMETER *p;
   char buffer[STRING];
@@ -367,20 +363,18 @@ int mutt_write_mime_header (BODY *a, FILE *f)
   int len;
   int tmplen;
   int encode;
-  
+
   fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype);
 
-  if (a->parameter)
-  {
-    len = 25 + mutt_strlen (a->subtype); /* approximate len. of content-type */
+  if (a->parameter) {
+    len = 25 + mutt_strlen (a->subtype);        /* approximate len. of content-type */
 
-    for(p = a->parameter; p; p = p->next)
-    {
+    for (p = a->parameter; p; p = p->next) {
       char *tmp;
-      
-      if(!p->value)
-       continue;
-      
+
+      if (!p->value)
+        continue;
+
       fputc (';', f);
 
       buffer[0] = 0;
@@ -393,22 +387,21 @@ int mutt_write_mime_header (BODY *a, FILE *f)
        * even when they aren't needed.
        */
 
-      if (!ascii_strcasecmp (p->attribute, "boundary") && !strcmp (buffer, tmp))
-       snprintf (buffer, sizeof (buffer), "\"%s\"", tmp);
+      if (!ascii_strcasecmp (p->attribute, "boundary")
+          && !strcmp (buffer, tmp))
+        snprintf (buffer, sizeof (buffer), "\"%s\"", tmp);
 
       FREE (&tmp);
 
       tmplen = mutt_strlen (buffer) + mutt_strlen (p->attribute) + 1;
 
-      if (len + tmplen + 2 > 76)
-      {
-       fputs ("\n\t", f);
-       len = tmplen + 8;
+      if (len + tmplen + 2 > 76) {
+        fputs ("\n\t", f);
+        len = tmplen + 8;
       }
-      else
-      {
-       fputc (' ', f);
-       len += tmplen + 1;
+      else {
+        fputc (' ', f);
+        len += tmplen + 1;
       }
 
       fprintf (f, "%s%s=%s", p->attribute, encode ? "*" : "", buffer);
@@ -419,25 +412,23 @@ int mutt_write_mime_header (BODY *a, FILE *f)
   fputc ('\n', f);
 
   if (a->description)
-    fprintf(f, "Content-Description: %s\n", a->description);
+    fprintf (f, "Content-Description: %s\n", a->description);
 
   fprintf (f, "Content-Disposition: %s", DISPOSITION (a->disposition));
 
-  if (a->use_disp)
-  {
-    if(!(fn = a->d_filename))
+  if (a->use_disp) {
+    if (!(fn = a->d_filename))
       fn = a->filename;
-    
-    if (fn)
-    {
+
+    if (fn) {
       char *tmp;
 
       /* Strip off the leading path... */
       if ((t = strrchr (fn, '/')))
-       t++;
+        t++;
       else
-       t = fn;
-      
+        t = fn;
+
       buffer[0] = 0;
       tmp = safe_strdup (t);
       encode = rfc2231_encode_string (&tmp);
@@ -450,7 +441,7 @@ int mutt_write_mime_header (BODY *a, FILE *f)
   fputc ('\n', f);
 
   if (a->encoding != ENC7BIT)
-    fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING (a->encoding));
+    fprintf (f, "Content-Transfer-Encoding: %s\n", ENCODING (a->encoding));
 
   /* Do NOT add the terminator here!!! */
   return (ferror (f) ? -1 : 0);
@@ -460,33 +451,33 @@ int mutt_write_mime_header (BODY *a, FILE *f)
                                  || ((WithCrypto & APPLICATION_PGP)\
                                       && mutt_is_application_pgp(a)))
 
-int mutt_write_mime_body (BODY *a, FILE *f)
+int mutt_write_mime_body (BODY * a, FILE * f)
 {
   char *p, boundary[SHORT_STRING];
   char send_charset[SHORT_STRING];
   FILE *fpin;
   BODY *t;
   FGETCONV *fc;
-  
-  if (a->type == TYPEMULTIPART)
-  {
+
+  if (a->type == TYPEMULTIPART) {
     /* First, find the boundary to use */
-    if (!(p = mutt_get_parameter ("boundary", a->parameter)))
-    {
-      dprint (1, (debugfile, "mutt_write_mime_body(): no boundary parameter found!\n"));
+    if (!(p = mutt_get_parameter ("boundary", a->parameter))) {
+      dprint (1,
+              (debugfile,
+               "mutt_write_mime_body(): no boundary parameter found!\n"));
       mutt_error _("No boundary parameter found! [report this error]");
+
       return (-1);
     }
     strfcpy (boundary, p, sizeof (boundary));
 
-    for (t = a->parts; t ; t = t->next)
-    {
+    for (t = a->parts; t; t = t->next) {
       fprintf (f, "\n--%s\n", boundary);
       if (mutt_write_mime_header (t, f) == -1)
-       return -1;
+        return -1;
       fputc ('\n', f);
       if (mutt_write_mime_body (t, f) == -1)
-       return -1;
+        return -1;
     }
     fprintf (f, "\n--%s--\n", boundary);
     return (ferror (f) ? -1 : 0);
@@ -495,23 +486,23 @@ int mutt_write_mime_body (BODY *a, FILE *f)
   /* This is pretty gross, but it's the best solution for now... */
   if ((WithCrypto & APPLICATION_PGP)
       && a->type == TYPEAPPLICATION
-      && mutt_strcmp (a->subtype, "pgp-encrypted") == 0)
-  {
+      && mutt_strcmp (a->subtype, "pgp-encrypted") == 0) {
     fputs ("Version: 1\n", f);
     return 0;
   }
 
-  if ((fpin = fopen (a->filename, "r")) == NULL)
-  {
-    dprint(1,(debugfile, "write_mime_body: %s no longer exists!\n",a->filename));
+  if ((fpin = fopen (a->filename, "r")) == NULL) {
+    dprint (1,
+            (debugfile, "write_mime_body: %s no longer exists!\n",
+             a->filename));
     mutt_error (_("%s no longer exists!"), a->filename);
     return -1;
   }
 
   if (a->type == TYPETEXT && (!a->noconv))
-    fc = fgetconv_open (fpin, a->file_charset, 
-                       mutt_get_body_charset (send_charset, sizeof (send_charset), a),
-                       0);
+    fc = fgetconv_open (fpin, a->file_charset,
+                        mutt_get_body_charset (send_charset,
+                                               sizeof (send_charset), a), 0);
   else
     fc = fgetconv_open (fpin, 0, 0, 0);
 
@@ -533,32 +524,31 @@ int mutt_write_mime_body (BODY *a, FILE *f)
 #undef write_as_text_part
 
 #define BOUNDARYLEN 16
-void mutt_generate_boundary (PARAMETER **parm)
+void mutt_generate_boundary (PARAMETER ** parm)
 {
   char rs[BOUNDARYLEN + 1];
   char *p = rs;
   int i;
 
   rs[BOUNDARYLEN] = 0;
-  for (i=0;i<BOUNDARYLEN;i++) 
-    *p++ = B64Chars[LRAND() % sizeof (B64Chars)];
+  for (i = 0; i < BOUNDARYLEN; i++)
+    *p++ = B64Chars[LRAND () % sizeof (B64Chars)];
   *p = 0;
-  
+
   mutt_set_parameter ("boundary", rs, parm);
 }
 
-typedef struct
-{
+typedef struct {
   int from;
   int whitespace;
   int dot;
   int linelen;
   int was_cr;
-}
-CONTENT_STATE;
+} CONTENT_STATE;
 
 
-static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_t dlen)
+static void update_content_info (CONTENT * info, CONTENT_STATE * s, char *d,
+                                 size_t dlen)
 {
   int from = s->from;
   int whitespace = s->whitespace;
@@ -566,8 +556,7 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
   int linelen = s->linelen;
   int was_cr = s->was_cr;
 
-  if (!d) /* This signals EOF */
-  {
+  if (!d) {                     /* This signals EOF */
     if (was_cr)
       info->binary = 1;
     if (linelen > info->linemax)
@@ -576,42 +565,42 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
     return;
   }
 
-  for (; dlen; d++, dlen--)
-  {
+  for (; dlen; d++, dlen--) {
     char ch = *d;
 
-    if (was_cr)
-    {
+    if (was_cr) {
       was_cr = 0;
-      if (ch != '\n')
-      {
+      if (ch != '\n') {
         info->binary = 1;
       }
-      else
-      {
-        if (whitespace) info->space = 1;
-       if (dot) info->dot = 1;
-        if (linelen > info->linemax) info->linemax = linelen;
+      else {
+        if (whitespace)
+          info->space = 1;
+        if (dot)
+          info->dot = 1;
+        if (linelen > info->linemax)
+          info->linemax = linelen;
         whitespace = 0;
-       dot = 0;
+        dot = 0;
         linelen = 0;
-       continue;
+        continue;
       }
     }
 
     linelen++;
-    if (ch == '\n')
-    {
+    if (ch == '\n') {
       info->crlf++;
-      if (whitespace) info->space = 1;
-      if (dot) info->dot = 1;
-      if (linelen > info->linemax) info->linemax = linelen;
+      if (whitespace)
+        info->space = 1;
+      if (dot)
+        info->dot = 1;
+      if (linelen > info->linemax)
+        info->linemax = linelen;
       whitespace = 0;
       linelen = 0;
       dot = 0;
     }
-    else if (ch == '\r')
-    {
+    else if (ch == '\r') {
       info->crlf++;
       info->cr = 1;
       was_cr = 1;
@@ -619,17 +608,14 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
     }
     else if (ch & 0x80)
       info->hibin++;
-    else if (ch == '\t' || ch == '\f')
-    {
+    else if (ch == '\t' || ch == '\f') {
       info->ascii++;
       whitespace++;
     }
     else if (ch < 32 || ch == 127)
       info->lobin++;
-    else
-    {
-      if (linelen == 1)
-      {
+    else {
+      if (linelen == 1) {
         if ((ch == 'F') || (ch == 'f'))
           from = 1;
         else
@@ -639,22 +625,26 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
         else
           dot = 0;
       }
-      else if (from)
-      {
-        if (linelen == 2 && ch != 'r') from = 0;
-        else if (linelen == 3 && ch != 'o') from = 0;
-        else if (linelen == 4)
-       {
-          if (ch == 'm') info->from = 1;
+      else if (from) {
+        if (linelen == 2 && ch != 'r')
+          from = 0;
+        else if (linelen == 3 && ch != 'o')
+          from = 0;
+        else if (linelen == 4) {
+          if (ch == 'm')
+            info->from = 1;
           from = 0;
         }
       }
-      if (ch == ' ') whitespace++;
+      if (ch == ' ')
+        whitespace++;
       info->ascii++;
     }
 
-    if (linelen > 1) dot = 0;
-    if (ch != ' ' && ch != '\t') whitespace = 0;
+    if (linelen > 1)
+      dot = 0;
+    if (ch != ' ' && ch != '\t')
+      whitespace = 0;
   }
 
   s->from = from;
@@ -662,7 +652,7 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
   s->dot = dot;
   s->linelen = linelen;
   s->was_cr = was_cr;
-  
+
 }
 
 /* Define as 1 if iconv sometimes returns -1(EILSEQ) instead of transcribing. */
@@ -684,9 +674,9 @@ static void update_content_info (CONTENT *info, CONTENT_STATE *s, char *d, size_
  * long as the input for any pair of charsets we might be interested
  * in.
  */
-static size_t convert_file_to (FILE *file, const char *fromcode,
-                              int ncodes, const char **tocodes,
-                              int *tocode, CONTENT *info)
+static size_t convert_file_to (FILE * file, const char *fromcode,
+                               int ncodes, const char **tocodes,
+                               int *tocode, CONTENT * info)
 {
 #ifdef HAVE_ICONV
   iconv_t cd1, *cd;
@@ -700,25 +690,24 @@ static size_t convert_file_to (FILE *file, const char *fromcode,
   size_t *score;
 
   cd1 = mutt_iconv_open ("UTF-8", fromcode, 0);
-  if (cd1 == (iconv_t)(-1))
+  if (cd1 == (iconv_t) (-1))
     return -1;
 
-  cd     = safe_calloc (ncodes, sizeof (iconv_t));
-  score  = safe_calloc (ncodes, sizeof (size_t));
+  cd = safe_calloc (ncodes, sizeof (iconv_t));
+  score = safe_calloc (ncodes, sizeof (size_t));
   states = safe_calloc (ncodes, sizeof (CONTENT_STATE));
-  infos  = safe_calloc (ncodes, sizeof (CONTENT));
+  infos = safe_calloc (ncodes, sizeof (CONTENT));
 
   for (i = 0; i < ncodes; i++)
     if (ascii_strcasecmp (tocodes[i], "UTF-8"))
       cd[i] = mutt_iconv_open (tocodes[i], "UTF-8", 0);
     else
       /* Special case for conversion to UTF-8 */
-      cd[i] = (iconv_t)(-1), score[i] = (size_t)(-1);
+      cd[i] = (iconv_t) (-1), score[i] = (size_t) (-1);
 
   rewind (file);
   ibl = 0;
-  for (;;)
-  {
+  for (;;) {
 
     /* Try to fill input buffer */
     n = fread (bufi + ibl, 1, sizeof (bufi) - ibl, file);
@@ -728,82 +717,72 @@ static size_t convert_file_to (FILE *file, const char *fromcode,
     ib = bufi;
     ob = bufu, obl = sizeof (bufu);
     n = iconv (cd1, ibl ? &ib : 0, &ibl, &ob, &obl);
-    assert (n == (size_t)(-1) || !n || ICONV_NONTRANS);
-    if (n == (size_t)(-1) &&
-       ((errno != EINVAL && errno != E2BIG) || ib == bufi))
-    {
+    assert (n == (size_t) (-1) || !n || ICONV_NONTRANS);
+    if (n == (size_t) (-1) &&
+        ((errno != EINVAL && errno != E2BIG) || ib == bufi)) {
       assert (errno == EILSEQ ||
-             (errno == EINVAL && ib == bufi && ibl < sizeof (bufi)));
-      ret = (size_t)(-1);
+              (errno == EINVAL && ib == bufi && ibl < sizeof (bufi)));
+      ret = (size_t) (-1);
       break;
     }
     ubl1 = ob - bufu;
 
     /* Convert from UTF-8 */
     for (i = 0; i < ncodes; i++)
-      if (cd[i] != (iconv_t)(-1) && score[i] != (size_t)(-1))
-      {
-       ub = bufu, ubl = ubl1;
-       ob = bufo, obl = sizeof (bufo);
-       n = iconv (cd[i], (ibl || ubl) ? &ub : 0, &ubl, &ob, &obl);
-       if (n == (size_t)(-1))
-       {
-         assert (errno == E2BIG ||
-                 (BUGGY_ICONV && (errno == EILSEQ || errno == ENOENT)));
-         score[i] = (size_t)(-1);
-       }
-       else
-       {
-         score[i] += n;
-         update_content_info (&infos[i], &states[i], bufo, ob - bufo);
-       }
+      if (cd[i] != (iconv_t) (-1) && score[i] != (size_t) (-1)) {
+        ub = bufu, ubl = ubl1;
+        ob = bufo, obl = sizeof (bufo);
+        n = iconv (cd[i], (ibl || ubl) ? &ub : 0, &ubl, &ob, &obl);
+        if (n == (size_t) (-1)) {
+          assert (errno == E2BIG ||
+                  (BUGGY_ICONV && (errno == EILSEQ || errno == ENOENT)));
+          score[i] = (size_t) (-1);
+        }
+        else {
+          score[i] += n;
+          update_content_info (&infos[i], &states[i], bufo, ob - bufo);
+        }
       }
-      else if (cd[i] == (iconv_t)(-1) && score[i] == (size_t)(-1))
-       /* Special case for conversion to UTF-8 */
-       update_content_info (&infos[i], &states[i], bufu, ubl1);
+      else if (cd[i] == (iconv_t) (-1) && score[i] == (size_t) (-1))
+        /* Special case for conversion to UTF-8 */
+        update_content_info (&infos[i], &states[i], bufu, ubl1);
 
     if (ibl)
       /* Save unused input */
       memmove (bufi, ib, ibl);
-    else if (!ubl1 && ib < bufi + sizeof (bufi))
-    {
+    else if (!ubl1 && ib < bufi + sizeof (bufi)) {
       ret = 0;
       break;
     }
   }
 
-  if (!ret)
-  {
+  if (!ret) {
     /* Find best score */
-    ret = (size_t)(-1);
-    for (i = 0; i < ncodes; i++)
-    {
-      if (cd[i] == (iconv_t)(-1) && score[i] == (size_t)(-1))
-      {
-       /* Special case for conversion to UTF-8 */
-       *tocode = i;
-       ret = 0;
-       break;
+    ret = (size_t) (-1);
+    for (i = 0; i < ncodes; i++) {
+      if (cd[i] == (iconv_t) (-1) && score[i] == (size_t) (-1)) {
+        /* Special case for conversion to UTF-8 */
+        *tocode = i;
+        ret = 0;
+        break;
       }
-      else if (cd[i] == (iconv_t)(-1) || score[i] == (size_t)(-1))
-       continue;
-      else if (ret == (size_t)(-1) || score[i] < ret)
-      {
-       *tocode = i;
-       ret = score[i];
-       if (!ret)
-         break;
+      else if (cd[i] == (iconv_t) (-1) || score[i] == (size_t) (-1))
+        continue;
+      else if (ret == (size_t) (-1) || score[i] < ret) {
+        *tocode = i;
+        ret = score[i];
+        if (!ret)
+          break;
       }
     }
-    if (ret != (size_t)(-1))
-    {
-      memcpy (info, &infos[*tocode], sizeof(CONTENT));
-      update_content_info (info, &states[*tocode], 0, 0); /* EOF */
+    if (ret != (size_t) (-1)) {
+      memcpy (info, &infos[*tocode], sizeof (CONTENT));
+      update_content_info (info, &states[*tocode], 0, 0);       /* EOF */
     }
   }
 
   for (i = 0; i < ncodes; i++)
-    if (cd[i] != (iconv_t)(-1))
+    if (cd[i] != (iconv_t) (-1))
       iconv_close (cd[i]);
 
   iconv_close (cd1);
@@ -829,9 +808,10 @@ static size_t convert_file_to (FILE *file, const char *fromcode,
  * However, if fromcode is zero then fromcodes is assumed to be the
  * name of a single charset even if it contains a colon.
  */
-static size_t convert_file_from_to (FILE *file,
-                                   const char *fromcodes, const char *tocodes,
-                                   char **fromcode, char **tocode, CONTENT *info)
+static size_t convert_file_from_to (FILE * file,
+                                    const char *fromcodes,
+                                    const char *tocodes, char **fromcode,
+                                    char **tocode, CONTENT * info)
 {
   char *fcode;
   char **tcode;
@@ -841,8 +821,7 @@ static size_t convert_file_from_to (FILE *file,
 
   /* Count the tocodes */
   ncodes = 0;
-  for (c = tocodes; c; c = c1 ? c1 + 1 : 0)
-  {
+  for (c = tocodes; c; c = c1 ? c1 + 1 : 0) {
     if ((c1 = strchr (c, ':')) == c)
       continue;
     ++ncodes;
@@ -850,42 +829,36 @@ static size_t convert_file_from_to (FILE *file,
 
   /* Copy them */
   tcode = safe_malloc (ncodes * sizeof (char *));
-  for (c = tocodes, i = 0; c; c = c1 ? c1 + 1 : 0, i++)
-  {
+  for (c = tocodes, i = 0; c; c = c1 ? c1 + 1 : 0, i++) {
     if ((c1 = strchr (c, ':')) == c)
       continue;
     tcode[i] = mutt_substrdup (c, c1);
   }
 
-  ret = (size_t)(-1);
-  if (fromcode)
-  {
+  ret = (size_t) (-1);
+  if (fromcode) {
     /* Try each fromcode in turn */
-    for (c = fromcodes; c; c = c1 ? c1 + 1 : 0)
-    {
+    for (c = fromcodes; c; c = c1 ? c1 + 1 : 0) {
       if ((c1 = strchr (c, ':')) == c)
-       continue;
+        continue;
       fcode = mutt_substrdup (c, c1);
-      
-      ret = convert_file_to (file, fcode, ncodes, (const char **)tcode,
-                            &cn, info);
-      if (ret != (size_t)(-1))
-      {
-       *fromcode = fcode;
-       *tocode = tcode[cn];
-       tcode[cn] = 0;
-       break;
+
+      ret = convert_file_to (file, fcode, ncodes, (const char **) tcode,
+                             &cn, info);
+      if (ret != (size_t) (-1)) {
+        *fromcode = fcode;
+        *tocode = tcode[cn];
+        tcode[cn] = 0;
+        break;
       }
       FREE (&fcode);
     }
   }
-  else
-  {
+  else {
     /* There is only one fromcode */
-    ret = convert_file_to (file, fromcodes, ncodes, (const char **)tcode,
-                          &cn, info);
-    if (ret != (size_t)(-1))
-    {
+    ret = convert_file_to (file, fromcodes, ncodes, (const char **) tcode,
+                           &cn, info);
+    if (ret != (size_t) (-1)) {
       *tocode = tcode[cn];
       tcode[cn] = 0;
     }
@@ -896,7 +869,7 @@ static size_t convert_file_from_to (FILE *file,
     FREE (&tcode[i]);
 
   FREE (tcode);
-  
+
   return ret;
 }
 
@@ -904,7 +877,7 @@ static size_t convert_file_from_to (FILE *file,
  * Analyze the contents of a file to determine which MIME encoding to use.
  * Also set the body charset, sometimes, or not.
  */
-CONTENT *mutt_get_content_info (const char *fname, BODY *b)
+CONTENT *mutt_get_content_info (const char *fname, BODY * b)
 {
   CONTENT *info;
   CONTENT_STATE state;
@@ -916,44 +889,39 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
   size_t r;
 
   struct stat sb;
-  
-  if(b && !fname) fname = b->filename;
 
-  if (stat (fname, &sb) == -1)
-  {
+  if (b && !fname)
+    fname = b->filename;
+
+  if (stat (fname, &sb) == -1) {
     mutt_error (_("Can't stat %s: %s"), fname, strerror (errno));
     return NULL;
   }
-  
-  if (!S_ISREG(sb.st_mode))
-  {
+
+  if (!S_ISREG (sb.st_mode)) {
     mutt_error (_("%s isn't a regular file."), fname);
     return NULL;
   }
-  
-  if ((fp = fopen (fname, "r")) == NULL)
-  {
+
+  if ((fp = fopen (fname, "r")) == NULL) {
     dprint (1, (debugfile, "mutt_get_content_info: %s: %s (errno %d).\n",
-               fname, strerror (errno), errno));
+                fname, strerror (errno), errno));
     return (NULL);
   }
 
   info = safe_calloc (1, sizeof (CONTENT));
   memset (&state, 0, sizeof (state));
-  
-  if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
-  {
+
+  if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset)) {
     char *chs = mutt_get_parameter ("charset", b->parameter);
     char *fchs = b->use_disp ? ((FileCharset && *FileCharset) ?
                                 FileCharset : Charset) : Charset;
     if (Charset && (chs || SendCharset) &&
         convert_file_from_to (fp, fchs, chs ? chs : SendCharset,
-                              &fromcode, &tocode, info) != (size_t)(-1))
-    {
-      if (!chs)
-      {
-       mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode);
-       mutt_set_parameter ("charset", chsbuf, &b->parameter);
+                              &fromcode, &tocode, info) != (size_t) (-1)) {
+      if (!chs) {
+        mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode);
+        mutt_set_parameter ("charset", chsbuf, &b->parameter);
       }
       b->file_charset = fromcode;
       FREE (&tocode);
@@ -963,16 +931,17 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
   }
 
   rewind (fp);
-  while ((r = fread (buffer, 1, sizeof(buffer), fp)))
+  while ((r = fread (buffer, 1, sizeof (buffer), fp)))
     update_content_info (info, &state, buffer, r);
   update_content_info (info, &state, 0, 0);
 
   safe_fclose (&fp);
-  
+
   if (b != NULL && b->type == TYPETEXT && (!b->noconv && !b->force_charset))
     mutt_set_parameter ("charset", (!info->hibin ? "us-ascii" :
-                                   Charset  && !mutt_is_us_ascii (Charset) ? Charset : "unknown-8bit"),
-                       &b->parameter);
+                                    Charset
+                                    && !mutt_is_us_ascii (Charset) ? Charset :
+                                    "unknown-8bit"), &b->parameter);
 
   return info;
 }
@@ -984,7 +953,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
  * exists.
  */
 
-int mutt_lookup_mime_type (BODY *att, const char *path)
+int mutt_lookup_mime_type (BODY * att, const char *path)
 {
   FILE *f;
   char *p, *q, *ct;
@@ -995,99 +964,99 @@ int mutt_lookup_mime_type (BODY *att, const char *path)
   int type;
 
   *subtype = '\0';
-  *xtype   = '\0';
-  type     = TYPEOTHER;
-  cur_sze  = 0;
+  *xtype = '\0';
+  type = TYPEOTHER;
+  cur_sze = 0;
 
-  szf      = mutt_strlen (path);
+  szf = mutt_strlen (path);
 
-  for (count = 0 ; count < 3 ; count++)
-  {
+  for (count = 0; count < 3; count++) {
     /*
      * can't use strtok() because we use it in an inner loop below, so use
      * a switch statement here instead.
      */
-    switch (count)
-    {
-      case 0:
-       snprintf (buf, sizeof (buf), "%s/.mime.types", NONULL(Homedir));
-       break;
-      case 1:
-       strfcpy (buf, SYSCONFDIR"/mime.types", sizeof(buf));
-       break;
-      case 2:
-       strfcpy (buf, PKGDATADIR"/mime.types", sizeof (buf));
-       break;
-      default:
-        dprint (1, (debugfile, "mutt_lookup_mime_type: Internal error, count = %d.\n", count));
-       goto bye;       /* shouldn't happen */
-    }
-
-    if ((f = fopen (buf, "r")) != NULL)
-    {
-      while (fgets (buf, sizeof (buf) - 1, f) != NULL)
-      {
-       /* weed out any comments */
-       if ((p = strchr (buf, '#')))
-         *p = 0;
-
-       /* remove any leading space. */
-       ct = buf;
-       SKIPWS (ct);
-
-       /* position on the next field in this line */
-       if ((p = strpbrk (ct, " \t")) == NULL)
-         continue;
-       *p++ = 0;
-       SKIPWS (p);
-
-       /* cycle through the file extensions */
-       while ((p = strtok (p, " \t\n")))
-       {
-         sze = mutt_strlen (p);
-         if ((sze > cur_sze) && (szf >= sze) &&
-             (mutt_strcasecmp (path + szf - sze, p) == 0 || ascii_strcasecmp (path + szf - sze, p) == 0) &&
-             (szf == sze || path[szf - sze - 1] == '.'))
-         {
-           /* get the content-type */
-
-           if ((p = strchr (ct, '/')) == NULL)
-           {
-             /* malformed line, just skip it. */
-             break;
-           }
-           *p++ = 0;
-
-           for (q = p; *q && !ISSPACE (*q); q++)
-             ;
-           
-           mutt_substrcpy (subtype, p, q, sizeof (subtype));
-
-           if ((type = mutt_check_mime_type (ct)) == TYPEOTHER)
-             strfcpy (xtype, ct, sizeof (xtype));
-
-           cur_sze = sze;
-         }
-         p = NULL;
-       }
+    switch (count) {
+    case 0:
+      snprintf (buf, sizeof (buf), "%s/.mime.types", NONULL (Homedir));
+      break;
+    case 1:
+      strfcpy (buf, SYSCONFDIR "/mime.types", sizeof (buf));
+      break;
+    case 2:
+      strfcpy (buf, PKGDATADIR "/mime.types", sizeof (buf));
+      break;
+    default:
+      dprint (1,
+              (debugfile,
+               "mutt_lookup_mime_type: Internal error, count = %d.\n",
+               count));
+      goto bye;                 /* shouldn't happen */
+    }
+
+    if ((f = fopen (buf, "r")) != NULL) {
+      while (fgets (buf, sizeof (buf) - 1, f) != NULL) {
+        /* weed out any comments */
+        if ((p = strchr (buf, '#')))
+          *p = 0;
+
+        /* remove any leading space. */
+        ct = buf;
+        SKIPWS (ct);
+
+        /* position on the next field in this line */
+        if ((p = strpbrk (ct, " \t")) == NULL)
+          continue;
+        *p++ = 0;
+        SKIPWS (p);
+
+        /* cycle through the file extensions */
+        while ((p = strtok (p, " \t\n"))) {
+          sze = mutt_strlen (p);
+          if ((sze > cur_sze) && (szf >= sze) &&
+              (mutt_strcasecmp (path + szf - sze, p) == 0
+               || ascii_strcasecmp (path + szf - sze, p) == 0) && (szf == sze
+                                                                   || path[szf
+                                                                           -
+                                                                           sze
+                                                                           -
+                                                                           1]
+                                                                   == '.')) {
+            /* get the content-type */
+
+            if ((p = strchr (ct, '/')) == NULL) {
+              /* malformed line, just skip it. */
+              break;
+            }
+            *p++ = 0;
+
+            for (q = p; *q && !ISSPACE (*q); q++);
+
+            mutt_substrcpy (subtype, p, q, sizeof (subtype));
+
+            if ((type = mutt_check_mime_type (ct)) == TYPEOTHER)
+              strfcpy (xtype, ct, sizeof (xtype));
+
+            cur_sze = sze;
+          }
+          p = NULL;
+        }
       }
       fclose (f);
     }
   }
-  
- bye:
 
-  if (type != TYPEOTHER || *xtype != '\0')
-  {
+bye:
+
+  if (type != TYPEOTHER || *xtype != '\0') {
     att->type = type;
     mutt_str_replace (&att->subtype, subtype);
     mutt_str_replace (&att->xtype, xtype);
   }
-  
+
   return (type);
 }
 
-void mutt_message_to_7bit (BODY *a, FILE *fp)
+void mutt_message_to_7bit (BODY * a, FILE * fp)
 {
   char temp[_POSIX_PATH_MAX];
   char *line = NULL;
@@ -1097,16 +1066,13 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
 
   if (!a->filename && fp)
     fpin = fp;
-  else if (!a->filename || !(fpin = fopen (a->filename, "r")))
-  {
+  else if (!a->filename || !(fpin = fopen (a->filename, "r"))) {
     mutt_error (_("Could not open %s"), a->filename ? a->filename : "(null)");
     return;
-  } 
-  else
-  {
+  }
+  else {
     a->offset = 0;
-    if (stat (a->filename, &sb) == -1)
-    {
+    if (stat (a->filename, &sb) == -1) {
       mutt_perror ("stat");
       fclose (fpin);
     }
@@ -1114,8 +1080,7 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
   }
 
   mutt_mktemp (temp);
-  if (!(fpout = safe_fopen (temp, "w+")))
-  {
+  if (!(fpout = safe_fopen (temp, "w+"))) {
     mutt_perror ("fopen");
     goto cleanup;
   }
@@ -1124,16 +1089,16 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
   a->parts = mutt_parse_messageRFC822 (fpin, a);
 
   transform_to_7bit (a->parts, fpin);
-  
-  mutt_copy_hdr (fpin, fpout, a->offset, a->offset + a->length, 
-                CH_MIME | CH_NONEWLINE | CH_XMIT, NULL);
+
+  mutt_copy_hdr (fpin, fpout, a->offset, a->offset + a->length,
+                 CH_MIME | CH_NONEWLINE | CH_XMIT, NULL);
 
   fputs ("Mime-Version: 1.0\n", fpout);
   mutt_write_mime_header (a->parts, fpout);
   fputc ('\n', fpout);
   mutt_write_mime_body (a->parts, fpout);
-  
- cleanup:
+
+cleanup:
   FREE (&line);
 
   if (fpin && !fp)
@@ -1142,15 +1107,14 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
     fclose (fpout);
   else
     return;
-  
+
   a->encoding = ENC7BIT;
   a->d_filename = a->filename;
   if (a->filename && a->unlink)
     unlink (a->filename);
   a->filename = safe_strdup (temp);
   a->unlink = 1;
-  if(stat (a->filename, &sb) == -1) 
-  {
+  if (stat (a->filename, &sb) == -1) {
     mutt_perror ("stat");
     return;
   }
@@ -1159,36 +1123,31 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
   a->hdr->content = NULL;
 }
 
-static void transform_to_7bit (BODY *a, FILE *fpin)
+static void transform_to_7bit (BODY * a, FILE * fpin)
 {
   char buff[_POSIX_PATH_MAX];
   STATE s;
   struct stat sb;
 
   memset (&s, 0, sizeof (s));
-  for (; a; a = a->next)
-  {
-    if (a->type == TYPEMULTIPART)
-    {
+  for (; a; a = a->next) {
+    if (a->type == TYPEMULTIPART) {
       if (a->encoding != ENC7BIT)
-       a->encoding = ENC7BIT;
+        a->encoding = ENC7BIT;
 
       transform_to_7bit (a->parts, fpin);
-    } 
-    else if (mutt_is_message_type(a->type, a->subtype))
-    {
+    }
+    else if (mutt_is_message_type (a->type, a->subtype)) {
       mutt_message_to_7bit (a, fpin);
     }
-    else 
-    {
+    else {
       a->noconv = 1;
       a->force_charset = 1;
-      
+
       mutt_mktemp (buff);
-      if ((s.fpout = safe_fopen (buff, "w")) == NULL) 
-      {
-       mutt_perror ("fopen");
-       return;
+      if ((s.fpout = safe_fopen (buff, "w")) == NULL) {
+        mutt_perror ("fopen");
+        return;
       }
       s.fpin = fpin;
       mutt_decode_attachment (a, &s);
@@ -1196,60 +1155,59 @@ static void transform_to_7bit (BODY *a, FILE *fpin)
       a->d_filename = a->filename;
       a->filename = safe_strdup (buff);
       a->unlink = 1;
-      if (stat (a->filename, &sb) == -1) 
-      {
-       mutt_perror ("stat");
-       return;
+      if (stat (a->filename, &sb) == -1) {
+        mutt_perror ("stat");
+        return;
       }
       a->length = sb.st_size;
 
       mutt_update_encoding (a);
       if (a->encoding == ENC8BIT)
-       a->encoding = ENCQUOTEDPRINTABLE;
-      else if(a->encoding == ENCBINARY)
-       a->encoding = ENCBASE64;
+        a->encoding = ENCQUOTEDPRINTABLE;
+      else if (a->encoding == ENCBINARY)
+        a->encoding = ENCBASE64;
     }
   }
 }
 
 /* determine which Content-Transfer-Encoding to use */
-static void mutt_set_encoding (BODY *b, CONTENT *info)
+static void mutt_set_encoding (BODY * b, CONTENT * info)
 {
   char send_charset[SHORT_STRING];
 
-  if (b->type == TYPETEXT)
-  {
-    char *chsname = mutt_get_body_charset (send_charset, sizeof (send_charset), b);
-    if ((info->lobin && ascii_strncasecmp (chsname, "iso-2022", 8)) || info->linemax > 990 || (info->from && option (OPTENCODEFROM)))
+  if (b->type == TYPETEXT) {
+    char *chsname =
+      mutt_get_body_charset (send_charset, sizeof (send_charset), b);
+    if ((info->lobin && ascii_strncasecmp (chsname, "iso-2022", 8))
+        || info->linemax > 990 || (info->from && option (OPTENCODEFROM)))
       b->encoding = ENCQUOTEDPRINTABLE;
     else if (info->hibin)
       b->encoding = option (OPTALLOW8BIT) ? ENC8BIT : ENCQUOTEDPRINTABLE;
     else
       b->encoding = ENC7BIT;
   }
-  else if (b->type == TYPEMESSAGE || b->type == TYPEMULTIPART)
-  {
-    if (info->lobin || info->hibin)
-    {
+  else if (b->type == TYPEMESSAGE || b->type == TYPEMULTIPART) {
+    if (info->lobin || info->hibin) {
       if (option (OPTALLOW8BIT) && !info->lobin)
-       b->encoding = ENC8BIT; 
+        b->encoding = ENC8BIT;
       else
-       mutt_message_to_7bit (b, NULL);
+        mutt_message_to_7bit (b, NULL);
     }
     else
       b->encoding = ENC7BIT;
   }
-  else if (b->type == TYPEAPPLICATION && ascii_strcasecmp (b->subtype, "pgp-keys") == 0)
+  else if (b->type == TYPEAPPLICATION
+           && ascii_strcasecmp (b->subtype, "pgp-keys") == 0)
     b->encoding = ENC7BIT;
   else
 #if 0
-    if (info->lobin || info->hibin || info->binary || info->linemax > 990
-          || info->cr || (/* option (OPTENCODEFROM) && */ info->from))
+  if (info->lobin || info->hibin || info->binary || info->linemax > 990
+        || info->cr || ( /* option (OPTENCODEFROM) && */ info->from))
 #endif
   {
     /* Determine which encoding is smaller  */
-    if (1.33 * (float)(info->lobin+info->hibin+info->ascii) < 
-        3.0 * (float)(info->lobin + info->hibin) + (float)info->ascii)
+    if (1.33 * (float) (info->lobin + info->hibin + info->ascii) <
+        3.0 * (float) (info->lobin + info->hibin) + (float) info->ascii)
       b->encoding = ENCBASE64;
     else
       b->encoding = ENCQUOTEDPRINTABLE;
@@ -1260,25 +1218,25 @@ static void mutt_set_encoding (BODY *b, CONTENT *info)
 #endif
 }
 
-void mutt_stamp_attachment(BODY *a)
+void mutt_stamp_attachment (BODY * a)
 {
-  a->stamp = time(NULL);
+  a->stamp = time (NULL);
 }
 
 /* Get a body's character set */
 
-char *mutt_get_body_charset (char *d, size_t dlen, BODY *b)
+char *mutt_get_body_charset (char *d, size_t dlen, BODY * b)
 {
   char *p = NULL;
 
   if (b && b->type != TYPETEXT)
     return NULL;
 
-  if (b) 
+  if (b)
     p = mutt_get_parameter ("charset", b->parameter);
 
   if (p)
-    mutt_canonical_charset (d, dlen, NONULL(p));
+    mutt_canonical_charset (d, dlen, NONULL (p));
   else
     strfcpy (d, "us-ascii", dlen);
 
@@ -1287,7 +1245,7 @@ char *mutt_get_body_charset (char *d, size_t dlen, BODY *b)
 
 
 /* Assumes called from send mode where BODY->filename points to actual file */
-void mutt_update_encoding (BODY *a)
+void mutt_update_encoding (BODY * a)
 {
   CONTENT *info;
   char chsbuff[STRING];
@@ -1303,26 +1261,25 @@ void mutt_update_encoding (BODY *a)
     return;
 
   mutt_set_encoding (a, info);
-  mutt_stamp_attachment(a);
+  mutt_stamp_attachment (a);
 
   FREE (&a->content);
   a->content = info;
 
 }
 
-BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
+BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg)
 {
   char buffer[LONG_STRING];
   BODY *body;
   FILE *fp;
   int cmflags, chflags;
-  int pgp = WithCrypto? hdr->security : 0;
+  int pgp = WithCrypto ? hdr->security : 0;
 
-  if (WithCrypto)
-  {
-    if ((option(OPTMIMEFORWDECODE) || option(OPTFORWDECRYPT)) &&
+  if (WithCrypto) {
+    if ((option (OPTMIMEFORWDECODE) || option (OPTFORWDECRYPT)) &&
         (hdr->security & ENCRYPT)) {
-      if (!crypt_valid_passphrase(hdr->security))
+      if (!crypt_valid_passphrase (hdr->security))
         return (NULL);
     }
   }
@@ -1346,8 +1303,7 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
   cmflags = 0;
 
   /* If we are attaching a message, ignore OPTMIMEFORWDECODE */
-  if (!attach_msg && option (OPTMIMEFORWDECODE))
-  {
+  if (!attach_msg && option (OPTMIMEFORWDECODE)) {
     chflags |= CH_MIME | CH_TXTPLAIN;
     cmflags = M_CM_DECODE | M_CM_CHARCONV;
     if ((WithCrypto & APPLICATION_PGP))
@@ -1355,26 +1311,21 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
     if ((WithCrypto & APPLICATION_SMIME))
       pgp &= ~SMIMEENCRYPT;
   }
-  else if (WithCrypto
-           && option (OPTFORWDECRYPT) && (hdr->security & ENCRYPT))
-  {
+  else if (WithCrypto && option (OPTFORWDECRYPT) && (hdr->security & ENCRYPT)) {
     if ((WithCrypto & APPLICATION_PGP)
-        && mutt_is_multipart_encrypted (hdr->content))
-    {
+        && mutt_is_multipart_encrypted (hdr->content)) {
       chflags |= CH_MIME | CH_NONEWLINE;
       cmflags = M_CM_DECODE_PGP;
       pgp &= ~PGPENCRYPT;
     }
     else if ((WithCrypto & APPLICATION_PGP)
-             && (mutt_is_application_pgp (hdr->content) & PGPENCRYPT))
-    {
+             && (mutt_is_application_pgp (hdr->content) & PGPENCRYPT)) {
       chflags |= CH_MIME | CH_TXTPLAIN;
       cmflags = M_CM_DECODE | M_CM_CHARCONV;
       pgp &= ~PGPENCRYPT;
     }
     else if ((WithCrypto & APPLICATION_SMIME)
-              && mutt_is_application_smime (hdr->content) & SMIMEENCRYPT)
-    {
+             && mutt_is_application_smime (hdr->content) & SMIMEENCRYPT) {
       chflags |= CH_MIME | CH_TXTPLAIN;
       cmflags = M_CM_DECODE | M_CM_CHARCONV;
       pgp &= ~SMIMEENCRYPT;
@@ -1382,21 +1333,21 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
   }
 
   mutt_copy_message (fp, ctx, hdr, cmflags, chflags);
-  
-  fflush(fp);
-  rewind(fp);
 
-  body->hdr = mutt_new_header();
+  fflush (fp);
+  rewind (fp);
+
+  body->hdr = mutt_new_header ();
   body->hdr->offset = 0;
   /* we don't need the user headers here */
-  body->hdr->env = mutt_read_rfc822_header(fp, body->hdr, 0, 0);
+  body->hdr->env = mutt_read_rfc822_header (fp, body->hdr, 0, 0);
   if (WithCrypto)
     body->hdr->security = pgp;
   mutt_update_encoding (body);
   body->parts = body->hdr->content;
 
-  fclose(fp);
-  
+  fclose (fp);
+
   return (body);
 }
 
@@ -1413,31 +1364,29 @@ BODY *mutt_make_file_attach (const char *path)
    */
 
 #if 0
-  
-  if ((n = mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf), path)) != TYPEOTHER 
-      || *xbuf != '\0')
-  {
+
+  if ((n =
+       mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf),
+                              path)) != TYPEOTHER || *xbuf != '\0') {
     att->type = n;
     att->subtype = safe_strdup (buf);
     att->xtype = safe_strdup (xbuf);
   }
 
 #else
-  
+
   mutt_lookup_mime_type (att, path);
 
 #endif
-  
-  if ((info = mutt_get_content_info (path, att)) == NULL)
-  {
+
+  if ((info = mutt_get_content_info (path, att)) == NULL) {
     mutt_free_body (&att);
     return NULL;
   }
 
-  if (!att->subtype)
-  {
-    if (info->lobin == 0 || (info->lobin + info->hibin + info->ascii)/ info->lobin >= 10)
-    {
+  if (!att->subtype) {
+    if (info->lobin == 0
+        || (info->lobin + info->hibin + info->ascii) / info->lobin >= 10) {
       /*
        * Statistically speaking, there should be more than 10% "lobin" 
        * chars if this is really a binary file...
@@ -1445,23 +1394,21 @@ BODY *mutt_make_file_attach (const char *path)
       att->type = TYPETEXT;
       att->subtype = safe_strdup ("plain");
     }
-    else
-    {
+    else {
       att->type = TYPEAPPLICATION;
       att->subtype = safe_strdup ("octet-stream");
     }
-  } 
+  }
 
   mutt_update_encoding (att);
   return (att);
 }
 
-static int get_toplevel_encoding (BODY *a)
+static int get_toplevel_encoding (BODY * a)
 {
   int e = ENC7BIT;
 
-  for (; a; a = a->next)
-  {
+  for (; a; a = a->next) {
     if (a->encoding == ENCBINARY)
       return (ENCBINARY);
     else if (a->encoding == ENC8BIT)
@@ -1471,7 +1418,7 @@ static int get_toplevel_encoding (BODY *a)
   return (e);
 }
 
-BODY *mutt_make_multipart (BODY *b)
+BODY *mutt_make_multipart (BODY * b)
 {
   BODY *new;
 
@@ -1480,7 +1427,7 @@ BODY *mutt_make_multipart (BODY *b)
   new->subtype = safe_strdup ("mixed");
   new->encoding = get_toplevel_encoding (b);
   mutt_generate_boundary (&new->parameter);
-  new->use_disp = 0;  
+  new->use_disp = 0;
   new->disposition = DISPINLINE;
   new->parts = b;
 
@@ -1488,12 +1435,11 @@ BODY *mutt_make_multipart (BODY *b)
 }
 
 /* remove the multipart body if it exists */
-BODY *mutt_remove_multipart (BODY *b)
+BODY *mutt_remove_multipart (BODY * b)
 {
   BODY *t;
 
-  if (b->parts)
-  {
+  if (b->parts) {
     t = b;
     b = b->parts;
     t->parts = NULL;
@@ -1510,47 +1456,43 @@ char *mutt_make_date (char *s, size_t len)
 
   tz /= 60;
 
-  snprintf (s, len,  "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
-           Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon],
-           l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec,
-           (int) tz / 60, (int) abs (tz) % 60);
+  snprintf (s, len, "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
+            Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon],
+            l->tm_year + 1900, l->tm_hour, l->tm_min, l->tm_sec,
+            (int) tz / 60, (int) abs (tz) % 60);
   return (s);
 }
 
 /* wrapper around mutt_write_address() so we can handle very large
    recipient lists without needing a huge temporary buffer in memory */
-void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display)
+void mutt_write_address_list (ADDRESS * adr, FILE * fp, int linelen,
+                              int display)
 {
   ADDRESS *tmp;
   char buf[LONG_STRING];
   int count = 0;
   int len;
 
-  while (adr)
-  {
+  while (adr) {
     tmp = adr->next;
     adr->next = NULL;
     buf[0] = 0;
     rfc822_write_address (buf, sizeof (buf), adr, display);
     len = mutt_strlen (buf);
-    if (count && linelen + len > 74)
-    {
+    if (count && linelen + len > 74) {
       fputs ("\n\t", fp);
-      linelen = len + 8; /* tab is usually about 8 spaces... */
+      linelen = len + 8;        /* tab is usually about 8 spaces... */
     }
-    else
-    {
-      if (count && adr->mailbox)
-      {
-       fputc (' ', fp);
-       linelen++;
+    else {
+      if (count && adr->mailbox) {
+        fputc (' ', fp);
+        linelen++;
       }
       linelen += len;
     }
     fputs (buf, fp);
     adr->next = tmp;
-    if (!adr->group && adr->next && adr->next->mailbox)
-    {
+    if (!adr->group && adr->next && adr->next->mailbox) {
       linelen++;
       fputc (',', fp);
     }
@@ -1568,20 +1510,18 @@ void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display)
 /* need to write the list in reverse because they are stored in reverse order
  * when parsed to speed up threading
  */
-void mutt_write_references (LIST *r, FILE *f)
+void mutt_write_references (LIST * r, FILE * f)
 {
   LIST **ref = NULL;
   int refcnt = 0, refmax = 0;
 
-  for ( ; (TrimRef == 0 || refcnt < TrimRef) && r ; r = r->next)
-  {
+  for (; (TrimRef == 0 || refcnt < TrimRef) && r; r = r->next) {
     if (refcnt == refmax)
       safe_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *));
     ref[refcnt++] = r;
   }
 
-  while (refcnt-- > 0)
-  {
+  while (refcnt-- > 0) {
     fputc (' ', f);
     fputs (ref[refcnt]->data, f);
   }
@@ -1605,65 +1545,60 @@ void mutt_write_references (LIST *r, FILE *f)
  *
  */
 
-int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, 
-                             int mode, int privacy)
+int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach,
+                              int mode, int privacy)
 {
   char buffer[LONG_STRING];
   char *p;
   LIST *tmp = env->userhdrs;
-  int has_agent = 0; /* user defined user-agent header field exists */
-  
+  int has_agent = 0;            /* user defined user-agent header field exists */
+
 #ifdef USE_NNTP
   if (!option (OPTNEWSSEND))
 #endif
-  if (mode == 0 && !privacy)
-    fputs (mutt_make_date (buffer, sizeof(buffer)), fp);
+    if (mode == 0 && !privacy)
+      fputs (mutt_make_date (buffer, sizeof (buffer)), fp);
 
   /* OPTUSEFROM is not consulted here so that we can still write a From:
    * field if the user sets it with the `my_hdr' command
    */
-  if (env->from && !privacy)
-  {
+  if (env->from && !privacy) {
     buffer[0] = 0;
     rfc822_write_address (buffer, sizeof (buffer), env->from, 0);
     fprintf (fp, "From: %s\n", buffer);
   }
 
-  if (env->to)
-  {
+  if (env->to) {
     fputs ("To: ", fp);
     mutt_write_address_list (env->to, fp, 4, 0);
   }
   else if (mode > 0)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
+    if (!option (OPTNEWSSEND))
 #endif
-    fputs ("To: \n", fp);
+      fputs ("To: \n", fp);
 
-  if (env->cc)
-  {
+  if (env->cc) {
     fputs ("Cc: ", fp);
     mutt_write_address_list (env->cc, fp, 4, 0);
   }
   else if (mode > 0)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
+    if (!option (OPTNEWSSEND))
 #endif
-    fputs ("Cc: \n", fp);
+      fputs ("Cc: \n", fp);
 
-  if (env->bcc)
-  {
-    if(mode != 0 || option(OPTWRITEBCC))
-    {
+  if (env->bcc) {
+    if (mode != 0 || option (OPTWRITEBCC)) {
       fputs ("Bcc: ", fp);
       mutt_write_address_list (env->bcc, fp, 5, 0);
     }
   }
   else if (mode > 0)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
+    if (!option (OPTNEWSSEND))
 #endif
-    fputs ("Bcc: \n", fp);
+      fputs ("Bcc: \n", fp);
 
 #ifdef USE_NNTP
   if (env->newsgroups)
@@ -1691,8 +1626,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
   if (env->message_id && !privacy)
     fprintf (fp, "Message-ID: %s\n", env->message_id);
 
-  if (env->reply_to)
-  {
+  if (env->reply_to) {
     fputs ("Reply-To: ", fp);
     mutt_write_address_list (env->reply_to, fp, 10, 0);
   }
@@ -1701,20 +1635,18 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
 
   if (env->mail_followup_to)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
+    if (!option (OPTNEWSSEND))
 #endif
-  {
-    fputs ("Mail-Followup-To: ", fp);
-    mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
-  }
-
-  if (mode <= 0)
-  {
-    if (env->references)
     {
+      fputs ("Mail-Followup-To: ", fp);
+      mutt_write_address_list (env->mail_followup_to, fp, 18, 0);
+    }
+
+  if (mode <= 0) {
+    if (env->references) {
       fputs ("References:", fp);
       mutt_write_references (env->references, fp);
-      fputc('\n', fp);
+      fputc ('\n', fp);
     }
 
     /* Add the MIME headers */
@@ -1722,27 +1654,25 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
     mutt_write_mime_header (attach, fp);
   }
 
-  if (env->in_reply_to)
-  {
+  if (env->in_reply_to) {
     fputs ("In-Reply-To:", fp);
     mutt_write_references (env->in_reply_to, fp);
     fputc ('\n', fp);
   }
-  
+
   /* Add any user defined headers */
-  for (; tmp; tmp = tmp->next)
-  {
-    if ((p = strchr (tmp->data, ':')))
-    {
-      p++; SKIPWS (p);
-      if (!*p)         continue;  /* don't emit empty fields. */
+  for (; tmp; tmp = tmp->next) {
+    if ((p = strchr (tmp->data, ':'))) {
+      p++;
+      SKIPWS (p);
+      if (!*p)
+        continue;               /* don't emit empty fields. */
 
       /* check to see if the user has overridden the user-agent field */
-      if (!ascii_strncasecmp ("user-agent", tmp->data, 10))
-      {
-       has_agent = 1;
-       if (privacy)
-         continue;
+      if (!ascii_strncasecmp ("user-agent", tmp->data, 10)) {
+        has_agent = 1;
+        if (privacy)
+          continue;
       }
 
       fputs (tmp->data, fp);
@@ -1750,87 +1680,90 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
     }
   }
 
-  if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent)
-  {
+  if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent) {
     struct utsname un;
-    char * os;
-    if (OperatingSystem!=NULL) {
+    char *os;
+
+    if (OperatingSystem != NULL) {
       os = OperatingSystem;
-    } else {
-      if (uname(&un)==-1) {
+    }
+    else {
+      if (uname (&un) == -1) {
         os = "UNIX";
-      } else {
+      }
+      else {
         os = un.sysname;
       }
     }
     /* Add a vanity header */
-    fprintf (fp, "User-Agent: mutt-ng %s (%s)\n", MUTT_VERSION,os);
+    fprintf (fp, "User-Agent: mutt-ng %s (%s)\n", MUTT_VERSION, os);
   }
 
   return (ferror (fp) == 0 ? 0 : -1);
 }
 
-static void encode_headers (LIST *h)
+static void encode_headers (LIST * h)
 {
   char *tmp;
   char *p;
   int i;
-  
-  for (; h; h = h->next)
-  {
+
+  for (; h; h = h->next) {
     if (!(p = strchr (h->data, ':')))
       continue;
 
     i = p - h->data;
-    ++p; SKIPWS (p);
+    ++p;
+    SKIPWS (p);
     tmp = safe_strdup (p);
 
     if (!tmp)
       continue;
-    
+
     rfc2047_encode_string (&tmp);
-    safe_realloc (&h->data, mutt_strlen (h->data) + 2 + mutt_strlen (tmp) + 1);
+    safe_realloc (&h->data,
+                  mutt_strlen (h->data) + 2 + mutt_strlen (tmp) + 1);
+
+    sprintf (h->data + i, ": %s", NONULL (tmp));        /* __SPRINTF_CHECKED__ */
 
-    sprintf (h->data + i, ": %s", NONULL (tmp));  /* __SPRINTF_CHECKED__ */
-    
     FREE (&tmp);
   }
 }
 
-const char *mutt_fqdn(short may_hide_host)
+const char *mutt_fqdn (short may_hide_host)
 {
   char *p = NULL, *q;
-  
-  if(Fqdn && Fqdn[0] != '@')
-  {
+
+  if (Fqdn && Fqdn[0] != '@') {
     p = Fqdn;
-    
-    if(may_hide_host && option(OPTHIDDENHOST))
-    {
-      if((p = strchr(Fqdn, '.')))
-       p++;
+
+    if (may_hide_host && option (OPTHIDDENHOST)) {
+      if ((p = strchr (Fqdn, '.')))
+        p++;
 
       /* sanity check: don't hide the host if
        * the fqdn is something like detebe.org.
        */
-      
-      if(!p || !(q = strchr(p, '.')))
-       p = Fqdn;
+
+      if (!p || !(q = strchr (p, '.')))
+        p = Fqdn;
     }
   }
 
   return p;
 }
 
-static char mutt_normalized_char(char c) {
-  if (isalnum(c))
+static char mutt_normalized_char (char c)
+{
+  if (isalnum (c))
     return c;
-  if (strchr(".!#$%&'*+-/=?^_`{|}~",c))
+  if (strchr (".!#$%&'*+-/=?^_`{|}~", c))
     return c;
-  return '.'; /* normalized character (we're stricter than RFC2822, 3.6.4) */
+  return '.';                   /* normalized character (we're stricter than RFC2822, 3.6.4) */
 }
 
-static void mutt_gen_localpart(char * buf, unsigned int len, char * fmt) {
+static void mutt_gen_localpart (char *buf, unsigned int len, char *fmt)
+{
   time_t now;
   struct tm *tm;
   char tmp[SHORT_STRING];
@@ -1840,75 +1773,77 @@ static void mutt_gen_localpart(char * buf, unsigned int len, char * fmt) {
   now = time (NULL);
   tm = gmtime (&now);
 
-  for (;*fmt;++fmt) {
+  for (; *fmt; ++fmt) {
     if (*fmt == '%') {
       switch (fmt[1]) {
       case 0:
         return;
       case 'd':
-        snprintf(tmp,sizeof(tmp),"%02d",tm->tm_mday);
-        safe_strncat(buf,len,tmp,2);
+        snprintf (tmp, sizeof (tmp), "%02d", tm->tm_mday);
+        safe_strncat (buf, len, tmp, 2);
         break;
       case 'h':
-        snprintf(tmp,sizeof(tmp),"%02d",tm->tm_hour);
-        safe_strncat(buf,len,tmp,2);
+        snprintf (tmp, sizeof (tmp), "%02d", tm->tm_hour);
+        safe_strncat (buf, len, tmp, 2);
         break;
       case 'm':
-        snprintf(tmp,sizeof(tmp),"%02d",tm->tm_mon+1);
-        safe_strncat(buf,len,tmp,2);
+        snprintf (tmp, sizeof (tmp), "%02d", tm->tm_mon + 1);
+        safe_strncat (buf, len, tmp, 2);
         break;
       case 'M':
-        snprintf(tmp,sizeof(tmp),"%02d",tm->tm_min);
-        safe_strncat(buf,len,tmp,2);
+        snprintf (tmp, sizeof (tmp), "%02d", tm->tm_min);
+        safe_strncat (buf, len, tmp, 2);
         break;
       case 'O':
-        snprintf(tmp,sizeof(tmp),"%lo",(unsigned long)now);
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%lo", (unsigned long) now);
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 'p':
-        snprintf(tmp,sizeof(tmp),"%u",(unsigned int)getpid());
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%u", (unsigned int) getpid ());
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 'P':
-        snprintf(tmp,sizeof(tmp),"%c",MsgIdPfx);
+        snprintf (tmp, sizeof (tmp), "%c", MsgIdPfx);
         MsgIdPfx = (MsgIdPfx == 'Z') ? 'A' : MsgIdPfx + 1;
-        safe_strncat(buf,len,tmp,1);
+        safe_strncat (buf, len, tmp, 1);
         break;
       case 'r':
-        snprintf(tmp,sizeof(tmp),"%u",(unsigned int)rand());
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%u", (unsigned int) rand ());
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 'R':
-        snprintf(tmp,sizeof(tmp),"%x",(unsigned int)rand());
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%x", (unsigned int) rand ());
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 's':
-        snprintf(tmp,sizeof(tmp),"%02d",tm->tm_sec);
-        safe_strncat(buf,len,tmp,2);
+        snprintf (tmp, sizeof (tmp), "%02d", tm->tm_sec);
+        safe_strncat (buf, len, tmp, 2);
         break;
       case 'T':
-        snprintf(tmp,sizeof(tmp),"%u",(unsigned int)now);
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%u", (unsigned int) now);
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 'X':
-        snprintf(tmp,sizeof(tmp),"%x",(unsigned int)now);
-        safe_strncat(buf,len,tmp,strlen(tmp));
+        snprintf (tmp, sizeof (tmp), "%x", (unsigned int) now);
+        safe_strncat (buf, len, tmp, strlen (tmp));
         break;
       case 'Y':
-        snprintf(tmp,sizeof(tmp),"%04d",tm->tm_year+1900); /* this will break in the year 10000 ;-) */
-        safe_strncat(buf,len,tmp,4);
+        snprintf (tmp, sizeof (tmp), "%04d", tm->tm_year + 1900);       /* this will break in the year 10000 ;-) */
+        safe_strncat (buf, len, tmp, 4);
         break;
       case '%':
-        safe_strncat(buf,len,"%",1);
+        safe_strncat (buf, len, "%", 1);
         break;
       default:
-        safe_strncat(buf,len,".",1); /* invalid formats are replaced by '.' */
-      } /* switch */
+        safe_strncat (buf, len, ".", 1);        /* invalid formats are replaced by '.' */
+      }                         /* switch */
       ++fmt;
-    } else {
+    }
+    else {
       char c;
-      c = mutt_normalized_char(*fmt); /* @todo: filter out invalid characters */
-      safe_strncat(buf,len,&c,1);
+
+      c = mutt_normalized_char (*fmt);  /* @todo: filter out invalid characters */
+      safe_strncat (buf, len, &c, 1);
     }
   }
 }
@@ -1924,14 +1859,14 @@ char *mutt_gen_msgid (void)
 
   now = time (NULL);
   tm = gmtime (&now);
-  if(!(fqdn = mutt_fqdn(0)))
-    fqdn = NONULL(Hostname);
+  if (!(fqdn = mutt_fqdn (0)))
+    fqdn = NONULL (Hostname);
 
-  localpart_length = sizeof(buf) - strlen(fqdn) - 4; /* the 4 characters are '<', '@', '>' and '\0' */
+  localpart_length = sizeof (buf) - strlen (fqdn) - 4;  /* the 4 characters are '<', '@', '>' and '\0' */
 
-  mutt_gen_localpart(localpart,localpart_length,MsgIdFormat);
+  mutt_gen_localpart (localpart, localpart_length, MsgIdFormat);
 
-  snprintf(buf,sizeof(buf),"<%s@%s>",localpart,fqdn);
+  snprintf (buf, sizeof (buf), "<%s@%s>", localpart, fqdn);
   return (safe_strdup (buf));
 }
 
@@ -1961,16 +1896,14 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
   sigaddset (&set, SIGTSTP);
   sigprocmask (SIG_BLOCK, &set, NULL);
 
-  if (SendmailWait >= 0)
-  {
+  if (SendmailWait >= 0) {
     char tmp[_POSIX_PATH_MAX];
 
     mutt_mktemp (tmp);
     *tempfile = safe_strdup (tmp);
   }
 
-  if ((pid = fork ()) == 0)
-  {
+  if ((pid = fork ()) == 0) {
     struct sigaction act, oldalrm;
 
     /* save parent's ID before setsid() */
@@ -1980,7 +1913,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
      * so we put ourselves into another session right away
      */
     setsid ();
-  
+
     /* next we close all open files */
 #if defined(OPEN_MAX)
     for (fd = 0; fd < OPEN_MAX; fd++)
@@ -1995,38 +1928,34 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
 #endif
 
     /* now the second fork() */
-    if ((pid = fork ()) == 0)
-    {
+    if ((pid = fork ()) == 0) {
       /* "msg" will be opened as stdin */
-      if (open (msg, O_RDONLY, 0) < 0)
-      {
-       unlink (msg);
-       _exit (S_ERR);
+      if (open (msg, O_RDONLY, 0) < 0) {
+        unlink (msg);
+        _exit (S_ERR);
       }
       unlink (msg);
 
-      if (SendmailWait >= 0)
-      {
-       /* *tempfile will be opened as stdout */
-       if (open (*tempfile, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0600) < 0)
-         _exit (S_ERR);
-       /* redirect stderr to *tempfile too */
-       if (dup (1) < 0)
-         _exit (S_ERR);
+      if (SendmailWait >= 0) {
+        /* *tempfile will be opened as stdout */
+        if (open (*tempfile, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0600) <
+            0)
+          _exit (S_ERR);
+        /* redirect stderr to *tempfile too */
+        if (dup (1) < 0)
+          _exit (S_ERR);
       }
-      else 
-      {
-       if (open ("/dev/null", O_WRONLY | O_APPEND) < 0)        /* stdout */
-         _exit (S_ERR);
-       if (open ("/dev/null", O_RDWR | O_APPEND) < 0)          /* stderr */
-         _exit (S_ERR);
+      else {
+        if (open ("/dev/null", O_WRONLY | O_APPEND) < 0)        /* stdout */
+          _exit (S_ERR);
+        if (open ("/dev/null", O_RDWR | O_APPEND) < 0)  /* stderr */
+          _exit (S_ERR);
       }
 
       execv (path, args);
       _exit (S_ERR);
     }
-    else if (pid == -1)
-    {
+    else if (pid == -1) {
       unlink (msg);
       FREE (tempfile);
       _exit (S_ERR);
@@ -2036,8 +1965,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
      * SendmailWait = 0: wait forever
      * SendmailWait < 0: don't wait
      */
-    if (SendmailWait > 0)
-    {
+    if (SendmailWait > 0) {
       SigAlrm = 0;
       act.sa_handler = alarm_handler;
 #ifdef SA_INTERRUPT
@@ -2053,23 +1981,18 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
     else if (SendmailWait < 0)
       _exit (0xff & EX_OK);
 
-    if (waitpid (pid, &st, 0) > 0)
-    {
+    if (waitpid (pid, &st, 0) > 0) {
       st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR;
-      if (SendmailWait && st == (0xff & EX_OK))
-      {
-       unlink (*tempfile); /* no longer needed */
-       FREE (tempfile);
+      if (SendmailWait && st == (0xff & EX_OK)) {
+        unlink (*tempfile);     /* no longer needed */
+        FREE (tempfile);
       }
     }
-    else
-    {
-      st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ?
-             S_BKG : S_ERR;
-      if (SendmailWait > 0)
-      {
-       unlink (*tempfile);
-       FREE (tempfile);
+    else {
+      st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ? S_BKG : S_ERR;
+      if (SendmailWait > 0) {
+        unlink (*tempfile);
+        FREE (tempfile);
       }
     }
 
@@ -2077,8 +2000,7 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
     alarm (0);
     sigaction (SIGALRM, &oldalrm, NULL);
 
-    if (kill (ppid, 0) == -1 && errno == ESRCH)
-    {
+    if (kill (ppid, 0) == -1 && errno == ESRCH) {
       /* the parent is already dead */
       unlink (*tempfile);
       FREE (tempfile);
@@ -2090,33 +2012,31 @@ send_msg (const char *path, char **args, const char *msg, char **tempfile)
   sigprocmask (SIG_UNBLOCK, &set, NULL);
 
   if (pid != -1 && waitpid (pid, &st, 0) > 0)
-    st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR; /* return child status */
+    st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR;     /* return child status */
   else
-    st = S_ERR;        /* error */
+    st = S_ERR;                 /* error */
 
   mutt_unblock_signals_system (1);
 
   return (st);
 }
 
-static char **
-add_args (char **args, size_t *argslen, size_t *argsmax, ADDRESS *addr)
+static char **add_args (char **args, size_t * argslen, size_t * argsmax,
+                        ADDRESS * addr)
 {
-  for (; addr; addr = addr->next)
-  {
+  for (; addr; addr = addr->next) {
     /* weed out group mailboxes, since those are for display only */
-    if (addr->mailbox && !addr->group)
-    {
+    if (addr->mailbox && !addr->group) {
       if (*argslen == *argsmax)
-       safe_realloc (&args, (*argsmax += 5) * sizeof (char *));
+        safe_realloc (&args, (*argsmax += 5) * sizeof (char *));
       args[(*argslen)++] = addr->mailbox;
     }
   }
   return (args);
 }
 
-static char **
-add_option (char **args, size_t *argslen, size_t *argsmax, char *s)
+static char **add_option (char **args, size_t * argslen, size_t * argsmax,
+                          char *s)
 {
   if (*argslen == *argsmax)
     safe_realloc (&args, (*argsmax += 5) * sizeof (char *));
@@ -2124,40 +2044,36 @@ add_option (char **args, size_t *argslen, size_t *argsmax, char *s)
   return (args);
 }
 
-static const char *
-strsysexit(int e)
+static const char *strsysexit (int e)
 {
   int i;
-  
-  for(i = 0; sysexits_h[i].str; i++)
-  {
-    if(e == sysexits_h[i].v)
+
+  for (i = 0; sysexits_h[i].str; i++) {
+    if (e == sysexits_h[i].v)
       break;
   }
-  
+
   return sysexits_h[i].str;
 }
 
 
-static int
-mutt_invoke_sendmail (ADDRESS *from,   /* the sender */
-                ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
-                const char *msg, /* file containing message */
-                int eightbit) /* message contains 8bit chars */
-{
+static int mutt_invoke_sendmail (ADDRESS * from,        /* the sender */
+                                 ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,     /* recips */
+                                 const char *msg,       /* file containing message */
+                                 int eightbit)
+{                               /* message contains 8bit chars */
   char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
   char **args = NULL;
   size_t argslen = 0, argsmax = 0;
   int i;
 
 #ifdef USE_NNTP
-  if (option (OPTNEWSSEND))
-  {
+  if (option (OPTNEWSSEND)) {
     char cmd[LONG_STRING];
 
-    mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0, 0);
-    if (!*cmd)
-    {
+    mutt_FormatString (cmd, sizeof (cmd), NONULL (Inews), nntp_format_str, 0,
+                       0);
+    if (!*cmd) {
       i = nntp_post (msg);
       unlink (msg);
       return i;
@@ -2171,21 +2087,19 @@ mutt_invoke_sendmail (ADDRESS *from,    /* the sender */
 
   ps = s;
   i = 0;
-  while ((ps = strtok (ps, " ")))
-  {
+  while ((ps = strtok (ps, " "))) {
     if (argslen == argsmax)
       safe_realloc (&args, sizeof (char *) * (argsmax += 5));
 
     if (i)
       args[argslen++] = ps;
-    else
-    {
+    else {
       path = safe_strdup (ps);
       ps = strrchr (ps, '/');
       if (ps)
-       ps++;
+        ps++;
       else
-       ps = path;
+        ps = path;
       args[argslen++] = ps;
     }
     ps = NULL;
@@ -2193,54 +2107,49 @@ mutt_invoke_sendmail (ADDRESS *from,    /* the sender */
   }
 
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND))
-  {
+  if (!option (OPTNEWSSEND)) {
 #endif
-  if (eightbit && option (OPTUSE8BITMIME))
-    args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
+    if (eightbit && option (OPTUSE8BITMIME))
+      args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
 
-  if (option (OPTENVFROM) && from && !from->next)
-  {
-    args = add_option (args, &argslen, &argsmax, "-f");
-    args = add_args   (args, &argslen, &argsmax, from);
-  }
-  if (DsnNotify)
-  {
-    args = add_option (args, &argslen, &argsmax, "-N");
-    args = add_option (args, &argslen, &argsmax, DsnNotify);
-  }
-  if (DsnReturn)
-  {
-    args = add_option (args, &argslen, &argsmax, "-R");
-    args = add_option (args, &argslen, &argsmax, DsnReturn);
-  }
-  args = add_option (args, &argslen, &argsmax, "--");
-  args = add_args (args, &argslen, &argsmax, to);
-  args = add_args (args, &argslen, &argsmax, cc);
-  args = add_args (args, &argslen, &argsmax, bcc);
+    if (option (OPTENVFROM) && from && !from->next) {
+      args = add_option (args, &argslen, &argsmax, "-f");
+      args = add_args (args, &argslen, &argsmax, from);
+    }
+    if (DsnNotify) {
+      args = add_option (args, &argslen, &argsmax, "-N");
+      args = add_option (args, &argslen, &argsmax, DsnNotify);
+    }
+    if (DsnReturn) {
+      args = add_option (args, &argslen, &argsmax, "-R");
+      args = add_option (args, &argslen, &argsmax, DsnReturn);
+    }
+    args = add_option (args, &argslen, &argsmax, "--");
+    args = add_args (args, &argslen, &argsmax, to);
+    args = add_args (args, &argslen, &argsmax, cc);
+    args = add_args (args, &argslen, &argsmax, bcc);
 #ifdef USE_NNTP
   }
 #endif
 
   if (argslen == argsmax)
     safe_realloc (&args, sizeof (char *) * (++argsmax));
-  
+
   args[argslen++] = NULL;
 
-  if ((i = send_msg (path, args, msg, &childout)) != (EX_OK & 0xff))
-  {
-    if (i != S_BKG)
-    {
+  if ((i = send_msg (path, args, msg, &childout)) != (EX_OK & 0xff)) {
+    if (i != S_BKG) {
       const char *e = strsysexit (i);
 
       e = strsysexit (i);
-      mutt_error (_("Error sending message, child exited %d (%s)."), i, NONULL (e));
-      if (childout)
-      {
-       struct stat st;
-       
-       if (stat (childout, &st) == 0 && st.st_size > 0)
-         mutt_do_pager (_("Output of the delivery process"), childout, 0, NULL);
+      mutt_error (_("Error sending message, child exited %d (%s)."), i,
+                  NONULL (e));
+      if (childout) {
+        struct stat st;
+
+        if (stat (childout, &st) == 0 && st.st_size > 0)
+          mutt_do_pager (_("Output of the delivery process"), childout, 0,
+                         NULL);
       }
     }
   }
@@ -2261,18 +2170,17 @@ mutt_invoke_sendmail (ADDRESS *from,    /* the sender */
   return (i);
 }
 
-int
-mutt_invoke_mta (ADDRESS *from,        /* the sender */
-                ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */
-                const char *msg, /* file containing message */
-                int eightbit) /* message contains 8bit chars */
-{
+int mutt_invoke_mta (ADDRESS * from,    /* the sender */
+                     ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, /* recips */
+                     const char *msg,   /* file containing message */
+                     int eightbit)
+{                               /* message contains 8bit chars */
 #ifdef USE_LIBESMTP
   if (SmtpHost)
-    return mutt_invoke_libesmtp(from, to, cc, bcc, msg, eightbit);
+    return mutt_invoke_libesmtp (from, to, cc, bcc, msg, eightbit);
 #endif
-  
-  return mutt_invoke_sendmail(from, to, cc, bcc, msg, eightbit);
+
+  return mutt_invoke_sendmail (from, to, cc, bcc, msg, eightbit);
 }
 
 /* appends string 'b' to string 'a', and returns the pointer to the new
@@ -2280,8 +2188,9 @@ mutt_invoke_mta (ADDRESS *from,   /* the sender */
 char *mutt_append_string (char *a, const char *b)
 {
   size_t la = mutt_strlen (a);
+
   safe_realloc (&a, la + mutt_strlen (b) + 1);
-  strcpy (a + la, b);  /* __STRCPY_CHECKED__ */
+  strcpy (a + la, b);           /* __STRCPY_CHECKED__ */
   return (a);
 }
 
@@ -2293,8 +2202,7 @@ char *mutt_append_string (char *a, const char *b)
    when used on a command line to execute a command */
 int mutt_needs_quote (const char *s)
 {
-  while (*s)
-  {
+  while (*s) {
     if (INVALID_CHAR (*s))
       return 1;
     s++;
@@ -2312,11 +2220,10 @@ char *mutt_quote_string (const char *s)
   rlen = mutt_strlen (s) + 3;
   pr = r = (char *) safe_malloc (rlen);
   *pr++ = '"';
-  while (*s)
-  {
-    if (INVALID_CHAR (*s))
-    {
+  while (*s) {
+    if (INVALID_CHAR (*s)) {
       size_t o = pr - r;
+
       safe_realloc (&r, ++rlen);
       pr = r + o;
       *pr++ = '\\';
@@ -2329,14 +2236,12 @@ char *mutt_quote_string (const char *s)
 }
 
 /* For postponing (!final) do the necessary encodings only */
-void mutt_prepare_envelope (ENVELOPE *env, int final)
+void mutt_prepare_envelope (ENVELOPE * env, int final)
 {
   char buffer[LONG_STRING];
 
-  if (final)
-  {
-    if (env->bcc && !(env->to || env->cc))
-    {
+  if (final) {
+    if (env->bcc && !(env->to || env->cc)) {
       /* some MTA's will put an Apparently-To: header field showing the Bcc:
        * recipients if there is no To: or Cc: field, so attempt to suppress
        * it by using an empty To: field.
@@ -2347,7 +2252,7 @@ void mutt_prepare_envelope (ENVELOPE *env, int final)
 
       buffer[0] = 0;
       rfc822_cat (buffer, sizeof (buffer), "undisclosed-recipients",
-                 RFC822Specials);
+                  RFC822Specials);
 
       env->to->mailbox = safe_strdup (buffer);
     }
@@ -2368,15 +2273,15 @@ void mutt_prepare_envelope (ENVELOPE *env, int final)
 
   if (env->subject)
 #ifdef USE_NNTP
-  if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
+    if (!option (OPTNEWSSEND) || option (OPTMIMESUBJECT))
 #endif
-  {
-    rfc2047_encode_string (&env->subject);
-  }
+    {
+      rfc2047_encode_string (&env->subject);
+    }
   encode_headers (env->userhdrs);
 }
 
-void mutt_unprepare_envelope (ENVELOPE *env)
+void mutt_unprepare_envelope (ENVELOPE * env)
 {
   LIST *item;
 
@@ -2394,20 +2299,21 @@ void mutt_unprepare_envelope (ENVELOPE *env)
   rfc2047_decode (&env->subject);
 }
 
-static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *resent_from,
-                                 ADDRESS *env_from)
+static int _mutt_bounce_message (FILE * fp, HEADER * h, ADDRESS * to,
+                                 const char *resent_from, ADDRESS * env_from)
 {
   int i, ret = 0;
   FILE *f;
   char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX];
   MESSAGE *msg = NULL;
 
-  if (!h)
-  {
-         /* Try to bounce each message out, aborting if we get any failures. */
-    for (i=0; i<Context->msgcount; i++)
+  if (!h) {
+    /* Try to bounce each message out, aborting if we get any failures. */
+    for (i = 0; i < Context->msgcount; i++)
       if (Context->hdrs[i]->tagged)
-        ret |= _mutt_bounce_message (fp, Context->hdrs[i], to, resent_from, env_from);
+        ret |=
+          _mutt_bounce_message (fp, Context->hdrs[i], to, resent_from,
+                                env_from);
     return ret;
   }
 
@@ -2415,20 +2321,20 @@ static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *r
   if (!fp && (msg = mx_open_message (Context, h->msgno)) == NULL)
     return -1;
 
-  if (!fp) fp = msg->fp;
+  if (!fp)
+    fp = msg->fp;
 
   mutt_mktemp (tempfile);
-  if ((f = safe_fopen (tempfile, "w")) != NULL)
-  {
+  if ((f = safe_fopen (tempfile, "w")) != NULL) {
     int ch_flags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
-    
+
     if (!option (OPTBOUNCEDELIVERED))
       ch_flags |= CH_WEED_DELIVERED;
-    
+
     fseek (fp, h->offset, 0);
     fprintf (f, "Resent-From: %s", resent_from);
-    fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date)));
-    fprintf (f, "Resent-Message-ID: %s\n", mutt_gen_msgid());
+    fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof (date)));
+    fprintf (f, "Resent-Message-ID: %s\n", mutt_gen_msgid ());
     fputs ("Resent-To: ", f);
     mutt_write_address_list (to, f, 11, 0);
     mutt_copy_header (fp, h, f, ch_flags, NULL);
@@ -2437,7 +2343,7 @@ static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *r
     fclose (f);
 
     ret = mutt_invoke_mta (env_from, to, NULL, NULL, tempfile,
-                               h->content->encoding == ENC8BIT);
+                           h->content->encoding == ENC8BIT);
   }
 
   if (msg)
@@ -2446,14 +2352,14 @@ static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *r
   return ret;
 }
 
-int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to)
+int mutt_bounce_message (FILE * fp, HEADER * h, ADDRESS * to)
 {
   ADDRESS *from;
   const char *fqdn = mutt_fqdn (1);
   char resent_from[STRING];
   int ret;
   char *err;
-  
+
   resent_from[0] = '\0';
   from = mutt_default_from ();
 
@@ -2461,10 +2367,8 @@ int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to)
     rfc822_qualify (from, fqdn);
 
   rfc2047_encode_adrlist (from, "Resent-From");
-  if (mutt_addrlist_to_idna (from, &err))
-  {
-    mutt_error (_("Bad IDN %s while preparing resent-from."),
-               err);
+  if (mutt_addrlist_to_idna (from, &err)) {
+    mutt_error (_("Bad IDN %s while preparing resent-from."), err);
     return -1;
   }
   rfc822_write_address (resent_from, sizeof (resent_from), from, 0);
@@ -2482,64 +2386,58 @@ int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to)
 
 
 /* given a list of addresses, return a list of unique addresses */
-ADDRESS *mutt_remove_duplicates (ADDRESS *addr)
+ADDRESS *mutt_remove_duplicates (ADDRESS * addr)
 {
   ADDRESS *top = addr;
   ADDRESS **last = &top;
   ADDRESS *tmp;
   int dup;
 
-  while (addr)
-  {
-    for (tmp = top, dup = 0; tmp && tmp != addr; tmp = tmp->next)
-    {
-      if (tmp->mailbox && addr->mailbox && 
-         !ascii_strcasecmp (addr->mailbox, tmp->mailbox))
-      {
-       dup = 1;
-       break;
+  while (addr) {
+    for (tmp = top, dup = 0; tmp && tmp != addr; tmp = tmp->next) {
+      if (tmp->mailbox && addr->mailbox &&
+          !ascii_strcasecmp (addr->mailbox, tmp->mailbox)) {
+        dup = 1;
+        break;
       }
     }
-    
-    if (dup)
-    {
+
+    if (dup) {
       dprint (2, (debugfile, "mutt_remove_duplicates: Removing %s\n",
-                 addr->mailbox));
-      
+                  addr->mailbox));
+
       *last = addr->next;
 
       addr->next = NULL;
-      rfc822_free_address(&addr);
-      
+      rfc822_free_address (&addr);
+
       addr = *last;
     }
-    else 
-    {
+    else {
       last = &addr->next;
       addr = addr->next;
     }
   }
-  
+
   return (top);
 }
 
-static void set_noconv_flags (BODY *b, short flag)
+static void set_noconv_flags (BODY * b, short flag)
 {
-  for(; b; b = b->next)
-  {
+  for (; b; b = b->next) {
     if (b->type == TYPEMESSAGE || b->type == TYPEMULTIPART)
       set_noconv_flags (b->parts, flag);
-    else if (b->type == TYPETEXT && b->noconv)
-    {
+    else if (b->type == TYPETEXT && b->noconv) {
       if (flag)
-       mutt_set_parameter ("x-mutt-noconv", "yes", &b->parameter);
+        mutt_set_parameter ("x-mutt-noconv", "yes", &b->parameter);
       else
-       mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
+        mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
     }
   }
 }
 
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc)
+int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid,
+                    int post, char *fcc)
 {
   CONTEXT f;
   MESSAGE *msg;
@@ -2549,31 +2447,29 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
 
   if (post)
     set_noconv_flags (hdr->content, 1);
-  
-  if (mx_open_mailbox (path, M_APPEND | M_QUIET, &f) == NULL)
-  {
-    dprint (1, (debugfile, "mutt_write_fcc(): unable to open mailbox %s in append-mode, aborting.\n",
-               path));
+
+  if (mx_open_mailbox (path, M_APPEND | M_QUIET, &f) == NULL) {
+    dprint (1,
+            (debugfile,
+             "mutt_write_fcc(): unable to open mailbox %s in append-mode, aborting.\n",
+             path));
     return (-1);
   }
 
   /* We need to add a Content-Length field to avoid problems where a line in
    * the message body begins with "From "   
    */
-  if (f.magic == M_MMDF || f.magic == M_MBOX)
-  {
+  if (f.magic == M_MMDF || f.magic == M_MBOX) {
     mutt_mktemp (tempfile);
-    if ((tempfp = safe_fopen (tempfile, "w+")) == NULL)
-    {
+    if ((tempfp = safe_fopen (tempfile, "w+")) == NULL) {
       mutt_perror (tempfile);
       mx_close_mailbox (&f, NULL);
       return (-1);
     }
   }
 
-  hdr->read = !post; /* make sure to put it in the `cur' directory (maildir) */
-  if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM)) == NULL)
-  {
+  hdr->read = !post;            /* make sure to put it in the `cur' directory (maildir) */
+  if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM)) == NULL) {
     mx_close_mailbox (&f, NULL);
     return (-1);
   }
@@ -2581,7 +2477,8 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
   /* post == 1 => postpone message. Set mode = -1 in mutt_write_rfc822_header()
    * post == 0 => Normal mode. Set mode = 0 in mutt_write_rfc822_header() 
    * */
-  mutt_write_rfc822_header (msg->fp, hdr->env, hdr->content, post ? -post : 0, 0);
+  mutt_write_rfc822_header (msg->fp, hdr->env, hdr->content, post ? -post : 0,
+                            0);
 
   /* (postponment) if this was a reply of some sort, <msgid> contians the
    * Message-ID: of message replied to.  Save it using a special X-Mutt-
@@ -2591,7 +2488,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
    */
   if (post && msgid)
     fprintf (msg->fp, "X-Mutt-References: %s\n", msgid);
-  
+
   /* (postponment) save the Fcc: using a special X-Mutt- header so that
    * it can be picked up when the message is recalled 
    */
@@ -2603,13 +2500,11 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
 
   /* (postponment) if the mail is to be signed or encrypted, save this info */
   if ((WithCrypto & APPLICATION_PGP)
-      && post && (hdr->security & APPLICATION_PGP))
-  {
+      && post && (hdr->security & APPLICATION_PGP)) {
     fputs ("X-Mutt-PGP: ", msg->fp);
-    if (hdr->security & ENCRYPT) 
+    if (hdr->security & ENCRYPT)
       fputc ('E', msg->fp);
-    if (hdr->security & SIGN)
-    {
+    if (hdr->security & SIGN) {
       fputc ('S', msg->fp);
       if (PgpSignAs && *PgpSignAs)
         fprintf (msg->fp, "<%s>", PgpSignAs);
@@ -2621,18 +2516,17 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
 
   /* (postponment) if the mail is to be signed or encrypted, save this info */
   if ((WithCrypto & APPLICATION_SMIME)
-      && post && (hdr->security & APPLICATION_SMIME))
-  {
+      && post && (hdr->security & APPLICATION_SMIME)) {
     fputs ("X-Mutt-SMIME: ", msg->fp);
     if (hdr->security & ENCRYPT) {
-       fputc ('E', msg->fp);
-       if (SmimeCryptAlg && *SmimeCryptAlg)
-           fprintf (msg->fp, "C<%s>", SmimeCryptAlg);
+      fputc ('E', msg->fp);
+      if (SmimeCryptAlg && *SmimeCryptAlg)
+        fprintf (msg->fp, "C<%s>", SmimeCryptAlg);
     }
     if (hdr->security & SIGN) {
-       fputc ('S', msg->fp);
-       if (SmimeDefaultKey && *SmimeDefaultKey)
-           fprintf (msg->fp, "<%s>", SmimeDefaultKey);
+      fputc ('S', msg->fp);
+      if (SmimeDefaultKey && *SmimeDefaultKey)
+        fprintf (msg->fp, "<%s>", SmimeDefaultKey);
     }
     if (hdr->security & INLINE)
       fputc ('I', msg->fp);
@@ -2643,21 +2537,19 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
   /* (postponement) if the mail is to be sent through a mixmaster 
    * chain, save that information
    */
-  
-  if (post && hdr->chain && hdr->chain)
-  {
+
+  if (post && hdr->chain && hdr->chain) {
     LIST *p;
 
     fputs ("X-Mutt-Mix:", msg->fp);
     for (p = hdr->chain; p; p = p->next)
       fprintf (msg->fp, " %s", (char *) p->data);
-    
+
     fputc ('\n', msg->fp);
   }
-#endif    
+#endif
 
-  if (tempfp)
-  {
+  if (tempfp) {
     char sasha[LONG_STRING];
     int lines = 0;
 
@@ -2668,19 +2560,18 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
      * later.
      */
     fseek (tempfp, -1, 2);
-    if (fgetc (tempfp) != '\n')
-    {
+    if (fgetc (tempfp) != '\n') {
       fseek (tempfp, 0, 2);
       fputc ('\n', tempfp);
     }
 
     fflush (tempfp);
-    if (ferror (tempfp))
-    {
-      dprint (1, (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile));
+    if (ferror (tempfp)) {
+      dprint (1,
+              (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile));
       fclose (tempfp);
       unlink (tempfile);
-      mx_commit_message (msg, &f);     /* XXX - really? */
+      mx_commit_message (msg, &f);      /* XXX - really? */
       mx_close_message (&msg);
       mx_close_mailbox (&f, NULL);
       return -1;
@@ -2702,9 +2593,8 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
     if (!r)
       unlink (tempfile);
   }
-  else
-  {
-    fputc ('\n', msg->fp); /* finish off the header */
+  else {
+    fputc ('\n', msg->fp);      /* finish off the header */
     r = mutt_write_mime_body (hdr->content, msg->fp);
   }
 
@@ -2715,6 +2605,6 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
 
   if (post)
     set_noconv_flags (hdr->content, 0);
-  
+
   return r;
 }
diff --git a/sha1.c b/sha1.c
index 3fb597e..4a5bedb 100644 (file)
--- a/sha1.c
+++ b/sha1.c
 
 /* Hash a single 512-bit block. This is the core of the algorithm. */
 
-void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
+void SHA1Transform (uint32_t state[5], const unsigned char buffer[64])
 {
-uint32_t a, b, c, d, e;
-typedef union {
+  uint32_t a, b, c, d, e;
+  typedef union {
     unsigned char c[64];
     uint32_t l[16];
-} CHAR64LONG16;
+  } CHAR64LONG16;
+
 #ifdef SHA1HANDSOFF
-CHAR64LONG16 block[1];  /* use array to appear as a pointer */
-    memcpy(block, buffer, 64);
+  CHAR64LONG16 block[1];        /* use array to appear as a pointer */
+
+  memcpy (block, buffer, 64);
 #else
-    /* The following had better never be used because it causes the
-     * pointer-to-const buffer to be cast into a pointer to non-const.
-     * And the result is written through.  I threw a "const" in, hoping
-     * this will cause a diagnostic.
-     */
-CHAR64LONG16* block = (const CHAR64LONG16*)buffer;
+  /* The following had better never be used because it causes the
+   * pointer-to-const buffer to be cast into a pointer to non-const.
+   * And the result is written through.  I threw a "const" in, hoping
+   * this will cause a diagnostic.
+   */
+  CHAR64LONG16 *block = (const CHAR64LONG16 *) buffer;
 #endif
-    /* Copy context->state[] to working vars */
-    a = state[0];
-    b = state[1];
-    c = state[2];
-    d = state[3];
-    e = state[4];
-    /* 4 rounds of 20 operations each. Loop unrolled. */
-    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
-    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
-    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
-    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
-    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
-    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
-    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
-    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
-    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
-    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
-    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
-    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
-    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
-    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
-    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
-    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
-    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
-    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
-    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
-    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
-    /* Add the working vars back into context.state[] */
-    state[0] += a;
-    state[1] += b;
-    state[2] += c;
-    state[3] += d;
-    state[4] += e;
-    /* Wipe variables */
-    a = b = c = d = e = 0;
+  /* Copy context->state[] to working vars */
+  a = state[0];
+  b = state[1];
+  c = state[2];
+  d = state[3];
+  e = state[4];
+  /* 4 rounds of 20 operations each. Loop unrolled. */
+  R0 (a, b, c, d, e, 0);
+  R0 (e, a, b, c, d, 1);
+  R0 (d, e, a, b, c, 2);
+  R0 (c, d, e, a, b, 3);
+  R0 (b, c, d, e, a, 4);
+  R0 (a, b, c, d, e, 5);
+  R0 (e, a, b, c, d, 6);
+  R0 (d, e, a, b, c, 7);
+  R0 (c, d, e, a, b, 8);
+  R0 (b, c, d, e, a, 9);
+  R0 (a, b, c, d, e, 10);
+  R0 (e, a, b, c, d, 11);
+  R0 (d, e, a, b, c, 12);
+  R0 (c, d, e, a, b, 13);
+  R0 (b, c, d, e, a, 14);
+  R0 (a, b, c, d, e, 15);
+  R1 (e, a, b, c, d, 16);
+  R1 (d, e, a, b, c, 17);
+  R1 (c, d, e, a, b, 18);
+  R1 (b, c, d, e, a, 19);
+  R2 (a, b, c, d, e, 20);
+  R2 (e, a, b, c, d, 21);
+  R2 (d, e, a, b, c, 22);
+  R2 (c, d, e, a, b, 23);
+  R2 (b, c, d, e, a, 24);
+  R2 (a, b, c, d, e, 25);
+  R2 (e, a, b, c, d, 26);
+  R2 (d, e, a, b, c, 27);
+  R2 (c, d, e, a, b, 28);
+  R2 (b, c, d, e, a, 29);
+  R2 (a, b, c, d, e, 30);
+  R2 (e, a, b, c, d, 31);
+  R2 (d, e, a, b, c, 32);
+  R2 (c, d, e, a, b, 33);
+  R2 (b, c, d, e, a, 34);
+  R2 (a, b, c, d, e, 35);
+  R2 (e, a, b, c, d, 36);
+  R2 (d, e, a, b, c, 37);
+  R2 (c, d, e, a, b, 38);
+  R2 (b, c, d, e, a, 39);
+  R3 (a, b, c, d, e, 40);
+  R3 (e, a, b, c, d, 41);
+  R3 (d, e, a, b, c, 42);
+  R3 (c, d, e, a, b, 43);
+  R3 (b, c, d, e, a, 44);
+  R3 (a, b, c, d, e, 45);
+  R3 (e, a, b, c, d, 46);
+  R3 (d, e, a, b, c, 47);
+  R3 (c, d, e, a, b, 48);
+  R3 (b, c, d, e, a, 49);
+  R3 (a, b, c, d, e, 50);
+  R3 (e, a, b, c, d, 51);
+  R3 (d, e, a, b, c, 52);
+  R3 (c, d, e, a, b, 53);
+  R3 (b, c, d, e, a, 54);
+  R3 (a, b, c, d, e, 55);
+  R3 (e, a, b, c, d, 56);
+  R3 (d, e, a, b, c, 57);
+  R3 (c, d, e, a, b, 58);
+  R3 (b, c, d, e, a, 59);
+  R4 (a, b, c, d, e, 60);
+  R4 (e, a, b, c, d, 61);
+  R4 (d, e, a, b, c, 62);
+  R4 (c, d, e, a, b, 63);
+  R4 (b, c, d, e, a, 64);
+  R4 (a, b, c, d, e, 65);
+  R4 (e, a, b, c, d, 66);
+  R4 (d, e, a, b, c, 67);
+  R4 (c, d, e, a, b, 68);
+  R4 (b, c, d, e, a, 69);
+  R4 (a, b, c, d, e, 70);
+  R4 (e, a, b, c, d, 71);
+  R4 (d, e, a, b, c, 72);
+  R4 (c, d, e, a, b, 73);
+  R4 (b, c, d, e, a, 74);
+  R4 (a, b, c, d, e, 75);
+  R4 (e, a, b, c, d, 76);
+  R4 (d, e, a, b, c, 77);
+  R4 (c, d, e, a, b, 78);
+  R4 (b, c, d, e, a, 79);
+  /* Add the working vars back into context.state[] */
+  state[0] += a;
+  state[1] += b;
+  state[2] += c;
+  state[3] += d;
+  state[4] += e;
+  /* Wipe variables */
+  a = b = c = d = e = 0;
 #ifdef SHA1HANDSOFF
-    memset(block, '\0', sizeof(block));
+  memset (block, '\0', sizeof (block));
 #endif
 }
 
 
 /* SHA1Init - Initialize new context */
 
-void SHA1Init(SHA1_CTX* context)
+void SHA1Init (SHA1_CTX * context)
 {
-    /* SHA1 initialization constants */
-    context->state[0] = 0x67452301;
-    context->state[1] = 0xEFCDAB89;
-    context->state[2] = 0x98BADCFE;
-    context->state[3] = 0x10325476;
-    context->state[4] = 0xC3D2E1F0;
-    context->count[0] = context->count[1] = 0;
+  /* SHA1 initialization constants */
+  context->state[0] = 0x67452301;
+  context->state[1] = 0xEFCDAB89;
+  context->state[2] = 0x98BADCFE;
+  context->state[3] = 0x10325476;
+  context->state[4] = 0xC3D2E1F0;
+  context->count[0] = context->count[1] = 0;
 }
 
 
 /* Run your data through this. */
 
-void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
+void SHA1Update (SHA1_CTX * context, const unsigned char *data, uint32_t len)
 {
-uint32_t i;
-uint32_t j;
-
-    j = context->count[0];
-    if ((context->count[0] += len << 3) < j)
-       context->count[1]++;
-    context->count[1] += (len>>29);
-    j = (j >> 3) & 63;
-    if ((j + len) > 63) {
-        memcpy(&context->buffer[j], data, (i = 64-j));
-        SHA1Transform(context->state, context->buffer);
-        for ( ; i + 63 < len; i += 64) {
-            SHA1Transform(context->state, &data[i]);
-        }
-        j = 0;
+  uint32_t i;
+  uint32_t j;
+
+  j = context->count[0];
+  if ((context->count[0] += len << 3) < j)
+    context->count[1]++;
+  context->count[1] += (len >> 29);
+  j = (j >> 3) & 63;
+  if ((j + len) > 63) {
+    memcpy (&context->buffer[j], data, (i = 64 - j));
+    SHA1Transform (context->state, context->buffer);
+    for (; i + 63 < len; i += 64) {
+      SHA1Transform (context->state, &data[i]);
     }
-    else i = 0;
-    memcpy(&context->buffer[j], &data[i], len - i);
+    j = 0;
+  }
+  else
+    i = 0;
+  memcpy (&context->buffer[j], &data[i], len - i);
 }
 
 
 /* Add padding and return the message digest. */
 
-void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+void SHA1Final (unsigned char digest[20], SHA1_CTX * context)
 {
-unsigned i;
-unsigned char finalcount[8];
-unsigned char c;
-
-#if 0  /* untested "improvement" by DHR */
-    /* Convert context->count to a sequence of bytes
-     * in finalcount.  Second element first, but
-     * big-endian order within element.
-     * But we do it all backwards.
-     */
-    unsigned char *fcp = &finalcount[8];
-
-    for (i = 0; i < 2; i++)
-    {
-       uint32_t t = context->count[i];
-       int j;
-
-       for (j = 0; j < 4; t >>= 8, j++)
-           *--fcp = (unsigned char) t
-    }
-#else
-    for (i = 0; i < 8; i++) {
-        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
-         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
-    }
-#endif
-    c = 0200;
-    SHA1Update(context, &c, 1);
-    while ((context->count[0] & 504) != 448) {
-       c = 0000;
-        SHA1Update(context, &c, 1);
-    }
-    SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
-    for (i = 0; i < 20; i++) {
-        digest[i] = (unsigned char)
-         ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
-    }
-    /* Wipe variables */
-    memset(context, '\0', sizeof(*context));
-    memset(&finalcount, '\0', sizeof(finalcount));
+  unsigned i;
+  unsigned char finalcount[8];
+  unsigned char c;
+
+  for (i = 0; i < 8; i++) {
+    finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)]
+                                      >> ((3 - (i & 3)) * 8)) & 255);   /* Endian independent */
+  }
+  c = 0200;
+  SHA1Update (context, &c, 1);
+  while ((context->count[0] & 504) != 448) {
+    c = 0000;
+    SHA1Update (context, &c, 1);
+  }
+  SHA1Update (context, finalcount, 8);  /* Should cause a SHA1Transform() */
+  for (i = 0; i < 20; i++) {
+    digest[i] = (unsigned char)
+      ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
+  }
+  /* Wipe variables */
+  memset (context, '\0', sizeof (*context));
+  memset (&finalcount, '\0', sizeof (finalcount));
 }
diff --git a/sha1.h b/sha1.h
index 304beb9..33eebbf 100644 (file)
--- a/sha1.h
+++ b/sha1.h
@@ -17,10 +17,10 @@ typedef struct {
   unsigned char buffer[64];
 } SHA1_CTX;
 
-void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
-void SHA1Init(SHA1_CTX* context);
-void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
-void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
+void SHA1Transform (uint32_t state[5], const unsigned char buffer[64]);
+void SHA1Init (SHA1_CTX * context);
+void SHA1Update (SHA1_CTX * context, const unsigned char *data, uint32_t len);
+void SHA1Final (unsigned char digest[20], SHA1_CTX * context);
 
 # define SHA1_Transform SHA1Transform
 # define SHA1_Init SHA1Init
index c59e982..56ba1bf 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -15,7 +15,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 
 
@@ -37,11 +37,11 @@ static int prev_show_value;
 static short saveSidebarWidth;
 static char *entry = 0;
 
-static int quick_log10(int n)
+static int quick_log10 (int n)
 {
   int len = 0;
-  for (; n > 9; len++, n /= 10)
-    ;
+
+  for (; n > 9; len++, n /= 10);
   return (++len);
 }
 
@@ -51,73 +51,78 @@ void calc_boundaries (int menu)
 {
   BUFFY *tmp = Incoming;
   int position;
-  int i,count, mailbox_position;
+  int i, count, mailbox_position;
 
   /* correct known_lines if it has changed because of a window resize */
-  if ( known_lines != LINES ) {
+  if (known_lines != LINES) {
     known_lines = LINES;
   }
   /* fix all the prev links on all the mailboxes
    * FIXME move this over to buffy.c where it belongs */
-  for ( ; tmp->next != 0; tmp = tmp->next )
+  for (; tmp->next != 0; tmp = tmp->next)
     tmp->next->prev = tmp;
 
   /* calculate the position of the current mailbox */
   position = 1;
   tmp = Incoming;
-  while (tmp != CurBuffy)
-  {
+  while (tmp != CurBuffy) {
     position++;
     tmp = tmp->next;
   }
   /* calculate the size of the screen we can use */
   count = LINES - 2 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
   /* calculate the position of the current mailbox on the screen */
-  mailbox_position = position%count;
-  if (mailbox_position == 0) mailbox_position=count;
+  mailbox_position = position % count;
+  if (mailbox_position == 0)
+    mailbox_position = count;
   /* determine topbuffy */
   TopBuffy = CurBuffy;
-  for(i = mailbox_position; i >1; i--) TopBuffy = TopBuffy->prev;
+  for (i = mailbox_position; i > 1; i--)
+    TopBuffy = TopBuffy->prev;
   /* determine bottombuffy */
   BottomBuffy = CurBuffy;
-  for(i = mailbox_position; i < count && BottomBuffy->next; i++)
+  for (i = mailbox_position; i < count && BottomBuffy->next; i++)
     BottomBuffy = BottomBuffy->next;
 }
 
-static char * shortened_hierarchy(char * box) {
+static char *shortened_hierarchy (char *box)
+{
   int dots = 0;
-  char * last_dot;
-  int i,j;
-  char * new_box;
-  for (i=0;i<strlen(box);++i) {
-    if (box[i] == '.') ++dots;
-    else if (isupper (box[i])) 
+  char *last_dot;
+  int i, j;
+  char *new_box;
+
+  for (i = 0; i < strlen (box); ++i) {
+    if (box[i] == '.')
+      ++dots;
+    else if (isupper (box[i]))
       return (safe_strdup (box));
   }
-  last_dot = strrchr(box,'.');
+  last_dot = strrchr (box, '.');
   if (last_dot) {
     ++last_dot;
-    new_box = safe_malloc(strlen(last_dot)+2*dots+1);
+    new_box = safe_malloc (strlen (last_dot) + 2 * dots + 1);
     new_box[0] = box[0];
-    for (i=1,j=1;i<strlen(box);++i) {
+    for (i = 1, j = 1; i < strlen (box); ++i) {
       if (box[i] == '.') {
         new_box[j++] = '.';
         new_box[j] = 0;
-        if (&box[i+1] != last_dot) {
-          new_box[j++] = box[i+1];
+        if (&box[i + 1] != last_dot) {
+          new_box[j++] = box[i + 1];
           new_box[j] = 0;
-        } else {
-          strcat(&new_box[j],last_dot);
+        }
+        else {
+          strcat (&new_box[j], last_dot);
           break;
         }
       }
     }
     return new_box;
   }
-  return safe_strdup(box);
+  return safe_strdup (box);
 }
 
-char *make_sidebar_entry(char *box, int size, int new, int flagged)
+char *make_sidebar_entry (char *box, int size, int new, int flagged)
 {
   int i = 0, dlen, max, shortened = 0;
   int offset;
@@ -125,92 +130,103 @@ char *make_sidebar_entry(char *box, int size, int new, int flagged)
   if (SidebarWidth > COLS)
     SidebarWidth = COLS;
 
-  dlen = mutt_strlen(SidebarDelim);
+  dlen = mutt_strlen (SidebarDelim);
   max = SidebarWidth - dlen - 1;
 
-  safe_realloc(&entry, SidebarWidth + 1);
+  safe_realloc (&entry, SidebarWidth + 1);
   entry[SidebarWidth] = 0;
-  for (; i < SidebarWidth; entry[i++] = ' ' );
+  for (; i < SidebarWidth; entry[i++] = ' ');
 #if USE_IMAP
-  if (ImapHomeNamespace && strlen(ImapHomeNamespace)>0) {
-    if (strncmp(box,ImapHomeNamespace,strlen(ImapHomeNamespace))==0 && strcmp(box,ImapHomeNamespace)!=0) {
-      box+=strlen(ImapHomeNamespace)+1;
+  if (ImapHomeNamespace && strlen (ImapHomeNamespace) > 0) {
+    if (strncmp (box, ImapHomeNamespace, strlen (ImapHomeNamespace)) == 0
+        && strcmp (box, ImapHomeNamespace) != 0) {
+      box += strlen (ImapHomeNamespace) + 1;
     }
   }
 #endif
-  max -= quick_log10(size);
+  max -= quick_log10 (size);
   if (new)
-    max -= quick_log10(new) + 2;
+    max -= quick_log10 (new) + 2;
   if (flagged > 0)
-    max -= quick_log10(flagged) + 2;
-  if (option(OPTSHORTENHIERARCHY) && mutt_strlen(box) > max) {
-    box = shortened_hierarchy(box);
+    max -= quick_log10 (flagged) + 2;
+  if (option (OPTSHORTENHIERARCHY) && mutt_strlen (box) > max) {
+    box = shortened_hierarchy (box);
     shortened = 1;
   }
-  i = strlen(box);
-  strncpy( entry, box, i < SidebarWidth - dlen ? i :SidebarWidth - dlen);
-
-  if ( new ) {
-    if (flagged>0) {
-      offset = SidebarWidth - 5 - quick_log10(size) - dlen - quick_log10(new) - quick_log10(flagged);
-      if (offset<0) offset = 0;
-      snprintf(entry + offset, SidebarWidth - dlen - offset + 1,
-              "% d(%d)[%d]", size, new, flagged);
-    } else {
-      offset = SidebarWidth - 3 - quick_log10(size) - dlen - quick_log10(new);
-      if (offset<0) offset = 0;
-      snprintf(entry + offset, SidebarWidth - dlen - offset + 1,
-              "% d(%d)", size, new);
+  i = strlen (box);
+  strncpy (entry, box, i < SidebarWidth - dlen ? i : SidebarWidth - dlen);
+
+  if (new) {
+    if (flagged > 0) {
+      offset =
+        SidebarWidth - 5 - quick_log10 (size) - dlen - quick_log10 (new) -
+        quick_log10 (flagged);
+      if (offset < 0)
+        offset = 0;
+      snprintf (entry + offset, SidebarWidth - dlen - offset + 1,
+                "% d(%d)[%d]", size, new, flagged);
+    }
+    else {
+      offset =
+        SidebarWidth - 3 - quick_log10 (size) - dlen - quick_log10 (new);
+      if (offset < 0)
+        offset = 0;
+      snprintf (entry + offset, SidebarWidth - dlen - offset + 1,
+                "% d(%d)", size, new);
+    }
+  }
+  else {
+    if (flagged > 0) {
+      offset =
+        SidebarWidth - 3 - quick_log10 (size) - dlen - quick_log10 (flagged);
+      if (offset < 0)
+        offset = 0;
+      snprintf (entry + offset, SidebarWidth - dlen - offset + 1,
+                "% d[%d]", size, flagged);
     }
-  } else {
-    if (flagged>0) {
-      offset = SidebarWidth - 3 - quick_log10(size) - dlen - quick_log10(flagged);
-      if (offset<0) offset = 0;
-      snprintf( entry + offset, SidebarWidth - dlen - offset + 1,
-              "% d[%d]", size,flagged);
-    } else {
-      offset = SidebarWidth - 1 - quick_log10(size) - dlen;
-      if (offset<0) offset = 0;
-      snprintf( entry + offset, SidebarWidth - dlen - offset + 1,
-              "% d", size);
+    else {
+      offset = SidebarWidth - 1 - quick_log10 (size) - dlen;
+      if (offset < 0)
+        offset = 0;
+      snprintf (entry + offset, SidebarWidth - dlen - offset + 1,
+                "% d", size);
     }
   }
 
-  if (option(OPTSHORTENHIERARCHY) && shortened) {
-    free(box);
+  if (option (OPTSHORTENHIERARCHY) && shortened) {
+    free (box);
   }
   return entry;
 }
 
-void set_curbuffy(char buf[LONG_STRING])
+void set_curbuffy (char buf[LONG_STRING])
 {
-  BUFFYtmp = CurBuffy = Incoming;
+  BUFFY *tmp = CurBuffy = Incoming;
 
   if (!Incoming)
     return;
 
-  while(1) {
-    if(!strcmp(tmp->path, buf)) {
+  while (1) {
+    if (!strcmp (tmp->path, buf)) {
       CurBuffy = tmp;
       break;
     }
 
-    if(tmp->next)
+    if (tmp->next)
       tmp = tmp->next;
     else
       break;
   }
 }
 
-void set_buffystats (CONTEXT* Context)
+void set_buffystats (CONTEXT * Context)
 {
-  BUFFY* tmp = Incoming;
+  BUFFY *tmp = Incoming;
+
   if (!Context)
     return;
-  while (tmp)
-  {
-    if (strcmp (tmp->path, Context->path) == 0)
-    {
+  while (tmp) {
+    if (strcmp (tmp->path, Context->path) == 0) {
       tmp->new = Context->new;
       tmp->msg_unread = Context->unread;
       tmp->msgcount = Context->msgcount;
@@ -221,34 +237,38 @@ void set_buffystats (CONTEXT* Context)
   }
 }
 
-int draw_sidebar(int menu) {
+int draw_sidebar (int menu)
+{
 
-  int lines = option(OPTHELP) ? 1 : 0;
+  int lines = option (OPTHELP) ? 1 : 0;
   BUFFY *tmp;
   short delim_len = mutt_strlen (SidebarDelim);
 
   /* initialize first time */
-  if(!initialized) {
-    prev_show_value = option(OPTMBOXPANE);
+  if (!initialized) {
+    prev_show_value = option (OPTMBOXPANE);
     saveSidebarWidth = SidebarWidth;
-    if(!option(OPTMBOXPANE)) SidebarWidth = 0;
+    if (!option (OPTMBOXPANE))
+      SidebarWidth = 0;
     initialized = 1;
   }
 
   /* save or restore the value SidebarWidth */
-  if(prev_show_value != option(OPTMBOXPANE)) {
-    if(prev_show_value && !option(OPTMBOXPANE)) {
+  if (prev_show_value != option (OPTMBOXPANE)) {
+    if (prev_show_value && !option (OPTMBOXPANE)) {
       saveSidebarWidth = SidebarWidth;
       SidebarWidth = 0;
-    } else if(!prev_show_value && option(OPTMBOXPANE)) {
+    }
+    else if (!prev_show_value && option (OPTMBOXPANE)) {
       SidebarWidth = saveSidebarWidth;
       /* after toggle: force recounting of all mail */
-      mutt_buffy_check(2);
+      mutt_buffy_check (2);
     }
-    prev_show_value = option(OPTMBOXPANE);
+    prev_show_value = option (OPTMBOXPANE);
   }
 
-  if (SidebarWidth > 0 && option (OPTMBOXPANE) && mutt_strlen (SidebarDelim) >= SidebarWidth) {
+  if (SidebarWidth > 0 && option (OPTMBOXPANE)
+      && mutt_strlen (SidebarDelim) >= SidebarWidth) {
     mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
     sleep (2);
     unset_option (OPTMBOXPANE);
@@ -260,168 +280,189 @@ int draw_sidebar(int menu) {
 
   /* draw the divider */
   /* SETCOLOR(MT_COLOR_STATUS); */
-    SETCOLOR(MT_COLOR_SIDEBAR);
+  SETCOLOR (MT_COLOR_SIDEBAR);
   for (lines = 1;
-       lines < LINES-1-(menu != MENU_PAGER || option (OPTSTATUSONTOP)); lines++ ) {
-    move(lines, SidebarWidth - delim_len);
+       lines < LINES - 1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
+       lines++) {
+    move (lines, SidebarWidth - delim_len);
     if (option (OPTASCIICHARS))
       addstr (NONULL (SidebarDelim));
-    else if(!option(OPTASCIICHARS) && !strcmp(SidebarDelim,"|"))
-      addch(ACS_VLINE);
-    else if ((Charset_is_utf8) && !strcmp(SidebarDelim, "|"))
+    else if (!option (OPTASCIICHARS) && !strcmp (SidebarDelim, "|"))
+      addch (ACS_VLINE);
+    else if ((Charset_is_utf8) && !strcmp (SidebarDelim, "|"))
       addstr ("\342\224\202");
     else
       addstr (NONULL (SidebarDelim));
   }
-  SETCOLOR(MT_COLOR_NORMAL);
+  SETCOLOR (MT_COLOR_NORMAL);
 
-  if ( Incoming == 0 ) return 0;
-  lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
+  if (Incoming == 0)
+    return 0;
+  lines = option (OPTHELP) ? 1 : 0;     /* go back to the top */
 
-  if ( CurBuffy == 0 ) CurBuffy = Incoming;
+  if (CurBuffy == 0)
+    CurBuffy = Incoming;
 #if 0
-  if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
+  if (known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0)
 #endif
-    calc_boundaries(menu);
+    calc_boundaries (menu);
 
   tmp = TopBuffy;
 
-  for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP)); tmp = tmp->next ) {
-    if ( tmp == CurBuffy )
-      SETCOLOR(MT_COLOR_INDICATOR);
-    else if ( tmp->msg_flagged > 0 )
-      SETCOLOR(MT_COLOR_FLAGGED);
-    else if ( tmp->msg_unread > 0 )
-      SETCOLOR(MT_COLOR_NEW);
+  for (;
+       tmp && lines < LINES - 1 - (menu != MENU_PAGER
+                                   || option (OPTSTATUSONTOP));
+       tmp = tmp->next) {
+    if (tmp == CurBuffy)
+      SETCOLOR (MT_COLOR_INDICATOR);
+    else if (tmp->msg_flagged > 0)
+      SETCOLOR (MT_COLOR_FLAGGED);
+    else if (tmp->msg_unread > 0)
+      SETCOLOR (MT_COLOR_NEW);
     else
-      SETCOLOR(MT_COLOR_NORMAL);
+      SETCOLOR (MT_COLOR_NORMAL);
 
-    move( lines, 0 );
-    if (option(OPTSIDEBARNEWMAILONLY)) {
+    move (lines, 0);
+    if (option (OPTSIDEBARNEWMAILONLY)) {
       if (tmp->msg_unread > 0) {
-        if ( Context && !strcmp( tmp->path, Context->path ) ) {
-          printw( "%.*s", SidebarWidth - delim_len,
-                  make_sidebar_entry(basename(tmp->path),
-                                     Context->msgcount, Context->unread, Context->flagged));
+        if (Context && !strcmp (tmp->path, Context->path)) {
+          printw ("%.*s", SidebarWidth - delim_len,
+                  make_sidebar_entry (basename (tmp->path),
+                                      Context->msgcount, Context->unread,
+                                      Context->flagged));
           tmp->msg_unread = Context->unread;
           tmp->msgcount = Context->msgcount;
           tmp->msg_flagged = Context->flagged;
         }
         else
-          printw( "%.*s", SidebarWidth - delim_len,
-                  make_sidebar_entry(basename(tmp->path),
-                                     tmp->msgcount,tmp->msg_unread, tmp->msg_flagged));
+          printw ("%.*s", SidebarWidth - delim_len,
+                  make_sidebar_entry (basename (tmp->path),
+                                      tmp->msgcount, tmp->msg_unread,
+                                      tmp->msg_flagged));
         lines++;
       }
-    } else {
-      if ( Context && !strcmp( tmp->path, Context->path ) ) {
-        printw( "%.*s", SidebarWidth - delim_len,
-                make_sidebar_entry(basename(tmp->path),
-                                   Context->msgcount, Context->unread, Context->flagged));
+    }
+    else {
+      if (Context && !strcmp (tmp->path, Context->path)) {
+        printw ("%.*s", SidebarWidth - delim_len,
+                make_sidebar_entry (basename (tmp->path),
+                                    Context->msgcount, Context->unread,
+                                    Context->flagged));
         tmp->msg_unread = Context->unread;
         tmp->msgcount = Context->msgcount;
         tmp->msg_flagged = Context->flagged;
       }
       else
-        printw( "%.*s", SidebarWidth - delim_len,
-                make_sidebar_entry(basename(tmp->path),
-                                   tmp->msgcount,tmp->msg_unread, tmp->msg_flagged));
+        printw ("%.*s", SidebarWidth - delim_len,
+                make_sidebar_entry (basename (tmp->path),
+                                    tmp->msgcount, tmp->msg_unread,
+                                    tmp->msg_flagged));
       lines++;
     }
   }
-  SETCOLOR(MT_COLOR_NORMAL);
-  for ( ; lines < LINES - 1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP)); lines++ ) {
+  SETCOLOR (MT_COLOR_NORMAL);
+  for (; lines < LINES - 1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP));
+       lines++) {
     int i = 0;
-    move( lines, 0 );
-    for ( ; i < SidebarWidth - delim_len; i++ )
-      addch(' ');
+
+    move (lines, 0);
+    for (; i < SidebarWidth - delim_len; i++)
+      addch (' ');
   }
   return 0;
 }
 
-BUFFY * exist_next_new()
+BUFFY *exist_next_new ()
 {
-       BUFFY *tmp = CurBuffy;
-       if(tmp == NULL) return NULL;
-       while (tmp->next != NULL)
-       {
-               tmp = tmp->next;
-               if(tmp->msg_unread) return tmp;
-       }
-       return NULL;
+  BUFFY *tmp = CurBuffy;
+
+  if (tmp == NULL)
+    return NULL;
+  while (tmp->next != NULL) {
+    tmp = tmp->next;
+    if (tmp->msg_unread)
+      return tmp;
+  }
+  return NULL;
 }
 
-BUFFY * exist_prev_new()
+BUFFY *exist_prev_new ()
 {
-       BUFFY *tmp = CurBuffy;
-       if(tmp == NULL) return NULL;
-       while (tmp->prev != NULL)
-       {
-               tmp = tmp->prev;
-               if(tmp->msg_unread) return tmp;
-       }
-       return NULL;
-}     
-
-
-void scroll_sidebar(int op, int menu)
+  BUFFY *tmp = CurBuffy;
+
+  if (tmp == NULL)
+    return NULL;
+  while (tmp->prev != NULL) {
+    tmp = tmp->prev;
+    if (tmp->msg_unread)
+      return tmp;
+  }
+  return NULL;
+}
+
+
+void scroll_sidebar (int op, int menu)
 {
   BUFFY *tmp;
 
-  if(!SidebarWidth) return;
-  if(!CurBuffy) return;
+  if (!SidebarWidth)
+    return;
+  if (!CurBuffy)
+    return;
 
   switch (op) {
-    case OP_SIDEBAR_NEXT:
-      if (!option(OPTSIDEBARNEWMAILONLY)) {
-        if ( CurBuffy->next == NULL ) {
-          mutt_error (_("You are on the last mailbox."));
-          return;
-        }
-        CurBuffy = CurBuffy->next;
-        break;
-      } /* the fall-through is intentional */
-    case OP_SIDEBAR_NEXT_NEW:
-      if ( (tmp = exist_next_new()) == NULL) {
-        mutt_error (_("No next mailboxes with new mail."));
+  case OP_SIDEBAR_NEXT:
+    if (!option (OPTSIDEBARNEWMAILONLY)) {
+      if (CurBuffy->next == NULL) {
+        mutt_error (_("You are on the last mailbox."));
         return;
       }
-      else CurBuffy = tmp;
+      CurBuffy = CurBuffy->next;
       break;
-    case OP_SIDEBAR_PREV:
-      if (!option(OPTSIDEBARNEWMAILONLY)) {
-        if ( CurBuffy->prev == NULL ) {
-          mutt_error (_("You are on the first mailbox."));
-          return;
-        }
-        CurBuffy = CurBuffy->prev;
-       break;
-     } /* the fall-through is intentional */
-    case OP_SIDEBAR_PREV_NEW:
-      if ( (tmp = exist_prev_new()) == NULL) {
-        mutt_error (_("No previous mailbox with new mail."));
+    }                           /* the fall-through is intentional */
+  case OP_SIDEBAR_NEXT_NEW:
+    if ((tmp = exist_next_new ()) == NULL) {
+      mutt_error (_("No next mailboxes with new mail."));
+      return;
+    }
+    else
+      CurBuffy = tmp;
+    break;
+  case OP_SIDEBAR_PREV:
+    if (!option (OPTSIDEBARNEWMAILONLY)) {
+      if (CurBuffy->prev == NULL) {
+        mutt_error (_("You are on the first mailbox."));
         return;
       }
-      else CurBuffy = tmp;
-      break;
-     
-    case OP_SIDEBAR_SCROLL_UP:
-      CurBuffy = TopBuffy;
-      if ( CurBuffy != Incoming ) {
-        calc_boundaries(menu);
-        CurBuffy = CurBuffy->prev;
-      }
-      break;
-    case OP_SIDEBAR_SCROLL_DOWN:
-      CurBuffy = BottomBuffy;
-      if ( CurBuffy->next ) {
-        calc_boundaries(menu);
-        CurBuffy = CurBuffy->next;
-      }
+      CurBuffy = CurBuffy->prev;
       break;
-    default:
+    }                           /* the fall-through is intentional */
+  case OP_SIDEBAR_PREV_NEW:
+    if ((tmp = exist_prev_new ()) == NULL) {
+      mutt_error (_("No previous mailbox with new mail."));
       return;
+    }
+    else
+      CurBuffy = tmp;
+    break;
+
+  case OP_SIDEBAR_SCROLL_UP:
+    CurBuffy = TopBuffy;
+    if (CurBuffy != Incoming) {
+      calc_boundaries (menu);
+      CurBuffy = CurBuffy->prev;
+    }
+    break;
+  case OP_SIDEBAR_SCROLL_DOWN:
+    CurBuffy = BottomBuffy;
+    if (CurBuffy->next) {
+      calc_boundaries (menu);
+      CurBuffy = CurBuffy->next;
+    }
+    break;
+  default:
+    return;
   }
-  calc_boundaries(menu);
-  draw_sidebar(menu);
+  calc_boundaries (menu);
+  draw_sidebar (menu);
 }
index 4e7bbf3..ca7faa2 100644 (file)
--- a/sidebar.h
+++ b/sidebar.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #ifndef SIDEBAR_H
 #define SIDEBAR_H
 
 /* parameter is whether or not to go to the status line */
 /* used for omitting the last | that covers up the status bar in the index */
-int draw_sidebar(int);
-void scroll_sidebar(int, int);
-void set_curbuffy(char*);
-void set_buffystats (CONTEXT*);
+int draw_sidebar (int);
+void scroll_sidebar (int, int);
+void set_curbuffy (char *);
+void set_buffystats (CONTEXT *);
 
 #endif /* SIDEBAR_H */
index 05be6b0..81f1d70 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -38,17 +38,17 @@ static int IsEndwin = 0;
 RETSIGTYPE exit_handler (int sig)
 {
   curs_set (1);
-  endwin (); /* just to be safe */
+  endwin ();                    /* just to be safe */
 #if SYS_SIGLIST_DECLARED
-  printf(_("%s...  Exiting.\n"), sys_siglist[sig]);
+  printf (_("%s...  Exiting.\n"), sys_siglist[sig]);
 #else
 #if (__sun__ && __svr4__)
-  printf(_("Caught %s...  Exiting.\n"), _sys_siglist[sig]);
+  printf (_("Caught %s...  Exiting.\n"), _sys_siglist[sig]);
 #else
 #if (__alpha && __osf__)
-  printf(_("Caught %s...  Exiting.\n"), __sys_siglist[sig]);
+  printf (_("Caught %s...  Exiting.\n"), __sys_siglist[sig]);
 #else
-  printf(_("Caught signal %d...  Exiting.\n"), sig);
+  printf (_("Caught signal %d...  Exiting.\n"), sig);
 #endif
 #endif
 #endif
@@ -64,37 +64,36 @@ RETSIGTYPE sighandler (int sig)
 {
   int save_errno = errno;
 
-  switch (sig)
-  {
-    case SIGTSTP: /* user requested a suspend */
-      if (!option (OPTSUSPEND))
-        break;
-      IsEndwin = isendwin ();
-      curs_set (1);
-      if (!IsEndwin)
-       endwin ();
-      kill (0, SIGSTOP);
-
-    case SIGCONT:
-      if (!IsEndwin)
-       refresh ();
-      mutt_curs_set (-1);
+  switch (sig) {
+  case SIGTSTP:                /* user requested a suspend */
+    if (!option (OPTSUSPEND))
+      break;
+    IsEndwin = isendwin ();
+    curs_set (1);
+    if (!IsEndwin)
+      endwin ();
+    kill (0, SIGSTOP);
+
+  case SIGCONT:
+    if (!IsEndwin)
+      refresh ();
+    mutt_curs_set (-1);
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-      /* We don't receive SIGWINCH when suspended; however, no harm is done by
-       * just assuming we received one, and triggering the 'resize' anyway. */
-      SigWinch = 1;
+    /* We don't receive SIGWINCH when suspended; however, no harm is done by
+     * just assuming we received one, and triggering the 'resize' anyway. */
+    SigWinch = 1;
 #endif
-      break;
+    break;
 
 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-    case SIGWINCH:
-      SigWinch = 1;
-      break;
+  case SIGWINCH:
+    SigWinch = 1;
+    break;
 #endif
 
-    case SIGINT:
-      SigInt = 1;
-      break;
+  case SIGINT:
+    SigInt = 1;
+    break;
 
   }
   errno = save_errno;
@@ -169,8 +168,7 @@ void mutt_signal_init (void)
 /* signals which are important to block while doing critical ops */
 void mutt_block_signals (void)
 {
-  if (!option (OPTSIGNALSBLOCKED))
-  {
+  if (!option (OPTSIGNALSBLOCKED)) {
     sigemptyset (&Sigset);
     sigaddset (&Sigset, SIGTERM);
     sigaddset (&Sigset, SIGHUP);
@@ -187,8 +185,7 @@ void mutt_block_signals (void)
 /* restore the previous signal mask */
 void mutt_unblock_signals (void)
 {
-  if (option (OPTSIGNALSBLOCKED))
-  {
+  if (option (OPTSIGNALSBLOCKED)) {
     sigprocmask (SIG_UNBLOCK, &Sigset, 0);
     unset_option (OPTSIGNALSBLOCKED);
   }
@@ -198,8 +195,7 @@ void mutt_block_signals_system (void)
 {
   struct sigaction sa;
 
-  if (! option (OPTSYSSIGNALSBLOCKED))
-  {
+  if (!option (OPTSYSSIGNALSBLOCKED)) {
     /* POSIX: ignore SIGINT and SIGQUIT & block SIGCHLD  before exec */
     sa.sa_handler = SIG_IGN;
     sa.sa_flags = 0;
@@ -216,16 +212,13 @@ void mutt_block_signals_system (void)
 
 void mutt_unblock_signals_system (int catch)
 {
-  if (option (OPTSYSSIGNALSBLOCKED))
-  {
+  if (option (OPTSYSSIGNALSBLOCKED)) {
     sigprocmask (SIG_UNBLOCK, &SigsetSys, NULL);
-    if (catch)
-    {
+    if (catch) {
       sigaction (SIGQUIT, &SysOldQuit, NULL);
       sigaction (SIGINT, &SysOldInt, NULL);
     }
-    else
-    {
+    else {
       struct sigaction sa;
 
       sa.sa_handler = SIG_DFL;
@@ -242,7 +235,7 @@ void mutt_unblock_signals_system (int catch)
 void mutt_allow_interrupt (int disposition)
 {
   struct sigaction sa;
-  
+
   memset (&sa, 0, sizeof sa);
   sa.sa_handler = sighandler;
 #ifdef SA_RESTART
diff --git a/smime.c b/smime.c
index 2361830..1f25222 100644 (file)
--- a/smime.c
+++ b/smime.c
 #include "mutt_crypt.h"
 
 struct smime_command_context {
-  const char *key;                 /* %k */
-  const char *cryptalg;                    /* %a */
-  const char *fname;               /* %f */
-  const char *sig_fname;           /* %s */
-  const char *certificates;        /* %c */
-  const char *intermediates;        /* %i */
+  const char *key;              /* %k */
+  const char *cryptalg;         /* %a */
+  const char *fname;            /* %f */
+  const char *sig_fname;        /* %s */
+  const char *certificates;     /* %c */
+  const char *intermediates;    /* %i */
 };
 
 
@@ -68,13 +68,13 @@ typedef struct {
   char suffix;
   char email[256];
   char nick[256];
-  char trust; /* i=Invalid r=revoked e=expired u=unverified v=verified t=trusted */
-  short public; /* 1=public 0=private */
+  char trust;                   /* i=Invalid r=revoked e=expired u=unverified v=verified t=trusted */
+  short public;                 /* 1=public 0=private */
 } smime_id;
 
 
 char SmimePass[STRING];
-time_t SmimeExptime = 0; /* when does the cached passphrase expire? */
+time_t SmimeExptime = 0;        /* when does the cached passphrase expire? */
 
 
 static char SmimeKeyToUse[_POSIX_PATH_MAX] = { 0 };
@@ -106,13 +106,13 @@ int smime_valid_passphrase (void)
     /* Use cached copy.  */
     return 1;
 
-  smime_void_passphrase();
-  
-  if (mutt_get_password (_("Enter SMIME passphrase:"), SmimePass, sizeof (SmimePass)) == 0)
-    {
-      SmimeExptime = time (NULL) + SmimeTimeout;
-      return (1);
-    }
+  smime_void_passphrase ();
+
+  if (mutt_get_password
+      (_("Enter SMIME passphrase:"), SmimePass, sizeof (SmimePass)) == 0) {
+    SmimeExptime = time (NULL) + SmimeTimeout;
+    return (1);
+  }
   else
     SmimeExptime = 0;
 
@@ -127,126 +127,121 @@ int smime_valid_passphrase (void)
 /* This is almost identical to ppgp's invoking interface. */
 
 static const char *_mutt_fmt_smime_command (char *dest,
-                                           size_t destlen,
-                                           char op,
-                                           const char *src,
-                                           const char *prefix,
-                                           const char *ifstring,
-                                           const char *elsestring,
-                                           unsigned long data,
-                                           format_flag flags)
+                                            size_t destlen,
+                                            char op,
+                                            const char *src,
+                                            const char *prefix,
+                                            const char *ifstring,
+                                            const char *elsestring,
+                                            unsigned long data,
+                                            format_flag flags)
 {
   char fmt[16];
   struct smime_command_context *cctx = (struct smime_command_context *) data;
   int optional = (flags & M_FORMAT_OPTIONAL);
-  
-  switch (op)
-  {
-    case 'C':
+
+  switch (op) {
+  case 'C':
     {
-      if (!optional)
-      {
-       char path[_POSIX_PATH_MAX];
-       char buf1[LONG_STRING], buf2[LONG_STRING];
-       struct stat sb;
-
-       strfcpy (path, NONULL (SmimeCALocation), sizeof (path));
-       mutt_expand_path (path, sizeof (path));
-       mutt_quote_filename (buf1, sizeof (buf1), path);
-
-       if (stat (path, &sb) != 0 || !S_ISDIR (sb.st_mode))
-         snprintf (buf2, sizeof (buf2), "-CAfile %s", buf1);
-       else
-         snprintf (buf2, sizeof (buf2), "-CApath %s", buf1);
-       
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, buf2);
+      if (!optional) {
+        char path[_POSIX_PATH_MAX];
+        char buf1[LONG_STRING], buf2[LONG_STRING];
+        struct stat sb;
+
+        strfcpy (path, NONULL (SmimeCALocation), sizeof (path));
+        mutt_expand_path (path, sizeof (path));
+        mutt_quote_filename (buf1, sizeof (buf1), path);
+
+        if (stat (path, &sb) != 0 || !S_ISDIR (sb.st_mode))
+          snprintf (buf2, sizeof (buf2), "-CAfile %s", buf1);
+        else
+          snprintf (buf2, sizeof (buf2), "-CApath %s", buf1);
+
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, buf2);
       }
       else if (!SmimeCALocation)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'c':
-    {           /* certificate (list) */
+
+  case 'c':
+    {                           /* certificate (list) */
       if (!optional) {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL(cctx->certificates));
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->certificates));
       }
       else if (!cctx->certificates)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'i':
-    {           /* intermediate certificates  */
+
+  case 'i':
+    {                           /* intermediate certificates  */
       if (!optional) {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL(cctx->intermediates));
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->intermediates));
       }
       else if (!cctx->intermediates)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 's':
-    {           /* detached signature */
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->sig_fname));
+
+  case 's':
+    {                           /* detached signature */
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->sig_fname));
       }
       else if (!cctx->sig_fname)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'k':
-    {           /* private key */
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->key));
+
+  case 'k':
+    {                           /* private key */
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->key));
       }
       else if (!cctx->key)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'a':
-    {           /* algorithm for encryption */
+
+  case 'a':
+    {                           /* algorithm for encryption */
       if (!optional) {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->cryptalg));
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->cryptalg));
       }
       else if (!cctx->key)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    case 'f':
-    {           /* file to process */
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       snprintf (dest, destlen, fmt, NONULL (cctx->fname));
+
+  case 'f':
+    {                           /* file to process */
+      if (!optional) {
+        snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+        snprintf (dest, destlen, fmt, NONULL (cctx->fname));
       }
       else if (!cctx->fname)
-       optional = 0;
+        optional = 0;
       break;
     }
-    
-    default:
-      *dest = '\0';
-      break;
+
+  default:
+    *dest = '\0';
+    break;
   }
 
   if (optional)
     mutt_FormatString (dest, destlen, ifstring, _mutt_fmt_smime_command,
-                      data, 0);
+                       data, 0);
   else if (flags & M_FORMAT_OPTIONAL)
     mutt_FormatString (dest, destlen, elsestring, _mutt_fmt_smime_command,
-                      data, 0);
+                       data, 0);
 
   return (src);
 }
@@ -254,45 +249,43 @@ static const char *_mutt_fmt_smime_command (char *dest,
 
 
 static void mutt_smime_command (char *d, size_t dlen,
-                               struct smime_command_context *cctx, const char *fmt)
+                                struct smime_command_context *cctx,
+                                const char *fmt)
 {
-  mutt_FormatString (d, dlen, NONULL(fmt), _mutt_fmt_smime_command,
-                   (unsigned long) cctx, 0);
-  dprint (2,(debugfile, "mutt_smime_command: %s\n", d));
+  mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_smime_command,
+                     (unsigned long) cctx, 0);
+  dprint (2, (debugfile, "mutt_smime_command: %s\n", d));
 }
 
 
 
 
-static pid_t smime_invoke (FILE **smimein, FILE **smimeout, FILE **smimeerr,
-                          int smimeinfd, int smimeoutfd, int smimeerrfd,
-                          const char *fname,
-                          const char *sig_fname,
-                          const char *cryptalg,
-                          const char *key,
-                          const char *certificates,
-                          const char *intermediates,
-                          const char *format)
+static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout,
+                           FILE ** smimeerr, int smimeinfd, int smimeoutfd,
+                           int smimeerrfd, const char *fname,
+                           const char *sig_fname, const char *cryptalg,
+                           const char *key, const char *certificates,
+                           const char *intermediates, const char *format)
 {
   struct smime_command_context cctx;
   char cmd[HUGE_STRING];
-  
+
   memset (&cctx, 0, sizeof (cctx));
 
   if (!format || !*format)
-    return (pid_t) -1;
-  
-  cctx.fname          = fname;
-  cctx.sig_fname       = sig_fname;
-  cctx.key            = key;
-  cctx.cryptalg               = cryptalg;
-  cctx.certificates    = certificates;
-  cctx.intermediates   = intermediates;
-  
+    return (pid_t) - 1;
+
+  cctx.fname = fname;
+  cctx.sig_fname = sig_fname;
+  cctx.key = key;
+  cctx.cryptalg = cryptalg;
+  cctx.certificates = certificates;
+  cctx.intermediates = intermediates;
+
   mutt_smime_command (cmd, sizeof (cmd), &cctx, format);
 
   return mutt_create_filter_fd (cmd, smimein, smimeout, smimeerr,
-                               smimeinfd, smimeoutfd, smimeerrfd);
+                                smimeinfd, smimeoutfd, smimeerrfd);
 }
 
 
@@ -313,131 +306,134 @@ static pid_t smime_invoke (FILE **smimein, FILE **smimeout, FILE **smimeerr,
 
 static void smime_entry (char *s, size_t l, MUTTMENU * menu, int num)
 {
-  smime_id *Table = (smime_id*) menu->data;
+  smime_id *Table = (smime_id *) menu->data;
   smime_id this = Table[num];
-  char* truststate;
-  switch(this.trust) {
-    case 't':
-      truststate = N_("Trusted   ");
-      break;
-    case 'v':
-      truststate = N_("Verified  ");
-      break;
-    case 'u':
-      truststate = N_("Unverified");
-      break;
-    case 'e':
-      truststate = N_("Expired   ");
-      break;
-    case 'r':
-      truststate = N_("Revoked   ");
-      break;
-    case 'i':
-      truststate = N_("Invalid   ");
-      break;
-    default:
-      truststate = N_("Unknown   ");
+  char *truststate;
+
+  switch (this.trust) {
+  case 't':
+    truststate = N_("Trusted   ");
+    break;
+  case 'v':
+    truststate = N_("Verified  ");
+    break;
+  case 'u':
+    truststate = N_("Unverified");
+    break;
+  case 'e':
+    truststate = N_("Expired   ");
+    break;
+  case 'r':
+    truststate = N_("Revoked   ");
+    break;
+  case 'i':
+    truststate = N_("Invalid   ");
+    break;
+  default:
+    truststate = N_("Unknown   ");
   }
   if (this.public)
-    snprintf(s, l, " 0x%.8X.%i %s %-35.35s %s", this.hash, this.suffix, truststate, this.email, this.nick);
+    snprintf (s, l, " 0x%.8X.%i %s %-35.35s %s", this.hash, this.suffix,
+              truststate, this.email, this.nick);
   else
-    snprintf(s, l, " 0x%.8X.%i %-35.35s %s", this.hash, this.suffix, this.email, this.nick);
+    snprintf (s, l, " 0x%.8X.%i %-35.35s %s", this.hash, this.suffix,
+              this.email, this.nick);
 }
 
 
 
 
 
-charsmime_ask_for_key (char *prompt, char *mailbox, short public)
+char *smime_ask_for_key (char *prompt, char *mailbox, short public)
 {
   char *fname;
   smime_id *Table;
-  long cert_num; /* Will contain the number of certificates.
-      * To be able to get it, the .index file will be read twice... */
+  long cert_num;                /* Will contain the number of certificates.
+                                 * To be able to get it, the .index file will be read twice... */
   char index_file[_POSIX_PATH_MAX];
   FILE *index;
   char buf[LONG_STRING];
   char fields[5][STRING];
-  int numFields, hash_suffix, done, cur; /* The current entry */
-  MUTTMENUmenu;
+  int numFields, hash_suffix, done, cur;        /* The current entry */
+  MUTTMENU *menu;
   unsigned int hash;
-  char helpstr[HUGE_STRING*3];
+  char helpstr[HUGE_STRING * 3];
   char qry[256];
   char title[256];
 
-  if (!prompt) prompt = _("Enter keyID: ");
-  snprintf(index_file, sizeof (index_file), "%s/.index",
-    public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
-  
-  index = fopen(index_file, "r");
-  if (index == NULL) 
-  {
-    mutt_perror (index_file);      
+  if (!prompt)
+    prompt = _("Enter keyID: ");
+  snprintf (index_file, sizeof (index_file), "%s/.index",
+            public ? NONULL (SmimeCertificates) : NONULL (SmimeKeys));
+
+  index = fopen (index_file, "r");
+  if (index == NULL) {
+    mutt_perror (index_file);
     return NULL;
   }
   /* Count Lines */
   cert_num = 0;
-  while (!feof(index)) {
-    if (fgets(buf, sizeof(buf), index)) cert_num++;
+  while (!feof (index)) {
+    if (fgets (buf, sizeof (buf), index))
+      cert_num++;
   }
-  fclose(index);
+  fclose (index);
 
-  FOREVER
-  {
+  FOREVER {
     *qry = 0;
-    if (mutt_get_field(prompt,
-      qry, sizeof(qry), 0))
+    if (mutt_get_field (prompt, qry, sizeof (qry), 0))
       return NULL;
-    snprintf(title, sizeof(title), _("S/MIME certificates matching \"%s\"."),
-      qry);
+    snprintf (title, sizeof (title),
+              _("S/MIME certificates matching \"%s\"."), qry);
 
-    
-    index = fopen(index_file, "r");
-    if (index == NULL) 
-    {
-      mutt_perror (index_file);      
+
+    index = fopen (index_file, "r");
+    if (index == NULL) {
+      mutt_perror (index_file);
       return NULL;
     }
     /* Read Entries */
     cur = 0;
-    Table = safe_calloc(cert_num, sizeof (smime_id));
-    while (!feof(index)) {
-        numFields = fscanf (index, MUTT_FORMAT(STRING) " %x.%i " MUTT_FORMAT(STRING), fields[0], &hash,
-          &hash_suffix, fields[2]);
-        if (public)
-          fscanf (index, MUTT_FORMAT(STRING) " " MUTT_FORMAT(STRING) "\n", fields[3], fields[4]);
-  
+    Table = safe_calloc (cert_num, sizeof (smime_id));
+    while (!feof (index)) {
+      numFields =
+        fscanf (index, MUTT_FORMAT (STRING) " %x.%i " MUTT_FORMAT (STRING),
+                fields[0], &hash, &hash_suffix, fields[2]);
+      if (public)
+        fscanf (index, MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) "\n",
+                fields[3], fields[4]);
+
       /* 0=email 1=name 2=nick 3=intermediate 4=trust */
-      if (numFields < 2) continue;
-  
+      if (numFields < 2)
+        continue;
+
       /* Check if query matches this certificate */
-      if (!mutt_stristr(fields[0], qry) &&
-          !mutt_stristr(fields[2], qry))
+      if (!mutt_stristr (fields[0], qry) && !mutt_stristr (fields[2], qry))
         continue;
-  
+
       Table[cur].hash = hash;
       Table[cur].suffix = hash_suffix;
-      strncpy(Table[cur].email, fields[0], sizeof(Table[cur].email));
-      strncpy(Table[cur].nick, fields[2], sizeof(Table[cur].nick));
+      strncpy (Table[cur].email, fields[0], sizeof (Table[cur].email));
+      strncpy (Table[cur].nick, fields[2], sizeof (Table[cur].nick));
       Table[cur].trust = *fields[4];
       Table[cur].public = public;
-  
+
       cur++;
     }
-    fclose(index);
-  
+    fclose (index);
+
     /* Make Helpstring */
     helpstr[0] = 0;
     mutt_make_help (buf, sizeof (buf), _("Exit  "), MENU_SMIME, OP_EXIT);
-    strcat (helpstr, buf);     /* __STRCAT_CHECKED__ */
+    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
     mutt_make_help (buf, sizeof (buf), _("Select  "), MENU_SMIME,
-        OP_GENERIC_SELECT_ENTRY);
-    strcat (helpstr, buf);     /* __STRCAT_CHECKED__ */
-    mutt_make_help (buf, sizeof(buf), _("Help"), MENU_SMIME, OP_HELP);
-    strcat (helpstr, buf);     /* __STRCAT_CHECKED__ */
-  
+                    OP_GENERIC_SELECT_ENTRY);
+    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
+    mutt_make_help (buf, sizeof (buf), _("Help"), MENU_SMIME, OP_HELP);
+    strcat (helpstr, buf);      /* __STRCAT_CHECKED__ */
+
     /* Create the menu */
-    menu = mutt_new_menu();
+    menu = mutt_new_menu ();
     menu->max = cur;
     menu->make_entry = smime_entry;
     menu->menu = MENU_SMIME;
@@ -445,57 +441,61 @@ char* smime_ask_for_key (char *prompt, char *mailbox, short public)
     menu->data = Table;
     menu->title = title;
     /* sorting keys might be done later - TODO */
-  
-    mutt_clear_error();
-  
+
+    mutt_clear_error ();
+
     done = 0;
     hash = 0;
     while (!done) {
       switch (mutt_menuLoop (menu)) {
-        case OP_GENERIC_SELECT_ENTRY:
-          cur = menu->current;
-       hash = 1;
-          done = 1;
-          break;
-        case OP_EXIT:
-          hash = 0;
-          done = 1;
-          break;
+      case OP_GENERIC_SELECT_ENTRY:
+        cur = menu->current;
+        hash = 1;
+        done = 1;
+        break;
+      case OP_EXIT:
+        hash = 0;
+        done = 1;
+        break;
       }
     }
     if (hash) {
-      fname = safe_malloc(13); /* Hash + '.' + Suffix + \0 */
-      sprintf(fname, "%.8x.%i", Table[cur].hash, Table[cur].suffix);
+      fname = safe_malloc (13); /* Hash + '.' + Suffix + \0 */
+      sprintf (fname, "%.8x.%i", Table[cur].hash, Table[cur].suffix);
     }
-    else fname = NULL;
-  
+    else
+      fname = NULL;
+
     mutt_menuDestroy (&menu);
     FREE (&Table);
     set_option (OPTNEEDREDRAW);
-  
-    if (fname) return fname;
+
+    if (fname)
+      return fname;
   }
 }
 
 
 
-char *smime_get_field_from_db (char *mailbox, char *query, short public, short may_ask)
+char *smime_get_field_from_db (char *mailbox, char *query, short public,
+                               short may_ask)
 {
   int addr_len, query_len, found = 0, ask = 0, choice = 0;
   char cert_path[_POSIX_PATH_MAX];
   char buf[LONG_STRING], prompt[STRING];
   char fields[5][STRING];
-  char key[STRING];  
+  char key[STRING];
   int numFields;
   struct stat info;
   char key_trust_level = 0;
   FILE *fp;
 
-  if(!mailbox && !query) return(NULL);
+  if (!mailbox && !query)
+    return (NULL);
 
   addr_len = mailbox ? mutt_strlen (mailbox) : 0;
   query_len = query ? mutt_strlen (query) : 0;
-  
+
   *key = '\0';
 
   /* index-file format:
@@ -505,137 +505,122 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, short m
      Note that this was done according to the OpenSSL
      specs on their CA-directory.
 
-  */
+   */
   snprintf (cert_path, sizeof (cert_path), "%s/.index",
-           (public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys)));
+            (public ? NONULL (SmimeCertificates) : NONULL (SmimeKeys)));
 
-  if (!stat (cert_path, &info))
-  {
-    if ((fp = safe_fopen (cert_path, "r")) == NULL)
-    {
+  if (!stat (cert_path, &info)) {
+    if ((fp = safe_fopen (cert_path, "r")) == NULL) {
       mutt_perror (cert_path);
       return (NULL);
     }
 
     while (fgets (buf, sizeof (buf) - 1, fp) != NULL)
-      if (mailbox && !(mutt_strncasecmp (mailbox, buf, addr_len)))
-      {
-       numFields = sscanf (buf, 
-                           MUTT_FORMAT(STRING) " " MUTT_FORMAT(STRING) " " 
-                           MUTT_FORMAT(STRING) " " MUTT_FORMAT(STRING) " " 
-                           MUTT_FORMAT(STRING) "\n", 
-                           fields[0], fields[1],
-                          fields[2], fields[3], 
-                           fields[4]);
-       if (numFields < 2)
-           continue;
-       if (mailbox && public && 
-           (!fields[4] ||
-            *fields[4] == 'i' || *fields[4] == 'e' || *fields[4] == 'r'))
-           continue;
-
-       if (found)
-       {
-         if (public && *fields[4] == 'u' )
-           snprintf (prompt, sizeof (prompt),
-                     _("ID %s is unverified. Do you want to use it for %s ?"),
-                     fields[1], mailbox);
-         else if (public && *fields[4] == 'v' )
-           snprintf (prompt, sizeof (prompt),
-                     _("Use (untrusted!) ID %s for %s ?"),
-                     fields[1], mailbox);
-         else
-           snprintf (prompt, sizeof (prompt), _("Use ID %s for %s ?"),
-                     fields[1], mailbox);
-         if (may_ask == 0)
-           choice = M_YES;
-         if (may_ask && (choice = mutt_yesorno (prompt, M_NO)) == -1)
-         {
-           found = 0;
-           ask = 0;
-           *key = '\0';
-           break;
-         }
-         else if (choice == M_NO) 
-         {
-           ask = 1;
-           continue;
-         }
-         else if (choice == M_YES)
-         {
-           strfcpy (key, fields[1], sizeof (key));
-           ask = 0;
-           break;
-         }
-       }
-       else
-       {
-         if (public) 
-           key_trust_level = *fields[4];
-         strfcpy (key, fields[1], sizeof (key));
-       }
-       found = 1;
+      if (mailbox && !(mutt_strncasecmp (mailbox, buf, addr_len))) {
+        numFields = sscanf (buf,
+                            MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
+                            MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
+                            MUTT_FORMAT (STRING) "\n",
+                            fields[0], fields[1],
+                            fields[2], fields[3], fields[4]);
+        if (numFields < 2)
+          continue;
+        if (mailbox && public &&
+            (!fields[4] ||
+             *fields[4] == 'i' || *fields[4] == 'e' || *fields[4] == 'r'))
+          continue;
+
+        if (found) {
+          if (public && *fields[4] == 'u')
+            snprintf (prompt, sizeof (prompt),
+                      _
+                      ("ID %s is unverified. Do you want to use it for %s ?"),
+                      fields[1], mailbox);
+          else if (public && *fields[4] == 'v')
+            snprintf (prompt, sizeof (prompt),
+                      _("Use (untrusted!) ID %s for %s ?"),
+                      fields[1], mailbox);
+          else
+            snprintf (prompt, sizeof (prompt), _("Use ID %s for %s ?"),
+                      fields[1], mailbox);
+          if (may_ask == 0)
+            choice = M_YES;
+          if (may_ask && (choice = mutt_yesorno (prompt, M_NO)) == -1) {
+            found = 0;
+            ask = 0;
+            *key = '\0';
+            break;
+          }
+          else if (choice == M_NO) {
+            ask = 1;
+            continue;
+          }
+          else if (choice == M_YES) {
+            strfcpy (key, fields[1], sizeof (key));
+            ask = 0;
+            break;
+          }
+        }
+        else {
+          if (public)
+            key_trust_level = *fields[4];
+          strfcpy (key, fields[1], sizeof (key));
+        }
+        found = 1;
       }
-      else if(query)
-      {
-       numFields = sscanf (buf, 
-                           MUTT_FORMAT(STRING) " " MUTT_FORMAT(STRING) " " 
-                           MUTT_FORMAT(STRING) " " MUTT_FORMAT(STRING) " " 
-                           MUTT_FORMAT(STRING) "\n", 
-                           fields[0], fields[1],
-                           fields[2], fields[3], 
-                           fields[4]);
-
-       /* query = label: return certificate. */
-       if (numFields >= 3 && 
-           !(mutt_strncasecmp (query, fields[2], query_len)))
-       {
-         ask = 0;
-         strfcpy (key, fields[1], sizeof (key));
-       }
-       /* query = certificate: return intermediate certificate. */
-       else if (numFields >= 4 && 
-                !(mutt_strncasecmp (query, fields[1], query_len)))
-       {
-         ask = 0;
-         strfcpy (key, fields[3], sizeof (key));
-       }
+      else if (query) {
+        numFields = sscanf (buf,
+                            MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
+                            MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " "
+                            MUTT_FORMAT (STRING) "\n",
+                            fields[0], fields[1],
+                            fields[2], fields[3], fields[4]);
+
+        /* query = label: return certificate. */
+        if (numFields >= 3 &&
+            !(mutt_strncasecmp (query, fields[2], query_len))) {
+          ask = 0;
+          strfcpy (key, fields[1], sizeof (key));
+        }
+        /* query = certificate: return intermediate certificate. */
+        else if (numFields >= 4 &&
+                 !(mutt_strncasecmp (query, fields[1], query_len))) {
+          ask = 0;
+          strfcpy (key, fields[3], sizeof (key));
+        }
       }
 
     safe_fclose (&fp);
 
-    if (ask)
-    {
-      if (public && *fields[4] == 'u' )
-       snprintf (prompt, sizeof (prompt),
-                 _("ID %s is unverified. Do you want to use it for %s ?"),
-                 fields[1], mailbox);
-      else if (public && *fields[4] == 'v' )
-       snprintf (prompt, sizeof (prompt),
-                 _("Use (untrusted!) ID %s for %s ?"),
-                 fields[1], mailbox);
+    if (ask) {
+      if (public && *fields[4] == 'u')
+        snprintf (prompt, sizeof (prompt),
+                  _("ID %s is unverified. Do you want to use it for %s ?"),
+                  fields[1], mailbox);
+      else if (public && *fields[4] == 'v')
+        snprintf (prompt, sizeof (prompt),
+                  _("Use (untrusted!) ID %s for %s ?"), fields[1], mailbox);
       else
-       snprintf (prompt, sizeof(prompt), _("Use ID %s for %s ?"), key,
-                 mailbox);
+        snprintf (prompt, sizeof (prompt), _("Use ID %s for %s ?"), key,
+                  mailbox);
       choice = mutt_yesorno (prompt, M_NO);
       if (choice == -1 || choice == M_NO)
-       *key = '\0';
+        *key = '\0';
     }
-    else if (key_trust_level && may_ask)
-    {
-      if (key_trust_level == 'u' )
-      {
-       snprintf (prompt, sizeof (prompt),
-                 _("ID %s is unverified. Do you want to use it for %s ?"),
-                 key, mailbox);
-       choice = mutt_yesorno (prompt, M_NO);
-       if (choice != M_YES)
-         *key = '\0';
+    else if (key_trust_level && may_ask) {
+      if (key_trust_level == 'u') {
+        snprintf (prompt, sizeof (prompt),
+                  _("ID %s is unverified. Do you want to use it for %s ?"),
+                  key, mailbox);
+        choice = mutt_yesorno (prompt, M_NO);
+        if (choice != M_YES)
+          *key = '\0';
       }
-      else if (key_trust_level == 'v' )
-      {
-       mutt_error (_("Warning: You have not yet decided to trust ID %s. (any key to continue)"), key);
-       mutt_sleep (5);
+      else if (key_trust_level == 'v') {
+        mutt_error (_
+                    ("Warning: You have not yet decided to trust ID %s. (any key to continue)"),
+                    key);
+        mutt_sleep (5);
       }
     }
 
@@ -660,29 +645,26 @@ void _smime_getkeys (char *mailbox)
 
   k = smime_get_field_from_db (mailbox, NULL, 0, 1);
 
-  if (!k)
-  {
-    snprintf(buf, sizeof(buf), _("Enter keyID for %s: "),
-            mailbox);
-    k = smime_ask_for_key(buf, mailbox, 0);
+  if (!k) {
+    snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), mailbox);
+    k = smime_ask_for_key (buf, mailbox, 0);
   }
 
-  if (k)
-  {
+  if (k) {
     /* the key used last time. */
-    if (*SmimeKeyToUse && 
-        !mutt_strcasecmp (k, SmimeKeyToUse + mutt_strlen (SmimeKeys)+1))
-    {
+    if (*SmimeKeyToUse &&
+        !mutt_strcasecmp (k, SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1)) {
       FREE (&k);
       return;
     }
-    else smime_void_passphrase ();
+    else
+      smime_void_passphrase ();
+
+    snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
+              NONULL (SmimeKeys), k);
 
-    snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s", 
-             NONULL(SmimeKeys), k);
-    
     snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
-             NONULL(SmimeCertificates), k);
+              NONULL (SmimeCertificates), k);
 
     if (mutt_strcasecmp (k, SmimeDefaultKey))
       smime_void_passphrase ();
@@ -691,52 +673,47 @@ void _smime_getkeys (char *mailbox)
     return;
   }
 
-  if (*SmimeKeyToUse)
-  {
-    if (!mutt_strcasecmp (SmimeDefaultKey, 
-                          SmimeKeyToUse + mutt_strlen (SmimeKeys)+1))
+  if (*SmimeKeyToUse) {
+    if (!mutt_strcasecmp (SmimeDefaultKey,
+                          SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1))
       return;
 
     smime_void_passphrase ();
   }
 
-  snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s", 
-           NONULL (SmimeKeys), NONULL (SmimeDefaultKey));
-  
+  snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
+            NONULL (SmimeKeys), NONULL (SmimeDefaultKey));
+
   snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
-           NONULL (SmimeCertificates), NONULL (SmimeDefaultKey));
+            NONULL (SmimeCertificates), NONULL (SmimeDefaultKey));
 }
 
-void smime_getkeys (ENVELOPE *env)
+void smime_getkeys (ENVELOPE * env)
 {
   ADDRESS *t;
   int found = 0;
 
-  if (option (OPTSDEFAULTDECRYPTKEY) && SmimeDefaultKey && *SmimeDefaultKey)
-  {
-    snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s", 
-             NONULL (SmimeKeys), SmimeDefaultKey);
-    
+  if (option (OPTSDEFAULTDECRYPTKEY) && SmimeDefaultKey && *SmimeDefaultKey) {
+    snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
+              NONULL (SmimeKeys), SmimeDefaultKey);
+
     snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
-             NONULL(SmimeCertificates), SmimeDefaultKey);
+              NONULL (SmimeCertificates), SmimeDefaultKey);
 
     return;
   }
 
   for (t = env->to; !found && t; t = t->next)
-    if (mutt_addr_is_user (t))
-    {
+    if (mutt_addr_is_user (t)) {
       found = 1;
       _smime_getkeys (t->mailbox);
     }
   for (t = env->cc; !found && t; t = t->next)
-    if (mutt_addr_is_user (t))
-    {
+    if (mutt_addr_is_user (t)) {
       found = 1;
       _smime_getkeys (t->mailbox);
     }
-  if (!found && (t = mutt_default_from()))
-  {
+  if (!found && (t = mutt_default_from ())) {
     _smime_getkeys (t->mailbox);
     rfc822_free_address (&t);
   }
@@ -746,7 +723,7 @@ void smime_getkeys (ENVELOPE *env)
  * It returns NULL if any of the keys can not be found.
  */
 
-char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+char *smime_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
 {
   char *keyID, *keylist = NULL;
   size_t keylist_size = 0;
@@ -757,17 +734,22 @@ char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
   int i;
 
   const char *fqdn = mutt_fqdn (1);
-  
-  for (i = 0; i < 3; i++)
-  {
-    switch (i)
-    {
-      case 0: p = to; break;
-      case 1: p = cc; break;
-      case 2: p = bcc; break;
-      default: abort ();
+
+  for (i = 0; i < 3; i++) {
+    switch (i) {
+    case 0:
+      p = to;
+      break;
+    case 1:
+      p = cc;
+      break;
+    case 2:
+      p = bcc;
+      break;
+    default:
+      abort ();
     }
-    
+
     *last = rfc822_cpy_adr (p);
     while (*last)
       last = &((*last)->next);
@@ -777,32 +759,27 @@ char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
     rfc822_qualify (tmp, fqdn);
 
   tmp = mutt_remove_duplicates (tmp);
-  
-  for (p = tmp; p ; p = p->next)
-  {
+
+  for (p = tmp; p; p = p->next) {
     char buf[LONG_STRING];
 
     q = p;
 
-    if ((keyID = smime_get_field_from_db (q->mailbox, NULL, 1, 1)) == NULL)
-    {
-      snprintf(buf, sizeof(buf),
-              _("Enter keyID for %s: "),
-              q->mailbox);
-      keyID = smime_ask_for_key(buf, q->mailbox, 1);
+    if ((keyID = smime_get_field_from_db (q->mailbox, NULL, 1, 1)) == NULL) {
+      snprintf (buf, sizeof (buf), _("Enter keyID for %s: "), q->mailbox);
+      keyID = smime_ask_for_key (buf, q->mailbox, 1);
     }
-    if(!keyID)
-    {
+    if (!keyID) {
       mutt_message (_("No (valid) certificate found for %s."), q->mailbox);
       FREE (&keylist);
       rfc822_free_address (&tmp);
       rfc822_free_address (&addr);
       return NULL;
     }
-    
+
     keylist_size += mutt_strlen (keyID) + 2;
     safe_realloc (&keylist, keylist_size);
-    sprintf (keylist + keylist_used, "%s\n", keyID);   /* __SPRINTF_CHECKED__ */
+    sprintf (keylist + keylist_used, "%s\n", keyID);    /* __SPRINTF_CHECKED__ */
     keylist_used = mutt_strlen (keylist);
 
     rfc822_free_address (&addr);
@@ -818,7 +795,7 @@ char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 
 
 static int smime_handle_cert_email (char *certificate, char *mailbox,
-                                  int copy, char ***buffer, int *num)
+                                    int copy, char ***buffer, int *num)
 {
   FILE *fpout = NULL, *fperr = NULL;
   char tmpfname[_POSIX_PATH_MAX];
@@ -827,27 +804,24 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
   pid_t thepid;
 
   mutt_mktemp (tmpfname);
-  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL) {
     mutt_perror (tmpfname);
     return 1;
   }
   mutt_unlink (tmpfname);
 
   mutt_mktemp (tmpfname);
-  if ((fpout = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (tmpfname, "w+")) == NULL) {
     fclose (fperr);
     mutt_perror (tmpfname);
     return 1;
   }
   mutt_unlink (tmpfname);
 
-  if ((thepid =  smime_invoke (NULL, NULL, NULL,
-                              -1, fileno (fpout), fileno (fperr),
-                              certificate, NULL, NULL, NULL, NULL, NULL,
-                              SmimeGetCertEmailCommand))== -1)
-  {
+  if ((thepid = smime_invoke (NULL, NULL, NULL,
+                              -1, fileno (fpout), fileno (fperr),
+                              certificate, NULL, NULL, NULL, NULL, NULL,
+                              SmimeGetCertEmailCommand)) == -1) {
     mutt_message (_("Error: unable to create OpenSSL subprocess!"));
     fclose (fperr);
     fclose (fpout);
@@ -862,43 +836,42 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
   fflush (fperr);
 
 
-  while ((fgets (email, sizeof (email), fpout)))
-  {
-    *(email + mutt_strlen (email)-1) = '\0';
-    if(mutt_strncasecmp (email, mailbox, mutt_strlen (mailbox)) == 0)
-      ret=1;
+  while ((fgets (email, sizeof (email), fpout))) {
+    *(email + mutt_strlen (email) - 1) = '\0';
+    if (mutt_strncasecmp (email, mailbox, mutt_strlen (mailbox)) == 0)
+      ret = 1;
 
     ret = ret < 0 ? 0 : ret;
     count++;
   }
 
-  if (ret == -1)
-  {
-    mutt_endwin(NULL);
+  if (ret == -1) {
+    mutt_endwin (NULL);
     mutt_copy_stream (fperr, stdout);
-    mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
+    mutt_any_key_to_continue (_
+                              ("Error: unable to create OpenSSL subprocess!"));
     ret = 1;
   }
   else if (!ret)
     ret = 1;
-  else ret = 0;
+  else
+    ret = 0;
 
-  if(copy && buffer && num)
-  {
+  if (copy && buffer && num) {
     (*num) = count;
-    *buffer =  safe_calloc(sizeof(char*), count);
+    *buffer = safe_calloc (sizeof (char *), count);
     count = 0;
 
     rewind (fpout);
-    while ((fgets (email, sizeof (email), fpout)))
-    {
+    while ((fgets (email, sizeof (email), fpout))) {
       *(email + mutt_strlen (email) - 1) = '\0';
-      (*buffer)[count] = safe_calloc(1, mutt_strlen (email) + 1);
-      strncpy((*buffer)[count], email, mutt_strlen (email));
+      (*buffer)[count] = safe_calloc (1, mutt_strlen (email) + 1);
+      strncpy ((*buffer)[count], email, mutt_strlen (email));
       count++;
     }
   }
-  else if(copy) ret = 2;
+  else if (copy)
+    ret = 2;
 
   fclose (fpout);
   fclose (fperr);
@@ -918,16 +891,14 @@ static char *smime_extract_certificate (char *infile)
 
 
   mutt_mktemp (tmpfname);
-  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL) {
     mutt_perror (tmpfname);
     return NULL;
   }
   mutt_unlink (tmpfname);
 
   mutt_mktemp (pk7out);
-  if ((fpout = safe_fopen (pk7out, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (pk7out, "w+")) == NULL) {
     fclose (fperr);
     mutt_perror (pk7out);
     return NULL;
@@ -935,13 +906,13 @@ static char *smime_extract_certificate (char *infile)
 
   /* Step 1: Convert the signature to a PKCS#7 structure, as we can't
      extract the full set of certificates directly.
-  */
-  if ((thepid =  smime_invoke (NULL, NULL, NULL,
-                              -1, fileno (fpout), fileno (fperr),
-                              infile, NULL, NULL, NULL, NULL, NULL,
-                              SmimePk7outCommand))== -1)
-  {
-    mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
+   */
+  if ((thepid = smime_invoke (NULL, NULL, NULL,
+                              -1, fileno (fpout), fileno (fperr),
+                              infile, NULL, NULL, NULL, NULL, NULL,
+                              SmimePk7outCommand)) == -1) {
+    mutt_any_key_to_continue (_
+                              ("Error: unable to create OpenSSL subprocess!"));
     fclose (fperr);
     fclose (fpout);
     mutt_unlink (pk7out);
@@ -956,36 +927,34 @@ static char *smime_extract_certificate (char *infile)
   rewind (fperr);
   fflush (fperr);
   empty = (fgetc (fpout) == EOF);
-  if (empty)
-  {
+  if (empty) {
     mutt_perror (pk7out);
     mutt_copy_stream (fperr, stdout);
     fclose (fpout);
     fclose (fperr);
     mutt_unlink (pk7out);
     return NULL;
-    
+
   }
 
 
   fclose (fpout);
   mutt_mktemp (certfile);
-  if ((fpout = safe_fopen (certfile, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (certfile, "w+")) == NULL) {
     fclose (fperr);
     mutt_unlink (pk7out);
     mutt_perror (certfile);
     return NULL;
   }
-  
+
   /* Step 2: Extract the certificates from a PKCS#7 structure.
    */
-  if ((thepid =  smime_invoke (NULL, NULL, NULL,
-                              -1, fileno (fpout), fileno (fperr),
-                              pk7out, NULL, NULL, NULL, NULL, NULL,
-                              SmimeGetCertCommand))== -1)
-  {
-    mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
+  if ((thepid = smime_invoke (NULL, NULL, NULL,
+                              -1, fileno (fpout), fileno (fperr),
+                              pk7out, NULL, NULL, NULL, NULL, NULL,
+                              SmimeGetCertCommand)) == -1) {
+    mutt_any_key_to_continue (_
+                              ("Error: unable to create OpenSSL subprocess!"));
     fclose (fperr);
     fclose (fpout);
     mutt_unlink (pk7out);
@@ -1001,9 +970,8 @@ static char *smime_extract_certificate (char *infile)
   rewind (fpout);
   rewind (fperr);
   fflush (fperr);
-  empty =  (fgetc (fpout) == EOF);
-  if (empty)
-  {
+  empty = (fgetc (fpout) == EOF);
+  if (empty) {
     mutt_copy_stream (fperr, stdout);
     fclose (fpout);
     fclose (fperr);
@@ -1027,8 +995,7 @@ static char *smime_extract_signer_certificate (char *infile)
 
 
   mutt_mktemp (tmpfname);
-  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL) {
     mutt_perror (tmpfname);
     return NULL;
   }
@@ -1036,21 +1003,20 @@ static char *smime_extract_signer_certificate (char *infile)
 
 
   mutt_mktemp (certfile);
-  if ((fpout = safe_fopen (certfile, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (certfile, "w+")) == NULL) {
     fclose (fperr);
     mutt_perror (certfile);
     return NULL;
   }
-  
+
   /* Extract signer's certificate
    */
-  if ((thepid =  smime_invoke (NULL, NULL, NULL,
-                              -1, -1, fileno (fperr),
-                              infile, NULL, NULL, NULL, certfile, NULL,
-                              SmimeGetSignerCertCommand))== -1)
-  {
-    mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
+  if ((thepid = smime_invoke (NULL, NULL, NULL,
+                              -1, -1, fileno (fperr),
+                              infile, NULL, NULL, NULL, certfile, NULL,
+                              SmimeGetSignerCertCommand)) == -1) {
+    mutt_any_key_to_continue (_
+                              ("Error: unable to create OpenSSL subprocess!"));
     fclose (fperr);
     fclose (fpout);
     mutt_unlink (pk7out);
@@ -1064,9 +1030,8 @@ static char *smime_extract_signer_certificate (char *infile)
   rewind (fpout);
   rewind (fperr);
   fflush (fperr);
-  empty =  (fgetc (fpout) == EOF);
-  if (empty)
-  {
+  empty = (fgetc (fpout) == EOF);
+  if (empty) {
     mutt_endwin (NULL);
     mutt_copy_stream (fperr, stdout);
     mutt_any_key_to_continue (NULL);
@@ -1090,20 +1055,18 @@ static char *smime_extract_signer_certificate (char *infile)
 void smime_invoke_import (char *infile, char *mailbox)
 {
   char tmpfname[_POSIX_PATH_MAX], *certfile = NULL, buf[STRING];
-  FILE *smimein=NULL, *fpout = NULL, *fperr = NULL;
-  pid_t thepid=-1;
+  FILE *smimein = NULL, *fpout = NULL, *fperr = NULL;
+  pid_t thepid = -1;
 
   mutt_mktemp (tmpfname);
-  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fperr = safe_fopen (tmpfname, "w+")) == NULL) {
     mutt_perror (tmpfname);
     return;
   }
   mutt_unlink (tmpfname);
 
   mutt_mktemp (tmpfname);
-  if ((fpout = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (tmpfname, "w+")) == NULL) {
     fclose (fperr);
     mutt_perror (tmpfname);
     return;
@@ -1116,24 +1079,22 @@ void smime_invoke_import (char *infile, char *mailbox)
     mutt_get_field ("Label for certificate:", buf, sizeof (buf), 0);
 
   mutt_endwin (NULL);
-  if ((certfile = smime_extract_certificate(infile)))
-  {
+  if ((certfile = smime_extract_certificate (infile))) {
     mutt_endwin (NULL);
-  
-    if ((thepid =  smime_invoke (&smimein, NULL, NULL,
-                                -1, fileno(fpout), fileno(fperr),
-                                certfile, NULL, NULL, NULL, NULL, NULL,
-                                SmimeImportCertCommand))== -1)
-    {
+
+    if ((thepid = smime_invoke (&smimein, NULL, NULL,
+                                -1, fileno (fpout), fileno (fperr),
+                                certfile, NULL, NULL, NULL, NULL, NULL,
+                                SmimeImportCertCommand)) == -1) {
       mutt_message (_("Error: unable to create OpenSSL subprocess!"));
       return;
     }
     fputs (buf, smimein);
     fputc ('\n', smimein);
-    fclose(smimein);
+    fclose (smimein);
 
     mutt_wait_filter (thepid);
-  
+
     mutt_unlink (certfile);
     FREE (&certfile);
   }
@@ -1153,62 +1114,56 @@ void smime_invoke_import (char *infile, char *mailbox)
 
 
 
-int smime_verify_sender(HEADER *h)
+int smime_verify_sender (HEADER * h)
 {
   char *mbox = NULL, *certfile, tempfname[_POSIX_PATH_MAX];
   FILE *fpout;
-  int retval=1;
+  int retval = 1;
 
   mutt_mktemp (tempfname);
-  if (!(fpout = safe_fopen (tempfname, "w")))
-  {
+  if (!(fpout = safe_fopen (tempfname, "w"))) {
     mutt_perror (tempfname);
     return 1;
   }
 
-  if(h->security & ENCRYPT)
+  if (h->security & ENCRYPT)
     mutt_copy_message (fpout, Context, h,
-                      M_CM_DECODE_CRYPT & M_CM_DECODE_SMIME,
-                      CH_MIME|CH_WEED|CH_NONEWLINE);
+                       M_CM_DECODE_CRYPT & M_CM_DECODE_SMIME,
+                       CH_MIME | CH_WEED | CH_NONEWLINE);
   else
     mutt_copy_message (fpout, Context, h, 0, 0);
 
-  fflush(fpout);
+  fflush (fpout);
   fclose (fpout);
 
-  if (h->env->from)
-  {
-    h->env->from = mutt_expand_aliases (h->env->from); 
-    mbox = h->env->from->mailbox; 
+  if (h->env->from) {
+    h->env->from = mutt_expand_aliases (h->env->from);
+    mbox = h->env->from->mailbox;
   }
-  else if (h->env->sender)
-  {
-    h->env->sender = mutt_expand_aliases (h->env->sender); 
-    mbox = h->env->sender->mailbox; 
+  else if (h->env->sender) {
+    h->env->sender = mutt_expand_aliases (h->env->sender);
+    mbox = h->env->sender->mailbox;
   }
 
-  if (mbox)
-  {
-    if ((certfile = smime_extract_signer_certificate(tempfname)))
-    {
-      mutt_unlink(tempfname);
-      if (smime_handle_cert_email (certfile, mbox, 0, NULL, NULL))
-      {
-       if(isendwin())
-         mutt_any_key_to_continue(NULL);
+  if (mbox) {
+    if ((certfile = smime_extract_signer_certificate (tempfname))) {
+      mutt_unlink (tempfname);
+      if (smime_handle_cert_email (certfile, mbox, 0, NULL, NULL)) {
+        if (isendwin ())
+          mutt_any_key_to_continue (NULL);
       }
       else
-       retval = 0;
-      mutt_unlink(certfile);
+        retval = 0;
+      mutt_unlink (certfile);
       FREE (&certfile);
     }
-  else 
-       mutt_any_key_to_continue(_("no certfile"));
+    else
+      mutt_any_key_to_continue (_("no certfile"));
   }
-  else 
-       mutt_any_key_to_continue(_("no mbox"));
+  else
+    mutt_any_key_to_continue (_("no mbox"));
 
-  mutt_unlink(tempfname);
+  mutt_unlink (tempfname);
   return retval;
 }
 
@@ -1228,32 +1183,33 @@ int smime_verify_sender(HEADER *h)
 
 
 static
-pid_t smime_invoke_encrypt (FILE **smimein, FILE **smimeout, FILE **smimeerr,
-                           int smimeinfd, int smimeoutfd, int smimeerrfd,
-                           const char *fname, const char *uids)
+pid_t smime_invoke_encrypt (FILE ** smimein, FILE ** smimeout,
+                            FILE ** smimeerr, int smimeinfd, int smimeoutfd,
+                            int smimeerrfd, const char *fname,
+                            const char *uids)
 {
   return smime_invoke (smimein, smimeout, smimeerr,
-                      smimeinfd, smimeoutfd, smimeerrfd,
-                      fname, NULL, SmimeCryptAlg, NULL, uids, NULL,
-                      SmimeEncryptCommand);
+                       smimeinfd, smimeoutfd, smimeerrfd,
+                       fname, NULL, SmimeCryptAlg, NULL, uids, NULL,
+                       SmimeEncryptCommand);
 }
 
 
 static
-pid_t smime_invoke_sign (FILE **smimein, FILE **smimeout, FILE **smimeerr,
-                        int smimeinfd, int smimeoutfd, int smimeerrfd, 
-                        const char *fname)
+pid_t smime_invoke_sign (FILE ** smimein, FILE ** smimeout, FILE ** smimeerr,
+                         int smimeinfd, int smimeoutfd, int smimeerrfd,
+                         const char *fname)
 {
   return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
-                      smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
-                      SmimeCertToUse, SmimeIntermediateToUse,
-                      SmimeSignCommand);
+                       smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
+                       SmimeCertToUse, SmimeIntermediateToUse,
+                       SmimeSignCommand);
 }
 
 
 
 
-BODY *smime_build_smime_entity (BODY *a, char *certlist)
+BODY *smime_build_smime_entity (BODY * a, char *certlist)
 {
   char buf[LONG_STRING], certfile[LONG_STRING];
   char tempfile[_POSIX_PATH_MAX], smimeerrfile[_POSIX_PATH_MAX];
@@ -1263,27 +1219,24 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
   BODY *t;
   int err = 0, empty;
   pid_t thepid;
-  
+
   mutt_mktemp (tempfile);
-  if ((fpout = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((fpout = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     return (NULL);
   }
 
   mutt_mktemp (smimeerrfile);
-  if ((smimeerr = safe_fopen (smimeerrfile, "w+")) == NULL)
-  {
+  if ((smimeerr = safe_fopen (smimeerrfile, "w+")) == NULL) {
     mutt_perror (smimeerrfile);
     fclose (fpout);
     mutt_unlink (tempfile);
     return NULL;
   }
   mutt_unlink (smimeerrfile);
-  
+
   mutt_mktemp (smimeinfile);
-  if ((fptmp = safe_fopen (smimeinfile, "w+")) == NULL)
-  {
+  if ((fptmp = safe_fopen (smimeinfile, "w+")) == NULL) {
     mutt_perror (smimeinfile);
     mutt_unlink (tempfile);
     fclose (fpout);
@@ -1292,14 +1245,15 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
   }
 
   *certfile = '\0';
-  while (1)
-  {
+  while (1) {
     int off = mutt_strlen (certfile);
+
     while (*++cert_end && *cert_end != '\n');
-    if (!*cert_end) break;
+    if (!*cert_end)
+      break;
     *cert_end = '\0';
-    snprintf (certfile+off, sizeof (certfile)-off, " %s/%s",
-             NONULL(SmimeCertificates), cert_start);
+    snprintf (certfile + off, sizeof (certfile) - off, " %s/%s",
+              NONULL (SmimeCertificates), cert_start);
     *cert_end = '\n';
     cert_start = cert_end;
     cert_start++;
@@ -1313,9 +1267,8 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
 
   if ((thepid =
        smime_invoke_encrypt (&smimein, NULL, NULL, -1,
-                            fileno (fpout), fileno (smimeerr),
-                            smimeinfile, certfile)) == -1)
-  {
+                             fileno (fpout), fileno (smimeerr),
+                             smimeinfile, certfile)) == -1) {
     fclose (smimeerr);
     mutt_unlink (smimeinfile);
     mutt_unlink (certfile);
@@ -1323,20 +1276,19 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
   }
 
   fclose (smimein);
-  
+
   mutt_wait_filter (thepid);
   mutt_unlink (smimeinfile);
   mutt_unlink (certfile);
-  
+
   fflush (fpout);
   rewind (fpout);
   empty = (fgetc (fpout) == EOF);
   fclose (fpout);
+
   fflush (smimeerr);
   rewind (smimeerr);
-  while (fgets (buf, sizeof (buf) - 1, smimeerr) != NULL)
-  {
+  while (fgets (buf, sizeof (buf) - 1, smimeerr) != NULL) {
     err = 1;
     fputs (buf, stdout);
   }
@@ -1346,10 +1298,11 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
   if (err)
     mutt_any_key_to_continue (NULL);
 
-  if (empty)
-  {
+  if (empty) {
     /* fatal error while trying to encrypt message */
-    if (!err) mutt_any_key_to_continue _("No output from OpenSSL..");
+    if (!err)
+      mutt_any_key_to_continue _("No output from OpenSSL..");
+
     mutt_unlink (tempfile);
     return (NULL);
   }
@@ -1359,22 +1312,22 @@ BODY *smime_build_smime_entity (BODY *a, char *certlist)
   t->subtype = safe_strdup ("x-pkcs7-mime");
   mutt_set_parameter ("name", "smime.p7m", &t->parameter);
   mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
-  t->encoding = ENCBASE64;  /* The output of OpenSSL SHOULD be binary */
+  t->encoding = ENCBASE64;      /* The output of OpenSSL SHOULD be binary */
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   t->d_filename = safe_strdup ("smime.p7m");
   t->filename = safe_strdup (tempfile);
-  t->unlink = 1; /*delete after sending the message */
-  t->parts=0;
-  t->next=0;
-  
+  t->unlink = 1;                /*delete after sending the message */
+  t->parts = 0;
+  t->next = 0;
+
   return (t);
 }
 
 
 
 
-BODY *smime_sign_message (BODY *)
+BODY *smime_sign_message (BODY * a)
 {
   BODY *t;
   char buffer[LONG_STRING];
@@ -1383,54 +1336,52 @@ BODY *smime_sign_message (BODY *a )
   int err = 0;
   int empty = 0;
   pid_t thepid;
-  char *intermediates = smime_get_field_from_db(NULL, SmimeDefaultKey, 1, 1);
+  char *intermediates = smime_get_field_from_db (NULL, SmimeDefaultKey, 1, 1);
 
-  if (!intermediates)
-  {
-    mutt_message(_("Warning: Intermediate certificate not found."));
-    intermediates = SmimeDefaultKey; /* so openssl won't complain in any case */
+  if (!intermediates) {
+    mutt_message (_("Warning: Intermediate certificate not found."));
+    intermediates = SmimeDefaultKey;    /* so openssl won't complain in any case */
   }
 
-  convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
+  convert_to_7bit (a);          /* Signed data _must_ be in 7-bit format. */
 
   mutt_mktemp (filetosign);
-  if ((sfp = safe_fopen (filetosign, "w+")) == NULL)
-  {
+  if ((sfp = safe_fopen (filetosign, "w+")) == NULL) {
     mutt_perror (filetosign);
     return NULL;
   }
 
   mutt_mktemp (signedfile);
-  if ((smimeout = safe_fopen (signedfile, "w+")) == NULL)
-  {
+  if ((smimeout = safe_fopen (signedfile, "w+")) == NULL) {
     mutt_perror (signedfile);
     fclose (sfp);
     mutt_unlink (filetosign);
     return NULL;
   }
-  
+
   mutt_write_mime_header (a, sfp);
   fputc ('\n', sfp);
   mutt_write_mime_body (a, sfp);
   fclose (sfp);
 
-  
 
-  snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s", 
-          NONULL(SmimeKeys), SmimeDefaultKey);
+
+  snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
+            NONULL (SmimeKeys), SmimeDefaultKey);
 
   snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
-          NONULL(SmimeCertificates), SmimeDefaultKey);
-  
+            NONULL (SmimeCertificates), SmimeDefaultKey);
+
   snprintf (SmimeIntermediateToUse, sizeof (SmimeIntermediateToUse), "%s/%s",
-          NONULL(SmimeCertificates), intermediates);
-  
+            NONULL (SmimeCertificates), intermediates);
+
 
 
   if ((thepid = smime_invoke_sign (&smimein, NULL, &smimeerr,
-                                -1, fileno (smimeout), -1, filetosign)) == -1)
-  {
+                                   -1, fileno (smimeout), -1,
+                                   filetosign)) == -1) {
     mutt_perror _("Can't open OpenSSL subprocess!");
+
     fclose (smimeout);
     mutt_unlink (signedfile);
     mutt_unlink (filetosign);
@@ -1439,7 +1390,7 @@ BODY *smime_sign_message (BODY *a )
   fputs (SmimePass, smimein);
   fputc ('\n', smimein);
   fclose (smimein);
-  
+
 
   mutt_wait_filter (thepid);
 
@@ -1447,8 +1398,7 @@ BODY *smime_sign_message (BODY *a )
   err = 0;
   fflush (smimeerr);
   rewind (smimeerr);
-  while (fgets (buffer, sizeof (buffer) - 1, smimeerr) != NULL)
-  {
+  while (fgets (buffer, sizeof (buffer) - 1, smimeerr) != NULL) {
     err = 1;
     fputs (buffer, stdout);
   }
@@ -1461,16 +1411,16 @@ BODY *smime_sign_message (BODY *a )
   fclose (smimeout);
 
   mutt_unlink (filetosign);
-  
+
 
   if (err)
     mutt_any_key_to_continue (NULL);
 
-  if (empty)
-  {
+  if (empty) {
     mutt_any_key_to_continue _("No output from OpenSSL...");
+
     mutt_unlink (signedfile);
-    return (NULL); /* fatal error while signing */
+    return (NULL);              /* fatal error while signing */
   }
 
   t = mutt_new_body ();
@@ -1484,7 +1434,7 @@ BODY *smime_sign_message (BODY *a )
   /* check if this can be extracted from private key somehow.... */
   mutt_set_parameter ("micalg", "sha1", &t->parameter);
   mutt_set_parameter ("protocol", "application/x-pkcs7-signature",
-                    &t->parameter);
+                      &t->parameter);
 
   t->parts = a;
   a = t;
@@ -1498,7 +1448,7 @@ BODY *smime_sign_message (BODY *a )
   t->use_disp = 1;
   t->disposition = DISPATTACH;
   t->encoding = ENCBASE64;
-  t->unlink = 1; /* ok to remove this file after sending. */
+  t->unlink = 1;                /* ok to remove this file after sending. */
 
   return (a);
 
@@ -1519,32 +1469,34 @@ BODY *smime_sign_message (BODY *a )
 
 
 static
-pid_t smime_invoke_verify (FILE **smimein, FILE **smimeout, FILE **smimeerr,
-                          int smimeinfd, int smimeoutfd, int smimeerrfd, 
-                          const char *fname, const char *sig_fname, int opaque)
+pid_t smime_invoke_verify (FILE ** smimein, FILE ** smimeout,
+                           FILE ** smimeerr, int smimeinfd, int smimeoutfd,
+                           int smimeerrfd, const char *fname,
+                           const char *sig_fname, int opaque)
 {
   return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
-                      smimeerrfd, fname, sig_fname, NULL, NULL, NULL, NULL,
-                      (opaque ? SmimeVerifyOpaqueCommand : SmimeVerifyCommand));
+                       smimeerrfd, fname, sig_fname, NULL, NULL, NULL, NULL,
+                       (opaque ? SmimeVerifyOpaqueCommand :
+                        SmimeVerifyCommand));
 }
 
 
 static
-pid_t smime_invoke_decrypt (FILE **smimein, FILE **smimeout, FILE **smimeerr,
-                           int smimeinfd, int smimeoutfd, int smimeerrfd, 
-                           const char *fname)
+pid_t smime_invoke_decrypt (FILE ** smimein, FILE ** smimeout,
+                            FILE ** smimeerr, int smimeinfd, int smimeoutfd,
+                            int smimeerrfd, const char *fname)
 {
   return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
-                      smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
-                      SmimeCertToUse, NULL, SmimeDecryptCommand);
+                       smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
+                       SmimeCertToUse, NULL, SmimeDecryptCommand);
 }
 
 
 
-int smime_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
+int smime_verify_one (BODY * sigbdy, STATE * s, const char *tempfile)
 {
   char signedfile[_POSIX_PATH_MAX], smimeerrfile[_POSIX_PATH_MAX];
-  FILE *fp=NULL, *smimeout=NULL, *smimeerr=NULL;
+  FILE *fp = NULL, *smimeout = NULL, *smimeerr = NULL;
   pid_t thepid;
   int badsig = -1;
 
@@ -1555,11 +1507,10 @@ int smime_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
 
 
   snprintf (signedfile, sizeof (signedfile), "%s.sig", tempfile);
-  
+
   /* decode to a tempfile, saving the original destination */
   fp = s->fpout;
-  if ((s->fpout = safe_fopen (signedfile, "w")) == NULL)
-  {
+  if ((s->fpout = safe_fopen (signedfile, "w")) == NULL) {
     mutt_perror (signedfile);
     return -1;
   }
@@ -1588,63 +1539,60 @@ int smime_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
 
   /* restore the prefix */
   s->prefix = savePrefix;
-  
+
   sigbdy->type = origType;
 
-  
+
   mutt_mktemp (smimeerrfile);
-  if (!(smimeerr = safe_fopen (smimeerrfile, "w+")))
-  {
+  if (!(smimeerr = safe_fopen (smimeerrfile, "w+"))) {
     mutt_perror (smimeerrfile);
     mutt_unlink (signedfile);
     return -1;
   }
-  
+
   crypt_current_time (s, "OpenSSL");
-  
-  if ((thepid = smime_invoke_verify (NULL, &smimeout, NULL, 
-                                  -1, -1, fileno (smimeerr),
-                                  tempfile, signedfile, 0)) != -1)
-  {
+
+  if ((thepid = smime_invoke_verify (NULL, &smimeout, NULL,
+                                     -1, -1, fileno (smimeerr),
+                                     tempfile, signedfile, 0)) != -1) {
     fflush (smimeout);
     fclose (smimeout);
-      
+
     if (mutt_wait_filter (thepid))
       badsig = -1;
-    else
-    {
+    else {
       char *line = NULL;
       int lineno = 0;
       size_t linelen;
-      
+
       fflush (smimeerr);
       rewind (smimeerr);
-      
+
       line = mutt_read_line (line, &linelen, smimeerr, &lineno);
       if (linelen && !mutt_strcasecmp (line, "verification successful"))
-       badsig = 0;
+        badsig = 0;
 
       FREE (&line);
     }
   }
-  
+
   fflush (smimeerr);
   rewind (smimeerr);
   mutt_copy_stream (smimeerr, s->fpout);
   fclose (smimeerr);
-    
+
   state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s);
-  
+
   mutt_unlink (signedfile);
   mutt_unlink (smimeerrfile);
 
   sigbdy->length = tmplength;
   sigbdy->offset = tmpoffset;
-  
+
   /* restore the original source stream */
   fclose (s->fpin);
   s->fpin = fp;
-  
+
 
   return badsig;
 }
@@ -1658,81 +1606,87 @@ int smime_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
   or an encrypted message.
 */
 
-static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
+static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile)
 {
-  int len=0;
+  int len = 0;
   int c;
   long last_pos;
   char buf[HUGE_STRING];
   char outfile[_POSIX_PATH_MAX], errfile[_POSIX_PATH_MAX];
   char tmpfname[_POSIX_PATH_MAX];
   char tmptmpfname[_POSIX_PATH_MAX];
-  FILE *smimeout = NULL, *smimein=NULL, *smimeerr=NULL;
-  FILE *tmpfp=NULL, *tmpfp_buffer=NULL, *fpout=NULL;
+  FILE *smimeout = NULL, *smimein = NULL, *smimeerr = NULL;
+  FILE *tmpfp = NULL, *tmpfp_buffer = NULL, *fpout = NULL;
   struct stat info;
-  BODY *p=NULL;
-  pid_t thepid=-1;
+  BODY *p = NULL;
+  pid_t thepid = -1;
   unsigned int type = mutt_is_application_smime (m);
 
-  if (!(type & APPLICATION_SMIME)) return NULL;
+  if (!(type & APPLICATION_SMIME))
+    return NULL;
 
   mutt_mktemp (outfile);
-  if ((smimeout = safe_fopen (outfile, "w+")) == NULL)
-  {
+  if ((smimeout = safe_fopen (outfile, "w+")) == NULL) {
     mutt_perror (outfile);
     return NULL;
   }
-  
+
   mutt_mktemp (errfile);
-  if ((smimeerr = safe_fopen (errfile, "w+")) == NULL)
-  {
+  if ((smimeerr = safe_fopen (errfile, "w+")) == NULL) {
     mutt_perror (errfile);
-    fclose (smimeout); smimeout = NULL;
+    fclose (smimeout);
+    smimeout = NULL;
     return NULL;
   }
   mutt_unlink (errfile);
 
-  
+
   mutt_mktemp (tmpfname);
-  if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL)
-  {
+  if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL) {
     mutt_perror (tmpfname);
-    fclose (smimeout); smimeout = NULL;
-    fclose (smimeerr); smimeerr = NULL;
+    fclose (smimeout);
+    smimeout = NULL;
+    fclose (smimeerr);
+    smimeerr = NULL;
     return NULL;
   }
 
   fseek (s->fpin, m->offset, 0);
   last_pos = m->offset;
 
-  mutt_copy_bytes (s->fpin, tmpfp,  m->length);
+  mutt_copy_bytes (s->fpin, tmpfp, m->length);
 
   fflush (tmpfp);
   fclose (tmpfp);
 
   if ((type & ENCRYPT) &&
       (thepid = smime_invoke_decrypt (&smimein, NULL, NULL, -1,
-                                     fileno (smimeout),  fileno (smimeerr), tmpfname)) == -1)
-  {
-    fclose (smimeout); smimeout = NULL;
+                                      fileno (smimeout), fileno (smimeerr),
+                                      tmpfname)) == -1) {
+    fclose (smimeout);
+    smimeout = NULL;
     mutt_unlink (tmpfname);
-    state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
+    state_attach_puts (_
+                       ("[-- Error: unable to create OpenSSL subprocess! --]\n"),
+                       s);
     return NULL;
   }
   else if ((type & SIGNOPAQUE) &&
-          (thepid = smime_invoke_verify (&smimein, NULL, NULL, -1,
-                                         fileno (smimeout), fileno (smimeerr), NULL,
-                                         tmpfname, SIGNOPAQUE)) == -1)
-  {
-    fclose (smimeout); smimeout = NULL;
+           (thepid = smime_invoke_verify (&smimein, NULL, NULL, -1,
+                                          fileno (smimeout),
+                                          fileno (smimeerr), NULL, tmpfname,
+                                          SIGNOPAQUE)) == -1) {
+    fclose (smimeout);
+    smimeout = NULL;
     mutt_unlink (tmpfname);
-    state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
+    state_attach_puts (_
+                       ("[-- Error: unable to create OpenSSL subprocess! --]\n"),
+                       s);
     return NULL;
   }
 
-  
-  if (type & ENCRYPT)
-  {
+
+  if (type & ENCRYPT) {
     if (!smime_valid_passphrase ())
       smime_void_passphrase ();
     fputs (SmimePass, smimein);
@@ -1740,114 +1694,104 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
   }
 
   fclose (smimein);
-       
+
   mutt_wait_filter (thepid);
   mutt_unlink (tmpfname);
-  
 
-  if (s->flags & M_DISPLAY)
-  {
+
+  if (s->flags & M_DISPLAY) {
     rewind (smimeerr);
-    
-    if ((c = fgetc (smimeerr)) != EOF)
-    {
+
+    if ((c = fgetc (smimeerr)) != EOF) {
       ungetc (c, smimeerr);
-      
+
       crypt_current_time (s, "OpenSSL");
       mutt_copy_stream (smimeerr, s->fpout);
       state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s);
     }
-    
+
     if (type & ENCRYPT)
       state_attach_puts (_("[-- The following data is S/MIME"
                            " encrypted --]\n"), s);
     else
-      state_attach_puts (_("[-- The following data is S/MIME signed --]\n"), s);
+      state_attach_puts (_("[-- The following data is S/MIME signed --]\n"),
+                         s);
   }
 
-  if (smimeout)
-  {
+  if (smimeout) {
     fflush (smimeout);
     rewind (smimeout);
-    
-    if (outFile) fpout = outFile;
-    else
-    {
+
+    if (outFile)
+      fpout = outFile;
+    else {
       mutt_mktemp (tmptmpfname);
-      if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL)
-      {
-       mutt_perror(tmptmpfname);
-       fclose (smimeout); smimeout = NULL;
-       return NULL;
+      if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL) {
+        mutt_perror (tmptmpfname);
+        fclose (smimeout);
+        smimeout = NULL;
+        return NULL;
       }
     }
-    while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL)
-    {
+    while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL) {
       len = mutt_strlen (buf);
-      if (len > 1 && buf[len - 2] == '\r')
-      {
-       buf[len-2] = '\n';
-       buf[len-1] = '\0';
+      if (len > 1 && buf[len - 2] == '\r') {
+        buf[len - 2] = '\n';
+        buf[len - 1] = '\0';
       }
       fputs (buf, fpout);
     }
     fflush (fpout);
-    rewind (fpout); 
+    rewind (fpout);
 
 
-    if ((p = mutt_read_mime_header (fpout, 0)) != NULL)
-    {
+    if ((p = mutt_read_mime_header (fpout, 0)) != NULL) {
       fstat (fileno (fpout), &info);
       p->length = info.st_size - p->offset;
-         
+
       mutt_parse_part (fpout, p);
-      if (s->fpout)
-      {
-       rewind (fpout);
-       tmpfp_buffer = s->fpin;
-       s->fpin = fpout;
-       mutt_body_handler (p, s);
-       s->fpin = tmpfp_buffer;
+      if (s->fpout) {
+        rewind (fpout);
+        tmpfp_buffer = s->fpin;
+        s->fpin = fpout;
+        mutt_body_handler (p, s);
+        s->fpin = tmpfp_buffer;
       }
-      
+
     }
     fclose (smimeout);
     smimeout = NULL;
     mutt_unlink (outfile);
 
-    if (!outFile)
-    {
+    if (!outFile) {
       fclose (fpout);
       mutt_unlink (tmptmpfname);
     }
     fpout = NULL;
   }
 
-  if (s->flags & M_DISPLAY)
-  {
+  if (s->flags & M_DISPLAY) {
     if (type & ENCRYPT)
       state_attach_puts (_("\n[-- End of S/MIME encrypted data. --]\n"), s);
     else
       state_attach_puts (_("\n[-- End of S/MIME signed data. --]\n"), s);
   }
 
-  if (type & SIGNOPAQUE)
-  {
+  if (type & SIGNOPAQUE) {
     char *line = NULL;
     int lineno = 0;
     size_t linelen;
-    
+
     rewind (smimeerr);
-    
+
     line = mutt_read_line (line, &linelen, smimeerr, &lineno);
     if (linelen && !mutt_strcasecmp (line, "verification successful"))
       m->goodsig = 1;
     FREE (&line);
   }
-  else 
-  {
+  else {
     m->goodsig = p->goodsig;
-    m->badsig  = p->badsig;
+    m->badsig = p->badsig;
   }
   fclose (smimeerr);
 
@@ -1858,7 +1802,7 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
 
 
 
-int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
+int smime_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur)
 {
 
 
@@ -1867,21 +1811,20 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   long tmpoffset = b->offset;
   size_t tmplength = b->length;
   int origType = b->type;
-  FILE *tmpfp=NULL;
+  FILE *tmpfp = NULL;
 
   if (!mutt_is_application_smime (b))
     return -1;
 
   if (b->parts)
     return -1;
-  
+
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
   fseek (s.fpin, b->offset, 0);
 
   mutt_mktemp (tempfile);
-  if ((tmpfp = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((tmpfp = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     return (-1);
   }
@@ -1897,8 +1840,7 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   s.fpout = 0;
 
   mutt_mktemp (tempfile);
-  if ((*fpout = safe_fopen (tempfile, "w+")) == NULL)
-  {
+  if ((*fpout = safe_fopen (tempfile, "w+")) == NULL) {
     mutt_perror (tempfile);
     return (-1);
   }
@@ -1918,71 +1860,71 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
 }
 
 
-void smime_application_smime_handler (BODY *m, STATE *s)
+void smime_application_smime_handler (BODY * m, STATE * s)
 {
-    
-    smime_handle_entity (m, s, NULL);
+
+  smime_handle_entity (m, s, NULL);
 
 }
 
-int smime_send_menu (HEADER *msg, int *redraw)
+int smime_send_menu (HEADER * msg, int *redraw)
 {
   char *p;
 
   if (!(WithCrypto & APPLICATION_SMIME))
     return msg->security;
 
-  switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear? "),
-                            _("eswabfc")))
-  {
-  case 1: /* (e)ncrypt */
+  switch (mutt_multi_choice
+          (_
+           ("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear? "),
+           _("eswabfc"))) {
+  case 1:                      /* (e)ncrypt */
     msg->security |= ENCRYPT;
     msg->security &= ~SIGN;
     break;
 
-  case 3: /* encrypt (w)ith */
+  case 3:                      /* encrypt (w)ith */
     msg->security |= ENCRYPT;
     switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40,"
-                                " 4: RC2-64, 5: RC2-128, or (f)orget it? "),
-                              _("12345f"))) {
+                                 " 4: RC2-64, 5: RC2-128, or (f)orget it? "),
+                               _("12345f"))) {
     case 1:
-       mutt_str_replace (&SmimeCryptAlg, "des");
-       break;
+      mutt_str_replace (&SmimeCryptAlg, "des");
+      break;
     case 2:
-       mutt_str_replace (&SmimeCryptAlg, "des3");
-       break;
+      mutt_str_replace (&SmimeCryptAlg, "des3");
+      break;
     case 3:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-40");
-       break;
+      mutt_str_replace (&SmimeCryptAlg, "rc2-40");
+      break;
     case 4:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-64");
-       break;
+      mutt_str_replace (&SmimeCryptAlg, "rc2-64");
+      break;
     case 5:
-       mutt_str_replace (&SmimeCryptAlg, "rc2-128");
-       break;
-    case 6: /* forget it */
-       break;
+      mutt_str_replace (&SmimeCryptAlg, "rc2-128");
+      break;
+    case 6:                    /* forget it */
+      break;
     }
     break;
 
-  case 2: /* (s)ign */
-      
-    if(!SmimeDefaultKey)
-       mutt_message _("Can't sign: No key specified. Use Sign As.");
-    else
-    {
+  case 2:                      /* (s)ign */
+
+    if (!SmimeDefaultKey)
+      mutt_message (_("Can't sign: No key specified. Use Sign As."));
+
+    else {
       msg->security |= SIGN;
       msg->security &= ~ENCRYPT;
     }
     break;
 
-  case 4: /* sign (a)s */
+  case 4:                      /* sign (a)s */
 
-    if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) 
-    {
-      p[mutt_strlen (p)-1] = '\0';
+    if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) {
+      p[mutt_strlen (p) - 1] = '\0';
       mutt_str_replace (&SmimeDefaultKey, p);
-       
+
       msg->security |= SIGN;
 
       /* probably need a different passphrase */
@@ -1996,12 +1938,12 @@ int smime_send_menu (HEADER *msg, int *redraw)
     *redraw = REDRAW_FULL;
     break;
 
-  case 5: /* (b)oth */
+  case 5:                      /* (b)oth */
     msg->security |= (ENCRYPT | SIGN);
     break;
 
-  case 6: /* (f)orget it */
-  case 7: /* (c)lear */
+  case 6:                      /* (f)orget it */
+  case 7:                      /* (c)lear */
     msg->security = 0;
     break;
   }
diff --git a/smime.h b/smime.h
index dba0a0f..6c57f93 100644 (file)
--- a/smime.h
+++ b/smime.h
 void smime_void_passphrase (void);
 int smime_valid_passphrase (void);
 
-int   smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
+int smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
 
-void  smime_application_smime_handler (BODY *, STATE *);
+void smime_application_smime_handler (BODY *, STATE *);
 
 
-BODYsmime_sign_message (BODY *);
+BODY *smime_sign_message (BODY *);
 
-BODYsmime_build_smime_entity (BODY *, char *);
+BODY *smime_build_smime_entity (BODY *, char *);
 
-int   smime_verify_one(BODY *, STATE *, const char *);
+int smime_verify_one (BODY *, STATE *, const char *);
 
 
-int   smime_verify_sender(HEADER *);
+int smime_verify_sender (HEADER *);
 
 
-charsmime_get_field_from_db (char *, char *, short, short);
+char *smime_get_field_from_db (char *, char *, short, short);
 
-void  smime_getkeys (ENVELOPE *);
+void smime_getkeys (ENVELOPE *);
 
-charsmime_ask_for_key (char *, char *, short);
+char *smime_ask_for_key (char *, char *, short);
 
-char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+char *smime_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc);
 
-void  smime_invoke_import (char *, char *);
+void smime_invoke_import (char *, char *);
 
-int smime_send_menu (HEADER *msg, int *redraw);
+int smime_send_menu (HEADER * msg, int *redraw);
 
 #endif
-
-
index 8a5586a..2a40c4f 100644 (file)
 
 #if defined(HAVE_STDARG_H)
 # include <stdarg.h>
-# define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
+# define HAVE_STDARGS           /* let's hope that works everywhere (mj) */
 # define VA_LOCAL_DECL   va_list ap
 # define VA_START(f)     va_start(ap, f)
-# define VA_SHIFT(v,t)  ;   /* no-op for ANSI */
+# define VA_SHIFT(v,t)  ;       /* no-op for ANSI */
 # define VA_END          va_end(ap)
 #else
 # if defined(HAVE_VARARGS_H)
 #  include <varargs.h>
 #  undef HAVE_STDARGS
 #  define VA_LOCAL_DECL   va_list ap
-#  define VA_START(f)     va_start(ap)      /* f is ignored! */
+#  define VA_START(f)     va_start(ap)  /* f is ignored! */
 #  define VA_SHIFT(v,t) v = va_arg(ap,t)
 #  define VA_END        va_end(ap)
 # else
 /*int snprintf (char *str, size_t count, const char *fmt, ...);*/
 /*int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);*/
 
-static void dopr (char *buffer, size_t maxlen, const char *format, 
+static void dopr (char *buffer, size_t maxlen, const char *format,
                   va_list args);
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
-                   char *value, int flags, int min, int max);
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
-                   long value, int base, int min, int max, int flags);
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
-                  long double fvalue, int min, int max, int flags);
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+static void fmtstr (char *buffer, size_t * currlen, size_t maxlen,
+                    char *value, int flags, int min, int max);
+static void fmtint (char *buffer, size_t * currlen, size_t maxlen,
+                    long value, int base, int min, int max, int flags);
+static void fmtfp (char *buffer, size_t * currlen, size_t maxlen,
+                   long double fvalue, int min, int max, int flags);
+static void dopr_outch (char *buffer, size_t * currlen, size_t maxlen,
+                        char c);
 
 /*
  * dopr(): poor man's version of doprintf
@@ -121,7 +122,8 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
 #undef MAX
 #define MAX(p,q) ((p >= q) ? p : q)
 
-static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
+static void dopr (char *buffer, size_t maxlen, const char *format,
+                  va_list args)
 {
   char ch;
   long value;
@@ -133,228 +135,242 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
   int flags;
   int cflags;
   size_t currlen;
-  
+
   state = DP_S_DEFAULT;
   currlen = flags = cflags = min = 0;
   max = -1;
   ch = *format++;
 
-  while (state != DP_S_DONE)
-  {
-    if ((ch == '\0') || (currlen >= maxlen)) 
+  while (state != DP_S_DONE) {
+    if ((ch == '\0') || (currlen >= maxlen))
       state = DP_S_DONE;
 
-    switch(state) 
-    {
+    switch (state) {
     case DP_S_DEFAULT:
-      if (ch == '%') 
-       state = DP_S_FLAGS;
-      else 
-       dopr_outch (buffer, &currlen, maxlen, ch);
+      if (ch == '%')
+        state = DP_S_FLAGS;
+      else
+        dopr_outch (buffer, &currlen, maxlen, ch);
       ch = *format++;
       break;
     case DP_S_FLAGS:
-      switch (ch) 
-      {
+      switch (ch) {
       case '-':
-       flags |= DP_F_MINUS;
+        flags |= DP_F_MINUS;
         ch = *format++;
-       break;
+        break;
       case '+':
-       flags |= DP_F_PLUS;
+        flags |= DP_F_PLUS;
         ch = *format++;
-       break;
+        break;
       case ' ':
-       flags |= DP_F_SPACE;
+        flags |= DP_F_SPACE;
         ch = *format++;
-       break;
+        break;
       case '#':
-       flags |= DP_F_NUM;
+        flags |= DP_F_NUM;
         ch = *format++;
-       break;
+        break;
       case '0':
-       flags |= DP_F_ZERO;
+        flags |= DP_F_ZERO;
         ch = *format++;
-       break;
+        break;
       default:
-       state = DP_S_MIN;
-       break;
+        state = DP_S_MIN;
+        break;
       }
       break;
     case DP_S_MIN:
-      if (isdigit((unsigned char)ch)) 
-      {
-       min = 10*min + char_to_int (ch);
-       ch = *format++;
-      } 
-      else if (ch == '*') 
-      {
-       min = va_arg (args, int);
-       ch = *format++;
-       state = DP_S_DOT;
-      } 
-      else 
-       state = DP_S_DOT;
+      if (isdigit ((unsigned char) ch)) {
+        min = 10 * min + char_to_int (ch);
+        ch = *format++;
+      }
+      else if (ch == '*') {
+        min = va_arg (args, int);
+
+        ch = *format++;
+        state = DP_S_DOT;
+      }
+      else
+        state = DP_S_DOT;
       break;
     case DP_S_DOT:
-      if (ch == '.') 
-      {
-       state = DP_S_MAX;
-       ch = *format++;
-      } 
-      else 
-       state = DP_S_MOD;
+      if (ch == '.') {
+        state = DP_S_MAX;
+        ch = *format++;
+      }
+      else
+        state = DP_S_MOD;
       break;
     case DP_S_MAX:
-      if (isdigit((unsigned char)ch)) 
-      {
-       if (max < 0)
-         max = 0;
-       max = 10*max + char_to_int (ch);
-       ch = *format++;
-      } 
-      else if (ch == '*') 
-      {
-       max = va_arg (args, int);
-       ch = *format++;
-       state = DP_S_MOD;
-      } 
-      else 
-       state = DP_S_MOD;
+      if (isdigit ((unsigned char) ch)) {
+        if (max < 0)
+          max = 0;
+        max = 10 * max + char_to_int (ch);
+        ch = *format++;
+      }
+      else if (ch == '*') {
+        max = va_arg (args, int);
+
+        ch = *format++;
+        state = DP_S_MOD;
+      }
+      else
+        state = DP_S_MOD;
       break;
     case DP_S_MOD:
       /* Currently, we don't support Long Long, bummer */
-      switch (ch) 
-      {
+      switch (ch) {
       case 'h':
-       cflags = DP_C_SHORT;
-       ch = *format++;
-       break;
+        cflags = DP_C_SHORT;
+        ch = *format++;
+        break;
       case 'l':
-       cflags = DP_C_LONG;
-       ch = *format++;
-       break;
+        cflags = DP_C_LONG;
+        ch = *format++;
+        break;
       case 'L':
-       cflags = DP_C_LDOUBLE;
-       ch = *format++;
-       break;
+        cflags = DP_C_LDOUBLE;
+        ch = *format++;
+        break;
       default:
-       break;
+        break;
       }
       state = DP_S_CONV;
       break;
     case DP_S_CONV:
-      switch (ch) 
-      {
+      switch (ch) {
       case 'd':
       case 'i':
-       if (cflags == DP_C_SHORT) 
-         value = va_arg (args, short int);
-       else if (cflags == DP_C_LONG)
-         value = va_arg (args, long int);
-       else
-         value = va_arg (args, int);
-       fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
-       break;
+        if (cflags == DP_C_SHORT)
+          value = va_arg (args, short int);
+
+        else if (cflags == DP_C_LONG)
+          value = va_arg (args, long int);
+
+        else
+          value = va_arg (args, int);
+
+        fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+        break;
       case 'o':
-       flags |= DP_F_UNSIGNED;
-       if (cflags == DP_C_SHORT)
-         value = va_arg (args, unsigned short int);
-       else if (cflags == DP_C_LONG)
-         value = va_arg (args, unsigned long int);
-       else
-         value = va_arg (args, unsigned int);
-       fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
-       break;
+        flags |= DP_F_UNSIGNED;
+        if (cflags == DP_C_SHORT)
+          value = va_arg (args, unsigned short int);
+
+        else if (cflags == DP_C_LONG)
+          value = va_arg (args, unsigned long int);
+
+        else
+          value = va_arg (args, unsigned int);
+
+        fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
+        break;
       case 'u':
-       flags |= DP_F_UNSIGNED;
-       if (cflags == DP_C_SHORT)
-         value = va_arg (args, unsigned short int);
-       else if (cflags == DP_C_LONG)
-         value = va_arg (args, unsigned long int);
-       else
-         value = va_arg (args, unsigned int);
-       fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
-       break;
+        flags |= DP_F_UNSIGNED;
+        if (cflags == DP_C_SHORT)
+          value = va_arg (args, unsigned short int);
+
+        else if (cflags == DP_C_LONG)
+          value = va_arg (args, unsigned long int);
+
+        else
+          value = va_arg (args, unsigned int);
+
+        fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+        break;
       case 'X':
-       flags |= DP_F_UP;
+        flags |= DP_F_UP;
       case 'x':
-       flags |= DP_F_UNSIGNED;
-       if (cflags == DP_C_SHORT)
-         value = va_arg (args, unsigned short int);
-       else if (cflags == DP_C_LONG)
-         value = va_arg (args, unsigned long int);
-       else
-         value = va_arg (args, unsigned int);
-       fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
-       break;
+        flags |= DP_F_UNSIGNED;
+        if (cflags == DP_C_SHORT)
+          value = va_arg (args, unsigned short int);
+
+        else if (cflags == DP_C_LONG)
+          value = va_arg (args, unsigned long int);
+
+        else
+          value = va_arg (args, unsigned int);
+
+        fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
+        break;
       case 'f':
-       if (cflags == DP_C_LDOUBLE)
-         fvalue = va_arg (args, long double);
-       else
-         fvalue = va_arg (args, double);
-       /* um, floating point? */
-       fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
-       break;
+        if (cflags == DP_C_LDOUBLE)
+          fvalue = va_arg (args, long double);
+
+        else
+          fvalue = va_arg (args, double);
+
+        /* um, floating point? */
+        fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
+        break;
       case 'E':
-       flags |= DP_F_UP;
+        flags |= DP_F_UP;
       case 'e':
-       if (cflags == DP_C_LDOUBLE)
-         fvalue = va_arg (args, long double);
-       else
-         fvalue = va_arg (args, double);
-       break;
+        if (cflags == DP_C_LDOUBLE)
+          fvalue = va_arg (args, long double);
+
+        else
+          fvalue = va_arg (args, double);
+
+        break;
       case 'G':
-       flags |= DP_F_UP;
+        flags |= DP_F_UP;
       case 'g':
-       if (cflags == DP_C_LDOUBLE)
-         fvalue = va_arg (args, long double);
-       else
-         fvalue = va_arg (args, double);
-       break;
+        if (cflags == DP_C_LDOUBLE)
+          fvalue = va_arg (args, long double);
+
+        else
+          fvalue = va_arg (args, double);
+
+        break;
       case 'c':
-       dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
-       break;
+        dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+
+        break;
       case 's':
-       strvalue = va_arg (args, char *);
-       if (max < 0) 
-         max = maxlen; /* ie, no max */
-       fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
-       break;
+        strvalue = va_arg (args, char *);
+
+        if (max < 0)
+          max = maxlen;         /* ie, no max */
+        fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+        break;
       case 'p':
-       strvalue = va_arg (args, void *);
-       fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
-       break;
+        strvalue = va_arg (args, void *);
+
+        fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max,
+                flags);
+        break;
       case 'n':
-       if (cflags == DP_C_SHORT) 
-       {
-         short int *num;
-         num = va_arg (args, short int *);
-         *num = currlen;
-        } 
-       else if (cflags == DP_C_LONG) 
-       {
-         long int *num;
-         num = va_arg (args, long int *);
-         *num = currlen;
-        } 
-       else 
-       {
-         int *num;
-         num = va_arg (args, int *);
-         *num = currlen;
+        if (cflags == DP_C_SHORT) {
+          short int *num;
+          num = va_arg (args, short int *);
+
+          *num = currlen;
         }
-       break;
+        else if (cflags == DP_C_LONG) {
+          long int *num;
+          num = va_arg (args, long int *);
+
+          *num = currlen;
+        }
+        else {
+          int *num;
+          num = va_arg (args, int *);
+
+          *num = currlen;
+        }
+        break;
       case '%':
-       dopr_outch (buffer, &currlen, maxlen, ch);
-       break;
+        dopr_outch (buffer, &currlen, maxlen, ch);
+        break;
       case 'w':
-       /* not supported yet, treat as next char */
-       ch = *format++;
-       break;
+        /* not supported yet, treat as next char */
+        ch = *format++;
+        break;
       default:
-       /* Unknown, skip */
-       break;
+        /* Unknown, skip */
+        break;
       }
       ch = *format++;
       state = DP_S_DEFAULT;
@@ -365,46 +381,42 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
       break;
     default:
       /* hmm? */
-      break; /* some picky compilers need this */
+      break;                    /* some picky compilers need this */
     }
   }
-  if (currlen < maxlen - 1) 
+  if (currlen < maxlen - 1)
     buffer[currlen] = '\0';
-  else 
+  else
     buffer[maxlen - 1] = '\0';
 }
 
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
-                   char *value, int flags, int min, int max)
+static void fmtstr (char *buffer, size_t * currlen, size_t maxlen,
+                    char *value, int flags, int min, int max)
 {
-  int padlen, strln;     /* amount to pad */
+  int padlen, strln;            /* amount to pad */
   int cnt = 0;
-  
-  if (value == 0)
-  {
+
+  if (value == 0) {
     value = "<NULL>";
   }
 
-  for (strln = 0; value[strln]; ++strln); /* strlen */
+  for (strln = 0; value[strln]; ++strln);       /* strlen */
   padlen = min - strln;
-  if (padlen < 0) 
+  if (padlen < 0)
     padlen = 0;
-  if (flags & DP_F_MINUS) 
-    padlen = -padlen; /* Left Justify */
+  if (flags & DP_F_MINUS)
+    padlen = -padlen;           /* Left Justify */
 
-  while ((padlen > 0) && (cnt < max)) 
-  {
+  while ((padlen > 0) && (cnt < max)) {
     dopr_outch (buffer, currlen, maxlen, ' ');
     --padlen;
     ++cnt;
   }
-  while (*value && (cnt < max)) 
-  {
+  while (*value && (cnt < max)) {
     dopr_outch (buffer, currlen, maxlen, *value++);
     ++cnt;
   }
-  while ((padlen < 0) && (cnt < max)) 
-  {
+  while ((padlen < 0) && (cnt < max)) {
     dopr_outch (buffer, currlen, maxlen, ' ');
     ++padlen;
     ++cnt;
@@ -413,89 +425,85 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
 
 /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
 
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
-                   long value, int base, int min, int max, int flags)
+static void fmtint (char *buffer, size_t * currlen, size_t maxlen,
+                    long value, int base, int min, int max, int flags)
 {
   int signvalue = 0;
   unsigned long uvalue;
   char convert[20];
   int place = 0;
-  int spadlen = 0; /* amount to space pad */
-  int zpadlen = 0; /* amount to zero pad */
+  int spadlen = 0;              /* amount to space pad */
+  int zpadlen = 0;              /* amount to zero pad */
   int caps = 0;
-  
+
   if (max < 0)
     max = 0;
 
   uvalue = value;
 
-  if(!(flags & DP_F_UNSIGNED))
-  {
-    if( value < 0 ) {
+  if (!(flags & DP_F_UNSIGNED)) {
+    if (value < 0) {
       signvalue = '-';
       uvalue = -value;
     }
-    else
-      if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
-       signvalue = '+';
-    else
-      if (flags & DP_F_SPACE)
-       signvalue = ' ';
+    else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
+      signvalue = '+';
+    else if (flags & DP_F_SPACE)
+      signvalue = ' ';
   }
-  
-  if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+
+  if (flags & DP_F_UP)
+    caps = 1;                   /* Should characters be upper case? */
 
   do {
-    convert[place++] =
-      (caps? "0123456789ABCDEF":"0123456789abcdef")
-      [uvalue % (unsigned)base  ];
-    uvalue = (uvalue / (unsigned)base );
-  } while(uvalue && (place < 20));
-  if (place == 20) place--;
+    convert[place++] = (caps ? "0123456789ABCDEF" : "0123456789abcdef")
+      [uvalue % (unsigned) base];
+    uvalue = (uvalue / (unsigned) base);
+  } while (uvalue && (place < 20));
+  if (place == 20)
+    place--;
   convert[place] = 0;
 
   zpadlen = max - place;
   spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
-  if (zpadlen < 0) zpadlen = 0;
-  if (spadlen < 0) spadlen = 0;
-  if (flags & DP_F_ZERO)
-  {
-    zpadlen = MAX(zpadlen, spadlen);
+  if (zpadlen < 0)
+    zpadlen = 0;
+  if (spadlen < 0)
+    spadlen = 0;
+  if (flags & DP_F_ZERO) {
+    zpadlen = MAX (zpadlen, spadlen);
     spadlen = 0;
   }
-  if (flags & DP_F_MINUS) 
-    spadlen = -spadlen; /* Left Justifty */
+  if (flags & DP_F_MINUS)
+    spadlen = -spadlen;         /* Left Justifty */
 
 #ifdef DEBUG_SNPRINTF
   dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
-      zpadlen, spadlen, min, max, place));
+              zpadlen, spadlen, min, max, place));
 #endif
 
   /* Spaces */
-  while (spadlen > 0) 
-  {
+  while (spadlen > 0) {
     dopr_outch (buffer, currlen, maxlen, ' ');
     --spadlen;
   }
 
   /* Sign */
-  if (signvalue) 
+  if (signvalue)
     dopr_outch (buffer, currlen, maxlen, signvalue);
 
   /* Zeros */
-  if (zpadlen > 0) 
-  {
-    while (zpadlen > 0)
-    {
+  if (zpadlen > 0) {
+    while (zpadlen > 0) {
       dopr_outch (buffer, currlen, maxlen, '0');
       --zpadlen;
     }
   }
 
   /* Digits */
-  while (place > 0) 
+  while (place > 0)
     dopr_outch (buffer, currlen, maxlen, convert[--place]);
-  
+
   /* Left Justified spaces */
   while (spadlen < 0) {
     dopr_outch (buffer, currlen, maxlen, ' ');
@@ -517,12 +525,11 @@ static long double pow10 (int exp)
 {
   long double result = 1;
 
-  while (exp)
-  {
+  while (exp) {
     result *= 10;
     exp--;
   }
-  
+
   return result;
 }
 
@@ -538,8 +545,8 @@ static long round (long double value)
   return intpart;
 }
 
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
-                  long double fvalue, int min, int max, int flags)
+static void fmtfp (char *buffer, size_t * currlen, size_t maxlen,
+                   long double fvalue, int min, int max, int flags)
 {
   int signvalue = 0;
   long double ufvalue;
@@ -547,12 +554,12 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
   char fconvert[20];
   int iplace = 0;
   int fplace = 0;
-  int padlen = 0; /* amount to pad */
-  int zpadlen = 0; 
+  int padlen = 0;               /* amount to pad */
+  int zpadlen = 0;
   int caps = 0;
   long intpart;
   long fracpart;
-  
+
   /* 
    * AIX manpage says the default is 0, but Solaris says the default
    * is 6, and sprintf on AIX defaults to 6
@@ -564,15 +571,14 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
 
   if (fvalue < 0)
     signvalue = '-';
-  else
-    if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
-      signvalue = '+';
-    else
-      if (flags & DP_F_SPACE)
-       signvalue = ' ';
+  else if (flags & DP_F_PLUS)   /* Do a sign (+/i) */
+    signvalue = '+';
+  else if (flags & DP_F_SPACE)
+    signvalue = ' ';
 
 #if 0
-  if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+  if (flags & DP_F_UP)
+    caps = 1;                   /* Should characters be upper case? */
 #endif
 
   intpart = ufvalue;
@@ -589,8 +595,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
    */
   fracpart = round ((pow10 (max)) * (ufvalue - intpart));
 
-  if (fracpart >= pow10 (max))
-  {
+  if (fracpart >= pow10 (max)) {
     intpart++;
     fracpart -= pow10 (max);
   }
@@ -602,54 +607,52 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
   /* Convert integer part */
   do {
     iconvert[iplace++] =
-      (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
+      (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];
     intpart = (intpart / 10);
-  } while(intpart && (iplace < 20));
-  if (iplace == 20) iplace--;
+  } while (intpart && (iplace < 20));
+  if (iplace == 20)
+    iplace--;
   iconvert[iplace] = 0;
 
   /* Convert fractional part */
   do {
     fconvert[fplace++] =
-      (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
+      (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];
     fracpart = (fracpart / 10);
-  } while(fracpart && (fplace < 20));
-  if (fplace == 20) fplace--;
+  } while (fracpart && (fplace < 20));
+  if (fplace == 20)
+    fplace--;
   fconvert[fplace] = 0;
 
   /* -1 for decimal point, another -1 if we are printing a sign */
-  padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
+  padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
   zpadlen = max - fplace;
   if (zpadlen < 0)
     zpadlen = 0;
-  if (padlen < 0) 
+  if (padlen < 0)
     padlen = 0;
-  if (flags & DP_F_MINUS) 
-    padlen = -padlen; /* Left Justifty */
+  if (flags & DP_F_MINUS)
+    padlen = -padlen;           /* Left Justifty */
 
-  if ((flags & DP_F_ZERO) && (padlen > 0)) 
-  {
-    if (signvalue) 
-    {
+  if ((flags & DP_F_ZERO) && (padlen > 0)) {
+    if (signvalue) {
       dopr_outch (buffer, currlen, maxlen, signvalue);
       --padlen;
       signvalue = 0;
     }
-    while (padlen > 0)
-    {
+    while (padlen > 0) {
       dopr_outch (buffer, currlen, maxlen, '0');
       --padlen;
     }
   }
-  while (padlen > 0)
-  {
+  while (padlen > 0) {
     dopr_outch (buffer, currlen, maxlen, ' ');
     --padlen;
   }
-  if (signvalue) 
+  if (signvalue)
     dopr_outch (buffer, currlen, maxlen, signvalue);
 
-  while (iplace > 0) 
+  while (iplace > 0)
     dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
 
   /*
@@ -658,23 +661,21 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
    */
   dopr_outch (buffer, currlen, maxlen, '.');
 
-  while (fplace > 0) 
+  while (fplace > 0)
     dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
 
-  while (zpadlen > 0)
-  {
+  while (zpadlen > 0) {
     dopr_outch (buffer, currlen, maxlen, '0');
     --zpadlen;
   }
 
-  while (padlen < 0) 
-  {
+  while (padlen < 0) {
     dopr_outch (buffer, currlen, maxlen, ' ');
     ++padlen;
   }
 }
 
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
+static void dopr_outch (char *buffer, size_t * currlen, size_t maxlen, char c)
 {
   if (*currlen < maxlen)
     buffer[(*currlen)++] = c;
@@ -685,17 +686,18 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
 int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
 {
   str[0] = 0;
-  dopr(str, count, fmt, args);
-  return(strlen(str));
+  dopr (str, count, fmt, args);
+  return (strlen (str));
 }
 #endif /* !HAVE_VSNPRINTF */
 
 #ifndef HAVE_SNPRINTF
 /* VARARGS3 */
 #ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
+int snprintf (char *str, size_t count, const char *fmt, ...)
 #else
-int snprintf (va_alist) va_dcl
+int snprintf (va_alist)
+     va_dcl
 #endif
 {
 #ifndef HAVE_STDARGS
@@ -704,14 +706,16 @@ int snprintf (va_alist) va_dcl
   char *fmt;
 #endif
   VA_LOCAL_DECL;
-    
+
   VA_START (fmt);
   VA_SHIFT (str, char *);
-  VA_SHIFT (count, size_t );
+
+  VA_SHIFT (count, size_t);
   VA_SHIFT (fmt, char *);
-  (void) vsnprintf(str, count, fmt, ap);
+
+  (void) vsnprintf (str, count, fmt, ap);
   VA_END;
-  return(strlen(str));
+  return (strlen (str));
 }
 
 #ifdef TEST_SNPRINTF
@@ -736,8 +740,9 @@ int main (void)
     "%3.2f",
     NULL
   };
-  double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 
-    0.9996, 1.996, 4.136, 0};
+  double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+    0.9996, 1.996, 4.136, 0
+  };
   char *int_fmt[] = {
     "%-1.5d",
     "%1.5d",
@@ -750,37 +755,33 @@ int main (void)
     "%4d",
     NULL
   };
-  long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+  long int_nums[] = { -1, 134, 91340, 341, 0203, 0 };
   int x, y;
   int fail = 0;
   int num = 0;
 
   printf ("Testing snprintf format codes against system sprintf...\n");
 
-  for (x = 0; fp_fmt[x] != NULL ; x++)
-    for (y = 0; fp_nums[y] != 0 ; y++)
-    {
+  for (x = 0; fp_fmt[x] != NULL; x++)
+    for (y = 0; fp_nums[y] != 0; y++) {
       snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
       sprintf (buf2, fp_fmt[x], fp_nums[y]);
-      if (strcmp (buf1, buf2))
-      {
-       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n", /* __SPRINTF_CHECKED__ */
-           fp_fmt[x], buf1, buf2);
-       fail++;
+      if (strcmp (buf1, buf2)) {
+        printf ("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n",        /* __SPRINTF_CHECKED__ */
+                fp_fmt[x], buf1, buf2);
+        fail++;
       }
       num++;
     }
 
-  for (x = 0; int_fmt[x] != NULL ; x++)
-    for (y = 0; int_nums[y] != 0 ; y++)
-    {
+  for (x = 0; int_fmt[x] != NULL; x++)
+    for (y = 0; int_nums[y] != 0; y++) {
       snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
       sprintf (buf2, int_fmt[x], int_nums[y]);
-      if (strcmp (buf1, buf2))
-      {
-       printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n", /* __SPRINTF_CHECKED__ */
-           int_fmt[x], buf1, buf2);
-       fail++;
+      if (strcmp (buf1, buf2)) {
+        printf ("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf  = %s\n",        /* __SPRINTF_CHECKED__ */
+                int_fmt[x], buf1, buf2);
+        fail++;
       }
       num++;
     }
diff --git a/sort.c b/sort.c
index ae2a8e5..79fac85 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -46,8 +46,9 @@ int compare_score (const void *a, const void *b)
 {
   HEADER **pa = (HEADER **) a;
   HEADER **pb = (HEADER **) b;
-  int result = (*pb)->score - (*pa)->score; /* note that this is reverse */
-  AUXSORT(result,a,b);
+  int result = (*pb)->score - (*pa)->score;     /* note that this is reverse */
+
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -56,7 +57,8 @@ int compare_size (const void *a, const void *b)
   HEADER **pa = (HEADER **) a;
   HEADER **pb = (HEADER **) b;
   int result = (*pa)->content->length - (*pb)->content->length;
-  AUXSORT(result,a,b);
+
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -65,7 +67,8 @@ int compare_date_sent (const void *a, const void *b)
   HEADER **pa = (HEADER **) a;
   HEADER **pb = (HEADER **) b;
   int result = (*pa)->date_sent - (*pb)->date_sent;
-  AUXSORT(result,a,b);
+
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -75,8 +78,7 @@ int compare_subject (const void *a, const void *b)
   HEADER **pb = (HEADER **) b;
   int rc;
 
-  if (!(*pa)->env->real_subj)
-  {
+  if (!(*pa)->env->real_subj) {
     if (!(*pb)->env->real_subj)
       rc = compare_date_sent (pa, pb);
     else
@@ -86,18 +88,18 @@ int compare_subject (const void *a, const void *b)
     rc = 1;
   else
     rc = mutt_strcasecmp ((*pa)->env->real_subj, (*pb)->env->real_subj);
-  AUXSORT(rc,a,b);
+  AUXSORT (rc, a, b);
   return (SORTCODE (rc));
 }
 
-const char *mutt_get_name (ADDRESS *a)
+const char *mutt_get_name (ADDRESS * a)
 {
   ADDRESS *ali;
-  const char * name = "";
+  const char *name = "";
 
-  if (a)
-  {
-    if (option (OPTREVALIAS) && (ali = alias_reverse_lookup (a)) && ali->personal)
+  if (a) {
+    if (option (OPTREVALIAS) && (ali = alias_reverse_lookup (a))
+        && ali->personal)
       name = ali->personal;
     else if (a->personal)
       name = a->personal;
@@ -120,14 +122,14 @@ int compare_to (const void *a, const void *b)
    * On the next call that pointer may get smashed so we copy the return value
    * to our own memory space. */
 
-  strncpy(fa,mutt_get_name ((*ppa)->env->to),sizeof(fa));
-  fa[sizeof(fa)-1] = '\0';
+  strncpy (fa, mutt_get_name ((*ppa)->env->to), sizeof (fa));
+  fa[sizeof (fa) - 1] = '\0';
 
-  strncpy(fb,mutt_get_name ((*ppb)->env->to),sizeof(fb));
-  fb[sizeof(fb)-1] = '\0';
+  strncpy (fb, mutt_get_name ((*ppb)->env->to), sizeof (fb));
+  fb[sizeof (fb) - 1] = '\0';
 
   result = mutt_strcasecmp (fa, fb);
-  AUXSORT(result,a,b);
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -143,14 +145,14 @@ int compare_from (const void *a, const void *b)
    * On the next call that pointer may get smashed so we copy the return value
    * to our own memory space. */
 
-  strncpy(fa,mutt_get_name ((*ppa)->env->from),sizeof(fa));
-  fa[sizeof(fa)-1] = '\0';
+  strncpy (fa, mutt_get_name ((*ppa)->env->from), sizeof (fa));
+  fa[sizeof (fa) - 1] = '\0';
 
-  strncpy(fb,mutt_get_name ((*ppb)->env->from),sizeof(fb));
-  fb[sizeof(fb)-1] = '\0';
+  strncpy (fb, mutt_get_name ((*ppb)->env->from), sizeof (fb));
+  fb[sizeof (fb) - 1] = '\0';
 
   result = mutt_strcasecmp (fa, fb);
-  AUXSORT(result,a,b);
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -159,7 +161,8 @@ int compare_date_received (const void *a, const void *b)
   HEADER **pa = (HEADER **) a;
   HEADER **pb = (HEADER **) b;
   int result = (*pa)->received - (*pb)->received;
-  AUXSORT(result,a,b);
+
+  AUXSORT (result, a, b);
   return (SORTCODE (result));
 }
 
@@ -169,25 +172,25 @@ int compare_order (const void *a, const void *b)
   HEADER **hb = (HEADER **) b;
 
 #ifdef USE_NNTP
-  if ((*ha)->article_num && (*hb)->article_num)
-  {
+  if ((*ha)->article_num && (*hb)->article_num) {
     int result = (*ha)->article_num - (*hb)->article_num;
-    AUXSORT(result,a,b);
+
+    AUXSORT (result, a, b);
     return (SORTCODE (result));
   }
   else
 #endif
-  /* no need to auxsort because you will never have equality here */
-  return (SORTCODE ((*ha)->index - (*hb)->index));
+    /* no need to auxsort because you will never have equality here */
+    return (SORTCODE ((*ha)->index - (*hb)->index));
 }
 
 int compare_spam (const void *a, const void *b)
 {
   HEADER **ppa = (HEADER **) a;
   HEADER **ppb = (HEADER **) b;
-  char   *aptr, *bptr;
-  int     ahas, bhas;
-  int     result = 0;
+  char *aptr, *bptr;
+  int ahas, bhas;
+  int result = 0;
 
   /* Firstly, require spam attributes for both msgs */
   /* to compare. Determine which msgs have one.     */
@@ -196,105 +199,99 @@ int compare_spam (const void *a, const void *b)
 
   /* If one msg has spam attr but other does not, sort the one with first. */
   if (ahas && !bhas)
-    return (SORTCODE(1));
+    return (SORTCODE (1));
   if (!ahas && bhas)
-    return (SORTCODE(-1));
+    return (SORTCODE (-1));
 
   /* Else, if neither has a spam attr, presume equality. Fall back on aux. */
-  if (!ahas && !bhas)
-  {
-    AUXSORT(result, a, b);
-    return (SORTCODE(result));
+  if (!ahas && !bhas) {
+    AUXSORT (result, a, b);
+    return (SORTCODE (result));
   }
 
 
   /* Both have spam attrs. */
 
   /* preliminary numeric examination */
-  result = (strtoul((*ppa)->env->spam->data, &aptr, 10) -
-            strtoul((*ppb)->env->spam->data, &bptr, 10));
+  result = (strtoul ((*ppa)->env->spam->data, &aptr, 10) -
+            strtoul ((*ppb)->env->spam->data, &bptr, 10));
 
   /* If either aptr or bptr is equal to data, there is no numeric    */
   /* value for that spam attribute. In this case, compare lexically. */
   if ((aptr == (*ppa)->env->spam->data) || (bptr == (*ppb)->env->spam->data))
-    return (SORTCODE(strcmp(aptr, bptr)));
+    return (SORTCODE (strcmp (aptr, bptr)));
 
   /* Otherwise, we have numeric value for both attrs. If these values */
   /* are equal, then we first fall back upon string comparison, then  */
   /* upon auxiliary sort.                                             */
-  if (result == 0)
-  {
-    result = strcmp(aptr, bptr);
+  if (result == 0) {
+    result = strcmp (aptr, bptr);
     if (result == 0)
-      AUXSORT(result, a, b);
+      AUXSORT (result, a, b);
   }
 
-  return (SORTCODE(result));
+  return (SORTCODE (result));
 }
 
 sort_t *mutt_get_sort_func (int method)
 {
-  switch (method & SORT_MASK)
-  {
-    case SORT_RECEIVED:
-      return (compare_date_received);
-    case SORT_ORDER:
-      return (compare_order);
-    case SORT_DATE:
-      return (compare_date_sent);
-    case SORT_SUBJECT:
-      return (compare_subject);
-    case SORT_FROM:
-      return (compare_from);
-    case SORT_SIZE:
-      return (compare_size);
-    case SORT_TO:
-      return (compare_to);
-    case SORT_SCORE:
-      return (compare_score);
-    case SORT_SPAM:
-      return (compare_spam);
-    default:
-      return (NULL);
+  switch (method & SORT_MASK) {
+  case SORT_RECEIVED:
+    return (compare_date_received);
+  case SORT_ORDER:
+    return (compare_order);
+  case SORT_DATE:
+    return (compare_date_sent);
+  case SORT_SUBJECT:
+    return (compare_subject);
+  case SORT_FROM:
+    return (compare_from);
+  case SORT_SIZE:
+    return (compare_size);
+  case SORT_TO:
+    return (compare_to);
+  case SORT_SCORE:
+    return (compare_score);
+  case SORT_SPAM:
+    return (compare_spam);
+  default:
+    return (NULL);
   }
   /* not reached */
 }
 
-void mutt_sort_headers (CONTEXT *ctx, int init)
+void mutt_sort_headers (CONTEXT * ctx, int init)
 {
   int i;
   HEADER *h;
   THREAD *thread, *top;
   sort_t *sortfunc;
-  
+
   unset_option (OPTNEEDRESORT);
 
   if (!ctx)
     return;
 
-  if (!ctx->msgcount)
-  {
+  if (!ctx->msgcount) {
     /* this function gets called by mutt_sync_mailbox(), which may have just
      * deleted all the messages.  the virtual message numbers are not updated
      * in that routine, so we must make sure to zero the vcount member.
      */
     ctx->vcount = 0;
     mutt_clear_threads (ctx);
-    return; /* nothing to do! */
+    return;                     /* nothing to do! */
   }
 
   if (!ctx->quiet)
     mutt_message _("Sorting mailbox...");
 
-  if (option (OPTNEEDRESCORE) && option (OPTSCORE))
-  {
+  if (option (OPTNEEDRESCORE) && option (OPTSCORE)) {
     for (i = 0; i < ctx->msgcount; i++)
       mutt_score_message (ctx, ctx->hdrs[i], 1);
   }
   unset_option (OPTNEEDRESCORE);
 
-  if (option (OPTRESORTINIT))
-  {
+  if (option (OPTRESORTINIT)) {
     unset_option (OPTRESORTINIT);
     init = 1;
   }
@@ -302,39 +299,37 @@ void mutt_sort_headers (CONTEXT *ctx, int init)
   if (init && ctx->tree)
     mutt_clear_threads (ctx);
 
-  if ((Sort & SORT_MASK) == SORT_THREADS)
-  {
+  if ((Sort & SORT_MASK) == SORT_THREADS) {
     AuxSort = NULL;
     /* if $sort_aux changed after the mailbox is sorted, then all the
        subthreads need to be resorted */
-    if (option (OPTSORTSUBTHREADS))
-    {
+    if (option (OPTSORTSUBTHREADS)) {
       i = Sort;
       Sort = SortAux;
       if (ctx->tree)
-       ctx->tree = mutt_sort_subthreads (ctx->tree, 1);
+        ctx->tree = mutt_sort_subthreads (ctx->tree, 1);
       Sort = i;
       unset_option (OPTSORTSUBTHREADS);
     }
     mutt_sort_threads (ctx, init);
   }
   else if ((sortfunc = mutt_get_sort_func (Sort)) == NULL ||
-          (AuxSort = mutt_get_sort_func (SortAux)) == NULL)
-  {
+           (AuxSort = mutt_get_sort_func (SortAux)) == NULL) {
     mutt_error _("Could not find sorting function! [report this bug]");
+
     mutt_sleep (1);
     return;
   }
-  else 
+  else
     qsort ((void *) ctx->hdrs, ctx->msgcount, sizeof (HEADER *), sortfunc);
 
   /* adjust the virtual message numbers */
   ctx->vcount = 0;
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     HEADER *cur = ctx->hdrs[i];
-    if (cur->virtual != -1 || (cur->collapsed && (!ctx->pattern || cur->limited)))
-    {
+
+    if (cur->virtual != -1
+        || (cur->collapsed && (!ctx->pattern || cur->limited))) {
       cur->virtual = ctx->vcount;
       ctx->v2r[ctx->vcount] = i;
       ctx->vcount++;
@@ -343,17 +338,15 @@ void mutt_sort_headers (CONTEXT *ctx, int init)
   }
 
   /* re-collapse threads marked as collapsed */
-  if ((Sort & SORT_MASK) == SORT_THREADS)
-  {
+  if ((Sort & SORT_MASK) == SORT_THREADS) {
     top = ctx->tree;
-    while ((thread = top) != NULL)
-    {
+    while ((thread = top) != NULL) {
       while (!thread->message)
-       thread = thread->child;
+        thread = thread->child;
       h = thread->message;
 
       if (h->collapsed)
-       mutt_collapse_thread (ctx, h);
+        mutt_collapse_thread (ctx, h);
       top = top->next;
     }
     mutt_set_virtual (ctx);
diff --git a/sort.h b/sort.h
index 880fb9d..108e440 100644 (file)
--- a/sort.h
+++ b/sort.h
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
-#define SORT_DATE      1   /* the date the mail was sent. */
+#define SORT_DATE      1       /* the date the mail was sent. */
 #define SORT_SIZE      2
 #define SORT_SUBJECT   3
-#define SORT_ALPHA     3   /* makedoc.c requires this */
+#define SORT_ALPHA     3       /* makedoc.c requires this */
 #define SORT_FROM      4
-#define SORT_ORDER     5   /* the order the messages appear in the mailbox. */
+#define SORT_ORDER     5       /* the order the messages appear in the mailbox. */
 #define SORT_THREADS   6
-#define SORT_RECEIVED  7   /* when the message were delivered locally */
+#define SORT_RECEIVED  7       /* when the message were delivered locally */
 #define SORT_TO                8
 #define SORT_SCORE     9
 #define SORT_ALIAS     10
@@ -48,7 +48,7 @@ THREAD *mutt_sort_subthreads (THREAD *, int);
 
 WHERE short BrowserSort INITVAL (SORT_SUBJECT);
 WHERE short Sort INITVAL (SORT_DATE);
-WHERE short SortAux INITVAL (SORT_DATE); /* auxiallary sorting method */
+WHERE short SortAux INITVAL (SORT_DATE);        /* auxiallary sorting method */
 WHERE short SortAlias INITVAL (SORT_ALIAS);
 
 /* FIXME: This one does not belong to here */
index 42d4fce..f0b3c3a 100644 (file)
--- a/status.c
+++ b/status.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -34,9 +34,9 @@
 static char *get_sort_str (char *buf, size_t buflen, int method)
 {
   snprintf (buf, buflen, "%s%s%s",
-           (method & SORT_REVERSE) ? "reverse-" : "",
-           (method & SORT_LAST) ? "last-" : "",
-           mutt_getnamebyvalue (method & SORT_MASK, SortMethods));
+            (method & SORT_REVERSE) ? "reverse-" : "",
+            (method & SORT_LAST) ? "last-" : "",
+            mutt_getnamebyvalue (method & SORT_MASK, SortMethods));
   return buf;
 }
 
@@ -58,264 +58,252 @@ static char *get_sort_str (char *buf, size_t buflen, int method)
  * %t = # of tagged messages [option]
  * %v = Mutt-ng version 
  * %V = currently active limit pattern [option] */
-static const char *
-status_format_str (char *buf, size_t buflen, char op, const char *src,
-                  const char *prefix, const char *ifstring,
-                  const char *elsestring,
-                  unsigned long data, format_flag flags)
+static const char *status_format_str (char *buf, size_t buflen, char op,
+                                      const char *src, const char *prefix,
+                                      const char *ifstring,
+                                      const char *elsestring,
+                                      unsigned long data, format_flag flags)
 {
   char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp, *p;
   int count, optional = (flags & M_FORMAT_OPTIONAL);
   MUTTMENU *menu = (MUTTMENU *) data;
 
   *buf = 0;
-  switch (op)
-  {
-    case 'b':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, mutt_buffy_check (0));
-      }
-      else if (!mutt_buffy_check (0))
-       optional = 0;
-      break;
+  switch (op) {
+  case 'b':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, mutt_buffy_check (0));
+    }
+    else if (!mutt_buffy_check (0))
+      optional = 0;
+    break;
 
-    case 'B':
-      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+  case 'B':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
 #ifdef USE_COMPRESSED
-      if (Context && Context->compressinfo && Context->realpath)
-      {
-       if ((p = strrchr (Context->realpath, '/')))
-         strfcpy (tmp, p + 1, sizeof (tmp));
-       else
-         strfcpy (tmp, Context->realpath, sizeof (tmp));
-      } 
+    if (Context && Context->compressinfo && Context->realpath) {
+      if ((p = strrchr (Context->realpath, '/')))
+        strfcpy (tmp, p + 1, sizeof (tmp));
       else
+        strfcpy (tmp, Context->realpath, sizeof (tmp));
+    }
+    else
 #endif
-      if (Context && Context->path)
-      {
-       if ((p = strrchr (Context->path, '/')))
-         strfcpy (tmp, p + 1, sizeof (tmp));
-       else
-         strfcpy (tmp, Context->path, sizeof (tmp));
-      }
+    if (Context && Context->path) {
+      if ((p = strrchr (Context->path, '/')))
+        strfcpy (tmp, p + 1, sizeof (tmp));
       else
-         strfcpy (tmp, _("no mailbox"), sizeof (tmp));
-      snprintf (buf, buflen, fmt, tmp);
-      break;
-
-    case 'd':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->deleted : 0);
-      }
-      else if (!Context || !Context->deleted)
-       optional = 0;
-      break;
+        strfcpy (tmp, Context->path, sizeof (tmp));
+    }
+    else
+      strfcpy (tmp, _("no mailbox"), sizeof (tmp));
+    snprintf (buf, buflen, fmt, tmp);
+    break;
+
+  case 'd':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->deleted : 0);
+    }
+    else if (!Context || !Context->deleted)
+      optional = 0;
+    break;
 
-    case 'h':
-      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (buf, buflen, fmt, NONULL(Hostname));
-      break;
+  case 'h':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (buf, buflen, fmt, NONULL (Hostname));
+    break;
 
-    case 'f':
-      snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
+  case 'f':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
 #ifdef USE_COMPRESSED
-      if (Context && Context->compressinfo && Context->realpath)
-      {
-        strfcpy (tmp, Context->realpath, sizeof (tmp));
-        mutt_pretty_mailbox (tmp);
-      }
-      else
+    if (Context && Context->compressinfo && Context->realpath) {
+      strfcpy (tmp, Context->realpath, sizeof (tmp));
+      mutt_pretty_mailbox (tmp);
+    }
+    else
 #endif
-      if (Context && Context->path)
-      {
-       strfcpy (tmp, Context->path, sizeof (tmp));
-       mutt_pretty_mailbox (tmp);
-      }
-      else
-       strfcpy (tmp, _("(no mailbox)"), sizeof (tmp));
-      snprintf (buf, buflen, fmt, tmp);
-      break;
-
-    case 'F':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->flagged : 0);
-      }
-      else if (!Context || !Context->flagged)
-       optional = 0;
-      break;
-
-    case 'l':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       mutt_pretty_size (tmp, sizeof (tmp), Context ? Context->size : 0);
-       snprintf (buf, buflen, fmt, tmp);
-      }
-      else if (!Context || !Context->size)
-       optional = 0;
-      break;
-
-    case 'L':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-       mutt_pretty_size (tmp, sizeof (tmp), Context ? Context->vsize: 0);
-       snprintf (buf, buflen, fmt, tmp);
-      }
-      else if (!Context || !Context->pattern)
-       optional = 0;
-      break;
-
-    case 'm':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->msgcount : 0);
-      }
-      else if (!Context || !Context->msgcount)
-       optional = 0;
-      break;
-
-    case 'M':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof(fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->vcount : 0);
-      }
-      else if (!Context || !Context->pattern)
-       optional = 0;
-      break;
-
-    case 'n':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->new : 0);
-      }
-      else if (!Context || Context->new <= 0)
-       optional = 0;
-      break;
-
-    case 'o':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->unread - Context->new : 0);
-      }
-      else if (!Context || !(Context->unread - Context->new))
-       optional = 0;
-      break;
+    if (Context && Context->path) {
+      strfcpy (tmp, Context->path, sizeof (tmp));
+      mutt_pretty_mailbox (tmp);
+    }
+    else
+      strfcpy (tmp, _("(no mailbox)"), sizeof (tmp));
+    snprintf (buf, buflen, fmt, tmp);
+    break;
+
+  case 'F':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->flagged : 0);
+    }
+    else if (!Context || !Context->flagged)
+      optional = 0;
+    break;
 
-    case 'p':
-      count = mutt_num_postponed (0);
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, count);
-      }
-      else if (!count)
-       optional = 0;
-      break;
+  case 'l':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      mutt_pretty_size (tmp, sizeof (tmp), Context ? Context->size : 0);
+      snprintf (buf, buflen, fmt, tmp);
+    }
+    else if (!Context || !Context->size)
+      optional = 0;
+    break;
 
-    case 'P':
-      if (menu->top + menu->pagelen >= menu->max)
-       cp = menu->top ? "end" : "all";
-      else
-      {
-       count = (100 * (menu->top + menu->pagelen)) / menu->max;
-       snprintf (tmp, sizeof (tmp), "%d%%", count);
-       cp = tmp;
-      }
+  case 'L':
+    if (!optional) {
       snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (buf, buflen, fmt, cp);
-      break;
+      mutt_pretty_size (tmp, sizeof (tmp), Context ? Context->vsize : 0);
+      snprintf (buf, buflen, fmt, tmp);
+    }
+    else if (!Context || !Context->pattern)
+      optional = 0;
+    break;
+
+  case 'm':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->msgcount : 0);
+    }
+    else if (!Context || !Context->msgcount)
+      optional = 0;
+    break;
+
+  case 'M':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->vcount : 0);
+    }
+    else if (!Context || !Context->pattern)
+      optional = 0;
+    break;
+
+  case 'n':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->new : 0);
+    }
+    else if (!Context || Context->new <= 0)
+      optional = 0;
+    break;
+
+  case 'o':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt,
+                Context ? Context->unread - Context->new : 0);
+    }
+    else if (!Context || !(Context->unread - Context->new))
+      optional = 0;
+    break;
+
+  case 'p':
+    count = mutt_num_postponed (0);
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, count);
+    }
+    else if (!count)
+      optional = 0;
+    break;
+
+  case 'P':
+    if (menu->top + menu->pagelen >= menu->max)
+      cp = menu->top ? "end" : "all";
+    else {
+      count = (100 * (menu->top + menu->pagelen)) / menu->max;
+      snprintf (tmp, sizeof (tmp), "%d%%", count);
+      cp = tmp;
+    }
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (buf, buflen, fmt, cp);
+    break;
 
-    case 'r':
+  case 'r':
     {
       int i = 0;
 
-      if (Context)
-      {
-       i = option(OPTATTACHMSG) ? 3 : ((Context->readonly ||
-          Context->dontwrite) ? 2 : (Context->changed || (
+      if (Context) {
+        i = option (OPTATTACHMSG) ? 3 : ((Context->readonly ||
+                                          Context->dontwrite) ? 2 : (Context->
+                                                                     changed
+                                                                     || (
 #ifdef USE_IMAP
-        /* deleted doesn't necessarily mean changed in IMAP */
-          Context->magic != M_IMAP &&
+                                                                             /* deleted doesn't necessarily mean changed in IMAP */
+                                                                             Context->
+                                                                             magic
+                                                                             !=
+                                                                             M_IMAP
+                                                                             &&
 #endif
-          Context->deleted)) ? 1 : 0);
+                                                                             Context->
+                                                                             deleted))
+                                         ? 1 : 0);
       }
-      
+
       if (!StChars)
-       buf[0] = 0;
-      else if (i >= mutt_strlen(StChars))
-       buf[0] = StChars[0];
+        buf[0] = 0;
+      else if (i >= mutt_strlen (StChars))
+        buf[0] = StChars[0];
       else
-       buf[0] = StChars[i];
+        buf[0] = StChars[i];
 
       buf[1] = 0;
       break;
     }
-      
-    case 's':
-      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (buf, buflen, fmt,
-               get_sort_str (tmp, sizeof (tmp), Sort));
-      break;
 
-    case 'S':
-      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
-      snprintf (buf, buflen, fmt,
-               get_sort_str (tmp, sizeof (tmp), SortAux));
-      break;
+  case 's':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (buf, buflen, fmt, get_sort_str (tmp, sizeof (tmp), Sort));
+    break;
 
-    case 't':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->tagged : 0);
-      }
-      else if (!Context || !Context->tagged)
-       optional = 0;
-      break;
+  case 'S':
+    snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+    snprintf (buf, buflen, fmt, get_sort_str (tmp, sizeof (tmp), SortAux));
+    break;
 
-    case 'u':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       snprintf (buf, buflen, fmt, Context ? Context->unread : 0);
-      }
-      else if (!Context || !Context->unread)
-       optional = 0;
-      break;
+  case 't':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->tagged : 0);
+    }
+    else if (!Context || !Context->tagged)
+      optional = 0;
+    break;
+
+  case 'u':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+      snprintf (buf, buflen, fmt, Context ? Context->unread : 0);
+    }
+    else if (!Context || !Context->unread)
+      optional = 0;
+    break;
 
-    case 'v':
-      snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
-      snprintf (buf, buflen, fmt, MUTT_VERSION);
-      break;
+  case 'v':
+    snprintf (fmt, sizeof (fmt), "Mutt-ng %%s");
+    snprintf (buf, buflen, fmt, MUTT_VERSION);
+    break;
 
-    case 'V':
-      if (!optional)
-      {
-       snprintf (fmt, sizeof(fmt), "%%%ss", prefix);
-       snprintf (buf, buflen, fmt, (Context && Context->pattern) ? Context->pattern : "");
-      }
-      else if (!Context || !Context->pattern)
-       optional = 0;
-      break;
+  case 'V':
+    if (!optional) {
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+      snprintf (buf, buflen, fmt,
+                (Context && Context->pattern) ? Context->pattern : "");
+    }
+    else if (!Context || !Context->pattern)
+      optional = 0;
+    break;
 
-    case 0:
-      *buf = 0;
-      return (src);
+  case 0:
+    *buf = 0;
+    return (src);
 
-    default:
-      snprintf (buf, buflen, "%%%s%c", prefix, op);
-      break;
+  default:
+    snprintf (buf, buflen, "%%%s%c", prefix, op);
+    break;
   }
 
   if (optional)
@@ -326,7 +314,9 @@ status_format_str (char *buf, size_t buflen, char op, const char *src,
   return (src);
 }
 
-void menu_status_line (char *buf, size_t buflen, MUTTMENU *menu, const char *p)
+void menu_status_line (char *buf, size_t buflen, MUTTMENU * menu,
+                       const char *p)
 {
-  mutt_FormatString (buf, buflen, p, status_format_str, (unsigned long) menu, 0);
+  mutt_FormatString (buf, buflen, p, status_format_str, (unsigned long) menu,
+                     0);
 }
index 51e6e10..030f220 100644 (file)
@@ -6,9 +6,8 @@
 int strncasecmp (char *s1, char *s2, size_t n)
 {
   register int c1, c2, l = 0;
-  
-  while (*s1 && *s2 && l < n)
-  {
+
+  while (*s1 && *s2 && l < n) {
     c1 = tolower ((unsigned char) *s1);
     c2 = tolower ((unsigned char) *s2);
     if (c1 != c2)
@@ -26,15 +25,14 @@ int strncasecmp (char *s1, char *s2, size_t n)
 int strcasecmp (char *s1, char *s2)
 {
   register int c1, c2;
-  
-  while (*s1 && *s2)
-  {
+
+  while (*s1 && *s2) {
     c1 = tolower ((unsigned char) *s1);
     c2 = tolower ((unsigned char) *s2);
     if (c1 != c2)
       return (c1 - c2);
     s1++;
     s2++;
-  }                                                                           
+  }
   return (int) (*s1 - *s2);
 }
index 0249a05..a240d82 100644 (file)
--- a/strdup.c
+++ b/strdup.c
@@ -3,17 +3,16 @@
 #include <string.h>
 #include <stdlib.h>
 
-char *strdup (const char *s)   /* __MEM_CHECKED__ */
-{
+char *strdup (const char *s)
+{                               /* __MEM_CHECKED__ */
   char *d;
-  
+
   if (s == NULL)
     return NULL;
-  
-  if ((d = malloc (strlen (s) + 1)) == NULL)   /* __MEM_CHECKED__ */
+
+  if ((d = malloc (strlen (s) + 1)) == NULL)    /* __MEM_CHECKED__ */
     return NULL;
 
   memcpy (d, s, strlen (s) + 1);
   return d;
 }
-
index f5674fd..d34f2be 100644 (file)
--- a/system.c
+++ b/system.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
@@ -49,14 +49,12 @@ int _mutt_system (const char *cmd, int flags)
   mutt_block_signals_system ();
 
   /* also don't want to be stopped right now */
-  if (flags & M_DETACH_PROCESS)
-  {
+  if (flags & M_DETACH_PROCESS) {
     sigemptyset (&set);
     sigaddset (&set, SIGTSTP);
     sigprocmask (SIG_BLOCK, &set, NULL);
   }
-  else
-  {
+  else {
     act.sa_handler = SIG_DFL;
     /* we want to restart the waitpid() below */
 #ifdef SA_RESTART
@@ -67,41 +65,38 @@ int _mutt_system (const char *cmd, int flags)
     sigaction (SIGCONT, &act, &oldcont);
   }
 
-  if ((thepid = fork ()) == 0)
-  {
+  if ((thepid = fork ()) == 0) {
     act.sa_flags = 0;
 
-    if (flags & M_DETACH_PROCESS)
-    {
+    if (flags & M_DETACH_PROCESS) {
       int fd;
 
       /* give up controlling terminal */
       setsid ();
 
-      switch (fork ())
-      {
-       case 0:
+      switch (fork ()) {
+      case 0:
 #if defined(OPEN_MAX)
-         for (fd = 0; fd < OPEN_MAX; fd++)
-           close (fd);
+        for (fd = 0; fd < OPEN_MAX; fd++)
+          close (fd);
 #elif defined(_POSIX_OPEN_MAX)
-         for (fd = 0; fd < _POSIX_OPEN_MAX; fd++)
-           close (fd);
+        for (fd = 0; fd < _POSIX_OPEN_MAX; fd++)
+          close (fd);
 #else
-         close (0);
-         close (1);
-         close (2);
+        close (0);
+        close (1);
+        close (2);
 #endif
-         chdir ("/");
-         act.sa_handler = SIG_DFL;
-         sigaction (SIGCHLD, &act, NULL);
-         break;
+        chdir ("/");
+        act.sa_handler = SIG_DFL;
+        sigaction (SIGCHLD, &act, NULL);
+        break;
 
-       case -1:
-         _exit (127);
+      case -1:
+        _exit (127);
 
-       default:
-         _exit (0);
+      default:
+        _exit (0);
       }
     }
 
@@ -115,10 +110,9 @@ int _mutt_system (const char *cmd, int flags)
     sigaction (SIGCONT, &act, NULL);
 
     execl (EXECSHELL, "sh", "-c", cmd, NULL);
-    _exit (127); /* execl error */
+    _exit (127);                /* execl error */
   }
-  else if (thepid != -1)
-  {
+  else if (thepid != -1) {
 #ifndef USE_IMAP
     /* wait for the (first) child process to finish */
     waitpid (thepid, &rc, 0);
index 29e876d..9da0e5b 100644 (file)
--- a/thread.c
+++ b/thread.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #define VISIBLE(hdr, ctx) (hdr->virtual >= 0 || (hdr->collapsed && (!ctx->pattern || hdr->limited)))
 
 /* determine whether a is a descendant of b */
-static int is_descendant (THREAD *a, THREAD *b)
+static int is_descendant (THREAD * a, THREAD * b)
 {
-  while (a)
-  {
+  while (a) {
     if (a == b)
       return (1);
     a = a->parent;
@@ -41,7 +40,7 @@ static int is_descendant (THREAD *a, THREAD *b)
 }
 
 /* Determines whether to display a message's subject. */
-static int need_display_subject (CONTEXT *ctx, HEADER *hdr)
+static int need_display_subject (CONTEXT * ctx, HEADER * hdr)
 {
   THREAD *tmp, *tree = hdr->thread;
 
@@ -55,29 +54,25 @@ static int need_display_subject (CONTEXT *ctx, HEADER *hdr)
 
   /* if our subject is different from that of our closest previously displayed
    * sibling, display the subject */
-  for (tmp = tree->prev; tmp; tmp = tmp->prev)
-  {
+  for (tmp = tree->prev; tmp; tmp = tmp->prev) {
     hdr = tmp->message;
-    if (hdr && VISIBLE (hdr, ctx))
-    {
+    if (hdr && VISIBLE (hdr, ctx)) {
       if (hdr->subject_changed)
-       return (1);
+        return (1);
       else
-       break;
+        break;
     }
   }
-  
+
   /* if there is a parent-to-child subject change anywhere between us and our
    * closest displayed ancestor, display the subject */
-  for (tmp = tree->parent; tmp; tmp = tmp->parent)
-  {
+  for (tmp = tree->parent; tmp; tmp = tmp->parent) {
     hdr = tmp->message;
-    if (hdr)
-    {
+    if (hdr) {
       if (VISIBLE (hdr, ctx))
-       return (0);
+        return (0);
       else if (hdr->subject_changed)
-       return (1);
+        return (1);
     }
   }
 
@@ -85,13 +80,12 @@ static int need_display_subject (CONTEXT *ctx, HEADER *hdr)
   return (1);
 }
 
-static void linearize_tree (CONTEXT *ctx)
+static void linearize_tree (CONTEXT * ctx)
 {
   THREAD *tree = ctx->tree;
   HEADER **array = ctx->hdrs + (Sort & SORT_REVERSE ? ctx->msgcount - 1 : 0);
 
-  while (tree)
-  {
+  while (tree) {
     while (!tree->message)
       tree = tree->child;
 
@@ -100,17 +94,14 @@ static void linearize_tree (CONTEXT *ctx)
 
     if (tree->child)
       tree = tree->child;
-    else
-    {
-      while (tree)
-      {
-       if (tree->next)
-       {
-         tree = tree->next;
-         break;
-       }
-       else
-         tree = tree->parent;
+    else {
+      while (tree) {
+        if (tree->next) {
+          tree = tree->next;
+          break;
+        }
+        else
+          tree = tree->parent;
       }
     }
   }
@@ -123,11 +114,13 @@ static void linearize_tree (CONTEXT *ctx)
  * skip parts of the tree in mutt_draw_tree() if we've decided here that we
  * don't care about them any more.
  */
-static void calculate_visibility (CONTEXT *ctx, int *max_depth)
+static void calculate_visibility (CONTEXT * ctx, int *max_depth)
 {
   THREAD *tmp, *tree = ctx->tree;
-  int hide_top_missing = option (OPTHIDETOPMISSING) && !option (OPTHIDEMISSING);
-  int hide_top_limited = option (OPTHIDETOPLIMITED) && !option (OPTHIDELIMITED);
+  int hide_top_missing = option (OPTHIDETOPMISSING)
+    && !option (OPTHIDEMISSING);
+  int hide_top_limited = option (OPTHIDETOPLIMITED)
+    && !option (OPTHIDELIMITED);
   int depth = 0;
 
   /* we walk each level backwards to make it easier to compute next_subtree_visible */
@@ -135,89 +128,78 @@ static void calculate_visibility (CONTEXT *ctx, int *max_depth)
     tree = tree->next;
   *max_depth = 0;
 
-  FOREVER
-  {
+  FOREVER {
     if (depth > *max_depth)
       *max_depth = depth;
 
     tree->subtree_visible = 0;
-    if (tree->message)
-    {
+    if (tree->message) {
       FREE (&tree->message->tree);
-      if (VISIBLE (tree->message, ctx))
-      {
-       tree->deep = 1;
-       tree->visible = 1;
-       tree->message->display_subject = need_display_subject (ctx, tree->message);
-       for (tmp = tree; tmp; tmp = tmp->parent)
-       {
-         if (tmp->subtree_visible)
-         {
-           tmp->deep = 1;
-           tmp->subtree_visible = 2;
-           break;
-         }
-         else
-           tmp->subtree_visible = 1;
-       }
+      if (VISIBLE (tree->message, ctx)) {
+        tree->deep = 1;
+        tree->visible = 1;
+        tree->message->display_subject =
+          need_display_subject (ctx, tree->message);
+        for (tmp = tree; tmp; tmp = tmp->parent) {
+          if (tmp->subtree_visible) {
+            tmp->deep = 1;
+            tmp->subtree_visible = 2;
+            break;
+          }
+          else
+            tmp->subtree_visible = 1;
+        }
       }
-      else
-      {
-       tree->visible = 0;
-       tree->deep = !option (OPTHIDELIMITED);
+      else {
+        tree->visible = 0;
+        tree->deep = !option (OPTHIDELIMITED);
       }
     }
-    else
-    {
+    else {
       tree->visible = 0;
       tree->deep = !option (OPTHIDEMISSING);
     }
-    tree->next_subtree_visible = tree->next && (tree->next->next_subtree_visible
-                                               || tree->next->subtree_visible);
-    if (tree->child)
-    {
+    tree->next_subtree_visible = tree->next
+      && (tree->next->next_subtree_visible || tree->next->subtree_visible);
+    if (tree->child) {
       depth++;
       tree = tree->child;
       while (tree->next)
-       tree = tree->next;
+        tree = tree->next;
     }
     else if (tree->prev)
       tree = tree->prev;
-    else
-    {
-      while (tree && !tree->prev)
-      {
-       depth--;
-       tree = tree->parent;
+    else {
+      while (tree && !tree->prev) {
+        depth--;
+        tree = tree->parent;
       }
       if (!tree)
-       break;
+        break;
       else
-       tree = tree->prev;
+        tree = tree->prev;
     }
   }
-  
+
   /* now fix up for the OPTHIDETOP* options if necessary */
-  if (hide_top_limited || hide_top_missing)
-  {
+  if (hide_top_limited || hide_top_missing) {
     tree = ctx->tree;
-    FOREVER
-    {
-      if (!tree->visible && tree->deep && tree->subtree_visible < 2 
-         && ((tree->message && hide_top_limited) || (!tree->message && hide_top_missing)))
-       tree->deep = 0;
+    FOREVER {
+      if (!tree->visible && tree->deep && tree->subtree_visible < 2
+          && ((tree->message && hide_top_limited)
+              || (!tree->message && hide_top_missing)))
+        tree->deep = 0;
       if (!tree->deep && tree->child && tree->subtree_visible)
-       tree = tree->child;
+        tree = tree->child;
       else if (tree->next)
-       tree = tree->next;
-      else
-      {
-       while (tree && !tree->next)
-         tree = tree->parent;
-       if (!tree)
-         break;
-       else
-         tree = tree->next;
+        tree = tree->next;
+      else {
+        while (tree && !tree->next)
+          tree = tree->parent;
+        if (!tree)
+          break;
+        else
+          tree = tree->next;
       }
     }
   }
@@ -231,12 +213,13 @@ static void calculate_visibility (CONTEXT *ctx, int *max_depth)
  * graphics chars on terminals which don't support them (see the man page
  * for curs_addch).
  */
-void mutt_draw_tree (CONTEXT *ctx)
+void mutt_draw_tree (CONTEXT * ctx)
 {
   char *pfx = NULL, *mypfx = NULL, *arrow = NULL, *myarrow = NULL, *new_tree;
   char corner = (Sort & SORT_REVERSE) ? M_TREE_ULCORNER : M_TREE_LLCORNER;
   char vtee = (Sort & SORT_REVERSE) ? M_TREE_BTEE : M_TREE_TTEE;
-  int depth = 0, start_depth = 0, max_depth = 0, width = option (OPTNARROWTREE) ? 1 : 2;
+  int depth = 0, start_depth = 0, max_depth = 0, width =
+    option (OPTNARROWTREE) ? 1 : 2;
   THREAD *nextdisp = NULL, *pseudo = NULL, *parent = NULL, *tree = ctx->tree;
 
   /* Do the visibility calculations and free the old thread chars.
@@ -245,96 +228,86 @@ void mutt_draw_tree (CONTEXT *ctx)
   calculate_visibility (ctx, &max_depth);
   pfx = safe_malloc (width * max_depth + 2);
   arrow = safe_malloc (width * max_depth + 2);
-  while (tree)
-  {
-    if (depth)
-    {
+  while (tree) {
+    if (depth) {
       myarrow = arrow + (depth - start_depth - (start_depth ? 0 : 1)) * width;
       if (depth && start_depth == depth)
-       myarrow[0] = nextdisp ? M_TREE_LTEE : corner;
+        myarrow[0] = nextdisp ? M_TREE_LTEE : corner;
       else if (parent->message && !option (OPTHIDELIMITED))
-       myarrow[0] = M_TREE_HIDDEN;
+        myarrow[0] = M_TREE_HIDDEN;
       else if (!parent->message && !option (OPTHIDEMISSING))
-       myarrow[0] = M_TREE_MISSING;
+        myarrow[0] = M_TREE_MISSING;
       else
-       myarrow[0] = vtee;
+        myarrow[0] = vtee;
       if (width == 2)
-       myarrow[1] = pseudo ?  M_TREE_STAR
-                            : (tree->duplicate_thread ? M_TREE_EQUALS : M_TREE_HLINE);
-      if (tree->visible)
-      {
-       myarrow[width] = M_TREE_RARROW;
-       myarrow[width + 1] = 0;
-       new_tree = safe_malloc ((2 + depth * width));
-       if (start_depth > 1)
-       {
-         strncpy (new_tree, pfx, (start_depth - 1) * width);
-         strfcpy (new_tree + (start_depth - 1) * width,
-                  arrow, (1 + depth - start_depth) * width + 2);
-       }
-       else
-         strfcpy (new_tree, arrow, 2 + depth * width);
-       tree->message->tree = new_tree;
+        myarrow[1] = pseudo ? M_TREE_STAR
+          : (tree->duplicate_thread ? M_TREE_EQUALS : M_TREE_HLINE);
+      if (tree->visible) {
+        myarrow[width] = M_TREE_RARROW;
+        myarrow[width + 1] = 0;
+        new_tree = safe_malloc ((2 + depth * width));
+        if (start_depth > 1) {
+          strncpy (new_tree, pfx, (start_depth - 1) * width);
+          strfcpy (new_tree + (start_depth - 1) * width,
+                   arrow, (1 + depth - start_depth) * width + 2);
+        }
+        else
+          strfcpy (new_tree, arrow, 2 + depth * width);
+        tree->message->tree = new_tree;
       }
     }
-    if (tree->child && depth)
-    {
+    if (tree->child && depth) {
       mypfx = pfx + (depth - 1) * width;
       mypfx[0] = nextdisp ? M_TREE_VLINE : M_TREE_SPACE;
       if (width == 2)
-       mypfx[1] = M_TREE_SPACE;
+        mypfx[1] = M_TREE_SPACE;
     }
     parent = tree;
     nextdisp = NULL;
     pseudo = NULL;
-    do
-    {
-      if (tree->child && tree->subtree_visible)
-      {
-       if (tree->deep)
-         depth++;
-       if (tree->visible)
-         start_depth = depth;
-       tree = tree->child;
-
-       /* we do this here because we need to make sure that the first child thread
-        * of the old tree that we deal with is actually displayed if any are,
-        * or we might set the parent variable wrong while going through it. */
-       while (!tree->subtree_visible && tree->next)
-         tree = tree->next;
+    do {
+      if (tree->child && tree->subtree_visible) {
+        if (tree->deep)
+          depth++;
+        if (tree->visible)
+          start_depth = depth;
+        tree = tree->child;
+
+        /* we do this here because we need to make sure that the first child thread
+         * of the old tree that we deal with is actually displayed if any are,
+         * or we might set the parent variable wrong while going through it. */
+        while (!tree->subtree_visible && tree->next)
+          tree = tree->next;
       }
-      else
-      {
-       while (!tree->next && tree->parent)
-       {
-         if (tree == pseudo)
-           pseudo = NULL;
-         if (tree == nextdisp)
-           nextdisp = NULL;
-         if (tree->visible)
-           start_depth = depth;
-         tree = tree->parent;
-         if (tree->deep)
-         {
-           if (start_depth == depth)
-             start_depth--;
-           depth--;
-         }
-       }
-       if (tree == pseudo)
-         pseudo = NULL;
-       if (tree == nextdisp)
-         nextdisp = NULL;
-       if (tree->visible)
-         start_depth = depth;
-       tree = tree->next;
-       if (!tree)
-         break;
+      else {
+        while (!tree->next && tree->parent) {
+          if (tree == pseudo)
+            pseudo = NULL;
+          if (tree == nextdisp)
+            nextdisp = NULL;
+          if (tree->visible)
+            start_depth = depth;
+          tree = tree->parent;
+          if (tree->deep) {
+            if (start_depth == depth)
+              start_depth--;
+            depth--;
+          }
+        }
+        if (tree == pseudo)
+          pseudo = NULL;
+        if (tree == nextdisp)
+          nextdisp = NULL;
+        if (tree->visible)
+          start_depth = depth;
+        tree = tree->next;
+        if (!tree)
+          break;
       }
       if (!pseudo && tree->fake_thread)
-       pseudo = tree;
+        pseudo = tree;
       if (!nextdisp && tree->next_subtree_visible)
-       nextdisp = tree;
+        nextdisp = tree;
     }
     while (!tree->deep);
   }
@@ -347,57 +320,49 @@ void mutt_draw_tree (CONTEXT *ctx)
  * has no message, we have to make a list of all the subjects of its
  * most immediate existing descendants.  we also note the earliest
  * date on any of the parents and put it in *dateptr. */
-static LIST *make_subject_list (THREAD *cur, time_t *dateptr)
+static LIST *make_subject_list (THREAD * cur, time_t * dateptr)
 {
   THREAD *start = cur;
   ENVELOPE *env;
   time_t thisdate;
   LIST *curlist, *oldlist, *newlist, *subjects = NULL;
   int rc = 0;
-  
-  FOREVER
-  {
+
+  FOREVER {
     while (!cur->message)
       cur = cur->child;
 
-    if (dateptr)
-    {
+    if (dateptr) {
       thisdate = option (OPTTHREADRECEIVED)
-       ? cur->message->received : cur->message->date_sent;
+        ? cur->message->received : cur->message->date_sent;
       if (!*dateptr || thisdate < *dateptr)
-       *dateptr = thisdate;
+        *dateptr = thisdate;
     }
 
     env = cur->message->env;
     if (env->real_subj &&
-       ((env->real_subj != env->subject) || (!option (OPTSORTRE))))
-    {
+        ((env->real_subj != env->subject) || (!option (OPTSORTRE)))) {
       for (curlist = subjects, oldlist = NULL;
-          curlist; oldlist = curlist, curlist = curlist->next)
-      {
-       rc = mutt_strcmp (env->real_subj, curlist->data);
-       if (rc >= 0)
-         break;
+           curlist; oldlist = curlist, curlist = curlist->next) {
+        rc = mutt_strcmp (env->real_subj, curlist->data);
+        if (rc >= 0)
+          break;
       }
-      if (!curlist || rc > 0)
-      {
-       newlist = safe_calloc (1, sizeof (LIST));
-       newlist->data = env->real_subj;
-       if (oldlist)
-       {
-         newlist->next = oldlist->next;
-         oldlist->next = newlist;
-       }
-       else
-       {
-         newlist->next = subjects;
-         subjects = newlist;
-       }
+      if (!curlist || rc > 0) {
+        newlist = safe_calloc (1, sizeof (LIST));
+        newlist->data = env->real_subj;
+        if (oldlist) {
+          newlist->next = oldlist->next;
+          oldlist->next = newlist;
+        }
+        else {
+          newlist->next = subjects;
+          subjects = newlist;
+        }
       }
     }
 
-    while (!cur->next && cur != start)
-    {
+    while (!cur->next && cur != start) {
       cur = cur->parent;
     }
     if (cur == start)
@@ -412,37 +377,35 @@ static LIST *make_subject_list (THREAD *cur, time_t *dateptr)
  * if there are multiple matches, the one which was sent the latest, but
  * before the current message, is used. 
  */
-static THREAD *find_subject (CONTEXT *ctx, THREAD *cur)
+static THREAD *find_subject (CONTEXT * ctx, THREAD * cur)
 {
   struct hash_elem *ptr;
   THREAD *tmp, *last = NULL;
   int hash;
   LIST *subjects = NULL, *oldlist;
-  time_t date = 0;  
+  time_t date = 0;
 
   subjects = make_subject_list (cur, &date);
 
-  while (subjects)
-  {
+  while (subjects) {
     hash = hash_string ((unsigned char *) subjects->data,
-                       ctx->subj_hash->nelem);
-    for (ptr = ctx->subj_hash->table[hash]; ptr; ptr = ptr->next)
-    {
+                        ctx->subj_hash->nelem);
+    for (ptr = ctx->subj_hash->table[hash]; ptr; ptr = ptr->next) {
       tmp = ((HEADER *) ptr->data)->thread;
-      if (tmp != cur &&                           /* don't match the same message */
-         !tmp->fake_thread &&             /* don't match pseudo threads */
-         tmp->message->subject_changed && /* only match interesting replies */
-         !is_descendant (tmp, cur) &&     /* don't match in the same thread */
-         (date >= (option (OPTTHREADRECEIVED) ?
-                   tmp->message->received :
-                   tmp->message->date_sent)) &&
-         (!last ||
-          (option (OPTTHREADRECEIVED) ?
-           (last->message->received < tmp->message->received) :
-           (last->message->date_sent < tmp->message->date_sent))) &&
-         tmp->message->env->real_subj &&
-         mutt_strcmp (subjects->data, tmp->message->env->real_subj) == 0)
-       last = tmp; /* best match so far */
+      if (tmp != cur &&         /* don't match the same message */
+          !tmp->fake_thread &&  /* don't match pseudo threads */
+          tmp->message->subject_changed &&      /* only match interesting replies */
+          !is_descendant (tmp, cur) &&  /* don't match in the same thread */
+          (date >= (option (OPTTHREADRECEIVED) ?
+                    tmp->message->received :
+                    tmp->message->date_sent)) &&
+          (!last ||
+           (option (OPTTHREADRECEIVED) ?
+            (last->message->received < tmp->message->received) :
+            (last->message->date_sent < tmp->message->date_sent))) &&
+          tmp->message->env->real_subj &&
+          mutt_strcmp (subjects->data, tmp->message->env->real_subj) == 0)
+        last = tmp;             /* best match so far */
     }
 
     oldlist = subjects;
@@ -455,7 +418,7 @@ static THREAD *find_subject (CONTEXT *ctx, THREAD *cur)
 /* remove cur and its descendants from their current location.
  * also make sure ancestors of cur no longer are sorted by the
  * fact that cur is their descendant. */
-static void unlink_message (THREAD **old, THREAD *cur)
+static void unlink_message (THREAD ** old, THREAD * cur)
 {
   THREAD *tmp;
 
@@ -467,16 +430,15 @@ static void unlink_message (THREAD **old, THREAD *cur)
   if (cur->next)
     cur->next->prev = cur->prev;
 
-  if (cur->sort_key)
-  {
+  if (cur->sort_key) {
     for (tmp = cur->parent; tmp && tmp->sort_key == cur->sort_key;
-        tmp = tmp->parent)
+         tmp = tmp->parent)
       tmp->sort_key = NULL;
   }
 }
 
 /* add cur as a prior sibling of *new, with parent newparent */
-static void insert_message (THREAD **new, THREAD *newparent, THREAD *cur)
+static void insert_message (THREAD ** new, THREAD * newparent, THREAD * cur)
 {
   if (*new)
     (*new)->prev = cur;
@@ -488,7 +450,7 @@ static void insert_message (THREAD **new, THREAD *newparent, THREAD *cur)
 }
 
 /* thread by subject things that didn't get threaded by message-id */
-static void pseudo_threads (CONTEXT *ctx)
+static void pseudo_threads (CONTEXT * ctx)
 {
   THREAD *tree = ctx->tree, *top = tree;
   THREAD *tmp, *cur, *parent, *curchild, *nextchild;
@@ -496,52 +458,45 @@ static void pseudo_threads (CONTEXT *ctx)
   if (!ctx->subj_hash)
     ctx->subj_hash = mutt_make_subj_hash (ctx);
 
-  while (tree)
-  {
+  while (tree) {
     cur = tree;
     tree = tree->next;
-    if ((parent = find_subject (ctx, cur)) != NULL)
-    {
+    if ((parent = find_subject (ctx, cur)) != NULL) {
       cur->fake_thread = 1;
       unlink_message (&top, cur);
       insert_message (&parent->child, parent, cur);
       parent->sort_children = 1;
       tmp = cur;
-      FOREVER
-      {
-       while (!tmp->message)
-         tmp = tmp->child;
-
-       /* if the message we're attaching has pseudo-children, they
-        * need to be attached to its parent, so move them up a level.
-        * but only do this if they have the same real subject as the
-        * parent, since otherwise they rightly belong to the message
-        * we're attaching. */
-       if (tmp == cur
-           || !mutt_strcmp (tmp->message->env->real_subj,
-                            parent->message->env->real_subj))
-       {
-         tmp->message->subject_changed = 0;
-
-         for (curchild = tmp->child; curchild; )
-         {
-           nextchild = curchild->next;
-           if (curchild->fake_thread)
-           {
-             unlink_message (&tmp->child, curchild);
-             insert_message (&parent->child, parent, curchild);
-           }
-           curchild = nextchild;
-         }
-       }
-
-       while (!tmp->next && tmp != cur)
-       {
-         tmp = tmp->parent;
-       }
-       if (tmp == cur)
-         break;
-       tmp = tmp->next;
+      FOREVER {
+        while (!tmp->message)
+          tmp = tmp->child;
+
+        /* if the message we're attaching has pseudo-children, they
+         * need to be attached to its parent, so move them up a level.
+         * but only do this if they have the same real subject as the
+         * parent, since otherwise they rightly belong to the message
+         * we're attaching. */
+        if (tmp == cur
+            || !mutt_strcmp (tmp->message->env->real_subj,
+                             parent->message->env->real_subj)) {
+          tmp->message->subject_changed = 0;
+
+          for (curchild = tmp->child; curchild;) {
+            nextchild = curchild->next;
+            if (curchild->fake_thread) {
+              unlink_message (&tmp->child, curchild);
+              insert_message (&parent->child, parent, curchild);
+            }
+            curchild = nextchild;
+          }
+        }
+
+        while (!tmp->next && tmp != cur) {
+          tmp = tmp->parent;
+        }
+        if (tmp == cur)
+          break;
+        tmp = tmp->next;
       }
     }
   }
@@ -549,12 +504,11 @@ static void pseudo_threads (CONTEXT *ctx)
 }
 
 
-void mutt_clear_threads (CONTEXT *ctx)
+void mutt_clear_threads (CONTEXT * ctx)
 {
   int i;
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     ctx->hdrs[i]->thread = NULL;
     ctx->hdrs[i]->threaded = 0;
   }
@@ -570,24 +524,23 @@ int compare_threads (const void *a, const void *b)
 
   if (a || b)
     return ((*sort_func) (&(*((THREAD **) a))->sort_key,
-                         &(*((THREAD **) b))->sort_key));
+                          &(*((THREAD **) b))->sort_key));
   /* a hack to let us reset sort_func even though we can't
    * have extra arguments because of qsort
    */
-  else
-  {
+  else {
     sort_func = NULL;
     sort_func = mutt_get_sort_func (Sort);
     return (sort_func ? 1 : 0);
   }
 }
 
-THREAD *mutt_sort_subthreads (THREAD *thread, int init)
+THREAD *mutt_sort_subthreads (THREAD * thread, int init)
 {
   THREAD **array, *sort_key, *top, *tmp;
   HEADER *oldsort_key;
   int i, array_size, sort_top = 0;
-  
+
   /* we put things into the array backwards to save some cycles,
    * but we want to have to move less stuff around if we're 
    * resorting, so we sort backwards and then put them back
@@ -600,111 +553,99 @@ THREAD *mutt_sort_subthreads (THREAD *thread, int init)
   top = thread;
 
   array = safe_calloc ((array_size = 256), sizeof (THREAD *));
-  while (1)
-  {
-    if (init || !thread->sort_key)
-    {
+  while (1) {
+    if (init || !thread->sort_key) {
       thread->sort_key = NULL;
 
       if (thread->parent)
         thread->parent->sort_children = 1;
       else
-       sort_top = 1;
+        sort_top = 1;
     }
 
-    if (thread->child)
-    {
+    if (thread->child) {
       thread = thread->child;
       continue;
     }
-    else
-    {
+    else {
       /* if it has no children, it must be real. sort it on its own merits */
       thread->sort_key = thread->message;
 
-      if (thread->next)
-      {
-       thread = thread->next;
-       continue;
+      if (thread->next) {
+        thread = thread->next;
+        continue;
       }
     }
 
-    while (!thread->next)
-    {
+    while (!thread->next) {
       /* if it has siblings and needs to be sorted, sort it... */
-      if (thread->prev && (thread->parent ? thread->parent->sort_children : sort_top))
-      {
-       /* put them into the array */
-       for (i = 0; thread; i++, thread = thread->prev)
-       {
-         if (i >= array_size)
-           safe_realloc (&array, (array_size *= 2) * sizeof (THREAD *));
-
-         array[i] = thread;
-       }
-
-       qsort ((void *) array, i, sizeof (THREAD *), compare_threads);
-
-       /* attach them back together.  make thread the last sibling. */
-       thread = array[0];
-       thread->next = NULL;
-       array[i - 1]->prev = NULL;
-
-       if (thread->parent)
-         thread->parent->child = array[i - 1];
-       else
-         top = array[i - 1];
-
-       while (--i)
-       {
-         array[i - 1]->prev = array[i];
-         array[i]->next = array[i - 1];
-       }
+      if (thread->prev
+          && (thread->parent ? thread->parent->sort_children : sort_top)) {
+        /* put them into the array */
+        for (i = 0; thread; i++, thread = thread->prev) {
+          if (i >= array_size)
+            safe_realloc (&array, (array_size *= 2) * sizeof (THREAD *));
+
+          array[i] = thread;
+        }
+
+        qsort ((void *) array, i, sizeof (THREAD *), compare_threads);
+
+        /* attach them back together.  make thread the last sibling. */
+        thread = array[0];
+        thread->next = NULL;
+        array[i - 1]->prev = NULL;
+
+        if (thread->parent)
+          thread->parent->child = array[i - 1];
+        else
+          top = array[i - 1];
+
+        while (--i) {
+          array[i - 1]->prev = array[i];
+          array[i]->next = array[i - 1];
+        }
       }
 
-      if (thread->parent)
-      {
-       tmp = thread;
-       thread = thread->parent;
-
-       if (!thread->sort_key || thread->sort_children)
-       {
-         /* make sort_key the first or last sibling, as appropriate */
-         sort_key = (!(Sort & SORT_LAST) ^ !(Sort & SORT_REVERSE)) ? thread->child : tmp;
-
-         /* we just sorted its children */
-         thread->sort_children = 0;
-
-         oldsort_key = thread->sort_key;
-         thread->sort_key = thread->message;
-
-         if (Sort & SORT_LAST)
-         {
-           if (!thread->sort_key
-               || ((((Sort & SORT_REVERSE) ? 1 : -1)
-                    * compare_threads ((void *) &thread,
-                                       (void *) &sort_key))
-                   > 0))
-             thread->sort_key = sort_key->sort_key;
-         }
-         else if (!thread->sort_key)
-           thread->sort_key = sort_key->sort_key;
-
-         /* if its sort_key has changed, we need to resort it and siblings */
-         if (oldsort_key != thread->sort_key)
-         {
-           if (thread->parent)
-             thread->parent->sort_children = 1;
-           else
-             sort_top = 1;
-         }
-       }
+      if (thread->parent) {
+        tmp = thread;
+        thread = thread->parent;
+
+        if (!thread->sort_key || thread->sort_children) {
+          /* make sort_key the first or last sibling, as appropriate */
+          sort_key =
+            (!(Sort & SORT_LAST) ^ !(Sort & SORT_REVERSE)) ? thread->
+            child : tmp;
+
+          /* we just sorted its children */
+          thread->sort_children = 0;
+
+          oldsort_key = thread->sort_key;
+          thread->sort_key = thread->message;
+
+          if (Sort & SORT_LAST) {
+            if (!thread->sort_key || ((((Sort & SORT_REVERSE) ? 1 : -1)
+                                       * compare_threads ((void *) &thread,
+                                                          (void *) &sort_key))
+                                      > 0))
+              thread->sort_key = sort_key->sort_key;
+          }
+          else if (!thread->sort_key)
+            thread->sort_key = sort_key->sort_key;
+
+          /* if its sort_key has changed, we need to resort it and siblings */
+          if (oldsort_key != thread->sort_key) {
+            if (thread->parent)
+              thread->parent->sort_children = 1;
+            else
+              sort_top = 1;
+          }
+        }
       }
-      else
-      {
-       Sort ^= SORT_REVERSE;
-       FREE (&array);
-       return (top);
+      else {
+        Sort ^= SORT_REVERSE;
+        FREE (&array);
+        return (top);
       }
     }
 
@@ -712,14 +653,13 @@ THREAD *mutt_sort_subthreads (THREAD *thread, int init)
   }
 }
 
-static void check_subjects (CONTEXT *ctx, int init)
+static void check_subjects (CONTEXT * ctx, int init)
 {
   HEADER *cur;
   THREAD *tmp;
   int i;
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     cur = ctx->hdrs[i];
     if (cur->thread->check_subject)
       cur->thread->check_subject = 0;
@@ -728,8 +668,7 @@ static void check_subjects (CONTEXT *ctx, int init)
 
     /* figure out which messages have subjects different than their parents' */
     tmp = cur->thread->parent;
-    while (tmp && !tmp->message)
-    {
+    while (tmp && !tmp->message) {
       tmp = tmp->parent;
     }
 
@@ -737,27 +676,28 @@ static void check_subjects (CONTEXT *ctx, int init)
       cur->subject_changed = 1;
     else if (cur->env->real_subj && tmp->message->env->real_subj)
       cur->subject_changed = mutt_strcmp (cur->env->real_subj,
-                                         tmp->message->env->real_subj) ? 1 : 0;
+                                          tmp->message->env->
+                                          real_subj) ? 1 : 0;
     else
       cur->subject_changed = (cur->env->real_subj
-                             || tmp->message->env->real_subj) ? 1 : 0;
+                              || tmp->message->env->real_subj) ? 1 : 0;
   }
 }
 
-void mutt_sort_threads (CONTEXT *ctx, int init)
+void mutt_sort_threads (CONTEXT * ctx, int init)
 {
   HEADER *cur;
   int i, oldsort, using_refs = 0;
   THREAD *thread, *new, *tmp, top;
   LIST *ref = NULL;
-  
+
   /* set Sort to the secondary method to support the set sort_aux=reverse-*
    * settings.  The sorting functions just look at the value of
    * SORT_REVERSE
    */
   oldsort = Sort;
   Sort = SortAux;
-  
+
   if (!ctx->thread_hash)
     init = 1;
 
@@ -776,101 +716,89 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
    * exists.  otherwise, if there is a THREAD that already has a message, thread
    * new message as an identical child.  if we didn't attach the message to a
    * THREAD, make a new one for it. */
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     cur = ctx->hdrs[i];
 
-    if (!cur->thread)
-    {
+    if (!cur->thread) {
       if ((!init || option (OPTDUPTHREADS)) && cur->env->message_id)
-       thread = hash_find (ctx->thread_hash, cur->env->message_id);
+        thread = hash_find (ctx->thread_hash, cur->env->message_id);
       else
-       thread = NULL;
-
-      if (thread && !thread->message)
-      {
-       /* this is a message which was missing before */
-       thread->message = cur;
-       cur->thread = thread;
-       thread->check_subject = 1;
-
-       /* mark descendants as needing subject_changed checked */
-       for (tmp = (thread->child ? thread->child : thread); tmp != thread; )
-       {
-         while (!tmp->message)
-           tmp = tmp->child;
-         tmp->check_subject = 1;
-         while (!tmp->next && tmp != thread)
-           tmp = tmp->parent;
-         if (tmp != thread)
-           tmp = tmp->next;
-       }
-
-       if (thread->parent)
-       {
-         /* remove threading info above it based on its children, which we'll
-          * recalculate based on its headers.  make sure not to leave
-          * dangling missing messages.  note that we haven't kept track
-          * of what info came from its children and what from its siblings'
-          * children, so we just remove the stuff that's definitely from it */
-         do
-         {
-           tmp = thread->parent;
-           unlink_message (&tmp->child, thread);
-           thread->parent = NULL;
-           thread->sort_key = NULL;
-           thread->fake_thread = 0;
-           thread = tmp;
-         } while (thread != &top && !thread->child && !thread->message);
-       }
+        thread = NULL;
+
+      if (thread && !thread->message) {
+        /* this is a message which was missing before */
+        thread->message = cur;
+        cur->thread = thread;
+        thread->check_subject = 1;
+
+        /* mark descendants as needing subject_changed checked */
+        for (tmp = (thread->child ? thread->child : thread); tmp != thread;) {
+          while (!tmp->message)
+            tmp = tmp->child;
+          tmp->check_subject = 1;
+          while (!tmp->next && tmp != thread)
+            tmp = tmp->parent;
+          if (tmp != thread)
+            tmp = tmp->next;
+        }
+
+        if (thread->parent) {
+          /* remove threading info above it based on its children, which we'll
+           * recalculate based on its headers.  make sure not to leave
+           * dangling missing messages.  note that we haven't kept track
+           * of what info came from its children and what from its siblings'
+           * children, so we just remove the stuff that's definitely from it */
+          do {
+            tmp = thread->parent;
+            unlink_message (&tmp->child, thread);
+            thread->parent = NULL;
+            thread->sort_key = NULL;
+            thread->fake_thread = 0;
+            thread = tmp;
+          } while (thread != &top && !thread->child && !thread->message);
+        }
       }
-      else
-      {
-       new = (option (OPTDUPTHREADS) ? thread : NULL);
-
-       thread = safe_calloc (1, sizeof (THREAD));
-       thread->message = cur;
-       thread->check_subject = 1;
-       cur->thread = thread;
-       hash_insert (ctx->thread_hash,
-                    cur->env->message_id ? cur->env->message_id : "",
-                    thread, 1);
-
-       if (new)
-       {
-         if (new->duplicate_thread)
-           new = new->parent;
-
-         thread = cur->thread;
-
-         insert_message (&new->child, new, thread);
-         thread->duplicate_thread = 1;
-         thread->message->threaded = 1;
-       }
+      else {
+        new = (option (OPTDUPTHREADS) ? thread : NULL);
+
+        thread = safe_calloc (1, sizeof (THREAD));
+        thread->message = cur;
+        thread->check_subject = 1;
+        cur->thread = thread;
+        hash_insert (ctx->thread_hash,
+                     cur->env->message_id ? cur->env->message_id : "",
+                     thread, 1);
+
+        if (new) {
+          if (new->duplicate_thread)
+            new = new->parent;
+
+          thread = cur->thread;
+
+          insert_message (&new->child, new, thread);
+          thread->duplicate_thread = 1;
+          thread->message->threaded = 1;
+        }
       }
     }
-    else
-    {
+    else {
       /* unlink pseudo-threads because they might be children of newly
        * arrived messages */
       thread = cur->thread;
-      for (new = thread->child; new; )
-      {
-       tmp = new->next;
-       if (new->fake_thread)
-       {
-         unlink_message (&thread->child, new);
-         insert_message (&top.child, &top, new);
-         new->fake_thread = 0;
-       }
-       new = tmp;
+      for (new = thread->child; new;) {
+        tmp = new->next;
+        if (new->fake_thread) {
+          unlink_message (&thread->child, new);
+          insert_message (&top.child, &top, new);
+          new->fake_thread = 0;
+        }
+        new = tmp;
       }
     }
   }
 
   /* thread by references */
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     cur = ctx->hdrs[i];
     if (cur->threaded)
       continue;
@@ -879,64 +807,57 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
     thread = cur->thread;
     using_refs = 0;
 
-    while (1)
-    {
-      if (using_refs == 0)
-      {
-       /* look at the beginning of in-reply-to: */
-       if ((ref = cur->env->in_reply_to) != NULL)
-         using_refs = 1;
-       else
-       {
-         ref = cur->env->references;
-         using_refs = 2;
-       }
+    while (1) {
+      if (using_refs == 0) {
+        /* look at the beginning of in-reply-to: */
+        if ((ref = cur->env->in_reply_to) != NULL)
+          using_refs = 1;
+        else {
+          ref = cur->env->references;
+          using_refs = 2;
+        }
       }
-      else if (using_refs == 1)
-      {
-       /* if there's no references header, use all the in-reply-to:
-        * data that we have.  otherwise, use the first reference
-        * if it's different than the first in-reply-to, otherwise use
-        * the second reference (since at least eudora puts the most
-        * recent reference in in-reply-to and the rest in references)
-        */
-       if (!cur->env->references)
-         ref = ref->next;
-       else
-       {
-         if (mutt_strcmp (ref->data, cur->env->references->data))
-           ref = cur->env->references;
-         else
-           ref = cur->env->references->next;
-         
-         using_refs = 2;
-       }
+      else if (using_refs == 1) {
+        /* if there's no references header, use all the in-reply-to:
+         * data that we have.  otherwise, use the first reference
+         * if it's different than the first in-reply-to, otherwise use
+         * the second reference (since at least eudora puts the most
+         * recent reference in in-reply-to and the rest in references)
+         */
+        if (!cur->env->references)
+          ref = ref->next;
+        else {
+          if (mutt_strcmp (ref->data, cur->env->references->data))
+            ref = cur->env->references;
+          else
+            ref = cur->env->references->next;
+
+          using_refs = 2;
+        }
       }
       else
-       ref = ref->next; /* go on with references */
-      
+        ref = ref->next;        /* go on with references */
+
       if (!ref)
-       break;
+        break;
 
-      if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL)
-      {
-       new = safe_calloc (1, sizeof (THREAD));
-       hash_insert (ctx->thread_hash, ref->data, new, 1);
+      if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL) {
+        new = safe_calloc (1, sizeof (THREAD));
+        hash_insert (ctx->thread_hash, ref->data, new, 1);
       }
-      else
-      {
-       if (new->duplicate_thread)
-         new = new->parent;
-       if (is_descendant (new, thread)) /* no loops! */
-         break;
+      else {
+        if (new->duplicate_thread)
+          new = new->parent;
+        if (is_descendant (new, thread))        /* no loops! */
+          break;
       }
 
       if (thread->parent)
-       unlink_message (&top.child, thread);
+        unlink_message (&top.child, thread);
       insert_message (&new->child, new, thread);
       thread = new;
       if (thread->message || (thread->parent && thread->parent != &top))
-       break;
+        break;
     }
 
     if (!thread->parent)
@@ -944,8 +865,7 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
   }
 
   /* detach everything from the temporary top node */
-  for (thread = top.child; thread; thread = thread->next)
-  {
+  for (thread = top.child; thread; thread = thread->next) {
     thread->parent = NULL;
   }
   ctx->tree = top.child;
@@ -955,13 +875,12 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
   if (!option (OPTSTRICTTHREADS))
     pseudo_threads (ctx);
 
-  if (ctx->tree)
-  {
+  if (ctx->tree) {
     ctx->tree = mutt_sort_subthreads (ctx->tree, init);
 
     /* restore the oldsort order. */
     Sort = oldsort;
-    
+
     /* Put the list into an array. */
     linearize_tree (ctx);
 
@@ -970,7 +889,7 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
   }
 }
 
-static HEADER *find_virtual (THREAD *cur, int reverse)
+static HEADER *find_virtual (THREAD * cur, int reverse)
 {
   THREAD *top;
 
@@ -984,27 +903,23 @@ static HEADER *find_virtual (THREAD *cur, int reverse)
   while (reverse && cur->next)
     cur = cur->next;
 
-  FOREVER
-  {
+  FOREVER {
     if (cur->message && cur->message->virtual >= 0)
       return (cur->message);
 
-    if (cur->child)
-    {
+    if (cur->child) {
       cur = cur->child;
 
       while (reverse && cur->next)
-       cur = cur->next;
+        cur = cur->next;
     }
     else if (reverse ? cur->prev : cur->next)
       cur = reverse ? cur->prev : cur->next;
-    else
-    {
-      while (!(reverse ? cur->prev : cur->next))
-      {
-       cur = cur->parent;
-       if (cur == top)
-         return (NULL);
+    else {
+      while (!(reverse ? cur->prev : cur->next)) {
+        cur = cur->parent;
+        if (cur == top)
+          return (NULL);
       }
       cur = reverse ? cur->prev : cur->next;
     }
@@ -1012,55 +927,47 @@ static HEADER *find_virtual (THREAD *cur, int reverse)
   }
 }
 
-int _mutt_aside_thread (HEADER *hdr, short dir, short subthreads)
+int _mutt_aside_thread (HEADER * hdr, short dir, short subthreads)
 {
   THREAD *cur;
   HEADER *tmp;
 
-  if ((Sort & SORT_MASK) != SORT_THREADS)
-  {
+  if ((Sort & SORT_MASK) != SORT_THREADS) {
     mutt_error _("Threading is not enabled.");
+
     return (hdr->virtual);
   }
 
   cur = hdr->thread;
 
-  if (!subthreads)
-  {
+  if (!subthreads) {
     while (cur->parent)
       cur = cur->parent;
   }
-  else
-  {
-    if ((dir != 0) ^ ((Sort & SORT_REVERSE) != 0))
-    {
+  else {
+    if ((dir != 0) ^ ((Sort & SORT_REVERSE) != 0)) {
       while (!cur->next && cur->parent)
-       cur = cur->parent;
+        cur = cur->parent;
     }
-    else
-    {
+    else {
       while (!cur->prev && cur->parent)
-       cur = cur->parent;
+        cur = cur->parent;
     }
   }
 
-  if ((dir != 0) ^ ((Sort & SORT_REVERSE) != 0))
-  {
-    do
-    { 
+  if ((dir != 0) ^ ((Sort & SORT_REVERSE) != 0)) {
+    do {
       cur = cur->next;
       if (!cur)
-       return (-1);
+        return (-1);
       tmp = find_virtual (cur, 0);
     } while (!tmp);
   }
-  else
-  {
-    do
-    { 
+  else {
+    do {
       cur = cur->prev;
       if (!cur)
-       return (-1);
+        return (-1);
       tmp = find_virtual (cur, 1);
     } while (!tmp);
   }
@@ -1068,35 +975,34 @@ int _mutt_aside_thread (HEADER *hdr, short dir, short subthreads)
   return (tmp->virtual);
 }
 
-int mutt_parent_message (CONTEXT *ctx, HEADER *hdr)
+int mutt_parent_message (CONTEXT * ctx, HEADER * hdr)
 {
   THREAD *thread;
 
-  if ((Sort & SORT_MASK) != SORT_THREADS)
-  {
+  if ((Sort & SORT_MASK) != SORT_THREADS) {
     mutt_error _("Threading is not enabled.");
+
     return (hdr->virtual);
   }
 
-  for (thread = hdr->thread->parent; thread; thread = thread->parent)
-  {
-    if ((hdr = thread->message) != NULL)
-    {
+  for (thread = hdr->thread->parent; thread; thread = thread->parent) {
+    if ((hdr = thread->message) != NULL) {
       if (VISIBLE (hdr, ctx))
-       return (hdr->virtual);
-      else
-      {
-       mutt_error _("Parent message is not visible in this limited view.");
-       return (-1);
+        return (hdr->virtual);
+      else {
+        mutt_error _("Parent message is not visible in this limited view.");
+
+        return (-1);
       }
     }
   }
-  
+
   mutt_error _("Parent message is not available.");
+
   return (-1);
 }
 
-void mutt_set_virtual (CONTEXT *ctx)
+void mutt_set_virtual (CONTEXT * ctx)
 {
   int i;
   HEADER *cur;
@@ -1104,31 +1010,31 @@ void mutt_set_virtual (CONTEXT *ctx)
   ctx->vcount = 0;
   ctx->vsize = 0;
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     cur = ctx->hdrs[i];
-    if (cur->virtual >= 0)
-    {
+    if (cur->virtual >= 0) {
       cur->virtual = ctx->vcount;
       ctx->v2r[ctx->vcount] = i;
       ctx->vcount++;
-      ctx->vsize += cur->content->length + cur->content->offset - cur->content->hdr_offset;
+      ctx->vsize +=
+        cur->content->length + cur->content->offset -
+        cur->content->hdr_offset;
       cur->num_hidden = mutt_get_hidden (ctx, cur);
     }
   }
 }
 
-int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
+int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag)
 {
   THREAD *thread, *top;
   HEADER *roothdr = NULL;
   int final, reverse = (Sort & SORT_REVERSE), minmsgno;
   int num_hidden = 0, new = 0, old = 0;
   int min_unread_msgno = INT_MAX, min_unread = cur->virtual;
+
 #define CHECK_LIMIT (!ctx->pattern || cur->limited)
 
-  if ((Sort & SORT_MASK) != SORT_THREADS && !(flag & M_THREAD_GET_HIDDEN))
-  {
+  if ((Sort & SORT_MASK) != SORT_THREADS && !(flag & M_THREAD_GET_HIDDEN)) {
     mutt_error (_("Threading is not enabled."));
     return (cur->virtual);
   }
@@ -1143,14 +1049,12 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
   cur = thread->message;
   minmsgno = cur->msgno;
 
-  if (!cur->read && CHECK_LIMIT)
-  {
+  if (!cur->read && CHECK_LIMIT) {
     if (cur->old)
       old = 2;
     else
       new = 1;
-    if (cur->msgno < min_unread_msgno)
-    {
+    if (cur->msgno < min_unread_msgno) {
       min_unread = cur->virtual;
       min_unread_msgno = cur->msgno;
     }
@@ -1159,20 +1063,17 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
   if (cur->virtual == -1 && CHECK_LIMIT)
     num_hidden++;
 
-  if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
-  {
-    cur->pair = 0; /* force index entry's color to be re-evaluated */
+  if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE)) {
+    cur->pair = 0;              /* force index entry's color to be re-evaluated */
     cur->collapsed = flag & M_THREAD_COLLAPSE;
-    if (cur->virtual != -1)
-    {
+    if (cur->virtual != -1) {
       roothdr = cur;
       if (flag & M_THREAD_COLLAPSE)
-       final = roothdr->virtual;
+        final = roothdr->virtual;
     }
   }
 
-  if (thread == top && (thread = thread->child) == NULL)
-  {
+  if (thread == top && (thread = thread->child) == NULL) {
     /* return value depends on action requested */
     if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
       return (final);
@@ -1183,78 +1084,68 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
     else if (flag & M_THREAD_NEXT_UNREAD)
       return (min_unread);
   }
-  
-  FOREVER
-  {
+
+  FOREVER {
     cur = thread->message;
 
-    if (cur)
-    {
-      if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
-      {
-       cur->pair = 0; /* force index entry's color to be re-evaluated */
-       cur->collapsed = flag & M_THREAD_COLLAPSE;
-       if (!roothdr && CHECK_LIMIT)
-       {
-         roothdr = cur;
-         if (flag & M_THREAD_COLLAPSE)
-           final = roothdr->virtual;
-       }
-
-       if (reverse && (flag & M_THREAD_COLLAPSE) && (cur->msgno < minmsgno) && CHECK_LIMIT)
-       {
-         minmsgno = cur->msgno;
-         final = cur->virtual;
-       }
-
-       if (flag & M_THREAD_COLLAPSE)
-       {
-         if (cur != roothdr)
-           cur->virtual = -1;
-       }
-       else 
-       {
-         if (CHECK_LIMIT)
-           cur->virtual = cur->msgno;
-       }
+    if (cur) {
+      if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE)) {
+        cur->pair = 0;          /* force index entry's color to be re-evaluated */
+        cur->collapsed = flag & M_THREAD_COLLAPSE;
+        if (!roothdr && CHECK_LIMIT) {
+          roothdr = cur;
+          if (flag & M_THREAD_COLLAPSE)
+            final = roothdr->virtual;
+        }
+
+        if (reverse && (flag & M_THREAD_COLLAPSE) && (cur->msgno < minmsgno)
+            && CHECK_LIMIT) {
+          minmsgno = cur->msgno;
+          final = cur->virtual;
+        }
+
+        if (flag & M_THREAD_COLLAPSE) {
+          if (cur != roothdr)
+            cur->virtual = -1;
+        }
+        else {
+          if (CHECK_LIMIT)
+            cur->virtual = cur->msgno;
+        }
       }
 
 
-      if (!cur->read && CHECK_LIMIT)
-      {
-       if (cur->old)
-         old = 2;
-       else
-         new = 1;
-       if (cur->msgno < min_unread_msgno)
-       {
-         min_unread = cur->virtual;
-         min_unread_msgno = cur->msgno;
-       }
+      if (!cur->read && CHECK_LIMIT) {
+        if (cur->old)
+          old = 2;
+        else
+          new = 1;
+        if (cur->msgno < min_unread_msgno) {
+          min_unread = cur->virtual;
+          min_unread_msgno = cur->msgno;
+        }
       }
 
       if (cur->virtual == -1 && CHECK_LIMIT)
-       num_hidden++;
+        num_hidden++;
     }
 
     if (thread->child)
       thread = thread->child;
     else if (thread->next)
       thread = thread->next;
-    else
-    {
+    else {
       int done = 0;
-      while (!thread->next)
-      {
-       thread = thread->parent;
-       if (thread == top)
-       {
-         done = 1;
-         break;
-       }
+
+      while (!thread->next) {
+        thread = thread->parent;
+        if (thread == top) {
+          done = 1;
+          break;
+        }
       }
       if (done)
-       break;
+        break;
       thread = thread->next;
     }
   }
@@ -1265,7 +1156,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
   else if (flag & M_THREAD_UNREAD)
     return ((old && new) ? new : (old ? old : new));
   else if (flag & M_THREAD_GET_HIDDEN)
-    return (num_hidden+1);
+    return (num_hidden + 1);
   else if (flag & M_THREAD_NEXT_UNREAD)
     return (min_unread);
 
@@ -1277,7 +1168,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag)
 /* if flag is 0, we want to know how many messages
  * are in the thread.  if flag is 1, we want to know
  * our position in the thread. */
-int mutt_messages_in_thread (CONTEXT *ctx, HEADER *hdr, int flag)
+int mutt_messages_in_thread (CONTEXT * ctx, HEADER * hdr, int flag)
 {
   THREAD *threads[2];
   int i, rc;
@@ -1291,25 +1182,28 @@ int mutt_messages_in_thread (CONTEXT *ctx, HEADER *hdr, int flag)
 
   threads[1] = flag ? hdr->thread : threads[0]->next;
 
-  for (i = 0; i < ((flag || !threads[1]) ? 1 : 2); i++)
-  {
+  for (i = 0; i < ((flag || !threads[1]) ? 1 : 2); i++) {
     while (!threads[i]->message)
       threads[i] = threads[i]->child;
-  } 
+  }
 
   if (Sort & SORT_REVERSE)
-    rc = threads[0]->message->msgno - (threads[1] ? threads[1]->message->msgno : -1);
+    rc =
+      threads[0]->message->msgno -
+      (threads[1] ? threads[1]->message->msgno : -1);
   else
-    rc = (threads[1] ? threads[1]->message->msgno : ctx->msgcount) - threads[0]->message->msgno;
-  
+    rc =
+      (threads[1] ? threads[1]->message->msgno : ctx->msgcount) -
+      threads[0]->message->msgno;
+
   if (flag)
     rc += 1;
-  
+
   return (rc);
 }
 
 
-HASH *mutt_make_id_hash (CONTEXT *ctx)
+HASH *mutt_make_id_hash (CONTEXT * ctx)
 {
   int i;
   HEADER *hdr;
@@ -1317,8 +1211,7 @@ HASH *mutt_make_id_hash (CONTEXT *ctx)
 
   hash = hash_create (ctx->msgcount * 2);
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     hdr = ctx->hdrs[i];
     if (hdr->env->message_id)
       hash_insert (hash, hdr->env->message_id, hdr, 0);
@@ -1327,7 +1220,7 @@ HASH *mutt_make_id_hash (CONTEXT *ctx)
   return hash;
 }
 
-HASH *mutt_make_subj_hash (CONTEXT *ctx)
+HASH *mutt_make_subj_hash (CONTEXT * ctx)
 {
   int i;
   HEADER *hdr;
@@ -1335,8 +1228,7 @@ HASH *mutt_make_subj_hash (CONTEXT *ctx)
 
   hash = hash_create (ctx->msgcount * 2);
 
-  for (i = 0; i < ctx->msgcount; i++)
-  {
+  for (i = 0; i < ctx->msgcount; i++) {
     hdr = ctx->hdrs[i];
     if (hdr->env->real_subj)
       hash_insert (hash, hdr->env->real_subj, hdr, 1);
@@ -1345,42 +1237,40 @@ HASH *mutt_make_subj_hash (CONTEXT *ctx)
   return hash;
 }
 
-static void clean_references (THREAD *brk, THREAD *cur)
+static void clean_references (THREAD * brk, THREAD * cur)
 {
   THREAD *p;
   LIST *ref = NULL;
   int done = 0;
 
-  for (; cur; cur = cur->next, done = 0)
-  {
+  for (; cur; cur = cur->next, done = 0) {
     /* parse subthread recursively */
     clean_references (brk, cur->child);
 
     if (!cur->message)
-      break; /* skip pseudo-message */
+      break;                    /* skip pseudo-message */
 
     /* Looking for the first bad reference according to the new threading.
      * Optimal since Mutt stores the references in reverse order, and the
      * first loop should match immediatly for mails respecting RFC2822. */
     for (p = brk; !done && p; p = p->parent)
-      for (ref = cur->message->env->references; p->message && ref; ref = ref->next)
-       if (!mutt_strcasecmp (ref->data, p->message->env->message_id))
-       {
-         done = 1;
-         break;
-       }
-
-    if (done)
-    {
+      for (ref = cur->message->env->references; p->message && ref;
+           ref = ref->next)
+        if (!mutt_strcasecmp (ref->data, p->message->env->message_id)) {
+          done = 1;
+          break;
+        }
+
+    if (done) {
       HEADER *h = cur->message;
 
       /* clearing the References: header from obsolete Message-Id(s) */
       mutt_free_list (&ref->next);
 
       if (h->new_env)
-       mutt_free_list (&h->new_env->references);
+        mutt_free_list (&h->new_env->references);
       else
-       h->new_env = mutt_new_envelope ();
+        h->new_env = mutt_new_envelope ();
 
       h->new_env->references = mutt_copy_list (h->env->references);
 
@@ -1389,14 +1279,13 @@ static void clean_references (THREAD *brk, THREAD *cur)
   }
 }
 
-void mutt_break_thread (HEADER *hdr)
+void mutt_break_thread (HEADER * hdr)
 {
   mutt_free_list (&hdr->env->in_reply_to);
   mutt_free_list (&hdr->env->references);
   hdr->irt_changed = hdr->refs_changed = hdr->changed = 1;
 
-  if (hdr->new_env)
-  {
+  if (hdr->new_env) {
     mutt_free_list (&hdr->new_env->in_reply_to);
     mutt_free_list (&hdr->new_env->references);
   }
@@ -1406,7 +1295,7 @@ void mutt_break_thread (HEADER *hdr)
   clean_references (hdr->thread, hdr->thread->child);
 }
 
-static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx)
+static int link_threads (HEADER * parent, HEADER * child, CONTEXT * ctx)
 {
   if (child == parent)
     return 0;
@@ -1418,22 +1307,21 @@ static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx)
 
   child->new_env->in_reply_to = mutt_new_list ();
   child->new_env->in_reply_to->data = safe_strdup (parent->env->message_id);
-  
+
   mutt_set_flag (ctx, child, M_TAG, 0);
-  
+
   child->irt_changed = child->changed = 1;
   return 1;
 }
 
-int mutt_link_threads (HEADER *cur, HEADER *last, CONTEXT *ctx)
+int mutt_link_threads (HEADER * cur, HEADER * last, CONTEXT * ctx)
 {
   int i, changed = 0;
 
-  if (!last)
-  {
+  if (!last) {
     for (i = 0; i < ctx->vcount; i++)
       if (ctx->hdrs[Context->v2r[i]]->tagged)
-       changed |= link_threads (cur, ctx->hdrs[Context->v2r[i]], ctx);
+        changed |= link_threads (cur, ctx->hdrs[Context->v2r[i]], ctx);
   }
   else
     changed = link_threads (cur, last, ctx);
diff --git a/url.c b/url.c
index f29fd7e..44463cb 100644 (file)
--- a/url.c
+++ b/url.c
@@ -14,7 +14,7 @@
  *     You should have received a copy of the GNU General Public License
  *     along with this program; if not, write to the Free Software
  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- */ 
+ */
 
 /*
  * A simple URL parser.
 
 #include <ctype.h>
 
-static struct mapping_t UrlMap[] =
-{
-  { "file",    U_FILE },
-  { "imap",    U_IMAP },
-  { "imaps",   U_IMAPS },
-  { "pop",     U_POP  },
-  { "pops",    U_POPS  },
-  { "nntp",    U_NNTP },
-  { "nntps",   U_NNTPS },
-  { "snews",   U_NNTPS },
-  { "mailto",  U_MAILTO },
-  { NULL,      U_UNKNOWN}
+static struct mapping_t UrlMap[] = {
+  {"file", U_FILE},
+  {"imap", U_IMAP},
+  {"imaps", U_IMAPS},
+  {"pop", U_POP},
+  {"pops", U_POPS},
+  {"nntp", U_NNTP},
+  {"nntps", U_NNTPS},
+  {"snews", U_NNTPS},
+  {"mailto", U_MAILTO},
+  {NULL, U_UNKNOWN}
 };
 
 
@@ -53,21 +52,19 @@ static void url_pct_decode (char *s)
 
   if (!s)
     return;
-  
-  for (d = s; *s; s++)
-  {
+
+  for (d = s; *s; s++) {
     if (*s == '%' && s[1] && s[2] &&
-       isxdigit ((unsigned char) s[1]) &&
+        isxdigit ((unsigned char) s[1]) &&
         isxdigit ((unsigned char) s[2]) &&
-       hexval (s[1]) >= 0 && hexval (s[2]) >= 0)
-    {
+        hexval (s[1]) >= 0 && hexval (s[2]) >= 0) {
       *d++ = (hexval (s[1]) << 4) | (hexval (s[2]));
       s += 2;
     }
     else
       *d++ = *s;
   }
-  *d ='\0';
+  *d = '\0';
 }
 
 url_scheme_t url_check_scheme (const char *s)
@@ -75,12 +72,12 @@ url_scheme_t url_check_scheme (const char *s)
   char sbuf[STRING];
   char *t;
   int i;
-  
+
   if (!s || !(t = strchr (s, ':')))
     return U_UNKNOWN;
   if ((t - s) + 1 >= sizeof (sbuf))
     return U_UNKNOWN;
-  
+
   strfcpy (sbuf, s, t - s + 1);
   for (t = sbuf; *t; t++)
     *t = ascii_tolower (*t);
@@ -95,11 +92,11 @@ int url_parse_file (char *d, const char *src, size_t dl)
 {
   if (ascii_strncasecmp (src, "file:", 5))
     return -1;
-  else if (!ascii_strncasecmp (src, "file://", 7))     /* we don't support remote files */
+  else if (!ascii_strncasecmp (src, "file://", 7))      /* we don't support remote files */
     return -1;
   else
     strfcpy (d, src + 5, dl);
-  
+
   url_pct_decode (d);
   return 0;
 }
@@ -107,7 +104,7 @@ int url_parse_file (char *d, const char *src, size_t dl)
 /* ciss_parse_userhost: fill in components of ciss with info from src. Note
  *   these are pointers into src, which is altered with '\0's. Port of 0
  *   means no port given. */
-static char *ciss_parse_userhost (ciss_url_t *ciss, char *src)
+static char *ciss_parse_userhost (ciss_url_t * ciss, char *src)
 {
   char *t;
   char *p;
@@ -120,17 +117,15 @@ static char *ciss_parse_userhost (ciss_url_t *ciss, char *src)
 
   if (strncmp (src, "//", 2))
     return src;
-  
+
   src += 2;
 
   if ((path = strchr (src, '/')))
     *path++ = '\0';
-  
-  if ((t = strrchr (src, '@')))
-  {
+
+  if ((t = strrchr (src, '@'))) {
     *t = '\0';
-    if ((p = strchr (src, ':')))
-    {
+    if ((p = strchr (src, ':'))) {
       *p = '\0';
       ciss->pass = p + 1;
       url_pct_decode (ciss->pass);
@@ -141,15 +136,14 @@ static char *ciss_parse_userhost (ciss_url_t *ciss, char *src)
   }
   else
     t = src;
-  
-  if ((p = strchr (t, ':')))
-  {
+
+  if ((p = strchr (t, ':'))) {
     *p++ = '\0';
     ciss->port = atoi (p);
   }
   else
     ciss->port = 0;
-  
+
   ciss->host = t;
   url_pct_decode (ciss->host);
   return path;
@@ -157,7 +151,7 @@ static char *ciss_parse_userhost (ciss_url_t *ciss, char *src)
 
 /* url_parse_ciss: Fill in ciss_url_t. char* elements are pointers into src,
  *   which is modified by this call (duplicate it first if you need to). */
-int url_parse_ciss (ciss_url_t *ciss, char *src)
+int url_parse_ciss (ciss_url_t * ciss, char *src)
 {
   char *tmp;
 
@@ -168,13 +162,13 @@ int url_parse_ciss (ciss_url_t *ciss, char *src)
 
   ciss->path = ciss_parse_userhost (ciss, tmp);
   url_pct_decode (ciss->path);
-  
+
   return 0;
 }
 
 /* url_ciss_tostring: output the URL string for a given CISS object. */
 
-int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags)
+int url_ciss_tostring (ciss_url_t * ciss, char *dest, size_t len, int flags)
 {
   long l;
 
@@ -183,18 +177,19 @@ int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags)
 
   snprintf (dest, len, "%s:", mutt_getnamebyvalue (ciss->scheme, UrlMap));
 
-  if (ciss->host)
-  {
+  if (ciss->host) {
     safe_strcat (dest, len, "//");
-    len -= (l = strlen (dest)); dest += l;
-    
+    len -= (l = strlen (dest));
+    dest += l;
+
     if (ciss->user) {
       if (flags & U_DECODE_PASSWD && ciss->pass)
-       snprintf (dest, len, "%s:%s@", ciss->user, ciss->pass);
+        snprintf (dest, len, "%s:%s@", ciss->user, ciss->pass);
       else
-       snprintf (dest, len, "%s@", ciss->user);
+        snprintf (dest, len, "%s@", ciss->user);
 
-      len -= (l = strlen (dest)); dest += l;
+      len -= (l = strlen (dest));
+      dest += l;
     }
 
     if (ciss->port)
@@ -209,7 +204,7 @@ int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags)
   return 0;
 }
 
-int url_parse_mailto (ENVELOPE *e, char **body, const char *src)
+int url_parse_mailto (ENVELOPE * e, char **body, const char *src)
 {
   char *t;
   char *tmp;
@@ -220,10 +215,10 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src)
   int taglen;
 
   LIST *last = NULL;
-  
+
   if (!(t = strchr (src, ':')))
     return -1;
-  
+
   if ((tmp = safe_strdup (t + 1)) == NULL)
     return -1;
 
@@ -234,9 +229,8 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src)
   e->to = rfc822_parse_adrlist (e->to, tmp);
 
   tag = headers ? strtok (headers, "&") : NULL;
-  
-  for (; tag; tag = strtok (NULL, "&"))
-  {
+
+  for (; tag; tag = strtok (NULL, "&")) {
     if ((value = strchr (tag, '=')))
       *value++ = '\0';
     if (!value || !*value)
@@ -245,24 +239,21 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src)
     url_pct_decode (tag);
     url_pct_decode (value);
 
-    if (!ascii_strcasecmp (tag, "body"))
-    {
+    if (!ascii_strcasecmp (tag, "body")) {
       if (body)
-       mutt_str_replace (body, value);
+        mutt_str_replace (body, value);
     }
-    else 
-    {
+    else {
       taglen = strlen (tag);
       /* mutt_parse_rfc822_line makes some assumptions */
       snprintf (scratch, sizeof (scratch), "%s: %s", tag, value);
       scratch[taglen] = '\0';
-      value = &scratch[taglen+1];
+      value = &scratch[taglen + 1];
       SKIPWS (value);
       mutt_parse_rfc822_line (e, NULL, scratch, value, 1, 0, 0, &last);
     }
   }
-  
+
   FREE (&tmp);
   return 0;
 }
-
diff --git a/url.h b/url.h
index 5e0f3ae..e268b84 100644 (file)
--- a/url.h
+++ b/url.h
@@ -1,8 +1,7 @@
 #ifndef _URL_H
 # define _URL_H
 
-typedef enum url_scheme
-{
+typedef enum url_scheme {
   U_FILE,
   U_POP,
   U_POPS,
@@ -12,26 +11,23 @@ typedef enum url_scheme
   U_NNTPS,
   U_MAILTO,
   U_UNKNOWN
-}
-url_scheme_t;
+} url_scheme_t;
 
 #define U_DECODE_PASSWD (1)
 
-typedef struct ciss_url
-{
+typedef struct ciss_url {
   url_scheme_t scheme;
   char *user;
   char *pass;
   char *host;
   unsigned short port;
   char *path;
-} 
-ciss_url_t;
+} ciss_url_t;
 
 url_scheme_t url_check_scheme (const char *s);
 int url_parse_file (char *d, const char *src, size_t dl);
-int url_parse_ciss (ciss_url_t *ciss, char *src);
-int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags);
-int url_parse_mailto (ENVELOPE *e, char **body, const char *src);
+int url_parse_ciss (ciss_url_t * ciss, char *src);
+int url_ciss_tostring (ciss_url_t * ciss, char *dest, size_t len, int flags);
+int url_parse_mailto (ENVELOPE * e, char **body, const char *src);
 
 #endif
diff --git a/utf8.c b/utf8.c
index bed31ab..8f72f3b 100644 (file)
--- a/utf8.c
+++ b/utf8.c
 
 int mutt_wctoutf8 (char *s, unsigned int c)
 {
-  if (c < (1 << 7)) 
-  {
+  if (c < (1 << 7)) {
     if (s)
       *s++ = c;
     return 1;
   }
-  else if (c < (1 << 11))
-  {
-    if (s)
-    {
+  else if (c < (1 << 11)) {
+    if (s) {
       *s++ = 0xc0 | (c >> 6);
       *s++ = 0x80 | (c & 0x3f);
     }
     return 2;
   }
-  else if (c < (1 << 16))
-  {
-    if (s)
-    {
+  else if (c < (1 << 16)) {
+    if (s) {
       *s++ = 0xe0 | (c >> 12);
       *s++ = 0x80 | ((c >> 6) & 0x3f);
       *s++ = 0x80 | (c & 0x3f);
     }
     return 3;
   }
-  else if (c < (1 << 21))
-  {
-    if (s)
-    {
+  else if (c < (1 << 21)) {
+    if (s) {
       *s++ = 0xf0 | (c >> 18);
       *s++ = 0x80 | ((c >> 12) & 0x3f);
       *s++ = 0x80 | ((c >> 6) & 0x3f);
@@ -48,10 +41,8 @@ int mutt_wctoutf8 (char *s, unsigned int c)
     }
     return 4;
   }
-  else if (c < (1 << 26))
-  {
-    if (s)
-    {
+  else if (c < (1 << 26)) {
+    if (s) {
       *s++ = 0xf8 | (c >> 24);
       *s++ = 0x80 | ((c >> 18) & 0x3f);
       *s++ = 0x80 | ((c >> 12) & 0x3f);
@@ -60,10 +51,8 @@ int mutt_wctoutf8 (char *s, unsigned int c)
     }
     return 5;
   }
-  else if (c < (1 << 31))
-  {
-    if (s)
-    {
+  else if (c < (1 << 31)) {
+    if (s) {
       *s++ = 0xfc | (c >> 30);
       *s++ = 0x80 | ((c >> 24) & 0x3f);
       *s++ = 0x80 | ((c >> 18) & 0x3f);
index 03c055a..5f22b75 100644 (file)
--- a/wcwidth.c
+++ b/wcwidth.c
@@ -78,7 +78,8 @@ struct interval {
 };
 
 /* auxiliary function for binary search in interval table */
-static int bisearch(wchar_t ucs, const struct interval *table, int max) {
+static int bisearch (wchar_t ucs, const struct interval *table, int max)
+{
   int min = 0;
   int mid;
 
@@ -135,47 +136,47 @@ int wcwidth_ucs (wchar_t ucs)
   /* sorted list of non-overlapping intervals of non-spacing characters */
   /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
   static const struct interval combining[] = {
-    { 0x0300, 0x0357 }, { 0x035D, 0x036F }, { 0x0483, 0x0486 },
-    { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
-    { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
-    { 0x05C4, 0x05C4 }, { 0x0600, 0x0603 }, { 0x0610, 0x0615 },
-    { 0x064B, 0x0658 }, { 0x0670, 0x0670 }, { 0x06D6, 0x06E4 },
-    { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, { 0x070F, 0x070F },
-    { 0x0711, 0x0711 }, { 0x0730, 0x074A }, { 0x07A6, 0x07B0 },
-    { 0x0901, 0x0902 }, { 0x093C, 0x093C }, { 0x0941, 0x0948 },
-    { 0x094D, 0x094D }, { 0x0951, 0x0954 }, { 0x0962, 0x0963 },
-    { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 },
-    { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 },
-    { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 },
-    { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 },
-    { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 },
-    { 0x0ACD, 0x0ACD }, { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 },
-    { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
-    { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
-    { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
-    { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
-    { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 },
-    { 0x0CCC, 0x0CCD }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
-    { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
-    { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
-    { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
-    { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
-    { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
-    { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
-    { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
-    { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
-    { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x1712, 0x1714 },
-    { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 },
-    { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
-    { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D },
-    { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, { 0x1927, 0x1928 },
-    { 0x1932, 0x1932 }, { 0x1939, 0x193B }, { 0x200B, 0x200F },
-    { 0x202A, 0x202E }, { 0x2060, 0x2063 }, { 0x206A, 0x206F },
-    { 0x20D0, 0x20EA }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
-    { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE23 },
-    { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, { 0x1D167, 0x1D169 },
-    { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
-    { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, { 0xE0100, 0xE01EF }
+    {0x0300, 0x0357}, {0x035D, 0x036F}, {0x0483, 0x0486},
+    {0x0488, 0x0489}, {0x0591, 0x05A1}, {0x05A3, 0x05B9},
+    {0x05BB, 0x05BD}, {0x05BF, 0x05BF}, {0x05C1, 0x05C2},
+    {0x05C4, 0x05C4}, {0x0600, 0x0603}, {0x0610, 0x0615},
+    {0x064B, 0x0658}, {0x0670, 0x0670}, {0x06D6, 0x06E4},
+    {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x070F, 0x070F},
+    {0x0711, 0x0711}, {0x0730, 0x074A}, {0x07A6, 0x07B0},
+    {0x0901, 0x0902}, {0x093C, 0x093C}, {0x0941, 0x0948},
+    {0x094D, 0x094D}, {0x0951, 0x0954}, {0x0962, 0x0963},
+    {0x0981, 0x0981}, {0x09BC, 0x09BC}, {0x09C1, 0x09C4},
+    {0x09CD, 0x09CD}, {0x09E2, 0x09E3}, {0x0A01, 0x0A02},
+    {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42}, {0x0A47, 0x0A48},
+    {0x0A4B, 0x0A4D}, {0x0A70, 0x0A71}, {0x0A81, 0x0A82},
+    {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5}, {0x0AC7, 0x0AC8},
+    {0x0ACD, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0B01, 0x0B01},
+    {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, {0x0B41, 0x0B43},
+    {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B82, 0x0B82},
+    {0x0BC0, 0x0BC0}, {0x0BCD, 0x0BCD}, {0x0C3E, 0x0C40},
+    {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
+    {0x0CBC, 0x0CBC}, {0x0CBF, 0x0CBF}, {0x0CC6, 0x0CC6},
+    {0x0CCC, 0x0CCD}, {0x0D41, 0x0D43}, {0x0D4D, 0x0D4D},
+    {0x0DCA, 0x0DCA}, {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6},
+    {0x0E31, 0x0E31}, {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E},
+    {0x0EB1, 0x0EB1}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},
+    {0x0EC8, 0x0ECD}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35},
+    {0x0F37, 0x0F37}, {0x0F39, 0x0F39}, {0x0F71, 0x0F7E},
+    {0x0F80, 0x0F84}, {0x0F86, 0x0F87}, {0x0F90, 0x0F97},
+    {0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102D, 0x1030},
+    {0x1032, 0x1032}, {0x1036, 0x1037}, {0x1039, 0x1039},
+    {0x1058, 0x1059}, {0x1160, 0x11FF}, {0x1712, 0x1714},
+    {0x1732, 0x1734}, {0x1752, 0x1753}, {0x1772, 0x1773},
+    {0x17B4, 0x17B5}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6},
+    {0x17C9, 0x17D3}, {0x17DD, 0x17DD}, {0x180B, 0x180D},
+    {0x18A9, 0x18A9}, {0x1920, 0x1922}, {0x1927, 0x1928},
+    {0x1932, 0x1932}, {0x1939, 0x193B}, {0x200B, 0x200F},
+    {0x202A, 0x202E}, {0x2060, 0x2063}, {0x206A, 0x206F},
+    {0x20D0, 0x20EA}, {0x302A, 0x302F}, {0x3099, 0x309A},
+    {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23},
+    {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0x1D167, 0x1D169},
+    {0x1D173, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD},
+    {0xE0001, 0xE0001}, {0xE0020, 0xE007F}, {0xE0100, 0xE01EF}
   };
 
   /* test for 8-bit control characters */
@@ -185,25 +186,21 @@ int wcwidth_ucs (wchar_t ucs)
     return -1;
 
   /* binary search in table of non-spacing characters */
-  if (bisearch(ucs, combining,
-              sizeof(combining) / sizeof(struct interval) - 1))
+  if (bisearch (ucs, combining,
+                sizeof (combining) / sizeof (struct interval) - 1))
     return 0;
 
   /* if we arrive here, ucs is not a combining or C0/C1 control character */
 
-  return 1 + 
-    (ucs >= 0x1100 &&
-     (ucs <= 0x115f ||                    /* Hangul Jamo init. consonants */
-      ucs == 0x2329 || ucs == 0x232a ||
-      (ucs >= 0x2e80 && ucs <= 0xa4cf &&
-       ucs != 0x303f) ||                  /* CJK ... Yi */
-      (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
-      (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
-      (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
-      (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */
-      (ucs >= 0xffe0 && ucs <= 0xffe6) ||
-      (ucs >= 0x20000 && ucs <= 0x2fffd) ||
-      (ucs >= 0x30000 && ucs <= 0x3fffd)));
+  return 1 + (ucs >= 0x1100 && (ucs <= 0x115f ||        /* Hangul Jamo init. consonants */
+                                ucs == 0x2329 || ucs == 0x232a || (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs != 0x303f) ||  /* CJK ... Yi */
+                                (ucs >= 0xac00 && ucs <= 0xd7a3) ||     /* Hangul Syllables */
+                                (ucs >= 0xf900 && ucs <= 0xfaff) ||     /* CJK Compatibility Ideographs */
+                                (ucs >= 0xfe30 && ucs <= 0xfe6f) ||     /* CJK Compatibility Forms */
+                                (ucs >= 0xff00 && ucs <= 0xff60) ||     /* Fullwidth Forms */
+                                (ucs >= 0xffe0 && ucs <= 0xffe6) ||
+                                (ucs >= 0x20000 && ucs <= 0x2fffd) ||
+                                (ucs >= 0x30000 && ucs <= 0x3fffd)));
 }
 
 #endif /* !HAVE_WC_FUNCS */