0.9.4claws28
[claws.git] / src / procmsg.c
index 7cc0a05a828a26c0f895fedf59019ceae239ec1e..ef9b94793973cd93210463888d6d6ccdf0c4a296 100644 (file)
@@ -139,17 +139,14 @@ static gboolean procmsg_ignore_node(GNode *node, gpointer data)
 
 /* CLAWS subject threading:
   
-  in the first round it inserts subject lines in a hash 
-  table. a duplicate subject line replaces the one in
-  the table only if its older. (this round should actually 
-  create a list of all duplicate subject lines)
+  in the first round it inserts subject lines in a 
+  relation (subject <-> node)
 
   the second round finishes the threads by attaching
-  duplicate subject lines to the one found in the
-  hash table. as soon as a subject line is found that
-  is too old, that one becomes the new parent for
-  the next iteration. (this fails when a parent arrived
-  later than its child.)
+  matching subject lines to the one found in the
+  relation. will use the oldest node with the same
+  subject that is not more then thread_by_subject_max_age
+  days old (see subject_relation_lookup)
 */  
 
 static void subject_relation_insert(GRelation *relation, GNode *node)
@@ -175,13 +172,17 @@ static GNode *subject_relation_lookup(GRelation *relation, MsgInfo *msginfo)
        gchar *subject;
        GTuples *tuples;
        GNode *node = NULL;
+       gint prefix_length;
     
        g_return_val_if_fail(relation != NULL, NULL);
 
        subject = msginfo->subject;
        if (subject == NULL)
                return NULL;
-       subject += subject_get_prefix_length(subject);
+       prefix_length = subject_get_prefix_length(subject);
+       if (prefix_length <= 0)
+               return NULL;
+       subject += prefix_length;
        
        tuples = g_relation_select(relation, subject, 0);
        if (tuples == NULL)