Commit 248c2ee8 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Clean up code indentation.

These are mostly automated changes corresponding to the emacs
settings:
  (c-set-style "linux")
  (setq c-basic-offset 2)
  (c-set-offset 'case-label '+)

Most of the code follows the convention:
  (add-to-list 'c-cleanup-list 'space-before-funcall)
but this is not enforced by this indentation cleanup.

Also, I personally dislike tabs, so I have:
  (setq-default indent-tabs-mode nil)
in my own configuration.  However I have no desire to change every line
just for that effect.  So this cleanup does nothing about the mix issue.

Some of the secondary files (e.g. regex.c) have been skipped.

I've also skipped crypt-gpgme.c, because I need to think about that
file.  Werner Koch and the GnuPG team contributed most it, and it
follows the Gnu indentation settings.  It should probably be made
uniform with Mutt, but I don't want to discourage future GnuPG
contribution to the file.

I manually reverted a few unsightly cleanups, and added a few tweeks
when I saw things that could be improved.
parent 085a6f74
Pipeline #42197293 passed with stages
in 2 minutes and 59 seconds
......@@ -388,7 +388,7 @@ retry_name:
return;
fseek_err:
fseek_err:
mutt_perror (_("Error seeking in alias file"));
safe_fclose (&rc);
return;
......
......@@ -295,7 +295,7 @@ int mutt_edit_attachment (BODY *a)
rc = 1;
bailout:
bailout:
if(unlink_newfile)
unlink(mutt_b2s (newfile));
......@@ -313,15 +313,17 @@ void mutt_check_lookup_list (BODY *b, char *type, int len)
LIST *t = MimeLookupList;
int i;
for (; t; t = t->next) {
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) {
ascii_strcasecmp (type, t->data) == 0)
{
BODY tmp = {0};
int n;
if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) {
if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER)
{
snprintf (type, len, "%s/%s",
n == TYPEAUDIO ? "audio" :
n == TYPEAPPLICATION ? "application" :
......@@ -607,7 +609,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
else
rc = 0;
return_error:
return_error:
if (entry)
rfc1524_free_entry (&entry);
......
......@@ -157,7 +157,7 @@ FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp)
s = strchr (s + 1, '/');
}
out:
out:
dprint (3, (debugfile, "bcache: put: '%s'\n", path));
return fp;
......
......@@ -226,9 +226,15 @@ folder_format_str (char *dest, size_t destlen, size_t col, int cols, char op, co
s = NONULL (folder->ff->name);
snprintf (fn, sizeof (fn), "%s%s", s,
folder->ff->local ? (S_ISLNK (folder->ff->mode) ? "@" :
(S_ISDIR (folder->ff->mode) ? "/" :
((folder->ff->mode & S_IXUSR) != 0 ? "*" : ""))) : "");
folder->ff->local ?
(S_ISLNK (folder->ff->mode) ?
"@" :
(S_ISDIR (folder->ff->mode) ?
"/" :
((folder->ff->mode & S_IXUSR) != 0 ?
"*" :
""))) :
"");
mutt_format_s (dest, destlen, fmt, fn);
break;
......@@ -1324,7 +1330,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
}
}
bail:
bail:
if (menu)
{
......
......@@ -462,7 +462,7 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
return (-1);
}
if(
if (
#ifdef HAVE_COLOR
/* we're running without curses */
option (OPTNOCURSES)
......
......@@ -223,7 +223,8 @@ int mutt_display_message (HEADER *cur)
}
res = mutt_copy_message (fpout, Context, cur, cmflags,
(option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM | CH_DISPLAY);
(option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
CH_DECODE | CH_FROM | CH_DISPLAY);
if ((safe_fclose (&fpout) != 0 && errno != EPIPE) || res < 0)
{
mutt_error (_("Could not copy message"));
......
......@@ -79,7 +79,9 @@ int mutt_complete (char *s, size_t slen)
if ((p = strrchr (s, '/')))
{
char buf[_POSIX_PATH_MAX];
if (mutt_concatn_path (buf, sizeof(buf), exp_dirpart, strlen(exp_dirpart), s + 1, (size_t)(p - s - 1)) == NULL) {
if (mutt_concatn_path (buf, sizeof(buf), exp_dirpart, strlen(exp_dirpart),
s + 1, (size_t)(p - s - 1)) == NULL)
{
return -1;
}
strfcpy (exp_dirpart, buf, sizeof (exp_dirpart));
......
......@@ -1207,8 +1207,8 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
CHECK_COUNT;
strfcpy (fname, CURATTACH->content->filename, sizeof (fname));
mutt_pretty_mailbox (fname, sizeof (fname));
if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), MUTT_FILE)
== 0 && fname[0])
if ((mutt_get_field (_("Rename to: "), fname, sizeof (fname), MUTT_FILE) == 0)
&& fname[0])
{
if (stat(CURATTACH->content->filename, &st) == -1)
{
......
......@@ -325,7 +325,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
return (0);
}
/* flags
/* flags:
CH_DECODE RFC2047 header decoding
CH_FROM retain the "From " message separator
CH_FORCE_FROM give CH_FROM precedence over CH_WEED
......@@ -345,9 +345,9 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
CH_UPDATE_REFS update the References: header
CH_UPDATE_LABEL update the X-Label: header
prefix
prefix:
string to use if CH_PREFIX is set
*/
*/
int
mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
......
......@@ -18,7 +18,7 @@
/*
This is a crytpo module wrapping the classic pgp code.
*/
*/
#if HAVE_CONFIG_H
# include "config.h"
......@@ -107,7 +107,7 @@ static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE *fp, int tag,
}
struct crypt_module_specs crypt_mod_pgp_classic =
{ APPLICATION_PGP,
{ APPLICATION_PGP,
{
NULL, /* init */
crypt_mod_pgp_void_passphrase,
......@@ -134,4 +134,4 @@ struct crypt_module_specs crypt_mod_pgp_classic =
NULL, /* smime_build_smime_entity */
NULL, /* smime_invoke_import */
}
};
};
......@@ -18,7 +18,7 @@
/*
This is a crytpo module wrapping the gpgme based pgp code.
*/
*/
#if HAVE_CONFIG_H
# include "config.h"
......@@ -106,7 +106,7 @@ static void crypt_mod_pgp_set_sender (const char *sender)
}
struct crypt_module_specs crypt_mod_pgp_gpgme =
{ APPLICATION_PGP,
{ APPLICATION_PGP,
{
/* Common. */
crypt_mod_pgp_init,
......@@ -135,6 +135,6 @@ struct crypt_module_specs crypt_mod_pgp_gpgme =
NULL, /* smime_build_smime_entity */
NULL, /* smime_invoke_import */
}
};
};
#endif
......@@ -18,7 +18,7 @@
/*
This is a crytpo module wrapping the classic smime code.
*/
*/
#if HAVE_CONFIG_H
# include "config.h"
......@@ -88,7 +88,7 @@ static void crypt_mod_smime_invoke_import (char *infile, char *mailbox)
struct crypt_module_specs crypt_mod_smime_classic =
{ APPLICATION_SMIME,
{ APPLICATION_SMIME,
{
NULL, /* init */
crypt_mod_smime_void_passphrase,
......@@ -115,4 +115,4 @@ struct crypt_module_specs crypt_mod_smime_classic =
crypt_mod_smime_build_smime_entity,
crypt_mod_smime_invoke_import,
}
};
};
......@@ -18,7 +18,7 @@
/*
This is a crytpo module wrapping the gpgme based smime code.
*/
*/
#if HAVE_CONFIG_H
# include "config.h"
......@@ -86,7 +86,7 @@ static int crypt_mod_smime_verify_sender (HEADER *h)
}
struct crypt_module_specs crypt_mod_smime_gpgme =
{ APPLICATION_SMIME,
{ APPLICATION_SMIME,
{
crypt_mod_smime_init,
crypt_mod_smime_void_passphrase,
......@@ -113,6 +113,6 @@ struct crypt_module_specs crypt_mod_smime_gpgme =
crypt_mod_smime_build_smime_entity,
NULL, /* smime_invoke_import */
}
};
};
#endif
......@@ -743,8 +743,7 @@ void crypt_extract_keys_from_messages (HEADER * h)
if (Context->hdrs[Context->v2r[i]]->env->from)
tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]->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 (Context->hdrs[Context->v2r[i]]->env->sender);
mbox = tmp ? tmp->mailbox : NULL;
if (mbox)
{
......@@ -776,9 +775,9 @@ void crypt_extract_keys_from_messages (HEADER * h)
&& (h->security & APPLICATION_SMIME))
{
if (h->security & ENCRYPT)
mutt_copy_message (fpout, Context, h, MUTT_CM_NOHEADER
|MUTT_CM_DECODE_CRYPT
|MUTT_CM_DECODE_SMIME, 0);
mutt_copy_message (fpout, Context, h,
MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
0);
else
mutt_copy_message (fpout, Context, h, 0, 0);
......
......@@ -64,14 +64,16 @@ 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 *No_visible = N_("No visible messages.");
#define CHECK_IN_MAILBOX if (!Context) \
#define CHECK_IN_MAILBOX \
if (!Context) \
{ \
mutt_flushinp (); \
mutt_error _(No_mailbox_is_open); \
break; \
}
#define CHECK_MSGCOUNT if (!Context) \
#define CHECK_MSGCOUNT \
if (!Context) \
{ \
mutt_flushinp (); \
mutt_error _(No_mailbox_is_open); \
......@@ -84,15 +86,17 @@ static const char *No_visible = N_("No visible messages.");
break; \
}
#define CHECK_VISIBLE if (Context && menu->current >= Context->vcount) \
{\
#define CHECK_VISIBLE \
if (Context && menu->current >= Context->vcount) \
{ \
mutt_flushinp (); \
mutt_error _(No_visible); \
break; \
}
#define CHECK_READONLY if (Context->readonly) \
#define CHECK_READONLY \
if (Context->readonly) \
{ \
mutt_flushinp (); \
mutt_error _(Mailbox_is_read_only); \
......@@ -100,15 +104,17 @@ static const char *No_visible = N_("No visible messages.");
}
#define CHECK_ACL(aclbit,action) \
if (!mutt_bit_isset(Context->rights,aclbit)) { \
if (!mutt_bit_isset(Context->rights,aclbit)) \
{ \
mutt_flushinp(); \
/* L10N: %s is one of the CHECK_ACL entries below. */ \
mutt_error (_("%s: Operation not permitted by ACL"), action); \
break; \
}
#define CHECK_ATTACH if(option(OPTATTACHMSG)) \
{\
#define CHECK_ATTACH \
if (option(OPTATTACHMSG)) \
{ \
mutt_flushinp (); \
mutt_error _(Function_not_permitted_in_attach_message_mode); \
break; \
......
......@@ -368,8 +368,8 @@ struct
char *machine;
char *human;
}
types[] =
{
types[] =
{
{ "DT_NONE", "-none-" },
{ "DT_BOOL", "boolean" },
{ "DT_NUM", "number" },
......@@ -384,7 +384,7 @@ types[] =
{ "DT_ADDR", "e-mail address" },
{ "DT_MBCHARTBL", "string" },
{ NULL, NULL }
};
};
static int buff2type (const char *s)
......
......@@ -191,7 +191,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
mx_close_mailbox (&tmpctx, NULL);
bail:
bail:
if (fp) safe_fclose (&fp);
if (rc >= 0)
......
......@@ -579,8 +579,9 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
else if (flags & MUTT_ALIAS && ch == OP_EDITOR_COMPLETE)
{
/* 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->curpos;
i && state->wbuf[i-1] != ',' && state->wbuf[i-1] != ':';
i--)
;
for (; i < state->lastchar && state->wbuf[i] == ' '; i++)
;
......@@ -596,8 +597,9 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
}
else if (flags & MUTT_LABEL && ch == OP_EDITOR_COMPLETE)
{
for (i = state->curpos; i && state->wbuf[i-1] != ',' &&
state->wbuf[i-1] != ':'; i--)
for (i = state->curpos;
i && state->wbuf[i-1] != ',' && state->wbuf[i-1] != ':';
i--)
;
for (; i < state->lastchar && state->wbuf[i] == ' '; i++)
;
......@@ -665,7 +667,8 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
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 &&
if ((!tempbuf && !state->lastchar) ||
(tempbuf && templen == state->lastchar &&
!memcmp (tempbuf, state->wbuf, state->lastchar * sizeof (wchar_t))))
{
_mutt_select_file (buf, buflen,
......@@ -816,7 +819,7 @@ self_insert:
}
}
bye:
bye:
mutt_reset_history_state (hclass);
FREE (&tempbuf);
......
......@@ -1015,7 +1015,8 @@ static int alternative_handler (BODY *a, STATE *s)
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);
(long) st.st_size,
ascii_strcasecmp ("digest", a->subtype) == 0);
}
else
b = a;
......@@ -1241,7 +1242,8 @@ static int multipart_handler (BODY *a, STATE *s)
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);
(long) st.st_size,
ascii_strcasecmp ("digest", a->subtype) == 0);
}
else
b = a;
......
......@@ -1288,13 +1288,13 @@ hcache_open_db4 (struct header_cache* h, const char* path)
return 0;
fail_db:
fail_db:
h->db->close (h->db, 0);
fail_env:
fail_env:
h->env->close (h->env, 0);
fail_unlock:
fail_unlock:
mx_unlock_file (h->lockfile, h->fd, 0);
fail_close:
fail_close:
close (h->fd);
unlink (h->lockfile);
......
......@@ -465,7 +465,9 @@ hdr_format_str (char *dest,
case 'H':
/* (Hormel) spam score */
if (optional)
{
optional = hdr->env->spam ? 1 : 0;
}
if (hdr->env->spam)
mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->spam->data));
......
......@@ -604,8 +604,8 @@ static char *_mutt_string_hook (const char *match, int hook)
for (; tmp; tmp = tmp->next)
{
if ((tmp->type & hook) && ((match &&
regexec (tmp->rx.rx, match, 0, NULL, 0) == 0) ^ tmp->rx.not))
if ((tmp->type & hook) &&
((match && regexec (tmp->rx.rx, match, 0, NULL, 0) == 0) ^ tmp->rx.not))
return (tmp->command);
}
return (NULL);
......
......@@ -69,7 +69,7 @@ imap_auth_res_t imap_auth_anon (IMAP_DATA* idata, const char* method)
if (imap_code (idata->buf))
return IMAP_AUTH_SUCCESS;
bail:
bail:
mutt_error _("Anonymous authentication failed.");
mutt_sleep (2);
return IMAP_AUTH_FAILURE;
......
......@@ -124,7 +124,7 @@ imap_auth_res_t imap_auth_cram_md5 (IMAP_DATA* idata, const char* method)
if (imap_code (idata->buf))
return IMAP_AUTH_SUCCESS;
bail:
bail:
mutt_error _("CRAM-MD5 authentication failed.");
mutt_sleep (2);
return IMAP_AUTH_FAILURE;
......
......@@ -319,13 +319,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;
......
......@@ -220,7 +220,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method)
return IMAP_AUTH_SUCCESS;
}
bail:
bail:
sasl_dispose (&saslconn);
FREE (&buf);
......
......@@ -202,7 +202,7 @@ int imap_browse (char* path, struct browser_state* state)
FREE (&mx.mbox);
return 0;
fail:
fail:
if (save_lsub)
set_option (OPTIMAPCHECKSUBSCRIBED);
FREE (&mx.mbox);
......@@ -259,7 +259,7 @@ int imap_mailbox_create (const char* folder)
FREE (&mx.mbox);
return 0;
fail:
fail:
FREE (&mx.mbox);
return -1;
}
......@@ -317,7 +317,7 @@ int imap_mailbox_rename(const char* mailbox)
FREE (&mx.mbox);
return 0;
fail:
fail:
FREE (&mx.mbox);
return -1;
}
......
......@@ -336,8 +336,8 @@ static int imap_check_capabilities (IMAP_DATA* idata)
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 */
......@@ -529,10 +529,10 @@ int imap_open_connection (IMAP_DATA* idata)
return 0;
#if defined(USE_SSL)
err_close_conn:
err_close_conn:
imap_close_connection (idata);
#endif
bail:
bail:
FREE (&idata->capstr);
return -1;
}
......@@ -787,8 +787,8 @@ static int imap_open_mailbox (CONTEXT* ctx)
goto fail;
/* check for READ-ONLY notification */
if (!ascii_strncasecmp (imap_get_qualifier (idata->buf), "[READ-ONLY]", 11) \
&& !mutt_bit_isset (idata->capabilities, ACL))
if (!ascii_strncasecmp (imap_get_qualifier (idata->buf), "[READ-ONLY]", 11) &&
!mutt_bit_isset (idata->capabilities, ACL))
{
dprint (2, (debugfile, "Mailbox is read-only.\n"));
ctx->readonly = 1;
......@@ -839,10 +839,10 @@ static int imap_open_mailbox (CONTEXT* ctx)
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;
}
......@@ -1464,7 +1464,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
rc = 0;
out:
out:
if (appendctx)
{
mx_fastclose_mailbox (appendctx);
......@@ -2072,7 +2072,7 @@ int imap_subscribe (char *path, int subscribe)
FREE (&mx.mbox);
return 0;
fail:
fail:
FREE (&mx.mbox);
return -1;
}
......@@ -2340,7 +2340,7 @@ int imap_fast_trash (CONTEXT* ctx, char* dest)
rc = 0;
out:
out:
mutt_buffer_free (&sync_cmd);
FREE (&mx.mbox);
......
......@@ -1027,7 +1027,7 @@ int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
msg_cache_commit (idata, h);
parsemsg:
parsemsg:
/* Update the header information. Previously, we only downloaded a
* portion of the headers, those required for the main display.
*/
......@@ -1228,7 +1228,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
FREE (&mx.mbox);
return 0;
fail:
fail:
FREE (&mx.mbox);
return -1;
}
......@@ -1404,7 +1404,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
rc = 0;
out:
out:
if (cmd.data)
FREE (&cmd.data);
if (sync_cmd.data)
......
......@@ -134,7 +134,7 @@ static char *utf7_to_utf8 (const char *u7, size_t u7len, char **u8,
*u8 = buf;
return buf;
bail:
bail:
FREE (&buf);
return 0;
}
......@@ -247,7 +247,7 @@ static char *utf8_to_utf7 (const char *u8, size_t u8len, char **u7,
if (u7) *u7 = buf;
return buf;
bail:
bail:
FREE (&buf);
return 0;
}
......
......@@ -744,7 +744,7 @@ static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER
mutt_group_context_destroy (&gc);
return 0;
bail:
bail:
mutt_group_context_destroy (&gc);
return -1;
}
......@@ -1022,7 +1022,7 @@ static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
mutt_group_context_destroy (&gc);
return 0;
bail:
bail:
mutt_group_context_destroy (&gc);
return -1;
}
......@@ -1419,7 +1419,7 @@ static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
mutt_group_context_destroy (&gc);
return 0;
bail:
bail:
mutt_group_context_destroy (&gc);
return -1;
}
......@@ -1573,7 +1573,7 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
mutt_group_context_destroy (&gc);