From 1835f317c515a983c03136d8ba33737472298302 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 8 May 2016 21:04:47 +2100 Subject: [PATCH] [Patch v4 10/12] lib: make a global constant for query parser flags --- e7/171591d3b02c2380250d857899f9de7b992756 | 124 ++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 e7/171591d3b02c2380250d857899f9de7b992756 diff --git a/e7/171591d3b02c2380250d857899f9de7b992756 b/e7/171591d3b02c2380250d857899f9de7b992756 new file mode 100644 index 000000000..405a13531 --- /dev/null +++ b/e7/171591d3b02c2380250d857899f9de7b992756 @@ -0,0 +1,124 @@ +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 DE3126DE098A + for ; Sat, 7 May 2016 17:05:37 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.013 +X-Spam-Level: +X-Spam-Status: No, score=-0.013 tagged_above=-999 required=5 + tests=[AWL=-0.002, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] + 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 g8KkzRilCNcU for ; + Sat, 7 May 2016 17:05:30 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id F1E3C6DE0217 + for ; Sat, 7 May 2016 17:05:04 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1azCDS-000157-TJ; Sat, 07 May 2016 20:04:58 -0400 +Received: (nullmailer pid 17201 invoked by uid 1000); + Sun, 08 May 2016 00:04:53 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [Patch v4 10/12] lib: make a global constant for query parser flags +Date: Sat, 7 May 2016 21:04:47 -0300 +Message-Id: <1462665889-17121-11-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.1 +In-Reply-To: <1462665889-17121-1-git-send-email-david@tethera.net> +References: <1462665889-17121-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: Sun, 08 May 2016 00:05:38 -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 | 7 +++++++ + lib/query.cc | 16 ++-------------- + 2 files changed, 9 insertions(+), 14 deletions(-) + +diff --git a/lib/database-private.h b/lib/database-private.h +index e1962f4..d2990b6 100644 +--- a/lib/database-private.h ++++ b/lib/database-private.h +@@ -144,6 +144,13 @@ 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 77a7926..0875b0e 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -220,12 +220,6 @@ _notmuch_query_search_documents (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) +@@ -233,7 +227,7 @@ _notmuch_query_search_documents (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); + } +@@ -579,12 +573,6 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign + type)); + 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) +@@ -592,7 +580,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign + 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.8.1 + -- 2.26.2