]> granicus.if.org Git - neomutt/commitdiff
Reduce variable scope - hdrline.c
authorFederico Kircheis <federico.kircheis@gmail.com>
Fri, 2 Mar 2018 18:54:47 +0000 (19:54 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 3 Mar 2018 12:33:02 +0000 (12:33 +0000)
hdrline.c

index 6afed0125626723f46dab546eb418b28c20bd949..7cb3dbe8040b4b95ce5640b95706bc9dc13398f2 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -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;
@@ -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;
   }
@@ -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;
@@ -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 == '(')))
         {
@@ -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;
@@ -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;
@@ -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 != '>')))