[Patch v5 10/11] lib: make a global constant for query parser flags
authorDavid Bremner <david@tethera.net>
Fri, 13 May 2016 10:38:12 +0000 (07:38 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:49 +0000 (16:21 -0700)
37/79cd554d56d7d1e319704755fa8d588989df42 [new file with mode: 0644]

diff --git a/37/79cd554d56d7d1e319704755fa8d588989df42 b/37/79cd554d56d7d1e319704755fa8d588989df42
new file mode 100644 (file)
index 0000000..56a0a9d
--- /dev/null
@@ -0,0 +1,124 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id F23246DE096D\r
+ for <notmuch@notmuchmail.org>; Fri, 13 May 2016 03:39:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.013\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.013 tagged_above=-999 required=5\r
+ tests=[AWL=-0.002, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id iF6isvrOyA6N for <notmuch@notmuchmail.org>;\r
+ Fri, 13 May 2016 03:39:02 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id B336D6DE0355\r
+ for <notmuch@notmuchmail.org>; Fri, 13 May 2016 03:38:30 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1b1AUB-0003Pj-Oa; Fri, 13 May 2016 06:38:23 -0400\r
+Received: (nullmailer pid 7564 invoked by uid 1000);\r
+ Fri, 13 May 2016 10:38:17 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v5 10/11] lib: make a global constant for query parser flags\r
+Date: Fri, 13 May 2016 07:38:12 -0300\r
+Message-Id: <1463135893-7471-11-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1463135893-7471-1-git-send-email-david@tethera.net>\r
+References: <1463135893-7471-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 13 May 2016 10:39:10 -0000\r
+\r
+It's already kindof gross that this is hardcoded in two different\r
+places. We will also need these later in field processors calling back\r
+into the query parser.\r
+---\r
+ lib/database-private.h |  7 +++++++\r
+ lib/query.cc           | 16 ++--------------\r
+ 2 files changed, 9 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/lib/database-private.h b/lib/database-private.h\r
+index e1962f4..d2990b6 100644\r
+--- a/lib/database-private.h\r
++++ b/lib/database-private.h\r
+@@ -144,6 +144,13 @@ operator&=(_notmuch_features &a, _notmuch_features b)\r
+     return a;\r
+ }\r
\r
++#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | \\r
++                                  Xapian::QueryParser::FLAG_PHRASE | \\r
++                                  Xapian::QueryParser::FLAG_LOVEHATE | \\r
++                                  Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \\r
++                                  Xapian::QueryParser::FLAG_WILDCARD | \\r
++                                  Xapian::QueryParser::FLAG_PURE_NOT)\r
++\r
+ struct _notmuch_database {\r
+     notmuch_bool_t exception_reported;\r
\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 77a7926..0875b0e 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -220,12 +220,6 @@ _notmuch_query_search_documents (notmuch_query_t *query,\r
+       Xapian::Query string_query, final_query, exclude_query;\r
+       Xapian::MSet mset;\r
+       Xapian::MSetIterator iterator;\r
+-      unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
+-                            Xapian::QueryParser::FLAG_PHRASE |\r
+-                            Xapian::QueryParser::FLAG_LOVEHATE |\r
+-                            Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE |\r
+-                            Xapian::QueryParser::FLAG_WILDCARD |\r
+-                            Xapian::QueryParser::FLAG_PURE_NOT);\r
\r
+       if (strcmp (query_string, "") == 0 ||\r
+           strcmp (query_string, "*") == 0)\r
+@@ -233,7 +227,7 @@ _notmuch_query_search_documents (notmuch_query_t *query,\r
+           final_query = mail_query;\r
+       } else {\r
+           string_query = notmuch->query_parser->\r
+-              parse_query (query_string, flags);\r
++              parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS);\r
+           final_query = Xapian::Query (Xapian::Query::OP_AND,\r
+                                        mail_query, string_query);\r
+       }\r
+@@ -579,12 +573,6 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign\r
+                                                  type));\r
+       Xapian::Query string_query, final_query, exclude_query;\r
+       Xapian::MSet mset;\r
+-      unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
+-                            Xapian::QueryParser::FLAG_PHRASE |\r
+-                            Xapian::QueryParser::FLAG_LOVEHATE |\r
+-                            Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE |\r
+-                            Xapian::QueryParser::FLAG_WILDCARD |\r
+-                            Xapian::QueryParser::FLAG_PURE_NOT);\r
\r
+       if (strcmp (query_string, "") == 0 ||\r
+           strcmp (query_string, "*") == 0)\r
+@@ -592,7 +580,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign\r
+           final_query = mail_query;\r
+       } else {\r
+           string_query = notmuch->query_parser->\r
+-              parse_query (query_string, flags);\r
++              parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS);\r
+           final_query = Xapian::Query (Xapian::Query::OP_AND,\r
+                                        mail_query, string_query);\r
+       }\r
+-- \r
+2.8.1\r
+\r