projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace deprecated luaL_openlib() by luaL_register()
[apps/madmutt.git]
/
thread.c
diff --git
a/thread.c
b/thread.c
index
6d2b649
..
5dc9842
100644
(file)
--- a/
thread.c
+++ b/
thread.c
@@
-7,21
+7,12
@@
* please see the file GPL in the top level source directory.
*/
* please see the file GPL in the top level source directory.
*/
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <lib-lib/mem.h>
-#include <lib-lib/macros.h>
+#include <lib-lib/lib-lib.h>
#include "mutt.h"
#include "sort.h"
#include "thread.h"
#include "mutt.h"
#include "sort.h"
#include "thread.h"
-
-#include <string.h>
-#include <ctype.h>
-
#define VISIBLE(hdr, ctx) (hdr->virtual >= 0 || (hdr->collapsed && (!ctx->pattern || hdr->limited)))
/* determine whether a is a descendant of b */
#define VISIBLE(hdr, ctx) (hdr->virtual >= 0 || (hdr->collapsed && (!ctx->pattern || hdr->limited)))
/* determine whether a is a descendant of b */
@@
-29,10
+20,10
@@
static int is_descendant (THREAD * a, THREAD * b)
{
while (a) {
if (a == b)
{
while (a) {
if (a == b)
- return
(1)
;
+ return
1
;
a = a->parent;
}
a = a->parent;
}
- return
(0)
;
+ return
0
;
}
/* Determines whether to display a message's subject. */
}
/* Determines whether to display a message's subject. */
@@
-42,11
+33,11
@@
static int need_display_subject (CONTEXT * ctx, HEADER * hdr)
/* if the user disabled subject hiding, display it */
if (!option (OPTHIDETHREADSUBJECT))
/* if the user disabled subject hiding, display it */
if (!option (OPTHIDETHREADSUBJECT))
- return
(1)
;
+ return
1
;
/* if our subject is different from our parent's, display it */
if (hdr->subject_changed)
/* if our subject is different from our parent's, display it */
if (hdr->subject_changed)
- return
(1)
;
+ return
1
;
/* if our subject is different from that of our closest previously displayed
* sibling, display the subject */
/* if our subject is different from that of our closest previously displayed
* sibling, display the subject */
@@
-54,7
+45,7
@@
static int need_display_subject (CONTEXT * ctx, HEADER * hdr)
hdr = tmp->message;
if (hdr && VISIBLE (hdr, ctx)) {
if (hdr->subject_changed)
hdr = tmp->message;
if (hdr && VISIBLE (hdr, ctx)) {
if (hdr->subject_changed)
- return
(1)
;
+ return
1
;
else
break;
}
else
break;
}
@@
-66,14
+57,14
@@
static int need_display_subject (CONTEXT * ctx, HEADER * hdr)
hdr = tmp->message;
if (hdr) {
if (VISIBLE (hdr, ctx))
hdr = tmp->message;
if (hdr) {
if (VISIBLE (hdr, ctx))
- return
(0)
;
+ return
0
;
else if (hdr->subject_changed)
else if (hdr->subject_changed)
- return
(1)
;
+ return
1
;
}
}
/* if we have no visible parent or previous sibling, display the subject */
}
}
/* if we have no visible parent or previous sibling, display the subject */
- return
(1)
;
+ return
1
;
}
static void linearize_tree (CONTEXT * ctx)
}
static void linearize_tree (CONTEXT * ctx)
@@
-204,10
+195,6
@@
static void calculate_visibility (CONTEXT * ctx, int *max_depth)
/* Since the graphics characters have a value >255, I have to resort to
* using escape sequences to pass the information to print_enriched_string().
* These are the macros M_TREE_* defined in mutt.h.
/* Since the graphics characters have a value >255, I have to resort to
* using escape sequences to pass the information to print_enriched_string().
* These are the macros M_TREE_* defined in mutt.h.
- *
- * ncurses should automatically use the default ASCII characters instead of
- * graphics chars on terminals which don't support them (see the man page
- * for curs_addch).
*/
void mutt_draw_tree (CONTEXT * ctx)
{
*/
void mutt_draw_tree (CONTEXT * ctx)
{
@@
-244,11
+231,11
@@
void mutt_draw_tree (CONTEXT * ctx)
new_tree = p_new(char, (2 + depth * width));
if (start_depth > 1) {
memcpy(new_tree, pfx, (start_depth - 1) * width);
new_tree = p_new(char, (2 + depth * width));
if (start_depth > 1) {
memcpy(new_tree, pfx, (start_depth - 1) * width);
-
strfcpy
(new_tree + (start_depth - 1) * width,
-
arrow, (1 + depth - start_depth) * width + 2
);
+
m_strcpy
(new_tree + (start_depth - 1) * width,
+
(1 + depth - start_depth) * width + 2, arrow
);
}
else
}
else
-
strfcpy (new_tree, arrow, 2 + depth * width
);
+
m_strcpy(new_tree, 2 + depth * width, arrow
);
tree->message->tree = new_tree;
}
}
tree->message->tree = new_tree;
}
}
@@
-316,12
+303,12
@@
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. */
* 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;
{
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;
for (;;) {
int rc = 0;
for (;;) {
@@
-345,7
+332,7
@@
static LIST *make_subject_list (THREAD * cur, time_t * dateptr)
break;
}
if (!curlist || rc > 0) {
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;
newlist->data = env->real_subj;
if (oldlist) {
newlist->next = oldlist->next;
@@
-366,7
+353,7
@@
static LIST *make_subject_list (THREAD * cur, time_t * dateptr)
cur = cur->next;
}
cur = cur->next;
}
- return
(subjects)
;
+ return
subjects
;
}
/* find the best possible match for a parent mesage based upon subject.
}
/* find the best possible match for a parent mesage based upon subject.
@@
-378,7
+365,7
@@
static THREAD *find_subject (CONTEXT * ctx, THREAD * cur)
struct hash_elem *ptr;
THREAD *tmp, *last = NULL;
int hash;
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);
time_t date = 0;
subjects = make_subject_list (cur, &date);
@@
-408,7
+395,7
@@
static THREAD *find_subject (CONTEXT * ctx, THREAD * cur)
subjects = subjects->next;
p_delete(&oldlist);
}
subjects = subjects->next;
p_delete(&oldlist);
}
- return
(last)
;
+ return
last
;
}
/* remove cur and its descendants from their current location.
}
/* remove cur and its descendants from their current location.
@@
-511,7
+498,7
@@
void mutt_clear_threads (CONTEXT * ctx)
ctx->tree = NULL;
if (ctx->thread_hash)
ctx->tree = NULL;
if (ctx->thread_hash)
- hash_de
stroy
(&ctx->thread_hash, free);
+ hash_de
lete
(&ctx->thread_hash, free);
}
static int compare_threads (const void *a, const void *b)
}
static int compare_threads (const void *a, const void *b)
@@
-527,7
+514,7
@@
static int compare_threads (const void *a, const void *b)
else {
sort_func = NULL;
sort_func = mutt_get_sort_func (Sort);
else {
sort_func = NULL;
sort_func = mutt_get_sort_func (Sort);
- return
(sort_func ? 1 : 0)
;
+ return
sort_func ? 1 : 0
;
}
}
}
}
@@
-544,7
+531,7
@@
THREAD *mutt_sort_subthreads (THREAD * thread, int init)
*/
Sort ^= SORT_REVERSE;
if (!compare_threads (NULL, NULL))
*/
Sort ^= SORT_REVERSE;
if (!compare_threads (NULL, NULL))
- return
(thread)
;
+ return
thread
;
top = thread;
top = thread;
@@
-641,7
+628,7
@@
THREAD *mutt_sort_subthreads (THREAD * thread, int init)
else {
Sort ^= SORT_REVERSE;
p_delete(&array);
else {
Sort ^= SORT_REVERSE;
p_delete(&array);
- return
(top)
;
+ return
top
;
}
}
}
}
@@
-685,7
+672,7
@@
void mutt_sort_threads (CONTEXT * ctx, int init)
HEADER *cur;
int i, oldsort, using_refs = 0;
THREAD *thread, *new, *tmp, top;
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
/* set Sort to the secondary method to support the set sort_aux=reverse-*
* settings. The sorting functions just look at the value of
@@
-698,7
+685,7
@@
void mutt_sort_threads (CONTEXT * ctx, int init)
init = 1;
if (init)
init = 1;
if (init)
- ctx->thread_hash = hash_
create (ctx->msgcount * 2
);
+ ctx->thread_hash = hash_
new (ctx->msgcount * 2, 1
);
/* we want a quick way to see if things are actually attached to the top of the
* thread tree or if they're just dangling, so we attach everything to a top
/* we want a quick way to see if things are actually attached to the top of the
* thread tree or if they're just dangling, so we attach everything to a top
@@
-763,7
+750,7
@@
void mutt_sort_threads (CONTEXT * ctx, int init)
cur->thread = thread;
hash_insert (ctx->thread_hash,
cur->env->message_id ? cur->env->message_id : "",
cur->thread = thread;
hash_insert (ctx->thread_hash,
cur->env->message_id ? cur->env->message_id : "",
- thread
, 1
);
+ thread);
if (new) {
if (new->duplicate_thread)
if (new) {
if (new->duplicate_thread)
@@
-839,7
+826,7
@@
void mutt_sort_threads (CONTEXT * ctx, int init)
if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL) {
new = p_new(THREAD, 1);
if ((new = hash_find (ctx->thread_hash, ref->data)) == NULL) {
new = p_new(THREAD, 1);
- hash_insert (ctx->thread_hash, ref->data, new
, 1
);
+ hash_insert (ctx->thread_hash, ref->data, new);
}
else {
if (new->duplicate_thread)
}
else {
if (new->duplicate_thread)
@@
-890,18
+877,18
@@
static HEADER *find_virtual (THREAD * cur, int reverse)
THREAD *top;
if (cur->message && cur->message->virtual >= 0)
THREAD *top;
if (cur->message && cur->message->virtual >= 0)
- return
(cur->message)
;
+ return
cur->message
;
top = cur;
if ((cur = cur->child) == NULL)
top = cur;
if ((cur = cur->child) == NULL)
- return
(NULL)
;
+ return
NULL
;
while (reverse && cur->next)
cur = cur->next;
for (;;) {
if (cur->message && cur->message->virtual >= 0)
while (reverse && cur->next)
cur = cur->next;
for (;;) {
if (cur->message && cur->message->virtual >= 0)
- return
(cur->message)
;
+ return
cur->message
;
if (cur->child) {
cur = cur->child;
if (cur->child) {
cur = cur->child;
@@
-915,7
+902,7
@@
static HEADER *find_virtual (THREAD * cur, int reverse)
while (!(reverse ? cur->prev : cur->next)) {
cur = cur->parent;
if (cur == top)
while (!(reverse ? cur->prev : cur->next)) {
cur = cur->parent;
if (cur == top)
- return
(NULL)
;
+ return
NULL
;
}
cur = reverse ? cur->prev : cur->next;
}
}
cur = reverse ? cur->prev : cur->next;
}
@@
-931,7
+918,7
@@
int _mutt_aside_thread (HEADER * hdr, short dir, short subthreads)
if ((Sort & SORT_MASK) != SORT_THREADS) {
mutt_error _("Threading is not enabled.");
if ((Sort & SORT_MASK) != SORT_THREADS) {
mutt_error _("Threading is not enabled.");
- return
(hdr->virtual)
;
+ return
hdr->virtual
;
}
cur = hdr->thread;
}
cur = hdr->thread;
@@
-955,7
+942,7
@@
int _mutt_aside_thread (HEADER * hdr, short dir, short subthreads)
do {
cur = cur->next;
if (!cur)
do {
cur = cur->next;
if (!cur)
- return
(-1)
;
+ return
-1
;
tmp = find_virtual (cur, 0);
} while (!tmp);
}
tmp = find_virtual (cur, 0);
} while (!tmp);
}
@@
-963,12
+950,12
@@
int _mutt_aside_thread (HEADER * hdr, short dir, short subthreads)
do {
cur = cur->prev;
if (!cur)
do {
cur = cur->prev;
if (!cur)
- return
(-1)
;
+ return
-1
;
tmp = find_virtual (cur, 1);
} while (!tmp);
}
tmp = find_virtual (cur, 1);
} while (!tmp);
}
- return
(tmp->virtual)
;
+ return
tmp->virtual
;
}
int mutt_parent_message (CONTEXT * ctx, HEADER * hdr)
}
int mutt_parent_message (CONTEXT * ctx, HEADER * hdr)
@@
-978,24
+965,24
@@
int mutt_parent_message (CONTEXT * ctx, HEADER * hdr)
if ((Sort & SORT_MASK) != SORT_THREADS) {
mutt_error _("Threading is not enabled.");
if ((Sort & SORT_MASK) != SORT_THREADS) {
mutt_error _("Threading is not enabled.");
- return
(hdr->virtual)
;
+ return
hdr->virtual
;
}
for (thread = hdr->thread->parent; thread; thread = thread->parent) {
if ((hdr = thread->message) != NULL) {
if (VISIBLE (hdr, ctx))
}
for (thread = hdr->thread->parent; thread; thread = thread->parent) {
if ((hdr = thread->message) != NULL) {
if (VISIBLE (hdr, ctx))
- return
(hdr->virtual)
;
+ return
hdr->virtual
;
else {
mutt_error _("Parent message is not visible in this limited view.");
else {
mutt_error _("Parent message is not visible in this limited view.");
- return
(-1)
;
+ return
-1
;
}
}
}
mutt_error _("Parent message is not available.");
}
}
}
mutt_error _("Parent message is not available.");
- return
(-1)
;
+ return
-1
;
}
void mutt_set_virtual (CONTEXT * ctx)
}
void mutt_set_virtual (CONTEXT * ctx)
@@
-1032,7
+1019,7
@@
int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag)
if ((Sort & SORT_MASK) != SORT_THREADS && !(flag & M_THREAD_GET_HIDDEN)) {
mutt_error (_("Threading is not enabled."));
if ((Sort & SORT_MASK) != SORT_THREADS && !(flag & M_THREAD_GET_HIDDEN)) {
mutt_error (_("Threading is not enabled."));
- return
(cur->virtual)
;
+ return
cur->virtual
;
}
final = cur->virtual;
}
final = cur->virtual;
@@
-1072,13
+1059,13
@@
int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag)
if (thread == top && (thread = thread->child) == NULL) {
/* return value depends on action requested */
if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
if (thread == top && (thread = thread->child) == NULL) {
/* return value depends on action requested */
if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
- return
(final)
;
+ return
final
;
else if (flag & M_THREAD_UNREAD)
else if (flag & M_THREAD_UNREAD)
- return (
(old && new) ? new : (old ? old : new)
);
+ return (
old && new) ? new : (old ? old : new
);
else if (flag & M_THREAD_GET_HIDDEN)
else if (flag & M_THREAD_GET_HIDDEN)
- return
(num_hidden)
;
+ return
num_hidden
;
else if (flag & M_THREAD_NEXT_UNREAD)
else if (flag & M_THREAD_NEXT_UNREAD)
- return
(min_unread)
;
+ return
min_unread
;
}
for (;;) {
}
for (;;) {
@@
-1148,15
+1135,15
@@
int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag)
/* return value depends on action requested */
if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
/* return value depends on action requested */
if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))
- return
(final)
;
+ return
final
;
else if (flag & M_THREAD_UNREAD)
else if (flag & M_THREAD_UNREAD)
- return (
(old && new) ? new : (old ? old : new)
);
+ return (
old && new) ? new : (old ? old : new
);
else if (flag & M_THREAD_GET_HIDDEN)
else if (flag & M_THREAD_GET_HIDDEN)
- return
(num_hidden + 1)
;
+ return
num_hidden + 1
;
else if (flag & M_THREAD_NEXT_UNREAD)
else if (flag & M_THREAD_NEXT_UNREAD)
- return
(min_unread)
;
+ return
min_unread
;
- return
(0)
;
+ return
0
;
#undef CHECK_LIMIT
}
#undef CHECK_LIMIT
}
@@
-1170,7
+1157,7
@@
int mutt_messages_in_thread (CONTEXT * ctx, HEADER * hdr, int flag)
int i, rc;
if ((Sort & SORT_MASK) != SORT_THREADS || !hdr->thread)
int i, rc;
if ((Sort & SORT_MASK) != SORT_THREADS || !hdr->thread)
- return
(1)
;
+ return
1
;
threads[0] = hdr->thread;
while (threads[0]->parent)
threads[0] = hdr->thread;
while (threads[0]->parent)
@@
-1195,53
+1182,53
@@
int mutt_messages_in_thread (CONTEXT * ctx, HEADER * hdr, int flag)
if (flag)
rc += 1;
if (flag)
rc += 1;
- return
(rc)
;
+ return
rc
;
}
}
-
HASH
*mutt_make_id_hash (CONTEXT * ctx)
+
hash_t
*mutt_make_id_hash (CONTEXT * ctx)
{
int i;
HEADER *hdr;
{
int i;
HEADER *hdr;
-
HASH
*hash;
+
hash_t
*hash;
- hash = hash_
create (ctx->msgcount * 2
);
+ hash = hash_
new (ctx->msgcount * 2, 0
);
for (i = 0; i < ctx->msgcount; i++) {
hdr = ctx->hdrs[i];
if (hdr->env->message_id)
for (i = 0; i < ctx->msgcount; i++) {
hdr = ctx->hdrs[i];
if (hdr->env->message_id)
- hash_insert (hash, hdr->env->message_id, hdr
, 0
);
+ hash_insert (hash, hdr->env->message_id, hdr);
}
return hash;
}
}
return hash;
}
-
HASH
*mutt_make_subj_hash (CONTEXT * ctx)
+
hash_t
*mutt_make_subj_hash (CONTEXT * ctx)
{
int i;
HEADER *hdr;
{
int i;
HEADER *hdr;
-
HASH
*hash;
+
hash_t
*hash;
- hash = hash_
create (ctx->msgcount * 2
);
+ hash = hash_
new (ctx->msgcount * 2, 1
);
for (i = 0; i < ctx->msgcount; i++) {
hdr = ctx->hdrs[i];
if (hdr->env->real_subj)
for (i = 0; i < ctx->msgcount; i++) {
hdr = ctx->hdrs[i];
if (hdr->env->real_subj)
- hash_insert
(hash, hdr->env->real_subj, hdr, 1
);
+ hash_insert
(hash, hdr->env->real_subj, hdr
);
}
return hash;
}
}
return hash;
}
-static void clean_references (THREAD * brk, THREAD * cur)
+static void clean_references (THREAD *
t
brk, THREAD * cur)
{
THREAD *p;
{
THREAD *p;
-
LIST
*ref = NULL;
+
string_list_t
*ref = NULL;
int done = 0;
for (; cur; cur = cur->next, done = 0) {
/* parse subthread recursively */
int done = 0;
for (; cur; cur = cur->next, done = 0) {
/* parse subthread recursively */
- clean_references (brk, cur->child);
+ clean_references (
t
brk, cur->child);
if (!cur->message)
break; /* skip pseudo-message */
if (!cur->message)
break; /* skip pseudo-message */
@@
-1249,7
+1236,7
@@
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. */
/* 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 =
t
brk; !done && p; p = p->parent)
for (ref = cur->message->env->references; p->message && ref;
ref = ref->next)
if (!m_strcasecmp(ref->data, p->message->env->message_id)) {
for (ref = cur->message->env->references; p->message && ref;
ref = ref->next)
if (!m_strcasecmp(ref->data, p->message->env->message_id)) {
@@
-1261,7
+1248,7
@@
static void clean_references (THREAD * brk, THREAD * cur)
HEADER *h = cur->message;
/* clearing the References: header from obsolete Message-ID(s) */
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;
}
h->env->refs_changed = h->changed = 1;
}
@@
-1270,8
+1257,8
@@
static void clean_references (THREAD * brk, THREAD * cur)
void mutt_break_thread (HEADER * hdr)
{
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);
}
hdr->env->irt_changed = hdr->env->refs_changed = hdr->changed = 1;
clean_references (hdr->thread, hdr->thread->child);
}
@@
-1283,7
+1270,7
@@
static int link_threads (HEADER * parent, HEADER * child, CONTEXT * ctx)
mutt_break_thread (child);
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);
child->env->in_reply_to->data = m_strdup(parent->env->message_id);
mutt_set_flag (ctx, child, M_TAG, 0);