[PATCH 12/13] lib: make a global constant for query parser flags
authorDavid Bremner <david@tethera.net>
Tue, 22 Mar 2016 10:54:53 +0000 (07:54 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:21 +0000 (16:21 -0700)
59/03b063cda27bec994d989ca60ea2f88e292114 [new file with mode: 0644]

diff --git a/59/03b063cda27bec994d989ca60ea2f88e292114 b/59/03b063cda27bec994d989ca60ea2f88e292114
new file mode 100644 (file)
index 0000000..2cf3bb8
--- /dev/null
@@ -0,0 +1,121 @@
+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 0BBDC6DE0361\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Mar 2016 03:56:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.029\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.029 tagged_above=-999 required=5\r
+ tests=[AWL=-0.018, 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 VkXr3PY6_VUd for <notmuch@notmuchmail.org>;\r
+ Tue, 22 Mar 2016 03:55:52 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 8AEA26DE02AF\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Mar 2016 03:55:23 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1aiJyh-00015O-2V; Tue, 22 Mar 2016 06:55:59 -0400\r
+Received: (nullmailer pid 14091 invoked by uid 1000);\r
+ Tue, 22 Mar 2016 10:55:11 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 12/13] lib: make a global constant for query parser flags\r
+Date: Tue, 22 Mar 2016 07:54:53 -0300\r
+Message-Id: <1458644094-13951-13-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.7.0\r
+In-Reply-To: <1458644094-13951-1-git-send-email-david@tethera.net>\r
+References: <1458644094-13951-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: Tue, 22 Mar 2016 10:56:00 -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 |  4 ++++\r
+ lib/query.cc           | 16 ++--------------\r
+ 2 files changed, 6 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/lib/database-private.h b/lib/database-private.h\r
+index 30a045e..59708d0 100644\r
+--- a/lib/database-private.h\r
++++ b/lib/database-private.h\r
+@@ -144,6 +144,10 @@ operator&=(_notmuch_features &a, _notmuch_features b)\r
+     return a;\r
+ }\r
\r
++#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | \\r
++                                  Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \\r
++                                  Xapian::QueryParser::FLAG_WILDCARD | Xapian::QueryParser::FLAG_PURE_NOT)\r
++\r
+ #if HAVE_XAPIAN_FIELD_PROCESSOR\r
+ class DateFieldProcessor;\r
+ #endif\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index e627bfc..972a389 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -212,12 +212,6 @@ notmuch_query_search_messages_st (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
+@@ -225,7 +219,7 @@ notmuch_query_search_messages_st (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
+@@ -565,12 +559,6 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)\r
+                                                  "mail"));\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
+@@ -578,7 +566,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)\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.7.0\r
+\r