C99 allows a 'for' loop to define its variable.
This reduces the variable's scope making its use clearer.
else
{
struct NntpServer *nserv = CurrentNewsSrv;
- unsigned int j;
/* default state for news reader mode is browse subscribed newsgroups */
buffy = 0;
- for (j = 0; j < nserv->groups_num; j++)
+ for (unsigned int j = 0; j < nserv->groups_num; j++)
{
struct NntpData *nntp_data = nserv->groups_list[j];
if (nntp_data && nntp_data->subscribed)
if (multiple)
{
char **tfiles = NULL;
- int j, k;
if (menu->tagged)
{
*numfiles = menu->tagged;
tfiles = safe_calloc(*numfiles, sizeof(char *));
- for (j = 0, k = 0; j < state.entrylen; j++)
+ for (int j = 0, k = 0; j < state.entrylen; j++)
{
struct FolderFile ff = state.entry[j];
char full[_POSIX_PATH_MAX];
if (option(OPT_NEWS))
{
struct NntpServer *nserv = CurrentNewsSrv;
- unsigned int j;
if (nntp_newsrc_parse(nserv) < 0)
break;
- for (j = 0; j < nserv->groups_num; j++)
+ for (unsigned int j = 0; j < nserv->groups_num; j++)
{
struct NntpData *nntp_data = nserv->groups_list[j];
if (nntp_data)
}
if (i == OP_SUBSCRIBE_PATTERN)
{
- unsigned int k;
-
- for (k = 0; nserv && k < nserv->groups_num; k++)
+ for (unsigned int k = 0; nserv && (k < nserv->groups_num); k++)
{
struct NntpData *nntp_data = nserv->groups_list[k];
if (nntp_data && nntp_data->group && !nntp_data->subscribed)
bool mutt_check_charset(const char *s, bool strict)
{
- int i;
iconv_t cd;
if (mutt_is_utf8(s))
return true;
if (!strict)
- for (i = 0; PreferredMIMENames[i].key; i++)
+ for (int i = 0; PreferredMIMENames[i].key; i++)
{
if ((mutt_strcasecmp(PreferredMIMENames[i].key, s) == 0) ||
(mutt_strcasecmp(PreferredMIMENames[i].pref, s) == 0))
static char *get_color_name(char *dest, size_t destlen, int val)
{
static const char *const missing[3] = { "brown", "lightgray", "default" };
- int i;
switch (val)
{
return dest;
}
- for (i = 0; Colors[i].name; i++)
+ for (int i = 0; Colors[i].name; i++)
{
if (Colors[i].value == val)
{
static int _mutt_pipe_message(struct Header *h, char *cmd, int decode,
int print, int split, char *sep)
{
- int i, rc = 0;
+ int rc = 0;
pid_t thepid;
FILE *fpout = NULL;
if (WithCrypto && decode)
{
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
if (Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook(Context, Context->hdrs[Context->v2r[i]], MUTT_MESSAGEHOOK);
if (split)
{
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
return 1;
}
set_option(OPT_KEEP_QUIET);
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
*/
int mutt_save_message(struct Header *h, int delete, int decode, int decrypt)
{
- int i, need_buffy_cleanup;
+ int need_buffy_cleanup;
int need_passphrase = 0, app = 0;
char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
struct Context ctx;
{
/* look for the first tagged message */
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
if (Context->magic == MUTT_NOTMUCH)
nm_longrun_init(Context, true);
#endif
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
int mutt_check_traditional_pgp(struct Header *h, int *redraw)
{
- int i;
int rv = 0;
if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
rv = _mutt_check_traditional_pgp(h, redraw);
else
{
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
if (Context->hdrs[Context->v2r[i]]->tagged &&
!(Context->hdrs[Context->v2r[i]]->security & PGP_TRADITIONAL_CHECKED))
{
static void init_header_padding(void)
{
static short done = 0;
- int i;
if (done)
return;
done = 1;
- for (i = 0; i <= HDR_XCOMMENTTO; i++)
+ for (int i = 0; i <= HDR_XCOMMENTTO; i++)
calc_header_width_padding(i, _(Prompts[i]), 1);
/* Don't include "Sign as: " in the MaxHeaderWidth calculation. It
* the other fields look funny. */
calc_header_width_padding(HDR_CRYPTINFO, _(Prompts[HDR_CRYPTINFO]), 0);
- for (i = 0; i <= HDR_XCOMMENTTO; i++)
+ for (int i = 0; i <= HDR_XCOMMENTTO; i++)
{
HeaderPadding[i] += MaxHeaderWidth;
if (HeaderPadding[i] < 0)
*/
static unsigned long cum_attachs_size(struct Menu *menu)
{
- size_t s;
- unsigned short i;
+ size_t s = 0;
struct AttachCtx *actx = menu->data;
struct AttachPtr **idx = actx->idx;
struct Content *info = NULL;
struct Body *b = NULL;
- for (i = 0, s = 0; i < actx->idxlen; i++)
+ for (unsigned short i = 0; i < actx->idxlen; i++)
{
b = idx[i]->content;
static int count_delete_lines(FILE *fp, struct Body *b, LOFF_T *length, size_t datelen)
{
int dellines = 0;
- long l;
int ch;
if (b->deleted)
{
fseeko(fp, b->offset, SEEK_SET);
- for (l = b->length; l; l--)
+ for (long l = b->length; l; l--)
{
ch = getc(fp);
if (ch == EOF)
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)
+ for (long l = 10; b->length >= l; l *= 10)
(*length)++;
}
else
/* Restore the cursor */
mutt_set_virtual(Context);
- int j;
- for (j = 0; j < Context->vcount; j++)
+ for (int j = 0; j < Context->vcount; j++)
{
if (Context->hdrs[Context->v2r[j]]->index == base->index)
{
static int ci_next_undeleted(int msgno)
{
- int i;
-
- for (i = msgno + 1; i < Context->vcount; i++)
+ for (int i = msgno + 1; i < Context->vcount; i++)
if (!Context->hdrs[Context->v2r[i]]->deleted)
return i;
return -1;
static int ci_previous_undeleted(int msgno)
{
- int i;
-
- for (i = msgno - 1; i >= 0; i--)
+ for (int i = msgno - 1; i >= 0; i--)
if (!Context->hdrs[Context->v2r[i]]->deleted)
return i;
return -1;
*/
static int ci_first_message(void)
{
- int old = -1, i;
+ int old = -1;
if (Context && Context->msgcount)
{
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (!Context->hdrs[Context->v2r[i]]->read &&
!Context->hdrs[Context->v2r[i]]->deleted)
static void resort_index(struct Menu *menu)
{
- int i;
struct Header *current = CURHDR;
menu->current = -1;
mutt_sort_headers(Context, 0);
/* Restore the current message */
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]] == current)
{
{
/* store pointers to the newly added messages */
struct Header **save_new = NULL;
- int j;
if (!menu || !ctx)
return;
* they will be visible in the limited view */
if (ctx->pattern)
{
- for (j = (check == MUTT_REOPENED) ? 0 : oldcount; j < ctx->msgcount; j++)
+ for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->msgcount; i++)
{
- if (!j)
+ if (!i)
ctx->vcount = 0;
if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx,
- ctx->hdrs[j], NULL))
+ ctx->hdrs[i], NULL))
{
assert(ctx->vcount < ctx->msgcount);
- ctx->hdrs[j]->virtual = ctx->vcount;
- ctx->v2r[ctx->vcount] = j;
- ctx->hdrs[j]->limited = true;
+ ctx->hdrs[i]->virtual = ctx->vcount;
+ ctx->v2r[ctx->vcount] = i;
+ ctx->hdrs[i]->limited = true;
ctx->vcount++;
- struct Body *b = ctx->hdrs[j]->content;
+ struct Body *b = ctx->hdrs[i]->content;
ctx->vsize += b->length + b->offset - b->hdr_offset;
}
}
((Sort & SORT_MASK) == SORT_THREADS))
{
save_new = safe_malloc(sizeof(struct Header *) * (ctx->msgcount - oldcount));
- for (j = oldcount; j < ctx->msgcount; j++)
- save_new[j - oldcount] = ctx->hdrs[j];
+ for (int i = oldcount; i < ctx->msgcount; i++)
+ save_new[i - oldcount] = ctx->hdrs[i];
}
/* if the mailbox was reopened, need to rethread from scratch */
}
else if (oldcount)
{
- for (j = 0; j < ctx->msgcount - oldcount; j++)
+ for (int i = 0; i < ctx->msgcount - oldcount; i++)
{
- int k;
-
- for (k = 0; k < ctx->msgcount; k++)
+ for (int k = 0; k < ctx->msgcount; k++)
{
struct Header *h = ctx->hdrs[k];
- if (h == save_new[j] && (!ctx->pattern || h->limited))
+ if (h == save_new[i] && (!ctx->pattern || h->limited))
mutt_uncollapse_thread(ctx, h);
}
}
if (oldcount)
{
/* restore the current message to the message it was pointing to */
- for (j = 0; j < ctx->vcount; j++)
+ for (int i = 0; i < ctx->vcount; i++)
{
- if (ctx->hdrs[ctx->v2r[j]]->index == menu->oldcurrent)
+ if (ctx->hdrs[ctx->v2r[i]]->index == menu->oldcurrent)
{
- menu->current = j;
+ menu->current = i;
break;
}
}
{
struct Header *oldcur = CURHDR;
struct Header *hdr = NULL;
- int k;
bool quiet = Context->quiet;
if (rc2 < 0)
/* try to restore old position */
else
{
- for (k = 0; k < Context->msgcount; k++)
+ for (int k = 0; k < Context->msgcount; k++)
{
if (Context->hdrs[k]->index == oldindex)
{
int mutt_edit_message(struct Context *ctx, struct Header *hdr)
{
- int j;
-
if (hdr)
return edit_one_message(ctx, hdr);
for (int i = 0; i < ctx->vcount; i++)
{
- j = ctx->v2r[i];
+ int j = ctx->v2r[i];
if (ctx->hdrs[j]->tagged)
{
if (edit_one_message(ctx, ctx->hdrs[j]) == -1)
*/
void mutt_tag_set_flag(int flag, int bf)
{
- for (int j = 0; j < Context->vcount; j++)
- if (Context->hdrs[Context->v2r[j]]->tagged)
- mutt_set_flag(Context, Context->hdrs[Context->v2r[j]], flag, bf);
+ for (int i = 0; i < Context->vcount; i++)
+ if (Context->hdrs[Context->v2r[i]]->tagged)
+ mutt_set_flag(Context, Context->hdrs[Context->v2r[i]], flag, bf);
}
int mutt_thread_set_flag(struct Header *hdr, int flag, int bf, int subthread)
return 1;
else if (a->type == TYPEMULTIPART)
{
- struct Body *p = NULL;
-
if (WithCrypto)
{
if ((mutt_strcasecmp(a->subtype, "signed") == 0) ||
return 1;
}
- for (p = a->parts; p; p = p->next)
+ for (struct Body *b = a->parts; b; b = b->next)
{
- if (mutt_can_decode(p))
+ if (mutt_can_decode(b))
return 1;
}
}
int mutt_label_message(struct Header *hdr)
{
char buf[LONG_STRING], *new = NULL;
- int i;
int changed;
if (!Context || !Context->label_hash)
else
{
#define HDR_OF(index) Context->hdrs[Context->v2r[(index)]]
- for (i = 0; i < Context->vcount; ++i)
+ for (int i = 0; i < Context->vcount; ++i)
{
if (HDR_OF(i)->tagged)
if (label_message(Context, HDR_OF(i), new))
static const struct Binding *help_lookup_function(int op, int menu)
{
- int i;
const struct Binding *map = NULL;
if (menu != MENU_PAGER)
{
/* first look in the generic map for the function */
- for (i = 0; OpGeneric[i].name; i++)
+ for (int i = 0; OpGeneric[i].name; i++)
if (OpGeneric[i].op == op)
return (&OpGeneric[i]);
}
if ((map = km_get_table(menu)))
{
- for (i = 0; map[i].name; i++)
+ for (int i = 0; map[i].name; i++)
if (map[i].op == op)
return (&map[i]);
}
static void init_history(struct History *h)
{
- int i;
-
if (OldSize)
{
if (h->hist)
{
- for (i = 0; i <= OldSize; i++)
+ for (int i = 0; i <= OldSize; i++)
FREE(&h->hist[i]);
FREE(&h->hist);
}
{
static int n = 0;
FILE *f = NULL;
- char *tmp = NULL, *p = NULL;
+ char *tmp = NULL;
if (!s || !*s) /* This shouldn't happen, but it's safer. */
return;
/* Format of a history item (1 line): "<histclass>:<string>|".
We add a '|' in order to avoid lines ending with '\'. */
fprintf(f, "%d:", (int) hclass);
- for (p = tmp; *p; p++)
+ for (char *p = tmp; *p; p++)
{
/* Don't copy \n as a history item must fit on one line. The string
shouldn't contain such a character anyway, but as this can happen
*/
static void cmd_parse_capability(struct ImapData *idata, char *s)
{
- int x;
bool found;
char *bracket = NULL;
while (*s)
{
found = false;
- for (x = 0; x < CAPMAX; x++)
- if (imap_wordcasecmp(Capabilities[x], s) == 0)
+ for (int i = 0; i < CAPMAX; i++)
+ {
+ if (imap_wordcasecmp(Capabilities[i], s) == 0)
{
- mutt_bit_set(idata->capabilities, x);
- mutt_debug(4, " Found capability \"%s\": %d\n", Capabilities[x], x);
+ mutt_bit_set(idata->capabilities, i);
+ mutt_debug(4, " Found capability \"%s\": %d\n", Capabilities[i], i);
found = true;
break;
}
+ }
if (!found)
{
- for (x = 0; CapabilityAliases[x].name != NULL; x++)
+ for (int i = 0; CapabilityAliases[i].name != NULL; i++)
{
- if (imap_wordcasecmp(CapabilityAliases[x].name, s) == 0)
+ if (imap_wordcasecmp(CapabilityAliases[i].name, s) == 0)
{
- mutt_bit_set(idata->capabilities, CapabilityAliases[x].value);
+ mutt_bit_set(idata->capabilities, CapabilityAliases[i].value);
mutt_debug(4, " Found capability \"%s\": %d\n",
- CapabilityAliases[x].name, CapabilityAliases[x].value);
+ CapabilityAliases[i].name, CapabilityAliases[i].value);
break;
}
}
struct Header *h = NULL;
struct Header **hdrs = NULL;
int oldsort;
- int n;
int rc;
idata = ctx->data;
{
/* 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 = false;
+ for (int i = 0; i < ctx->msgcount; i++)
+ if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->changed)
+ ctx->hdrs[i]->active = false;
mutt_message(_("Marking %d messages deleted..."), rc);
}
}
#endif
/* save messages with real (non-flag) changes */
- for (n = 0; n < ctx->msgcount; n++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
- h = ctx->hdrs[n];
+ h = ctx->hdrs[i];
if (h->deleted)
{
if ((h->env && (h->env->refs_changed || h->env->irt_changed)) ||
h->attach_del || h->xlabel_changed)
{
- mutt_message(_("Saving changed messages... [%d/%d]"), n + 1, ctx->msgcount);
+ mutt_message(_("Saving changed messages... [%d/%d]"), i + 1, ctx->msgcount);
if (!appendctx)
appendctx = mx_open_mailbox(ctx->path, MUTT_APPEND | MUTT_QUIET, NULL);
if (!appendctx)
/* Update local record of server state to reflect the synchronization just
* completed. imap_read_headers always overwrites hcache-origin flags, so
* there is no need to mutate the hcache after flag-only changes. */
- for (n = 0; n < ctx->msgcount; n++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
- HEADER_DATA(ctx->hdrs[n])->deleted = ctx->hdrs[n]->deleted;
- HEADER_DATA(ctx->hdrs[n])->flagged = ctx->hdrs[n]->flagged;
- HEADER_DATA(ctx->hdrs[n])->old = ctx->hdrs[n]->old;
- HEADER_DATA(ctx->hdrs[n])->read = ctx->hdrs[n]->read;
- HEADER_DATA(ctx->hdrs[n])->replied = ctx->hdrs[n]->replied;
- ctx->hdrs[n]->changed = false;
+ HEADER_DATA(ctx->hdrs[i])->deleted = ctx->hdrs[i]->deleted;
+ HEADER_DATA(ctx->hdrs[i])->flagged = ctx->hdrs[i]->flagged;
+ HEADER_DATA(ctx->hdrs[i])->old = ctx->hdrs[i]->old;
+ HEADER_DATA(ctx->hdrs[i])->read = ctx->hdrs[i]->read;
+ HEADER_DATA(ctx->hdrs[i])->replied = ctx->hdrs[i]->replied;
+ ctx->hdrs[i]->changed = false;
}
ctx->changed = false;
int imap_close_mailbox(struct Context *ctx)
{
struct ImapData *idata = NULL;
- int i;
idata = ctx->data;
/* Check to see if the mailbox is actually open */
idata->msn_index_size = 0;
idata->max_msn = 0;
- for (i = 0; i < IMAP_CACHE_LEN; i++)
+ for (int i = 0; i < IMAP_CACHE_LEN; i++)
{
if (idata->cache[i].path)
{
}
/* free IMAP part of headers */
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
+ {
/* mailbox may not have fully loaded */
if (ctx->hdrs[i] && ctx->hdrs[i]->data)
imap_free_header_data((struct ImapHeaderData **) &(ctx->hdrs[i]->data));
+ }
return 0;
}
char mbox[LONG_STRING];
char mmbox[LONG_STRING];
char prompt[LONG_STRING];
- int n, rc;
+ int rc;
struct ImapMbox mx;
bool triedcreate = false;
struct Buffer *sync_cmd = NULL;
imap_munge_mbox_name(idata, mmbox, sizeof(mmbox), mbox);
sync_cmd = mutt_buffer_new();
- for (n = 0; n < ctx->msgcount; n++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
- if (ctx->hdrs[n]->active && ctx->hdrs[n]->changed &&
- ctx->hdrs[n]->deleted && !ctx->hdrs[n]->purge)
+ if (ctx->hdrs[i]->active && ctx->hdrs[i]->changed &&
+ ctx->hdrs[i]->deleted && !ctx->hdrs[i]->purge)
{
- rc = imap_sync_message_for_copy(idata, ctx->hdrs[n], sync_cmd, &err_continue);
+ rc = imap_sync_message_for_copy(idata, ctx->hdrs[i], sync_cmd, &err_continue);
if (rc < 0)
{
mutt_debug(1, "imap_fast_trash: could not sync\n");
char mmbox[LONG_STRING];
char prompt[LONG_STRING];
int rc;
- int n;
struct ImapMbox mx;
int err_continue = MUTT_NO;
int triedcreate = 0;
/* 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++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
- if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->attach_del)
+ if (ctx->hdrs[i]->tagged && ctx->hdrs[i]->attach_del)
{
mutt_debug(3, "imap_copy_messages: Message contains attachments to "
"be deleted\n");
return 1;
}
- if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->active && ctx->hdrs[n]->changed)
+ if (ctx->hdrs[i]->tagged && ctx->hdrs[i]->active && ctx->hdrs[i]->changed)
{
- rc = imap_sync_message_for_copy(idata, ctx->hdrs[n], &sync_cmd, &err_continue);
+ rc = imap_sync_message_for_copy(idata, ctx->hdrs[i], &sync_cmd, &err_continue);
if (rc < 0)
{
mutt_debug(1, "imap_copy_messages: could not sync\n");
if (delete)
{
if (!h)
- for (n = 0; n < ctx->msgcount; n++)
+ {
+ for (int i = 0; i < ctx->msgcount; i++)
{
- if (ctx->hdrs[n]->tagged)
+ if (ctx->hdrs[i]->tagged)
{
- mutt_set_flag(ctx, ctx->hdrs[n], MUTT_DELETE, 1);
- mutt_set_flag(ctx, ctx->hdrs[n], MUTT_PURGE, 1);
+ mutt_set_flag(ctx, ctx->hdrs[i], MUTT_DELETE, 1);
+ mutt_set_flag(ctx, ctx->hdrs[i], MUTT_PURGE, 1);
if (option(OPT_DELETE_UNTAG))
- mutt_set_flag(ctx, ctx->hdrs[n], MUTT_TAG, 0);
+ mutt_set_flag(ctx, ctx->hdrs[i], MUTT_TAG, 0);
}
}
+ }
else
{
mutt_set_flag(ctx, h, MUTT_DELETE, 1);
{
char *buf = NULL, *p = NULL;
int ch;
- int n, i, b = 0, k = 0;
+ int n, b = 0, k = 0;
bool base64 = false;
/*
u8len--;
if (n > u8len)
goto bail;
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
if ((u8[i] & 0xc0) != 0x80)
goto bail;
static int parse_ifdef(struct Buffer *tmp, struct Buffer *s, unsigned long data,
struct Buffer *err)
{
- int i, j;
bool res = 0;
struct Buffer token;
/* or a function? */
if (!res)
{
- for (i = 0; !res && (i < MENU_MAX); i++)
+ for (int i = 0; !res && (i < MENU_MAX); i++)
{
const struct Binding *b = km_get_table(Menus[i].value);
if (!b)
continue;
- for (j = 0; b[j].name; j++)
+ for (int j = 0; b[j].name; j++)
{
if (mutt_strcmp(tmp->data, b[j].name) == 0)
{
/* or a command? */
if (!res)
{
- for (i = 0; Commands[i].name; i++)
+ for (int i = 0; Commands[i].name; i++)
{
if (mutt_strcmp(tmp->data, Commands[i].name) == 0)
{
static void _alternates_clean(void)
{
- int i;
if (Context && Context->msgcount)
{
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
Context->hdrs[i]->recip_valid = false;
}
}
static void clear_subject_mods(void)
{
- int i;
if (Context && Context->msgcount)
{
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
FREE(&Context->hdrs[i]->env->disp_subj);
}
}
*/
static void _attachments_clean(void)
{
- int i;
if (Context && Context->msgcount)
{
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
Context->hdrs[i]->attach_valid = false;
}
}
#ifdef DEBUG
if (debuglevel >= 2)
{
- struct Address *a = NULL;
/* A group is terminated with an empty address, so check a->mailbox */
- for (a = tmp->addr; a && a->mailbox; a = a->next)
+ for (struct Address *a = tmp->addr; a && a->mailbox; a = a->next)
{
if (!a->group)
mutt_debug(3, "parse_alias: %s\n", a->mailbox);
static int check_charset(struct Option *opt, const char *val)
{
- char *p = NULL, *q = NULL, *s = safe_strdup(val);
+ char *q = NULL, *s = safe_strdup(val);
int rc = 0;
bool strict = (strcmp(opt->option, "send_charset") == 0);
if (!s)
return rc;
- for (p = strtok_r(s, ":", &q); p; p = strtok_r(NULL, ":", &q))
+ for (char *p = strtok_r(s, ":", &q); p; p = strtok_r(NULL, ":", &q))
{
if (!*p)
continue;
(mutt_strcmp(MuttVars[idx].option, "reply_regexp") == 0))
{
regmatch_t pmatch[1];
- int i;
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
{
struct Envelope *e = Context->hdrs[i]->env;
if (e && e->subject)
if (!dest || !try || !src)
return;
- int l;
-
if (strstr(src, try) == src)
{
matches_ensure_morespace(Num_matched);
strfcpy(dest, src, len);
else
{
+ int l;
for (l = 0; src[l] && src[l] == dest[l]; l++)
;
dest[l] = '\0';
int mutt_get_hook_type(const char *name)
{
- const struct Command *c = NULL;
-
- for (c = Commands; c->name; c++)
+ for (const struct Command *c = Commands; c->name; c++)
if (c->func == mutt_parse_hook && (mutt_strcasecmp(c->name, name) == 0))
return c->data;
return 0;
{
const struct Binding *bindings = NULL;
char *key = NULL;
- int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus, i;
+ int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = 0, nummenus;
if ((key = parse_keymap(menu, s, sizeof(menu) / sizeof(menu[0]), &nummenus, err)) == NULL)
return -1;
}
else if (mutt_strcasecmp("noop", buf->data) == 0)
{
- for (i = 0; i < nummenus; ++i)
+ for (int i = 0; i < nummenus; ++i)
{
km_bindkey(key, menu[i], OP_NULL); /* the `unbind' command */
}
}
else
{
- for (i = 0; i < nummenus; ++i)
+ for (int i = 0; i < nummenus; ++i)
{
/* The pager and editor menus don't use the generic map,
* however for other menus try generic first. */
int mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data,
struct Buffer *err)
{
- int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = -1, nummenus, i;
+ int menu[sizeof(Menus) / sizeof(struct Mapping) - 1], r = -1, nummenus;
char *seq = NULL;
char *key = NULL;
}
else
{
- for (i = 0; i < nummenus; ++i)
+ for (int i = 0; i < nummenus; ++i)
{
r = km_bind(key, menu[i], OP_MACRO, seq, buf->data);
}
}
else
{
- for (i = 0; i < nummenus; ++i)
+ for (int i = 0; i < nummenus; ++i)
{
r = km_bind(key, menu[i], OP_MACRO, buf->data, NULL);
}
}
errno = 0;
- char *p = NULL;
char _path[PATH_MAX];
const size_t len = strlen(path);
/* Create a mutable copy */
strfcpy(_path, path, sizeof(_path));
- for (p = _path + 1; *p; p++)
+ for (char *p = _path + 1; *p; p++)
{
if (*p != '/')
continue;
*/
void sha1_final(unsigned char digest[20], struct Sha1Ctx *context)
{
- unsigned i;
unsigned char finalcount[8];
unsigned char c;
- for (i = 0; i < 8; i++)
+ for (unsigned int i = 0; i < 8; i++)
{
finalcount[i] =
(unsigned char) ((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */
sha1_update(context, &c, 1);
}
sha1_update(context, finalcount, 8); /* Should cause a sha1_transform() */
- for (i = 0; i < 20; i++)
+ for (unsigned int i = 0; i < 20; i++)
{
digest[i] = (unsigned char) ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
}
*/
void mutt_remove_trailing_ws(char *s)
{
- char *p = NULL;
-
- for (p = s + mutt_strlen(s) - 1; p >= s && ISSPACE(*p); p--)
+ for (char *p = s + mutt_strlen(s) - 1; p >= s && ISSPACE(*p); p--)
*p = '\0';
}
{
int needle_length = strlen(needle);
const char *haystack_end = haystack + haystack_length - needle_length;
- const char *p = NULL;
- for (p = haystack_end; p >= haystack; --p)
+ for (const char *p = haystack_end; p >= haystack; --p)
{
for (size_t i = 0; i < needle_length; ++i)
{
void mutt_menu_destroy(struct Menu **p)
{
- int i;
-
if ((*p)->dialog)
{
- for (i = 0; i < (*p)->max; i++)
+ for (int i = 0; i < (*p)->max; i++)
FREE(&(*p)->dialog[i]);
FREE(&(*p)->dialog);
static void apply_exclude_tags(notmuch_query_t *query)
{
- char *buf = NULL, *p = NULL, *end = NULL, *tag = NULL;
+ char *buf = NULL, *end = NULL, *tag = NULL;
if (!NmExcludeTags || !*NmExcludeTags)
return;
buf = safe_strdup(NmExcludeTags);
- for (p = buf; p && *p; p++)
+ for (char *p = buf; p && *p; p++)
{
if (!tag && isspace(*p))
continue;
*/
static int update_header_flags(struct Context *ctx, struct Header *hdr, const char *tags)
{
- char *tag = NULL, *end = NULL, *p = NULL;
+ char *tag = NULL, *end = NULL;
char *buf = safe_strdup(tags);
if (!buf)
return -1;
- for (p = buf; p && *p; p++)
+ for (char *p = buf; p && *p; p++)
{
if (!tag && isspace(*p))
continue;
time_t mtime = 0;
notmuch_query_t *q = NULL;
notmuch_messages_t *msgs = NULL;
- int i, limit, new_flags = 0;
+ int limit, new_flags = 0;
bool occult = false;
if (!data || (get_database_mtime(data, &mtime) != 0))
data->oldmsgcount = ctx->msgcount;
data->noprogress = true;
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
ctx->hdrs[i]->active = false;
limit = get_limit(data);
msgs = notmuch_query_search_messages(q);
#endif
- for (i = 0; notmuch_messages_valid(msgs) && ((limit == 0) || (i < limit));
+ for (int i = 0; notmuch_messages_valid(msgs) && ((limit == 0) || (i < limit));
notmuch_messages_move_to_next(msgs), i++)
{
char old[_POSIX_PATH_MAX];
notmuch_message_destroy(m);
}
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
if (!ctx->hdrs[i]->active)
{
{
unsigned char md[EVP_MAX_MD_SIZE];
unsigned int n;
- int j;
if (!X509_digest(cert, hashfunc(), md, &n))
{
}
else
{
- for (j = 0; j < (int) n; j++)
+ for (int i = 0; i < (int) n; i++)
{
char ch[8];
- snprintf(ch, 8, "%02X%s", md[j], (j % 2 ? " " : ""));
+ snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : ""));
safe_strcat(s, l, ch);
}
}
unsigned char peermd[EVP_MAX_MD_SIZE];
unsigned int peermdlen;
X509 *cert = NULL;
- int i;
if (!X509_digest(peercert, EVP_sha256(), peermd, &peermdlen) || !SslSessionCerts)
{
return false;
}
- for (i = sk_X509_num(SslSessionCerts); i-- > 0;)
+ for (int i = sk_X509_num(SslSessionCerts); i-- > 0;)
{
cert = sk_X509_value(SslSessionCerts, i);
if (compare_certificates(cert, peercert, peermd, peermdlen))
*/
static int check_host(X509 *x509cert, const char *hostname, char *err, size_t errlen)
{
- int i, rc = 0;
+ int rc = 0;
/* hostname in ASCII format: */
char *hostname_ascii = NULL;
/* needed to get the common name: */
if ((subj_alt_names = X509_get_ext_d2i(x509cert, NID_subject_alt_name, NULL, NULL)))
{
subj_alt_names_count = sk_GENERAL_NAME_num(subj_alt_names);
- for (i = 0; i < subj_alt_names_count; i++)
+ for (int i = 0; i < subj_alt_names_count; i++)
{
subj_alt_name = sk_GENERAL_NAME_value(subj_alt_names, i);
if (subj_alt_name->type == GEN_DNS)
char title[STRING];
struct Menu *menu = mutt_new_menu(MENU_GENERIC);
int done, row;
- unsigned u;
FILE *fp = NULL;
int allow_skip = 0;
strfcpy(menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING);
row++;
x509_subject = X509_get_subject_name(cert);
- for (u = 0; u < mutt_array_size(part); u++)
+ for (unsigned int u = 0; u < mutt_array_size(part); u++)
snprintf(menu->dialog[row++], SHORT_STRING, " %s",
x509_get_part(x509_subject, part[u]));
strfcpy(menu->dialog[row], _("This certificate was issued by:"), SHORT_STRING);
row++;
x509_issuer = X509_get_issuer_name(cert);
- for (u = 0; u < mutt_array_size(part); u++)
+ for (unsigned int u = 0; u < mutt_array_size(part); u++)
snprintf(menu->dialog[row++], SHORT_STRING, " %s",
x509_get_part(x509_issuer, part[u]));
{
unsigned char md[36];
size_t n;
- int j;
n = 36;
}
else
{
- for (j = 0; j < (int) n; j++)
+ for (int i = 0; i < (int) n; i++)
{
char ch[8];
- snprintf(ch, 8, "%02X%s", md[j], (j % 2 ? " " : ""));
+ snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : ""));
safe_strcat(s, l, ch);
}
s[2 * n + n / 2 - 1] = '\0'; /* don't want trailing space */
char title[STRING];
FILE *fp = NULL;
gnutls_datum_t pemdata;
- int i, row, done, ret;
+ int row, done, ret;
if (!tls_check_preauth(certdata, certstat, hostname, idx, &certerr, &savedcert))
return 1;
menu = mutt_new_menu(MENU_GENERIC);
menu->max = 25;
menu->dialog = safe_calloc(1, menu->max * sizeof(char *));
- for (i = 0; i < menu->max; i++)
+ for (int i = 0; i < menu->max; i++)
menu->dialog[i] = safe_calloc(1, SHORT_STRING * sizeof(char));
mutt_push_current_menu(menu);
const gnutls_datum_t *cert_list = NULL;
unsigned int cert_list_size = 0;
gnutls_certificate_status_t certstat;
- int certerr, i, preauthrc, savedcert, rc = 0;
+ int certerr, preauthrc, savedcert, rc = 0;
int rcpeer = -1; /* the result of tls_check_preauth() on the peer's EE cert */
if (gnutls_auth_get_type(state) != GNUTLS_CRD_CERTIFICATE)
* from most specific to least checking these. If we see a saved certificate,
* its status short-circuits the remaining checks. */
preauthrc = 0;
- for (i = 0; i < cert_list_size; i++)
+ for (int i = 0; i < cert_list_size; i++)
{
rc = tls_check_preauth(&cert_list[i], certstat, conn->account.host, i,
&certerr, &savedcert);
}
/* then check interactively, starting from chain root */
- for (i = cert_list_size - 1; i >= 0; i--)
+ for (int i = cert_list_size - 1; i >= 0; i--)
{
rc = tls_check_one_certificate(&cert_list[i], certstat, conn->account.host,
i, cert_list_size);
void mutt_safe_path(char *s, size_t l, struct Address *a)
{
- char *p = NULL;
-
mutt_save_path(s, l, a);
- for (p = s; *p; p++)
- if (*p == '/' || ISSPACE(*p) || !IsPrint((unsigned char) *p))
+ for (char *p = s; *p; p++)
+ if ((*p == '/') || ISSPACE(*p) || !IsPrint((unsigned char) *p))
*p = '_';
}
static char twinbuf[2][LONG_STRING];
int switcher = 0;
char *p = NULL;
- int i, n;
+ int n;
size_t cpysize, tlen;
char *src = NULL, *dst = NULL;
n = strtoul(p, &p, 10); /* get subst number */
while (isdigit((unsigned char) *p)) /* skip subst token */
p++;
- for (i = pmatch[n].rm_so;
+ for (int i = pmatch[n].rm_so;
(i < pmatch[n].rm_eo) && (tlen < LONG_STRING - 1); i++)
dst[tlen++] = src[i];
}
/* Iterate expansions across successive arguments */
do
{
- char *p = NULL;
-
/* Extract the command name and copy to command line */
mutt_debug(3, "fmtpipe +++: %s\n", srcbuf->dptr);
if (word->data)
mutt_buffer_addch(command, '\'');
mutt_expando_format(buf, sizeof(buf), 0, cols, word->data, callback,
data, flags | MUTT_FORMAT_NOFILTER);
- for (p = buf; p && *p; p++)
+ for (char *p = buf; p && *p; p++)
{
if (*p == '\'')
/* shell quoting doesn't permit escaping a single quote within
*/
int mx_sync_mailbox(struct Context *ctx, int *index_hint)
{
- int rc, i;
+ int rc;
int purge = 1;
int msgcount, deleted;
/* let IMAP servers hold on to D flags */
if (ctx->magic != MUTT_IMAP)
{
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
ctx->hdrs[i]->deleted = false;
ctx->hdrs[i]->purge = false;
if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE)
{
- struct Body *p = NULL;
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)
+ for (struct Body *b = m->parts; b; b = b->next)
{
- v = crypt_query(p);
+ v = crypt_query(b);
u &= v;
w |= v;
}
void crypt_extract_keys_from_messages(struct Header *h)
{
- int i;
char tempfname[_POSIX_PATH_MAX], *mbox = NULL;
struct Address *tmp = NULL;
FILE *fpout = NULL;
if (!h)
{
- for (i = 0; i < Context->vcount; i++)
+ for (int i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
struct Body *b = a;
struct Body **signatures = NULL;
int sigcnt = 0;
- int i;
bool goodsig = true;
int rc = 0;
mutt_mktemp(tempfile, sizeof(tempfile));
if (crypt_write_signed(a, s, tempfile) == 0)
{
- for (i = 0; i < sigcnt; i++)
+ for (int i = 0; i < sigcnt; i++)
{
if ((WithCrypto & APPLICATION_PGP) && signatures[i]->type == TYPEAPPLICATION &&
(mutt_strcasecmp(signatures[i]->subtype, "pgp-signature") == 0))
static int data_object_to_stream(gpgme_data_t data, FILE *fp)
{
int err;
- char buf[4096], *p = NULL;
+ char buf[4096];
ssize_t nread;
err = ((gpgme_data_seek(data, 0, SEEK_SET) == -1) ? gpgme_error_from_errno(errno) : 0);
{
/* 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--)
+ for (char *p = buf; nread; p++, nread--)
{
if (*p != '\r')
putc(*p, fp);
{
int msgwid;
gpgme_user_id_t uids = NULL;
- int i;
bool aka = false;
state_puts(msg, s);
msgwid = mutt_strwidth(msg) - mutt_strwidth(_("aka: ")) + 1;
if (msgwid < 0)
msgwid = 0;
- for (i = 0; i < msgwid; i++)
+ for (int i = 0; i < msgwid; i++)
state_puts(" ", s);
state_puts(_("aka: "), s);
}
msgwid = mutt_strwidth(msg) - mutt_strwidth(_("created: ")) + 1;
if (msgwid < 0)
msgwid = 0;
- for (i = 0; i < msgwid; i++)
+ for (int i = 0; i < msgwid; i++)
state_puts(" ", s);
state_puts(_("created: "), s);
print_time(sig->timestamp, s);
{
struct DnArray *array = NULL;
size_t arrayidx, arraysize;
- int i;
arraysize = 7; /* C,ST,L,O,OU,CN,email */
array = safe_malloc((arraysize + 1) * sizeof(*array));
arraysize += 5;
a2 = safe_malloc((arraysize + 1) * sizeof(*array));
- for (i = 0; i < arrayidx; i++)
+ for (int i = 0; i < arrayidx; i++)
{
a2[i].key = array[i].key;
a2[i].value = array[i].value;
return array;
failure:
- for (i = 0; i < arrayidx; i++)
+ for (int i = 0; i < arrayidx; i++)
{
FREE(&array[i].key);
FREE(&array[i].value);
static void parse_and_print_user_id(FILE *fp, const char *userid)
{
const char *s = NULL;
- int i;
if (*userid == '<')
{
else
{
print_dn_parts(fp, dn);
- for (i = 0; dn[i].key; i++)
+ for (int i = 0; dn[i].key; i++)
{
FREE(&dn[i].key);
FREE(&dn[i].value);
unsigned long aval = 0;
const char *delim = NULL;
int is_pgp = 0;
- int i;
gpgme_user_id_t uid = NULL;
static int max_header_width = 0;
int width;
if (!max_header_width)
{
- for (i = 0; i < KIP_END; i++)
+ for (int i = 0; i < KIP_END; i++)
{
KeyInfoPadding[i] = mutt_strlen(_(KeyInfoPrompts[i]));
width = mutt_strwidth(_(KeyInfoPrompts[i]));
max_header_width = width;
KeyInfoPadding[i] -= width;
}
- for (i = 0; i < KIP_END; i++)
+ for (int i = 0; i < KIP_END; i++)
KeyInfoPadding[i] += max_header_width;
}
fprintf(fp, "%*s", KeyInfoPadding[KIP_FINGERPRINT], _(KeyInfoPrompts[KIP_FINGERPRINT]));
if (is_pgp && strlen(s) == 40)
{
- for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
+ for (int i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++)
{
putc(*s, fp);
putc(s[1], fp);
}
else
{
- for (i = 0; *s && s[1] && s[2]; s += 2, i++)
+ for (int i = 0; *s && s[1] && s[2]; s += 2, i++)
{
putc(*s, fp);
putc(s[1], fp);
for (unsigned int i = 0; i < nserv->groups_num; i++)
{
struct NntpData *nntp_data = nserv->groups_list[i];
- unsigned int n;
if (!nntp_data || !nntp_data->newsrc_ent)
continue;
off += strlen(buf + off);
/* write entries */
- for (n = 0; n < nntp_data->newsrc_len; n++)
+ for (unsigned int i = 0; i < nntp_data->newsrc_len; i++)
{
if (off + LONG_STRING > buflen)
{
buflen *= 2;
safe_realloc(&buf, buflen);
}
- if (n)
+ if (i)
buf[off++] = ',';
- if (nntp_data->newsrc_ent[n].first == nntp_data->newsrc_ent[n].last)
- snprintf(buf + off, buflen - off, "%d", nntp_data->newsrc_ent[n].first);
- else if (nntp_data->newsrc_ent[n].first < nntp_data->newsrc_ent[n].last)
+ if (nntp_data->newsrc_ent[i].first == nntp_data->newsrc_ent[i].last)
+ snprintf(buf + off, buflen - off, "%d", nntp_data->newsrc_ent[i].first);
+ else if (nntp_data->newsrc_ent[i].first < nntp_data->newsrc_ent[i].last)
snprintf(buf + off, buflen - off, "%d-%d",
- nntp_data->newsrc_ent[n].first, nntp_data->newsrc_ent[n].last);
+ nntp_data->newsrc_ent[i].first, nntp_data->newsrc_ent[i].last);
off += strlen(buf + off);
}
buf[off++] = '\n';
if (Context && Context->magic == MUTT_NNTP &&
(mutt_strcmp(nntp_data->group, ((struct NntpData *) Context->data)->group) == 0))
{
- unsigned int j, unread = 0;
+ unsigned int unread = 0;
- for (j = 0; j < Context->msgcount; j++)
+ for (unsigned int j = 0; j < Context->msgcount; j++)
if (!Context->hdrs[j]->read && !Context->hdrs[j]->deleted)
unread++;
if (!unread)
int color; /* final color */
static int last_color; /* last color set */
bool search = false;
- int i, m;
+ int m;
if (!cnt)
last_color = -1; /* force attrset() */
color = def_color;
if (flags & MUTT_SHOWCOLOR)
{
- for (i = 0; i < line_info[m].chunks; i++)
+ for (int i = 0; i < line_info[m].chunks; i++)
{
/* we assume the chunks are sorted */
if (cnt > (line_info[m].syntax)[i].last)
if (flags & MUTT_SEARCH)
{
- for (i = 0; i < line_info[m].search_cnt; i++)
+ for (int i = 0; i < line_info[m].search_cnt; i++)
{
if (cnt > (line_info[m].search)[i].last)
continue;
void mutt_delete_parameter(const char *attribute, struct Parameter **p)
{
- struct Parameter *q = NULL;
-
- for (q = *p; q; p = &q->next, q = q->next)
+ for (struct Parameter *q = *p; q; p = &q->next, q = q->next)
{
if (mutt_strcasecmp(attribute, q->attribute) == 0)
{
static int match_adrlist(struct Pattern *pat, int match_personal, int n, ...)
{
va_list ap;
- struct Address *a = NULL;
va_start(ap, n);
for (; n; n--)
{
- for (a = va_arg(ap, struct Address *); a; a = a->next)
+ for (struct Address *a = va_arg(ap, struct Address *); a; a = a->next)
{
if (pat->alladdr ^ ((!pat->isalias || alias_reverse_lookup(a)) &&
((a->mailbox && !patmatch(pat, a->mailbox)) ||
{
char tmp[LONG_STRING];
bool do_simple = true;
- char *p = NULL;
- for (p = s; p && *p; p++)
+ for (char *p = s; p && *p; p++)
{
if (*p == '\\' && *(p + 1))
p++;
int mutt_search_command(int cur, int op)
{
- int i, j;
char buf[STRING];
char temp[LONG_STRING];
int incr;
if (option(OPT_SEARCH_INVALID))
{
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
Context->hdrs[i]->searched = false;
#ifdef USE_IMAP
if (Context->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0)
mutt_progress_init(&progress, _("Searching..."), MUTT_PROGRESS_MSG, ReadInc,
Context->vcount);
- for (i = cur + incr, j = 0; j != Context->vcount; j++)
+ for (int i = cur + incr, j = 0; j != Context->vcount; j++)
{
mutt_progress_update(&progress, j, -1);
if (i > Context->vcount - 1)
int main(int argc, char **argv)
{
char **opts = NULL, **opt = NULL, *pfx = NULL;
- int i;
if (argc < 2)
{
*opt++ = argv[1];
pfx = NULL;
- for (i = 2; i < argc;)
+ for (int i = 2; i < argc;)
{
if (strcmp(argv[i], "--") == 0)
{
unsigned long signerid1;
unsigned long signerid2;
size_t j;
- int i;
if (l < 22)
return -1;
sigtype = buff[j++];
sig_gen_time = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
sig_gen_time = (sig_gen_time << 8) + buff[j++];
signerid1 = signerid2 = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
signerid1 = (signerid1 << 8) + buff[j++];
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
signerid2 = (signerid2 << 8) + buff[j++];
if (sigtype == 0x20 || sigtype == 0x28)
unsigned long signerid2 = 0;
size_t ml;
size_t j;
- int i;
short have_critical_spks = 0;
if (l < 7)
if (skl < 4)
break;
sig_gen_time = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
sig_gen_time = (sig_gen_time << 8) + buff[j++];
break;
if (skl < 4)
break;
validity = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
validity = (validity << 8) + buff[j++];
break;
}
if (skl < 4)
break;
key_validity = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
key_validity = (key_validity << 8) + buff[j++];
break;
}
if (skl < 8)
break;
signerid2 = signerid1 = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
signerid1 = (signerid1 << 8) + buff[j++];
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
signerid2 = (signerid2 << 8) + buff[j++];
break;
ret = pop_open_connection(pop_data);
if (ret == 0)
{
- int i;
-
mutt_progress_init(&progressbar, _("Verifying message indexes..."),
MUTT_PROGRESS_SIZE, NetInc, 0);
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
ctx->hdrs[i]->refno = -1;
ret = pop_fetch_data(pop_data, "UIDL\r\n", &progressbar, check_uidl, ctx);
{
char buf[STRING];
char *s = NULL;
- int rindex, vindex;
+ int rindex;
mutt_update_v2r(actx);
- for (vindex = 0; vindex < actx->vcount; vindex++)
+ for (int vindex = 0; vindex < actx->vcount; vindex++)
{
rindex = actx->v2r[vindex];
actx->idx[rindex]->num = vindex;
{
char buf[_POSIX_PATH_MAX], tfile[_POSIX_PATH_MAX];
char *directory = NULL;
- int i, rc = 1;
+ int rc = 1;
int last = menu ? menu->current : -1;
FILE *fpout = NULL;
buf[0] = 0;
- for (i = 0; !tag || i < actx->idxlen; i++)
+ for (int i = 0; !tag || i < actx->idxlen; i++)
{
if (tag)
{
static void pipe_attachment_list(char *command, struct AttachCtx *actx, FILE *fp, bool tag,
struct Body *top, bool filter, struct State *state)
{
- int i;
-
- for (i = 0; !tag || i < actx->idxlen; i++)
+ for (int i = 0; !tag || i < actx->idxlen; i++)
{
if (tag)
{
static void recvattach_extract_pgp_keys(struct AttachCtx *actx, struct Menu *menu)
{
- int i;
-
if (!menu->tagprefix)
crypt_pgp_extract_keys_from_attachment_list(CURATTACH->fp, 0, CURATTACH->content);
else
{
- for (i = 0; i < actx->idxlen; i++)
+ for (int i = 0; i < actx->idxlen; i++)
if (actx->idx[i]->content->tagged)
crypt_pgp_extract_keys_from_attachment_list(actx->idx[i]->fp, 0,
actx->idx[i]->content);
static int recvattach_pgp_check_traditional(struct AttachCtx *actx, struct Menu *menu)
{
- int i, rv = 0;
+ int rv = 0;
if (!menu->tagprefix)
rv = crypt_pgp_check_traditional(CURATTACH->fp, CURATTACH->content, 1);
else
{
- for (i = 0; i < actx->idxlen; i++)
+ for (int i = 0; i < actx->idxlen; i++)
if (actx->idx[i]->content->tagged)
rv = rv || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->content, 1);
}
struct AttachCtx *actx = NULL;
int flags = 0;
int op = OP_NULL;
- int i;
/* make sure we have parsed this message */
mutt_parse_mime_message(Context, hdr);
}
else
{
- int x;
-
- for (x = 0; x < menu->max; x++)
+ for (int i = 0; i < menu->max; i++)
{
- if (actx->idx[x]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
- if (actx->idx[x]->parent_type == TYPEMULTIPART)
+ if (actx->idx[i]->parent_type == TYPEMULTIPART)
{
- actx->idx[x]->content->deleted = true;
+ actx->idx[i]->content->deleted = true;
menu->redraw = REDRAW_INDEX;
}
else
}
else
{
- int x;
-
- for (x = 0; x < menu->max; x++)
+ for (int i = 0; i < menu->max; i++)
{
- if (actx->idx[x]->content->tagged)
+ if (actx->idx[i]->content->tagged)
{
- actx->idx[x]->content->deleted = false;
+ actx->idx[i]->content->deleted = false;
menu->redraw = REDRAW_INDEX;
}
}
mx_close_message(Context, &msg);
hdr->attach_del = false;
- for (i = 0; i < actx->idxlen; i++)
+ for (int i = 0; i < actx->idxlen; i++)
+ {
if (actx->idx[i]->content && actx->idx[i]->content->deleted)
{
hdr->attach_del = true;
break;
}
+ }
if (hdr->attach_del)
hdr->changed = true;
static void mix_redraw_chain(struct Remailer **type2_list, struct Coord *coords,
struct MixChain *chain, int cur)
{
- int i;
-
- for (i = MIX_VOFFSET; i < MIX_MAXROW; i++)
+ for (int i = MIX_VOFFSET; i < MIX_MAXROW; i++)
{
mutt_window_move(MuttIndexWindow, i, 0);
mutt_window_clrtoeol(MuttIndexWindow);
}
- for (i = 0; i < chain->cl; i++)
+ for (int i = 0; i < chain->cl; i++)
mix_redraw_ce(type2_list, coords, chain, i, i == cur);
}
bool loop = true;
int op;
- int i, j;
+ int j;
char *t = NULL;
if (!(type2_list = mix_type2_list(&ttll)))
mutt_list_free(chainhead);
/* safety check */
- for (i = 0; i < chain->cl; i++)
+ for (int i = 0; i < chain->cl; i++)
{
if (chain->ch[i] >= ttll)
chain->ch[i] = 0;
if (chain->cl < MAXMIXES)
{
chain->cl++;
- for (i = chain->cl - 1; i > c_cur; i--)
+ for (int i = chain->cl - 1; i > c_cur; i--)
chain->ch[i] = chain->ch[i - 1];
chain->ch[c_cur] = menu->current;
{
chain->cl--;
- for (i = c_cur; i < chain->cl; i++)
+ for (int i = c_cur; i < chain->cl; i++)
chain->ch[i] = chain->ch[i + 1];
if (c_cur == chain->cl && c_cur)
if (chain->cl)
{
- for (i = 0; i < chain->cl; i++)
+ for (int i = 0; i < chain->cl; i++)
{
if ((j = chain->ch[i]))
t = type2_list[j]->shortname;
{
const char *fqdn = NULL;
bool need_hostname = false;
- struct Address *p = NULL;
if (msg->env->cc || msg->env->bcc)
{
* use_domain won't be respected at this point, hidden_host will.
*/
- for (p = msg->env->to; p; p = p->next)
+ for (struct Address *a = msg->env->to; a; a = a->next)
{
- if (!p->group && strchr(p->mailbox, '@') == NULL)
+ if (!a->group && strchr(a->mailbox, '@') == NULL)
{
need_hostname = true;
break;
int convert_nonmime_string(char **ps)
{
- const char *c = NULL, *c1 = NULL;
+ const char *c1 = NULL;
- for (c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
+ for (const char *c = AssumedCharset; c; c = c1 ? c1 + 1 : 0)
{
char *u = *ps;
char *s = NULL;
char canonical_buff[LONG_STRING];
char *e = NULL, *tocode = NULL;
size_t elen = 0, bestn = 0;
- const char *p = NULL, *q = NULL;
+ const char *q = NULL;
- for (p = charsets; p; p = q ? q + 1 : 0)
+ for (const char *p = charsets; p; p = q ? q + 1 : 0)
{
char *s = NULL, *t = NULL;
size_t slen, n;
while (dlen)
{
char encoded[11];
- size_t ret, i;
+ size_t ret;
size_t in_len = MIN(3, dlen);
ret = mutt_to_base64(encoded, d, in_len, sizeof(encoded));
- for (i = 0; i < ret; i++)
+ for (size_t i = 0; i < ret; i++)
*s++ = encoded[i];
dlen -= in_len;
char buf1[ENCWORD_LEN_MAX - ENCWORD_LEN_MIN + 1];
iconv_t cd;
ICONV_CONST char *ib = NULL;
- char *ob = NULL, *p = NULL;
+ char *ob = NULL;
size_t ibl, obl;
int count, len, len_b, len_q;
}
count = 0;
- for (p = buf1; p < ob; p++)
+ for (char *p = buf1; p < ob; p++)
{
unsigned char c = *p;
assert(strchr(MimeSpecials, '?'));
void mutt_check_rescore(struct Context *ctx)
{
- int i;
-
if (option(OPT_NEED_RESCORE) && option(OPT_SCORE))
{
if ((Sort & SORT_MASK) == SORT_SCORE || (SortAux & SORT_MASK) == SORT_SCORE)
mutt_set_menu_redraw_full(MENU_MAIN);
mutt_set_menu_redraw_full(MENU_PAGER);
- for (i = 0; ctx && i < ctx->msgcount; i++)
+ for (int i = 0; ctx && i < ctx->msgcount; i++)
{
mutt_score_message(ctx, ctx->hdrs[i], 1);
ctx->hdrs[i]->pair = 0;
struct Header *cur, int flags)
{
struct Envelope *curenv = NULL;
- int i = 0;
bool tag = false;
if (!cur)
{
tag = true;
- for (i = 0; i < ctx->vcount; i++)
+ for (int i = 0; i < ctx->vcount; i++)
if (ctx->hdrs[ctx->v2r[i]]->tagged)
{
cur = ctx->hdrs[ctx->v2r[i]];
{
struct Header *h = NULL;
- for (i = 0; i < ctx->vcount; i++)
+ for (int i = 0; i < ctx->vcount; i++)
{
h = ctx->hdrs[ctx->v2r[i]];
if (h->tagged && mutt_fetch_recips(env, h->env, flags) == -1)
*/
void mutt_encode_descriptions(struct Body *b, short recurse)
{
- struct Body *t = NULL;
-
- for (t = b; t; t = t->next)
+ for (struct Body *t = b; t; t = t->next)
{
if (t->description)
{
*/
static void decode_descriptions(struct Body *b)
{
- struct Body *t = NULL;
-
- for (t = b; t; t = t->next)
+ for (struct Body *t = b; t; t = t->next)
{
if (t->description)
{
int mutt_write_mime_header(struct Body *a, FILE *f)
{
- struct Parameter *p = NULL;
char buffer[STRING];
char *t = NULL;
char *fn = NULL;
{
len = 25 + mutt_strlen(a->subtype); /* approximate len. of content-type */
- for (p = a->parameter; p; p = p->next)
+ for (struct Parameter *p = a->parameter; p; p = p->next)
{
char *tmp = NULL;
char *p, boundary[SHORT_STRING];
char send_charset[SHORT_STRING];
FILE *fpin = NULL;
- struct Body *t = NULL;
FGETCONV *fc = NULL;
if (a->type == TYPEMULTIPART)
}
strfcpy(boundary, p, sizeof(boundary));
- for (t = a->parts; t; t = t->next)
+ for (struct Body *t = a->parts; t; t = t->next)
{
fprintf(f, "\n--%s\n", boundary);
if (mutt_write_mime_header(t, f) == -1)
ICONV_CONST char *ib = NULL, *ub = NULL;
char *ob = NULL;
size_t ibl, obl, ubl, ubl1, n, ret;
- int i;
struct Content *infos = NULL;
struct ContentState *states = NULL;
size_t *score = NULL;
states = safe_calloc(ncodes, sizeof(struct ContentState));
infos = safe_calloc(ncodes, sizeof(struct Content));
- for (i = 0; i < ncodes; i++)
+ for (int i = 0; i < ncodes; i++)
+ {
if (mutt_strcasecmp(tocodes[i], "utf-8") != 0)
cd[i] = mutt_iconv_open(tocodes[i], "utf-8", 0);
else
cd[i] = (iconv_t)(-1);
score[i] = (size_t)(-1);
}
+ }
rewind(file);
ibl = 0;
ubl1 = ob - bufu;
/* Convert from UTF-8 */
- for (i = 0; i < ncodes; i++)
+ for (int i = 0; i < ncodes; i++)
+ {
if (cd[i] != (iconv_t)(-1) && score[i] != (size_t)(-1))
{
ub = bufu;
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 */
{
/* Find best score */
ret = (size_t)(-1);
- for (i = 0; i < ncodes; i++)
+ for (int i = 0; i < ncodes; i++)
{
if (cd[i] == (iconv_t)(-1) && score[i] == (size_t)(-1))
{
}
}
- for (i = 0; i < ncodes; i++)
+ for (int i = 0; i < ncodes; i++)
if (cd[i] != (iconv_t)(-1))
iconv_close(cd[i]);
static int _mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to,
const char *resent_from, struct Address *env_from)
{
- int i, ret = 0;
+ int ret = 0;
FILE *f = NULL;
char date[SHORT_STRING], tempfile[_POSIX_PATH_MAX];
struct Message *msg = NULL;
if (!h)
{
/* Try to bounce each message out, aborting if we get any failures. */
- for (i = 0; i < Context->msgcount; i++)
+ for (int i = 0; i < Context->msgcount; i++)
if (Context->hdrs[i]->tagged)
ret |= _mutt_bounce_message(fp, Context->hdrs[i], to, resent_from, env_from);
return ret;
if ((num_rows < 1) || (num_cols < 1))
return 0;
- int i;
int delim_len;
enum DivType altchar = SB_DIV_UTF8;
}
else if (SidebarDividerChar)
{
- for (i = 0; i < delim_len; i++)
+ for (int i = 0; i < delim_len; i++)
{
if (SidebarDividerChar[i] & ~0x7F) /* high-bit is set */
{
int col = option(OPT_SIDEBAR_ON_RIGHT) ? 0 : (SidebarWidth - delim_len);
- for (i = 0; i < num_rows; i++)
+ for (int i = 0; i < num_rows; i++)
{
mutt_window_move(MuttSidebarWindow, i, col);
{
mutt_window_move(MuttSidebarWindow, first_row + r, div_width);
- int i;
- for (i = 0; i < num_cols; i++)
+ for (int i = 0; i < num_cols; i++)
addch(' ');
}
}
/* calculate depth of current folder and generate its display name with indented spaces */
int sidebar_folder_depth = 0;
char *sidebar_folder_name = NULL;
- int i;
if (option(OPT_SIDEBAR_SHORT_PATH))
{
/* disregard a trailing separator, so strlen() - 2 */
sidebar_folder_name = b->path;
- for (i = mutt_strlen(sidebar_folder_name) - 2; i >= 0; i--)
+ for (int i = mutt_strlen(sidebar_folder_name) - 2; i >= 0; i--)
{
if (SidebarDelimChars && strchr(SidebarDelimChars, sidebar_folder_name[i]))
{
int lastsep = 0;
tmp_folder_name = b->path + maildirlen + 1;
int tmplen = (int) mutt_strlen(tmp_folder_name) - 1;
- for (i = 0; i < tmplen; i++)
+ for (int i = 0; i < tmplen; i++)
{
if (SidebarDelimChars && strchr(SidebarDelimChars, tmp_folder_name[i]))
{
sidebar_folder_depth * mutt_strlen(SidebarIndentString) + 1;
sidebar_folder_name = safe_malloc(sfn_len);
sidebar_folder_name[0] = 0;
- for (i = 0; i < sidebar_folder_depth; i++)
+ for (int i = 0; i < sidebar_folder_depth; i++)
safe_strcat(sidebar_folder_name, sfn_len, NONULL(SidebarIndentString));
safe_strcat(sidebar_folder_name, sfn_len, tmp_folder_name);
}
void mutt_sort_headers(struct Context *ctx, int init)
{
- int i;
struct Header *h = NULL;
struct MuttThread *thread = NULL, *top = NULL;
sort_t *sortfunc = NULL;
if (option(OPT_NEED_RESCORE) && option(OPT_SCORE))
{
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
mutt_score_message(ctx, ctx->hdrs[i], 1);
}
unset_option(OPT_NEED_RESCORE);
subthreads need to be resorted */
if (option(OPT_SORT_SUBTHREADS))
{
- i = Sort;
+ int i = Sort;
Sort = SortAux;
if (ctx->tree)
ctx->tree = mutt_sort_subthreads(ctx->tree, 1);
/* adjust the virtual message numbers */
ctx->vcount = 0;
- for (i = 0; i < ctx->msgcount; i++)
+ for (int i = 0; i < ctx->msgcount; i++)
{
struct Header *cur = ctx->hdrs[i];
if (cur->virtual != -1 || (cur->collapsed && (!ctx->pattern || cur->limited)))
static void clean_references(struct MuttThread *brk, struct MuttThread *cur)
{
- struct MuttThread *p = NULL;
struct ListNode *ref = NULL;
bool done = false;
/* Looking for the first bad reference according to the new threading.
* Optimal since NeoMutt stores the references in reverse order, and the
* first loop should match immediately for mails respecting RFC2822. */
- for (p = brk; !done && p; p = p->parent)
+ for (struct MuttThread *p = brk; !done && p; p = p->parent)
{
for (ref = STAILQ_FIRST(&cur->message->env->references);
p->message && ref; ref = STAILQ_NEXT(ref, entries))
int mutt_link_threads(struct Header *cur, struct Header *last, struct Context *ctx)
{
- int i;
bool changed = false;
if (!last)
{
- for (i = 0; i < ctx->vcount; i++)
+ for (int i = 0; i < ctx->vcount; i++)
if (ctx->hdrs[Context->v2r[i]]->tagged)
changed |= link_threads(cur, ctx->hdrs[Context->v2r[i]], ctx);
}
static void txt2c(char *sym, FILE *fp)
{
unsigned char buf[PER_LINE];
- int i;
int sz = 0;
printf("unsigned char %s[] = {\n", sym);
if (sz == 0)
break;
printf("\t");
- for (i = 0; i < sz; i++)
+ for (int i = 0; i < sz; i++)
printf("0x%02x, ", buf[i]);
printf("\n");
}