From: David Bremner Date: Sat, 26 Mar 2016 17:57:22 +0000 (+2100) Subject: [Patch v2 12/13] lib: make a global constant for query parser flags X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cead28a8c0d1002c81d362ac553dbd57c5c7dced;p=notmuch-archives.git [Patch v2 12/13] lib: make a global constant for query parser flags --- diff --git a/42/32ef18b5b1e15e93c401f1abd08d8017c68913 b/42/32ef18b5b1e15e93c401f1abd08d8017c68913 new file mode 100644 index 000000000..14a500e4c --- /dev/null +++ b/42/32ef18b5b1e15e93c401f1abd08d8017c68913 @@ -0,0 +1,120 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 47AC26DE02D9 + for ; Sat, 26 Mar 2016 11:24:37 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.02 +X-Spam-Level: +X-Spam-Status: No, score=-0.02 tagged_above=-999 required=5 tests=[AWL=-0.021, + HEADER_FROM_DIFFERENT_DOMAINS=0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id lbk4zdSXNs8Z for ; + Sat, 26 Mar 2016 11:24:29 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 48C016DE02A9 + for ; Sat, 26 Mar 2016 11:23:25 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1ajsTX-0000vP-8b; Sat, 26 Mar 2016 13:58:15 -0400 +Received: (nullmailer pid 8826 invoked by uid 1000); + Sat, 26 Mar 2016 17:57:27 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [Patch v2 12/13] lib: make a global constant for query parser flags +Date: Sat, 26 Mar 2016 14:57:22 -0300 +Message-Id: <1459015043-8460-13-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.6.4 +In-Reply-To: <1459015043-8460-1-git-send-email-david@tethera.net> +References: <1459015043-8460-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 26 Mar 2016 18:24:37 -0000 + +It's already kindof gross that this is hardcoded in two different +places. We will also need these later in field processors calling back +into the query parser. +--- + lib/database-private.h | 4 ++++ + lib/query.cc | 16 ++-------------- + 2 files changed, 6 insertions(+), 14 deletions(-) + +diff --git a/lib/database-private.h b/lib/database-private.h +index e1962f4..b5c1f90 100644 +--- a/lib/database-private.h ++++ b/lib/database-private.h +@@ -144,6 +144,10 @@ operator&=(_notmuch_features &a, _notmuch_features b) + return a; + } + ++#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | \ ++ Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \ ++ Xapian::QueryParser::FLAG_WILDCARD | Xapian::QueryParser::FLAG_PURE_NOT) ++ + struct _notmuch_database { + notmuch_bool_t exception_reported; + +diff --git a/lib/query.cc b/lib/query.cc +index e627bfc..972a389 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -212,12 +212,6 @@ notmuch_query_search_messages_st (notmuch_query_t *query, + Xapian::Query string_query, final_query, exclude_query; + Xapian::MSet mset; + Xapian::MSetIterator iterator; +- unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | +- Xapian::QueryParser::FLAG_PHRASE | +- Xapian::QueryParser::FLAG_LOVEHATE | +- Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | +- Xapian::QueryParser::FLAG_WILDCARD | +- Xapian::QueryParser::FLAG_PURE_NOT); + + if (strcmp (query_string, "") == 0 || + strcmp (query_string, "*") == 0) +@@ -225,7 +219,7 @@ notmuch_query_search_messages_st (notmuch_query_t *query, + final_query = mail_query; + } else { + string_query = notmuch->query_parser-> +- parse_query (query_string, flags); ++ parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); + final_query = Xapian::Query (Xapian::Query::OP_AND, + mail_query, string_query); + } +@@ -565,12 +559,6 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out) + "mail")); + Xapian::Query string_query, final_query, exclude_query; + Xapian::MSet mset; +- unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | +- Xapian::QueryParser::FLAG_PHRASE | +- Xapian::QueryParser::FLAG_LOVEHATE | +- Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | +- Xapian::QueryParser::FLAG_WILDCARD | +- Xapian::QueryParser::FLAG_PURE_NOT); + + if (strcmp (query_string, "") == 0 || + strcmp (query_string, "*") == 0) +@@ -578,7 +566,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out) + final_query = mail_query; + } else { + string_query = notmuch->query_parser-> +- parse_query (query_string, flags); ++ parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); + final_query = Xapian::Query (Xapian::Query::OP_AND, + mail_query, string_query); + } +-- +2.6.4 +