# include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/macros.h>
+
#include "mutt.h"
#include "sort.h"
+#include "thread.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
#include <string.h>
#include <ctype.h>
tree->subtree_visible = 0;
if (tree->message) {
- FREE (&tree->message->tree);
+ p_delete(&tree->message->tree);
if (VISIBLE (tree->message, ctx)) {
tree->deep = 1;
tree->visible = 1;
* From now on we can simply ignore invisible subtrees
*/
calculate_visibility (ctx, &max_depth);
- pfx = safe_malloc (width * max_depth + 2);
- arrow = safe_malloc (width * max_depth + 2);
+ pfx = p_new(char, width * max_depth + 2);
+ arrow = p_new(char, width * max_depth + 2);
while (tree) {
if (depth) {
myarrow = arrow + (depth - start_depth - (start_depth ? 0 : 1)) * width;
if (tree->visible) {
myarrow[width] = M_TREE_RARROW;
myarrow[width + 1] = 0;
- new_tree = safe_malloc ((2 + depth * width));
+ 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,
while (!tree->deep);
}
- FREE (&pfx);
- FREE (&arrow);
+ p_delete(&pfx);
+ p_delete(&arrow);
}
/* since we may be trying to attach as a pseudo-thread a THREAD that
break;
}
if (!curlist || rc > 0) {
- newlist = safe_calloc (1, sizeof (LIST));
+ newlist = p_new(LIST, 1);
newlist->data = env->real_subj;
if (oldlist) {
newlist->next = oldlist->next;
oldlist = subjects;
subjects = subjects->next;
- FREE (&oldlist);
+ p_delete(&oldlist);
}
return (last);
}
hash_destroy (&ctx->thread_hash, free);
}
-int compare_threads (const void *a, const void *b)
+static int compare_threads (const void *a, const void *b)
{
static sort_t *sort_func = NULL;
top = thread;
- array = safe_calloc ((array_size = 256), sizeof (THREAD *));
+ array = p_new(THREAD *, (array_size = 256));
while (1) {
if (init || !thread->sort_key) {
thread->sort_key = NULL;
/* put them into the array */
for (i = 0; thread; i++, thread = thread->prev) {
if (i >= array_size)
- safe_realloc (&array, (array_size *= 2) * sizeof (THREAD *));
+ p_realloc(&array, array_size *= 2);
array[i] = thread;
}
}
else {
Sort ^= SORT_REVERSE;
- FREE (&array);
+ p_delete(&array);
return (top);
}
}
else {
new = (option (OPTDUPTHREADS) ? thread : NULL);
- thread = safe_calloc (1, sizeof (THREAD));
+ thread = p_new(THREAD, 1);
thread->message = cur;
thread->check_subject = 1;
cur->thread = thread;
break;
if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL) {
- new = safe_calloc (1, sizeof (THREAD));
+ new = p_new(THREAD, 1);
hash_insert (ctx->thread_hash, ref->data, new, 1);
}
else {
if (done) {
HEADER *h = cur->message;
- /* clearing the References: header from obsolete Message-Id(s) */
+ /* clearing the References: header from obsolete Message-ID(s) */
mutt_free_list (&ref->next);
h->env->refs_changed = h->changed = 1;
{
mutt_free_list (&hdr->env->in_reply_to);
mutt_free_list (&hdr->env->references);
- hdr->env->irt_changed = hdr->env->refs_changed = 1;
+ hdr->env->irt_changed = hdr->env->refs_changed = hdr->changed = 1;
clean_references (hdr->thread, hdr->thread->child);
}
mutt_break_thread (child);
child->env->in_reply_to = mutt_new_list ();
- child->env->in_reply_to->data = str_dup (parent->env->message_id);
+ child->env->in_reply_to->data = m_strdup(parent->env->message_id);
mutt_set_flag (ctx, child, M_TAG, 0);
return changed;
}
+
+void mutt_adjust_subject (ENVELOPE* e) {
+ regmatch_t pmatch[1];
+
+ if (e && e->subject) {
+ if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
+ e->real_subj = e->subject + pmatch[0].rm_eo;
+ else
+ e->real_subj = e->subject;
+ }
+}
+
+void mutt_adjust_all_subjects (void) {
+ int i = 0;
+
+ if (!Context || !Context->msgcount)
+ return;
+
+ for (i = 0; i < Context->msgcount; i++)
+ mutt_adjust_subject (Context->hdrs[i]->env);
+}