]> granicus.if.org Git - neomutt/commitdiff
tidy code
authorRichard Russon <rich@flatcap.org>
Wed, 17 Feb 2016 19:46:21 +0000 (19:46 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 6 Mar 2016 16:38:29 +0000 (16:38 +0000)
color.c
curs_lib.c
hdrline.c
menu.c
mutt_curses.h

diff --git a/color.c b/color.c
index 956326405dedc55c434fa0c1584b9d11cf40c748..45064ef2f02d3d6ed3139034876d110f773d45cb 100644 (file)
--- a/color.c
+++ b/color.c
@@ -35,9 +35,9 @@ int ColorDefs[MT_COLOR_MAX];
 COLOR_LINE *ColorHdrList = NULL;
 COLOR_LINE *ColorBodyList = NULL;
 COLOR_LINE *ColorIndexList = NULL;
-COLOR_LINE *ColorIndexSubjectList = NULL;
 COLOR_LINE *ColorIndexAuthorList = NULL;
 COLOR_LINE *ColorIndexFlagsList = NULL;
+COLOR_LINE *ColorIndexSubjectList = NULL;
 
 /* local to this file */
 static int ColorQuoteSize;
@@ -96,7 +96,6 @@ static const struct mapping_t Fields[] =
   { "bold",            MT_COLOR_BOLD },
   { "underline",       MT_COLOR_UNDERLINE },
   { "index",           MT_COLOR_INDEX },
-  { "index_subject",   MT_COLOR_INDEX_SUBJECT },
   { "index_author",    MT_COLOR_INDEX_AUTHOR },
   { "index_collapsed", MT_COLOR_INDEX_COLLAPSED },
   { "index_date",      MT_COLOR_INDEX_DATE },
@@ -104,6 +103,7 @@ static const struct mapping_t Fields[] =
   { "index_label",     MT_COLOR_INDEX_LABEL },
   { "index_number",    MT_COLOR_INDEX_NUMBER },
   { "index_size",      MT_COLOR_INDEX_SIZE },
+  { "index_subject",   MT_COLOR_INDEX_SUBJECT },
   { "prompt",          MT_COLOR_PROMPT },
   { NULL,              0 }
 };
@@ -376,48 +376,46 @@ int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data,
   return _mutt_parse_uncolor(buf, s, data, err, 0);
 }
 
+/**
+ * mutt_do_uncolor - XXX
+ */
 static void
 mutt_do_uncolor (BUFFER *buf, BUFFER *s, COLOR_LINE **ColorList,
                  int *do_cache, int parse_uncolor)
 {
-  COLOR_LINE *tmp, *last = NULL;
-
-  do
-  {
-    mutt_extract_token (buf, s, 0);
-    if (!mutt_strcmp ("*", buf->data))
-    {
-      for (tmp = *ColorList; tmp; )
-      {
-        if (!*do_cache)
-          *do_cache = 1;
-        last = tmp;
-        tmp = tmp->next;
-        mutt_free_color_line(&last, parse_uncolor);
-      }
-      *ColorList = NULL;
-    }
-    else
-    {
-      for (last = NULL, tmp = *ColorList; 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 ColorList\n",
-                               tmp->pattern));
-          if (last)
-            last->next = tmp->next;
-          else
-            *ColorList = tmp->next;
-          mutt_free_color_line(&tmp, parse_uncolor);
-          break;
-        }
-      }
-    }
-  }
-  while (MoreArgs (s));
+       COLOR_LINE *tmp, *last = NULL;
+
+       do {
+               mutt_extract_token (buf, s, 0);
+               if (mutt_strcmp ("*", buf->data) == 0) {
+                       for (tmp = *ColorList; tmp; ) {
+                               if (!*do_cache) {
+                                       *do_cache = 1;
+                               }
+                               last = tmp;
+                               tmp = tmp->next;
+                               mutt_free_color_line (&last, parse_uncolor);
+                       }
+                       *ColorList = NULL;
+               } else {
+                       for (last = NULL, tmp = *ColorList; tmp; last = tmp, tmp = tmp->next) {
+                               if (mutt_strcmp (buf->data, tmp->pattern) == 0) {
+                                       if (!*do_cache) {
+                                               *do_cache = 1;
+                                       }
+                                       dprint (1, (debugfile,"Freeing pattern \"%s\" from ColorList\n",
+                                                                                                                        tmp->pattern));
+                                       if (last) {
+                                               last->next = tmp->next;
+                                       } else {
+                                               *ColorList = tmp->next;
+                                       }
+                                       mutt_free_color_line (&tmp, parse_uncolor);
+                                       break;
+                               }
+                       }
+               }
+       } while (MoreArgs (s));
 }
 
 static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
@@ -433,16 +431,15 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
     return (-1);
   }
 
-  if (object > MT_COLOR_INDEX_SUBJECT) /* uncolor index column */
-  {
+  if (object > MT_COLOR_INDEX_SUBJECT) { /* uncolor index column */
     ColorDefs[object] = 0;
     set_option (OPTFORCEREDRAWINDEX);
-    return (0);
+    return 0;
   }
 
-  if ((mutt_strncmp (buf->data, "index", 5) != 0) &&
-      (mutt_strncmp (buf->data, "body", 4) != 0) &&
-      (mutt_strncmp (buf->data, "header", 6) != 0))
+  if ((mutt_strncmp (buf->data, "body",   4) != 0) &&
+      (mutt_strncmp (buf->data, "header", 6) != 0) &&
+      (mutt_strncmp (buf->data, "index",  5) != 0))
   {
     snprintf (err->data, err->dsize,
              _("%s: command valid only for index, body, header objects"),
@@ -479,18 +476,18 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data,
     return 0;
   }
 
-  if (object == MT_COLOR_INDEX)
-    mutt_do_uncolor(buf, s, &ColorIndexList, &do_cache, parse_uncolor);
-  else if (object == MT_COLOR_INDEX_SUBJECT)
-    mutt_do_uncolor(buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor);
+  if (object == MT_COLOR_BODY)
+    mutt_do_uncolor (buf, s, &ColorBodyList, &do_cache, parse_uncolor);
+  else if (object == MT_COLOR_HEADER)
+    mutt_do_uncolor (buf, s, &ColorHdrList, &do_cache, parse_uncolor);
+  else if (object == MT_COLOR_INDEX)
+    mutt_do_uncolor (buf, s, &ColorIndexList, &do_cache, parse_uncolor);
   else if (object == MT_COLOR_INDEX_AUTHOR)
-    mutt_do_uncolor(buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor);
+    mutt_do_uncolor (buf, s, &ColorIndexAuthorList, &do_cache, parse_uncolor);
   else if (object == MT_COLOR_INDEX_FLAGS)
-    mutt_do_uncolor(buf, s, &ColorIndexFlagsList, &do_cache, parse_uncolor);
-  else if (object == MT_COLOR_BODY)
-    mutt_do_uncolor(buf, s, &ColorBodyList, &do_cache, parse_uncolor);
-  else if (object == MT_COLOR_HEADER)
-    mutt_do_uncolor(buf, s, &ColorHdrList, &do_cache, parse_uncolor);
+    mutt_do_uncolor (buf, s, &ColorIndexFlagsList, &do_cache, parse_uncolor);
+  else if (object == MT_COLOR_INDEX_SUBJECT)
+    mutt_do_uncolor (buf, s, &ColorIndexSubjectList, &do_cache, parse_uncolor);
 
   if (do_cache && !option (OPTNOCURSES))
   {
@@ -730,17 +727,15 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err,
 
   /* extract a regular expression if needed */
   
-  if (object == MT_COLOR_HEADER ||
-      object == MT_COLOR_BODY ||
-      object == MT_COLOR_INDEX ||
-      object == MT_COLOR_INDEX_SUBJECT ||
-      object == MT_COLOR_INDEX_AUTHOR ||
-      object == MT_COLOR_INDEX_FLAGS)
-  {
-    if (!MoreArgs (s))
-    {
+  if ((object == MT_COLOR_BODY) ||
+      (object == MT_COLOR_HEADER) ||
+      (object == MT_COLOR_INDEX) ||
+      (object == MT_COLOR_INDEX_AUTHOR) ||
+      (object == MT_COLOR_INDEX_FLAGS) ||
+      (object == MT_COLOR_INDEX_SUBJECT)) {
+    if (!MoreArgs (s)) {
       strfcpy (err->data, _("too few arguments"), err->dsize);
-      return (-1);
+      return -1;
     }
 
     mutt_extract_token (buf, s, 0);
@@ -778,23 +773,14 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err,
   {
     r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1);
     set_option (OPTFORCEREDRAWINDEX);
-  }
-  else if (object == MT_COLOR_INDEX_SUBJECT)
-  {
-    r = add_pattern (&ColorIndexSubjectList, buf->data,
-                     1, fg, bg, attr, err, 1);
+  } else if (object == MT_COLOR_INDEX_AUTHOR) {
+    r = add_pattern (&ColorIndexAuthorList, buf->data, 1, fg, bg, attr, err, 1);
     set_option (OPTFORCEREDRAWINDEX);
-  }
-  else if (object == MT_COLOR_INDEX_AUTHOR)
-  {
-    r = add_pattern (&ColorIndexAuthorList, buf->data,
-                     1, fg, bg, attr, err, 1);
+  } else if (object == MT_COLOR_INDEX_FLAGS) {
+    r = add_pattern (&ColorIndexFlagsList, buf->data, 1, fg, bg, attr, err, 1);
     set_option (OPTFORCEREDRAWINDEX);
-  }
-  else if (object == MT_COLOR_INDEX_FLAGS)
-  {
-    r = add_pattern (&ColorIndexFlagsList, buf->data,
-                     1, fg, bg, attr, err, 1);
+  } else if (object == MT_COLOR_INDEX_SUBJECT) {
+    r = add_pattern (&ColorIndexSubjectList, buf->data, 1, fg, bg, attr, err, 1);
     set_option (OPTFORCEREDRAWINDEX);
   }
   else if (object == MT_COLOR_QUOTED)
index 5b753e9b962f79799aa406c6e93003516de547c5..a32db28f9436b70f940fd91ebb1db8663bf81355 100644 (file)
@@ -745,13 +745,12 @@ void mutt_format_string (char *dest, size_t destlen,
     if (escaped) {
       escaped = 0;
       w = 0;
-    }
-    else if (arboreal && wc == M_SPECIAL_INDEX) {
+    } else if (arboreal && wc == M_SPECIAL_INDEX) {
       escaped = 1;
       w = 0;
-    }
-    else if (arboreal && wc < M_TREE_MAX)
+    } else if (arboreal && wc < M_TREE_MAX) {
       w = 1; /* hack */
+    }
     else
     {
 #ifdef HAVE_ISWBLANK
@@ -984,8 +983,7 @@ int mutt_strwidth (const char *s)
   memset (&mbstate, 0, sizeof (mbstate));
   for (w=0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k)
   {
-    if (*s == M_SPECIAL_INDEX)
-    {
+    if (*s == M_SPECIAL_INDEX) {
       s += 2; /* skip the index coloring sequence */
       k = 0;
       continue;
index 5d0ea0074823c7b1f7939b0548082d364d570fe5..164dcec23e32c3e4480fbf142e43b400713b9371 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -103,32 +103,36 @@ static int first_mailing_list (char *buf, size_t buflen, ADDRESS *a)
   return 0;
 }
 
-/* Takes the color to embed, the buffer to manipulate and the buffer length as
+/**
+ * add_index_color - XXX
+ *
+ * Takes the color to embed, the buffer to manipulate and the buffer length as
  * arguments.
- * Returns the number of chars written. */
-static size_t add_index_color(char *buf, size_t buflen,
-                              format_flag flags, char color)
+ * Returns the number of chars written.
+ */
+static size_t
+add_index_color (char *buf, size_t buflen, format_flag flags, char color)
 {
-  int len;
+       int len;
 
-  /* only add color markers if we are operating on main index entries. */
-  if (!(flags & M_FORMAT_INDEX))
-    return 0;
+       /* only add color markers if we are operating on main index entries. */
+       if (!(flags & M_FORMAT_INDEX))
+               return 0;
 
-  if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */
-    len = mutt_strlen(buf);
-    buf += len;
-    buflen -= len;
-  }
+       if (color == MT_COLOR_INDEX) { /* buf might be uninitialized other cases */
+               len = mutt_strlen (buf);
+               buf += len;
+               buflen -= len;
+       }
 
-  if (buflen < 2)
-    return 0;
+       if (buflen < 2)
+               return 0;
 
-  buf[0] = M_SPECIAL_INDEX;
-  buf[1] = color;
-  buf[2] = '\0';
+       buf[0] = M_SPECIAL_INDEX;
+       buf[1] = color;
+       buf[2] = '\0';
 
-  return 2;
+       return 2;
 }
 
 static void make_from (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
@@ -292,9 +296,9 @@ hdr_format_str (char *dest,
     case 'A':
       if(hdr->env->reply_to && hdr->env->reply_to->mailbox)
       {
-        colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
-        mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_addr_for_display (hdr->env->reply_to));
-        add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+        colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
+        mutt_format_s (dest + colorlen, destlen - colorlen, prefix, mutt_addr_for_display (hdr->env->reply_to));
+        add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
        break;
       }
       /* fall through if 'A' returns nothing */
@@ -302,9 +306,9 @@ hdr_format_str (char *dest,
     case 'a':
       if(hdr->env->from && hdr->env->from->mailbox)
       {
-        colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
-        mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_addr_for_display (hdr->env->from));
-        add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+        colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
+        mutt_format_s (dest + colorlen, destlen - colorlen, prefix, mutt_addr_for_display (hdr->env->from));
+        add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       }
       else
         dest[0] = '\0';
@@ -337,16 +341,16 @@ hdr_format_str (char *dest,
       break;
     
     case 'c':
-      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE);
+      colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_SIZE);
       mutt_pretty_size (buf2, sizeof (buf2), (long) hdr->content->length);
-      mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-      add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+      mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+      add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       break;
 
     case 'C':
-      colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER);
-      snprintf (fmt+colorlen, sizeof(fmt)-colorlen, "%%%sd", prefix);
-      add_index_color(fmt+colorlen, sizeof(fmt)-colorlen, flags, MT_COLOR_INDEX);
+      colorlen = add_index_color (fmt, sizeof (fmt), flags, MT_COLOR_INDEX_NUMBER);
+      snprintf (fmt + colorlen, sizeof (fmt) - colorlen, "%%%sd", prefix);
+      add_index_color (fmt + colorlen, sizeof (fmt) - colorlen, flags, MT_COLOR_INDEX);
       snprintf (dest, destlen, fmt, hdr->msgno + 1);
       break;
 
@@ -445,9 +449,9 @@ hdr_format_str (char *dest,
        if (do_locales)
          setlocale (LC_TIME, "C");
 
-       colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_DATE);
-       mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-       add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+       colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_DATE);
+       mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+       add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
 
        if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
          src = cp + 1;
@@ -478,10 +482,10 @@ hdr_format_str (char *dest,
     case 'F':
       if (!optional)
       {
-        colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
+        colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
         make_from (hdr->env, buf2, sizeof (buf2), 0);
-        mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-        add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+        mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+        add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       }
       else if (mutt_addr_is_user (hdr->env->from))
         optional = 0;
@@ -507,9 +511,9 @@ hdr_format_str (char *dest,
       if (!optional)
       {
        snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
-       colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SIZE);
-       snprintf (dest+colorlen, destlen-colorlen, fmt, (int) hdr->lines);
-       add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+       colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_SIZE);
+       snprintf (dest + colorlen, destlen - colorlen, fmt, (int) hdr->lines);
+       add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       }
       else if (hdr->lines <= 0)
         optional = 0;
@@ -518,10 +522,10 @@ hdr_format_str (char *dest,
     case 'L':
       if (!optional)
       {
-       colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
+       colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
        make_from (hdr->env, buf2, sizeof (buf2), 1);
-       mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-       add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+       mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+       add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       }
       else if (!check_for_mailing_list (hdr->env->to, NULL, NULL, 0) &&
               !check_for_mailing_list (hdr->env->cc, NULL, NULL, 0))
@@ -541,9 +545,9 @@ hdr_format_str (char *dest,
       break;
 
     case 'n':
-      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
-      mutt_format_s (dest+colorlen, destlen-colorlen, prefix, mutt_get_name (hdr->env->from));
-      add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+      colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_AUTHOR);
+      mutt_format_s (dest + colorlen, destlen - colorlen, prefix, mutt_get_name (hdr->env->from));
+      add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       break;
 
     case 'N':
@@ -578,15 +582,14 @@ hdr_format_str (char *dest,
       snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
       if (!optional)
       {
-       colorlen = add_index_color(dest, destlen, flags,
+       colorlen = add_index_color (dest, destlen, flags,
                                   MT_COLOR_INDEX_COLLAPSED);
        if (threads && is_index && hdr->collapsed && hdr->num_hidden > 1) {
-         snprintf (dest+colorlen, destlen-colorlen, fmt, hdr->num_hidden);
-         add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX);
-       }
-       else if (is_index && threads) {
-         mutt_format_s (dest+colorlen, destlen-colorlen, prefix, " ");
-         add_index_color(dest, destlen-colorlen, flags, MT_COLOR_INDEX);
+         snprintf (dest + colorlen, destlen - colorlen, fmt, hdr->num_hidden);
+         add_index_color (dest, destlen - colorlen, flags, MT_COLOR_INDEX);
+       } else if (is_index && threads) {
+         mutt_format_s (dest + colorlen, destlen - colorlen, prefix, " ");
+         add_index_color (dest, destlen - colorlen, flags, MT_COLOR_INDEX);
        }
        else
          *dest = '\0';
@@ -608,9 +611,9 @@ hdr_format_str (char *dest,
       {
        if (flags & M_FORMAT_FORCESUBJ)
        {
-         colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
-         mutt_format_s (dest+colorlen, destlen-colorlen, "", NONULL (hdr->env->subject));
-         add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+         colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
+         mutt_format_s (dest + colorlen, destlen - colorlen, "", NONULL (hdr->env->subject));
+         add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
          snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
          mutt_format_s_tree (dest, destlen, prefix, buf2);
        }
@@ -618,9 +621,9 @@ hdr_format_str (char *dest,
          mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
       }
       else {
-       colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
-       mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->subject));
-       add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+       colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_SUBJECT);
+       mutt_format_s (dest + colorlen, destlen - colorlen, prefix, NONULL (hdr->env->subject));
+       add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       }
       break;
 
@@ -646,9 +649,9 @@ hdr_format_str (char *dest,
         a short string passed into this routine */
       buf2[0] = ch;
       buf2[1] = 0;
-      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS);
-      mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-      add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+      colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_FLAGS);
+      mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+      add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       break;
 
     case 't':
@@ -720,9 +723,9 @@ hdr_format_str (char *dest,
                hdr->tagged ? '*' :
                (hdr->flagged ? '!' :
                 (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
-      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_FLAGS);
-      mutt_format_s (dest+colorlen, destlen-colorlen, prefix, buf2);
-      add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+      colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_FLAGS);
+      mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2);
+      add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
       break;
 
     case 'X':
@@ -742,9 +745,9 @@ hdr_format_str (char *dest,
        if (optional)
         optional = hdr->env->x_label ? 1 : 0;
 
-       colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL);
-       mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label));
-       add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+       colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_LABEL);
+       mutt_format_s (dest + colorlen, destlen - colorlen, prefix, NONULL (hdr->env->x_label));
+       add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
        break;
  
     case 'Y':
@@ -770,12 +773,12 @@ hdr_format_str (char *dest,
       if (optional)
        optional = i;
 
-      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_LABEL);
+      colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_LABEL);
       if (i)
-        mutt_format_s (dest+colorlen, destlen-colorlen, prefix, NONULL (hdr->env->x_label));
+        mutt_format_s (dest + colorlen, destlen - colorlen, prefix, NONULL (hdr->env->x_label));
       else
-        mutt_format_s (dest+colorlen, destlen-colorlen, prefix, "");
-      add_index_color(dest+colorlen, destlen-colorlen, flags, MT_COLOR_INDEX);
+        mutt_format_s (dest + colorlen, destlen - colorlen, prefix, "");
+      add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
 
       break;
 
diff --git a/menu.c b/menu.c
index 87046968f813a2ba7b3ad4720a718a298939de9d..411b4bef5a182d09681113777d0e44d8d43873b9 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -29,31 +29,36 @@ extern size_t UngetCount;
 
 char* SearchBuffers[MENU_MAX];
 
-static int get_color(int index, unsigned char *s) {
-  COLOR_LINE *color;
-  HEADER *hdr = Context->hdrs[Context->v2r[index]];
-  int type = *s;
-
-  switch (type) {
-    case MT_COLOR_INDEX_SUBJECT:
-      color = ColorIndexSubjectList;
-      break;
-    case MT_COLOR_INDEX_AUTHOR:
-      color = ColorIndexAuthorList;
-      break;
-    case MT_COLOR_INDEX_FLAGS:
-      color = ColorIndexFlagsList;
-      break;
-    default:
-      return ColorDefs[type];
-  }
+/**
+ * get_color - XXX
+ */
+static int
+get_color (int index, unsigned char *s)
+{
+       COLOR_LINE *color;
+       HEADER *hdr = Context->hdrs[Context->v2r[index]];
+       int type = *s;
+
+       switch (type) {
+               case MT_COLOR_INDEX_AUTHOR:
+                       color = ColorIndexAuthorList;
+                       break;
+               case MT_COLOR_INDEX_FLAGS:
+                       color = ColorIndexFlagsList;
+                       break;
+               case MT_COLOR_INDEX_SUBJECT:
+                       color = ColorIndexSubjectList;
+                       break;
+               default:
+                       return ColorDefs[type];
+       }
 
-  for (; color; color = color->next)
-    if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS, 
-                           Context, hdr))
-      return color->pair;
+       for (; color; color = color->next)
+               if (mutt_pattern_exec (color->color_pattern, M_MATCH_FULL_ADDRESS,
+                   Context, hdr))
+                       return color->pair;
 
-  return 0;
+       return 0;
 }
 
 static void print_enriched_string (int index, int attr, unsigned char *s, int do_color)
@@ -188,21 +193,20 @@ static void print_enriched_string (int index, int attr, unsigned char *s, int do
       }
       if (do_color) ATTRSET(attr);
     }
-    else if (*s == M_SPECIAL_INDEX)
-    {
+    else if (*s == M_SPECIAL_INDEX) {
       s++;
       if (do_color) {
-        if (*s == MT_COLOR_INDEX)
-          attrset(attr);
-        else
-        {
-          if (get_color(index, s) == 0)
-            attron(attr);
-          else
-            attron(get_color(index, s));
+        if (*s == MT_COLOR_INDEX) {
+          attrset (attr);
+       } else {
+          if (get_color (index, s) == 0) {
+            attron (attr);
+         } else {
+            attron (get_color (index, s));
+         }
         }
       }
-      s++; 
+      s++;
       n -= 2;
     }
     else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
@@ -346,7 +350,7 @@ void menu_redraw_motion (MUTTMENU *menu)
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
       menu_pad_string (buf, sizeof (buf));
       move (menu->oldcurrent + menu->offset - menu->top, 3);
-      print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+      print_enriched_string (menu->oldcurrent, menu->color (menu->oldcurrent), (unsigned char *) buf, 1);
     }
 
     /* now draw it in the new location */
@@ -358,14 +362,14 @@ void menu_redraw_motion (MUTTMENU *menu)
     /* erase the current indicator */
     menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
     menu_pad_string (buf, sizeof (buf));
-    print_enriched_string (menu->oldcurrent, menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
+    print_enriched_string (menu->oldcurrent, 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);
     menu_pad_string (buf, sizeof (buf));
     SETCOLOR(MT_COLOR_INDICATOR);
     move(menu->current - menu->top + menu->offset, 0);
-    print_enriched_string (menu->current, menu->color(menu->current), (unsigned char *) buf, 0);
+    print_enriched_string (menu->current, menu->color (menu->current), (unsigned char *) buf, 0);
   }
   menu->redraw &= REDRAW_STATUS;
   NORMAL_COLOR;
index 9fd1a0861745be33fbde8d8752c6f9e27e6d1632..fa3e450d91557f1744a622a99837b24c6ee3b86f 100644 (file)
@@ -184,9 +184,9 @@ extern int ColorDefs[];
 extern COLOR_LINE *ColorHdrList;
 extern COLOR_LINE *ColorBodyList;
 extern COLOR_LINE *ColorIndexList;
-extern COLOR_LINE *ColorIndexSubjectList;
 extern COLOR_LINE *ColorIndexAuthorList;
 extern COLOR_LINE *ColorIndexFlagsList;
+extern COLOR_LINE *ColorIndexSubjectList;
 
 void ci_init_color (void);
 void ci_start_color (void);