aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2009-10-14 13:30:33 -0700
committerCarl Worth <cworth@cworth.org>2009-10-14 13:30:33 -0700
commitbe72bf30703c5df814d4f572c3d9132d39700b36 (patch)
treef03a0c3595c2871388dd16cf9eb4b3debdda9a8a
parent1c63ec7031926fcd06ac3293d9e402af069ea6ac (diff)
Use gmime's own reference-parsing code.
Here's another instance where I "knew" gmime must have support for some functionality, but not finding it, I rolled my own. Now that I found g_mime_references_decode I'm glad to drop my ugly code.
-rw-r--r--notmuch-index-message.cc30
1 files changed, 11 insertions, 19 deletions
diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc
index f7ea340f..1922dd37 100644
--- a/notmuch-index-message.cc
+++ b/notmuch-index-message.cc
@@ -307,30 +307,22 @@ find_thread_id (Xapian::Database db,
* message. */
static void
parse_references (GPtrArray *array,
- const char *refs)
+ const char *refs_str)
{
- const char *end, *next;
+ GMimeReferences *refs, *r;
+ const char *message_id;
- if (refs == NULL)
+ if (refs_str == NULL)
return;
- while (*refs) {
- while (*refs && isspace (*refs))
- refs++;
- if (*refs == '<')
- refs++;
- end = refs;
- while (*end && !isspace (*end))
- end++;
- next = end;
- end--;
- if (end > refs && *end == '>')
- end--;
- if (end > refs) {
- g_ptr_array_add (array, g_strndup (refs, end - refs + 1));
- }
- refs = next;
+ refs = g_mime_references_decode (refs_str);
+
+ for (r = refs; r; r = r->next) {
+ message_id = g_mime_references_get_message_id (r);
+ g_ptr_array_add (array, g_strdup (message_id));
}
+
+ g_mime_references_free (refs);
}
/* Given a string representing the body of a message, generate terms