]> git.notmuchmail.org Git - notmuch/commitdiff
Split thread_id value on commas before inserting into hash.
authorCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2009 23:04:25 +0000 (16:04 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2009 23:04:25 +0000 (16:04 -0700)
One thread_id value may have multiple thread IDs in it so we need
to separate them out before inserting into our hash.

notmuch-index-message.cc

index 3bb62f659dcdc29515bb03c616a56db569b586a3..5396cd19458fe0b5fc2833545da9aa6b7c345fe0 100644 (file)
@@ -269,12 +269,23 @@ static void
 insert_thread_id (GHashTable *thread_ids, Xapian::Document doc)
 {
     string value_string;
 insert_thread_id (GHashTable *thread_ids, Xapian::Document doc)
 {
     string value_string;
-    const char *value;
+    const char *value, *id, *comma;
 
     value_string = doc.get_value (NOTMUCH_VALUE_THREAD);
     value = value_string.c_str();
 
     value_string = doc.get_value (NOTMUCH_VALUE_THREAD);
     value = value_string.c_str();
-    if (strlen (value))
-       g_hash_table_insert (thread_ids, strdup (value), NULL);
+    if (strlen (value)) {
+       id = value;
+       while (*id) {
+           comma = strchr (id, ',');
+           if (comma == NULL)
+               comma = id + strlen (id);
+           g_hash_table_insert (thread_ids,
+                                strndup (id, comma - id), NULL);
+           id = comma;
+           if (*id)
+               id++;
+       }
+    }
 }
 
 /* Return one or more thread_ids, (as a GPtrArray of strings), for the
 }
 
 /* Return one or more thread_ids, (as a GPtrArray of strings), for the