#include <string.h>
#include <ctype.h>
+/* returns 1 if `a' is a descendant (child) of thread `b' */
+static int is_descendant (HEADER *a, HEADER *b)
+{
+ /* find the top parent of the thread */
+ while (a->parent)
+ a = a->parent;
+ return (a == b);
+}
+
/* This function makes use of the fact that Mutt stores message references in
* reverse order (i.e., last to first). This is optiminal since we would like
* to find the most recent message to which "cur" refers itself.
for (; refs; refs = refs->next)
{
/* ups, this message is in a reference loop. bad. */
-
if (cur->env->message_id && !strcmp (cur->env->message_id, refs->data))
continue;
-
+
if ((ptr = hash_find (ctx->id_hash, refs->data)))
+ {
+ if (is_descendant (ptr, cur))
+ continue;
+
return ptr;
+ }
}
return NULL;
}
/* determines whether a later sibling or the child of a later
- sibling is displayed. */
+ * sibling is displayed.
+ */
+
static int is_next_displayed (CONTEXT *ctx, HEADER *tree)
{
int depth = 0;
HEADER **array = ctx->hdrs + (Sort & SORT_REVERSE ? ctx->msgcount - 1 : 0);
/* A NULL tree should never be passed here, but may occur if there is
- a cycle. */
+ * a cycle.
+ */
if (!tree)
return;
msg->next = NULL;
}
-/* returns 1 if `a' is a descendant (child) of thread `b' */
-static int is_descendant (HEADER *a, HEADER *b)
-{
- /* find the top parent of the thread */
- while (a->parent)
- a = a->parent;
- return (a == b);
-}
/* find the best possible match for a parent mesage based upon subject.
- if there are multiple matches, the one which was sent the latest, but
- before the current message, is used. */
+ * if there are multiple matches, the one which was sent the latest, but
+ * before the current message, is used.
+ */
+
static HEADER *find_subject (CONTEXT *ctx, HEADER *cur)
{
struct hash_elem *ptr;