[PATCH 1/2] fix notmuch_message_file_get_header
Dirk Hohndel
hohndel at infradead.org
Tue Apr 6 12:45:30 PDT 2010
fix notmuch_message_file_get_header to always return the first instance
of the header you are looking for
Signed-off-by: Dirk Hohndel <hohndel at infradead.org>
---
lib/message-file.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/message-file.c b/lib/message-file.c
index 3a1a681..0c152a3 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -318,9 +318,15 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
match = (strcasecmp (header, header_desired) == 0);
decoded_value = g_mime_utils_header_decode_text (message->value.str);
-
- g_hash_table_insert (message->headers, header, decoded_value);
-
+ if (g_hash_table_lookup (message->headers, header) == NULL) {
+ /* Only insert if we don't have a value for this header, yet.
+ * This way we always return the FIRST instance of any header
+ * we search for
+ * FIXME: we should be returning ALL instances of a header
+ * or at least provide a way to iterate over them
+ */
+ g_hash_table_insert (message->headers, header, decoded_value);
+ }
if (match)
return decoded_value;
}
--
1.6.6.1
--
Dirk Hohndel
Intel Open Source Technology Center
More information about the notmuch
mailing list