[Patch v4 10/12] lib: make a global constant for query parser flags
authorDavid Bremner <david@tethera.net>
Sun, 8 May 2016 00:04:47 +0000 (21:04 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:47 +0000 (16:21 -0700)
e7/171591d3b02c2380250d857899f9de7b992756 [new file with mode: 0644]

diff --git a/e7/171591d3b02c2380250d857899f9de7b992756 b/e7/171591d3b02c2380250d857899f9de7b992756
new file mode 100644 (file)
index 0000000..405a135
--- /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 DE3126DE098A\r
+ for <notmuch@notmuchmail.org>; Sat,  7 May 2016 17:05:37 -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 g8KkzRilCNcU for <notmuch@notmuchmail.org>;\r
+ Sat,  7 May 2016 17:05:30 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id F1E3C6DE0217\r
+ for <notmuch@notmuchmail.org>; Sat,  7 May 2016 17:05:04 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1azCDS-000157-TJ; Sat, 07 May 2016 20:04:58 -0400\r
+Received: (nullmailer pid 17201 invoked by uid 1000);\r
+ Sun, 08 May 2016 00:04:53 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 10/12] lib: make a global constant for query parser flags\r
+Date: Sat,  7 May 2016 21:04:47 -0300\r
+Message-Id: <1462665889-17121-11-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1462665889-17121-1-git-send-email-david@tethera.net>\r
+References: <1462665889-17121-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: Sun, 08 May 2016 00:05:38 -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