]> granicus.if.org Git - neomutt/commitdiff
tidy code
authorRichard Russon <rich@flatcap.org>
Sat, 26 Mar 2016 03:44:41 +0000 (03:44 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 02:33:32 +0000 (03:33 +0100)
curs_main.c
pattern.c

index 92ac49efbc4421a58c376cd03e9b7e9672625d06..c709d4bce96879963b7741d5887ece2f6fad1176 100644 (file)
@@ -910,8 +910,8 @@ int mutt_index_menu (void)
        CHECK_IN_MAILBOX;
        menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
                CURHDR->index : -1;
-       if ((op == OP_LIMIT_CURRENT_THREAD && mutt_limit_current_thread(CURHDR))
-           || (op == OP_MAIN_LIMIT && mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0))
+       if (((op == OP_LIMIT_CURRENT_THREAD) && mutt_limit_current_thread(CURHDR))
+           || ((op == OP_MAIN_LIMIT) && (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)))
        {
          if (menu->oldcurrent >= 0)
          {
index c6abc1dca60e1937b450820351cba828f19ee38b..87305886a223cf8d2d3e5b00387fc3cb7f232f50 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1294,49 +1294,72 @@ void mutt_check_simple (char *s, size_t len, const char *simple)
   }
 }
 
-static THREAD* top_of_thread(HEADER *h)
+/**
+ * top_of_thread - Find the first email in the current thread
+ * @h: Header of current email
+ *
+ * Returns:
+ *     THREAD*: success, email found
+ *     NULL:    on error
+ */
+static THREAD *
+top_of_thread (HEADER *h)
 {
-  THREAD *t = h->thread;
+       THREAD *t;
 
-  while (t && t->parent) t = t->parent;
-  return t;
-}
+       if (!h)
+               return NULL;
 
-int mutt_limit_current_thread (HEADER *h)
-{
-  int i;
-  THREAD *me;
+       t = h->thread;
 
-  me = top_of_thread(h);
+       while (t && t->parent)
+               t = t->parent;
 
-  if (!me) {
-    /* NOP */
-    return 0;
-  }
-
-  Context->vcount    = 0;
-  Context->vsize     = 0;
-  Context->collapsed = 0;
+       return t;
+}
 
-  for (i = 0; i < Context->msgcount; i++)
-  {
-    Context->hdrs[i]->virtual = -1;
-    Context->hdrs[i]->limited = 0;
-    Context->hdrs[i]->collapsed = 0;
-    Context->hdrs[i]->num_hidden = 0;
-    if (top_of_thread(Context->hdrs[i]) == me)
-    {
-      BODY *body = Context->hdrs[i]->content;
-
-      Context->hdrs[i]->virtual = Context->vcount;
-      Context->hdrs[i]->limited = 1;
-      Context->v2r[Context->vcount] = i;
-      Context->vcount++;
-      Context->vsize += body->length + body->offset -
-       body->hdr_offset;
-    }
-  }
-  return 1;
+/**
+ * mutt_limit_current_thread - Limit the email view to the current thread
+ * @h: Header of current email
+ *
+ * Returns:
+ *     1: Success
+ *     0: Failure
+ */
+int
+mutt_limit_current_thread (HEADER *h)
+{
+       int i;
+       THREAD *me;
+
+       if (!h)
+               return 0;
+
+       me = top_of_thread (h);
+       if (!me)
+               return 0;
+
+       Context->vcount    = 0;
+       Context->vsize     = 0;
+       Context->collapsed = 0;
+
+       for (i = 0; i < Context->msgcount; i++) {
+               Context->hdrs[i]->virtual    = -1;
+               Context->hdrs[i]->limited    = 0;
+               Context->hdrs[i]->collapsed  = 0;
+               Context->hdrs[i]->num_hidden = 0;
+
+               if (top_of_thread (Context->hdrs[i]) == me) {
+                       BODY *body = Context->hdrs[i]->content;
+
+                       Context->hdrs[i]->virtual = Context->vcount;
+                       Context->hdrs[i]->limited = 1;
+                       Context->v2r[Context->vcount] = i;
+                       Context->vcount++;
+                       Context->vsize += (body->length + body->offset - body->hdr_offset);
+               }
+       }
+       return 1;
 }
 
 int mutt_pattern_func (int op, char *prompt)