* mu-msg-file: ensure there are no duplicates in References: + Reply-To
This commit is contained in:
@ -692,6 +692,34 @@ get_msgids_reverted (MuMsgFile *self, const gchar *header)
|
|||||||
return msgids;
|
return msgids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GSList*
|
||||||
|
remove_dups (GSList *refs)
|
||||||
|
{
|
||||||
|
GHashTable *hash;
|
||||||
|
GSList *cur, *oldcur;
|
||||||
|
|
||||||
|
hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
|
for (oldcur = NULL, cur = refs; cur; cur = g_slist_next (cur)) {
|
||||||
|
/* already seen? note, the first one cannot be a dup,
|
||||||
|
* so oldcur won't be NULL, and refs stays valid */
|
||||||
|
if (g_hash_table_lookup (hash, (gchar*)cur->data)) {
|
||||||
|
oldcur->next = cur->next;
|
||||||
|
cur->next = NULL;
|
||||||
|
g_slist_free (cur);
|
||||||
|
cur = oldcur;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
g_hash_table_insert (hash, (gchar*)cur->data,
|
||||||
|
GUINT_TO_POINTER(TRUE));
|
||||||
|
oldcur = cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_destroy (hash);
|
||||||
|
|
||||||
|
return refs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
get_references (MuMsgFile *self)
|
get_references (MuMsgFile *self)
|
||||||
@ -711,6 +739,8 @@ get_references (MuMsgFile *self)
|
|||||||
g_slist_free (inreply);
|
g_slist_free (inreply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refs = remove_dups (refs);
|
||||||
|
|
||||||
/* put in proper order */
|
/* put in proper order */
|
||||||
return g_slist_reverse (refs);
|
return g_slist_reverse (refs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user