X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=thread.c;h=e34c543ea88bf62b1d547c15eff7f8780dc22eab;hp=1bf0b5fd40fa2f020057d1275e1ed94524f6ced7;hb=7e6ea12f3d017b6a04d86862e42ef3fd23780d8e;hpb=2ea77d3b2827ba23feb756ce2fb936565ae38998 diff --git a/thread.c b/thread.c index 1bf0b5f..e34c543 100644 --- a/thread.c +++ b/thread.c @@ -7,21 +7,12 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include +#include #include "mutt.h" #include "sort.h" #include "thread.h" - -#include -#include - #define VISIBLE(hdr, ctx) (hdr->virtual >= 0 || (hdr->collapsed && (!ctx->pattern || hdr->limited))) /* determine whether a is a descendant of b */ @@ -124,7 +115,7 @@ static void calculate_visibility (CONTEXT * ctx, int *max_depth) tree = tree->next; *max_depth = 0; - FOREVER { + for (;;) { if (depth > *max_depth) *max_depth = depth; @@ -180,7 +171,7 @@ static void calculate_visibility (CONTEXT * ctx, int *max_depth) /* now fix up for the OPTHIDETOP* options if necessary */ if (hide_top_limited || hide_top_missing) { tree = ctx->tree; - FOREVER { + for (;;) { if (!tree->visible && tree->deep && tree->subtree_visible < 2 && ((tree->message && hide_top_limited) || (!tree->message && hide_top_missing))) @@ -243,12 +234,12 @@ void mutt_draw_tree (CONTEXT * ctx) myarrow[width + 1] = 0; new_tree = p_new(char, (2 + depth * width)); if (start_depth > 1) { - strncpy (new_tree, pfx, (start_depth - 1) * width); - strfcpy (new_tree + (start_depth - 1) * width, - arrow, (1 + depth - start_depth) * width + 2); + memcpy(new_tree, pfx, (start_depth - 1) * width); + m_strcpy(new_tree + (start_depth - 1) * width, + (1 + depth - start_depth) * width + 2, arrow); } else - strfcpy (new_tree, arrow, 2 + depth * width); + m_strcpy(new_tree, 2 + depth * width, arrow); tree->message->tree = new_tree; } } @@ -316,15 +307,15 @@ void mutt_draw_tree (CONTEXT * ctx) * has no message, we have to make a list of all the subjects of its * most immediate existing descendants. we also note the earliest * date on any of the parents and put it in *dateptr. */ -static LIST *make_subject_list (THREAD * cur, time_t * dateptr) +static string_list_t *make_subject_list (THREAD * cur, time_t * dateptr) { THREAD *start = cur; ENVELOPE *env; time_t thisdate; - LIST *curlist, *oldlist, *newlist, *subjects = NULL; + string_list_t *curlist, *oldlist, *newlist, *subjects = NULL; int rc = 0; - FOREVER { + for (;;) { while (!cur->message) cur = cur->child; @@ -345,7 +336,7 @@ static LIST *make_subject_list (THREAD * cur, time_t * dateptr) break; } if (!curlist || rc > 0) { - newlist = p_new(LIST, 1); + newlist = p_new(string_list_t, 1); newlist->data = env->real_subj; if (oldlist) { newlist->next = oldlist->next; @@ -378,7 +369,7 @@ static THREAD *find_subject (CONTEXT * ctx, THREAD * cur) struct hash_elem *ptr; THREAD *tmp, *last = NULL; int hash; - LIST *subjects = NULL, *oldlist; + string_list_t *subjects = NULL, *oldlist; time_t date = 0; subjects = make_subject_list (cur, &date); @@ -463,7 +454,7 @@ static void pseudo_threads (CONTEXT * ctx) insert_message (&parent->child, parent, cur); parent->sort_children = 1; tmp = cur; - FOREVER { + for (;;) { while (!tmp->message) tmp = tmp->child; @@ -685,7 +676,7 @@ void mutt_sort_threads (CONTEXT * ctx, int init) HEADER *cur; int i, oldsort, using_refs = 0; THREAD *thread, *new, *tmp, top; - LIST *ref = NULL; + string_list_t *ref = NULL; /* set Sort to the secondary method to support the set sort_aux=reverse-* * settings. The sorting functions just look at the value of @@ -899,7 +890,7 @@ static HEADER *find_virtual (THREAD * cur, int reverse) while (reverse && cur->next) cur = cur->next; - FOREVER { + for (;;) { if (cur->message && cur->message->virtual >= 0) return (cur->message); @@ -1081,7 +1072,7 @@ int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag) return (min_unread); } - FOREVER { + for (;;) { cur = thread->message; if (cur) { @@ -1233,15 +1224,15 @@ HASH *mutt_make_subj_hash (CONTEXT * ctx) return hash; } -static void clean_references (THREAD * brk, THREAD * cur) +static void clean_references (THREAD * tbrk, THREAD * cur) { THREAD *p; - LIST *ref = NULL; + string_list_t *ref = NULL; int done = 0; for (; cur; cur = cur->next, done = 0) { /* parse subthread recursively */ - clean_references (brk, cur->child); + clean_references (tbrk, cur->child); if (!cur->message) break; /* skip pseudo-message */ @@ -1249,10 +1240,10 @@ static void clean_references (THREAD * brk, THREAD * cur) /* Looking for the first bad reference according to the new threading. * Optimal since Mutt stores the references in reverse order, and the * first loop should match immediatly for mails respecting RFC2822. */ - for (p = brk; !done && p; p = p->parent) + for (p = tbrk; !done && p; p = p->parent) for (ref = cur->message->env->references; p->message && ref; ref = ref->next) - if (!str_casecmp (ref->data, p->message->env->message_id)) { + if (!m_strcasecmp(ref->data, p->message->env->message_id)) { done = 1; break; } @@ -1261,7 +1252,7 @@ static void clean_references (THREAD * brk, THREAD * cur) HEADER *h = cur->message; /* clearing the References: header from obsolete Message-ID(s) */ - mutt_free_list (&ref->next); + string_list_wipe(&ref->next); h->env->refs_changed = h->changed = 1; } @@ -1270,8 +1261,8 @@ static void clean_references (THREAD * brk, THREAD * cur) void mutt_break_thread (HEADER * hdr) { - mutt_free_list (&hdr->env->in_reply_to); - mutt_free_list (&hdr->env->references); + string_list_wipe(&hdr->env->in_reply_to); + string_list_wipe(&hdr->env->references); hdr->env->irt_changed = hdr->env->refs_changed = hdr->changed = 1; clean_references (hdr->thread, hdr->thread->child); } @@ -1283,7 +1274,7 @@ static int link_threads (HEADER * parent, HEADER * child, CONTEXT * ctx) mutt_break_thread (child); - child->env->in_reply_to = mutt_new_list (); + child->env->in_reply_to = string_item_new(); child->env->in_reply_to->data = m_strdup(parent->env->message_id); mutt_set_flag (ctx, child, M_TAG, 0);