diff options
| author | Carl Worth <cworth@cworth.org> | 2009-10-14 16:04:25 -0700 |
|---|---|---|
| committer | Carl Worth <cworth@cworth.org> | 2009-10-14 16:04:25 -0700 |
| commit | 870b3987265f74ed8b45ba0e7d7edfcca1923b5a (patch) | |
| tree | e3e481c5bdf367c250a21169096f13375688dc57 | |
| parent | 27c01802c89fb825c144ead13de0f6d6437ba997 (diff) | |
Split thread_id value on commas before inserting into hash.
One thread_id value may have multiple thread IDs in it so we need
to separate them out before inserting into our hash.
| -rw-r--r-- | notmuch-index-message.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index 3bb62f65..5396cd19 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -269,12 +269,23 @@ static void 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(); - 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 |
