Skip to content

Commit

Permalink
Reduce variable scope - hdrline.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fekir authored and flatcap committed Mar 3, 2018
1 parent 9272000 commit 9bd5b83
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions hdrline.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ static bool first_mailing_list(char *buf, size_t buflen, struct Address *a)
*/
static size_t add_index_color(char *buf, size_t buflen, enum FormatFlag flags, char color)
{
size_t len;

/* only add color markers if we are operating on main index entries. */
if (!(flags & MUTT_FORMAT_INDEX))
return 0;
Expand All @@ -164,7 +162,7 @@ static size_t add_index_color(char *buf, size_t buflen, enum FormatFlag flags, c

if (color == MT_COLOR_INDEX)
{ /* buf might be uninitialized other cases */
len = mutt_str_strlen(buf);
const size_t len = mutt_str_strlen(buf);
buf += len;
buflen -= len;
}
Expand Down Expand Up @@ -483,11 +481,10 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
struct Context *ctx = NULL;
char fmt[SHORT_STRING], tmp[LONG_STRING], *p, *tags = NULL;
char *wch = NULL;
int do_locales, i;
int i;
int optional = (flags & MUTT_FORMAT_OPTIONAL);
int threads = ((Sort & SORT_MASK) == SORT_THREADS);
int is_index = (flags & MUTT_FORMAT_INDEX);
size_t len;
size_t colorlen;

hdr = hfi->hdr;
Expand Down Expand Up @@ -596,7 +593,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
const char *cp = NULL;
struct tm *tm = NULL;
time_t T;
int j = 0, invert = 0;
int j = 0;

if (optional && ((op == '[') || (op == '(')))
{
Expand All @@ -606,6 +603,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
T -= (op == '(') ? hdr->received : hdr->date_sent;

is = (char *) prec;
int invert = 0;
if (*is == '>')
{
invert = 1;
Expand Down Expand Up @@ -692,6 +690,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
p = buf;

cp = (op == 'd' || op == 'D') ? (NONULL(DateFormat)) : src;
int do_locales;
if (*cp == '!')
{
do_locales = 0;
Expand All @@ -700,7 +699,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
else
do_locales = 1;

len = buflen - 1;
size_t len = buflen - 1;
while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||
(op == '{' && *cp != '}') || (op == '[' && *cp != ']') ||
(op == '(' && *cp != ')') || (op == '<' && *cp != '>')))
Expand Down

0 comments on commit 9bd5b83

Please sign in to comment.