X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fquery.cc;h=60ff8bd9a39e1707e12a4e96cff99890b00d669b;hp=1cc768f887db5736fa1ec3399e68c9af32a6253e;hb=3fed6736a7ef8b8b1f05d0fabb136bdd3b5917ee;hpb=38698d86596af64fa25c118dafef0249155ca7a4 diff --git a/lib/query.cc b/lib/query.cc index 1cc768f8..60ff8bd9 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -80,7 +80,7 @@ notmuch_query_create (notmuch_database_t *notmuch, if (_debug_query ()) fprintf (stderr, "Query string is:\n%s\n", query_string); - query = talloc (NULL, notmuch_query_t); + query = talloc (notmuch, notmuch_query_t); if (unlikely (query == NULL)) return NULL; @@ -218,13 +218,15 @@ notmuch_query_search_messages (notmuch_query_t *query) } messages->base.excluded_doc_ids = NULL; - if (query->exclude_terms) { + if ((query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) && (query->exclude_terms)) { exclude_query = _notmuch_exclude_tags (query, final_query); - if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) + if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE || + query->omit_excluded == NOTMUCH_EXCLUDE_ALL) + { final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); - else { + } else { /* NOTMUCH_EXCLUDE_FLAG */ exclude_query = Xapian::Query (Xapian::Query::OP_AND, exclude_query, final_query); @@ -460,6 +462,9 @@ notmuch_threads_valid (notmuch_threads_t *threads) { unsigned int doc_id; + if (! threads) + return FALSE; + while (threads->doc_id_pos < threads->doc_ids->len) { doc_id = g_array_index (threads->doc_ids, unsigned int, threads->doc_id_pos);