[Patch v6 6/7] lib: make a global constant for query parser flags
authorDavid Bremner <david@tethera.net>
Wed, 25 May 2016 10:51:25 +0000 (07:51 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:53 +0000 (16:21 -0700)
e7/2dfd5d093a1b9476a4130284494ba094f0b3da [new file with mode: 0644]

diff --git a/e7/2dfd5d093a1b9476a4130284494ba094f0b3da b/e7/2dfd5d093a1b9476a4130284494ba094f0b3da
new file mode 100644 (file)
index 0000000..5c75ab3
--- /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 980E86DE092C\r
+ for <notmuch@notmuchmail.org>; Wed, 25 May 2016 03:52:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.012\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5\r
+ tests=[AWL=-0.001, 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 J5tJMWismH6o for <notmuch@notmuchmail.org>;\r
+ Wed, 25 May 2016 03:51:53 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id EA17F6DE025F\r
+ for <notmuch@notmuchmail.org>; Wed, 25 May 2016 03:51:37 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1b5WPQ-0004UB-Jf; Wed, 25 May 2016 06:51:28 -0400\r
+Received: (nullmailer pid 23148 invoked by uid 1000);\r
+ Wed, 25 May 2016 10:51:31 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v6 6/7] lib: make a global constant for query parser flags\r
+Date: Wed, 25 May 2016 07:51:25 -0300\r
+Message-Id: <1464173486-23032-7-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1464173486-23032-1-git-send-email-david@tethera.net>\r
+References: <1464173486-23032-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: Wed, 25 May 2016 10:52: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 |  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