X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-search.c;h=3c455bfe54428df4a4affc04dc53c1c36a2c369e;hp=7fdc6acaa2fe90c600899dab91ef0caa02e4d443;hb=6cdd34a4c762c954426f586d514a3e041c1db3b0;hpb=dfe15c0e1b18f4d9ab5d328399e56b3be4a251a5 diff --git a/notmuch-search.c b/notmuch-search.c index 7fdc6aca..3c455bfe 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -111,6 +111,7 @@ do_search_threads (search_context_t *ctx) sprinter_t *format = ctx->format; time_t date; int i; + notmuch_status_t status; if (ctx->offset < 0) { ctx->offset += notmuch_query_count_threads (ctx->query); @@ -118,8 +119,8 @@ do_search_threads (search_context_t *ctx) ctx->offset = 0; } - threads = notmuch_query_search_threads (ctx->query); - if (threads == NULL) + status = notmuch_query_search_threads_st (ctx->query, &threads); + if (print_status_query("notmuch search", ctx->query, status)) return 1; format->begin_list (format); @@ -243,6 +244,21 @@ do_search_threads (search_context_t *ctx) return 0; } +static mailbox_t *new_mailbox (void *ctx, const char *name, const char *addr) +{ + mailbox_t *mailbox; + + mailbox = talloc (ctx, mailbox_t); + if (! mailbox) + return NULL; + + mailbox->name = talloc_strdup (mailbox, name); + mailbox->addr = talloc_strdup (mailbox, addr); + mailbox->count = 1; + + return mailbox; +} + /* Returns TRUE iff name and addr is duplicate. If not, stores the * name/addr pair in order to detect subsequent duplicates. */ static notmuch_bool_t @@ -262,10 +278,10 @@ is_duplicate (const search_context_t *ctx, const char *name, const char *addr) return TRUE; } - mailbox = talloc (ctx->format, mailbox_t); - mailbox->name = talloc_strdup (mailbox, name); - mailbox->addr = talloc_strdup (mailbox, addr); - mailbox->count = 1; + mailbox = new_mailbox (ctx->format, name, addr); + if (! mailbox) + return FALSE; + g_hash_table_insert (ctx->addresses, key, mailbox); return FALSE; @@ -411,6 +427,7 @@ do_search_messages (search_context_t *ctx) notmuch_filenames_t *filenames; sprinter_t *format = ctx->format; int i; + notmuch_status_t status; if (ctx->offset < 0) { ctx->offset += notmuch_query_count_messages (ctx->query); @@ -418,8 +435,8 @@ do_search_messages (search_context_t *ctx) ctx->offset = 0; } - messages = notmuch_query_search_messages (ctx->query); - if (messages == NULL) + status = notmuch_query_search_messages_st (ctx->query, &messages); + if (print_status_query ("notmuch search", ctx->query, status)) return 1; format->begin_list (format); @@ -507,8 +524,9 @@ do_search_tags (const search_context_t *ctx) if (strcmp (notmuch_query_get_query_string (query), "*") == 0) { tags = notmuch_database_get_all_tags (notmuch); } else { - messages = notmuch_query_search_messages (query); - if (messages == NULL) + notmuch_status_t status; + status = notmuch_query_search_messages_st (query, &messages); + if (print_status_query ("notmuch search", query, status)) return 1; tags = notmuch_messages_collect_tags (messages);